File indexing completed on 2024-04-28 03:50:35

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2015 Constantin Mihalache <mihalache.c94@gmail.com>
0004 //
0005 
0006 #ifndef OPENLOCATIONCODESEARCHRUNNER_H
0007 #define OPENLOCATIONCODESEARCHRUNNER_H
0008 
0009 #include "SearchRunner.h"
0010 #include "GeoDataLatLonBox.h"
0011 #include "MarbleDebug.h"
0012 
0013 namespace Marble
0014 {
0015 
0016 class GeoDataPolygon;
0017 
0018 class OpenLocationCodeSearchRunner : public SearchRunner
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit OpenLocationCodeSearchRunner( QObject *parent = nullptr );
0023 
0024     void search( const QString &searchTerm, const GeoDataLatLonBox &preferred ) override;
0025 
0026 private:
0027 
0028     /**
0029      * Makes a GeoDataPolygon which contains the boundary points of the
0030      * boundingBox parameter.
0031      */
0032     GeoDataPolygon polygonFromLatLonBox( const GeoDataLatLonBox& boundingBox ) const;
0033 
0034     /**
0035      * Decode a valid open location code string into a GeoDataLatLonBox.
0036      */
0037     GeoDataLatLonBox decodeOLC( const QString &ocl ) const;
0038 
0039     /**
0040      * Decide if the string is a valid & full open location code.
0041      */
0042     bool isValidOLC( const QString &ocl ) const;
0043 
0044     /**
0045      * Maps each character from the accepted chars to its corresponding index
0046      * inside the string.
0047      */
0048     QHash<QChar, int> charIndex;
0049 };
0050 
0051 }
0052 
0053 #endif // OPENLOCATIONCODESEARCHRUNNER_H