28 QString auxReturnedFormat = inputFormat;
29 QString returnedAddress = inputFormat;
30 QString returnedFormat;
32 QStringList returnedAddressElements;
34 int indexFBracket = -1;
36 while ((indexFBracket = returnedAddress.indexOf(QLatin1String(
"{"))) >= 0)
38 int indexLBracket = returnedAddress.indexOf(QLatin1String(
"}"));
39 QString humanTag = returnedAddress.mid(indexFBracket + 1, indexLBracket - indexFBracket - 1);
40 int indexFormatFBracket1 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
41 auxReturnedFormat.replace(indexFormatFBracket1 - 1, humanTag.length() + 3, QLatin1String(
""));
42 bool dataAdded =
false;
45 if (backendName == QLatin1String(
"OSM"))
47 if (humanTag == QLatin1String(
"Country"))
49 if (!info.
rgData[QLatin1String(
"country")].isEmpty())
51 result = info.
rgData[QLatin1String(
"country")];
52 returnedFormat.append(QLatin1String(
"/{Country}"));
56 else if (humanTag == QLatin1String(
"Country code"))
58 if (!info.
rgData[QLatin1String(
"country_code")].isEmpty())
60 result = info.
rgData[QLatin1String(
"country_code")];
61 returnedFormat.append(QLatin1String(
"/{Country code}"));
65 else if (humanTag == QLatin1String(
"State district"))
67 if (!info.
rgData[QLatin1String(
"state_district")].isEmpty())
69 result = info.
rgData[QLatin1String(
"state_district")];
70 returnedFormat.append(QLatin1String(
"/{State district}"));
74 else if (humanTag == QLatin1String(
"County"))
76 if (!info.
rgData[QLatin1String(
"county")].isEmpty())
78 result = info.
rgData[QLatin1String(
"county")];
79 returnedFormat.append(QLatin1String(
"/{County}"));
83 else if (humanTag == QLatin1String(
"City"))
85 if (!info.
rgData[QLatin1String(
"city")].isEmpty())
87 result = info.
rgData[QLatin1String(
"city")];
88 returnedFormat.append(QLatin1String(
"/{City}"));
92 else if (humanTag == QLatin1String(
"City district"))
94 if (!info.
rgData[QLatin1String(
"city_district")].isEmpty())
96 result = info.
rgData[QLatin1String(
"city_district")];
97 returnedFormat.append(QLatin1String(
"/{City district}"));
101 else if (humanTag == QLatin1String(
"Suburb"))
103 if (!info.
rgData[QLatin1String(
"suburb")].isEmpty())
105 result = info.
rgData[QLatin1String(
"suburb")];
106 returnedFormat.append(QLatin1String(
"/{Suburb}"));
110 else if (humanTag == QLatin1String(
"Street"))
112 if (!info.
rgData[QLatin1String(
"road")].isEmpty())
114 result = info.
rgData[QLatin1String(
"road")];
115 returnedFormat.append(QLatin1String(
"/{Street}"));
119 else if (humanTag == QLatin1String(
"State"))
121 if (!info.
rgData[QLatin1String(
"state")].isEmpty())
123 result = info.
rgData[QLatin1String(
"state")];
124 returnedFormat.append(QLatin1String(
"/{State}"));
128 else if (humanTag == QLatin1String(
"Town"))
130 if (!info.
rgData[QLatin1String(
"town")].isEmpty())
132 result = info.
rgData[QLatin1String(
"town")];
133 returnedFormat.append(QLatin1String(
"/{Town}"));
137 else if (humanTag == QLatin1String(
"Village"))
139 if (!info.
rgData[QLatin1String(
"village")].isEmpty())
141 result = info.
rgData[QLatin1String(
"village")];
142 returnedFormat.append(QLatin1String(
"/{Village}"));
146 else if (humanTag == QLatin1String(
"Hamlet"))
148 if (!info.
rgData[QLatin1String(
"hamlet")].isEmpty())
150 result = info.
rgData[QLatin1String(
"hamlet")];
151 returnedFormat.append(QLatin1String(
"/{Hamlet}"));
155 else if (humanTag == QLatin1String(
"House number"))
157 if (!info.
rgData[QLatin1String(
"house_number")].isEmpty())
159 result = info.
rgData[QLatin1String(
"house_number")];
160 returnedFormat.append(QLatin1String(
"/{House number}"));
166 returnedAddress.replace(indexFBracket - 1, indexLBracket - indexFBracket + 2, QLatin1String(
""));
168 int indexFormatFBracket2 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
169 int indexFormatLBracket = auxReturnedFormat.indexOf(QLatin1String(
"}"));
170 auxReturnedFormat.replace(indexFormatFBracket2 - 1,
171 indexFormatLBracket - indexFormatFBracket2 + 2,
177 else if (backendName == QLatin1String(
"GeonamesUS"))
179 if (humanTag.compare(QLatin1String(
"LAU2")) == 0)
181 if (!info.
rgData[QLatin1String(
"adminName2")].isEmpty())
183 result = info.
rgData[QLatin1String(
"adminName2")];
184 returnedFormat.append(QLatin1String(
"/{LAU2}"));
188 else if (humanTag == QLatin1String(
"LAU1"))
190 if (!info.
rgData[QLatin1String(
"adminName1")].isEmpty())
192 result = info.
rgData[QLatin1String(
"adminName1")];
193 returnedFormat.append(QLatin1String(
"/{LAU1}"));
197 else if (humanTag == QLatin1String(
"City"))
199 if (!info.
rgData[QLatin1String(
"placename")].isEmpty())
201 result = info.
rgData[QLatin1String(
"placename")];
202 returnedFormat.append(QLatin1String(
"/{City}"));
208 returnedAddress.replace(indexFBracket - 1,
209 indexLBracket - indexFBracket + 2,
212 int indexFormatFBracket3 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
213 int indexFormatLBracket = auxReturnedFormat.indexOf(QLatin1String(
"}"));
214 auxReturnedFormat.replace(indexFormatFBracket3 - 1,
215 indexFormatLBracket - indexFormatFBracket3 + 2,
221 else if (backendName == QLatin1String(
"Geonames"))
223 if (humanTag.compare(QLatin1String(
"Country")) == 0)
225 if (!info.
rgData[QLatin1String(
"countryName")].isEmpty())
227 result = info.
rgData[QLatin1String(
"countryName")];
228 returnedFormat.append(QLatin1String(
"/{Country}"));
232 else if (humanTag.compare(QLatin1String(
"Country code")) == 0)
234 if (!info.
rgData[QLatin1String(
"countryCode")].isEmpty())
236 result = info.
rgData[QLatin1String(
"countryCode")];
237 returnedFormat.append(QLatin1String(
"/{Country code}"));
241 else if (humanTag == QLatin1String(
"Place"))
243 if (!info.
rgData[QLatin1String(
"name")].isEmpty())
245 result = info.
rgData[QLatin1String(
"name")];
246 returnedFormat.append(QLatin1String(
"/{Place}"));
252 returnedAddress.replace(indexFBracket - 1,
253 indexLBracket - indexFBracket + 2,
256 int indexFormatFBracket4 = auxReturnedFormat.indexOf(QLatin1String(
"{"));
257 int indexFormatLBracket = auxReturnedFormat.indexOf(QLatin1String(
"}"));
258 auxReturnedFormat.replace(indexFormatFBracket4 - 1,
259 indexFormatLBracket - indexFormatFBracket4 + 2,
267 returnedAddress.replace(indexFBracket - 1, humanTag.length() + 3, QLatin1String(
""));
271 returnedAddress.replace(indexFBracket, humanTag.length() + 2, result);
275 returnedAddressElements.append(returnedFormat);
276 returnedAddressElements.append(returnedAddress);
278 return returnedAddressElements;