From 8105ad1fe53fd0c897c7b0c108c0ec25358ab93b Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Wed, 25 Mar 2020 13:27:11 +0100 Subject: [PATCH] Initial work on vector tile layer support --- CMakeLists.txt | 5 + python/CMakeLists.txt | 1 + python/core/core_auto.sip | 1 + scripts/astyle.sh | 2 +- src/core/CMakeLists.txt | 25 + .../wms => core}/qgsmbtilesreader.cpp | 0 .../wms => core}/qgsmbtilesreader.h | 3 +- .../vectortile/qgsvectortilebasicrenderer.cpp | 259 ++ .../vectortile/qgsvectortilebasicrenderer.h | 156 + src/core/vectortile/qgsvectortilelayer.cpp | 176 ++ src/core/vectortile/qgsvectortilelayer.h | 148 + .../vectortile/qgsvectortilelayerrenderer.cpp | 184 ++ .../vectortile/qgsvectortilelayerrenderer.h | 83 + src/core/vectortile/qgsvectortileloader.cpp | 265 ++ src/core/vectortile/qgsvectortileloader.h | 100 + .../vectortile/qgsvectortilemvtdecoder.cpp | 322 +++ src/core/vectortile/qgsvectortilemvtdecoder.h | 56 + src/core/vectortile/qgsvectortilerenderer.h | 90 + src/core/vectortile/qgsvectortileutils.cpp | 171 ++ src/core/vectortile/qgsvectortileutils.h | 62 + src/core/vectortile/vector_tile.pb.cc | 2527 +++++++++++++++++ src/core/vectortile/vector_tile.pb.h | 1260 ++++++++ src/providers/wms/CMakeLists.txt | 1 - 23 files changed, 5894 insertions(+), 3 deletions(-) rename src/{providers/wms => core}/qgsmbtilesreader.cpp (100%) rename src/{providers/wms => core}/qgsmbtilesreader.h (96%) create mode 100644 src/core/vectortile/qgsvectortilebasicrenderer.cpp create mode 100644 src/core/vectortile/qgsvectortilebasicrenderer.h create mode 100644 src/core/vectortile/qgsvectortilelayer.cpp create mode 100644 src/core/vectortile/qgsvectortilelayer.h create mode 100644 src/core/vectortile/qgsvectortilelayerrenderer.cpp create mode 100644 src/core/vectortile/qgsvectortilelayerrenderer.h create mode 100644 src/core/vectortile/qgsvectortileloader.cpp create mode 100644 src/core/vectortile/qgsvectortileloader.h create mode 100644 src/core/vectortile/qgsvectortilemvtdecoder.cpp create mode 100644 src/core/vectortile/qgsvectortilemvtdecoder.h create mode 100644 src/core/vectortile/qgsvectortilerenderer.h create mode 100644 src/core/vectortile/qgsvectortileutils.cpp create mode 100644 src/core/vectortile/qgsvectortileutils.h create mode 100644 src/core/vectortile/vector_tile.pb.cc create mode 100644 src/core/vectortile/vector_tile.pb.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f145d5257..2a17a6503f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,6 +331,11 @@ IF(WITH_CORE) MESSAGE (SEND_ERROR "sqlite3 dependency was not found!") ENDIF (NOT SQLITE3_FOUND) + FIND_PACKAGE(Protobuf REQUIRED) # for decoding of vector tiles in MVT format + MESSAGE(STATUS "Found Protobuf: ${Protobuf_LIBRARIES}") + FIND_PACKAGE(ZLIB REQUIRED) # for decompression of vector tiles in MBTiles file + MESSAGE(STATUS "Found zlib: ${ZLIB_LIBRARIES}") + # optional IF (WITH_POSTGRESQL) FIND_PACKAGE(Postgres) # PostgreSQL provider diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e87ac9aad67..101a12d656f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -123,6 +123,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/core/symbology ${CMAKE_SOURCE_DIR}/src/core/classification ${CMAKE_SOURCE_DIR}/src/core/validity + ${CMAKE_SOURCE_DIR}/src/core/vectortile ${CMAKE_SOURCE_DIR}/src/plugins ${CMAKE_SOURCE_DIR}/external ${CMAKE_SOURCE_DIR}/external/nlohmann diff --git a/python/core/core_auto.sip b/python/core/core_auto.sip index 542b47c8697..0ab8ae96443 100644 --- a/python/core/core_auto.sip +++ b/python/core/core_auto.sip @@ -534,3 +534,4 @@ %Include auto_generated/gps/qgsgpsconnectionregistry.sip %Include auto_generated/symbology/qgsmasksymbollayer.sip %Include auto_generated/qgsuserprofile.sip +%Include auto_generated/vectortile/qgsvectortilelayer.sip diff --git a/scripts/astyle.sh b/scripts/astyle.sh index 7217f9acee6..b1a44bd19a7 100755 --- a/scripts/astyle.sh +++ b/scripts/astyle.sh @@ -105,7 +105,7 @@ astyleit() { for f in "$@"; do case "$f" in - src/plugins/grass/qtermwidget/*|external/o2/*|external/qt-unix-signals/*|external/rtree/*|external/astyle/*|external/kdbush/*|external/poly2tri/*|external/wintoast/*|external/qt3dextra-headers/*|external/meshOptimizer/*|python/ext-libs/*|ui_*.py|*.astyle|tests/testdata/*|editors/*) + src/plugins/grass/qtermwidget/*|external/o2/*|external/qt-unix-signals/*|external/rtree/*|external/astyle/*|external/kdbush/*|external/poly2tri/*|external/wintoast/*|external/qt3dextra-headers/*|external/meshOptimizer/*|python/ext-libs/*|ui_*.py|*.astyle|tests/testdata/*|editors/*|src/core/vectortile/*.pb.*) echo -ne "$f skipped $elcr" continue ;; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 5b8b552b1da..128c3d1ea02 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -312,6 +312,7 @@ SET(QGIS_CORE_SRCS qgsmapunitscale.cpp qgsmargins.cpp qgsmaskidprovider.cpp + qgsmbtilesreader.cpp qgsmessagelog.cpp qgsmessageoutput.cpp qgsmimedatautils.cpp @@ -395,6 +396,7 @@ SET(QGIS_CORE_SRCS qgstessellator.cpp qgstextrenderer.cpp qgstilecache.cpp + qgstiles.cpp qgstolerance.cpp qgstracer.cpp qgstranslationcontext.cpp @@ -635,6 +637,14 @@ SET(QGIS_CORE_SRCS validity/qgsvaliditycheckcontext.cpp validity/qgsvaliditycheckregistry.cpp + vectortile/qgsvectortilebasicrenderer.cpp + vectortile/qgsvectortilelayer.cpp + vectortile/qgsvectortilelayerrenderer.cpp + vectortile/qgsvectortileloader.cpp + vectortile/qgsvectortilemvtdecoder.cpp + vectortile/qgsvectortileutils.cpp + vectortile/vector_tile.pb.cc + ${CMAKE_CURRENT_BINARY_DIR}/qgsexpression_texts.cpp qgsuserprofile.cpp @@ -833,6 +843,7 @@ SET(QGIS_CORE_HDRS qgsmapunitscale.h qgsmargins.h qgsmaskidprovider.h + qgsmbtilesreader.h qgsmessagelog.h qgsmessageoutput.h qgsmimedatautils.h @@ -924,6 +935,7 @@ SET(QGIS_CORE_HDRS qgstextrenderer.h qgsthreadingutils.h qgstilecache.h + qgstiles.h qgstolerance.h qgstracer.h qgstrackedvectorlayertools.h @@ -1319,6 +1331,14 @@ SET(QGIS_CORE_HDRS validity/qgsabstractvaliditycheck.h validity/qgsvaliditycheckcontext.h validity/qgsvaliditycheckregistry.h + + vectortile/qgsvectortilebasicrenderer.h + vectortile/qgsvectortilelayer.h + vectortile/qgsvectortilelayerrenderer.h + vectortile/qgsvectortileloader.h + vectortile/qgsvectortilemvtdecoder.h + vectortile/qgsvectortilerenderer.h + vectortile/qgsvectortileutils.h ) SET(QGIS_CORE_PRIVATE_HDRS @@ -1408,6 +1428,7 @@ INCLUDE_DIRECTORIES( symbology mesh validity + vectortile ${CMAKE_SOURCE_DIR}/external ${CMAKE_SOURCE_DIR}/external/nlohmann ${CMAKE_SOURCE_DIR}/external/kdbush/include @@ -1429,6 +1450,8 @@ INCLUDE_DIRECTORIES(SYSTEM ${QCA_INCLUDE_DIR} ${QTKEYCHAIN_INCLUDE_DIR} ${Qt5SerialPort_INCLUDE_DIRS} + ${Protobuf_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} ) @@ -1563,6 +1586,8 @@ TARGET_LINK_LIBRARIES(qgis_core ${SQLITE3_LIBRARY} ${SPATIALITE_LIBRARY} ${LIBZIP_LIBRARY} + ${Protobuf_LIBRARIES} + ${ZLIB_LIBRARIES} ) IF (FORCE_STATIC_PROVIDERS) diff --git a/src/providers/wms/qgsmbtilesreader.cpp b/src/core/qgsmbtilesreader.cpp similarity index 100% rename from src/providers/wms/qgsmbtilesreader.cpp rename to src/core/qgsmbtilesreader.cpp diff --git a/src/providers/wms/qgsmbtilesreader.h b/src/core/qgsmbtilesreader.h similarity index 96% rename from src/providers/wms/qgsmbtilesreader.h rename to src/core/qgsmbtilesreader.h index 279e89a6e3e..7944c066dc2 100644 --- a/src/providers/wms/qgsmbtilesreader.h +++ b/src/core/qgsmbtilesreader.h @@ -16,6 +16,7 @@ #ifndef QGSMBTILESREADER_H #define QGSMBTILESREADER_H +#include "qgis_core.h" #include "sqlite3.h" #include "qgssqliteutils.h" @@ -23,7 +24,7 @@ class QImage; class QgsRectangle; -class QgsMBTilesReader +class CORE_EXPORT QgsMBTilesReader { public: explicit QgsMBTilesReader( const QString &filename ); diff --git a/src/core/vectortile/qgsvectortilebasicrenderer.cpp b/src/core/vectortile/qgsvectortilebasicrenderer.cpp new file mode 100644 index 00000000000..31130657a7e --- /dev/null +++ b/src/core/vectortile/qgsvectortilebasicrenderer.cpp @@ -0,0 +1,259 @@ +/*************************************************************************** + qgsvectortilebasicrenderer.cpp + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsvectortilebasicrenderer.h" + +#include "qgslinesymbollayer.h" +#include "qgssymbollayerutils.h" +#include "qgsvectortileutils.h" + + +QgsVectorTileBasicRendererStyle::QgsVectorTileBasicRendererStyle( const QString &stName, const QString &laName, QgsWkbTypes::GeometryType geomType ) + : mStyleName( stName ) + , mLayerName( laName ) + , mGeometryType( geomType ) +{ +} + +QgsVectorTileBasicRendererStyle::QgsVectorTileBasicRendererStyle( const QgsVectorTileBasicRendererStyle &other ) +{ + operator=( other ); +} + +QgsVectorTileBasicRendererStyle &QgsVectorTileBasicRendererStyle::operator=( const QgsVectorTileBasicRendererStyle &other ) +{ + mStyleName = other.mStyleName; + mLayerName = other.mLayerName; + mGeometryType = other.mGeometryType; + mSymbol.reset( other.mSymbol ? other.mSymbol->clone() : nullptr ); + mEnabled = other.mEnabled; + mExpression = other.mExpression; + mMinZoomLevel = other.mMinZoomLevel; + mMaxZoomLevel = other.mMaxZoomLevel; + return *this; +} + +void QgsVectorTileBasicRendererStyle::setSymbol( QgsSymbol *sym ) +{ + mSymbol.reset( sym ); +} + +void QgsVectorTileBasicRendererStyle::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const +{ + elem.setAttribute( "name", mStyleName ); + elem.setAttribute( "layer", mLayerName ); + elem.setAttribute( "geometry", mGeometryType ); + elem.setAttribute( "enabled", mEnabled ? "1" : "0" ); + elem.setAttribute( "expression", mExpression ); + elem.setAttribute( "min-zoom", mMinZoomLevel ); + elem.setAttribute( "max-zoom", mMaxZoomLevel ); + + QDomDocument doc = elem.ownerDocument(); + QgsSymbolMap symbols; + symbols[QStringLiteral( "0" )] = mSymbol.get(); + QDomElement symbolsElem = QgsSymbolLayerUtils::saveSymbols( symbols, QStringLiteral( "symbols" ), doc, context ); + elem.appendChild( symbolsElem ); +} + +void QgsVectorTileBasicRendererStyle::readXml( const QDomElement &elem, const QgsReadWriteContext &context ) +{ + mStyleName = elem.attribute( "name" ); + mLayerName = elem.attribute( "layer" ); + mGeometryType = static_cast( elem.attribute( "geometry" ).toInt() ); + mEnabled = elem.attribute( "enabled" ).toInt(); + mExpression = elem.attribute( "expression" ); + mMinZoomLevel = elem.attribute( "min-zoom" ).toInt(); + mMaxZoomLevel = elem.attribute( "max-zoom" ).toInt(); + + mSymbol.reset(); + QDomElement symbolsElem = elem.firstChildElement( QStringLiteral( "symbols" ) ); + if ( !symbolsElem.isNull() ) + { + QgsSymbolMap symbolMap = QgsSymbolLayerUtils::loadSymbols( symbolsElem, context ); + if ( !symbolMap.contains( QStringLiteral( "0" ) ) ) + { + mSymbol.reset( symbolMap.take( QStringLiteral( "0" ) ) ); + } + } +} + +//////// + + +QgsVectorTileBasicRenderer::QgsVectorTileBasicRenderer() +{ + setDefaultStyle(); +} + +QString QgsVectorTileBasicRenderer::type() const +{ + return "basic"; +} + +QgsVectorTileBasicRenderer *QgsVectorTileBasicRenderer::clone() const +{ + QgsVectorTileBasicRenderer *r = new QgsVectorTileBasicRenderer; + r->mStyles = mStyles; + r->mStyles.detach(); // make a deep copy to make sure symbols get cloned + return r; +} + +void QgsVectorTileBasicRenderer::startRender( QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange ) +{ + Q_UNUSED( context ) + Q_UNUSED( tileRange ) + // figure out required fields for different layers + for ( const QgsVectorTileBasicRendererStyle &layerStyle : qgis::as_const( mStyles ) ) + { + if ( layerStyle.isActive( tileZoom ) && !layerStyle.filterExpression().isEmpty() ) + { + QgsExpression expr( layerStyle.filterExpression() ); + mRequiredFields[layerStyle.layerName()].unite( expr.referencedColumns() ); + } + } +} + +QMap > QgsVectorTileBasicRenderer::usedAttributes( const QgsRenderContext & ) +{ + return mRequiredFields; +} + +void QgsVectorTileBasicRenderer::stopRender( QgsRenderContext &context ) +{ + Q_UNUSED( context ) +} + +void QgsVectorTileBasicRenderer::renderTile( const QgsVectorTileRendererData &tile, QgsRenderContext &context ) +{ + const QgsVectorTileFeatures tileData = tile.features; + int zoomLevel = tile.id.zoomLevel(); + + for ( const QgsVectorTileBasicRendererStyle &layerStyle : qgis::as_const( mStyles ) ) + { + if ( !layerStyle.isActive( zoomLevel ) ) + continue; + + QgsFields fields = QgsVectorTileUtils::makeQgisFields( mRequiredFields[layerStyle.layerName()] ); + + QgsExpressionContextScope *scope = new QgsExpressionContextScope( QObject::tr( "Layer" ) ); + scope->setFields( fields ); + context.expressionContext().appendScope( scope ); + + QgsExpression filterExpression( layerStyle.filterExpression() ); + filterExpression.prepare( &context.expressionContext() ); + + QgsSymbol *sym = layerStyle.symbol(); + sym->startRender( context, QgsFields() ); + if ( layerStyle.layerName().isEmpty() ) + { + // matching all layers + for ( QString layerName : tileData.keys() ) + { + for ( const QgsFeature &f : tileData[layerName] ) + { + scope->setFeature( f ); + if ( filterExpression.isValid() && !filterExpression.evaluate( &context.expressionContext() ).toBool() ) + continue; + + if ( QgsWkbTypes::geometryType( f.geometry().wkbType() ) == layerStyle.geometryType() ) + sym->renderFeature( f, context ); + } + } + } + else if ( tileData.contains( layerStyle.layerName() ) ) + { + // matching one particular layer + for ( const QgsFeature &f : tileData[layerStyle.layerName()] ) + { + scope->setFeature( f ); + if ( filterExpression.isValid() && !filterExpression.evaluate( &context.expressionContext() ).toBool() ) + continue; + + if ( QgsWkbTypes::geometryType( f.geometry().wkbType() ) == layerStyle.geometryType() ) + sym->renderFeature( f, context ); + } + } + sym->stopRender( context ); + + delete context.expressionContext().popScope(); + } +} + +void QgsVectorTileBasicRenderer::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const +{ + QDomDocument doc = elem.ownerDocument(); + QDomElement elemStyles = doc.createElement( "styles" ); + for ( const QgsVectorTileBasicRendererStyle &layerStyle : mStyles ) + { + QDomElement elemStyle = doc.createElement( "style" ); + layerStyle.writeXml( elemStyle, context ); + elemStyles.appendChild( elemStyle ); + } + elem.appendChild( elemStyles ); +} + +void QgsVectorTileBasicRenderer::readXml( const QDomElement &elem, const QgsReadWriteContext &context ) +{ + mStyles.clear(); + + QDomElement elemStyles = elem.firstChildElement( "styles" ); + QDomElement elemStyle = elemStyles.firstChildElement( "style" ); + while ( !elemStyle.isNull() ) + { + QgsVectorTileBasicRendererStyle layerStyle; + layerStyle.readXml( elemStyle, context ); + mStyles.append( layerStyle ); + } +} + +void QgsVectorTileBasicRenderer::setStyles( const QList &styles ) +{ + mStyles = styles; +} + +QList QgsVectorTileBasicRenderer::styles() const +{ + return mStyles; +} + +void QgsVectorTileBasicRenderer::setDefaultStyle() +{ + QColor color = Qt::blue; + QColor polygonColor = color; + polygonColor.setAlpha( 100 ); + QColor pointColor = Qt::red; + + QgsFillSymbol *polygonSymbol = static_cast( QgsLineSymbol::defaultSymbol( QgsWkbTypes::PolygonGeometry ) ); + polygonSymbol->setColor( polygonColor ); + + QgsLineSymbol *lineSymbol = static_cast( QgsLineSymbol::defaultSymbol( QgsWkbTypes::LineGeometry ) ); + lineSymbol->setColor( color ); + + QgsMarkerSymbol *pointSymbol = static_cast( QgsLineSymbol::defaultSymbol( QgsWkbTypes::PointGeometry ) ); + pointSymbol->setColor( pointColor ); + + QgsVectorTileBasicRendererStyle st1( "polygons", QString(), QgsWkbTypes::PolygonGeometry ); + st1.setSymbol( polygonSymbol ); + + QgsVectorTileBasicRendererStyle st2( "lines", QString(), QgsWkbTypes::LineGeometry ); + st2.setSymbol( lineSymbol ); + + QgsVectorTileBasicRendererStyle st3( "points", QString(), QgsWkbTypes::PointGeometry ); + st3.setSymbol( pointSymbol ); + + QList lst; + lst << st1 << st2 << st3; + setStyles( lst ); +} diff --git a/src/core/vectortile/qgsvectortilebasicrenderer.h b/src/core/vectortile/qgsvectortilebasicrenderer.h new file mode 100644 index 00000000000..e938877cecc --- /dev/null +++ b/src/core/vectortile/qgsvectortilebasicrenderer.h @@ -0,0 +1,156 @@ +/*************************************************************************** + qgsvectortilebasicrenderer.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILEBASICRENDERER_H +#define QGSVECTORTILEBASICRENDERER_H + +#include "qgsvectortilerenderer.h" + +class QgsLineSymbol; +class QgsFillSymbol; +class QgsMarkerSymbol; + +class QgsSymbol; + +/** + * \ingroup core + * Definition of map rendering of a subset of vector tile data. The subset of data is defined by: + * 1. sub-layer name + * 2. geometry type (a single sub-layer may have multiple geometry types) + * 3. filter expression + * + * Renering is determined by the associated symbol (QgsSymbol). Symbol has to be of the same + * type as the chosen geometryType() - i.e. QgsMarkerSymbol for points, QgsLineSymbol for linestrings + * and QgsFillSymbol for polygons. + * + * It is possible to further constrain when this style is applied by setting a range of allowed + * zoom levels, or by disabling it. + * + * \since QGIS 3.14 + */ +struct QgsVectorTileBasicRendererStyle +{ + public: + //! Constructs a style object + QgsVectorTileBasicRendererStyle( const QString &stName = QString(), const QString &laName = QString(), QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ); + + QgsVectorTileBasicRendererStyle( const QgsVectorTileBasicRendererStyle &other ); + QgsVectorTileBasicRendererStyle &operator=( const QgsVectorTileBasicRendererStyle &other ); + + //! Sets human readable name of this style + void setStyleName( const QString &name ) { mStyleName = name; } + //! Returns human readable name of this style + QString styleName() const { return mStyleName; } + + //! Sets name of the sub-layer to render (empty layer means that all layers match) + void setLayerName( const QString &name ) { mLayerName = name; } + //! Returns name of the sub-layer to render (empty layer means that all layers match) + QString layerName() const { return mLayerName; } + + //! Sets type of the geometry that will be used (point / line / polygon) + void setGeometryType( QgsWkbTypes::GeometryType geomType ) { mGeometryType = geomType; } + //! Returns type of the geometry that will be used (point / line / polygon) + QgsWkbTypes::GeometryType geometryType() const { return mGeometryType; } + + //! Sets filter expression (empty filter means that all features match) + void setFilterExpression( const QString &expr ) { mExpression = expr; } + //! Returns filter expression (empty filter means that all features match) + QString filterExpression() const { return mExpression; } + + //! Sets symbol for rendering. Takes ownership of the symbol. + void setSymbol( QgsSymbol *sym ); + //! Returns symbol for rendering + QgsSymbol *symbol() const { return mSymbol.get(); } + + //! Sets whether this style is enabled (used for rendering) + void setEnabled( bool enabled ) { mEnabled = enabled; } + //! Returns whether this style is enabled (used for rendering) + bool isEnabled() const { return mEnabled; } + + //! Sets minimum zoom level index (negative number means no limit) + void setMinZoomLevel( int minZoom ) { mMinZoomLevel = minZoom; } + //! Returns minimum zoom level index (negative number means no limit) + int minZoomLevel() const { return mMinZoomLevel; } + + //! Sets maximum zoom level index (negative number means no limit) + void setMaxZoomLevel( int maxZoom ) { mMaxZoomLevel = maxZoom; } + //! Returns maxnimum zoom level index (negative number means no limit) + int maxZoomLevel() const { return mMaxZoomLevel; } + + //! Returns whether the style is active at given zoom level (also checks "enabled" flag) + bool isActive( int zoomLevel ) const + { + return mEnabled && ( mMinZoomLevel == -1 || zoomLevel >= mMinZoomLevel ) && ( mMaxZoomLevel == -1 || zoomLevel <= mMaxZoomLevel ); + } + + //! Writes object content to given DOM element + void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const; + //! Reads object content from given DOM element + void readXml( const QDomElement &elem, const QgsReadWriteContext &context ); + + private: + QString mStyleName; + QString mLayerName; + QgsWkbTypes::GeometryType mGeometryType; + std::unique_ptr mSymbol; + bool mEnabled = true; + QString mExpression; + int mMinZoomLevel = -1; + int mMaxZoomLevel = -1; +}; + + +/** + * \ingroup core + * The default vector tile renderer implementation. It has an ordered list of "styles", + * each defines a rendering rule. + * + * \since QGIS 3.14 + */ +class QgsVectorTileBasicRenderer : public QgsVectorTileRenderer +{ + public: + //! Constructs renderer with some default styles + QgsVectorTileBasicRenderer(); + + QString type() const override; + QgsVectorTileBasicRenderer *clone() const override; + void startRender( QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange ) override; + QMap > usedAttributes( const QgsRenderContext & ) override; + void stopRender( QgsRenderContext &context ) override; + void renderTile( const QgsVectorTileRendererData &tile, QgsRenderContext &context ) override; + void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override; + void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override; + + //! Sets list of styles of the renderer + void setStyles( const QList &styles ); + //! Returns list of styles of the renderer + QList styles() const; + + private: + void setDefaultStyle(); + + private: + //! List of rendering styles + QList mStyles; + + // temporary bits + + //! Names of required fields for each sub-layer (only valid between startRender/stopRender calls) + QMap > mRequiredFields; + +}; + +#endif // QGSVECTORTILEBASICRENDERER_H diff --git a/src/core/vectortile/qgsvectortilelayer.cpp b/src/core/vectortile/qgsvectortilelayer.cpp new file mode 100644 index 00000000000..b035fde77b9 --- /dev/null +++ b/src/core/vectortile/qgsvectortilelayer.cpp @@ -0,0 +1,176 @@ +/*************************************************************************** + qgsvectortilelayer.cpp + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsvectortilelayer.h" + +#include "qgsvectortilelayerrenderer.h" +#include "qgsmbtilesreader.h" +#include "qgsvectortilebasicrenderer.h" +#include "qgsvectortileloader.h" + +#include "qgsdatasourceuri.h" + +QgsVectorTileLayer::QgsVectorTileLayer( const QString &uri, const QString &baseName ) + : QgsPluginLayer( "vector-tile", baseName ) +{ + mDataSource = uri; + + QgsDataSourceUri dsUri; + dsUri.setEncodedUri( uri ); + + mSourceType = dsUri.param( "type" ); + mSourcePath = dsUri.param( "url" ); + if ( mSourceType == "xyz" ) + { + // online tiles + mSourceMinZoom = 0; + mSourceMaxZoom = 14; + + setExtent( QgsRectangle( -20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892 ) ); + } + else if ( mSourceType == "mbtiles" ) + { + QgsMBTilesReader reader( mSourcePath ); + if ( !reader.open() ) + { + qDebug() << "failed to open MBTiles file:" << mSourcePath; + return; + } + + qDebug() << "name:" << reader.metadataValue( "name" ); + bool minZoomOk, maxZoomOk; + int minZoom = reader.metadataValue( "minzoom" ).toInt( &minZoomOk ); + int maxZoom = reader.metadataValue( "maxzoom" ).toInt( &maxZoomOk ); + if ( minZoomOk ) + mSourceMinZoom = minZoom; + if ( maxZoomOk ) + mSourceMaxZoom = maxZoom; + qDebug() << "zoom range:" << mSourceMinZoom << mSourceMaxZoom; + + QgsRectangle r = reader.extent(); + // TODO: reproject to EPSG:3857 + setExtent( r ); + } + else + { + // TODO: report error - unknown type + return; + } + + setCrs( QgsCoordinateReferenceSystem( "EPSG:3857" ) ); + setValid( true ); + + // set a default renderer + setRenderer( new QgsVectorTileBasicRenderer ); +} + +QgsVectorTileLayer::~QgsVectorTileLayer() = default; + + +QgsPluginLayer *QgsVectorTileLayer::clone() const +{ + QgsVectorTileLayer *layer = new QgsVectorTileLayer( source(), name() ); + layer->setRenderer( renderer() ? renderer()->clone() : nullptr ); + return layer; +} + +QgsMapLayerRenderer *QgsVectorTileLayer::createMapRenderer( QgsRenderContext &rendererContext ) +{ + return new QgsVectorTileLayerRenderer( this, rendererContext ); +} + +bool QgsVectorTileLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) +{ + QString errorMsg; + return readSymbology( layerNode, errorMsg, context ); +} + +bool QgsVectorTileLayer::writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const +{ + QDomElement mapLayerNode = layerNode.toElement(); + mapLayerNode.setAttribute( "type", "vector-tile" ); + + QString errorMsg; + return writeSymbology( layerNode, doc, errorMsg, context ); +} + +bool QgsVectorTileLayer::readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) +{ + QDomElement elem = node.toElement(); + + readCommonStyle( elem, context, categories ); + + QDomElement elemRenderer = elem.firstChildElement( "renderer" ); + if ( elemRenderer.isNull() ) + { + errorMessage = "Missing tag"; + return false; + } + QString rendererType = elemRenderer.attribute( "type" ); + QgsVectorTileRenderer *r = nullptr; + if ( rendererType == "basic" ) + r = new QgsVectorTileBasicRenderer; + //else if ( rendererType == "mapbox-gl" ) + // r = new MapboxGLStyleRenderer; + else + { + errorMessage = "Unknown renderer type: " + rendererType; + return false; + } + + r->readXml( elemRenderer, context ); + return true; +} + +bool QgsVectorTileLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const +{ + Q_UNUSED( errorMessage ) + QDomElement elem = node.toElement(); + + writeCommonStyle( elem, doc, context, categories ); + + if ( mRenderer ) + { + QDomElement elemRenderer = doc.createElement( "renderer" ); + elemRenderer.setAttribute( "type", mRenderer->type() ); + mRenderer->writeXml( elemRenderer, context ); + elem.appendChild( elemRenderer ); + } + return true; +} + +void QgsVectorTileLayer::setTransformContext( const QgsCoordinateTransformContext &transformContext ) +{ + Q_UNUSED( transformContext ) +} + +QByteArray QgsVectorTileLayer::getRawTile( QgsTileXYZ tileID ) +{ + QgsTileRange tileRange( tileID.column(), tileID.column(), tileID.row(), tileID.row() ); + QList rawTiles = QgsVectorTileLoader::blockingFetchTileRawData( mSourceType, mSourcePath, tileID.zoomLevel(), QPointF(), tileRange ); + if ( rawTiles.isEmpty() ) + return QByteArray(); + return rawTiles.first().data; +} + +void QgsVectorTileLayer::setRenderer( QgsVectorTileRenderer *r ) +{ + mRenderer.reset( r ); +} + +QgsVectorTileRenderer *QgsVectorTileLayer::renderer() const +{ + return mRenderer.get(); +} diff --git a/src/core/vectortile/qgsvectortilelayer.h b/src/core/vectortile/qgsvectortilelayer.h new file mode 100644 index 00000000000..675b97044c2 --- /dev/null +++ b/src/core/vectortile/qgsvectortilelayer.h @@ -0,0 +1,148 @@ +/*************************************************************************** + qgsvectortilelayer.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILELAYER_H +#define QGSVECTORTILELAYER_H + +#include "qgis_core.h" +#include "qgis_sip.h" + +#include "qgspluginlayer.h" + +class QgsVectorTileRenderer; + +struct QgsTileXYZ; + +/** + * \ingroup core + * Implements a map layer that is dedicated to rendering of vector tiles. + * Vector tiles compared to "ordinary" vector layers are pre-processed data + * optimized for fast rendering. A dataset is provided with a series of zoom levels + * for different map scales. Each zoom level has a matrix of tiles that contain + * actual data. A single vector tile may be a a file stored on a local drive, + * requested over HTTP request or retrieved from a database. + * + * Content of a vector tile is divided into one or more named sub-layers. Each such + * sub-layer may contain many features which consist of geometry and attributes. + * Contrary to traditional vector layers, these sub-layers do not need to have a rigid + * schema where geometry type and attributes are the same for all features. A single + * sub-layer may have multiple geometry types in a single tile or have some attributes + * defined only at particular zoom levels. + * + * Vector tile layer currently does not use the concept of data providers that other + * layer types use. The process of rendering of vector tiles looks like this: + * + * +--------+ +------+ +---------+ + * | DATA | | RAW | | DECODED | + * | | --> LOADER --> | | --> DECODER --> | | --> RENDERER + * | SOURCE | | TILE | | TILE | + * +--------+ +------+ +---------+ + * + * Data source is a place from where tiles are fetched from (URL for HTTP access, local + * files, MBTiles file, GeoPackage file or others. Loader (QgsVectorTileLoader) class + * takes care of loading data from the data source. The "raw tile" data is just a blob + * (QByteArray) that is encoded in some way. There are multiple ways how vector tiles + * are encoded just like there are different formats how to store images. For example, + * tiles can be encoded using Mapbox Vector Tiles (MVT) format or in GeoJSON. Decoder + * (QgsVectorTileDecoder) takes care of decoding raw tile data into QgsFeature objects. + * A decoded tile is essentially an array of vector features for each sub-layer found + * in the tile - this is what vector tile renderer (QgsVectorTileRenderer) expects + * and does the map rendering. + * + * To construct a vector tile layer, it is best to use QgsDataSourceUri class and set + * the following parameters to get a valid encoded URI: + * - "type" - what kind of data source will be used + * - "url" - URL or path of the data source (specific to each data source type, see below) + * + * Currently supported data source types: + * - "xyz" - the "url" should be a template like http://example.com/{z}/{x}/{y}.pbf where + * {x},{y},{z} will be replaced by tile coordinates + * - "mbtiles" - tiles read from a MBTiles file (a SQLite database) + * + * Currently supported decoders: + * - MVT - following Mapbox Vector Tiles specification + * + * \since QGIS 3.14 + */ +class CORE_EXPORT QgsVectorTileLayer : public QgsPluginLayer +{ + public: + //! Constructs a new vector tile layer + explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString() ); + ~QgsVectorTileLayer(); + + // implementation of virtual functions from QgsMapLayer + + QgsPluginLayer *clone() const override; + + virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override; + + virtual bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override; + + virtual bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override; + + virtual bool readSymbology( const QDomNode &node, QString &errorMessage, + QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override; + + virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, + StyleCategories categories = AllStyleCategories ) const override; + + virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override; + + // new methods + + //! Returns type of the data source + QString sourceType() const { return mSourceType; } + //! Returns URL/path of the data source (syntax different to each data source type) + QString sourcePath() const { return mSourcePath; } + + //! Returns minimum zoom level at which source has any valid tiles (negative = unconstrained) + int sourceMinZoom() const { return mSourceMinZoom; } + //! Returns maximum zoom level at which source has any valid tiles (negative = unconstrained) + int sourceMaxZoom() const { return mSourceMaxZoom; } + + /** + * Fetches raw tile data for the give tile coordinates. If failed to fetch tile data, + * it will return an empty byte array. + * + * \note This call may issue a network request (depending on the source type) and will block + * the caller until the request is finished. + */ + QByteArray getRawTile( QgsTileXYZ tileID ) SIP_SKIP; + + /** + * Sets renderer for the map layer. + * \note Takes ownership of the passed renderer + */ + void setRenderer( QgsVectorTileRenderer *r ) SIP_SKIP; + //! Returns currently assigned renderer + QgsVectorTileRenderer *renderer() const SIP_SKIP; + + private: + //! Type of the data source + QString mSourceType; + //! URL/Path of the data source + QString mSourcePath; + //! Minimum zoom level at which source has any valid tiles (negative = unconstrained) + int mSourceMinZoom = -1; + //! Maximum zoom level at which source has any valid tiles (negative = unconstrained) + int mSourceMaxZoom = -1; + + //! Renderer assigned to the layer to draw map + std::unique_ptr mRenderer; +}; + + +#endif // QGSVECTORTILELAYER_H diff --git a/src/core/vectortile/qgsvectortilelayerrenderer.cpp b/src/core/vectortile/qgsvectortilelayerrenderer.cpp new file mode 100644 index 00000000000..47733c2d639 --- /dev/null +++ b/src/core/vectortile/qgsvectortilelayerrenderer.cpp @@ -0,0 +1,184 @@ +/*************************************************************************** + qgsvectortilelayerrenderer.cpp + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsvectortilelayerrenderer.h" + +#include + +#include "qgsexpressioncontextutils.h" +#include "qgsfeedback.h" + +#include "qgsvectortilemvtdecoder.h" +#include "qgsvectortilelayer.h" +#include "qgsvectortileloader.h" +#include "qgsvectortileutils.h" + + +QgsVectorTileLayerRenderer::QgsVectorTileLayerRenderer( QgsVectorTileLayer *layer, QgsRenderContext &context ) + : QgsMapLayerRenderer( layer->id(), &context ) + , mSourceType( layer->sourceType() ) + , mSourcePath( layer->sourcePath() ) + , mSourceMinZoom( layer->sourceMinZoom() ) + , mSourceMaxZoom( layer->sourceMaxZoom() ) + , mRenderer( layer->renderer()->clone() ) + , mFeedback( new QgsFeedback ) +{ +} + +bool QgsVectorTileLayerRenderer::render() +{ + QgsRenderContext &ctx = *renderContext(); + + if ( ctx.renderingStopped() ) + return false; + + QElapsedTimer tTotal; + tTotal.start(); + + qDebug() << "MVT rend" << ctx.extent().toString( -1 ); + + mTileZoom = QgsVectorTileUtils::scaleToZoomLevel( ctx.rendererScale(), mSourceMinZoom, mSourceMaxZoom ); + qDebug() << "MVT zoom level" << mTileZoom; + + mTileMatrix = QgsTileMatrix::fromWebMercator( mTileZoom ); + + mTileRange = mTileMatrix.tileRangeFromExtent( ctx.extent() ); + qDebug() << "MVT tile range" << mTileRange.startColumn() << mTileRange.endColumn() << " | " << mTileRange.startRow() << mTileRange.endRow(); + + // view center is used to sort the order of tiles for fetching and rendering + QPointF viewCenter = mTileMatrix.mapToTileCoordinates( ctx.extent().center() ); + + if ( !mTileRange.isValid() ) + { + qDebug() << "outside of range"; + return true; // nothing to do + } + + bool isAsync = ( mSourceType == "xyz" ); + + std::unique_ptr asyncLoader; + QList rawTiles; + if ( !isAsync ) + { + QElapsedTimer tFetch; + tFetch.start(); + rawTiles = QgsVectorTileLoader::blockingFetchTileRawData( mSourceType, mSourcePath, mTileZoom, viewCenter, mTileRange ); + qDebug() << "FETCH TIME" << tFetch.elapsed() / 1000.; + qDebug() << "fetched tiles:" << rawTiles.count(); + } + else + { + asyncLoader.reset( new QgsVectorTileLoader( mSourcePath, mTileZoom, mTileRange, viewCenter, mFeedback.get() ) ); + QObject::connect( asyncLoader.get(), &QgsVectorTileLoader::tileRequestFinished, [this]( const QgsVectorTileRawData & rawTile ) + { + qDebug() << "got async tile" << rawTile.id.column() << rawTile.id.row() << rawTile.id.zoomLevel(); + if ( !rawTile.data.isEmpty() ) + decodeAndDrawTile( rawTile ); + } ); + } + + if ( ctx.renderingStopped() ) + return false; + + mRenderer->startRender( *renderContext(), mTileZoom, mTileRange ); + + QMap > requiredFields = mRenderer->usedAttributes( *renderContext() ); + + QMap perLayerFields; + for ( QString layerName : requiredFields.keys() ) + mPerLayerFields[layerName] = QgsVectorTileUtils::makeQgisFields( requiredFields[layerName] ); + + if ( !isAsync ) + { + for ( QgsVectorTileRawData &rawTile : rawTiles ) + { + if ( ctx.renderingStopped() ) + break; + + decodeAndDrawTile( rawTile ); + } + } + else + { + // Block until tiles are fetched and rendered. If the rendering gets cancelled at some point, + // the async loader will catch the signal, abort requests and return from downloadBlocking() + asyncLoader->downloadBlocking(); + } + + mRenderer->stopRender( ctx ); + + ctx.painter()->setClipping( false ); + + qDebug() << "DECODE TIME" << mTotalDecodeTime / 1000.; + qDebug() << "DRAW TIME" << mTotalDrawTime / 1000.; + qDebug() << "TOTAL TIME" << tTotal.elapsed() / 1000.; + + return !ctx.renderingStopped(); +} + +void QgsVectorTileLayerRenderer::decodeAndDrawTile( const QgsVectorTileRawData &rawTile ) +{ + QgsRenderContext &ctx = *renderContext(); + + qDebug() << "decoding tile " << rawTile.id.zoomLevel() << rawTile.id.column() << rawTile.id.row(); + + QElapsedTimer tLoad; + tLoad.start(); + + // currently only MVT encoding supported + QgsVectorTileMVTDecoder decoder; + if ( !decoder.decode( rawTile.id, rawTile.data ) ) + { + qDebug() << "Failed to parse raw tile data!"; + return; + } + + if ( ctx.renderingStopped() ) + return; + + QgsVectorTileRendererData tile; + tile.id = rawTile.id; + tile.features = decoder.layerFeatures( mPerLayerFields ); + + mTotalDecodeTime += tLoad.elapsed(); + + // calculate tile polygon in screen coordinates + tile.tilePolygon = QgsVectorTileUtils::tilePolygon( rawTile.id, mTileMatrix, ctx.mapToPixel() ); + + if ( ctx.renderingStopped() ) + return; + + // set up clipping so that rendering does not go behind tile's extent + + ctx.painter()->setClipRegion( QRegion( tile.tilePolygon ) ); + + qDebug() << "drawing tile" << tile.id.zoomLevel() << tile.id.column() << tile.id.row(); + + QElapsedTimer tDraw; + tDraw.start(); + + mRenderer->renderTile( tile, ctx ); + mTotalDrawTime += tDraw.elapsed(); + + if ( mDrawTileBoundaries ) + { + ctx.painter()->setClipping( false ); + + QPen pen( Qt::red ); + pen.setWidth( 3 ); + ctx.painter()->setPen( pen ); + ctx.painter()->drawPolygon( tile.tilePolygon ); + } +} diff --git a/src/core/vectortile/qgsvectortilelayerrenderer.h b/src/core/vectortile/qgsvectortilelayerrenderer.h new file mode 100644 index 00000000000..e6b87ee8395 --- /dev/null +++ b/src/core/vectortile/qgsvectortilelayerrenderer.h @@ -0,0 +1,83 @@ +/*************************************************************************** + qgsvectortilelayerrenderer.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILELAYERRENDERER_H +#define QGSVECTORTILELAYERRENDERER_H + +#include "qgsmaplayerrenderer.h" + +class QgsVectorTileLayer; +class QgsVectorTileRawData; + +#include "qgsvectortilerenderer.h" + +/** + * \ingroup core + * This class provides map rendering functionality for vector tile layers. + * In render() function (assumed to be run in a worker thread) it will: + * 1. fetch vector tiles using QgsVectorTileLoader + * 2. decode raw tiles into QgsFeature objects using QgsVectorTileDecoder + * 3. render tiles using a class derived from QgsVectorTileRenderer + * + * \since QGIS 3.14 + */ +class QgsVectorTileLayerRenderer : public QgsMapLayerRenderer +{ + public: + //! Creates the renderer. Always called from main thread, should copy whatever necessary from the layer + QgsVectorTileLayerRenderer( QgsVectorTileLayer *layer, QgsRenderContext &context ); + + virtual bool render() override; + virtual QgsFeedback *feedback() const override { return mFeedback.get(); } + + private: + void decodeAndDrawTile( const QgsVectorTileRawData &rawTile ); + + // data coming from the vector tile layer + + //! Type of the source from which we will be loading tiles (e.g. "xyz" or "mbtiles") + QString mSourceType; + //! Path/URL of the source. Format depends on source type + QString mSourcePath; + //! Minimum zoom level at which source has any valid tiles (negative = unconstrained) + int mSourceMinZoom = -1; + //! Maximum zoom level at which source has any valid tiles (negative = unconstrained) + int mSourceMaxZoom = -1; + //! Tile renderer object to do rendering of individual tiles + std::unique_ptr mRenderer; + + //! Whether to draw boundaries of tiles (useful for debugging) + bool mDrawTileBoundaries = true; + + // temporary data used during rendering process + + //! Feedback object that may be used by the caller to cancel the rendering + std::unique_ptr mFeedback; + //! Zoom level at which we will be rendering + int mTileZoom = 0; + //! Definition of the tile matrix for our zoom level + QgsTileMatrix mTileMatrix; + //!< Block of tiles we will be rendering in that zoom level + QgsTileRange mTileRange; + //! Cached QgsFields object for each sub-layer that will be rendered + QMap mPerLayerFields; + //! Counter of total elapsed time to decode tiles (ms) + int mTotalDecodeTime = 0; + //! Counter of total elapsed time to render tiles (ms) + int mTotalDrawTime = 0; +}; + + +#endif // QGSVECTORTILELAYERRENDERER_H diff --git a/src/core/vectortile/qgsvectortileloader.cpp b/src/core/vectortile/qgsvectortileloader.cpp new file mode 100644 index 00000000000..e6e22d7fcfc --- /dev/null +++ b/src/core/vectortile/qgsvectortileloader.cpp @@ -0,0 +1,265 @@ +/*************************************************************************** + qgsvectortileloader.cpp + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsvectortileloader.h" + +#include +#include + +#include + +#include "qgsblockingnetworkrequest.h" +#include "qgsmbtilesreader.h" +#include "qgsnetworkaccessmanager.h" +#include "qgsvectortileutils.h" + +QgsVectorTileLoader::QgsVectorTileLoader( const QString &uri, int zoomLevel, const QgsTileRange &range, const QPointF &viewCenter, QgsFeedback *feedback ) + : mEventLoop( new QEventLoop ) + , mFeedback( feedback ) +{ + if ( feedback ) + { + connect( feedback, &QgsFeedback::canceled, this, &QgsVectorTileLoader::canceled, Qt::QueuedConnection ); + + // rendering could have been canceled before we started to listen to canceled() signal + // so let's check before doing the download and maybe quit prematurely + if ( feedback->isCanceled() ) + return; + } + + qDebug() << "starting loader"; + QVector tiles = QgsVectorTileUtils::tilesInRange( range, zoomLevel ); + QgsVectorTileUtils::sortTilesByDistanceFromCenter( tiles, viewCenter ); + for ( QgsTileXYZ id : qgis::as_const( tiles ) ) + { + loadFromNetworkAsync( id, uri ); + } +} + +QgsVectorTileLoader::~QgsVectorTileLoader() +{ + qDebug() << "terminating loader"; + + if ( !mReplies.isEmpty() ) + { + // this can happen when the loader is terminated without getting requests finalized + // (e.g. downloadBlocking() was not called) + canceled(); + } +} + +void QgsVectorTileLoader::downloadBlocking() +{ + qDebug() << "starting event loop" << mReplies.count() << "requests"; + + if ( mFeedback && mFeedback->isCanceled() ) + { + qDebug() << "actually not - we were cancelled"; + return; // nothing to do + } + + mEventLoop->exec( QEventLoop::ExcludeUserInputEvents ); + + qDebug() << "download blocking finished"; + + Q_ASSERT( mReplies.isEmpty() ); +} + +void QgsVectorTileLoader::loadFromNetworkAsync( const QgsTileXYZ &id, const QString &requestUrl ) +{ + QString url = QgsVectorTileUtils::formatXYZUrlTemplate( requestUrl, id ); + QNetworkRequest request( url ); + // TODO: some extra headers? QgsSetRequestInitiatorClass / auth / "Accept" header + request.setAttribute( static_cast( QNetworkRequest::User + 1 ), id.column() ); + request.setAttribute( static_cast( QNetworkRequest::User + 2 ), id.row() ); + request.setAttribute( static_cast( QNetworkRequest::User + 3 ), id.zoomLevel() ); + + request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache ); + request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true ); + + QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request ); + connect( reply, &QNetworkReply::finished, this, &QgsVectorTileLoader::tileReplyFinished ); + + mReplies << reply; +} + +void QgsVectorTileLoader::tileReplyFinished() +{ + QNetworkReply *reply = qobject_cast( sender() ); + + int reqX = reply->request().attribute( static_cast( QNetworkRequest::User + 1 ) ).toInt(); + int reqY = reply->request().attribute( static_cast( QNetworkRequest::User + 2 ) ).toInt(); + int reqZ = reply->request().attribute( static_cast( QNetworkRequest::User + 3 ) ).toInt(); + QgsTileXYZ tileID( reqX, reqY, reqZ ); + + if ( reply->error() == QNetworkReply::NoError ) + { + // TODO: handle redirections? + + qDebug() << "tile reply - all good!"; + QByteArray rawData = reply->readAll(); + mReplies.removeOne( reply ); + reply->deleteLater(); + + emit tileRequestFinished( QgsVectorTileRawData( tileID, rawData ) ); + } + else + { + qDebug() << "tile reply - error! " << reply->errorString(); + mReplies.removeOne( reply ); + reply->deleteLater(); + + emit tileRequestFinished( QgsVectorTileRawData( tileID, QByteArray() ) ); + } + + if ( mReplies.isEmpty() ) + { + // exist the event loop + QMetaObject::invokeMethod( mEventLoop.get(), "quit", Qt::QueuedConnection ); + } +} + +void QgsVectorTileLoader::canceled() +{ + qDebug() << "cancelling pending requests"; + const QList replies = mReplies; + for ( QNetworkReply *reply : replies ) + { + qDebug() << "aborting request"; + reply->abort(); + } +} + +////// + +QList QgsVectorTileLoader::blockingFetchTileRawData( const QString &sourceType, const QString &sourcePath, int zoomLevel, const QPointF &viewCenter, const QgsTileRange &range ) +{ + QList rawTiles; + + QgsMBTilesReader mbReader( sourcePath ); + bool isUrl = ( sourceType == "xyz" ); + if ( !isUrl ) + { + bool res = mbReader.open(); + Q_ASSERT( res ); + } + + QVector tiles = QgsVectorTileUtils::tilesInRange( range, zoomLevel ); + QgsVectorTileUtils::sortTilesByDistanceFromCenter( tiles, viewCenter ); + for ( QgsTileXYZ id : qgis::as_const( tiles ) ) + { + QByteArray rawData = isUrl ? loadFromNetwork( id, sourcePath ) : loadFromMBTiles( id, mbReader ); + if ( !rawData.isEmpty() ) + { + rawTiles.append( QgsVectorTileRawData( id, rawData ) ); + } + } + return rawTiles; +} + +QByteArray QgsVectorTileLoader::loadFromNetwork( const QgsTileXYZ &id, const QString &requestUrl ) +{ + QString url = QgsVectorTileUtils::formatXYZUrlTemplate( requestUrl, id ); + QNetworkRequest nr; + nr.setUrl( QUrl( url ) ); + QgsBlockingNetworkRequest req; + qDebug() << "requestiong" << url; + QgsBlockingNetworkRequest::ErrorCode errCode = req.get( nr ); + qDebug() << "get" << errCode; + QgsNetworkReplyContent reply = req.reply(); + qDebug() << "content size" << reply.content().size(); + return reply.content(); +} + + +QByteArray QgsVectorTileLoader::loadFromMBTiles( const QgsTileXYZ &id, QgsMBTilesReader &mbTileReader ) +{ + // MBTiles uses TMS specs with Y starting at the bottom while XYZ uses Y starting at the top + int rowTMS = pow( 2, id.zoomLevel() ) - id.row() - 1; + QByteArray gzippedTileData = mbTileReader.tileData( id.zoomLevel(), id.column(), rowTMS ); + if ( gzippedTileData.isEmpty() ) + { + qDebug() << "Failed to get tile" << id.zoomLevel() << id.column() << id.row(); + return QByteArray(); + } + + // TODO: check format is "pbf" + + QByteArray data; + if ( !decodeGzip( gzippedTileData, data ) ) + { + qDebug() << "failed to decompress tile" << id.zoomLevel() << id.column() << id.row(); + return QByteArray(); + } + + qDebug() << "tile blob size" << gzippedTileData.size() << " -> uncompressed size" << data.size(); + return data; +} + + +bool QgsVectorTileLoader::decodeGzip( const QByteArray &bytesIn, QByteArray &bytesOut ) +{ + unsigned char *bytesInPtr = reinterpret_cast( const_cast( bytesIn.constData() ) ); + uint bytesInLeft = static_cast( bytesIn.count() ); + + const uint CHUNK = 16384; + unsigned char out[CHUNK]; + const int DEC_MAGIC_NUM_FOR_GZIP = 16; + + // allocate inflate state + z_stream strm; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + strm.avail_in = 0; + strm.next_in = Z_NULL; + + int ret = inflateInit2( &strm, MAX_WBITS + DEC_MAGIC_NUM_FOR_GZIP ); + if ( ret != Z_OK ) + return false; + + while ( ret != Z_STREAM_END ) // done when inflate() says it's done + { + // prepare next chunk + uint bytesToProcess = std::min( CHUNK, bytesInLeft ); + strm.next_in = bytesInPtr; + strm.avail_in = bytesToProcess; + bytesInPtr += bytesToProcess; + bytesInLeft -= bytesToProcess; + + if ( bytesToProcess == 0 ) + break; // we end with an error - no more data but inflate() wants more data + + // run inflate() on input until output buffer not full + do + { + strm.avail_out = CHUNK; + strm.next_out = out; + ret = inflate( &strm, Z_NO_FLUSH ); + Q_ASSERT( ret != Z_STREAM_ERROR ); // state not clobbered + if ( ret == Z_NEED_DICT || ret == Z_DATA_ERROR || ret == Z_MEM_ERROR ) + { + inflateEnd( &strm ); + return false; + } + unsigned have = CHUNK - strm.avail_out; + bytesOut.append( QByteArray::fromRawData( reinterpret_cast( out ), static_cast( have ) ) ); + } + while ( strm.avail_out == 0 ); + } + + inflateEnd( &strm ); + return ret == Z_STREAM_END; +} diff --git a/src/core/vectortile/qgsvectortileloader.h b/src/core/vectortile/qgsvectortileloader.h new file mode 100644 index 00000000000..e1ca631b1e2 --- /dev/null +++ b/src/core/vectortile/qgsvectortileloader.h @@ -0,0 +1,100 @@ +/*************************************************************************** + qgsvectortileloader.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILELOADER_H +#define QGSVECTORTILELOADER_H + +class QByteArray; + +#include "qgsvectortilerenderer.h" + +/** + * \ingroup core + * Keeps track of raw tile data that need to be decoded + * + * \since QGIS 3.14 + */ +class QgsVectorTileRawData +{ + public: + QgsVectorTileRawData( QgsTileXYZ tileID = QgsTileXYZ(), const QByteArray &raw = QByteArray() ) + : id( tileID ), data( raw ) {} + + //! Tile position in tile matrix set + QgsTileXYZ id; + //! Raw tile data + QByteArray data; +}; + + +class QNetworkReply; +class QEventLoop; + +class QgsMBTilesReader; + +/** + * \ingroup core + * The loader class takes care of loading raw vector tile data from a tile source. + * + * \since QGIS 3.14 + */ +class QgsVectorTileLoader : public QObject +{ + Q_OBJECT + public: + + //! Returns raw tile data for the specified range of tiles. Blocks the caller until all tiles are fetched. + static QList blockingFetchTileRawData( const QString &sourceType, const QString &sourcePath, int zoomLevel, const QPointF &viewCenter, const QgsTileRange &range ); + + //! Returns raw tile data for a single tile, doing a HTTP request. Block the caller until tile data are downloaded. + static QByteArray loadFromNetwork( const QgsTileXYZ &id, const QString &requestUrl ); + //! Returns raw tile data for a signle tile loaded from MBTiles file + static QByteArray loadFromMBTiles( const QgsTileXYZ &id, QgsMBTilesReader &mbTileReader ); + //! Decodes gzip byte stream, returns true on success + static bool decodeGzip( const QByteArray &bytesIn, QByteArray &bytesOut ); + + // + // non-static stuff + // + + //! Constructs tile loader for doing asynchronous requests and starts network requests + QgsVectorTileLoader( const QString &uri, int zoomLevel, const QgsTileRange &range, const QPointF &viewCenter, QgsFeedback *feedback ); + ~QgsVectorTileLoader(); + + //! Blocks the caller until all asynchronous requests are finished (with a success or a failure) + void downloadBlocking(); + + private: + void loadFromNetworkAsync( const QgsTileXYZ &id, const QString &requestUrl ); + + private slots: + void tileReplyFinished(); + void canceled(); + + signals: + //! Emitted when a tile request has finished. If a tile request has failed, the returned raw tile byte array is empty. + void tileRequestFinished( const QgsVectorTileRawData &rawTile ); + + private: + //! Event loop used for blocking download + std::unique_ptr mEventLoop; + //! Feedback object that allows cancellation of pending requests + QgsFeedback *mFeedback; + //! Running tile requests + QList mReplies; + +}; + +#endif // QGSVECTORTILELOADER_H diff --git a/src/core/vectortile/qgsvectortilemvtdecoder.cpp b/src/core/vectortile/qgsvectortilemvtdecoder.cpp new file mode 100644 index 00000000000..67f862cf045 --- /dev/null +++ b/src/core/vectortile/qgsvectortilemvtdecoder.cpp @@ -0,0 +1,322 @@ +/*************************************************************************** + qgsvectortilemvtdecoder.cpp + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include + +#include "qgsvectortilemvtdecoder.h" + +#include "qgsvectortilelayerrenderer.h" +#include "qgsvectortileutils.h" + +#include "qgsmultipoint.h" +#include "qgslinestring.h" +#include "qgsmultilinestring.h" +#include "qgsmultipolygon.h" +#include "qgspolygon.h" + + +inline bool _isExteriorRing( const QVector &pts ) +{ + // Exterior rings have POSITIVE area while interior rings have NEGATIVE area + // when calculated with https://en.wikipedia.org/wiki/Shoelace_formula + // The orientation of axes is that X grows to the right and Y grows to the bottom. + // the input data are expected to form a closed ring, i.e. first pt == last pt. + + double total = 0.0; + const QgsPoint *ptsPtr = pts.constData(); + int count = pts.count(); + for ( int i = 0; i < count - 1; i++ ) + { + double val = ( pts[i + 1].x() - ptsPtr[i].x() ) * ( ptsPtr[i + 1].y() + pts[i].y() ); + //double val = ptsPtr[i].x() * (-ptsPtr[i+1].y()) - ptsPtr[i+1].x() * (-ptsPtr[i].y()); // gives the same result + total += val; + } + return total >= 0; +} + + +bool QgsVectorTileMVTDecoder::decode( QgsTileXYZ tileID, const QByteArray &rawTileData ) +{ + if ( !tile.ParseFromArray( rawTileData.constData(), rawTileData.count() ) ) + return false; + + mTileID = tileID; + + mLayerNameToIndex.clear(); + for ( int layerNum = 0; layerNum < tile.layers_size(); layerNum++ ) + { + const ::vector_tile::Tile_Layer &layer = tile.layers( layerNum ); + QString layerName = layer.name().c_str(); + mLayerNameToIndex[layerName] = layerNum; + } + return true; +} + +QStringList QgsVectorTileMVTDecoder::layers() const +{ + QStringList layerNames; + for ( int layerNum = 0; layerNum < tile.layers_size(); layerNum++ ) + { + const ::vector_tile::Tile_Layer &layer = tile.layers( layerNum ); + QString layerName = layer.name().c_str(); + layerNames << layerName; + } + return layerNames; +} + +QStringList QgsVectorTileMVTDecoder::layerFieldNames( const QString &layerName ) const +{ + if ( !mLayerNameToIndex.contains( layerName ) ) + return QStringList(); + + const ::vector_tile::Tile_Layer &layer = tile.layers( mLayerNameToIndex[layerName] ); + QStringList fieldNames; + for ( int i = 0; i < layer.keys_size(); ++i ) + { + QString fieldName = layer.keys( i ).c_str(); + fieldNames << fieldName; + } + return fieldNames; +} + +QgsVectorTileFeatures QgsVectorTileMVTDecoder::layerFeatures( const QMap &perLayerFields ) const +{ + QgsVectorTileFeatures features; + + int numTiles = static_cast( pow( 2, mTileID.zoomLevel() ) ); // assuming we won't ever go over 30 zoom levels + double z0xMin = -20037508.3427892, z0yMin = -20037508.3427892; + double z0xMax = 20037508.3427892, z0yMax = 20037508.3427892; + double tileDX = ( z0xMax - z0xMin ) / numTiles; + double tileDY = ( z0yMax - z0yMin ) / numTiles; + double tileXMin = z0xMin + mTileID.column() * tileDX; + double tileYMax = z0yMax - mTileID.row() * tileDY; + + for ( int layerNum = 0; layerNum < tile.layers_size(); layerNum++ ) + { + const ::vector_tile::Tile_Layer &layer = tile.layers( layerNum ); + + QString layerName = layer.name().c_str(); + QVector layerFeatures; + QgsFields layerFields = perLayerFields[layerName]; + + // figure out how field indexes in MVT encoding map to field indexes in QgsFields (we may not use all available fields) + QHash tagKeyIndexToFieldIndex; + for ( int i = 0; i < layer.keys_size(); ++i ) + { + int fieldIndex = layerFields.indexOf( layer.keys( i ).c_str() ); + if ( fieldIndex != -1 ) + tagKeyIndexToFieldIndex.insert( i, fieldIndex ); + } + + // go through features of a layer + for ( int featureNum = 0; featureNum < layer.features_size(); featureNum++ ) + { + const ::vector_tile::Tile_Feature &feature = layer.features( featureNum ); + + QgsFeature f( layerFields, static_cast( feature.id() ) ); + + // initialize all fields to empty string. + // TODO: this should not be necessary, but some rules don't like NULL + for ( int i = 0; i < layerFields.count(); ++i ) + f.setAttribute( i, QStringLiteral( "" ) ); + + // + // parse attributes + // + + for ( int tagNum = 0; tagNum < feature.tags_size(); tagNum += 2 ) + { + int keyIndex = static_cast( feature.tags( tagNum ) ); + int fieldIndex = tagKeyIndexToFieldIndex.value( keyIndex, -1 ); + if ( fieldIndex == -1 ) + continue; + + int valueIndex = static_cast( feature.tags( tagNum + 1 ) ); + const ::vector_tile::Tile_Value &value = layer.values( valueIndex ); + + if ( value.has_string_value() ) + f.setAttribute( fieldIndex, QString::fromStdString( value.string_value() ) ); + else if ( value.has_float_value() ) + f.setAttribute( fieldIndex, static_cast( value.float_value() ) ); + else if ( value.has_double_value() ) + f.setAttribute( fieldIndex, value.double_value() ); + else if ( value.has_int_value() ) + f.setAttribute( fieldIndex, static_cast( value.int_value() ) ); + else if ( value.has_uint_value() ) + f.setAttribute( fieldIndex, static_cast( value.uint_value() ) ); + else if ( value.has_sint_value() ) + f.setAttribute( fieldIndex, static_cast( value.sint_value() ) ); + else if ( value.has_bool_value() ) + f.setAttribute( fieldIndex, static_cast( value.bool_value() ) ); // or keep it bool? (do we have good support for that?) + else + { + // TODO: report - should not happen + Q_ASSERT( false ); + } + } + + // + // parse geometry + // + + int extent = static_cast( layer.extent() ); + int cursorx = 0, cursory = 0; + + QVector outputPoints; // for point/multi-point + QVector outputLinestrings; // for linestring/multi-linestring + QVector outputPolygons; + QVector tmpPoints; + + for ( int i = 0; i < feature.geometry_size(); i ++ ) + { + unsigned g = feature.geometry( i ); + unsigned cmdId = g & 0x7; + unsigned cmdCount = g >> 3; + if ( cmdId == 1 ) // MoveTo + { + for ( unsigned j = 0; j < cmdCount; j++ ) + { + unsigned v = feature.geometry( i + 1 ); + unsigned w = feature.geometry( i + 2 ); + int dx = ( ( v >> 1 ) ^ ( -( v & 1 ) ) ); + int dy = ( ( w >> 1 ) ^ ( -( w & 1 ) ) ); + cursorx += dx; + cursory += dy; + double px = tileXMin + tileDX * double( cursorx ) / double( extent ); + double py = tileYMax - tileDY * double( cursory ) / double( extent ); + + if ( feature.type() == vector_tile::Tile_GeomType_POINT ) + { + outputPoints.append( new QgsPoint( px, py ) ); + } + else if ( feature.type() == vector_tile::Tile_GeomType_LINESTRING ) + { + if ( tmpPoints.size() > 0 ) + { + outputLinestrings.append( new QgsLineString( tmpPoints ) ); + tmpPoints.clear(); + } + tmpPoints.append( QgsPoint( px, py ) ); + } + else if ( feature.type() == vector_tile::Tile_GeomType_POLYGON ) + { + tmpPoints.append( QgsPoint( px, py ) ); + } + i += 2; + } + } + else if ( cmdId == 2 ) // LineTo + { + for ( unsigned j = 0; j < cmdCount; j++ ) + { + unsigned v = feature.geometry( i + 1 ); + unsigned w = feature.geometry( i + 2 ); + int dx = ( ( v >> 1 ) ^ ( -( v & 1 ) ) ); + int dy = ( ( w >> 1 ) ^ ( -( w & 1 ) ) ); + cursorx += dx; + cursory += dy; + double px = tileXMin + tileDX * double( cursorx ) / double( extent ); + double py = tileYMax - tileDY * double( cursory ) / double( extent ); + + tmpPoints.push_back( QgsPoint( px, py ) ); + i += 2; + } + } + else if ( cmdId == 7 ) // ClosePath + { + if ( feature.type() == vector_tile::Tile_GeomType_POLYGON ) + { + tmpPoints.append( tmpPoints.first() ); // close the ring + + if ( _isExteriorRing( tmpPoints ) ) + { + // start a new polygon + QgsPolygon *p = new QgsPolygon; + p->setExteriorRing( new QgsLineString( tmpPoints ) ); + outputPolygons.append( p ); + tmpPoints.clear(); + } + else + { + // interior ring (hole) + Q_ASSERT( outputPolygons.count() != 0 ); // TODO: better error handling + outputPolygons[outputPolygons.count() - 1]->addInteriorRing( new QgsLineString( tmpPoints ) ); + tmpPoints.clear(); + } + } + + } + else + { + qDebug() << "huh?"; // TODO: handle properly + } + } + + QString geomType; + if ( feature.type() == vector_tile::Tile_GeomType_POINT ) + { + geomType = QStringLiteral( "Point" ); + if ( outputPoints.count() == 1 ) + f.setGeometry( QgsGeometry( outputPoints[0] ) ); + else + { + QgsMultiPoint *mp = new QgsMultiPoint; + for ( int k = 0; k < outputPoints.count(); ++k ) + mp->addGeometry( outputPoints[k] ); + f.setGeometry( QgsGeometry( mp ) ); + } + } + else if ( feature.type() == vector_tile::Tile_GeomType_LINESTRING ) + { + geomType = QStringLiteral( "LineString" ); + + // finish the linestring we have started + outputLinestrings.append( new QgsLineString( tmpPoints ) ); + + if ( outputLinestrings.count() == 1 ) + f.setGeometry( QgsGeometry( outputLinestrings[0] ) ); + else + { + QgsMultiLineString *mls = new QgsMultiLineString; + for ( int k = 0; k < outputLinestrings.count(); ++k ) + mls->addGeometry( outputLinestrings[k] ); + f.setGeometry( QgsGeometry( mls ) ); + } + } + else if ( feature.type() == vector_tile::Tile_GeomType_POLYGON ) + { + geomType = QStringLiteral( "Polygon" ); + + if ( outputPolygons.count() == 1 ) + f.setGeometry( QgsGeometry( outputPolygons[0] ) ); + else + { + QgsMultiPolygon *mpl = new QgsMultiPolygon; + for ( int k = 0; k < outputPolygons.count(); ++k ) + mpl->addGeometry( outputPolygons[k] ); + f.setGeometry( QgsGeometry( mpl ) ); + } + } + + f.setAttribute( "ty_pe", geomType ); + + layerFeatures.append( f ); + } + + features[layerName] = layerFeatures; + } + return features; +} diff --git a/src/core/vectortile/qgsvectortilemvtdecoder.h b/src/core/vectortile/qgsvectortilemvtdecoder.h new file mode 100644 index 00000000000..a0e8d10be9a --- /dev/null +++ b/src/core/vectortile/qgsvectortilemvtdecoder.h @@ -0,0 +1,56 @@ +/*************************************************************************** + qgsvectortilemvtdecoder.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILEMVTDECODER_H +#define QGSVECTORTILEMVTDECODER_H + +class QgsFeature; + +#include +#include + +#include "vector_tile.pb.h" + +#include "qgsvectortilerenderer.h" + +/** + * \ingroup core + * This class is responsible for decoding raw tile data written with Mapbox Vector Tiles encoding. + * + * \since QGIS 3.14 + */ +class QgsVectorTileMVTDecoder +{ + public: + + //! Tries to decode raw tile data, returns true on success + bool decode( QgsTileXYZ tileID, const QByteArray &rawTileData ); + + //! Returns a list of sub-layer names in a tile. It can only be called after a successful decode() + QStringList layers() const; + + //! Returns a list of all field names in a tile. It can only be called after a successful decode() + QStringList layerFieldNames( const QString &layerName ) const; + + //! Returns decoded features grouped by sub-layers. It can only be called after a successful decode() + QgsVectorTileFeatures layerFeatures( const QMap &perLayerFields ) const; + + private: + vector_tile::Tile tile; + QgsTileXYZ mTileID; + QMap mLayerNameToIndex; +}; + +#endif // QGSVECTORTILEMVTDECODER_H diff --git a/src/core/vectortile/qgsvectortilerenderer.h b/src/core/vectortile/qgsvectortilerenderer.h new file mode 100644 index 00000000000..97f4a31286e --- /dev/null +++ b/src/core/vectortile/qgsvectortilerenderer.h @@ -0,0 +1,90 @@ +/*************************************************************************** + qgsvectortilerenderer.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILERENDERER_H +#define QGSVECTORTILERENDERER_H + +#include "qgis_core.h" + +#include "qgsfeature.h" + +#include "qgstiles.h" + +class QgsRenderContext; + +//! Features of a vector tile, grouped by sub-layer names (key of the map) +typedef QMap > QgsVectorTileFeatures; + +/** + * \ingroup core + * Contains decoded features of a single vector tile and any other data necessary + * for rendering of it. + * + * \since QGIS 3.14 + */ +struct QgsVectorTileRendererData +{ + //! Position of the tile in the tile matrix set + QgsTileXYZ id; + //! Features of the tile grouped into sub-layers + QgsVectorTileFeatures features; + //! Polygon (made out of four corners of the tile) in screen coordinates calculated from render context + QPolygon tilePolygon; +}; + +/** + * \ingroup core + * Abstract base class for all vector tile renderer implementations. + * + * For rendering it is expected that client code calls: + * 1. startRender() to prepare renderer + * 2. renderTile() for each tile + * 3. stopRender() to clean up renderer and free resources + * + * \since QGIS 3.14 + */ +class CORE_EXPORT QgsVectorTileRenderer +{ + public: + virtual ~QgsVectorTileRenderer() = default; + + //! Returns unique type name of the renderer implementation + virtual QString type() const = 0; + + //! Returns a clone of the renderer + virtual QgsVectorTileRenderer *clone() const = 0; + + //! Initializes rendering. It should be paired with a stopRender() call. + virtual void startRender( QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange ) = 0; + + //! Returns field names of sub-layers that will be used for rendering. Must be called between startRender/stopRender. + virtual QMap > usedAttributes( const QgsRenderContext & ) = 0; + + //! Finishes rendering and cleans up any resources + virtual void stopRender( QgsRenderContext &context ) = 0; + + //! Renders given vector tile. Must be called between startRender/stopRender. + virtual void renderTile( const QgsVectorTileRendererData &tile, QgsRenderContext &context ) = 0; + + //! Writes renderer's properties to given XML element + virtual void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const = 0; + //! Reads renderer's properties from given XML element + virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) = 0; + //! Resolves references to other objects - second phase of loading - after readXml() + virtual void resolveReferences( const QgsProject &project ) { Q_UNUSED( project ) } + +}; + +#endif // QGSVECTORTILERENDERER_H diff --git a/src/core/vectortile/qgsvectortileutils.cpp b/src/core/vectortile/qgsvectortileutils.cpp new file mode 100644 index 00000000000..85a27a7504f --- /dev/null +++ b/src/core/vectortile/qgsvectortileutils.cpp @@ -0,0 +1,171 @@ +/*************************************************************************** + qgsvectortileutils.cpp + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsvectortileutils.h" + +#include + +#include +#include + +#include "qgscoordinatetransform.h" +#include "qgsgeometrycollection.h" +#include "qgsfields.h" +#include "qgsmaptopixel.h" +#include "qgsrectangle.h" +#include "qgsvectorlayer.h" + +#include "qgsvectortilemvtdecoder.h" +#include "qgsvectortilelayer.h" +#include "qgsvectortilerenderer.h" + + + +QPolygon QgsVectorTileUtils::tilePolygon( QgsTileXYZ id, const QgsTileMatrix &tm, const QgsMapToPixel &mtp ) +{ + QgsRectangle r = tm.tileExtent( id ); + QgsPointXY p00a = mtp.transform( r.xMinimum(), r.yMinimum() ); + QgsPointXY p11a = mtp.transform( r.xMaximum(), r.yMaximum() ); + QgsPointXY p01a = mtp.transform( r.xMinimum(), r.yMaximum() ); + QgsPointXY p10a = mtp.transform( r.xMaximum(), r.yMinimum() ); + QPolygon path; + path << p00a.toQPointF().toPoint(); + path << p01a.toQPointF().toPoint(); + path << p11a.toQPointF().toPoint(); + path << p10a.toQPointF().toPoint(); + return path; +} + +QgsFields QgsVectorTileUtils::makeQgisFields( QSet flds ) +{ + QgsFields fields; + for ( QString fieldName : flds ) + { + fields.append( QgsField( fieldName, QVariant::String ) ); + } + return fields; +} + + +int QgsVectorTileUtils::scaleToZoomLevel( double mapScale, int sourceMinZoom, int sourceMaxZoom ) +{ + qDebug() << "MVT map scale 1 :" << mapScale; + + double s0 = 559082264.0287178; // scale denominator at zoom level 0 of GoogleCRS84Quad + double tileZoom2 = log( s0 / mapScale ) / log( 2 ); + tileZoom2 -= 1; // TODO: it seems that map scale is double (is that because of high-dpi screen?) + int tileZoom = static_cast( round( tileZoom2 ) ); + + if ( tileZoom < sourceMinZoom ) + tileZoom = sourceMinZoom; + if ( tileZoom > sourceMaxZoom ) + tileZoom = sourceMaxZoom; + + return tileZoom; +} + +QgsVectorLayer *QgsVectorTileUtils::makeVectorLayerForTile( QgsVectorTileLayer *mvt, QgsTileXYZ tileID, const QString &layerName ) +{ + QgsVectorTileMVTDecoder decoder; + decoder.decode( tileID, mvt->getRawTile( tileID ) ); + qDebug() << decoder.layers(); + QSet fieldNames = QSet::fromList( decoder.layerFieldNames( layerName ) ); + fieldNames << "ty_pe"; // geom. type + QMap perLayerFields; + QgsFields fields = QgsVectorTileUtils::makeQgisFields( fieldNames ); + perLayerFields[layerName] = fields; + QgsVectorTileFeatures data = decoder.layerFeatures( perLayerFields ); + QgsFeatureList featuresList = data[layerName].toList(); + + // turn all geometries to geom. collections (otherwise they won't be accepted by memory provider) + for ( int i = 0; i < featuresList.count(); ++i ) + { + QgsGeometry g = featuresList[i].geometry(); + QgsGeometryCollection *gc = new QgsGeometryCollection; + const QgsAbstractGeometry *gg = g.constGet(); + if ( const QgsGeometryCollection *ggc = qgsgeometry_cast( gg ) ) + { + for ( int k = 0; k < ggc->numGeometries(); ++k ) + gc->addGeometry( ggc->geometryN( k )->clone() ); + } + else + gc->addGeometry( gg->clone() ); + featuresList[i].setGeometry( QgsGeometry( gc ) ); + } + + QgsVectorLayer *vl = new QgsVectorLayer( "GeometryCollection", layerName, "memory" ); + vl->dataProvider()->addAttributes( fields.toList() ); + vl->updateFields(); + bool res = vl->dataProvider()->addFeatures( featuresList ); + Q_ASSERT( res ); + Q_ASSERT( featuresList.count() == vl->featureCount() ); + vl->updateExtents(); + qDebug() << "layer" << layerName << "features" << vl->featureCount(); + return vl; +} + + +QString QgsVectorTileUtils::formatXYZUrlTemplate( const QString &url, QgsTileXYZ tile ) +{ + QString turl( url ); + + turl.replace( QLatin1String( "{x}" ), QString::number( tile.column() ), Qt::CaseInsensitive ); + // TODO: inverted Y axis +// if ( turl.contains( QLatin1String( "{-y}" ) ) ) +// { +// turl.replace( QLatin1String( "{-y}" ), QString::number( tm.matrixHeight - tile.tileRow - 1 ), Qt::CaseInsensitive ); +// } +// else + { + turl.replace( QLatin1String( "{y}" ), QString::number( tile.row() ), Qt::CaseInsensitive ); + } + turl.replace( QLatin1String( "{z}" ), QString::number( tile.zoomLevel() ), Qt::CaseInsensitive ); + return turl; +} + +//! a helper class for ordering tile requests according to the distance from view center +struct LessThanTileRequest +{ + QPointF center; //!< Center in tile matrix (!) coordinates + bool operator()( const QgsTileXYZ &req1, const QgsTileXYZ &req2 ) + { + QPointF p1( req1.column() + 0.5, req1.row() + 0.5 ); + QPointF p2( req2.column() + 0.5, req2.row() + 0.5 ); + // using chessboard distance (loading order more natural than euclidean/manhattan distance) + double d1 = std::max( std::fabs( center.x() - p1.x() ), std::fabs( center.y() - p1.y() ) ); + double d2 = std::max( std::fabs( center.x() - p2.x() ), std::fabs( center.y() - p2.y() ) ); + return d1 < d2; + } +}; + +QVector QgsVectorTileUtils::tilesInRange( const QgsTileRange &range, int zoomLevel ) +{ + QVector tiles; + for ( int tileRow = range.startRow(); tileRow <= range.endRow(); ++tileRow ) + { + for ( int tileColumn = range.startColumn(); tileColumn <= range.endColumn(); ++tileColumn ) + { + tiles.append( QgsTileXYZ( tileColumn, tileRow, zoomLevel ) ); + } + } + return tiles; +} + +void QgsVectorTileUtils::sortTilesByDistanceFromCenter( QVector &tiles, const QPointF ¢er ) +{ + LessThanTileRequest cmp; + cmp.center = center; + std::sort( tiles.begin(), tiles.end(), cmp ); +} diff --git a/src/core/vectortile/qgsvectortileutils.h b/src/core/vectortile/qgsvectortileutils.h new file mode 100644 index 00000000000..1d484f20c30 --- /dev/null +++ b/src/core/vectortile/qgsvectortileutils.h @@ -0,0 +1,62 @@ +/*************************************************************************** + qgsvectortileutils.h + -------------------------------------- + Date : March 2020 + Copyright : (C) 2020 by Martin Dobias + Email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORTILEUTILS_H +#define QGSVECTORTILEUTILS_H + +#include + +class QPointF; +class QPolygon; + +class QgsCoordinateTransform; +class QgsFields; +class QgsMapToPixel; +class QgsRectangle; +class QgsVectorLayer; + +class QgsTileMatrix; +class QgsTileRange; +struct QgsTileXYZ; +class QgsVectorTileLayer; + +/** + * \ingroup core + * Random utility functions for working with vector tiles + * + * \since QGIS 3.14 + */ +class QgsVectorTileUtils +{ + public: + + //! Returns a list of tiles in the given tile range + static QVector tilesInRange( const QgsTileRange &range, int zoomLevel ); + //! Orders tile requests according to the distance from view center (given in tile matrix coords) + static void sortTilesByDistanceFromCenter( QVector &tiles, const QPointF ¢er ); + + //! Returns polygon (made by four corners of the tile) in screen coordinates + static QPolygon tilePolygon( QgsTileXYZ id, const QgsTileMatrix &tm, const QgsMapToPixel &mtp ); + //! Returns QgsFields instance based on the set of field names + static QgsFields makeQgisFields( QSet flds ); + //! Finds best fitting zoom level (assuming GoogleCRS84Quad tile matrix set) given map scale denominator and allowed zoom level range + static int scaleToZoomLevel( double mapScale, int sourceMinZoom, int sourceMaxZoom ); + //! Returns a temporary vector layer for given sub-layer of tile in vector tile layer + static QgsVectorLayer *makeVectorLayerForTile( QgsVectorTileLayer *mvt, QgsTileXYZ tileID, const QString &layerName ); + //! Returns formatted tile URL string replacing {x}, {y}, {z} placeholders + static QString formatXYZUrlTemplate( const QString &url, QgsTileXYZ tile ); +}; + +#endif // QGSVECTORTILEUTILS_H diff --git a/src/core/vectortile/vector_tile.pb.cc b/src/core/vectortile/vector_tile.pb.cc new file mode 100644 index 00000000000..3f66c597f2c --- /dev/null +++ b/src/core/vectortile/vector_tile.pb.cc @@ -0,0 +1,2527 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: vector_tile.proto + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "vector_tile.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace vector_tile { + +namespace { + +const ::google::protobuf::Descriptor* Tile_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Tile_reflection_ = NULL; +const ::google::protobuf::Descriptor* Tile_Value_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Tile_Value_reflection_ = NULL; +const ::google::protobuf::Descriptor* Tile_Feature_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Tile_Feature_reflection_ = NULL; +const ::google::protobuf::Descriptor* Tile_Layer_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Tile_Layer_reflection_ = NULL; +const ::google::protobuf::EnumDescriptor* Tile_GeomType_descriptor_ = NULL; + +} // namespace + + +void protobuf_AssignDesc_vector_5ftile_2eproto() GOOGLE_ATTRIBUTE_COLD; +void protobuf_AssignDesc_vector_5ftile_2eproto() { + protobuf_AddDesc_vector_5ftile_2eproto(); + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( + "vector_tile.proto"); + GOOGLE_CHECK(file != NULL); + Tile_descriptor_ = file->message_type(0); + static const int Tile_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile, layers_), + }; + Tile_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Tile_descriptor_, + Tile::default_instance_, + Tile_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile, _has_bits_[0]), + -1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile, _extensions_), + sizeof(Tile), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile, _internal_metadata_), + -1); + Tile_Value_descriptor_ = Tile_descriptor_->nested_type(0); + static const int Tile_Value_offsets_[7] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, string_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, float_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, double_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, int_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, uint_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, sint_value_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, bool_value_), + }; + Tile_Value_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Tile_Value_descriptor_, + Tile_Value::default_instance_, + Tile_Value_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, _has_bits_[0]), + -1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, _extensions_), + sizeof(Tile_Value), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Value, _internal_metadata_), + -1); + Tile_Feature_descriptor_ = Tile_descriptor_->nested_type(1); + static const int Tile_Feature_offsets_[4] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Feature, id_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Feature, tags_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Feature, type_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Feature, geometry_), + }; + Tile_Feature_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Tile_Feature_descriptor_, + Tile_Feature::default_instance_, + Tile_Feature_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Feature, _has_bits_[0]), + -1, + -1, + sizeof(Tile_Feature), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Feature, _internal_metadata_), + -1); + Tile_Layer_descriptor_ = Tile_descriptor_->nested_type(2); + static const int Tile_Layer_offsets_[6] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, version_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, features_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, keys_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, values_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, extent_), + }; + Tile_Layer_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Tile_Layer_descriptor_, + Tile_Layer::default_instance_, + Tile_Layer_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, _has_bits_[0]), + -1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, _extensions_), + sizeof(Tile_Layer), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Tile_Layer, _internal_metadata_), + -1); + Tile_GeomType_descriptor_ = Tile_descriptor_->enum_type(0); +} + +namespace { + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +inline void protobuf_AssignDescriptorsOnce() { + ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, + &protobuf_AssignDesc_vector_5ftile_2eproto); +} + +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Tile_descriptor_, &Tile::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Tile_Value_descriptor_, &Tile_Value::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Tile_Feature_descriptor_, &Tile_Feature::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Tile_Layer_descriptor_, &Tile_Layer::default_instance()); +} + +} // namespace + +void protobuf_ShutdownFile_vector_5ftile_2eproto() { + delete Tile::default_instance_; + delete Tile_reflection_; + delete Tile_Value::default_instance_; + delete Tile_Value_reflection_; + delete Tile_Feature::default_instance_; + delete Tile_Feature_reflection_; + delete Tile_Layer::default_instance_; + delete Tile_Layer_reflection_; +} + +void protobuf_AddDesc_vector_5ftile_2eproto() GOOGLE_ATTRIBUTE_COLD; +void protobuf_AddDesc_vector_5ftile_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + "\n\021vector_tile.proto\022\013vector_tile\"\300\004\n\004Til" + "e\022\'\n\006layers\030\003 \003(\0132\027.vector_tile.Tile.Lay" + "er\032\241\001\n\005Value\022\024\n\014string_value\030\001 \001(\t\022\023\n\013fl" + "oat_value\030\002 \001(\002\022\024\n\014double_value\030\003 \001(\001\022\021\n" + "\tint_value\030\004 \001(\003\022\022\n\nuint_value\030\005 \001(\004\022\022\n\n" + "sint_value\030\006 \001(\022\022\022\n\nbool_value\030\007 \001(\010*\010\010\010" + "\020\200\200\200\200\002\032s\n\007Feature\022\r\n\002id\030\001 \001(\004:\0010\022\020\n\004tags" + "\030\002 \003(\rB\002\020\001\0221\n\004type\030\003 \001(\0162\032.vector_tile.T" + "ile.GeomType:\007UNKNOWN\022\024\n\010geometry\030\004 \003(\rB" + "\002\020\001\032\255\001\n\005Layer\022\022\n\007version\030\017 \002(\r:\0011\022\014\n\004nam" + "e\030\001 \002(\t\022+\n\010features\030\002 \003(\0132\031.vector_tile." + "Tile.Feature\022\014\n\004keys\030\003 \003(\t\022\'\n\006values\030\004 \003" + "(\0132\027.vector_tile.Tile.Value\022\024\n\006extent\030\005 " + "\001(\r:\0044096*\010\010\020\020\200\200\200\200\002\"\?\n\010GeomType\022\013\n\007UNKNO" + "WN\020\000\022\t\n\005POINT\020\001\022\016\n\nLINESTRING\020\002\022\013\n\007POLYG" + "ON\020\003*\005\010\020\020\200@", 611); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "vector_tile.proto", &protobuf_RegisterTypes); + Tile::default_instance_ = new Tile(); + Tile_Value::default_instance_ = new Tile_Value(); + Tile_Feature::default_instance_ = new Tile_Feature(); + Tile_Layer::default_instance_ = new Tile_Layer(); + Tile::default_instance_->InitAsDefaultInstance(); + Tile_Value::default_instance_->InitAsDefaultInstance(); + Tile_Feature::default_instance_->InitAsDefaultInstance(); + Tile_Layer::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_vector_5ftile_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_vector_5ftile_2eproto { + StaticDescriptorInitializer_vector_5ftile_2eproto() { + protobuf_AddDesc_vector_5ftile_2eproto(); + } +} static_descriptor_initializer_vector_5ftile_2eproto_; + +// =================================================================== + +const ::google::protobuf::EnumDescriptor* Tile_GeomType_descriptor() { + protobuf_AssignDescriptorsOnce(); + return Tile_GeomType_descriptor_; +} +bool Tile_GeomType_IsValid(int value) { + switch(value) { + case 0: + case 1: + case 2: + case 3: + return true; + default: + return false; + } +} + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const Tile_GeomType Tile::UNKNOWN; +const Tile_GeomType Tile::POINT; +const Tile_GeomType Tile::LINESTRING; +const Tile_GeomType Tile::POLYGON; +const Tile_GeomType Tile::GeomType_MIN; +const Tile_GeomType Tile::GeomType_MAX; +const int Tile::GeomType_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Tile_Value::kStringValueFieldNumber; +const int Tile_Value::kFloatValueFieldNumber; +const int Tile_Value::kDoubleValueFieldNumber; +const int Tile_Value::kIntValueFieldNumber; +const int Tile_Value::kUintValueFieldNumber; +const int Tile_Value::kSintValueFieldNumber; +const int Tile_Value::kBoolValueFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +Tile_Value::Tile_Value() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:vector_tile.Tile.Value) +} + +void Tile_Value::InitAsDefaultInstance() { +} + +Tile_Value::Tile_Value(const Tile_Value& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:vector_tile.Tile.Value) +} + +void Tile_Value::SharedCtor() { + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + float_value_ = 0; + double_value_ = 0; + int_value_ = GOOGLE_LONGLONG(0); + uint_value_ = GOOGLE_ULONGLONG(0); + sint_value_ = GOOGLE_LONGLONG(0); + bool_value_ = false; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Tile_Value::~Tile_Value() { + // @@protoc_insertion_point(destructor:vector_tile.Tile.Value) + SharedDtor(); +} + +void Tile_Value::SharedDtor() { + string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + } +} + +void Tile_Value::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Tile_Value::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Tile_Value_descriptor_; +} + +const Tile_Value& Tile_Value::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_vector_5ftile_2eproto(); + return *default_instance_; +} + +Tile_Value* Tile_Value::default_instance_ = NULL; + +Tile_Value* Tile_Value::New(::google::protobuf::Arena* arena) const { + Tile_Value* n = new Tile_Value; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Tile_Value::Clear() { +// @@protoc_insertion_point(message_clear_start:vector_tile.Tile.Value) + _extensions_.Clear(); +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(Tile_Value, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&first, 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 127u) { + ZR_(double_value_, sint_value_); + if (has_string_value()) { + string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + } + +#undef ZR_HELPER_ +#undef ZR_ + + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool Tile_Value::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:vector_tile.Tile.Value) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string string_value = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_string_value())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->string_value().data(), this->string_value().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "vector_tile.Tile.Value.string_value"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(21)) goto parse_float_value; + break; + } + + // optional float float_value = 2; + case 2: { + if (tag == 21) { + parse_float_value: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( + input, &float_value_))); + set_has_float_value(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(25)) goto parse_double_value; + break; + } + + // optional double double_value = 3; + case 3: { + if (tag == 25) { + parse_double_value: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( + input, &double_value_))); + set_has_double_value(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(32)) goto parse_int_value; + break; + } + + // optional int64 int_value = 4; + case 4: { + if (tag == 32) { + parse_int_value: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( + input, &int_value_))); + set_has_int_value(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(40)) goto parse_uint_value; + break; + } + + // optional uint64 uint_value = 5; + case 5: { + if (tag == 40) { + parse_uint_value: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( + input, &uint_value_))); + set_has_uint_value(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(48)) goto parse_sint_value; + break; + } + + // optional sint64 sint_value = 6; + case 6: { + if (tag == 48) { + parse_sint_value: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_SINT64>( + input, &sint_value_))); + set_has_sint_value(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(56)) goto parse_bool_value; + break; + } + + // optional bool bool_value = 7; + case 7: { + if (tag == 56) { + parse_bool_value: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &bool_value_))); + set_has_bool_value(); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + if ((64u <= tag)) { + DO_(_extensions_.ParseField(tag, input, default_instance_, + mutable_unknown_fields())); + continue; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:vector_tile.Tile.Value) + return true; +failure: + // @@protoc_insertion_point(parse_failure:vector_tile.Tile.Value) + return false; +#undef DO_ +} + +void Tile_Value::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:vector_tile.Tile.Value) + // optional string string_value = 1; + if (has_string_value()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->string_value().data(), this->string_value().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "vector_tile.Tile.Value.string_value"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->string_value(), output); + } + + // optional float float_value = 2; + if (has_float_value()) { + ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->float_value(), output); + } + + // optional double double_value = 3; + if (has_double_value()) { + ::google::protobuf::internal::WireFormatLite::WriteDouble(3, this->double_value(), output); + } + + // optional int64 int_value = 4; + if (has_int_value()) { + ::google::protobuf::internal::WireFormatLite::WriteInt64(4, this->int_value(), output); + } + + // optional uint64 uint_value = 5; + if (has_uint_value()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt64(5, this->uint_value(), output); + } + + // optional sint64 sint_value = 6; + if (has_sint_value()) { + ::google::protobuf::internal::WireFormatLite::WriteSInt64(6, this->sint_value(), output); + } + + // optional bool bool_value = 7; + if (has_bool_value()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->bool_value(), output); + } + + // Extension range [8, 536870912) + _extensions_.SerializeWithCachedSizes( + 8, 536870912, output); + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:vector_tile.Tile.Value) +} + +::google::protobuf::uint8* Tile_Value::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:vector_tile.Tile.Value) + // optional string string_value = 1; + if (has_string_value()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->string_value().data(), this->string_value().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "vector_tile.Tile.Value.string_value"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->string_value(), target); + } + + // optional float float_value = 2; + if (has_float_value()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->float_value(), target); + } + + // optional double double_value = 3; + if (has_double_value()) { + target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(3, this->double_value(), target); + } + + // optional int64 int_value = 4; + if (has_int_value()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(4, this->int_value(), target); + } + + // optional uint64 uint_value = 5; + if (has_uint_value()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(5, this->uint_value(), target); + } + + // optional sint64 sint_value = 6; + if (has_sint_value()) { + target = ::google::protobuf::internal::WireFormatLite::WriteSInt64ToArray(6, this->sint_value(), target); + } + + // optional bool bool_value = 7; + if (has_bool_value()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->bool_value(), target); + } + + // Extension range [8, 536870912) + target = _extensions_.InternalSerializeWithCachedSizesToArray( + 8, 536870912, false, target); + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:vector_tile.Tile.Value) + return target; +} + +int Tile_Value::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:vector_tile.Tile.Value) + int total_size = 0; + + if (_has_bits_[0 / 32] & 127u) { + // optional string string_value = 1; + if (has_string_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->string_value()); + } + + // optional float float_value = 2; + if (has_float_value()) { + total_size += 1 + 4; + } + + // optional double double_value = 3; + if (has_double_value()) { + total_size += 1 + 8; + } + + // optional int64 int_value = 4; + if (has_int_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int64Size( + this->int_value()); + } + + // optional uint64 uint_value = 5; + if (has_uint_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt64Size( + this->uint_value()); + } + + // optional sint64 sint_value = 6; + if (has_sint_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::SInt64Size( + this->sint_value()); + } + + // optional bool bool_value = 7; + if (has_bool_value()) { + total_size += 1 + 1; + } + + } + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Tile_Value::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:vector_tile.Tile.Value) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + const Tile_Value* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:vector_tile.Tile.Value) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:vector_tile.Tile.Value) + MergeFrom(*source); + } +} + +void Tile_Value::MergeFrom(const Tile_Value& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:vector_tile.Tile.Value) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_string_value()) { + set_has_string_value(); + string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + } + if (from.has_float_value()) { + set_float_value(from.float_value()); + } + if (from.has_double_value()) { + set_double_value(from.double_value()); + } + if (from.has_int_value()) { + set_int_value(from.int_value()); + } + if (from.has_uint_value()) { + set_uint_value(from.uint_value()); + } + if (from.has_sint_value()) { + set_sint_value(from.sint_value()); + } + if (from.has_bool_value()) { + set_bool_value(from.bool_value()); + } + } + _extensions_.MergeFrom(from._extensions_); + if (from._internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + } +} + +void Tile_Value::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:vector_tile.Tile.Value) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Tile_Value::CopyFrom(const Tile_Value& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:vector_tile.Tile.Value) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Tile_Value::IsInitialized() const { + + + if (!_extensions_.IsInitialized()) return false; return true; +} + +void Tile_Value::Swap(Tile_Value* other) { + if (other == this) return; + InternalSwap(other); +} +void Tile_Value::InternalSwap(Tile_Value* other) { + string_value_.Swap(&other->string_value_); + std::swap(float_value_, other->float_value_); + std::swap(double_value_, other->double_value_); + std::swap(int_value_, other->int_value_); + std::swap(uint_value_, other->uint_value_); + std::swap(sint_value_, other->sint_value_); + std::swap(bool_value_, other->bool_value_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); + _extensions_.Swap(&other->_extensions_); +} + +::google::protobuf::Metadata Tile_Value::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Tile_Value_descriptor_; + metadata.reflection = Tile_Value_reflection_; + return metadata; +} + + +// ------------------------------------------------------------------- + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Tile_Feature::kIdFieldNumber; +const int Tile_Feature::kTagsFieldNumber; +const int Tile_Feature::kTypeFieldNumber; +const int Tile_Feature::kGeometryFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +Tile_Feature::Tile_Feature() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:vector_tile.Tile.Feature) +} + +void Tile_Feature::InitAsDefaultInstance() { +} + +Tile_Feature::Tile_Feature(const Tile_Feature& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:vector_tile.Tile.Feature) +} + +void Tile_Feature::SharedCtor() { + _cached_size_ = 0; + id_ = GOOGLE_ULONGLONG(0); + type_ = 0; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Tile_Feature::~Tile_Feature() { + // @@protoc_insertion_point(destructor:vector_tile.Tile.Feature) + SharedDtor(); +} + +void Tile_Feature::SharedDtor() { + if (this != default_instance_) { + } +} + +void Tile_Feature::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Tile_Feature::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Tile_Feature_descriptor_; +} + +const Tile_Feature& Tile_Feature::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_vector_5ftile_2eproto(); + return *default_instance_; +} + +Tile_Feature* Tile_Feature::default_instance_ = NULL; + +Tile_Feature* Tile_Feature::New(::google::protobuf::Arena* arena) const { + Tile_Feature* n = new Tile_Feature; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Tile_Feature::Clear() { +// @@protoc_insertion_point(message_clear_start:vector_tile.Tile.Feature) + if (_has_bits_[0 / 32] & 5u) { + id_ = GOOGLE_ULONGLONG(0); + type_ = 0; + } + tags_.Clear(); + geometry_.Clear(); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool Tile_Feature::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:vector_tile.Tile.Feature) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional uint64 id = 1 [default = 0]; + case 1: { + if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( + input, &id_))); + set_has_id(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_tags; + break; + } + + // repeated uint32 tags = 2 [packed = true]; + case 2: { + if (tag == 18) { + parse_tags: + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, this->mutable_tags()))); + } else if (tag == 16) { + DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + 1, 18, input, this->mutable_tags()))); + } else { + goto handle_unusual; + } + if (input->ExpectTag(24)) goto parse_type; + break; + } + + // optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; + case 3: { + if (tag == 24) { + parse_type: + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::vector_tile::Tile_GeomType_IsValid(value)) { + set_type(static_cast< ::vector_tile::Tile_GeomType >(value)); + } else { + mutable_unknown_fields()->AddVarint(3, value); + } + } else { + goto handle_unusual; + } + if (input->ExpectTag(34)) goto parse_geometry; + break; + } + + // repeated uint32 geometry = 4 [packed = true]; + case 4: { + if (tag == 34) { + parse_geometry: + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, this->mutable_geometry()))); + } else if (tag == 32) { + DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + 1, 34, input, this->mutable_geometry()))); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:vector_tile.Tile.Feature) + return true; +failure: + // @@protoc_insertion_point(parse_failure:vector_tile.Tile.Feature) + return false; +#undef DO_ +} + +void Tile_Feature::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:vector_tile.Tile.Feature) + // optional uint64 id = 1 [default = 0]; + if (has_id()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->id(), output); + } + + // repeated uint32 tags = 2 [packed = true]; + if (this->tags_size() > 0) { + ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); + output->WriteVarint32(_tags_cached_byte_size_); + } + for (int i = 0; i < this->tags_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32NoTag( + this->tags(i), output); + } + + // optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; + if (has_type()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 3, this->type(), output); + } + + // repeated uint32 geometry = 4 [packed = true]; + if (this->geometry_size() > 0) { + ::google::protobuf::internal::WireFormatLite::WriteTag(4, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); + output->WriteVarint32(_geometry_cached_byte_size_); + } + for (int i = 0; i < this->geometry_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32NoTag( + this->geometry(i), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:vector_tile.Tile.Feature) +} + +::google::protobuf::uint8* Tile_Feature::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:vector_tile.Tile.Feature) + // optional uint64 id = 1 [default = 0]; + if (has_id()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->id(), target); + } + + // repeated uint32 tags = 2 [packed = true]; + if (this->tags_size() > 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( + 2, + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, + target); + target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( + _tags_cached_byte_size_, target); + } + for (int i = 0; i < this->tags_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteUInt32NoTagToArray(this->tags(i), target); + } + + // optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; + if (has_type()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 3, this->type(), target); + } + + // repeated uint32 geometry = 4 [packed = true]; + if (this->geometry_size() > 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( + 4, + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, + target); + target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( + _geometry_cached_byte_size_, target); + } + for (int i = 0; i < this->geometry_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteUInt32NoTagToArray(this->geometry(i), target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:vector_tile.Tile.Feature) + return target; +} + +int Tile_Feature::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:vector_tile.Tile.Feature) + int total_size = 0; + + if (_has_bits_[0 / 32] & 5u) { + // optional uint64 id = 1 [default = 0]; + if (has_id()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt64Size( + this->id()); + } + + // optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; + if (has_type()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + } + + } + // repeated uint32 tags = 2 [packed = true]; + { + int data_size = 0; + for (int i = 0; i < this->tags_size(); i++) { + data_size += ::google::protobuf::internal::WireFormatLite:: + UInt32Size(this->tags(i)); + } + if (data_size > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _tags_cached_byte_size_ = data_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + total_size += data_size; + } + + // repeated uint32 geometry = 4 [packed = true]; + { + int data_size = 0; + for (int i = 0; i < this->geometry_size(); i++) { + data_size += ::google::protobuf::internal::WireFormatLite:: + UInt32Size(this->geometry(i)); + } + if (data_size > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _geometry_cached_byte_size_ = data_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + total_size += data_size; + } + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Tile_Feature::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:vector_tile.Tile.Feature) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + const Tile_Feature* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:vector_tile.Tile.Feature) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:vector_tile.Tile.Feature) + MergeFrom(*source); + } +} + +void Tile_Feature::MergeFrom(const Tile_Feature& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:vector_tile.Tile.Feature) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + tags_.MergeFrom(from.tags_); + geometry_.MergeFrom(from.geometry_); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_id()) { + set_id(from.id()); + } + if (from.has_type()) { + set_type(from.type()); + } + } + if (from._internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + } +} + +void Tile_Feature::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:vector_tile.Tile.Feature) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Tile_Feature::CopyFrom(const Tile_Feature& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:vector_tile.Tile.Feature) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Tile_Feature::IsInitialized() const { + + return true; +} + +void Tile_Feature::Swap(Tile_Feature* other) { + if (other == this) return; + InternalSwap(other); +} +void Tile_Feature::InternalSwap(Tile_Feature* other) { + std::swap(id_, other->id_); + tags_.UnsafeArenaSwap(&other->tags_); + std::swap(type_, other->type_); + geometry_.UnsafeArenaSwap(&other->geometry_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata Tile_Feature::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Tile_Feature_descriptor_; + metadata.reflection = Tile_Feature_reflection_; + return metadata; +} + + +// ------------------------------------------------------------------- + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Tile_Layer::kVersionFieldNumber; +const int Tile_Layer::kNameFieldNumber; +const int Tile_Layer::kFeaturesFieldNumber; +const int Tile_Layer::kKeysFieldNumber; +const int Tile_Layer::kValuesFieldNumber; +const int Tile_Layer::kExtentFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +Tile_Layer::Tile_Layer() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:vector_tile.Tile.Layer) +} + +void Tile_Layer::InitAsDefaultInstance() { +} + +Tile_Layer::Tile_Layer(const Tile_Layer& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:vector_tile.Tile.Layer) +} + +void Tile_Layer::SharedCtor() { + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + version_ = 1u; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + extent_ = 4096u; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Tile_Layer::~Tile_Layer() { + // @@protoc_insertion_point(destructor:vector_tile.Tile.Layer) + SharedDtor(); +} + +void Tile_Layer::SharedDtor() { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + } +} + +void Tile_Layer::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Tile_Layer::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Tile_Layer_descriptor_; +} + +const Tile_Layer& Tile_Layer::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_vector_5ftile_2eproto(); + return *default_instance_; +} + +Tile_Layer* Tile_Layer::default_instance_ = NULL; + +Tile_Layer* Tile_Layer::New(::google::protobuf::Arena* arena) const { + Tile_Layer* n = new Tile_Layer; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Tile_Layer::Clear() { +// @@protoc_insertion_point(message_clear_start:vector_tile.Tile.Layer) + _extensions_.Clear(); + if (_has_bits_[0 / 32] & 35u) { + version_ = 1u; + if (has_name()) { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + extent_ = 4096u; + } + features_.Clear(); + keys_.Clear(); + values_.Clear(); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool Tile_Layer::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:vector_tile.Tile.Layer) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required string name = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_name())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "vector_tile.Tile.Layer.name"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_features; + break; + } + + // repeated .vector_tile.Tile.Feature features = 2; + case 2: { + if (tag == 18) { + parse_features: + DO_(input->IncrementRecursionDepth()); + parse_loop_features: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_features())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_loop_features; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectTag(26)) goto parse_keys; + break; + } + + // repeated string keys = 3; + case 3: { + if (tag == 26) { + parse_keys: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->add_keys())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->keys(this->keys_size() - 1).data(), + this->keys(this->keys_size() - 1).length(), + ::google::protobuf::internal::WireFormat::PARSE, + "vector_tile.Tile.Layer.keys"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(26)) goto parse_keys; + if (input->ExpectTag(34)) goto parse_values; + break; + } + + // repeated .vector_tile.Tile.Value values = 4; + case 4: { + if (tag == 34) { + parse_values: + DO_(input->IncrementRecursionDepth()); + parse_loop_values: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_values())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(34)) goto parse_loop_values; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectTag(40)) goto parse_extent; + break; + } + + // optional uint32 extent = 5 [default = 4096]; + case 5: { + if (tag == 40) { + parse_extent: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &extent_))); + set_has_extent(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(120)) goto parse_version; + break; + } + + // required uint32 version = 15 [default = 1]; + case 15: { + if (tag == 120) { + parse_version: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &version_))); + set_has_version(); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + if ((128u <= tag)) { + DO_(_extensions_.ParseField(tag, input, default_instance_, + mutable_unknown_fields())); + continue; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:vector_tile.Tile.Layer) + return true; +failure: + // @@protoc_insertion_point(parse_failure:vector_tile.Tile.Layer) + return false; +#undef DO_ +} + +void Tile_Layer::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:vector_tile.Tile.Layer) + // required string name = 1; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "vector_tile.Tile.Layer.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->name(), output); + } + + // repeated .vector_tile.Tile.Feature features = 2; + for (unsigned int i = 0, n = this->features_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 2, this->features(i), output); + } + + // repeated string keys = 3; + for (int i = 0; i < this->keys_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->keys(i).data(), this->keys(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "vector_tile.Tile.Layer.keys"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 3, this->keys(i), output); + } + + // repeated .vector_tile.Tile.Value values = 4; + for (unsigned int i = 0, n = this->values_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 4, this->values(i), output); + } + + // optional uint32 extent = 5 [default = 4096]; + if (has_extent()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->extent(), output); + } + + // required uint32 version = 15 [default = 1]; + if (has_version()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(15, this->version(), output); + } + + // Extension range [16, 536870912) + _extensions_.SerializeWithCachedSizes( + 16, 536870912, output); + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:vector_tile.Tile.Layer) +} + +::google::protobuf::uint8* Tile_Layer::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:vector_tile.Tile.Layer) + // required string name = 1; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "vector_tile.Tile.Layer.name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->name(), target); + } + + // repeated .vector_tile.Tile.Feature features = 2; + for (unsigned int i = 0, n = this->features_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 2, this->features(i), false, target); + } + + // repeated string keys = 3; + for (int i = 0; i < this->keys_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->keys(i).data(), this->keys(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "vector_tile.Tile.Layer.keys"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(3, this->keys(i), target); + } + + // repeated .vector_tile.Tile.Value values = 4; + for (unsigned int i = 0, n = this->values_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 4, this->values(i), false, target); + } + + // optional uint32 extent = 5 [default = 4096]; + if (has_extent()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->extent(), target); + } + + // required uint32 version = 15 [default = 1]; + if (has_version()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(15, this->version(), target); + } + + // Extension range [16, 536870912) + target = _extensions_.InternalSerializeWithCachedSizesToArray( + 16, 536870912, false, target); + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:vector_tile.Tile.Layer) + return target; +} + +int Tile_Layer::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:vector_tile.Tile.Layer) + int total_size = 0; + + if (has_version()) { + // required uint32 version = 15 [default = 1]; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->version()); + } + + if (has_name()) { + // required string name = 1; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + return total_size; +} +int Tile_Layer::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:vector_tile.Tile.Layer) + int total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required uint32 version = 15 [default = 1]; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->version()); + + // required string name = 1; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + // optional uint32 extent = 5 [default = 4096]; + if (has_extent()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->extent()); + } + + // repeated .vector_tile.Tile.Feature features = 2; + total_size += 1 * this->features_size(); + for (int i = 0; i < this->features_size(); i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->features(i)); + } + + // repeated string keys = 3; + total_size += 1 * this->keys_size(); + for (int i = 0; i < this->keys_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->keys(i)); + } + + // repeated .vector_tile.Tile.Value values = 4; + total_size += 1 * this->values_size(); + for (int i = 0; i < this->values_size(); i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->values(i)); + } + + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Tile_Layer::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:vector_tile.Tile.Layer) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + const Tile_Layer* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:vector_tile.Tile.Layer) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:vector_tile.Tile.Layer) + MergeFrom(*source); + } +} + +void Tile_Layer::MergeFrom(const Tile_Layer& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:vector_tile.Tile.Layer) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + features_.MergeFrom(from.features_); + keys_.MergeFrom(from.keys_); + values_.MergeFrom(from.values_); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_version()) { + set_version(from.version()); + } + if (from.has_name()) { + set_has_name(); + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_extent()) { + set_extent(from.extent()); + } + } + _extensions_.MergeFrom(from._extensions_); + if (from._internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + } +} + +void Tile_Layer::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:vector_tile.Tile.Layer) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Tile_Layer::CopyFrom(const Tile_Layer& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:vector_tile.Tile.Layer) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Tile_Layer::IsInitialized() const { + if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; + + if (!::google::protobuf::internal::AllAreInitialized(this->values())) return false; + + if (!_extensions_.IsInitialized()) return false; return true; +} + +void Tile_Layer::Swap(Tile_Layer* other) { + if (other == this) return; + InternalSwap(other); +} +void Tile_Layer::InternalSwap(Tile_Layer* other) { + std::swap(version_, other->version_); + name_.Swap(&other->name_); + features_.UnsafeArenaSwap(&other->features_); + keys_.UnsafeArenaSwap(&other->keys_); + values_.UnsafeArenaSwap(&other->values_); + std::swap(extent_, other->extent_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); + _extensions_.Swap(&other->_extensions_); +} + +::google::protobuf::Metadata Tile_Layer::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Tile_Layer_descriptor_; + metadata.reflection = Tile_Layer_reflection_; + return metadata; +} + + +// ------------------------------------------------------------------- + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Tile::kLayersFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +Tile::Tile() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:vector_tile.Tile) +} + +void Tile::InitAsDefaultInstance() { +} + +Tile::Tile(const Tile& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:vector_tile.Tile) +} + +void Tile::SharedCtor() { + _cached_size_ = 0; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Tile::~Tile() { + // @@protoc_insertion_point(destructor:vector_tile.Tile) + SharedDtor(); +} + +void Tile::SharedDtor() { + if (this != default_instance_) { + } +} + +void Tile::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Tile::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Tile_descriptor_; +} + +const Tile& Tile::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_vector_5ftile_2eproto(); + return *default_instance_; +} + +Tile* Tile::default_instance_ = NULL; + +Tile* Tile::New(::google::protobuf::Arena* arena) const { + Tile* n = new Tile; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Tile::Clear() { +// @@protoc_insertion_point(message_clear_start:vector_tile.Tile) + _extensions_.Clear(); + layers_.Clear(); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool Tile::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:vector_tile.Tile) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated .vector_tile.Tile.Layer layers = 3; + case 3: { + if (tag == 26) { + DO_(input->IncrementRecursionDepth()); + parse_loop_layers: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_layers())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(26)) goto parse_loop_layers; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + if ((128u <= tag && tag < 65536u)) { + DO_(_extensions_.ParseField(tag, input, default_instance_, + mutable_unknown_fields())); + continue; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:vector_tile.Tile) + return true; +failure: + // @@protoc_insertion_point(parse_failure:vector_tile.Tile) + return false; +#undef DO_ +} + +void Tile::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:vector_tile.Tile) + // repeated .vector_tile.Tile.Layer layers = 3; + for (unsigned int i = 0, n = this->layers_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 3, this->layers(i), output); + } + + // Extension range [16, 8192) + _extensions_.SerializeWithCachedSizes( + 16, 8192, output); + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:vector_tile.Tile) +} + +::google::protobuf::uint8* Tile::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:vector_tile.Tile) + // repeated .vector_tile.Tile.Layer layers = 3; + for (unsigned int i = 0, n = this->layers_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 3, this->layers(i), false, target); + } + + // Extension range [16, 8192) + target = _extensions_.InternalSerializeWithCachedSizesToArray( + 16, 8192, false, target); + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:vector_tile.Tile) + return target; +} + +int Tile::ByteSize() const { +// @@protoc_insertion_point(message_byte_size_start:vector_tile.Tile) + int total_size = 0; + + // repeated .vector_tile.Tile.Layer layers = 3; + total_size += 1 * this->layers_size(); + for (int i = 0; i < this->layers_size(); i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->layers(i)); + } + + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Tile::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:vector_tile.Tile) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + const Tile* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:vector_tile.Tile) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:vector_tile.Tile) + MergeFrom(*source); + } +} + +void Tile::MergeFrom(const Tile& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:vector_tile.Tile) + if (GOOGLE_PREDICT_FALSE(&from == this)) { + ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + } + layers_.MergeFrom(from.layers_); + _extensions_.MergeFrom(from._extensions_); + if (from._internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + } +} + +void Tile::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:vector_tile.Tile) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Tile::CopyFrom(const Tile& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:vector_tile.Tile) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Tile::IsInitialized() const { + + if (!::google::protobuf::internal::AllAreInitialized(this->layers())) return false; + + if (!_extensions_.IsInitialized()) return false; return true; +} + +void Tile::Swap(Tile* other) { + if (other == this) return; + InternalSwap(other); +} +void Tile::InternalSwap(Tile* other) { + layers_.UnsafeArenaSwap(&other->layers_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); + _extensions_.Swap(&other->_extensions_); +} + +::google::protobuf::Metadata Tile::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Tile_descriptor_; + metadata.reflection = Tile_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// Tile_Value + +// optional string string_value = 1; +bool Tile_Value::has_string_value() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void Tile_Value::set_has_string_value() { + _has_bits_[0] |= 0x00000001u; +} +void Tile_Value::clear_has_string_value() { + _has_bits_[0] &= ~0x00000001u; +} +void Tile_Value::clear_string_value() { + string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_string_value(); +} + const ::std::string& Tile_Value::string_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.string_value) + return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void Tile_Value::set_string_value(const ::std::string& value) { + set_has_string_value(); + string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.string_value) +} + void Tile_Value::set_string_value(const char* value) { + set_has_string_value(); + string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:vector_tile.Tile.Value.string_value) +} + void Tile_Value::set_string_value(const char* value, size_t size) { + set_has_string_value(); + string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:vector_tile.Tile.Value.string_value) +} + ::std::string* Tile_Value::mutable_string_value() { + set_has_string_value(); + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Value.string_value) + return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* Tile_Value::release_string_value() { + // @@protoc_insertion_point(field_release:vector_tile.Tile.Value.string_value) + clear_has_string_value(); + return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void Tile_Value::set_allocated_string_value(::std::string* string_value) { + if (string_value != NULL) { + set_has_string_value(); + } else { + clear_has_string_value(); + } + string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value); + // @@protoc_insertion_point(field_set_allocated:vector_tile.Tile.Value.string_value) +} + +// optional float float_value = 2; +bool Tile_Value::has_float_value() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void Tile_Value::set_has_float_value() { + _has_bits_[0] |= 0x00000002u; +} +void Tile_Value::clear_has_float_value() { + _has_bits_[0] &= ~0x00000002u; +} +void Tile_Value::clear_float_value() { + float_value_ = 0; + clear_has_float_value(); +} + float Tile_Value::float_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.float_value) + return float_value_; +} + void Tile_Value::set_float_value(float value) { + set_has_float_value(); + float_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.float_value) +} + +// optional double double_value = 3; +bool Tile_Value::has_double_value() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void Tile_Value::set_has_double_value() { + _has_bits_[0] |= 0x00000004u; +} +void Tile_Value::clear_has_double_value() { + _has_bits_[0] &= ~0x00000004u; +} +void Tile_Value::clear_double_value() { + double_value_ = 0; + clear_has_double_value(); +} + double Tile_Value::double_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.double_value) + return double_value_; +} + void Tile_Value::set_double_value(double value) { + set_has_double_value(); + double_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.double_value) +} + +// optional int64 int_value = 4; +bool Tile_Value::has_int_value() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void Tile_Value::set_has_int_value() { + _has_bits_[0] |= 0x00000008u; +} +void Tile_Value::clear_has_int_value() { + _has_bits_[0] &= ~0x00000008u; +} +void Tile_Value::clear_int_value() { + int_value_ = GOOGLE_LONGLONG(0); + clear_has_int_value(); +} + ::google::protobuf::int64 Tile_Value::int_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.int_value) + return int_value_; +} + void Tile_Value::set_int_value(::google::protobuf::int64 value) { + set_has_int_value(); + int_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.int_value) +} + +// optional uint64 uint_value = 5; +bool Tile_Value::has_uint_value() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void Tile_Value::set_has_uint_value() { + _has_bits_[0] |= 0x00000010u; +} +void Tile_Value::clear_has_uint_value() { + _has_bits_[0] &= ~0x00000010u; +} +void Tile_Value::clear_uint_value() { + uint_value_ = GOOGLE_ULONGLONG(0); + clear_has_uint_value(); +} + ::google::protobuf::uint64 Tile_Value::uint_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.uint_value) + return uint_value_; +} + void Tile_Value::set_uint_value(::google::protobuf::uint64 value) { + set_has_uint_value(); + uint_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.uint_value) +} + +// optional sint64 sint_value = 6; +bool Tile_Value::has_sint_value() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void Tile_Value::set_has_sint_value() { + _has_bits_[0] |= 0x00000020u; +} +void Tile_Value::clear_has_sint_value() { + _has_bits_[0] &= ~0x00000020u; +} +void Tile_Value::clear_sint_value() { + sint_value_ = GOOGLE_LONGLONG(0); + clear_has_sint_value(); +} + ::google::protobuf::int64 Tile_Value::sint_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.sint_value) + return sint_value_; +} + void Tile_Value::set_sint_value(::google::protobuf::int64 value) { + set_has_sint_value(); + sint_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.sint_value) +} + +// optional bool bool_value = 7; +bool Tile_Value::has_bool_value() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void Tile_Value::set_has_bool_value() { + _has_bits_[0] |= 0x00000040u; +} +void Tile_Value::clear_has_bool_value() { + _has_bits_[0] &= ~0x00000040u; +} +void Tile_Value::clear_bool_value() { + bool_value_ = false; + clear_has_bool_value(); +} + bool Tile_Value::bool_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.bool_value) + return bool_value_; +} + void Tile_Value::set_bool_value(bool value) { + set_has_bool_value(); + bool_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.bool_value) +} + +// ------------------------------------------------------------------- + +// Tile_Feature + +// optional uint64 id = 1 [default = 0]; +bool Tile_Feature::has_id() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void Tile_Feature::set_has_id() { + _has_bits_[0] |= 0x00000001u; +} +void Tile_Feature::clear_has_id() { + _has_bits_[0] &= ~0x00000001u; +} +void Tile_Feature::clear_id() { + id_ = GOOGLE_ULONGLONG(0); + clear_has_id(); +} + ::google::protobuf::uint64 Tile_Feature::id() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.id) + return id_; +} + void Tile_Feature::set_id(::google::protobuf::uint64 value) { + set_has_id(); + id_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.id) +} + +// repeated uint32 tags = 2 [packed = true]; +int Tile_Feature::tags_size() const { + return tags_.size(); +} +void Tile_Feature::clear_tags() { + tags_.Clear(); +} + ::google::protobuf::uint32 Tile_Feature::tags(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.tags) + return tags_.Get(index); +} + void Tile_Feature::set_tags(int index, ::google::protobuf::uint32 value) { + tags_.Set(index, value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.tags) +} + void Tile_Feature::add_tags(::google::protobuf::uint32 value) { + tags_.Add(value); + // @@protoc_insertion_point(field_add:vector_tile.Tile.Feature.tags) +} + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +Tile_Feature::tags() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Feature.tags) + return tags_; +} + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +Tile_Feature::mutable_tags() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Feature.tags) + return &tags_; +} + +// optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; +bool Tile_Feature::has_type() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void Tile_Feature::set_has_type() { + _has_bits_[0] |= 0x00000004u; +} +void Tile_Feature::clear_has_type() { + _has_bits_[0] &= ~0x00000004u; +} +void Tile_Feature::clear_type() { + type_ = 0; + clear_has_type(); +} + ::vector_tile::Tile_GeomType Tile_Feature::type() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.type) + return static_cast< ::vector_tile::Tile_GeomType >(type_); +} + void Tile_Feature::set_type(::vector_tile::Tile_GeomType value) { + assert(::vector_tile::Tile_GeomType_IsValid(value)); + set_has_type(); + type_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.type) +} + +// repeated uint32 geometry = 4 [packed = true]; +int Tile_Feature::geometry_size() const { + return geometry_.size(); +} +void Tile_Feature::clear_geometry() { + geometry_.Clear(); +} + ::google::protobuf::uint32 Tile_Feature::geometry(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.geometry) + return geometry_.Get(index); +} + void Tile_Feature::set_geometry(int index, ::google::protobuf::uint32 value) { + geometry_.Set(index, value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.geometry) +} + void Tile_Feature::add_geometry(::google::protobuf::uint32 value) { + geometry_.Add(value); + // @@protoc_insertion_point(field_add:vector_tile.Tile.Feature.geometry) +} + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +Tile_Feature::geometry() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Feature.geometry) + return geometry_; +} + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +Tile_Feature::mutable_geometry() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Feature.geometry) + return &geometry_; +} + +// ------------------------------------------------------------------- + +// Tile_Layer + +// required uint32 version = 15 [default = 1]; +bool Tile_Layer::has_version() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void Tile_Layer::set_has_version() { + _has_bits_[0] |= 0x00000001u; +} +void Tile_Layer::clear_has_version() { + _has_bits_[0] &= ~0x00000001u; +} +void Tile_Layer::clear_version() { + version_ = 1u; + clear_has_version(); +} + ::google::protobuf::uint32 Tile_Layer::version() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.version) + return version_; +} + void Tile_Layer::set_version(::google::protobuf::uint32 value) { + set_has_version(); + version_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.version) +} + +// required string name = 1; +bool Tile_Layer::has_name() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void Tile_Layer::set_has_name() { + _has_bits_[0] |= 0x00000002u; +} +void Tile_Layer::clear_has_name() { + _has_bits_[0] &= ~0x00000002u; +} +void Tile_Layer::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} + const ::std::string& Tile_Layer::name() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void Tile_Layer::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.name) +} + void Tile_Layer::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:vector_tile.Tile.Layer.name) +} + void Tile_Layer::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:vector_tile.Tile.Layer.name) +} + ::std::string* Tile_Layer::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* Tile_Layer::release_name() { + // @@protoc_insertion_point(field_release:vector_tile.Tile.Layer.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void Tile_Layer::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:vector_tile.Tile.Layer.name) +} + +// repeated .vector_tile.Tile.Feature features = 2; +int Tile_Layer::features_size() const { + return features_.size(); +} +void Tile_Layer::clear_features() { + features_.Clear(); +} +const ::vector_tile::Tile_Feature& Tile_Layer::features(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.features) + return features_.Get(index); +} +::vector_tile::Tile_Feature* Tile_Layer::mutable_features(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.features) + return features_.Mutable(index); +} +::vector_tile::Tile_Feature* Tile_Layer::add_features() { + // @@protoc_insertion_point(field_add:vector_tile.Tile.Layer.features) + return features_.Add(); +} +::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature >* +Tile_Layer::mutable_features() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Layer.features) + return &features_; +} +const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature >& +Tile_Layer::features() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Layer.features) + return features_; +} + +// repeated string keys = 3; +int Tile_Layer::keys_size() const { + return keys_.size(); +} +void Tile_Layer::clear_keys() { + keys_.Clear(); +} + const ::std::string& Tile_Layer::keys(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.keys) + return keys_.Get(index); +} + ::std::string* Tile_Layer::mutable_keys(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.keys) + return keys_.Mutable(index); +} + void Tile_Layer::set_keys(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.keys) + keys_.Mutable(index)->assign(value); +} + void Tile_Layer::set_keys(int index, const char* value) { + keys_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:vector_tile.Tile.Layer.keys) +} + void Tile_Layer::set_keys(int index, const char* value, size_t size) { + keys_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:vector_tile.Tile.Layer.keys) +} + ::std::string* Tile_Layer::add_keys() { + // @@protoc_insertion_point(field_add_mutable:vector_tile.Tile.Layer.keys) + return keys_.Add(); +} + void Tile_Layer::add_keys(const ::std::string& value) { + keys_.Add()->assign(value); + // @@protoc_insertion_point(field_add:vector_tile.Tile.Layer.keys) +} + void Tile_Layer::add_keys(const char* value) { + keys_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:vector_tile.Tile.Layer.keys) +} + void Tile_Layer::add_keys(const char* value, size_t size) { + keys_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:vector_tile.Tile.Layer.keys) +} + const ::google::protobuf::RepeatedPtrField< ::std::string>& +Tile_Layer::keys() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Layer.keys) + return keys_; +} + ::google::protobuf::RepeatedPtrField< ::std::string>* +Tile_Layer::mutable_keys() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Layer.keys) + return &keys_; +} + +// repeated .vector_tile.Tile.Value values = 4; +int Tile_Layer::values_size() const { + return values_.size(); +} +void Tile_Layer::clear_values() { + values_.Clear(); +} +const ::vector_tile::Tile_Value& Tile_Layer::values(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.values) + return values_.Get(index); +} +::vector_tile::Tile_Value* Tile_Layer::mutable_values(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.values) + return values_.Mutable(index); +} +::vector_tile::Tile_Value* Tile_Layer::add_values() { + // @@protoc_insertion_point(field_add:vector_tile.Tile.Layer.values) + return values_.Add(); +} +::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value >* +Tile_Layer::mutable_values() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Layer.values) + return &values_; +} +const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value >& +Tile_Layer::values() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Layer.values) + return values_; +} + +// optional uint32 extent = 5 [default = 4096]; +bool Tile_Layer::has_extent() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void Tile_Layer::set_has_extent() { + _has_bits_[0] |= 0x00000020u; +} +void Tile_Layer::clear_has_extent() { + _has_bits_[0] &= ~0x00000020u; +} +void Tile_Layer::clear_extent() { + extent_ = 4096u; + clear_has_extent(); +} + ::google::protobuf::uint32 Tile_Layer::extent() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.extent) + return extent_; +} + void Tile_Layer::set_extent(::google::protobuf::uint32 value) { + set_has_extent(); + extent_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.extent) +} + +// ------------------------------------------------------------------- + +// Tile + +// repeated .vector_tile.Tile.Layer layers = 3; +int Tile::layers_size() const { + return layers_.size(); +} +void Tile::clear_layers() { + layers_.Clear(); +} +const ::vector_tile::Tile_Layer& Tile::layers(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.layers) + return layers_.Get(index); +} +::vector_tile::Tile_Layer* Tile::mutable_layers(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.layers) + return layers_.Mutable(index); +} +::vector_tile::Tile_Layer* Tile::add_layers() { + // @@protoc_insertion_point(field_add:vector_tile.Tile.layers) + return layers_.Add(); +} +::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer >* +Tile::mutable_layers() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.layers) + return &layers_; +} +const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer >& +Tile::layers() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.layers) + return layers_; +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// @@protoc_insertion_point(namespace_scope) + +} // namespace vector_tile + +// @@protoc_insertion_point(global_scope) diff --git a/src/core/vectortile/vector_tile.pb.h b/src/core/vectortile/vector_tile.pb.h new file mode 100644 index 00000000000..876720072a3 --- /dev/null +++ b/src/core/vectortile/vector_tile.pb.h @@ -0,0 +1,1260 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: vector_tile.proto + +#ifndef PROTOBUF_vector_5ftile_2eproto__INCLUDED +#define PROTOBUF_vector_5ftile_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 3000000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace vector_tile { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_vector_5ftile_2eproto(); +void protobuf_AssignDesc_vector_5ftile_2eproto(); +void protobuf_ShutdownFile_vector_5ftile_2eproto(); + +class Tile; +class Tile_Feature; +class Tile_Layer; +class Tile_Value; + +enum Tile_GeomType { + Tile_GeomType_UNKNOWN = 0, + Tile_GeomType_POINT = 1, + Tile_GeomType_LINESTRING = 2, + Tile_GeomType_POLYGON = 3 +}; +bool Tile_GeomType_IsValid(int value); +const Tile_GeomType Tile_GeomType_GeomType_MIN = Tile_GeomType_UNKNOWN; +const Tile_GeomType Tile_GeomType_GeomType_MAX = Tile_GeomType_POLYGON; +const int Tile_GeomType_GeomType_ARRAYSIZE = Tile_GeomType_GeomType_MAX + 1; + +const ::google::protobuf::EnumDescriptor* Tile_GeomType_descriptor(); +inline const ::std::string& Tile_GeomType_Name(Tile_GeomType value) { + return ::google::protobuf::internal::NameOfEnum( + Tile_GeomType_descriptor(), value); +} +inline bool Tile_GeomType_Parse( + const ::std::string& name, Tile_GeomType* value) { + return ::google::protobuf::internal::ParseNamedEnum( + Tile_GeomType_descriptor(), name, value); +} +// =================================================================== + +class Tile_Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:vector_tile.Tile.Value) */ { + public: + Tile_Value(); + virtual ~Tile_Value(); + + Tile_Value(const Tile_Value& from); + + inline Tile_Value& operator=(const Tile_Value& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Tile_Value& default_instance(); + + void Swap(Tile_Value* other); + + // implements Message ---------------------------------------------- + + inline Tile_Value* New() const { return New(NULL); } + + Tile_Value* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Tile_Value& from); + void MergeFrom(const Tile_Value& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Tile_Value* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string string_value = 1; + bool has_string_value() const; + void clear_string_value(); + static const int kStringValueFieldNumber = 1; + const ::std::string& string_value() const; + void set_string_value(const ::std::string& value); + void set_string_value(const char* value); + void set_string_value(const char* value, size_t size); + ::std::string* mutable_string_value(); + ::std::string* release_string_value(); + void set_allocated_string_value(::std::string* string_value); + + // optional float float_value = 2; + bool has_float_value() const; + void clear_float_value(); + static const int kFloatValueFieldNumber = 2; + float float_value() const; + void set_float_value(float value); + + // optional double double_value = 3; + bool has_double_value() const; + void clear_double_value(); + static const int kDoubleValueFieldNumber = 3; + double double_value() const; + void set_double_value(double value); + + // optional int64 int_value = 4; + bool has_int_value() const; + void clear_int_value(); + static const int kIntValueFieldNumber = 4; + ::google::protobuf::int64 int_value() const; + void set_int_value(::google::protobuf::int64 value); + + // optional uint64 uint_value = 5; + bool has_uint_value() const; + void clear_uint_value(); + static const int kUintValueFieldNumber = 5; + ::google::protobuf::uint64 uint_value() const; + void set_uint_value(::google::protobuf::uint64 value); + + // optional sint64 sint_value = 6; + bool has_sint_value() const; + void clear_sint_value(); + static const int kSintValueFieldNumber = 6; + ::google::protobuf::int64 sint_value() const; + void set_sint_value(::google::protobuf::int64 value); + + // optional bool bool_value = 7; + bool has_bool_value() const; + void clear_bool_value(); + static const int kBoolValueFieldNumber = 7; + bool bool_value() const; + void set_bool_value(bool value); + + GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(Tile_Value) + // @@protoc_insertion_point(class_scope:vector_tile.Tile.Value) + private: + inline void set_has_string_value(); + inline void clear_has_string_value(); + inline void set_has_float_value(); + inline void clear_has_float_value(); + inline void set_has_double_value(); + inline void clear_has_double_value(); + inline void set_has_int_value(); + inline void clear_has_int_value(); + inline void set_has_uint_value(); + inline void clear_has_uint_value(); + inline void set_has_sint_value(); + inline void clear_has_sint_value(); + inline void set_has_bool_value(); + inline void clear_has_bool_value(); + + ::google::protobuf::internal::ExtensionSet _extensions_; + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::uint32 _has_bits_[1]; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr string_value_; + double double_value_; + ::google::protobuf::int64 int_value_; + float float_value_; + bool bool_value_; + ::google::protobuf::uint64 uint_value_; + ::google::protobuf::int64 sint_value_; + friend void protobuf_AddDesc_vector_5ftile_2eproto(); + friend void protobuf_AssignDesc_vector_5ftile_2eproto(); + friend void protobuf_ShutdownFile_vector_5ftile_2eproto(); + + void InitAsDefaultInstance(); + static Tile_Value* default_instance_; +}; +// ------------------------------------------------------------------- + +class Tile_Feature : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:vector_tile.Tile.Feature) */ { + public: + Tile_Feature(); + virtual ~Tile_Feature(); + + Tile_Feature(const Tile_Feature& from); + + inline Tile_Feature& operator=(const Tile_Feature& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Tile_Feature& default_instance(); + + void Swap(Tile_Feature* other); + + // implements Message ---------------------------------------------- + + inline Tile_Feature* New() const { return New(NULL); } + + Tile_Feature* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Tile_Feature& from); + void MergeFrom(const Tile_Feature& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Tile_Feature* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional uint64 id = 1 [default = 0]; + bool has_id() const; + void clear_id(); + static const int kIdFieldNumber = 1; + ::google::protobuf::uint64 id() const; + void set_id(::google::protobuf::uint64 value); + + // repeated uint32 tags = 2 [packed = true]; + int tags_size() const; + void clear_tags(); + static const int kTagsFieldNumber = 2; + ::google::protobuf::uint32 tags(int index) const; + void set_tags(int index, ::google::protobuf::uint32 value); + void add_tags(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + tags() const; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + mutable_tags(); + + // optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; + bool has_type() const; + void clear_type(); + static const int kTypeFieldNumber = 3; + ::vector_tile::Tile_GeomType type() const; + void set_type(::vector_tile::Tile_GeomType value); + + // repeated uint32 geometry = 4 [packed = true]; + int geometry_size() const; + void clear_geometry(); + static const int kGeometryFieldNumber = 4; + ::google::protobuf::uint32 geometry(int index) const; + void set_geometry(int index, ::google::protobuf::uint32 value); + void add_geometry(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + geometry() const; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + mutable_geometry(); + + // @@protoc_insertion_point(class_scope:vector_tile.Tile.Feature) + private: + inline void set_has_id(); + inline void clear_has_id(); + inline void set_has_type(); + inline void clear_has_type(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::uint32 _has_bits_[1]; + mutable int _cached_size_; + ::google::protobuf::uint64 id_; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > tags_; + mutable int _tags_cached_byte_size_; + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > geometry_; + mutable int _geometry_cached_byte_size_; + int type_; + friend void protobuf_AddDesc_vector_5ftile_2eproto(); + friend void protobuf_AssignDesc_vector_5ftile_2eproto(); + friend void protobuf_ShutdownFile_vector_5ftile_2eproto(); + + void InitAsDefaultInstance(); + static Tile_Feature* default_instance_; +}; +// ------------------------------------------------------------------- + +class Tile_Layer : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:vector_tile.Tile.Layer) */ { + public: + Tile_Layer(); + virtual ~Tile_Layer(); + + Tile_Layer(const Tile_Layer& from); + + inline Tile_Layer& operator=(const Tile_Layer& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Tile_Layer& default_instance(); + + void Swap(Tile_Layer* other); + + // implements Message ---------------------------------------------- + + inline Tile_Layer* New() const { return New(NULL); } + + Tile_Layer* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Tile_Layer& from); + void MergeFrom(const Tile_Layer& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Tile_Layer* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // required uint32 version = 15 [default = 1]; + bool has_version() const; + void clear_version(); + static const int kVersionFieldNumber = 15; + ::google::protobuf::uint32 version() const; + void set_version(::google::protobuf::uint32 value); + + // required string name = 1; + bool has_name() const; + void clear_name(); + static const int kNameFieldNumber = 1; + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); + + // repeated .vector_tile.Tile.Feature features = 2; + int features_size() const; + void clear_features(); + static const int kFeaturesFieldNumber = 2; + const ::vector_tile::Tile_Feature& features(int index) const; + ::vector_tile::Tile_Feature* mutable_features(int index); + ::vector_tile::Tile_Feature* add_features(); + ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature >* + mutable_features(); + const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature >& + features() const; + + // repeated string keys = 3; + int keys_size() const; + void clear_keys(); + static const int kKeysFieldNumber = 3; + const ::std::string& keys(int index) const; + ::std::string* mutable_keys(int index); + void set_keys(int index, const ::std::string& value); + void set_keys(int index, const char* value); + void set_keys(int index, const char* value, size_t size); + ::std::string* add_keys(); + void add_keys(const ::std::string& value); + void add_keys(const char* value); + void add_keys(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& keys() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_keys(); + + // repeated .vector_tile.Tile.Value values = 4; + int values_size() const; + void clear_values(); + static const int kValuesFieldNumber = 4; + const ::vector_tile::Tile_Value& values(int index) const; + ::vector_tile::Tile_Value* mutable_values(int index); + ::vector_tile::Tile_Value* add_values(); + ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value >* + mutable_values(); + const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value >& + values() const; + + // optional uint32 extent = 5 [default = 4096]; + bool has_extent() const; + void clear_extent(); + static const int kExtentFieldNumber = 5; + ::google::protobuf::uint32 extent() const; + void set_extent(::google::protobuf::uint32 value); + + GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(Tile_Layer) + // @@protoc_insertion_point(class_scope:vector_tile.Tile.Layer) + private: + inline void set_has_version(); + inline void clear_has_version(); + inline void set_has_name(); + inline void clear_has_name(); + inline void set_has_extent(); + inline void clear_has_extent(); + + // helper for ByteSize() + int RequiredFieldsByteSizeFallback() const; + + ::google::protobuf::internal::ExtensionSet _extensions_; + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::uint32 _has_bits_[1]; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature > features_; + ::google::protobuf::uint32 version_; + ::google::protobuf::uint32 extent_; + ::google::protobuf::RepeatedPtrField< ::std::string> keys_; + ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value > values_; + friend void protobuf_AddDesc_vector_5ftile_2eproto(); + friend void protobuf_AssignDesc_vector_5ftile_2eproto(); + friend void protobuf_ShutdownFile_vector_5ftile_2eproto(); + + void InitAsDefaultInstance(); + static Tile_Layer* default_instance_; +}; +// ------------------------------------------------------------------- + +class Tile : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:vector_tile.Tile) */ { + public: + Tile(); + virtual ~Tile(); + + Tile(const Tile& from); + + inline Tile& operator=(const Tile& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Tile& default_instance(); + + void Swap(Tile* other); + + // implements Message ---------------------------------------------- + + inline Tile* New() const { return New(NULL); } + + Tile* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Tile& from); + void MergeFrom(const Tile& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Tile* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + typedef Tile_Value Value; + typedef Tile_Feature Feature; + typedef Tile_Layer Layer; + + typedef Tile_GeomType GeomType; + static const GeomType UNKNOWN = + Tile_GeomType_UNKNOWN; + static const GeomType POINT = + Tile_GeomType_POINT; + static const GeomType LINESTRING = + Tile_GeomType_LINESTRING; + static const GeomType POLYGON = + Tile_GeomType_POLYGON; + static inline bool GeomType_IsValid(int value) { + return Tile_GeomType_IsValid(value); + } + static const GeomType GeomType_MIN = + Tile_GeomType_GeomType_MIN; + static const GeomType GeomType_MAX = + Tile_GeomType_GeomType_MAX; + static const int GeomType_ARRAYSIZE = + Tile_GeomType_GeomType_ARRAYSIZE; + static inline const ::google::protobuf::EnumDescriptor* + GeomType_descriptor() { + return Tile_GeomType_descriptor(); + } + static inline const ::std::string& GeomType_Name(GeomType value) { + return Tile_GeomType_Name(value); + } + static inline bool GeomType_Parse(const ::std::string& name, + GeomType* value) { + return Tile_GeomType_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + // repeated .vector_tile.Tile.Layer layers = 3; + int layers_size() const; + void clear_layers(); + static const int kLayersFieldNumber = 3; + const ::vector_tile::Tile_Layer& layers(int index) const; + ::vector_tile::Tile_Layer* mutable_layers(int index); + ::vector_tile::Tile_Layer* add_layers(); + ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer >* + mutable_layers(); + const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer >& + layers() const; + + GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(Tile) + // @@protoc_insertion_point(class_scope:vector_tile.Tile) + private: + + ::google::protobuf::internal::ExtensionSet _extensions_; + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::uint32 _has_bits_[1]; + mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer > layers_; + friend void protobuf_AddDesc_vector_5ftile_2eproto(); + friend void protobuf_AssignDesc_vector_5ftile_2eproto(); + friend void protobuf_ShutdownFile_vector_5ftile_2eproto(); + + void InitAsDefaultInstance(); + static Tile* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +#if !PROTOBUF_INLINE_NOT_IN_HEADERS +// Tile_Value + +// optional string string_value = 1; +inline bool Tile_Value::has_string_value() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Tile_Value::set_has_string_value() { + _has_bits_[0] |= 0x00000001u; +} +inline void Tile_Value::clear_has_string_value() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Tile_Value::clear_string_value() { + string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_string_value(); +} +inline const ::std::string& Tile_Value::string_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.string_value) + return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Tile_Value::set_string_value(const ::std::string& value) { + set_has_string_value(); + string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.string_value) +} +inline void Tile_Value::set_string_value(const char* value) { + set_has_string_value(); + string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:vector_tile.Tile.Value.string_value) +} +inline void Tile_Value::set_string_value(const char* value, size_t size) { + set_has_string_value(); + string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:vector_tile.Tile.Value.string_value) +} +inline ::std::string* Tile_Value::mutable_string_value() { + set_has_string_value(); + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Value.string_value) + return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* Tile_Value::release_string_value() { + // @@protoc_insertion_point(field_release:vector_tile.Tile.Value.string_value) + clear_has_string_value(); + return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Tile_Value::set_allocated_string_value(::std::string* string_value) { + if (string_value != NULL) { + set_has_string_value(); + } else { + clear_has_string_value(); + } + string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value); + // @@protoc_insertion_point(field_set_allocated:vector_tile.Tile.Value.string_value) +} + +// optional float float_value = 2; +inline bool Tile_Value::has_float_value() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Tile_Value::set_has_float_value() { + _has_bits_[0] |= 0x00000002u; +} +inline void Tile_Value::clear_has_float_value() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Tile_Value::clear_float_value() { + float_value_ = 0; + clear_has_float_value(); +} +inline float Tile_Value::float_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.float_value) + return float_value_; +} +inline void Tile_Value::set_float_value(float value) { + set_has_float_value(); + float_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.float_value) +} + +// optional double double_value = 3; +inline bool Tile_Value::has_double_value() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Tile_Value::set_has_double_value() { + _has_bits_[0] |= 0x00000004u; +} +inline void Tile_Value::clear_has_double_value() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Tile_Value::clear_double_value() { + double_value_ = 0; + clear_has_double_value(); +} +inline double Tile_Value::double_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.double_value) + return double_value_; +} +inline void Tile_Value::set_double_value(double value) { + set_has_double_value(); + double_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.double_value) +} + +// optional int64 int_value = 4; +inline bool Tile_Value::has_int_value() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void Tile_Value::set_has_int_value() { + _has_bits_[0] |= 0x00000008u; +} +inline void Tile_Value::clear_has_int_value() { + _has_bits_[0] &= ~0x00000008u; +} +inline void Tile_Value::clear_int_value() { + int_value_ = GOOGLE_LONGLONG(0); + clear_has_int_value(); +} +inline ::google::protobuf::int64 Tile_Value::int_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.int_value) + return int_value_; +} +inline void Tile_Value::set_int_value(::google::protobuf::int64 value) { + set_has_int_value(); + int_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.int_value) +} + +// optional uint64 uint_value = 5; +inline bool Tile_Value::has_uint_value() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void Tile_Value::set_has_uint_value() { + _has_bits_[0] |= 0x00000010u; +} +inline void Tile_Value::clear_has_uint_value() { + _has_bits_[0] &= ~0x00000010u; +} +inline void Tile_Value::clear_uint_value() { + uint_value_ = GOOGLE_ULONGLONG(0); + clear_has_uint_value(); +} +inline ::google::protobuf::uint64 Tile_Value::uint_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.uint_value) + return uint_value_; +} +inline void Tile_Value::set_uint_value(::google::protobuf::uint64 value) { + set_has_uint_value(); + uint_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.uint_value) +} + +// optional sint64 sint_value = 6; +inline bool Tile_Value::has_sint_value() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void Tile_Value::set_has_sint_value() { + _has_bits_[0] |= 0x00000020u; +} +inline void Tile_Value::clear_has_sint_value() { + _has_bits_[0] &= ~0x00000020u; +} +inline void Tile_Value::clear_sint_value() { + sint_value_ = GOOGLE_LONGLONG(0); + clear_has_sint_value(); +} +inline ::google::protobuf::int64 Tile_Value::sint_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.sint_value) + return sint_value_; +} +inline void Tile_Value::set_sint_value(::google::protobuf::int64 value) { + set_has_sint_value(); + sint_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.sint_value) +} + +// optional bool bool_value = 7; +inline bool Tile_Value::has_bool_value() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +inline void Tile_Value::set_has_bool_value() { + _has_bits_[0] |= 0x00000040u; +} +inline void Tile_Value::clear_has_bool_value() { + _has_bits_[0] &= ~0x00000040u; +} +inline void Tile_Value::clear_bool_value() { + bool_value_ = false; + clear_has_bool_value(); +} +inline bool Tile_Value::bool_value() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Value.bool_value) + return bool_value_; +} +inline void Tile_Value::set_bool_value(bool value) { + set_has_bool_value(); + bool_value_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Value.bool_value) +} + +// ------------------------------------------------------------------- + +// Tile_Feature + +// optional uint64 id = 1 [default = 0]; +inline bool Tile_Feature::has_id() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Tile_Feature::set_has_id() { + _has_bits_[0] |= 0x00000001u; +} +inline void Tile_Feature::clear_has_id() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Tile_Feature::clear_id() { + id_ = GOOGLE_ULONGLONG(0); + clear_has_id(); +} +inline ::google::protobuf::uint64 Tile_Feature::id() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.id) + return id_; +} +inline void Tile_Feature::set_id(::google::protobuf::uint64 value) { + set_has_id(); + id_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.id) +} + +// repeated uint32 tags = 2 [packed = true]; +inline int Tile_Feature::tags_size() const { + return tags_.size(); +} +inline void Tile_Feature::clear_tags() { + tags_.Clear(); +} +inline ::google::protobuf::uint32 Tile_Feature::tags(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.tags) + return tags_.Get(index); +} +inline void Tile_Feature::set_tags(int index, ::google::protobuf::uint32 value) { + tags_.Set(index, value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.tags) +} +inline void Tile_Feature::add_tags(::google::protobuf::uint32 value) { + tags_.Add(value); + // @@protoc_insertion_point(field_add:vector_tile.Tile.Feature.tags) +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +Tile_Feature::tags() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Feature.tags) + return tags_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +Tile_Feature::mutable_tags() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Feature.tags) + return &tags_; +} + +// optional .vector_tile.Tile.GeomType type = 3 [default = UNKNOWN]; +inline bool Tile_Feature::has_type() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Tile_Feature::set_has_type() { + _has_bits_[0] |= 0x00000004u; +} +inline void Tile_Feature::clear_has_type() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Tile_Feature::clear_type() { + type_ = 0; + clear_has_type(); +} +inline ::vector_tile::Tile_GeomType Tile_Feature::type() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.type) + return static_cast< ::vector_tile::Tile_GeomType >(type_); +} +inline void Tile_Feature::set_type(::vector_tile::Tile_GeomType value) { + assert(::vector_tile::Tile_GeomType_IsValid(value)); + set_has_type(); + type_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.type) +} + +// repeated uint32 geometry = 4 [packed = true]; +inline int Tile_Feature::geometry_size() const { + return geometry_.size(); +} +inline void Tile_Feature::clear_geometry() { + geometry_.Clear(); +} +inline ::google::protobuf::uint32 Tile_Feature::geometry(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Feature.geometry) + return geometry_.Get(index); +} +inline void Tile_Feature::set_geometry(int index, ::google::protobuf::uint32 value) { + geometry_.Set(index, value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Feature.geometry) +} +inline void Tile_Feature::add_geometry(::google::protobuf::uint32 value) { + geometry_.Add(value); + // @@protoc_insertion_point(field_add:vector_tile.Tile.Feature.geometry) +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +Tile_Feature::geometry() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Feature.geometry) + return geometry_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +Tile_Feature::mutable_geometry() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Feature.geometry) + return &geometry_; +} + +// ------------------------------------------------------------------- + +// Tile_Layer + +// required uint32 version = 15 [default = 1]; +inline bool Tile_Layer::has_version() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Tile_Layer::set_has_version() { + _has_bits_[0] |= 0x00000001u; +} +inline void Tile_Layer::clear_has_version() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Tile_Layer::clear_version() { + version_ = 1u; + clear_has_version(); +} +inline ::google::protobuf::uint32 Tile_Layer::version() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.version) + return version_; +} +inline void Tile_Layer::set_version(::google::protobuf::uint32 value) { + set_has_version(); + version_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.version) +} + +// required string name = 1; +inline bool Tile_Layer::has_name() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Tile_Layer::set_has_name() { + _has_bits_[0] |= 0x00000002u; +} +inline void Tile_Layer::clear_has_name() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Tile_Layer::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +inline const ::std::string& Tile_Layer::name() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Tile_Layer::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.name) +} +inline void Tile_Layer::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:vector_tile.Tile.Layer.name) +} +inline void Tile_Layer::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:vector_tile.Tile.Layer.name) +} +inline ::std::string* Tile_Layer::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* Tile_Layer::release_name() { + // @@protoc_insertion_point(field_release:vector_tile.Tile.Layer.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Tile_Layer::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:vector_tile.Tile.Layer.name) +} + +// repeated .vector_tile.Tile.Feature features = 2; +inline int Tile_Layer::features_size() const { + return features_.size(); +} +inline void Tile_Layer::clear_features() { + features_.Clear(); +} +inline const ::vector_tile::Tile_Feature& Tile_Layer::features(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.features) + return features_.Get(index); +} +inline ::vector_tile::Tile_Feature* Tile_Layer::mutable_features(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.features) + return features_.Mutable(index); +} +inline ::vector_tile::Tile_Feature* Tile_Layer::add_features() { + // @@protoc_insertion_point(field_add:vector_tile.Tile.Layer.features) + return features_.Add(); +} +inline ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature >* +Tile_Layer::mutable_features() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Layer.features) + return &features_; +} +inline const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Feature >& +Tile_Layer::features() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Layer.features) + return features_; +} + +// repeated string keys = 3; +inline int Tile_Layer::keys_size() const { + return keys_.size(); +} +inline void Tile_Layer::clear_keys() { + keys_.Clear(); +} +inline const ::std::string& Tile_Layer::keys(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.keys) + return keys_.Get(index); +} +inline ::std::string* Tile_Layer::mutable_keys(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.keys) + return keys_.Mutable(index); +} +inline void Tile_Layer::set_keys(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.keys) + keys_.Mutable(index)->assign(value); +} +inline void Tile_Layer::set_keys(int index, const char* value) { + keys_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:vector_tile.Tile.Layer.keys) +} +inline void Tile_Layer::set_keys(int index, const char* value, size_t size) { + keys_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:vector_tile.Tile.Layer.keys) +} +inline ::std::string* Tile_Layer::add_keys() { + // @@protoc_insertion_point(field_add_mutable:vector_tile.Tile.Layer.keys) + return keys_.Add(); +} +inline void Tile_Layer::add_keys(const ::std::string& value) { + keys_.Add()->assign(value); + // @@protoc_insertion_point(field_add:vector_tile.Tile.Layer.keys) +} +inline void Tile_Layer::add_keys(const char* value) { + keys_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:vector_tile.Tile.Layer.keys) +} +inline void Tile_Layer::add_keys(const char* value, size_t size) { + keys_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:vector_tile.Tile.Layer.keys) +} +inline const ::google::protobuf::RepeatedPtrField< ::std::string>& +Tile_Layer::keys() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Layer.keys) + return keys_; +} +inline ::google::protobuf::RepeatedPtrField< ::std::string>* +Tile_Layer::mutable_keys() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Layer.keys) + return &keys_; +} + +// repeated .vector_tile.Tile.Value values = 4; +inline int Tile_Layer::values_size() const { + return values_.size(); +} +inline void Tile_Layer::clear_values() { + values_.Clear(); +} +inline const ::vector_tile::Tile_Value& Tile_Layer::values(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.values) + return values_.Get(index); +} +inline ::vector_tile::Tile_Value* Tile_Layer::mutable_values(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.Layer.values) + return values_.Mutable(index); +} +inline ::vector_tile::Tile_Value* Tile_Layer::add_values() { + // @@protoc_insertion_point(field_add:vector_tile.Tile.Layer.values) + return values_.Add(); +} +inline ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value >* +Tile_Layer::mutable_values() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.Layer.values) + return &values_; +} +inline const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Value >& +Tile_Layer::values() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.Layer.values) + return values_; +} + +// optional uint32 extent = 5 [default = 4096]; +inline bool Tile_Layer::has_extent() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void Tile_Layer::set_has_extent() { + _has_bits_[0] |= 0x00000020u; +} +inline void Tile_Layer::clear_has_extent() { + _has_bits_[0] &= ~0x00000020u; +} +inline void Tile_Layer::clear_extent() { + extent_ = 4096u; + clear_has_extent(); +} +inline ::google::protobuf::uint32 Tile_Layer::extent() const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.Layer.extent) + return extent_; +} +inline void Tile_Layer::set_extent(::google::protobuf::uint32 value) { + set_has_extent(); + extent_ = value; + // @@protoc_insertion_point(field_set:vector_tile.Tile.Layer.extent) +} + +// ------------------------------------------------------------------- + +// Tile + +// repeated .vector_tile.Tile.Layer layers = 3; +inline int Tile::layers_size() const { + return layers_.size(); +} +inline void Tile::clear_layers() { + layers_.Clear(); +} +inline const ::vector_tile::Tile_Layer& Tile::layers(int index) const { + // @@protoc_insertion_point(field_get:vector_tile.Tile.layers) + return layers_.Get(index); +} +inline ::vector_tile::Tile_Layer* Tile::mutable_layers(int index) { + // @@protoc_insertion_point(field_mutable:vector_tile.Tile.layers) + return layers_.Mutable(index); +} +inline ::vector_tile::Tile_Layer* Tile::add_layers() { + // @@protoc_insertion_point(field_add:vector_tile.Tile.layers) + return layers_.Add(); +} +inline ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer >* +Tile::mutable_layers() { + // @@protoc_insertion_point(field_mutable_list:vector_tile.Tile.layers) + return &layers_; +} +inline const ::google::protobuf::RepeatedPtrField< ::vector_tile::Tile_Layer >& +Tile::layers() const { + // @@protoc_insertion_point(field_list:vector_tile.Tile.layers) + return layers_; +} + +#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace vector_tile + +#ifndef SWIG +namespace google { +namespace protobuf { + +template <> struct is_proto_enum< ::vector_tile::Tile_GeomType> : ::google::protobuf::internal::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::vector_tile::Tile_GeomType>() { + return ::vector_tile::Tile_GeomType_descriptor(); +} + +} // namespace protobuf +} // namespace google +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_vector_5ftile_2eproto__INCLUDED diff --git a/src/providers/wms/CMakeLists.txt b/src/providers/wms/CMakeLists.txt index 834bef7dd07..331f7c982c5 100644 --- a/src/providers/wms/CMakeLists.txt +++ b/src/providers/wms/CMakeLists.txt @@ -1,5 +1,4 @@ SET (WMS_SRCS - qgsmbtilesreader.cpp qgswmscapabilities.cpp qgswmsprovider.cpp qgswmsconnection.cpp