In imagetools project folder src/code/geolocation/ there is three classes: city, cities y kdtree.
KDTree is data structure to store all locations provide by cities1000.txt
City is the model of a city with attributes which identify a city information as Name, Country, Continent, Prefix, etc
Cities is a singleton class which contains two private attributes KDTree m_citiesTree and QMap<QString, City*> m_citiesMap. Also, contains two functions parseCities and findCity The first m_citiesTree is the KDETree The second m_citiesMap is a Map whose key is the name of a city and the Value is a pointer to a City object. This Map is used to get City from a Coordinates, this coordinates are the nearest point between the coordinates read from image metadata and a point in KDTree.
ParseCities load from cities1000.txt in the first instance all location in the KDTree FindCity find the nearest point in KDTree of a point received by parameters and then find this coordinates in the Map to return the city name.
Cities singleton class is instanced in Gallery constructor and then in picinfomodel.cpp call extractor.GPSString() the complete FMLMODEL with city location.