diff --git a/src/plugins/runner/CMakeLists.txt b/src/plugins/runner/CMakeLists.txt --- a/src/plugins/runner/CMakeLists.txt +++ b/src/plugins/runner/CMakeLists.txt @@ -1,5 +1,6 @@ # Search and/or reverse geocoding add_subdirectory( hostip ) +add_subdirectory( geouri ) add_subdirectory( latlon ) add_subdirectory( local-osm-search ) add_subdirectory( localdatabase ) diff --git a/src/plugins/runner/geouri/CMakeLists.txt b/src/plugins/runner/geouri/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/plugins/runner/geouri/CMakeLists.txt @@ -0,0 +1,10 @@ +PROJECT( GeoUriPlugin ) + +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + +set( geouri_SRCS GeoUriRunner.cpp GeoUriPlugin.cpp ) + +marble_add_plugin( GeoUriPlugin ${geouri_SRCS} ) diff --git a/src/plugins/runner/geouri/GeoUriPlugin.h b/src/plugins/runner/geouri/GeoUriPlugin.h new file mode 100644 --- /dev/null +++ b/src/plugins/runner/geouri/GeoUriPlugin.h @@ -0,0 +1,47 @@ +// +// This file is part of the Marble Virtual Globe. +// +// This program is free software licensed under the GNU LGPL. You can +// find a copy of this license in LICENSE.txt in the top directory of +// the source code. +// +// Copyright 2016 Friedrich W. H. Kossebau +// + +#ifndef MARBLE_GEOURIPLUGIN_H +#define MARBLE_GEOURIPLUGIN_H + +#include "SearchRunnerPlugin.h" + +namespace Marble +{ + +class GeoUriPlugin : public SearchRunnerPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA( IID "org.kde.edu.marble.GeoUriPlugin" ) + Q_INTERFACES( Marble::SearchRunnerPlugin ) + +public: + explicit GeoUriPlugin(QObject *parent = nullptr); + + QString name() const override; + + QString guiString() const override; + + QString nameId() const override; + + QString version() const override; + + QString description() const override; + + QString copyrightYears() const override; + + QList pluginAuthors() const override; + + SearchRunner* newRunner() const override; +}; + +} + +#endif diff --git a/src/plugins/runner/geouri/GeoUriPlugin.cpp b/src/plugins/runner/geouri/GeoUriPlugin.cpp new file mode 100644 --- /dev/null +++ b/src/plugins/runner/geouri/GeoUriPlugin.cpp @@ -0,0 +1,68 @@ +// +// This file is part of the Marble Virtual Globe. +// +// This program is free software licensed under the GNU LGPL. You can +// find a copy of this license in LICENSE.txt in the top directory of +// the source code. +// +// Copyright 2016 Friedrich W. H. Kossebau +// + +#include "GeoUriPlugin.h" + +#include "GeoUriRunner.h" + +namespace Marble +{ + +GeoUriPlugin::GeoUriPlugin(QObject *parent) + : SearchRunnerPlugin(parent) +{ +} + +QString GeoUriPlugin::name() const +{ + return tr("Geo URI Search"); +} + +QString GeoUriPlugin::guiString() const +{ + return tr("Geo URI"); +} + +QString GeoUriPlugin::nameId() const +{ + return QStringLiteral("geouri"); +} + +QString GeoUriPlugin::version() const +{ + return QStringLiteral("1.0"); +} + +QString GeoUriPlugin::description() const +{ + return tr("Input of geographic coordinates by the geo URI scheme"); +} + +QString GeoUriPlugin::copyrightYears() const +{ + return QStringLiteral("2016"); +} + +QList GeoUriPlugin::pluginAuthors() const +{ + return QList() + << PluginAuthor(QStringLiteral("Friedrich W. H. Kossebau"), QStringLiteral("kossebau@kde.org")); +} + +SearchRunner* GeoUriPlugin::newRunner() const +{ + return new GeoUriRunner; +} + +} + +Q_EXPORT_PLUGIN2( GeoUriPlugin, Marble::GeoUriPlugin ) + +#include "moc_GeoUriPlugin.cpp" diff --git a/src/plugins/runner/geouri/GeoUriRunner.h b/src/plugins/runner/geouri/GeoUriRunner.h new file mode 100644 --- /dev/null +++ b/src/plugins/runner/geouri/GeoUriRunner.h @@ -0,0 +1,32 @@ +// +// This file is part of the Marble Virtual Globe. +// +// This program is free software licensed under the GNU LGPL. You can +// find a copy of this license in LICENSE.txt in the top directory of +// the source code. +// +// Copyright 2016 Friedrich W. H. Kossebau +// + +#ifndef MARBLE_GEOURIRUNNER_H +#define MARBLE_GEOURIRUNNER_H + +#include "SearchRunner.h" + +namespace Marble +{ + +class GeoUriRunner : public SearchRunner +{ + Q_OBJECT + +public: + explicit GeoUriRunner(QObject *parent = nullptr); + ~GeoUriRunner() override; + + void search(const QString &searchTerm, const GeoDataLatLonBox &preferred) override; +}; + +} + +#endif diff --git a/src/plugins/runner/geouri/GeoUriRunner.cpp b/src/plugins/runner/geouri/GeoUriRunner.cpp new file mode 100644 --- /dev/null +++ b/src/plugins/runner/geouri/GeoUriRunner.cpp @@ -0,0 +1,58 @@ +// +// This file is part of the Marble Virtual Globe. +// +// This program is free software licensed under the GNU LGPL. You can +// find a copy of this license in LICENSE.txt in the top directory of +// the source code. +// +// Copyright 2016 Friedrich W. H. Kossebau + +#include "GeoUriRunner.h" + +#include "GeoDataFeature.h" +#include "GeoDataPlacemark.h" +#include "GeoDataCoordinates.h" +#include "GeoUriParser.h" +#include "MarbleModel.h" + +#include "MarbleDebug.h" +#include + + +namespace Marble +{ + +GeoUriRunner::GeoUriRunner(QObject *parent) + : SearchRunner(parent) +{ +} + + +GeoUriRunner::~GeoUriRunner() +{ +} + +void GeoUriRunner::search(const QString &searchTerm, const GeoDataLatLonBox &) +{ + QVector vector; + + GeoUriParser uriParser(searchTerm); + const bool success = uriParser.parse(); + if (success && + (uriParser.planet().id() == model()->planet()->id())) { + const GeoDataCoordinates coordinates = uriParser.coordinates(); + + GeoDataPlacemark *placemark = new GeoDataPlacemark; + placemark->setName(searchTerm); + placemark->setCoordinate(coordinates); + placemark->setVisualCategory(GeoDataFeature::Coordinate); + placemark->setPopularity(1000000000); + placemark->setZoomLevel(1); + + vector.append(placemark); + } + + emit searchFinished(vector); +} + +}