summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <[email protected]>2016-07-05 12:49:50 +0200
committerFriedrich W. H. Kossebau <[email protected]>2016-07-09 18:39:24 +0200
commit7dc16625aa76aacf518d39f8acc12e7c6bac4f2e (patch)
tree97f149946eed5b22e8ea9b1f52b5a6f6cb9b51a1
parent35ee1504e51fd2958a800b273a8acaa40281b68e (diff)
Add runner for geo uris
Summary: Supports only geo uris with CRS mathcing the current globe Reviewers: rahn, nienhueser, #marble Reviewed By: nienhueser, #marble Differential Revision: https://phabricator.kde.org/D2076
-rw-r--r--src/plugins/runner/CMakeLists.txt1
-rw-r--r--src/plugins/runner/geouri/CMakeLists.txt10
-rw-r--r--src/plugins/runner/geouri/GeoUriPlugin.cpp68
-rw-r--r--src/plugins/runner/geouri/GeoUriPlugin.h47
-rw-r--r--src/plugins/runner/geouri/GeoUriRunner.cpp58
-rw-r--r--src/plugins/runner/geouri/GeoUriRunner.h32
6 files changed, 216 insertions, 0 deletions
diff --git a/src/plugins/runner/CMakeLists.txt b/src/plugins/runner/CMakeLists.txt
index 1690882..2ba7519 100644
--- 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
index 0000000..bacb589
--- /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.cpp b/src/plugins/runner/geouri/GeoUriPlugin.cpp
new file mode 100644
index 0000000..125d1dc
--- /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 <[email protected]>
+//
+
+#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<PluginAuthor> GeoUriPlugin::pluginAuthors() const
+{
+ return QList<PluginAuthor>()
+ << PluginAuthor(QStringLiteral("Friedrich W. H. Kossebau"), QStringLiteral("[email protected]"));
+}
+
+SearchRunner* GeoUriPlugin::newRunner() const
+{
+ return new GeoUriRunner;
+}
+
+}
+
+Q_EXPORT_PLUGIN2( GeoUriPlugin, Marble::GeoUriPlugin )
+
+#include "moc_GeoUriPlugin.cpp"
diff --git a/src/plugins/runner/geouri/GeoUriPlugin.h b/src/plugins/runner/geouri/GeoUriPlugin.h
new file mode 100644
index 0000000..af77f09
--- /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 <[email protected]>
+//
+
+#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<PluginAuthor> pluginAuthors() const override;
+
+ SearchRunner* newRunner() const override;
+};
+
+}
+
+#endif
diff --git a/src/plugins/runner/geouri/GeoUriRunner.cpp b/src/plugins/runner/geouri/GeoUriRunner.cpp
new file mode 100644
index 0000000..b532c9b
--- /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 <[email protected]>
+
+#include "GeoUriRunner.h"
+
+#include "GeoDataFeature.h"
+#include "GeoDataPlacemark.h"
+#include "GeoDataCoordinates.h"
+#include "GeoUriParser.h"
+#include "MarbleModel.h"
+
+#include "MarbleDebug.h"
+#include <QVector>
+
+
+namespace Marble
+{
+
+GeoUriRunner::GeoUriRunner(QObject *parent)
+ : SearchRunner(parent)
+{
+}
+
+
+GeoUriRunner::~GeoUriRunner()
+{
+}
+
+void GeoUriRunner::search(const QString &searchTerm, const GeoDataLatLonBox &)
+{
+ QVector<GeoDataPlacemark*> 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);
+}
+
+}
diff --git a/src/plugins/runner/geouri/GeoUriRunner.h b/src/plugins/runner/geouri/GeoUriRunner.h
new file mode 100644
index 0000000..db83417
--- /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 <[email protected]>
+//
+
+#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