No OneTemporary

File Metadata

Created
Fri, Apr 19, 6:19 PM
This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 270920764..6f88faa4b 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,301 +1,302 @@
install (FILES
credits_authors.html
credits_data.html
legend.html
legend.css
DESTINATION ${MARBLE_DATA_INSTALL_PATH})
FILE (GLOB LEGEND_FILES *.leg)
install (FILES ${LEGEND_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH})
FILE (GLOB BITMAP_FILES bitmaps/*.png)
install (FILES ${BITMAP_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/bitmaps)
INSTALL (DIRECTORY svg/osmcarto/svg
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/svg/osmcarto
FILES_MATCHING PATTERN "*.svg"
PATTERN "svgorig" EXCLUDE)
INSTALL (DIRECTORY svg/material svg/thenounproject
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/svg
FILES_MATCHING PATTERN "*.svg")
FILE (GLOB BITMAP_EDITARROW_FILES bitmaps/editarrows/*.png)
install (FILES ${BITMAP_EDITARROW_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/bitmaps/editarrows)
install (DIRECTORY bitmaps/osmcarto
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/bitmaps
PATTERN "LICENSE.txt" EXCLUDE)
FILE (GLOB BITMAP_STAR_FILES bitmaps/stars/*.png)
install (FILES ${BITMAP_STAR_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/bitmaps/stars)
FILE (GLOB BITMAP_FILES bitmaps/*.jpg)
install (FILES ${BITMAP_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/bitmaps)
install (FILES
svg/marble-logo.svg
svg/marble-logo.png
svg/marble-logo-32dpi.png
svg/marble-logo-72dpi.png
svg/marble-logo-inverted-32dpi.png
svg/marble-logo-inverted-72dpi.png
svg/application-x-marble.svg
svg/application-x-marble.png
svg/application-x-marble-gray.png
svg/worldmap.svg
svg/lunarmap.svg
svg/marsmap.svg
svg/coordinate.svg
svg/wikipedia.svg
svg/wikipedia_shadow.svg
svg/sunshine.png
svg/sun.png
svg/moon.png
svg/glow.png
svg/track_turtle.svg
svg/bookmark.svg
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/svg)
FILE (GLOB SVG_FILES flags/*.svg)
install (FILES ${SVG_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/flags)
install (FILES
maps/earth/citylights/citylights.jpg
maps/earth/citylights/citylights.dgml
maps/earth/citylights/citylights-preview.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/citylights)
install (FILES
maps/earth/citylights/legend/city.png
maps/earth/citylights/legend/lightterrain.png
maps/earth/citylights/legend/darkterrain.png
maps/earth/citylights/legend/water.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/citylights/legend)
install (FILES
maps/earth/clouds/0/000000/000000_000000.jpg
maps/earth/clouds/0/000000/000000_000001.jpg
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/clouds/0/000000)
install (DIRECTORY maps/earth/srtm DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth)
install (FILES
maps/earth/srtm2/srtm2.dgml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/srtm2)
install (FILES
maps/earth/srtm2/0/000000/000000_000000.png
maps/earth/srtm2/0/000000/000000_000001.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/srtm2/0/000000)
install (FILES
maps/earth/bluemarble/bluemarble.jpg
maps/earth/bluemarble/bluemarble.dgml
maps/earth/bluemarble/bluemarble-preview.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/bluemarble)
install (FILES
maps/earth/bluemarble/legend/ice.png
maps/earth/bluemarble/legend/mountain.png
maps/earth/bluemarble/legend/vegetation.png
maps/earth/bluemarble/legend/desert.png
maps/earth/bluemarble/legend/water.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/bluemarble/legend)
install (FILES
maps/earth/plain/plain.dgml
maps/earth/plain/plain-preview.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/plain)
install (DIRECTORY maps/earth/behaim1492
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth
)
install (DIRECTORY maps/earth/openstreetmap
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth
)
install (FILES
maps/earth/humanitarian/0/0/0.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/humanitarian/0/0)
install (FILES
maps/earth/hillshading/0/0/0.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/hillshading/0/0)
OPTION(EXPERIMENTAL_SENTINEL2_MAP "Install an experimental satellite map theme" ON)
if(EXPERIMENTAL_SENTINEL2_MAP)
install (DIRECTORY maps/earth/sentinel2 DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth)
endif()
-OPTION(EXPERIMENTAL_VECTOR_TILING "Install a map theme using OSM vector tiles (experimental)" ON)
-if(EXPERIMENTAL_VECTOR_TILING OR CMAKE_SYSTEM_NAME STREQUAL Android)
- install (DIRECTORY maps/earth/vectorosm DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth)
+install (DIRECTORY maps/earth/vectorosm DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth)
+OPTION(MARBLE_DEV_VECTOR_TILING "Install the development version of OSM vector tiles" OFF)
+if(MARBLE_DEV_VECTOR_TILING)
+ install (DIRECTORY maps/earth/vectorosm-dev DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth)
endif()
OPTION(MARBLE_EMPTY_MAPTHEME "Install an empty map theme for developmental purposes")
if(MARBLE_EMPTY_MAPTHEME)
install (DIRECTORY maps/earth/empty DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth)
endif()
install (FILES
maps/earth/temp-july/temp-july.jpg
maps/earth/temp-july/temp-july-preview.png
maps/earth/temp-july/temp-july.dgml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/temp-july)
install (FILES
maps/earth/temp-dec/temp-dec.jpg
maps/earth/temp-dec/temp-dec-preview.png
maps/earth/temp-dec/temp-dec.dgml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/temp-dec)
install (FILES
maps/earth/precip-july/precip-july.jpg
maps/earth/precip-july/precip-july-preview.png
maps/earth/precip-july/precip-july.dgml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/precip-july)
install (FILES
maps/earth/precip-dec/precip-dec.jpg
maps/earth/precip-dec/precip-dec-preview.png
maps/earth/precip-dec/precip-dec.dgml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/precip-dec)
install (FILES
maps/earth/schagen1689/legend.html
maps/earth/schagen1689/schagen1689.jpg
maps/earth/schagen1689/schagen1689.dgml
maps/earth/schagen1689/schagen1689-preview.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/schagen1689)
install (FILES
maps/earth/schagen1689/legend/mountain.png
maps/earth/schagen1689/legend/town.png
maps/earth/schagen1689/legend/river.png
maps/earth/schagen1689/legend/lake.png
maps/earth/schagen1689/legend/schagen_title.png
maps/earth/schagen1689/legend/schagen_orig.png
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/schagen1689/legend)
install (FILES
maps/earth/political/political-preview.png
maps/earth/political/political.dgml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/earth/political)
install (FILES
maps/moon/clementine/clementine.jpg
maps/moon/clementine/clementine-preview.png
maps/moon/clementine/legend.html
maps/moon/clementine/clementine.dgml
maps/moon/clementine/tour.kml
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/maps/moon/clementine)
FILE (GLOB_RECURSE DGML_FILES maps/*.dgml)
MARBLE_ADD_PROJECT_RESOURCES(${DGML_FILES})
install (FILES
weather/bbc-stations.xml
weather/weather-clear-night.png
weather/weather-clear.png
weather/weather-clouds-night.png
weather/weather-clouds.png
weather/weather-few-clouds-night.png
weather/weather-few-clouds.png
weather/weather-hail.png
weather/weather-many-clouds.png
weather/weather-mist.png
weather/weather-none-available.png
weather/weather-showers-day.png
weather/weather-showers-night.png
weather/weather-showers-scattered-day.png
weather/weather-showers-scattered-night.png
weather/weather-showers-scattered.png
weather/weather-showers.png
weather/weather-snow-rain.png
weather/weather-snow-scattered-day.png
weather/weather-snow-scattered-night.png
weather/weather-snow-scattered.png
weather/weather-snow.png
weather/weather-storm-day.png
weather/weather-storm-night.png
weather/weather-storm.png
weather/wind-arrows.svgz
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/weather)
install (FILES
licenses/lgpl2.txt
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/licenses)
install (FILES
mwdbii/DATELINE.PNT
mwdbii/PCOAST.PNT
mwdbii/PDIFFBORDER.PNT
mwdbii/PGLACIER.PNT
mwdbii/PISLAND.PNT
mwdbii/PLAKEISLAND.PNT
mwdbii/PLAKE.PNT
mwdbii/PUSA48.DIFF.PNT
mwdbii/RIVER.PNT
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/mwdbii)
FILE (GLOB PN2_FILES naturalearth/*.pn2)
install (FILES ${PN2_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/naturalearth)
FILE (GLOB STAR_FILES stars/*.dat)
install (FILES ${STAR_FILES} stars/deepsky.png stars/names.csv
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/stars)
install (FILES
placemarks/elevplacemarks.cache
placemarks/otherplacemarks.cache
placemarks/baseplacemarks.cache
placemarks/moonlandingsites.cache
placemarks/boundaryplacemarks.cache
placemarks/moonterrain.cache
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/placemarks)
if(MOBILE)
install (FILES placemarks/cityplacemarks_large_population.cache DESTINATION ${MARBLE_DATA_INSTALL_PATH}/placemarks RENAME placemarks/cityplacemarks.cache)
else(MOBILE)
install (FILES placemarks/cityplacemarks.cache DESTINATION ${MARBLE_DATA_INSTALL_PATH}/placemarks)
endif(MOBILE)
if(NOT APPLE AND NOT WIN32)
install (FILES icons/128-apps-marble.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/128x128/apps/ RENAME marble.png)
install (FILES icons/64-apps-marble.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/64x64/apps/ RENAME marble.png)
install (FILES icons/48-apps-marble.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/48x48/apps/ RENAME marble.png)
install (FILES icons/32-apps-marble.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/32x32/apps/ RENAME marble.png)
install (FILES icons/22-apps-marble.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/22x22/apps/ RENAME marble.png)
install (FILES icons/16-apps-marble.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/16x16/apps/ RENAME marble.png)
endif(NOT APPLE AND NOT WIN32 )
FILE (GLOB AUDIO_FILES audio/*.ogg)
install (FILES
${AUDIO_FILES}
DESTINATION ${MARBLE_DATA_INSTALL_PATH}/audio)
add_subdirectory(lang)
find_package(ECM ${REQUIRED_ECM_VERSION} QUIET) # for FindSharedMimeInfo
if(NOT ECM_FOUND)
return()
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
include(KDEInstallDirs) # for KDE_INSTALL_MIMEDIR
# shared-mime-info 0.40 is mandatory for generic-icon
set( SHARED_MIME_INFO_MINIMUM_VERSION "0.40" )
find_package( SharedMimeInfo QUIET )
if(SharedMimeInfo_FOUND)
install(FILES mimetypes/geo.xml DESTINATION ${KDE_INSTALL_MIMEDIR})
update_xdg_mimetypes( ${KDE_INSTALL_MIMEDIR} )
endif()
diff --git a/data/maps/earth/vectorosm-dev/0/0/0.o5m b/data/maps/earth/vectorosm-dev/0/0/0.o5m
new file mode 100644
index 000000000..7c20fea8b
--- /dev/null
+++ b/data/maps/earth/vectorosm-dev/0/0/0.o5m
@@ -0,0 +1,2 @@
+ÿào5m2Üì®ÐÞ
\ No newline at end of file
diff --git a/data/maps/earth/vectorosm-dev/legend.html b/data/maps/earth/vectorosm-dev/legend.html
new file mode 100644
index 000000000..783e94c35
--- /dev/null
+++ b/data/maps/earth/vectorosm-dev/legend.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Marble: Legend</title>
+ %!{bootstrap}%
+ <link href="../../../legend.css" rel="stylesheet" type="text/css" />
+</head>
+<body onload="1">
+
+<!-- The following comment gives a hint to the MarbleLegendBrowser where further
+ legend items which get generated from DGML should get inserted.
+ So DO NOT DELETE this comment: -->
+
+<!-- ##customLegendEntries:all## -->
+
+<!-- You can still appendfurther html and Marble-specific html attributes here: -->
+
+<br>
+</body>
+</html>
diff --git a/data/maps/earth/vectorosm-dev/vectorosm-dev-preview.png b/data/maps/earth/vectorosm-dev/vectorosm-dev-preview.png
new file mode 100644
index 000000000..d18de1839
Binary files /dev/null and b/data/maps/earth/vectorosm-dev/vectorosm-dev-preview.png differ
diff --git a/data/maps/earth/vectorosm-dev/vectorosm-dev.dgml b/data/maps/earth/vectorosm-dev/vectorosm-dev.dgml
new file mode 100644
index 000000000..31550e207
--- /dev/null
+++ b/data/maps/earth/vectorosm-dev/vectorosm-dev.dgml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This xml file 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.
+-->
+<dgml xmlns="http://edu.kde.org/marble/dgml/2.0">
+ <document>
+ <head>
+ <!-- The license here applies to the actual map content, not this dgml file. See the license header above for the dgml file license -->
+ <!-- The content that this license refers to is not distributed with this package -->
+ <license short="© OpenStreetMap contributors">Source: © OpenStreetMap contributors, License: Creative Commons Attribution-ShareAlike 2.0 (CC BY-SA)</license>
+ <name>Vector OSM (Development)</name>
+ <target>earth</target>
+ <theme>vectorosm-dev</theme>
+ <icon pixmap="vectorosm-dev-preview.png"/>
+ <visible>true</visible>
+ <description><![CDATA[<p>A <i>global roadmap</i> created by the OpenStreetMap (OSM) project.</p><p>OSM is an open community which creates free editable maps.</p>]]></description>
+ <zoom>
+ <minimum>900</minimum>
+ <maximum>3850</maximum>
+ <discrete>false</discrete>
+ </zoom>
+ </head>
+ <map bgcolor="#b5d0d0">
+ <canvas/>
+ <target/>
+ <layer name="vectorosm-dev" backend="vectortile">
+ <vectortile name="geojson_data" expire="604800">
+ <sourcedir format="O5M">earth/vectorosm-dev</sourcedir>
+ <storageLayout levelZeroColumns="1" levelZeroRows="1" tileLevels="1,3,5,7,9,11,13,15,17" mode="OpenStreetMap" />
+ <projection name="Mercator" />
+ <downloadUrl protocol="http" host="maps.kde.org" path="/earth/vectorosm/dev/" />
+ <downloadPolicy usage="Browse" maximumConnections="20" />
+ <downloadPolicy usage="Bulk" maximumConnections="2" />
+ </vectortile>
+ </layer>
+ <layer name="standardplaces" backend="geodata">
+ <geodata name="baseplacemarks">
+ <sourcefile>baseplacemarks.cache</sourcefile>
+ </geodata>
+ <geodata name="boundaryplacemarks">
+ <sourcefile>boundaryplacemarks.cache</sourcefile>
+ </geodata>
+ </layer>
+ </map>
+ <settings>
+ <property name="coordinate-grid">
+ <value>false</value>
+ <available>true</available>
+ </property>
+ <property name="overviewmap">
+ <value>true</value>
+ <available>true</available>
+ </property>
+ <property name="compass">
+ <value>false</value>
+ <available>true</available>
+ </property>
+ <property name="scalebar">
+ <value>true</value>
+ <available>true</available>
+ </property>
+ <group name="Places">
+ <property name="places">
+ <value>true</value>
+ <available>true</available>
+ </property>
+ <property name="cities">
+ <value>true</value>
+ <available>true</available>
+ </property>
+ <property name="terrain">
+ <value>false</value>
+ <available>false</available>
+ </property>
+ <property name="otherplaces">
+ <value>false</value>
+ <available>false</available>
+ </property>
+ </group>
+ </settings>
+ <legend>
+
+ <section name="Tours">
+ <heading>Explore the Earth</heading>
+ <item name="earthlandingsites">
+ <text><![CDATA[<a href="tour://earth/openstreetmap/tour.kml">Play a tour of popular places.</a>]]></text>
+ </item>
+ </section>
+
+ <section name="coordinate-grid" checkable="true" connect="coordinate-grid" spacing="12">
+ <heading>Coordinate Grid</heading>
+ </section>
+
+ </legend>
+ </document>
+</dgml>
diff --git a/tools/vectorosm-tilecreator/vectorosm-tilecreator.cpp b/tools/vectorosm-tilecreator/vectorosm-tilecreator.cpp
index be9915b1f..fc77b248e 100644
--- a/tools/vectorosm-tilecreator/vectorosm-tilecreator.cpp
+++ b/tools/vectorosm-tilecreator/vectorosm-tilecreator.cpp
@@ -1,339 +1,341 @@
//
// 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 David Kolozsvari <freedawson@gmail.com>
// Copyright 2016 Dennis Nienhüser <nienhueser@kde.org>
//
#include "GeoDataTypes.h"
#include "GeoDataDocumentWriter.h"
#include "MarbleModel.h"
#include "ParsingRunnerManager.h"
#include "GeoDataGeometry.h"
#include "GeoDataPlacemark.h"
#include "GeoDataLatLonAltBox.h"
#include "TileId.h"
#include "MarbleDirs.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QFileInfo>
#include <QDir>
#include <QString>
#include <QElapsedTimer>
#include <QSharedPointer>
#include <QUrl>
#include <QBuffer>
#include <QMessageLogContext>
#include <QProcess>
#include "VectorClipper.h"
#include "NodeReducer.h"
#include "WayConcatenator.h"
#include "TileIterator.h"
#include "TileDirectory.h"
#include "MbTileWriter.h"
#include "SpellChecker.h"
#include <iostream>
using namespace Marble;
GeoDataDocument* mergeDocuments(GeoDataDocument* map1, GeoDataDocument* map2)
{
GeoDataDocument* mergedMap = new GeoDataDocument(*map1);
OsmPlacemarkData marbleLand;
marbleLand.addTag("marble_land","landmass");
foreach (auto placemark, map2->placemarkList()) {
GeoDataPlacemark* land = new GeoDataPlacemark(*placemark);
if(land->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
land->setOsmData(marbleLand);
}
mergedMap->append(land);
}
return mergedMap;
}
QString tileFileName(const QCommandLineParser &parser, int x, int y, int zoomLevel)
{
QString const extension = parser.value("extension");
- QString const outputDir = QString("%1/%2/%3").arg(parser.value("output")).arg(zoomLevel).arg(x);
+ QString const output = parser.isSet("development") ? QString("%1/maps/earth/vectorosm-dev").arg(MarbleDirs::localPath()) : parser.value("output");
+ QString const outputDir = QString("%1/%2/%3").arg(output).arg(zoomLevel).arg(x);
QString const outputFile = QString("%1/%2.%3").arg(outputDir).arg(y).arg(extension);
return outputFile;
}
void writeBoundaryTile(GeoDataDocument* tile, const QString &region, const QCommandLineParser &parser, int x, int y, int zoomLevel)
{
QString const extension = parser.value("extension");
QString const outputDir = QString("%1/boundaries/%2/%3/%4").arg(parser.value("cache-directory")).arg(region).arg(zoomLevel).arg(x);
QString const outputFile = QString("%1/%2.%3").arg(outputDir).arg(y).arg(extension);
QDir().mkpath(outputDir);
GeoDataDocumentWriter::write(outputFile, *tile);
}
QSharedPointer<GeoDataDocument> mergeBoundaryTiles(const QSharedPointer<GeoDataDocument> &background, ParsingRunnerManager &manager, const QCommandLineParser &parser, int x, int y, int zoomLevel)
{
GeoDataDocument* mergedMap = new GeoDataDocument;
OsmPlacemarkData marbleLand;
marbleLand.addTag("marble_land","landmass");
foreach (auto placemark, background->placemarkList()) {
GeoDataPlacemark* land = new GeoDataPlacemark(*placemark);
if(land->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
land->setOsmData(marbleLand);
}
mergedMap->append(land);
}
QString const extension = parser.value("extension");
QString const boundaryDir = QString("%1/boundaries").arg(parser.value("cache-directory"));
foreach(auto const &dir, QDir(boundaryDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QString const file = QString("%1/%2/%3/%4/%5.%6").arg(boundaryDir).arg(dir).arg(zoomLevel).arg(x).arg(y).arg(extension);
if (QFileInfo(file).exists()) {
auto tile = TileDirectory::open(file, manager);
if (tile) {
foreach (auto placemark, tile->placemarkList()) {
mergedMap->append(placemark->clone());
}
}
}
}
return QSharedPointer<GeoDataDocument>(mergedMap);
}
bool writeTile(GeoDataDocument* tile, const QString &outputFile)
{
QDir().mkpath(QFileInfo(outputFile).path());
if (!GeoDataDocumentWriter::write(outputFile, *tile)) {
qWarning() << "Could not write the file " << outputFile;
return false;
}
return true;
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("marble-vectorosm-tilecreator");
QCoreApplication::setApplicationVersion("0.1");
QCommandLineParser parser;
parser.setApplicationDescription("A tool for Marble, which is used to reduce the details of osm maps.");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("input", "The input .osm or .shp file.");
parser.addOptions({
{{"t", "osmconvert"}, "Tile data using osmconvert."},
{"conflict-resolution", "How to deal with existing tiles: overwrite, skip or merge", "mode", "overwrite"},
{{"c", "cache-directory"}, "Directory for temporary data.", "cache", "cache"},
{{"m", "mbtile"}, "Store tiles at level 15 onwards in a mbtile database.", "mbtile"},
{{"s", "spellcheck"}, "Use this geonames.org cities file for spell-checking city names", "spellcheck"},
{"verbose", "Increase amount of shell output information"},
+ {{"d", "development"}, "Use local development vector osm map theme as output storage"},
{{"z", "zoom-level"}, "Zoom level according to which OSM information has to be processed.", "levels", "11,13,15,17"},
{{"o", "output"}, "Output file or directory", "output", QString("%1/maps/earth/vectorosm").arg(MarbleDirs::localPath())},
{{"e", "extension"}, "Output file type: o5m (default), osm or kml", "file extension", "o5m"}
});
// Process the actual command line arguments given by the user
parser.process(app);
const QStringList args = parser.positionalArguments();
if (args.isEmpty()) {
parser.showHelp();
return 0;
}
// input is args.at(0), output is args.at(1)
QString const extension = parser.value("extension");
QString inputFileName = args.at(0);
auto const levels = parser.value("zoom-level").split(',');
QVector<unsigned int> zoomLevels;
int maxZoomLevel = 0;
foreach(auto const &level, levels) {
int const zoomLevel = level.toInt();
maxZoomLevel = qMax(zoomLevel, maxZoomLevel);
zoomLevels << zoomLevel;
}
if (zoomLevels.isEmpty()) {
parser.showHelp(1);
return 1;
}
bool const overwriteTiles = parser.value("conflict-resolution") == "overwrite";
bool const mergeTiles = parser.value("conflict-resolution") == "merge";
QSharedPointer<MbTileWriter> mbtileWriter;
if (parser.isSet("mbtile")) {
QString const mbtile = parser.value("mbtile");
mbtileWriter = QSharedPointer<MbTileWriter>(new MbTileWriter(mbtile, extension));
mbtileWriter->setReportProgress(false);
mbtileWriter->setCommitInterval(500);
}
MarbleModel model;
ParsingRunnerManager manager(model.pluginManager());
QString const cacheDirectory = parser.value("cache-directory");
QDir().mkpath(cacheDirectory);
if (!QFileInfo(cacheDirectory).isWritable()) {
qWarning() << "Cannot write to cache directory" << cacheDirectory;
parser.showHelp(1);
}
if (*zoomLevels.cbegin() <= 9) {
auto map = TileDirectory::open(inputFileName, manager);
VectorClipper processor(map.data(), maxZoomLevel);
GeoDataLatLonBox world(85.0, -85.0, 180.0, -180.0, GeoDataCoordinates::Degree);
if (parser.isSet("spellcheck")) {
SpellChecker spellChecker(parser.value("spellcheck"));
spellChecker.setVerbose(parser.isSet("verbose"));
spellChecker.correctPlaceLabels(map.data()->placemarkList());
}
foreach(auto zoomLevel, zoomLevels) {
TileIterator iter(world, zoomLevel);
qint64 count = 0;
qint64 const total = iter.total();
foreach(auto const &tileId, iter) {
++count;
QString const filename = tileFileName(parser, tileId.x(), tileId.y(), zoomLevel);
if (!overwriteTiles && QFileInfo(filename).exists()) {
continue;
}
GeoDataDocument* tile = processor.clipTo(zoomLevel, tileId.x(), tileId.y());
if (tile->size() > 0) {
NodeReducer nodeReducer(tile, TileId(0, zoomLevel, tileId.x(), tileId.y()));
if (!writeTile(tile, filename)) {
return 4;
}
TileDirectory::printProgress(count / double(total));
std::cout << " Tile " << count << "/" << total << " (" << tile->name().toStdString() << ") done.";
double const reduction = nodeReducer.removedNodes() / qMax(1.0, double(nodeReducer.remainingNodes() + nodeReducer.removedNodes()));
std::cout << " Node reduction: " << qRound(reduction * 100.0) << "%";
} else {
TileDirectory::printProgress(count / double(total));
std::cout << " Skipping empty tile " << count << "/" << total << " (" << tile->name().toStdString() << ").";
}
std::cout << std::string(20, ' ') << '\r';
std::cout.flush();
delete tile;
}
}
} else {
QString const region = QFileInfo(inputFileName).fileName();
QString const regionDir = QString("%1/%2").arg(cacheDirectory).arg(QFileInfo(inputFileName).baseName());
TileDirectory mapTiles(TileDirectory::OpenStreetMap, regionDir, manager, extension, maxZoomLevel);
mapTiles.setInputFile(inputFileName);
mapTiles.createTiles();
auto const boundingBox = mapTiles.boundingBox();
TileDirectory loader(TileDirectory::Landmass, cacheDirectory, manager, extension, maxZoomLevel);
loader.setBoundingBox(boundingBox);
loader.createTiles();
typedef QMap<QString, QVector<TileId> > Tiles;
Tiles tiles;
qint64 total = 0;
QSet<QString> boundaryTiles;
foreach(auto zoomLevel, zoomLevels) {
TileIterator iter(mapTiles.boundingBox(), zoomLevel);
total += iter.total();
foreach(auto const &tileId, iter) {
auto const tile = TileId(0, zoomLevel, tileId.x(), tileId.y());
int const innerNodes = mapTiles.innerNodes(tile);
if (innerNodes > 0) {
auto const mapTile = mapTiles.tileFor(zoomLevel, tileId.x(), tileId.y());
auto const name = QString("%1/%2/%3").arg(mapTile.zoomLevel()).arg(mapTile.x()).arg(mapTile.y());
tiles[name] << tile;
if (innerNodes < 4) {
boundaryTiles << name;
}
} else {
--total;
}
}
}
qint64 count = 0;
for (auto iter = tiles.begin(), end = tiles.end(); iter != end; ++iter) {
foreach(auto const &tileId, iter.value()) {
++count;
int const zoomLevel = tileId.zoomLevel();
QString const filename = tileFileName(parser, tileId.x(), tileId.y(), zoomLevel);
if (!overwriteTiles) {
if (zoomLevel > 13 && mbtileWriter && mbtileWriter->hasTile(tileId.x(), tileId.y(), zoomLevel)) {
continue;
} else if (QFileInfo(filename).exists()) {
continue;
}
}
typedef QSharedPointer<GeoDataDocument> GeoDocPtr;
GeoDocPtr tile1 = GeoDocPtr(mapTiles.clip(zoomLevel, tileId.x(), tileId.y()));
TagsFilter::removeAnnotationTags(tile1.data());
int originalWays = 0;
int mergedWays = 0;
if (zoomLevel < 17) {
WayConcatenator concatenator(tile1.data());
originalWays = concatenator.originalWays();
mergedWays = concatenator.mergedWays();
}
NodeReducer nodeReducer(tile1.data(), tileId);
GeoDocPtr tile2 = GeoDocPtr(loader.clip(zoomLevel, tileId.x(), tileId.y()));
if (tile1->size() > 0 && tile2->size() > 0) {
GeoDocPtr combined = GeoDocPtr(mergeDocuments(tile1.data(), tile2.data()));
if (boundaryTiles.contains(iter.key())) {
writeBoundaryTile(tile1.data(), region, parser, tileId.x(), tileId.y(), zoomLevel);
if (mergeTiles) {
combined = mergeBoundaryTiles(tile2, manager, parser, tileId.x(), tileId.y(), zoomLevel);
}
}
if (zoomLevel > 13 && mbtileWriter) {
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
if (GeoDataDocumentWriter::write(&buffer, *combined, extension)) {
buffer.seek(0);
mbtileWriter->addTile(&buffer, tileId.x(), tileId.y(), zoomLevel);
} else {
qWarning() << "Could not write the tile " << combined->name();
}
} else {
if (!writeTile(combined.data(), filename)) {
return 4;
}
}
TileDirectory::printProgress(count / double(total));
std::cout << " Tile " << count << "/" << total << " (";
std::cout << combined->name().toStdString() << ").";
double const reduction = nodeReducer.removedNodes() / qMax(1.0, double(nodeReducer.remainingNodes() + nodeReducer.removedNodes()));
std::cout << " Node reduction: " << qRound(reduction * 100.0) << "%";
if (originalWays > 0) {
std::cout << " , " << originalWays << " ways merged to " << mergedWays;
}
} else {
TileDirectory::printProgress(count / double(total));
std::cout << " Skipping empty tile " << count << "/" << total << " (" << tile1->name().toStdString() << ").";
}
std::cout << std::string(20, ' ') << '\r';
std::cout.flush();
}
}
TileDirectory::printProgress(1.0);
std::cout << " Vector OSM tiles complete." << std::string(30, ' ') << std::endl;
}
return 0;
}