File indexing completed on 2024-05-12 04:21:08
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2015 Vishesh Handa <me@vhanda.in> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef KOKO_REVERSEGEOCODER_H 0008 #define KOKO_REVERSEGEOCODER_H 0009 0010 #include <QMutexLocker> 0011 #include <QVariantMap> 0012 #include <kdtree.h> 0013 0014 namespace Koko 0015 { 0016 class ReverseGeoCoder 0017 { 0018 public: 0019 ~ReverseGeoCoder(); 0020 0021 void init(); 0022 bool initialized(); 0023 0024 // Do nothing if it's already initialized 0025 void tryInitialization(); 0026 0027 /** 0028 * The ReverseGeoCoder consumes a significant amount of memory (around 100mb). It 0029 * makes sense to deinit it when it is not being used. 0030 */ 0031 void deinit(); 0032 0033 QVariantMap lookup(double lat, double lon); 0034 0035 private: 0036 KdTree m_tree; 0037 QMap<QString, QString> m_countryMap; 0038 QMap<QString, QString> m_admin1Map; 0039 QMap<QString, QString> m_admin2Map; 0040 QMutex m_mutex; 0041 }; 0042 } 0043 0044 #endif // KOKO_REVERSEGEOCODER_H