Commit c2803467 authored by Dennis Nienhüser's avatar Dennis Nienhüser

Use tiling approach for input map data as well

parent 2a26eab3
......@@ -21,7 +21,8 @@ TileDirectory::TileDirectory(const QString &baseDir, ParsingRunnerManager &manag
m_zoomLevel(QFileInfo(baseDir).baseName().toInt()),
m_tileX(-1),
m_tileY(-1),
m_extension(extension)
m_extension(extension),
m_filterTags(false)
{
// nothing to do
}
......@@ -42,6 +43,30 @@ QSharedPointer<GeoDataDocument> TileDirectory::load(int zoomLevel, int tileX, in
return m_landmass;
}
GeoDataDocument* TileDirectory::clip(int zoomLevel, int tileX, int tileY)
{
QSharedPointer<GeoDataDocument> oldMap = m_landmass;
load(zoomLevel, tileX, tileY);
if (!m_clipper || oldMap != m_landmass) {
GeoDataDocument* input = m_landmass.data();
if (m_filterTags) {
QStringList const tags = tagsFilteredIn(zoomLevel);
if (zoomLevel < 17) {
m_tagsFilter = QSharedPointer<TagsFilter>(new TagsFilter(m_landmass.data(), tags));
input = m_tagsFilter->accepted();
}
}
m_clipper = QSharedPointer<VectorClipper>(new VectorClipper(input));
}
return m_clipper->clipTo(zoomLevel, tileX, tileY);
}
QString TileDirectory::name() const
{
return QString("%1/%2/%3").arg(m_zoomLevel).arg(m_tileX).arg(m_tileY);
}
QSharedPointer<GeoDataDocument> TileDirectory::open(const QString &filename, ParsingRunnerManager &manager)
{
// Timeout is set to 10 min. If the file is reaaally huge, set it to something bigger.
......@@ -53,4 +78,103 @@ QSharedPointer<GeoDataDocument> TileDirectory::open(const QString &filename, Par
return result;
}
QStringList TileDirectory::tagsFilteredIn(int zoomLevel) const
{
QStringList tags;
tags << "highway=motorway" << "highway=motorway_link";
tags << "highway=trunk" << "highway=trunk_link";
tags << "highway=primary" << "highway=primary_link";
tags << "highway=secondary" << "highway=secondary_link";
if (zoomLevel >= 13) {
tags << "highway=tertiary" << "highway=tertiary_link";
tags << "highway=unclassified";
tags << "public_transport=station";
tags << "railway=light_rail";
tags << "railway=monorail";
tags << "railway=narrow_gauge";
tags << "railway=preserved";
tags << "railway=rail";
tags << "railway=subway";
tags << "railway=tram";
tags << "natural=scrub";
tags << "natural=heath";
tags << "natural=grassland";
tags << "natural=glacier";
tags << "natural=beach";
tags << "natural=coastline";
tags << "natural=water";
tags << "natural=wood";
tags << "leisure=stadium";
tags << "tourism=alpine_hut";
tags << "waterway=river";
tags << "waterway=stream";
tags << "waterway=canal";
tags << "place=suburb";
tags << "place=village";
tags << "natural=peak";
}
if (zoomLevel <= 13) {
tags << "landuse=commercial";
tags << "landuse=farmland";
tags << "landuse=farmyard";
tags << "landuse=forest";
tags << "landuse=industrial";
tags << "landuse=meadow";
tags << "landuse=military";
tags << "landuse=recreation_ground";
tags << "landuse=residential";
tags << "landuse=retail";
}
if (zoomLevel >= 15) {
tags << "highway=residential";
tags << "highway=track";
tags << "landuse=*";
tags << "leisure=pitch";
tags << "leisure=swimming_area";
tags << "place=hamlet";
tags << "place=isolated_dwelling";
tags << "man_made=beacon";
tags << "man_made=bridge";
tags << "man_made=campanile";
tags << "man_made=chimney";
tags << "man_made=communications_tower";
tags << "man_made=cross";
tags << "man_made=gasometer";
tags << "man_made=lighthouse";
tags << "man_made=tower";
tags << "man_made=water_tower";
tags << "man_made=windmill";
}
tags << "leisure=nature_reserve";
tags << "leisure=park";
tags << "place=city";
tags << "place=town";
tags << "place=locality";
tags << "boundary=administrative";
tags << "boundary=political";
tags << "boundary=national_park";
tags << "boundary=protected_area";
return tags;
}
void TileDirectory::setFilterTags(bool filter)
{
m_filterTags = filter;
}
}
......@@ -9,6 +9,9 @@
//
#include "VectorClipper.h"
#include "TagsFilter.h"
#include <QSharedPointer>
#include <ParsingRunnerManager.h>
......@@ -19,10 +22,16 @@ class TileDirectory
public:
TileDirectory(const QString &baseDir, ParsingRunnerManager &manager, const QString &extension);
QSharedPointer<GeoDataDocument> load(int zoomLevel, int tileX, int tileY);
void setFilterTags(bool filter);
GeoDataDocument *clip(int zoomLevel, int tileX, int tileY);
QString name() const;
static QSharedPointer<GeoDataDocument> open(const QString &filename, ParsingRunnerManager &manager);
private:
QStringList tagsFilteredIn(int zoomLevel) const;
QString m_baseDir;
ParsingRunnerManager &m_manager;
QSharedPointer<GeoDataDocument> m_landmass;
......@@ -30,6 +39,9 @@ private:
int m_tileX;
int m_tileY;
QString m_extension;
QSharedPointer<VectorClipper> m_clipper;
QSharedPointer<TagsFilter> m_tagsFilter;
bool m_filterTags;
};
}
This diff is collapsed.
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