25 #ifndef DIGIKAM_PARSE_TAG_STRING_H
26 #define DIGIKAM_PARSE_TAG_STRING_H
38 QString auxReturnedFormat = inputFormat;
39 QString returnedAddress = inputFormat;
40 QString returnedFormat;
42 QStringList returnedAddressElements;
44 int indexFBracket = -1;
46 while ((indexFBracket = returnedAddress.indexOf(QLatin1String(
"{"))) >= 0)
48 int indexLBracket = returnedAddress.indexOf(QLatin1String(
"}"));
49 QString humanTag = returnedAddress.mid(indexFBracket + 1, indexLBracket - indexFBracket - 1);
50 int indexFormatFBracket1 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
51 auxReturnedFormat.replace(indexFormatFBracket1 - 1, humanTag.length() + 3, QLatin1String(
""));
52 bool dataAdded =
false;
55 if (backendName == QLatin1String(
"OSM"))
57 if (humanTag == QLatin1String(
"Country"))
59 if (!info.
rgData[QLatin1String(
"country")].isEmpty())
61 result = info.
rgData[QLatin1String(
"country")];
62 returnedFormat.append(QLatin1String(
"/{Country}"));
66 else if (humanTag == QLatin1String(
"State district"))
68 if (!info.
rgData[QLatin1String(
"state_district")].isEmpty())
70 result = info.
rgData[QLatin1String(
"state_district")];
71 returnedFormat.append(QLatin1String(
"/{State district}"));
75 else if (humanTag == QLatin1String(
"County"))
77 if (!info.
rgData[QLatin1String(
"county")].isEmpty())
79 result = info.
rgData[QLatin1String(
"county")];
80 returnedFormat.append(QLatin1String(
"/{County}"));
84 else if (humanTag == QLatin1String(
"City"))
86 if (!info.
rgData[QLatin1String(
"city")].isEmpty())
88 result = info.
rgData[QLatin1String(
"city")];
89 returnedFormat.append(QLatin1String(
"/{City}"));
93 else if (humanTag == QLatin1String(
"City district"))
95 if (!info.
rgData[QLatin1String(
"city_district")].isEmpty())
97 result = info.
rgData[QLatin1String(
"city_district")];
98 returnedFormat.append(QLatin1String(
"/{City district}"));
102 else if (humanTag == QLatin1String(
"Suburb"))
104 if (!info.
rgData[QLatin1String(
"suburb")].isEmpty())
106 result = info.
rgData[QLatin1String(
"suburb")];
107 returnedFormat.append(QLatin1String(
"/{Suburb}"));
111 else if (humanTag == QLatin1String(
"Street"))
113 if (!info.
rgData[QLatin1String(
"road")].isEmpty())
115 result = info.
rgData[QLatin1String(
"road")];
116 returnedFormat.append(QLatin1String(
"/{Street}"));
120 else if (humanTag == QLatin1String(
"State"))
122 if (!info.
rgData[QLatin1String(
"state")].isEmpty())
124 result = info.
rgData[QLatin1String(
"state")];
125 returnedFormat.append(QLatin1String(
"/{State}"));
129 else if (humanTag == QLatin1String(
"Town"))
131 if (!info.
rgData[QLatin1String(
"town")].isEmpty())
133 result = info.
rgData[QLatin1String(
"town")];
134 returnedFormat.append(QLatin1String(
"/{Town}"));
138 else if (humanTag == QLatin1String(
"Village"))
140 if (!info.
rgData[QLatin1String(
"village")].isEmpty())
142 result = info.
rgData[QLatin1String(
"village")];
143 returnedFormat.append(QLatin1String(
"/{Village}"));
147 else if (humanTag == QLatin1String(
"Hamlet"))
149 if (!info.
rgData[QLatin1String(
"hamlet")].isEmpty())
151 result = info.
rgData[QLatin1String(
"hamlet")];
152 returnedFormat.append(QLatin1String(
"/{Hamlet}"));
156 else if (humanTag == QLatin1String(
"House number"))
158 if (!info.
rgData[QLatin1String(
"house_number")].isEmpty())
160 result = info.
rgData[QLatin1String(
"house_number")];
161 returnedFormat.append(QLatin1String(
"/{House number}"));
167 returnedAddress.replace(indexFBracket - 1, indexLBracket - indexFBracket + 2, QLatin1String(
""));
169 int indexFormatFBracket2 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
170 int indexFormatLBracket = auxReturnedFormat.indexOf(QLatin1String(
"}"));
171 auxReturnedFormat.replace(indexFormatFBracket2 - 1,
172 indexFormatLBracket - indexFormatFBracket2 + 2,
178 else if (backendName == QLatin1String(
"GeonamesUS"))
181 if (humanTag.compare(QLatin1String(
"LAU2")) == 0)
183 if (!info.
rgData[QLatin1String(
"adminName2")].isEmpty())
185 result = info.
rgData[QLatin1String(
"adminName2")];
186 returnedFormat.append(QLatin1String(
"/{LAU2}"));
191 else if (humanTag == QLatin1String(
"LAU1"))
193 if (!info.
rgData[QLatin1String(
"adminName1")].isEmpty())
195 result = info.
rgData[QLatin1String(
"adminName1")];
196 returnedFormat.append(QLatin1String(
"/{LAU1}"));
201 else if (humanTag == QLatin1String(
"City"))
203 if (!info.
rgData[QLatin1String(
"placename")].isEmpty())
205 result = info.
rgData[QLatin1String(
"placename")];
206 returnedFormat.append(QLatin1String(
"/{City}"));
212 returnedAddress.replace(indexFBracket - 1,
213 indexLBracket - indexFBracket + 2,
216 int indexFormatFBracket3 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
217 int indexFormatLBracket = auxReturnedFormat.indexOf(QLatin1String(
"}"));
218 auxReturnedFormat.replace(indexFormatFBracket3 - 1,
219 indexFormatLBracket - indexFormatFBracket3 + 2,
225 else if (backendName == QLatin1String(
"Geonames"))
227 if (humanTag.compare(QLatin1String(
"Country")) == 0)
229 if (!info.
rgData[QLatin1String(
"countryName")].isEmpty())
231 result = info.
rgData[QLatin1String(
"countryName")];
232 returnedFormat.append(QLatin1String(
"/{Country}"));
237 else if (humanTag == QLatin1String(
"Place"))
239 if (!info.
rgData[QLatin1String(
"name")].isEmpty())
241 result = info.
rgData[QLatin1String(
"name")];
242 returnedFormat.append(QLatin1String(
"/{Place}"));
248 returnedAddress.replace(indexFBracket - 1,
249 indexLBracket - indexFBracket + 2,
252 int indexFormatFBracket4 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
253 int indexFormatLBracket = auxReturnedFormat.indexOf(QLatin1String(
"}"));
254 auxReturnedFormat.replace(indexFormatFBracket4 - 1,
255 indexFormatLBracket - indexFormatFBracket4 + 2,
263 returnedAddress.replace(indexFBracket - 1, humanTag.length() + 3, QLatin1String(
""));
267 returnedAddress.replace(indexFBracket, humanTag.length() + 2, result);
271 returnedAddressElements.append(returnedFormat);
272 returnedAddressElements.append(returnedAddress);
274 return returnedAddressElements;
This class contains data needed in reverse geocoding process.
Definition: rginfo.h:48
QMap< QString, QString > rgData
Definition: rginfo.h:76
Definition: datefolderview.cpp:43
QStringList makeTagString(const RGInfo &info, const QString &inputFormat, const QString &backendName)
Definition: parsetagstring.h:36