data/PlaceGazetteer.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QString> | ||
| 4 | |||
| 5 | #include "data/ContactModels.h" | ||
| 6 | #include "data/GeoData.h" | ||
| 7 | |||
| 8 | // Offline geocoder (Sprint 103 S103.1.8, D-10): places a postal address or | ||
| 9 | // a place text with the bundled GeoData — nothing leaves the computer. | ||
| 10 | // | ||
| 11 | // Precedence for an address (the pinned ADR;GEO and the card GEO are applied | ||
| 12 | // before, by ContactPeopleStore): postal code (DE/AT/CH) → city → region → | ||
| 13 | // country. The country comes from the address, else from `defaultCountry` | ||
| 14 | // (ISO 3166 alpha-2 of the user's locale). The result keeps its precision so | ||
| 15 | // the UI can say "approximate" (§6.2 principle 6) and the time zone of the | ||
| 16 | // place (I-6 local time). | ||
| 17 | namespace PlaceGazetteer { | ||
| 18 | |||
| 19 | struct Place { | ||
| 20 | GeoPoint position; | ||
| 21 | QString precision; // "postal", "city", "region", "country" ("" = not placed) | ||
| 22 | QString timeZone; // IANA name, "" when unknown | ||
| 23 | QString placeName; // city (GeoNames name), region or country in English | ||
| 24 | QString countryIso; // "DE", "PT", … | ||
| 25 | 6169 | bool isValid() const { return position.valid; } | |
| 26 | }; | ||
| 27 | |||
| 28 | // The postal code normalised for its country ("D-10115" → "10115", | ||
| 29 | // "1010 " → "1010"); "" when it does not look like one of that country. | ||
| 30 | QString normalizedPostalCode(const QString &countryIso, const QString &code); | ||
| 31 | // A stable key of the address text for place_cache (folded, components in | ||
| 32 | // order); identical addresses of different cards share one cache entry. | ||
| 33 | QString addressKey(const ContactAddress &address); | ||
| 34 | |||
| 35 | Place locate(const GeoData &data, const ContactAddress &address, const QString &defaultCountry = {}); | ||
| 36 | // A free place text ("Lisbon", "Porto, Portugal", "Chaos Communication | ||
| 37 | // Camp, Mildenberg"): the last comma part that names a country restricts | ||
| 38 | // the cities; the other parts are tried as city names from the end. | ||
| 39 | Place locateText(const GeoData &data, const QString &text, const QString &defaultCountry = {}); | ||
| 40 | |||
| 41 | } // namespace PlaceGazetteer | ||
| 42 |