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
parent 35ee1504
# Search and/or reverse geocoding
add_subdirectory( hostip )
add_subdirectory( geouri )
add_subdirectory( latlon )
add_subdirectory( local-osm-search )
add_subdirectory( localdatabase )
......
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} )
//
// 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 <kossebau@kde.org>
//
#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("kossebau@kde.org"));
}
SearchRunner* GeoUriPlugin::newRunner() const
{
return new GeoUriRunner;
}
}
Q_EXPORT_PLUGIN2( GeoUriPlugin, Marble::GeoUriPlugin )
#include "moc_GeoUriPlugin.cpp"
//
// 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 <kossebau@kde.org>
//
#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
//
// 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 <kossebau@kde.org>
#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);
}
}
//
// 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 <kossebau@kde.org>
//
#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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment