Commit 0c7438b9 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Use zip compressed osm xml files to reduce download size

parent a48b9528
......@@ -45,7 +45,7 @@
</layer>
<layer name="vectorosm" backend="vectortile" >
<vectortile name="geojson_data" expire="604800" >
<sourcedir format="OSM"> earth/vectorosm </sourcedir>
<sourcedir format="OSM.ZIP"> earth/vectorosm </sourcedir>
<tileSize width="256" height="256" />
<storageLayout levelZeroColumns="1" levelZeroRows="1" minimumTileLevel="18" maximumTileLevel="18" mode="OpenStreetMap" />
<projection name="Mercator" />
......
......@@ -20,21 +20,40 @@
#include "GeoDataPoint.h"
#include "GeoDataTypes.h"
#include "GeoDataStyle.h"
#include <MarbleZipReader.h>
#include <QFile>
#include <QFileInfo>
#include <QBuffer>
namespace Marble {
GeoDataDocument *OsmParser::parse(const QString &filename, QString &error)
{
QFile file(filename);
if (!file.open(QFile::ReadOnly)) {
error = QString("Cannot open file %1").arg(filename);
return nullptr;
QXmlStreamReader parser;
QFile file;
QBuffer buffer;
QFileInfo fileInfo(filename);
if (fileInfo.completeSuffix() == "osm.zip") {
MarbleZipReader zipReader(filename);
if (zipReader.fileInfoList().size() != 1) {
int const fileNumber = zipReader.fileInfoList().size();
error = QString("Unexpected number of files (%1) in %2").arg(fileNumber).arg(filename);
return nullptr;
}
QByteArray const data = zipReader.fileData(zipReader.fileInfoList().first().filePath);
buffer.setData(data);
buffer.open(QBuffer::ReadOnly);
parser.setDevice(&buffer);
} else {
file.setFileName(filename);
if (!file.open(QFile::ReadOnly)) {
error = QString("Cannot open file %1").arg(filename);
return nullptr;
}
parser.setDevice(&file);
}
QXmlStreamReader parser;
parser.setDevice(&file);
OsmPlacemarkData* osmData(0);
QString parentTag;
qint64 parentId(0);
......
......@@ -56,7 +56,7 @@ QString OsmPlugin::fileFormatDescription() const
QStringList OsmPlugin::fileExtensions() const
{
return QStringList() << "osm";
return QStringList() << "osm" << "osm.zip";
}
ParsingRunner* OsmPlugin::newRunner() const
......
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