[mapguide-commits] r10081 - in branches/4.0/MgDev: Common/Foundation/Data Common/MapGuideCommon/Services Common/Renderers Common/Renderers/mvt Doc/samples Doc/samples/clientsamples Server/src/Services/Rendering Server/src/Services/Tile Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 17 04:06:38 PDT 2024
Author: jng
Date: 2024-07-17 04:06:37 -0700 (Wed, 17 Jul 2024)
New Revision: 10081
Removed:
branches/4.0/MgDev/Common/Renderers/MVTRenderer.cpp
branches/4.0/MgDev/Common/Renderers/MVTRenderer.h
branches/4.0/MgDev/Common/Renderers/mvt/gpb.h
branches/4.0/MgDev/Common/Renderers/mvt/mvt_port.h
branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.cpp
branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.h
branches/4.0/MgDev/Doc/samples/clientsamples/mvt/
branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.cpp
branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.h
Modified:
branches/4.0/MgDev/Common/Foundation/Data/ByteSink.cpp
branches/4.0/MgDev/Common/Foundation/Data/MimeType.cpp
branches/4.0/MgDev/Common/Foundation/Data/MimeType.h
branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp
branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h
branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h
branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingService.h
branches/4.0/MgDev/Common/Renderers/CMakeLists.txt
branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj
branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj.filters
branches/4.0/MgDev/Doc/samples/samples.php
branches/4.0/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp
branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj
branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj.filters
branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingServiceBuild.cpp
branches/4.0/MgDev/Server/src/Services/Tile/ServerTileService.cpp
branches/4.0/MgDev/Server/src/Services/Tile/TileCacheXYZProvider.cpp
branches/4.0/MgDev/Server/src/UnitTesting/TestRenderingService.cpp
Log:
#2880: Retract MVT rendering support
Modified: branches/4.0/MgDev/Common/Foundation/Data/ByteSink.cpp
===================================================================
--- branches/4.0/MgDev/Common/Foundation/Data/ByteSink.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Foundation/Data/ByteSink.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -81,7 +81,6 @@
if (!mimeType.empty()
&& mimeType.find(L"text") == STRING::npos
&& mimeType.find(L"json") == STRING::npos
- && MgMimeType::Mvt != mimeType
&& MgMimeType::Binary != mimeType)
{
// Note that the mime type of resource data is determined by the
Modified: branches/4.0/MgDev/Common/Foundation/Data/MimeType.cpp
===================================================================
--- branches/4.0/MgDev/Common/Foundation/Data/MimeType.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Foundation/Data/MimeType.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -36,5 +36,4 @@
const STRING MgMimeType::Json = L"application/json";
const STRING MgMimeType::Kml = L"application/vnd.google-earth.kml+xml";
const STRING MgMimeType::Kmz = L"application/vnd.google-earth.kmz";
-const STRING MgMimeType::Meta = L"application/metatile";
-const STRING MgMimeType::Mvt = L"application/vnd.mapbox-vector-tile";
\ No newline at end of file
+const STRING MgMimeType::Meta = L"application/metatile";
\ No newline at end of file
Modified: branches/4.0/MgDev/Common/Foundation/Data/MimeType.h
===================================================================
--- branches/4.0/MgDev/Common/Foundation/Data/MimeType.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Foundation/Data/MimeType.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -87,10 +87,6 @@
/// \brief
/// application/metatile
static const STRING Meta; ///\if INTERNAL value("application/metatile") \endif
-
- /// \brief
- /// application/vnd.mapbox-vector-tile
- static const STRING Mvt; ///\if INTERNAL value("application/vnd.mapbox-vector-tile") \endif
};
/// \}
Modified: branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp
===================================================================
--- branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -282,28 +282,6 @@
return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
}
-MgByteReader * MgProxyRenderingService::RenderTileMVT(MgMap * map, CREFSTRING baseMapLayerGroupName, INT32 x, INT32 y, INT32 z, INT32 dpi)
-{
- MgCommand cmd;
- cmd.ExecuteCommand(m_connProp, // Connection
- MgCommand::knObject, // Return type expected
- MgRenderingServiceOpId::RenderTileMVT, // Command Code
- 7, // No of arguments
- Rendering_Service, // Service Id
- BUILD_VERSION(4,0,0), // Operation version
- MgCommand::knObject, map, // Argument#1
- MgCommand::knString, &baseMapLayerGroupName, // Argument#2
- MgCommand::knInt32, x, // Argument#3
- MgCommand::knInt32, y, // Argument#4
- MgCommand::knInt32, z, // Argument#5
- MgCommand::knInt32, dpi, // Argument#6
- MgCommand::knNone); // End of arguments
-
- SetWarning(cmd.GetWarningObject());
-
- return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
-}
-
/////////////////////////////////////////////////////////////////
/// <summary>
/// Renders all dynamic layers in the specified MgMap to a dynamic overlay image
Modified: branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h
===================================================================
--- branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/MapGuideCommon/Services/ProxyRenderingService.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -322,46 +322,6 @@
/////////////////////////////////////////////////////////////////
/// \brief
- /// Returns the specified MVT (Mapbox Vector Tile) for the given map. Tile structure is
- /// based on the XYZ tiling scheme used by Google Maps, OpenStreetMap, and
- /// others
- ///
- /// \param map
- /// Input
- /// map object containing current state of map.
- /// \param baseMapLayerGroupName
- /// Input
- /// Specifies the name of the baseMapLayerGroup for which to render the tile.
- /// \param x
- /// Input
- /// Specifies the row index of the tile to return.
- /// \param y
- /// Input
- /// Specifies the column index of the tile to return.
- /// \param z
- /// Input
- /// Specifies the zoom level of the tile to return.
- /// \param dpi
- /// Input
- /// Specifies the dpi of the tile to return.
- /// \param tileImageFormat
- /// Input
- /// Specifies the image format of the tile to return.
- ///
- /// \return
- /// A byte reader containing the rendered tile image.
- ///
- /// \since 4.0
- virtual MgByteReader* RenderTileMVT(
- MgMap* map,
- CREFSTRING baseMapLayerGroupName,
- INT32 x,
- INT32 y,
- INT32 z,
- INT32 dpi);
-
- /////////////////////////////////////////////////////////////////
- /// \brief
/// Renders all dynamic layers in the specified MgMap to a dynamic overlay image
/// with a transparent background. The center, scale, size, and layers to be
/// rendered are defined by the specified map instance. The format parameter
Modified: branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h
===================================================================
--- branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingDefs.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -50,7 +50,6 @@
static const int RenderMetatile = 0x1111E916;
static const int RenderTileFromMetaTile = 0x1111E917;
static const int RenderMetatileXYZ = 0x1111E918;
- static const int RenderTileMVT = 0x1111E919;
};
/// \endcond
Modified: branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingService.h
===================================================================
--- branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingService.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/MapGuideCommon/Services/RenderingService.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -338,46 +338,6 @@
/////////////////////////////////////////////////////////////////
/// \brief
- /// Returns the specified MVT (Mapbox Vector Tile) for the given map. Tile structure is
- /// based on the XYZ tiling scheme used by Google Maps, OpenStreetMap, and
- /// others
- ///
- /// \param map
- /// Input
- /// map object containing current state of map.
- /// \param baseMapLayerGroupName
- /// Input
- /// Specifies the name of the baseMapLayerGroup for which to render the tile.
- /// \param x
- /// Input
- /// Specifies the row index of the tile to return.
- /// \param y
- /// Input
- /// Specifies the column index of the tile to return.
- /// \param z
- /// Input
- /// Specifies the zoom level of the tile to return.
- /// \param dpi
- /// Input
- /// Specifies the dpi of the tile to return.
- /// \param tileImageFormat
- /// Input
- /// Specifies the image format of the tile to return.
- ///
- /// \return
- /// A byte reader containing the rendered tile image.
- ///
- /// \since 4.0
- virtual MgByteReader* RenderTileMVT(
- MgMap* map,
- CREFSTRING baseMapLayerGroupName,
- INT32 x,
- INT32 y,
- INT32 z,
- INT32 dpi) = 0;
-
- /////////////////////////////////////////////////////////////////
- /// \brief
/// Renders all dynamic layers in the specified MgMap to a dynamic overlay image
/// with a transparent background. The center, scale, size, and layers to be
/// rendered are defined by the specified map instance. The format parameter
Modified: branches/4.0/MgDev/Common/Renderers/CMakeLists.txt
===================================================================
--- branches/4.0/MgDev/Common/Renderers/CMakeLists.txt 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/CMakeLists.txt 2024-07-17 11:06:37 UTC (rev 10081)
@@ -40,8 +40,6 @@
KmlIconStyle.cpp
KmlRenderer.cpp
MapQuantization.cpp
- mvt/mvt_tile.cpp
- MVTRenderer.cpp
ObservationMesh.cpp
RenderUtil.cpp
RS_ByteData.cpp
Deleted: branches/4.0/MgDev/Common/Renderers/MVTRenderer.cpp
===================================================================
--- branches/4.0/MgDev/Common/Renderers/MVTRenderer.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/MVTRenderer.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,877 +0,0 @@
-//
-// Copyright (C) 2004-2019 by Autodesk, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of version 2.1 of the GNU Lesser
-// General Public License as published by the Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#include "MVTRenderer.h"
-#include "RS_FeatureReader.h"
-#include "UnicodeString.h"
-#include <cmath>
-#include "mvt/gpb.h"
-#include "mvt/mvt_tile.h"
-
-// =========================== MVTRenderer overview =============================== //
-//
-// MVTRenderer is really just an adapter to connect our Stylizer to MVTTile
-//
-// So the responsibility of MVTRenderer is simply to:
-//
-// - Create a new MVTTileLayer instance on every StartLayer()
-// - Stash the RS_FeatureReader pointer on every StartFeature() call (we need this for writing properties)
-// - For every ProcessXXX() call
-// - Create a MVTTileLayerFeature instance
-// - Write the active property map
-// - Encode the geometry coordinates
-// - Add the MVTTileLayerFeature if encoding succeeds
-//
-// ================================================================================ //
-
-// WebMercator related constants
-constexpr double kmSPHERICAL_RADIUS = 6378137.0;
-constexpr double kmMAX_GM = kmSPHERICAL_RADIUS * M_PI; // 20037508.342789244
-
-static unsigned GetCmdCountCombined(unsigned int nCmdId,
- unsigned int nCmdCount)
-{
- return (nCmdId | (nCmdCount << 3));
-}
-
-
-struct MVTRenderer::MVTImpl {
- MVTImpl(MVTRenderer* parent, int x, int y, int z)
- : m_activeLayer(nullptr)
- , m_nExtent(knDEFAULT_EXTENT)
- , m_tileX(x)
- , m_tileY(y)
- , m_tileZ(z)
- //InitWebMercatorTilingScheme
- , m_dfTopX(-kmMAX_GM)
- , m_dfTopY(kmMAX_GM)
- , m_dfTileDim0(2 * kmMAX_GM)
- , m_parent(parent)
- , m_nBuffer(0)
- {
- m_nBuffer = 5 * m_nExtent / 256;
- }
-
- ~MVTImpl()
- {
-
- }
-
- double GetMVTBuffer()
- {
- double dfTileDim = m_dfTileDim0 / (1 << m_tileZ);
- double dfBuffer = dfTileDim * m_nBuffer / m_nExtent;
- return dfBuffer;
- }
-
- void AddDebugTileBorder(LineBuffer* lb)
- {
- auto layer = std::make_shared<MVTTileLayer>();
- layer->setName("MG_DEBUG_TILE_BORDER");
- // In the past it appeared we were able to get away with not setting this information, but with recent client libraries like
- // OpenLayers, this information is expected to be there, so set it.
- layer->setVersion(2);
- layer->setExtent(4096);
- m_tile.addLayer(layer);
-
- auto feature = std::make_shared<MVTTileLayerFeature>();
- feature->setType(MVTTileLayerFeature::GeomType::POLYGON);
-
- if (EncodePolygon(feature.get(), lb))
- layer->addFeature(feature);
- }
-
- void SetActiveLayerBuilder(const std::string& name)
- {
- m_activeLayer = std::make_shared<MVTTileLayer>();
- m_activeLayer->setName(name);
- // In the past it appeared we were able to get away with not setting this information, but with recent client libraries like
- // OpenLayers, this information is expected to be there, so set it.
- m_activeLayer->setVersion(2);
- m_activeLayer->setExtent(4096);
- m_tile.addLayer(m_activeLayer);
- }
-
- void ClearActiveLayerBuilder()
- {
- m_activeLayer.reset();
- }
-
- void ConvertToTileCoords(double dfX,
- double dfY,
- int& nX,
- int& nY,
- double dfTopX,
- double dfTopY,
- double dfTileDim) const
- {
- nX = static_cast<int>(std::round((dfX - dfTopX) * m_nExtent / dfTileDim));
- nY = static_cast<int>(std::round((dfTopY - dfY) * m_nExtent / dfTileDim));
- }
-
- static void AddActiveFeatureProperties(RS_FeatureReader* activeFeature, MVTTileLayer* layer, MVTTileLayerFeature* feature)
- {
- TrySetFeatureId(feature, activeFeature);
-
- int count;
- auto propNames = activeFeature->GetPropNames(count);
- for (int i = 0; i < count; i++)
- {
- auto name = propNames[i];
- if (activeFeature->IsNull(name))
- {
- continue;
- }
-
- MVTTileLayerValue tv;
-
- std::string mbName;
- UnicodeString::WideCharToMultiByte(name, mbName);
- auto propType = activeFeature->GetPropertyType(name);
- switch (propType)
- {
- case FdoDataType_Boolean:
- tv.setBoolValue(activeFeature->GetBoolean(name));
- break;
- case FdoDataType_Byte:
- tv.setIntValue(activeFeature->GetByte(name));
- break;
- case FdoDataType_DateTime:
- {
- auto dt = activeFeature->GetAsString(name);
- std::string sDt;
- UnicodeString::WideCharToMultiByte(dt, sDt);
- tv.setStringValue(sDt);
- break;
- }
- case FdoDataType_Decimal:
- case FdoDataType_Double:
- tv.setDoubleValue(activeFeature->GetDouble(name));
- break;
- case FdoDataType_Int16:
- tv.setIntValue(activeFeature->GetInt16(name));
- break;
- case FdoDataType_Int32:
- tv.setIntValue(activeFeature->GetInt32(name));
- break;
- case FdoDataType_Int64:
- tv.setIntValue(activeFeature->GetInt64(name));
- break;
- case FdoDataType_Single:
- tv.setFloatValue(activeFeature->GetSingle(name));
- break;
- case FdoDataType_String:
- {
- auto s = activeFeature->GetString(name);
- std::string sVal;
- UnicodeString::WideCharToMultiByte(s, sVal);
- tv.setStringValue(sVal);
- break;
- }
- case FdoDataType_BLOB: //Not handled
- case FdoDataType_CLOB:
- break;
- }
-
- auto nKey = layer->addKey(mbName);
- auto nVal = layer->addValue(tv);
- feature->addTag(nKey);
- feature->addTag(nVal);
- }
- }
-
- static void TrySetFeatureId(MVTTileLayerFeature* feature, RS_FeatureReader* activeFeature)
- {
- int count = 0;
- auto idPropNames = activeFeature->GetIdentPropNames(count);
- if (count == 1)
- {
- auto idName = idPropNames[0];
- auto ptype = activeFeature->GetPropertyType(idName);
- switch (ptype)
- {
- case FdoDataType_Byte:
- feature->setId(activeFeature->GetByte(idName));
- break;
- case FdoDataType_Int16:
- feature->setId(activeFeature->GetInt16(idName));
- break;
- case FdoDataType_Int32:
- feature->setId(activeFeature->GetInt32(idName));
- break;
- case FdoDataType_Int64:
- feature->setId(activeFeature->GetInt64(idName));
- break;
- }
- }
- }
-
- bool EncodePolygonGeometry(MVTTileLayerFeature* poGPBFeature,
- LineBuffer* lb,
- int cStart, int cEnd,
- double dfTopX,
- double dfTopY,
- double dfTileDim,
- bool bCanRecurse,
- int& nLastX,
- int& nLastY) const
- {
- for (int i = cStart; i <= cEnd; i++)
- {
- const bool bWriteLastPoint = false;
- const bool bReverseOrder = (i > 0);
- const GUInt32 nMinLineTo = 2;
- const GUInt32 nInitialSize = poGPBFeature->getGeometryCount();
- const int nLastXOri = nLastX;
- const int nLastYOri = nLastY;
-
- bool bSuccess =
- EncodeLineStringGeometry(poGPBFeature, lb, i,
- bWriteLastPoint, bReverseOrder,
- nMinLineTo,
- dfTopX, dfTopY, dfTileDim, nLastX, nLastY);
-
- if (!bSuccess)
- {
- if (i == 0)
- return false;
- continue;
- }
- poGPBFeature->addGeometry(GetCmdCountCombined(knCMD_CLOSEPATH, 1));
- }
- return true;
- }
-
- bool EncodePolygon(MVTTileLayerFeature* feature, LineBuffer* lb)
- {
- double dfTileDim = m_dfTileDim0 / (1 << m_tileZ);
- double dfTopX = m_dfTopX + m_tileX * dfTileDim;
- double dfTopY = m_dfTopY - m_tileY * dfTileDim;
- int nLastX = 0;
- int nLastY = 0;
- bool bGeomOK = false;
-
- int cStart = 0;
- int geom_count = lb->geom_count();
- for (int i = 0; i < geom_count; i++)
- {
- int cSize = lb->geom_size(i);
-
- bGeomOK |= EncodePolygonGeometry(feature, lb,
- cStart, cSize - 1,
- dfTopX, dfTopY, dfTileDim,
- true,
- nLastX, nLastY);
-
- cStart += cSize;
- }
-
- return bGeomOK;
- }
-
- void ProcessPolygon(RS_FeatureReader* activeFeature, LineBuffer * lb)
- {
- auto feature = std::make_shared<MVTTileLayerFeature>();
- feature->setType(MVTTileLayerFeature::GeomType::POLYGON);
- AddActiveFeatureProperties(activeFeature, m_activeLayer.get(), feature.get());
- if (EncodePolygon(feature.get(), lb))
- m_activeLayer->addFeature(feature);
- }
-
- bool EncodeLineStringGeometry(MVTTileLayerFeature* poGPBFeature,
- LineBuffer* lb,
- int lineStrIdx,
- bool bWriteLastPoint,
- bool bReverseOrder,
- GUInt32 nMinLineTo,
- double dfTopX,
- double dfTopY,
- double dfTileDim,
- int& nLastX,
- int& nLastY) const
- {
- const GUInt32 nInitialSize = poGPBFeature->getGeometryCount();
- const int nLastXOri = nLastX;
- const int nLastYOri = nLastY;
- GUInt32 nLineToCount = 0;
- const int nPoints = lb->cntr_size(lineStrIdx) - (bWriteLastPoint ? 0 : 1);
- int nFirstX = 0;
- int nFirstY = 0;
- int nLastXValid = nLastX;
- int nLastYValid = nLastY;
- auto pointOffset = lb->contour_start_point(lineStrIdx);
- for (int i = 0; i < nPoints; i++)
- {
- int nX, nY;
- int nSrcIdx = bReverseOrder ? lb->cntr_size(lineStrIdx) - 1 - i : i;
- double dfX = lb->x_coord(nSrcIdx + pointOffset);
- double dfY = lb->y_coord(nSrcIdx + pointOffset);
-
- ConvertToTileCoords(dfX, dfY, nX, nY,
- dfTopX, dfTopY, dfTileDim);
- int nDiffX = nX - nLastX;
- int nDiffY = nY - nLastY;
- if (i == 0 || nDiffX != 0 || nDiffY != 0)
- {
- if (i > 0)
- {
- nLineToCount++;
- if (nLineToCount == 1)
- {
- poGPBFeature->addGeometry(
- GetCmdCountCombined(knCMD_MOVETO, 1));
- const int nLastDiffX = nLastX - nLastXOri;
- const int nLastDiffY = nLastY - nLastYOri;
- poGPBFeature->addGeometry(EncodeSInt(nLastDiffX));
- poGPBFeature->addGeometry(EncodeSInt(nLastDiffY));
-
- // To be modified later
- poGPBFeature->addGeometry(
- GetCmdCountCombined(knCMD_LINETO, 0));
- }
-
- poGPBFeature->addGeometry(EncodeSInt(nDiffX));
- poGPBFeature->addGeometry(EncodeSInt(nDiffY));
- }
- else
- {
- nFirstX = nX;
- nFirstY = nY;
- }
- nLastXValid = nLastX;
- nLastYValid = nLastY;
- nLastX = nX;
- nLastY = nY;
- }
- }
-
- // If last point of ring is identical to first one, discard it
- if (nMinLineTo == 2 && nLineToCount > 0 &&
- nFirstX == nLastX && nFirstY == nLastY)
- {
- poGPBFeature->resizeGeometryArray(
- poGPBFeature->getGeometryCount() - 2);
- nLineToCount--;
- nLastX = nLastXValid;
- nLastY = nLastYValid;
- }
-
- if (nLineToCount >= nMinLineTo)
- {
- // Patch actual number of points in LINETO command
- poGPBFeature->setGeometry(nInitialSize + 3,
- GetCmdCountCombined(knCMD_LINETO, nLineToCount));
- return true;
- }
- else
- {
- poGPBFeature->resizeGeometryArray(nInitialSize);
- nLastX = nLastXOri;
- nLastY = nLastYOri;
- return false;
- }
- }
-
- bool EncodePolyine(MVTTileLayerFeature* feature, LineBuffer* lb)
- {
- double dfTileDim = m_dfTileDim0 / (1 << m_tileZ);
- double dfTopX = m_dfTopX + m_tileX * dfTileDim;
- double dfTopY = m_dfTopY - m_tileY * dfTileDim;
- bool bGeomOK = false;
- const bool bWriteLastPoint = true;
- const bool bReverseOrder = false;
- const GUInt32 nMinLineTo = 1;
- int nLastX = 0;
- int nLastY = 0;
- //TODO: Can probably fold everything into the MultiLineString code path here
- if (lb->cntr_count() == 1)
- {
- bGeomOK = EncodeLineStringGeometry(feature, lb, 0,
- bWriteLastPoint, bReverseOrder,
- nMinLineTo,
- dfTopX, dfTopY, dfTileDim,
- nLastX, nLastY);
- }
- else //MultiLineString
- {
- for (auto i = 0; i < lb->cntr_count(); i++)
- {
- bool bSubGeomOK = EncodeLineStringGeometry(
- feature, lb, i,
- bWriteLastPoint, bReverseOrder,
- nMinLineTo,
- dfTopX, dfTopY, dfTileDim,
- nLastX, nLastY);
- bGeomOK |= bSubGeomOK;
- }
- }
- return bGeomOK;
- }
-
- void ProcessPolyline(RS_FeatureReader* activeFeature, LineBuffer * lb)
- {
- auto feature = std::make_shared<MVTTileLayerFeature>();
- feature->setType(MVTTileLayerFeature::GeomType::LINESTRING);
- AddActiveFeatureProperties(activeFeature, m_activeLayer.get(), feature.get());
- if (EncodePolyine(feature.get(), lb))
- m_activeLayer->addFeature(feature);
- }
-
- bool EncodePoint(MVTTileLayerFeature* feature, LineBuffer* lb)
- {
- double dfTileDim = m_dfTileDim0 / (1 << m_tileZ);
- double dfTopX = m_dfTopX + m_tileX * dfTileDim;
- double dfTopY = m_dfTopY - m_tileY * dfTileDim;
-
- bool bGeomOK = false;
- if (lb->point_count() == 1)
- {
- int nX, nY;
- auto dfX = lb->x_coord(0);
- auto dfY = lb->y_coord(0);
- bGeomOK = true;
- ConvertToTileCoords(dfX, dfY, nX, nY, dfTopX, dfTopY, dfTileDim);
-
- feature->addGeometry(GetCmdCountCombined(knCMD_MOVETO, 1));
- feature->addGeometry(EncodeSInt(nX));
- feature->addGeometry(EncodeSInt(nY));
- }
- else //MultiPoint
- {
- std::set<std::pair<int, int>> oSetUniqueCoords;
- feature->addGeometry(GetCmdCountCombined(knCMD_MOVETO, 0)); // To be modified later
- int nLastX = 0;
- int nLastY = 0;
- for (auto i = 0; i < lb->point_count(); i++)
- {
- int nX, nY;
- auto dfX = lb->x_coord(i);
- auto dfY = lb->y_coord(i);
- ConvertToTileCoords(dfX, dfY, nX, nY, dfTopX, dfTopY, dfTileDim);
- if (oSetUniqueCoords.find(std::pair<int, int>(nX, nY)) ==
- oSetUniqueCoords.end())
- {
- oSetUniqueCoords.insert(std::pair<int, int>(nX, nY));
-
- int nDiffX = nX - nLastX;
- int nDiffY = nY - nLastY;
- feature->addGeometry(EncodeSInt(nDiffX));
- feature->addGeometry(EncodeSInt(nDiffY));
- nLastX = nX;
- nLastY = nY;
- }
- }
- GUInt32 nPoints = static_cast<GUInt32>(oSetUniqueCoords.size());
- bGeomOK = nPoints > 0;
- feature->setGeometry(0, GetCmdCountCombined(knCMD_MOVETO, nPoints));
- }
- return bGeomOK;
- }
-
- void ProcessMarker(RS_FeatureReader* activeFeature, LineBuffer * lb)
- {
- auto feature = std::make_shared<MVTTileLayerFeature>();
- feature->setType(MVTTileLayerFeature::GeomType::POINT);
- AddActiveFeatureProperties(activeFeature, m_activeLayer.get(), feature.get());
- if (EncodePoint(feature.get(), lb))
- m_activeLayer->addFeature(feature);
- }
-
- unsigned char* GetMVTContent(size_t& size)
- {
- size = m_tile.getSize();
- GByte* pabyBuffer = new GByte[size];
- m_tile.write(pabyBuffer);
- return pabyBuffer;
- }
-
- void ReleaseMVTContent(unsigned char* buf)
- {
- delete[] buf;
- }
-
- void SetTileCoords(const int x, const int y, const int z)
- {
- m_tileX = x;
- m_tileY = y;
- m_tileZ = z;
- }
-
-private:
- MVTTile m_tile;
- std::shared_ptr<MVTTileLayer> m_activeLayer;
- MVTRenderer* m_parent;
-
- int m_tileX;
- int m_tileY;
- int m_tileZ;
-
- double m_dfTopX;
- double m_dfTopY;
- double m_dfTileDim0;
-
- unsigned int m_nBuffer;
-
- unsigned int m_nExtent;
-};
-
-MVTRenderer::MVTRenderer(int x, int y, int z)
- : m_impl(new MVTRenderer::MVTImpl(this, x, y, z)) //MVTImpl only stashes this pointer in its ctor, nothing is called on it yet
- , m_mapInfo(nullptr)
- , m_layerInfo(nullptr)
- , m_fcInfo(nullptr)
- , m_bRenderDebugTileBorders(false)
-{
-
-}
-
-MVTRenderer::~MVTRenderer()
-{ }
-
-//Called by the stylizer when rendering is about to begin on the map
-void MVTRenderer::StartMap(RS_MapUIInfo * /*mapInfo*/, RS_Bounds & extents, double mapScale, double dpi, double metersPerUnit, CSysTransformer * /*xformToLL*/)
-{
- double dfBuffer = m_impl->GetMVTBuffer();
-
- m_mapScale = mapScale;
- m_dpi = dpi;
- m_metersPerUnit = metersPerUnit;
- m_extents = extents;
-
- //Capture a copy of the original extents
- m_origExtents.minx = extents.minx;
- m_origExtents.miny = extents.miny;
- m_origExtents.maxx = extents.maxx;
- m_origExtents.maxy = extents.maxy;
-
- m_extents.minx -= dfBuffer;
- m_extents.miny -= dfBuffer;
- m_extents.maxx += dfBuffer;
- m_extents.maxy += dfBuffer;
-
- double wScale = (double)m_width / m_extents.width();
- double hScale = (double)m_height / m_extents.height();
-
- m_xform.x0 = wScale;
- m_xform.x1 = 0.0;
- m_xform.x2 = -wScale * m_extents.minx;
- m_xform.y0 = 0.0;
- m_xform.y1 = hScale;
- m_xform.y2 = -hScale * m_extents.miny;
-
- m_ixform.x0 = 1.0 / wScale;
- m_ixform.x1 = 0.0;
- m_ixform.x2 = m_extents.minx;
- m_ixform.y0 = 0.0;
- m_ixform.y1 = m_ixform.x0;
- m_ixform.y2 = m_extents.miny;
-
- double metersPerPixel = METERS_PER_INCH / m_dpi;
-
- // compute drawing scale
- // drawing scale is map scale converted to [mapping units] / [pixels]
- m_drawingScale = m_mapScale * metersPerPixel / m_metersPerUnit;
-}
-
-//Called by the stylizer when rendering is about to begin on the map
-void MVTRenderer::EndMap()
-{
- // clear the map info
- m_mapInfo = nullptr;
-
- if (m_bRenderDebugTileBorders)
- {
- LineBuffer lb(1);
- lb.MoveTo(m_origExtents.minx, m_origExtents.miny);
- lb.LineTo(m_origExtents.maxx, m_origExtents.miny);
- lb.LineTo(m_origExtents.maxx, m_origExtents.maxy);
- lb.LineTo(m_origExtents.minx, m_origExtents.maxy);
- lb.Close();
-
- m_impl->AddDebugTileBorder(&lb);
- }
-}
-
-//Called by the stylizer when rendering is about to begin on the map for the given layer
-void MVTRenderer::StartLayer(RS_LayerUIInfo * layerInfo, RS_FeatureClassInfo * classInfo)
-{
- m_layerInfo = layerInfo;
- m_fcInfo = classInfo;
-
- std::string name;
- UnicodeString::WideCharToMultiByte(m_layerInfo->name().c_str(), name);
-
- m_impl->SetActiveLayerBuilder(name);
-}
-
-//Called by the stylizer when rendering is about to begin on the map for the layer indicated by StartLayer()
-void MVTRenderer::EndLayer()
-{
- // clear the layer/feature info
- m_layerInfo = nullptr;
- m_fcInfo = nullptr;
-
- m_impl->ClearActiveLayerBuilder();
-}
-
-//Called by the stylizer when rendering is about to begin on the map for the given feature
-void MVTRenderer::StartFeature(RS_FeatureReader * feature, bool /*initialPass*/, const RS_String * /*tooltip*/, const RS_String * /*url*/, const RS_String * /*theme*/, double /*zOffset*/, double /*zExtrusion*/, RS_ElevationType /*zOffsetType*/)
-{
- m_activeFeature = feature;
-}
-
-//Entry point for polygon rendering. Perform any pre-rendering operations.
-void MVTRenderer::ProcessPolygon(LineBuffer * lb, RS_FillStyle & /*fill*/)
-{
- //Optimize LB before sending to MVT tile writer
- auto workbuffer = lb->Optimize(m_drawingScale, m_pPool);
- std::unique_ptr<LineBuffer> spLB(workbuffer);
-
- if (workbuffer)
- m_impl->ProcessPolygon(m_activeFeature, workbuffer);
-
- if (spLB.get())
- LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
-}
-
-//Entry point for polyline rendering. Perform any pre-rendering operations.
-void MVTRenderer::ProcessPolyline(LineBuffer * lb, RS_LineStroke & /*lsym*/)
-{
- //Optimize LB before sending to MVT tile writer
- auto workbuffer = lb->Optimize(m_drawingScale, m_pPool);
- std::unique_ptr<LineBuffer> spLB(workbuffer);
-
- if (workbuffer)
- m_impl->ProcessPolyline(m_activeFeature, workbuffer);
-
- if (spLB.get())
- LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
-}
-
-//Entry point for raster/image rendering. Perform any pre-rendering operations.
-void MVTRenderer::ProcessRaster(unsigned char * /*data*/, int /*length*/, RS_ImageFormat /*format*/, int /*width*/, int /*height*/, RS_Bounds & /*extents*/, TransformMesh * /*xformMesh*/)
-{
- //This will generally result in a call to DrawScreenRaster() after processing.
- //
- //If your renderer only concerns vector data, this method can be left blank
-}
-
-//Entry point for marker rendering. Perform any pre-rendering operations.
-void MVTRenderer::ProcessMarker(LineBuffer * lb, RS_MarkerDef & /*mdef*/, bool /*allowOverpost*/, RS_Bounds * /*bounds*/)
-{
- //vtzero is very finicky about redundant coordinates, so feed vtzero an optimized LineBuffer
- //that should weed such coordinates out
- auto workbuffer = lb->Optimize(m_drawingScale, m_pPool);
- std::unique_ptr<LineBuffer> spLB(workbuffer);
-
- if (workbuffer)
- m_impl->ProcessMarker(m_activeFeature, workbuffer);
-
- if (spLB.get())
- LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
-}
-
-//Entry point for label group rendering.
-void MVTRenderer::ProcessLabelGroup(RS_LabelInfo * /*labels*/, int /*nlabels*/, const RS_String & /*text*/, RS_OverpostType /*type*/, bool /*exclude*/, LineBuffer * /*path*/, double /*scaleLimit*/)
-{
- //Most implementations will carry a LabelRenderer member and forward this method call
- //to it.
- //
- //If your renderer does not render labels, this method can be left blank
-}
-
-// Inserts the contents of a given DWF input stream into the current
-// output W2D. The given coord sys transformation is applied and geometry
-// will be clipped to the RS_Bounds context of the DWFRenderer.
-void MVTRenderer::AddDWFContent(RS_InputStream * /*in*/, CSysTransformer * /*xformer*/, const RS_String & /*section*/, const RS_String & /*passwd*/, const RS_String & /*w2dfilter*/)
-{
- // This is data from a DWF drawing layer. If your renderer is not intended to support DWF
- // drawing layers/sources, this method can be left blank.
-}
-
-//Sets the legacy symbol manager which will be used when fetching (DWF) symbol data
-void MVTRenderer::SetSymbolManager(RS_SymbolManager * /*manager*/)
-{
- //If your renderer does not render DWF-based image symbols, this method can be left blank
-}
-
-RS_MapUIInfo * MVTRenderer::GetMapInfo()
-{
- return m_mapInfo;
-}
-
-RS_LayerUIInfo * MVTRenderer::GetLayerInfo()
-{
- return m_layerInfo;
-}
-
-RS_FeatureClassInfo * MVTRenderer::GetFeatureClassInfo()
-{
- return m_fcInfo;
-}
-
-double MVTRenderer::GetMapScale()
-{
- return m_mapScale;
-}
-
-double MVTRenderer::GetDrawingScale()
-{
- return m_drawingScale;
-}
-
-double MVTRenderer::GetMetersPerUnit()
-{
- return m_metersPerUnit;
-}
-
-double MVTRenderer::GetDpi()
-{
- return m_dpi;
-}
-
-RS_Bounds & MVTRenderer::GetBounds()
-{
- return m_extents;
-}
-
-bool MVTRenderer::RequiresClipping()
-{
- return true;
-}
-
-bool MVTRenderer::RequiresLabelClipping()
-{
- return false;
-}
-
-//Return true if this renderer can handle 3D geometries
-bool MVTRenderer::SupportsZ()
-{
- return false;
-}
-
-//Render out the given polyline using the provided fill style
-void MVTRenderer::DrawScreenPolyline(LineBuffer * /*polyline*/, const SE_Matrix * /*xform*/, const SE_LineStroke & /*lineStroke*/)
-{
-
-}
-
-//Render out the given polygon using the provided fill style
-void MVTRenderer::DrawScreenPolygon(LineBuffer * /*polygon*/, const SE_Matrix * /*xform*/, unsigned int /*fill*/)
-{
-
-}
-
-//Render out the given raster data.
-void MVTRenderer::DrawScreenRaster(unsigned char * /*data*/, int /*length*/, RS_ImageFormat /*format*/, int /*native_width*/, int /*native_height*/, double /*x*/, double /*y*/, double /*w*/, double /*h*/, double /*angleDeg*/)
-{
- //If your renderer only concerns vector data, this method can be left blank
-}
-
-//Render out the given raster data.
-void MVTRenderer::DrawScreenRaster(unsigned char * /*data*/, int /*length*/, RS_ImageFormat /*format*/, int /*native_width*/, int /*native_height*/, double /*x*/, double /*y*/, double /*w*/, double /*h*/, double /*angleDeg*/, double /*alpha*/)
-{
- //If your renderer only concerns vector data, this method can be left blank
-}
-
-//Render out the given text.
-void MVTRenderer::DrawScreenText(const RS_TextMetrics & /*tm*/, RS_TextDef & /*tdef*/, double /*insx*/, double /*insy*/, RS_F_Point * /*path*/, int /*npts*/, double /*param_position*/)
-{
- //If your renderer does not render labels, this method can be left blank
-}
-
-bool MVTRenderer::YPointsUp()
-{
- return false;
-}
-
-void MVTRenderer::GetWorldToScreenTransform(SE_Matrix & xform)
-{
- xform = m_xform;
-}
-
-void MVTRenderer::WorldToScreenPoint(double & inx, double & iny, double & ox, double & oy)
-{
- m_xform.transform(inx, iny, ox, oy);
-}
-
-void MVTRenderer::ScreenToWorldPoint(double & inx, double & iny, double & ox, double & oy)
-{
- m_ixform.transform(inx, iny, ox, oy);
-}
-
-double MVTRenderer::GetScreenUnitsPerMillimeterDevice()
-{
- return m_dpi / MILLIMETERS_PER_INCH;
-}
-
-double MVTRenderer::GetScreenUnitsPerMillimeterWorld()
-{
- return m_dpi / MILLIMETERS_PER_INCH / m_mapScale;
-}
-
-double MVTRenderer::GetScreenUnitsPerPixel()
-{
- return 1.0;
-}
-
-RS_FontEngine * MVTRenderer::GetRSFontEngine()
-{
- return NULL;
-}
-
-//Entry point for label rendering.
-void MVTRenderer::ProcessSELabelGroup(SE_LabelInfo * /*labels*/, int /*nlabels*/, RS_OverpostType /*type*/, bool /*exclude*/, LineBuffer * /*path*/)
-{
- //Most implementations will carry a LabelRenderer member and forward this method call
- //to it.
- //
- //If this render does not render labels, this method can be left blank.
-}
-
-//If this renderer can render labels, add and track the given exclusion region.
-//An exclusion region is a region that should not factor into desired label/symbol placement.
-void MVTRenderer::AddExclusionRegion(RS_F_Point * /*fpts*/, int /*npts*/)
-{
- //Most implementations will carry a LabelRenderer member and forward this method call
- //to it.
- //
- //If this renderer does not render labels. This method can be left blank.
-}
-
-unsigned char* MVTRenderer::GetMVTContent(size_t& size)
-{
- return m_impl->GetMVTContent(size);
-}
-
-void MVTRenderer::ReleaseMVTContent(unsigned char* buf)
-{
- m_impl->ReleaseMVTContent(buf);
-}
-
-RS_DesiredPolygonOrientation MVTRenderer::GetDesiredPolygonOrientation()
-{
- return RS_DesiredPolygonOrientation::Clockwise;
-}
-
-bool MVTRenderer::IsValidTile(unsigned char* buf, size_t size)
-{
- MVTTile oTileDeserialized;
- bool bRet = oTileDeserialized.read(buf, buf + size);
- return bRet;
-}
\ No newline at end of file
Deleted: branches/4.0/MgDev/Common/Renderers/MVTRenderer.h
===================================================================
--- branches/4.0/MgDev/Common/Renderers/MVTRenderer.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/MVTRenderer.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,109 +0,0 @@
-//
-// Copyright (C) 2004-2019 by Autodesk, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of version 2.1 of the GNU Lesser
-// General Public License as published by the Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#ifndef _MVTRENDERER_H_
-#define _MVTRENDERER_H_
-
-#include "Renderers.h"
-#include "SE_Renderer.h"
-#include <vector>
-
-// A renderer that produces Mapbox Vector Tiles (MVT). This renderer exclusively works
-// against an XYZ tile access scheme so it can only be used for rendering XYZ tiles and
-// no other type of rendering
-class MVTRenderer : public SE_Renderer
-{
-public:
- RENDERERS_API MVTRenderer(int x, int y, int z);
- RENDERERS_API virtual ~MVTRenderer();
-
- // Inherited via SE_Renderer
- RENDERERS_API virtual void StartMap(RS_MapUIInfo * mapInfo, RS_Bounds & extents, double mapScale, double dpi, double metersPerUnit, CSysTransformer * xformToLL);
- RENDERERS_API virtual void EndMap();
- RENDERERS_API virtual void StartLayer(RS_LayerUIInfo * layerInfo, RS_FeatureClassInfo * classInfo);
- RENDERERS_API virtual void EndLayer();
- RENDERERS_API virtual void StartFeature(RS_FeatureReader * feature, bool initialPass, const RS_String * tooltip = NULL, const RS_String * url = NULL, const RS_String * theme = NULL, double zOffset = 0.0, double zExtrusion = 0.0, RS_ElevationType zOffsetType = RS_ElevationType_RelativeToGround);
- RENDERERS_API virtual void ProcessPolygon(LineBuffer * lb, RS_FillStyle & fill);
- RENDERERS_API virtual void ProcessPolyline(LineBuffer * lb, RS_LineStroke & lsym);
- RENDERERS_API virtual void ProcessRaster(unsigned char * data, int length, RS_ImageFormat format, int width, int height, RS_Bounds & extents, TransformMesh * xformMesh = NULL);
- RENDERERS_API virtual void ProcessMarker(LineBuffer * lb, RS_MarkerDef & mdef, bool allowOverpost, RS_Bounds * bounds = NULL);
- RENDERERS_API virtual void ProcessLabelGroup(RS_LabelInfo * labels, int nlabels, const RS_String & text, RS_OverpostType type, bool exclude, LineBuffer * path, double scaleLimit);
- RENDERERS_API virtual void AddDWFContent(RS_InputStream * in, CSysTransformer * xformer, const RS_String & section, const RS_String & passwd, const RS_String & w2dfilter);
- RENDERERS_API virtual void SetSymbolManager(RS_SymbolManager * manager);
- RENDERERS_API virtual RS_MapUIInfo * GetMapInfo();
- RENDERERS_API virtual RS_LayerUIInfo * GetLayerInfo();
- RENDERERS_API virtual RS_FeatureClassInfo * GetFeatureClassInfo();
- RENDERERS_API virtual double GetMapScale();
- RENDERERS_API virtual double GetDrawingScale();
- RENDERERS_API virtual double GetMetersPerUnit();
- RENDERERS_API virtual double GetDpi();
- RENDERERS_API virtual RS_Bounds & GetBounds();
- RENDERERS_API virtual bool RequiresClipping();
- RENDERERS_API virtual bool RequiresLabelClipping();
- RENDERERS_API virtual bool SupportsZ();
- RENDERERS_API virtual void DrawScreenPolyline(LineBuffer * polyline, const SE_Matrix * xform, const SE_LineStroke & lineStroke);
- RENDERERS_API virtual void DrawScreenPolygon(LineBuffer * polygon, const SE_Matrix * xform, unsigned int fill);
- RENDERERS_API virtual void DrawScreenRaster(unsigned char * data, int length, RS_ImageFormat format, int native_width, int native_height, double x, double y, double w, double h, double angleDeg);
- RENDERERS_API virtual void DrawScreenRaster(unsigned char * data, int length, RS_ImageFormat format, int native_width, int native_height, double x, double y, double w, double h, double angleDeg, double alpha);
- RENDERERS_API virtual void DrawScreenText(const RS_TextMetrics & tm, RS_TextDef & tdef, double insx, double insy, RS_F_Point * path, int npts, double param_position);
- RENDERERS_API virtual bool YPointsUp();
- RENDERERS_API virtual void GetWorldToScreenTransform(SE_Matrix & xform);
- RENDERERS_API virtual void WorldToScreenPoint(double & inx, double & iny, double & ox, double & oy);
- RENDERERS_API virtual void ScreenToWorldPoint(double & inx, double & iny, double & ox, double & oy);
- RENDERERS_API virtual double GetScreenUnitsPerMillimeterDevice();
- RENDERERS_API virtual double GetScreenUnitsPerMillimeterWorld();
- RENDERERS_API virtual double GetScreenUnitsPerPixel();
- RENDERERS_API virtual RS_FontEngine * GetRSFontEngine();
- RENDERERS_API virtual void ProcessSELabelGroup(SE_LabelInfo * labels, int nlabels, RS_OverpostType type, bool exclude, LineBuffer * path = NULL);
- RENDERERS_API virtual void AddExclusionRegion(RS_F_Point * fpts, int npts);
- RENDERERS_API virtual RS_DesiredPolygonOrientation GetDesiredPolygonOrientation();
-
- // MVT-specific. Caller responsible for calling ReleaseMVTContent() on the returned
- // pointer once done
- RENDERERS_API unsigned char* GetMVTContent(size_t& size);
- RENDERERS_API void ReleaseMVTContent(unsigned char* buf);
-
- // For unit testing purposes
- RENDERERS_API static bool IsValidTile(unsigned char* buf, size_t size);
-
-private:
- struct MVTImpl;
- std::unique_ptr<MVTImpl> m_impl;
-
- RS_FeatureReader* m_activeFeature;
-
- // map/layer/feature info
- RS_MapUIInfo* m_mapInfo;
- RS_LayerUIInfo* m_layerInfo;
- RS_FeatureClassInfo* m_fcInfo;
-
- SE_Matrix m_xform;
- SE_Matrix m_ixform;
- int m_width;
- int m_height;
-
- RS_Bounds m_origExtents;
- RS_Bounds m_extents;
- double m_drawingScale;
- double m_metersPerUnit;
- double m_dpi;
- double m_mapScale;
-
- bool m_bRenderDebugTileBorders;
-};
-
-#endif
\ No newline at end of file
Modified: branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj
===================================================================
--- branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj 2024-07-17 11:06:37 UTC (rev 10081)
@@ -215,8 +215,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="MapQuantization.cpp" />
- <ClCompile Include="MVTRenderer.cpp" />
- <ClCompile Include="mvt\mvt_tile.cpp" />
<ClCompile Include="SymbolTrans.cpp" />
<ClCompile Include="DWFRenderer.cpp" />
<ClCompile Include="EPlotRenderer.cpp" />
@@ -261,10 +259,6 @@
<ClInclude Include="agg_utfgrid_context.h" />
<ClInclude Include="MapQuantization.h" />
<ClInclude Include="MapUTFGrid.h" />
- <ClInclude Include="MVTRenderer.h" />
- <ClInclude Include="mvt\gpb.h" />
- <ClInclude Include="mvt\mvt_port.h" />
- <ClInclude Include="mvt\mvt_tile.h" />
<ClInclude Include="SymbolTrans.h" />
<ClInclude Include="DWFRenderer.h" />
<ClInclude Include="DWFRSInputStream.h" />
Modified: branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj.filters
===================================================================
--- branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj.filters 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/Renderers.vcxproj.filters 2024-07-17 11:06:37 UTC (rev 10081)
@@ -25,9 +25,6 @@
<Filter Include="UTFGridRenderer">
<UniqueIdentifier>{139cab4d-e977-4ad2-8526-73e40cb9dde1}</UniqueIdentifier>
</Filter>
- <Filter Include="MVTRenderer">
- <UniqueIdentifier>{86e80f69-f211-4769-b8fe-549ba11f2bee}</UniqueIdentifier>
- </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SymbolTrans.cpp">
@@ -114,12 +111,6 @@
<ClCompile Include="UTFGridContent.cpp">
<Filter>UTFGridRenderer</Filter>
</ClCompile>
- <ClCompile Include="mvt\mvt_tile.cpp">
- <Filter>MVTRenderer</Filter>
- </ClCompile>
- <ClCompile Include="MVTRenderer.cpp">
- <Filter>MVTRenderer</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SymbolTrans.h">
@@ -211,18 +202,6 @@
<ClInclude Include="MapUTFGrid.h">
<Filter>UTFGridRenderer</Filter>
</ClInclude>
- <ClInclude Include="mvt\gpb.h">
- <Filter>MVTRenderer</Filter>
- </ClInclude>
- <ClInclude Include="mvt\mvt_tile.h">
- <Filter>MVTRenderer</Filter>
- </ClInclude>
- <ClInclude Include="mvt\mvt_port.h">
- <Filter>MVTRenderer</Filter>
- </ClInclude>
- <ClInclude Include="MVTRenderer.h">
- <Filter>MVTRenderer</Filter>
- </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Renderers.rc" />
Deleted: branches/4.0/MgDev/Common/Renderers/mvt/gpb.h
===================================================================
--- branches/4.0/MgDev/Common/Renderers/mvt/gpb.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/mvt/gpb.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,543 +0,0 @@
-/******************************************************************************
- * $Id: gpb.h 1758774fff760a0e28521d01de2d9ae74ca66701 2018-02-14 22:17:51Z Kurt Schwehr $
- *
- * Project: OpenGIS Simple Features Reference Implementation
- * Author: Even Rouault, <even dot rouault at mines dash paris dot org>
- * Purpose: Google Protocol Buffer generic handling functions
- *
- ******************************************************************************
- * Copyright (c) 2012, Even Rouault <even dot rouault at mines-paris dot org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ****************************************************************************/
-
-#ifndef GPB_H_INCLUDED
-#define GPB_H_INCLUDED
-
-#include "mvt_port.h"
-
-#include <string>
-#include <exception>
-
-#ifndef CHECK_OOB
-#define CHECK_OOB 1
-#endif
-
-class GPBException: public std::exception
-{
- std::string m_osMessage;
- public:
- explicit GPBException(int nLine)
- {
- char buf[50];
- int r = snprintf(buf, 50, "Parsing error occurred at line %d", nLine);
- if (r >= 0 && r < 50)
- m_osMessage = buf;
- }
-
- const char* what() const noexcept override
- { return m_osMessage.c_str(); }
-};
-
-#define THROW_GPB_EXCEPTION throw GPBException(__LINE__)
-
-/************************************************************************/
-/* Google Protocol Buffer definitions */
-/************************************************************************/
-
-// TODO(schwehr): This should be an enum.
-constexpr int WT_VARINT = 0;
-constexpr int WT_64BIT = 1;
-constexpr int WT_DATA = 2;
-// constexpr WT_STARTGROUP = 3; // unused
-// constexpr WT_ENDGROUP = 4; // unused
-constexpr int WT_32BIT = 5;
-
-#define MAKE_KEY(nFieldNumber, nWireType) ((nFieldNumber << 3) | nWireType)
-#define GET_WIRETYPE(nKey) (nKey & 0x7)
-#define GET_FIELDNUMBER(nKey) (nKey >> 3)
-
-/************************************************************************/
-/* ReadVarUInt32() */
-/************************************************************************/
-
-inline int ReadVarUInt32(const GByte** ppabyData)
-{
- unsigned int nVal = 0;
- int nShift = 0;
- const GByte* pabyData = *ppabyData;
-
- while(true)
- {
- int nByte = *pabyData;
- if (!(nByte & 0x80))
- {
- *ppabyData = pabyData + 1;
- return nVal | ((unsigned)nByte << nShift);
- }
- nVal |= (nByte & 0x7f) << nShift;
- pabyData ++;
- nShift += 7;
- if( nShift == 28 )
- {
- nByte = *pabyData;
- if (!(nByte & 0x80))
- {
- *ppabyData = pabyData + 1;
- return nVal | (((unsigned)nByte & 0xf) << nShift);
- }
- *ppabyData = pabyData;
- return nVal;
- }
- }
-}
-
-#define READ_VARUINT32(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = ReadVarUInt32(&pabyData); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-#define READ_SIZE(pabyData, pabyDataLimit, nSize) \
- { \
- READ_VARUINT32(pabyData, pabyDataLimit, nSize); \
- if (CHECK_OOB && nSize > (unsigned int)(pabyDataLimit - pabyData)) THROW_GPB_EXCEPTION; \
- }
-
-/************************************************************************/
-/* ReadVarUInt64() */
-/************************************************************************/
-
-inline GUIntBig ReadVarUInt64(const GByte** ppabyData)
-{
- GUIntBig nVal = 0;
- int nShift = 0;
- const GByte* pabyData = *ppabyData;
-
- while(true)
- {
- int nByte = *pabyData;
- if (!(nByte & 0x80))
- {
- *ppabyData = pabyData + 1;
- return nVal | ((GUIntBig)nByte << nShift);
- }
- nVal |= ((GUIntBig)(nByte & 0x7f)) << nShift;
- pabyData ++;
- nShift += 7;
- if( nShift == 63 )
- {
- nByte = *pabyData;
- if (!(nByte & 0x80))
- {
- *ppabyData = pabyData + 1;
- return nVal | (((GUIntBig)nByte & 1) << nShift);
- }
- *ppabyData = pabyData;
- return nVal;
- }
- }
-}
-
-#define READ_VARUINT64(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = ReadVarUInt64(&pabyData); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-#define READ_SIZE64(pabyData, pabyDataLimit, nSize) \
- { \
- READ_VARUINT64(pabyData, pabyDataLimit, nSize); \
- if (CHECK_OOB && nSize > (unsigned int)(pabyDataLimit - pabyData)) THROW_GPB_EXCEPTION; \
- }
-
-/************************************************************************/
-/* ReadVarInt64() */
-/************************************************************************/
-
-inline GIntBig ReadVarInt64(const GByte** ppabyData)
-{
- return static_cast<GIntBig>(ReadVarUInt64(ppabyData));
-}
-
-#define READ_VARINT64(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = ReadVarInt64(&pabyData); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-/************************************************************************/
-/* DecodeSInt() */
-/************************************************************************/
-
-inline GIntBig DecodeSInt(GUIntBig nVal)
-{
- return ((nVal & 1) == 0) ?
- static_cast<GIntBig>(nVal >> 1) : -static_cast<GIntBig>(nVal >> 1)-1;
-}
-
-inline GInt32 DecodeSInt(GUInt32 nVal)
-{
- return ((nVal & 1) == 0) ?
- static_cast<GInt32>(nVal >> 1) : -static_cast<GInt32>(nVal >> 1)-1;
-}
-
-/************************************************************************/
-/* ReadVarSInt64() */
-/************************************************************************/
-
-inline GIntBig ReadVarSInt64(const GByte** ppabyPtr)
-{
- return DecodeSInt(ReadVarUInt64(ppabyPtr));
-}
-
-#define READ_VARSINT64(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = ReadVarSInt64(&pabyData); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-#define READ_VARSINT64_NOCHECK(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = ReadVarSInt64(&pabyData); \
- }
-
-/************************************************************************/
-/* ReadVarInt32() */
-/************************************************************************/
-
-inline int ReadVarInt32(const GByte** ppabyData)
-{
- /* If you use int32 or int64 as the type for a negative number, */
- /* the resulting varint is always ten bytes long */
- GIntBig nVal = static_cast<GIntBig>(ReadVarUInt64(ppabyData));
- return static_cast<int>(nVal);
-}
-
-#define READ_VARINT32(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = ReadVarInt32(&pabyData); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-#define READ_VARSINT32(pabyData, pabyDataLimit, nVal) \
- { \
- nVal = DecodeSInt(static_cast<GUInt32>(ReadVarUInt64(&pabyData))); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-/************************************************************************/
-/* ReadFloat32() */
-/************************************************************************/
-
-inline float ReadFloat32(const GByte** ppabyData, const GByte* pabyDataLimit)
-{
- if( *ppabyData + sizeof(float) > pabyDataLimit )
- THROW_GPB_EXCEPTION;
- float fValue;
- memcpy(&fValue, *ppabyData, sizeof(float));
- CPL_LSBPTR32(&fValue);
- *ppabyData += sizeof(float);
- return fValue;
-}
-
-/************************************************************************/
-/* ReadFloat64() */
-/************************************************************************/
-
-inline double ReadFloat64(const GByte** ppabyData, const GByte* pabyDataLimit)
-{
- if( *ppabyData + sizeof(double) > pabyDataLimit )
- THROW_GPB_EXCEPTION;
- double dfValue;
- memcpy(&dfValue, *ppabyData, sizeof(double));
- CPL_LSBPTR64(&dfValue);
- *ppabyData += sizeof(double);
- return dfValue;
-}
-
-/************************************************************************/
-/* SkipVarInt() */
-/************************************************************************/
-
-inline void SkipVarInt(const GByte** ppabyData)
-{
- const GByte* pabyData = *ppabyData;
- while(true)
- {
- int nByte = *pabyData;
- if (!(nByte & 0x80))
- {
- *ppabyData = pabyData + 1;
- return;
- }
- pabyData ++;
- }
-}
-
-#define SKIP_VARINT(pabyData, pabyDataLimit) \
- { \
- SkipVarInt(&pabyData); \
- if (CHECK_OOB && pabyData > pabyDataLimit) THROW_GPB_EXCEPTION; \
- }
-
-#define READ_FIELD_KEY(nKey) READ_VARINT32(pabyData, pabyDataLimit, nKey)
-
-#define READ_TEXT_WITH_SIZE(pabyData, pabyDataLimit, pszTxt, l_nDataLength) do { \
- READ_SIZE(pabyData, pabyDataLimit, l_nDataLength); \
- pszTxt = (char*)VSI_MALLOC_VERBOSE(l_nDataLength + 1); \
- if( pszTxt == nullptr ) THROW_GPB_EXCEPTION; \
- memcpy(pszTxt, pabyData, l_nDataLength); \
- pszTxt[l_nDataLength] = 0; \
- pabyData += l_nDataLength; } while(0)
-
-#define READ_TEXT(pabyData, pabyDataLimit, pszTxt) do { \
- unsigned int l_nDataLength; \
- READ_TEXT_WITH_SIZE(pabyData, pabyDataLimit, pszTxt, l_nDataLength); } while(0)
-
-/************************************************************************/
-/* SkipUnknownField() */
-/************************************************************************/
-
-#define SKIP_UNKNOWN_FIELD_INLINE(pabyData, pabyDataLimit, verbose) \
- int nWireType = GET_WIRETYPE(nKey); \
- if (verbose) \
- { \
- int nFieldNumber = GET_FIELDNUMBER(nKey); \
- CPLDebug("PBF", "Unhandled case: nFieldNumber = %d, nWireType = %d", nFieldNumber, nWireType); \
- } \
- switch (nWireType) \
- { \
- case WT_VARINT: \
- { \
- SKIP_VARINT(pabyData, pabyDataLimit); \
- break; \
- } \
- case WT_64BIT: \
- { \
- if (CHECK_OOB && pabyDataLimit - pabyData < 8) THROW_GPB_EXCEPTION; \
- pabyData += 8; \
- break; \
- } \
- case WT_DATA: \
- { \
- unsigned int nDataLength; \
- READ_SIZE(pabyData, pabyDataLimit, nDataLength); \
- pabyData += nDataLength; \
- break; \
- } \
- case WT_32BIT: \
- { \
- if (CHECK_OOB && pabyDataLimit - pabyData < 4) THROW_GPB_EXCEPTION; \
- pabyData += 4; \
- break; \
- } \
- default: \
- THROW_GPB_EXCEPTION; \
- }
-
-inline int SkipUnknownField(int nKey, const GByte* pabyData, const GByte* pabyDataLimit, int verbose)
-{
- const GByte* pabyDataBefore = pabyData;
- try
- {
- SKIP_UNKNOWN_FIELD_INLINE(pabyData, pabyDataLimit, verbose);
- return static_cast<int>(pabyData - pabyDataBefore);
- }
- catch( const GPBException& e )
- {
- if( verbose )
- {
- CPLError(CE_Failure, CPLE_AppDefined, "%s", e.what());
- }
- return -1;
- }
-}
-
-#define SKIP_UNKNOWN_FIELD(pabyData, pabyDataLimit, verbose) \
- { \
- int _nOffset = SkipUnknownField(nKey, pabyData, pabyDataLimit, verbose); \
- if (_nOffset < 0) \
- THROW_GPB_EXCEPTION; \
- pabyData += _nOffset; \
- }
-
-
-/************************************************************************/
-/* GetVarUIntSize() */
-/************************************************************************/
-
-inline int GetVarUIntSize(GUIntBig nVal)
-{
- int nBytes = 1;
- while( nVal > 127 )
- {
- nBytes ++;
- nVal >>= 7;
- }
- return nBytes;
-}
-
-/************************************************************************/
-/* EncodeSInt() */
-/************************************************************************/
-
-inline GUIntBig EncodeSInt(GIntBig nVal)
-{
- if( nVal < 0 )
- return (static_cast<GUIntBig>(-(nVal + 1)) << 1) | 1;
- else
- return static_cast<GUIntBig>(nVal) << 1;
-}
-
-inline GUInt32 EncodeSInt(GInt32 nVal)
-{
- if( nVal < 0 )
- return (static_cast<GUInt32>(-(nVal + 1)) << 1) | 1;
- else
- return static_cast<GUInt32>(nVal) << 1;
-}
-
-/************************************************************************/
-/* GetVarIntSize() */
-/************************************************************************/
-
-inline int GetVarIntSize(GIntBig nVal)
-{
- return GetVarUIntSize(static_cast<GUIntBig>(nVal));
-}
-
-/************************************************************************/
-/* GetVarSIntSize() */
-/************************************************************************/
-
-inline int GetVarSIntSize(GIntBig nVal)
-{
- return GetVarUIntSize(EncodeSInt(nVal));
-}
-
-/************************************************************************/
-/* WriteVarUInt() */
-/************************************************************************/
-
-inline void WriteVarUInt(GByte** ppabyData, GUIntBig nVal)
-{
- GByte* pabyData = *ppabyData;
- while( nVal > 127 )
- {
- *pabyData = static_cast<GByte>((nVal & 0x7f) | 0x80);
- pabyData ++;
- nVal >>= 7;
- }
- *pabyData = static_cast<GByte>(nVal);
- pabyData ++;
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* WriteVarUIntSingleByte() */
-/************************************************************************/
-
-inline void WriteVarUIntSingleByte(GByte** ppabyData, GUIntBig nVal)
-{
- GByte* pabyData = *ppabyData;
- CPLAssert( nVal < 128 );
- *pabyData = static_cast<GByte>(nVal);
- pabyData ++;
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* WriteVarInt() */
-/************************************************************************/
-
-inline void WriteVarInt(GByte** ppabyData, GIntBig nVal)
-{
- WriteVarUInt(ppabyData, static_cast<GUIntBig>(nVal));
-}
-
-/************************************************************************/
-/* WriteVarSInt() */
-/************************************************************************/
-
-inline void WriteVarSInt(GByte** ppabyData, GIntBig nVal)
-{
- WriteVarUInt(ppabyData, EncodeSInt(nVal) );
-}
-
-/************************************************************************/
-/* WriteFloat32() */
-/************************************************************************/
-
-inline void WriteFloat32(GByte** ppabyData, float fVal)
-{
- CPL_LSBPTR32(&fVal);
- memcpy(*ppabyData, &fVal, sizeof(float));
- *ppabyData += sizeof(float);
-}
-
-/************************************************************************/
-/* WriteFloat64() */
-/************************************************************************/
-
-inline void WriteFloat64(GByte** ppabyData, double dfVal)
-{
- CPL_LSBPTR64(&dfVal);
- memcpy(*ppabyData, &dfVal, sizeof(double));
- *ppabyData += sizeof(double);
-}
-
-/************************************************************************/
-/* GetTextSize() */
-/************************************************************************/
-
-inline int GetTextSize(const char* pszText)
-{
- size_t nTextSize = strlen(pszText);
- return GetVarUIntSize(nTextSize) + static_cast<int>(nTextSize);
-}
-
-inline int GetTextSize(const std::string& osText)
-{
- size_t nTextSize = osText.size();
- return GetVarUIntSize(nTextSize) + static_cast<int>(nTextSize);
-}
-
-/************************************************************************/
-/* WriteText() */
-/************************************************************************/
-
-inline void WriteText(GByte** ppabyData, const char* pszText)
-{
- size_t nTextSize = strlen(pszText);
- WriteVarUInt(ppabyData, nTextSize);
- memcpy(*ppabyData, pszText, nTextSize);
- *ppabyData += nTextSize;
-}
-
-inline void WriteText(GByte** ppabyData, const std::string& osText)
-{
- size_t nTextSize = osText.size();
- WriteVarUInt(ppabyData, nTextSize);
- memcpy(*ppabyData, osText.c_str(), nTextSize);
- *ppabyData += nTextSize;
-}
-
-
-#endif /* GPB_H_INCLUDED */
Deleted: branches/4.0/MgDev/Common/Renderers/mvt/mvt_port.h
===================================================================
--- branches/4.0/MgDev/Common/Renderers/mvt/mvt_port.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/mvt/mvt_port.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,298 +0,0 @@
-//
-// Copyright (C) 2004-2019 by Autodesk, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of version 2.1 of the GNU Lesser
-// General Public License as published by the Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-// Contains a minimal sub-set of cpl_port.h and other CPL headers
-/******************************************************************************
- * Copyright (c) 1998, 2005, Frank Warmerdam <warmerdam at pobox.com>
- * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ****************************************************************************/
-
-#ifndef MVT_PORT_H
-#define MVT_PORT_H
-
-#include <string.h>
-#include <limits.h>
-#include <assert.h>
-
-#if UINT_MAX == 65535
-typedef long GInt32;
-typedef unsigned long GUInt32;
-#else
-/** Int32 type */
-typedef int GInt32;
-/** Unsigned int32 type */
-typedef unsigned int GUInt32;
-#endif
-
-/** Large signed integer type (generally 64-bit integer type).
- * Use GInt64 when exactly 64 bit is needed */
-typedef long long GIntBig;
-
-/** Large unsigned integer type (generally 64-bit unsigned integer type).
- * Use GUInt64 when exactly 64 bit is needed */
-typedef unsigned long long GUIntBig;
-
-/** Signed 64 bit integer type */
-typedef GIntBig GInt64;
-/** Unsigned 64 bit integer type */
-typedef GUIntBig GUInt64;
-
-/** Unsigned byte type */
-typedef unsigned char GByte;
-
-#define VSI_MALLOC_VERBOSE malloc
-
-#define CPLMalloc malloc
-
-#define CPLFree free
-
-#define CPLAssert assert
-
-#define FALSE 0
-
-/* -------------------------------------------------------------------- */
-/* Handle isnan() and isinf(). Note that isinf() and isnan() */
-/* are supposed to be macros according to C99, defined in math.h */
-/* Some systems (i.e. Tru64) don't have isinf() at all, so if */
-/* the macro is not defined we just assume nothing is infinite. */
-/* This may mean we have no real CPLIsInf() on systems with isinf()*/
-/* function but no corresponding macro, but I can live with */
-/* that since it isn't that important a test. */
-/* -------------------------------------------------------------------- */
-#ifdef _MSC_VER
-# include <float.h>
-# define CPLIsNan(x) _isnan(x)
-# define CPLIsInf(x) (!_isnan(x) && !_finite(x))
-# define CPLIsFinite(x) _finite(x)
-#elif defined(__GNUC__) && ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) )
-/* When including <cmath> in C++11 the isnan() macro is undefined, so that */
-/* std::isnan() can work (#6489). This is a GCC specific workaround for now. */
-# define CPLIsNan(x) __builtin_isnan(x)
-# define CPLIsInf(x) __builtin_isinf(x)
-# define CPLIsFinite(x) __builtin_isfinite(x)
-#elif defined(__cplusplus) && defined(HAVE_STD_IS_NAN) && HAVE_STD_IS_NAN
-extern "C++" {
-#ifndef DOXYGEN_SKIP
-#include <cmath>
-#endif
- static inline int CPLIsNan(float f) { return std::isnan(f); }
- static inline int CPLIsNan(double f) { return std::isnan(f); }
- static inline int CPLIsInf(float f) { return std::isinf(f); }
- static inline int CPLIsInf(double f) { return std::isinf(f); }
- static inline int CPLIsFinite(float f) { return std::isfinite(f); }
- static inline int CPLIsFinite(double f) { return std::isfinite(f); }
-}
-#else
-/** Return whether a floating-pointer number is NaN */
-#if defined(__cplusplus) && defined(__GNUC__) && defined(__linux) && !defined(__ANDROID__) && !defined(CPL_SUPRESS_CPLUSPLUS)
-/* so to not get warning about conversion from double to float with */
-/* gcc -Wfloat-conversion when using isnan()/isinf() macros */
-extern "C++" {
- static inline int CPLIsNan(float f) { return __isnanf(f); }
- static inline int CPLIsNan(double f) { return __isnan(f); }
- static inline int CPLIsInf(float f) { return __isinff(f); }
- static inline int CPLIsInf(double f) { return __isinf(f); }
- static inline int CPLIsFinite(float f) { return !__isnanf(f) && !__isinff(f); }
- static inline int CPLIsFinite(double f) { return !__isnan(f) && !__isinf(f); }
-}
-#else
-# define CPLIsNan(x) isnan(x)
-# if defined(isinf) || defined(__FreeBSD__)
-/** Return whether a floating-pointer number is +/- infinty */
-# define CPLIsInf(x) isinf(x)
-/** Return whether a floating-pointer number is finite */
-# define CPLIsFinite(x) (!isnan(x) && !isinf(x))
-# elif defined(__sun__)
-# include <ieeefp.h>
-# define CPLIsInf(x) (!finite(x) && !isnan(x))
-# define CPLIsFinite(x) finite(x)
-# else
-# define CPLIsInf(x) (0)
-# define CPLIsFinite(x) (!isnan(x))
-# endif
-#endif
-#endif
-
-#define CPL_STATIC_ASSERT_IF_AVAILABLE(x)
-
-/*---------------------------------------------------------------------
- * Little endian <==> big endian byte swap macros.
- *--------------------------------------------------------------------*/
-
- /** Byte-swap a 16bit unsigned integer */
-#define CPL_SWAP16(x) CPL_STATIC_CAST(GUInt16, (CPL_STATIC_CAST(GUInt16, x) << 8) | (CPL_STATIC_CAST(GUInt16, x) >> 8) )
-
-#if defined(HAVE_GCC_BSWAP) && (defined(__i386__) || defined(__x86_64__))
-/* Could potentially be extended to other architectures but must be checked */
-/* that the intrinsic is indeed efficient */
-/* GCC (at least 4.6 or above) need that include */
-#include <x86intrin.h>
-/** Byte-swap a 32bit unsigned integer */
-#define CPL_SWAP32(x) CPL_STATIC_CAST(GUInt32, __builtin_bswap32(CPL_STATIC_CAST(GUInt32, x)))
-/** Byte-swap a 64bit unsigned integer */
-#define CPL_SWAP64(x) CPL_STATIC_CAST(GUInt64, __builtin_bswap64(CPL_STATIC_CAST(GUInt64, x)))
-#elif defined(_MSC_VER)
-#define CPL_SWAP32(x) CPL_STATIC_CAST(GUInt32, _byteswap_ulong(CPL_STATIC_CAST(GUInt32, x)))
-#define CPL_SWAP64(x) CPL_STATIC_CAST(GUInt64, _byteswap_uint64(CPL_STATIC_CAST(GUInt64, x)))
-#else
-/** Byte-swap a 32bit unsigned integer */
-#define CPL_SWAP32(x) \
- CPL_STATIC_CAST(GUInt32, \
- ((CPL_STATIC_CAST(GUInt32, x) & 0x000000ffU) << 24) | \
- ((CPL_STATIC_CAST(GUInt32, x) & 0x0000ff00U) << 8) | \
- ((CPL_STATIC_CAST(GUInt32, x) & 0x00ff0000U) >> 8) | \
- ((CPL_STATIC_CAST(GUInt32, x) & 0xff000000U) >> 24) )
-
-/** Byte-swap a 64bit unsigned integer */
-#define CPL_SWAP64(x) \
- ((CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, x))) << 32) | \
- (CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, CPL_STATIC_CAST(GUInt64, x) >> 32)))))
-
-#endif
-
-/** Byte-swap a 16 bit pointer */
-#define CPL_SWAP16PTR(x) \
-{ \
- GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
- CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2); \
- \
- byTemp = _pabyDataT[0]; \
- _pabyDataT[0] = _pabyDataT[1]; \
- _pabyDataT[1] = byTemp; \
-}
-
-#if defined(MAKE_SANITIZE_HAPPY) || !(defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64))
-
-/** Byte-swap a 32 bit pointer */
-#define CPL_SWAP32PTR(x) \
-{ \
- GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
- CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
- \
- byTemp = _pabyDataT[0]; \
- _pabyDataT[0] = _pabyDataT[3]; \
- _pabyDataT[3] = byTemp; \
- byTemp = _pabyDataT[1]; \
- _pabyDataT[1] = _pabyDataT[2]; \
- _pabyDataT[2] = byTemp; \
-}
-
-/** Byte-swap a 64 bit pointer */
-#define CPL_SWAP64PTR(x) \
-{ \
- GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
- CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
- \
- byTemp = _pabyDataT[0]; \
- _pabyDataT[0] = _pabyDataT[7]; \
- _pabyDataT[7] = byTemp; \
- byTemp = _pabyDataT[1]; \
- _pabyDataT[1] = _pabyDataT[6]; \
- _pabyDataT[6] = byTemp; \
- byTemp = _pabyDataT[2]; \
- _pabyDataT[2] = _pabyDataT[5]; \
- _pabyDataT[5] = byTemp; \
- byTemp = _pabyDataT[3]; \
- _pabyDataT[3] = _pabyDataT[4]; \
- _pabyDataT[4] = byTemp; \
-}
-
-#else
-
-/** Byte-swap a 32 bit pointer */
-#define CPL_SWAP32PTR(x) \
-{ \
- GUInt32 _n32; \
- void* _lx = x; \
- memcpy(&_n32, _lx, 4); \
- CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
- _n32 = CPL_SWAP32(_n32); \
- memcpy(_lx, &_n32, 4); \
-}
-
-/** Byte-swap a 64 bit pointer */
-#define CPL_SWAP64PTR(x) \
-{ \
- GUInt64 _n64; \
- void* _lx = x; \
- memcpy(&_n64, _lx, 8); \
- CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
- _n64 = CPL_SWAP64(_n64); \
- memcpy(_lx, &_n64, 8); \
-}
-
-#endif
-
-/** Byte-swap a 64 bit pointer */
-#define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
-
-#ifdef CPL_MSB
-# define CPL_MSBWORD16(x) (x)
-# define CPL_LSBWORD16(x) CPL_SWAP16(x)
-# define CPL_MSBWORD32(x) (x)
-# define CPL_LSBWORD32(x) CPL_SWAP32(x)
-# define CPL_MSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
-# define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
-# define CPL_MSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
-# define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
-# define CPL_MSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
-# define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
-#else
-/** Return a 16bit word from a originally LSB ordered word */
-# define CPL_LSBWORD16(x) (x)
-/** Return a 16bit word from a originally MSB ordered word */
-# define CPL_MSBWORD16(x) CPL_SWAP16(x)
-/** Return a 32bit word from a originally LSB ordered word */
-# define CPL_LSBWORD32(x) (x)
-/** Return a 32bit word from a originally MSB ordered word */
-# define CPL_MSBWORD32(x) CPL_SWAP32(x)
-/** Byte-swap if necessary a 16bit word at the location pointed from a originally LSB ordered pointer */
-# define CPL_LSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
-/** Byte-swap if necessary a 16bit word at the location pointed from a originally MSB ordered pointer */
-# define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
-/** Byte-swap if necessary a 32bit word at the location pointed from a originally LSB ordered pointer */
-# define CPL_LSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
-/** Byte-swap if necessary a 32bit word at the location pointed from a originally MSB ordered pointer */
-# define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
-/** Byte-swap if necessary a 64bit word at the location pointed from a originally LSB ordered pointer */
-# define CPL_LSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
-/** Byte-swap if necessary a 64bit word at the location pointed from a originally MSB ordered pointer */
-# define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
-#endif
-
-#define CPLError(a, b, c, d)
-
-#define CPLDebug(a, b, c, d)
-
-#endif
\ No newline at end of file
Deleted: branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.cpp
===================================================================
--- branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,928 +0,0 @@
-/******************************************************************************
- *
- * Project: MVT Translator
- * Purpose: Mapbox Vector Tile decoder and encoder
- * Author: Even Rouault, Even Rouault <even dot rouault at spatialys dot com>
- *
- ******************************************************************************
- * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ****************************************************************************/
-
-#include "gpb.h"
-
-#include <limits>
-#include <memory>
-#include <vector>
-
-#include "mvt_tile.h"
-
-constexpr int knSIZE_KEY = 1;
-
-/************************************************************************/
-/* MVTTileLayerValue() */
-/************************************************************************/
-
-MVTTileLayerValue::MVTTileLayerValue(): m_nUIntValue(0)
-{
-}
-
-MVTTileLayerValue::MVTTileLayerValue(const MVTTileLayerValue& oOther)
-{
- operator=(oOther);
-}
-
-/************************************************************************/
-/* ~MVTTileLayerValue() */
-/************************************************************************/
-
-MVTTileLayerValue::~MVTTileLayerValue()
-{
- unset();
-}
-
-/************************************************************************/
-/* operator= */
-/************************************************************************/
-
-MVTTileLayerValue& MVTTileLayerValue::operator=(
- const MVTTileLayerValue& oOther)
-
-{
- if( this != &oOther )
- {
- unset();
- m_eType = oOther.m_eType;
- if( m_eType == ValueType::STRING )
- {
- const size_t nSize = strlen(oOther.m_pszValue);
- m_pszValue = static_cast<char*>(CPLMalloc(1 + nSize));
- memcpy(m_pszValue, oOther.m_pszValue, nSize);
- m_pszValue[nSize] = 0;
- }
- else
- {
- m_nUIntValue = oOther.m_nUIntValue;
- }
- }
- return *this;
-}
-
-/************************************************************************/
-/* operator< */
-/************************************************************************/
-
-bool MVTTileLayerValue::operator <(const MVTTileLayerValue& rhs) const
-{
- if( m_eType < rhs.m_eType )
- return false;
- if( m_eType > rhs.m_eType )
- return true;
- if( m_eType == ValueType::NONE )
- return false;
- if( m_eType == ValueType::STRING )
- return strcmp( m_pszValue, rhs.m_pszValue ) < 0;
- if( m_eType == ValueType::FLOAT )
- return m_fValue < rhs.m_fValue;
- if( m_eType == ValueType::DOUBLE )
- return m_dfValue < rhs.m_dfValue;
- if( m_eType == ValueType::INT )
- return m_nIntValue < rhs.m_nIntValue;
- if( m_eType == ValueType::UINT )
- return m_nUIntValue < rhs.m_nUIntValue;
- if( m_eType == ValueType::SINT )
- return m_nIntValue < rhs.m_nIntValue;
- if( m_eType == ValueType::BOOL )
- return m_bBoolValue < rhs.m_bBoolValue;
- if( m_eType == ValueType::STRING_MAX_8 )
- return strncmp( m_achValue, rhs.m_achValue, 8 ) < 0;
- CPLAssert(false);
- return false;
-}
-
-/************************************************************************/
-/* unset() */
-/************************************************************************/
-
-void MVTTileLayerValue::unset()
-{
- if( m_eType == ValueType::STRING )
- CPLFree(m_pszValue);
- m_eType = ValueType::NONE;
- m_nUIntValue = 0;
-}
-
-/************************************************************************/
-/* GetSizeMax8() */
-/************************************************************************/
-
-static size_t GetSizeMax8(const char achValue[8])
-{
- size_t nSize = 0;
- while( nSize < 8 && achValue[nSize] != 0 )
- nSize ++;
- return nSize;
-}
-
-/************************************************************************/
-/* setStringValue() */
-/************************************************************************/
-
-void MVTTileLayerValue::setStringValue(const std::string& osValue)
-{
- unset();
- const size_t nSize = osValue.size();
- if( nSize <= 8 )
- {
- m_eType = ValueType::STRING_MAX_8;
- if( nSize )
- memcpy( m_achValue, osValue.c_str(), nSize );
- if( nSize < 8 )
- m_achValue[nSize] = 0;
- }
- else
- {
- m_eType = ValueType::STRING;
- m_pszValue = static_cast<char*>(CPLMalloc(1 + nSize));
- memcpy(m_pszValue, osValue.c_str(), nSize);
- m_pszValue[nSize] = 0;
- }
-}
-
-/************************************************************************/
-/* setValue() */
-/************************************************************************/
-
-void MVTTileLayerValue::setValue(double dfVal)
-{
- if( dfVal >= 0 &&
- dfVal <= static_cast<double>(std::numeric_limits<GUInt64>::max()) &&
- dfVal == static_cast<double>(static_cast<GUInt64>(dfVal)) )
- {
- setUIntValue(static_cast<GUInt64>(dfVal));
- }
- else if( dfVal >= static_cast<double>(
- std::numeric_limits<GInt64>::min()) &&
- dfVal < 0 &&
- dfVal == static_cast<double>(static_cast<GInt64>(dfVal)) )
- {
- setSIntValue(static_cast<GInt64>(dfVal));
- }
- else if( !CPLIsFinite(dfVal) ||
- (dfVal >= -std::numeric_limits<float>::max() &&
- dfVal <= std::numeric_limits<float>::max() &&
- dfVal == static_cast<float>(dfVal)) )
- {
- setFloatValue( static_cast<float>(dfVal) );
- }
- else
- {
- setDoubleValue( dfVal );
- }
-}
-
-/************************************************************************/
-/* getSize() */
-/************************************************************************/
-
-size_t MVTTileLayerValue::getSize() const
-{
- switch( m_eType )
- {
- case ValueType::NONE: return 0;
- case ValueType::STRING:
- {
- const size_t nSize = strlen(m_pszValue);
- return knSIZE_KEY + GetVarUIntSize(nSize) + nSize;
- }
- case ValueType::STRING_MAX_8:
- {
- const size_t nSize = GetSizeMax8(m_achValue);
- return knSIZE_KEY + GetVarUIntSize(nSize) + nSize;
- }
- case ValueType::FLOAT: return knSIZE_KEY + sizeof(float);
- case ValueType::DOUBLE: return knSIZE_KEY + sizeof(double);
- case ValueType::INT: return knSIZE_KEY + GetVarIntSize(m_nIntValue);
- case ValueType::UINT: return knSIZE_KEY + GetVarUIntSize(m_nUIntValue);
- case ValueType::SINT: return knSIZE_KEY + GetVarSIntSize(m_nIntValue);
- case ValueType::BOOL: return knSIZE_KEY + 1;
- default: return 0;
- }
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-void MVTTileLayerValue::write(GByte** ppabyData) const
-{
- GByte* pabyData = *ppabyData;
-
- switch( m_eType )
- {
- case ValueType::STRING:
- {
- const size_t nSize = strlen(m_pszValue);
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_STRING, WT_DATA));
- WriteVarUInt(&pabyData, nSize);
- memcpy(pabyData, m_pszValue, nSize);
- pabyData += nSize;
- break;
- }
-
- case ValueType::STRING_MAX_8:
- {
- const size_t nSize = GetSizeMax8(m_achValue);
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_STRING, WT_DATA));
- WriteVarUInt(&pabyData, nSize);
- if( nSize )
- memcpy(pabyData, m_achValue, nSize);
- pabyData += nSize;
- break;
- }
-
- case ValueType::FLOAT:
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_FLOAT, WT_32BIT));
- WriteFloat32(&pabyData, m_fValue);
- break;
-
- case ValueType::DOUBLE:
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_DOUBLE, WT_64BIT));
- WriteFloat64(&pabyData, m_dfValue);
- break;
-
- case ValueType::INT:
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_INT, WT_VARINT));
- WriteVarInt(&pabyData, m_nIntValue);
- break;
-
- case ValueType::UINT:
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_UINT, WT_VARINT));
- WriteVarUInt(&pabyData, m_nUIntValue);
- break;
-
- case ValueType::SINT:
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_SINT, WT_VARINT));
- WriteVarSInt(&pabyData, m_nIntValue);
- break;
-
- case ValueType::BOOL:
- WriteVarUIntSingleByte(&pabyData,
- MAKE_KEY(knVALUE_BOOL, WT_VARINT));
- WriteVarUIntSingleByte(&pabyData, m_bBoolValue ? 1 : 0);
- break;
-
- default:
- break;
- }
-
- CPLAssert(pabyData == *ppabyData + getSize());
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* read() */
-/************************************************************************/
-
-bool MVTTileLayerValue::read(const GByte** ppabyData, const GByte* pabyDataLimit)
-{
- const GByte* pabyData = *ppabyData;
-
- try
- {
- unsigned int nKey = 0;
- if( pabyData < pabyDataLimit )
- {
- READ_FIELD_KEY(nKey);
-
- if( nKey == MAKE_KEY(knVALUE_STRING, WT_DATA) )
- {
- char* pszValue = nullptr;
- READ_TEXT(pabyData, pabyDataLimit, pszValue);
- // cppcheck-suppress nullPointer
- setStringValue(pszValue);
- CPLFree(pszValue);
- }
- else if( nKey == MAKE_KEY(knVALUE_FLOAT, WT_32BIT) )
- {
- setFloatValue(ReadFloat32(&pabyData, pabyDataLimit));
- }
- else if( nKey == MAKE_KEY(knVALUE_DOUBLE, WT_64BIT) )
- {
- setDoubleValue(ReadFloat64(&pabyData, pabyDataLimit));
- }
- else if( nKey == MAKE_KEY(knVALUE_INT, WT_VARINT) )
- {
- GIntBig nVal = 0;
- READ_VARINT64(pabyData, pabyDataLimit, nVal);
- setIntValue(nVal);
- }
- else if( nKey == MAKE_KEY(knVALUE_UINT, WT_VARINT) )
- {
- GUIntBig nVal = 0;
- READ_VARUINT64(pabyData, pabyDataLimit, nVal);
- setUIntValue(nVal);
- }
- else if( nKey == MAKE_KEY(knVALUE_SINT, WT_VARINT) )
- {
- GIntBig nVal = 0;
- READ_VARSINT64(pabyData, pabyDataLimit, nVal);
- setSIntValue(nVal);
- }
- else if( nKey == MAKE_KEY(knVALUE_BOOL, WT_VARINT) )
- {
- unsigned nVal = 0;
- READ_VARUINT32(pabyData, pabyDataLimit, nVal);
- setBoolValue(nVal != 0);
- }
- }
- *ppabyData = pabyData;
- return true;
- }
- catch( const GPBException& )
- {
- return false;
- }
-}
-
-/************************************************************************/
-/* MVTTileLayer() */
-/************************************************************************/
-
-MVTTileLayerFeature::MVTTileLayerFeature()
-{
-}
-
-/************************************************************************/
-/* setOwner() */
-/************************************************************************/
-
-void MVTTileLayerFeature::setOwner(MVTTileLayer* poOwner)
-{
- CPLAssert( !m_poOwner );
- m_poOwner = poOwner;
- m_poOwner->invalidateCachedSize();
-}
-
-/************************************************************************/
-/* invalidateCachedSize() */
-/************************************************************************/
-
-void MVTTileLayerFeature::invalidateCachedSize()
-{
- m_bCachedSize = false;
- m_nCachedSize = 0;
- if( m_poOwner )
- m_poOwner->invalidateCachedSize();
-}
-
-/************************************************************************/
-/* GetPackedArraySize() */
-/************************************************************************/
-
-static size_t GetPackedArraySize(const std::vector<GUInt32>& anVals)
-{
- size_t nPackedSize = 0;
- for( const auto& nVal: anVals )
- {
- nPackedSize += GetVarUIntSize(nVal);
- }
- return nPackedSize;
-}
-
-/************************************************************************/
-/* getSize() */
-/************************************************************************/
-
-size_t MVTTileLayerFeature::getSize() const
-{
- if( m_bCachedSize )
- return m_nCachedSize;
- m_bCachedSize = true;
- m_nCachedSize = 0;
- if( m_bHasId )
- m_nCachedSize += knSIZE_KEY + GetVarUIntSize(m_nId);
- if( !m_anTags.empty() )
- {
- size_t nPackedSize = GetPackedArraySize(m_anTags);
- m_nCachedSize += knSIZE_KEY;
- m_nCachedSize += GetVarUIntSize(nPackedSize);
- m_nCachedSize += nPackedSize;
- }
- if( m_bHasType )
- m_nCachedSize += knSIZE_KEY + 1; // fixed size for m_eType
- if( !m_anGeometry.empty() )
- {
- size_t nPackedSize = GetPackedArraySize(m_anGeometry);
- m_nCachedSize += knSIZE_KEY;
- m_nCachedSize += GetVarUIntSize(nPackedSize);
- m_nCachedSize += nPackedSize;
- }
- return m_nCachedSize;
-}
-
-/************************************************************************/
-/* WriteUIntPackedArray() */
-/************************************************************************/
-
-static void WriteUIntPackedArray(GByte** ppabyData, int nKey,
- const std::vector<GUInt32>& anVals)
-{
- GByte* pabyData = *ppabyData;
- const size_t nPackedSize = GetPackedArraySize(anVals);
- WriteVarUIntSingleByte(&pabyData, nKey);
- WriteVarUInt(&pabyData, nPackedSize);
- for( const auto& nVal: anVals )
- {
- WriteVarUInt(&pabyData, nVal);
- }
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-void MVTTileLayerFeature::write(GByte** ppabyData) const
-{
- GByte* pabyData = *ppabyData;
-
- if( m_bHasId )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knFEATURE_ID, WT_VARINT));
- WriteVarUInt(&pabyData, m_nId);
- }
- if( !m_anTags.empty() )
- {
- WriteUIntPackedArray(&pabyData, MAKE_KEY(knFEATURE_TAGS, WT_DATA),
- m_anTags);
- }
- if( m_bHasType )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knFEATURE_TYPE, WT_VARINT));
- WriteVarUIntSingleByte(&pabyData, static_cast<GUIntBig>(m_eType));
- }
- if( !m_anGeometry.empty() )
- {
- WriteUIntPackedArray(&pabyData, MAKE_KEY(knFEATURE_GEOMETRY, WT_DATA),
- m_anGeometry);
- }
-
- CPLAssert(pabyData == *ppabyData + getSize());
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* read() */
-/************************************************************************/
-
-bool MVTTileLayerFeature::read(const GByte** ppabyData,
- const GByte* pabyDataLimit)
-{
- const GByte* pabyData = *ppabyData;
-
- try
- {
- unsigned int nKey = 0;
- while( pabyData < pabyDataLimit )
- {
- READ_FIELD_KEY(nKey);
- if( nKey == MAKE_KEY(knFEATURE_ID, WT_VARINT) )
- {
- GUIntBig nID = 0;
- READ_VARUINT64(pabyData, pabyDataLimit, nID);
- setId(nID);
- }
- else if( nKey == MAKE_KEY(knFEATURE_TAGS, WT_DATA) )
- {
- unsigned int nTagsSize = 0;
- READ_SIZE(pabyData, pabyDataLimit, nTagsSize);
- const GByte* pabyDataTagsEnd = pabyData + nTagsSize;
- while( pabyData < pabyDataTagsEnd )
- {
- unsigned int nTag = 0;
- READ_VARUINT32(pabyData, pabyDataTagsEnd, nTag);
- addTag(nTag);
- }
- pabyData = pabyDataTagsEnd;
- }
- else if( nKey == MAKE_KEY(knFEATURE_TYPE, WT_VARINT) )
- {
- unsigned int nType = 0;
- READ_VARUINT32(pabyData, pabyDataLimit, nType);
- if( nType <= knGEOM_TYPE_POLYGON )
- setType(static_cast<GeomType>(nType));
- }
- else if( nKey == MAKE_KEY(knFEATURE_GEOMETRY, WT_DATA) )
- {
- unsigned int nGeometrySize = 0;
- READ_SIZE(pabyData, pabyDataLimit, nGeometrySize);
- const GByte* pabyDataGeometryEnd = pabyData + nGeometrySize;
- while( pabyData < pabyDataGeometryEnd )
- {
- unsigned int nGeometry = 0;
- READ_VARUINT32(pabyData, pabyDataGeometryEnd, nGeometry);
- addGeometry(nGeometry);
- }
- pabyData = pabyDataGeometryEnd;
- }
- else
- {
- SKIP_UNKNOWN_FIELD(pabyData, pabyDataLimit, FALSE);
- }
- }
- *ppabyData = pabyData;
- return true;
- }
- catch( const GPBException& )
- {
- return false;
- }
-}
-
-/************************************************************************/
-/* MVTTileLayer() */
-/************************************************************************/
-
-MVTTileLayer::MVTTileLayer()
-{
-}
-
-/************************************************************************/
-/* setOwner() */
-/************************************************************************/
-
-void MVTTileLayer::setOwner(MVTTile* poOwner)
-{
- CPLAssert( !m_poOwner );
- m_poOwner = poOwner;
- m_poOwner->invalidateCachedSize();
-}
-
-/************************************************************************/
-/* invalidateCachedSize() */
-/************************************************************************/
-
-void MVTTileLayer::invalidateCachedSize()
-{
- m_bCachedSize = false;
- m_nCachedSize = 0;
- if( m_poOwner )
- m_poOwner->invalidateCachedSize();
-}
-
-/************************************************************************/
-/* addFeature() */
-/************************************************************************/
-
-size_t MVTTileLayer::addFeature(std::shared_ptr<MVTTileLayerFeature> poFeature)
-{
- poFeature->setOwner(this);
- m_apoFeatures.push_back(poFeature);
- invalidateCachedSize();
- return m_apoFeatures.size() - 1;
-}
-
-/************************************************************************/
-/* getSize() */
-/************************************************************************/
-
-size_t MVTTileLayer::getSize() const
-{
- if( m_bCachedSize )
- return m_nCachedSize;
- m_nCachedSize = knSIZE_KEY + GetTextSize(m_osName);
- for( const auto& poFeature: m_apoFeatures )
- {
- const size_t nFeatureSize = poFeature->getSize();
- m_nCachedSize += knSIZE_KEY +
- GetVarUIntSize(nFeatureSize) + nFeatureSize;
- }
- for( const auto& osKey: m_aosKeys )
- {
- m_nCachedSize += knSIZE_KEY + GetTextSize(osKey);
- }
- for( const auto& oValue: m_aoValues )
- {
- const size_t nValueSize = oValue.getSize();
- m_nCachedSize += knSIZE_KEY + GetVarUIntSize(nValueSize) + nValueSize;
- }
- if( m_bHasExtent )
- {
- m_nCachedSize += knSIZE_KEY + GetVarUIntSize(m_nExtent);
- }
- m_nCachedSize += knSIZE_KEY + GetVarUIntSize(m_nVersion);
- m_bCachedSize = true;
- return m_nCachedSize;
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-void MVTTileLayer::write(GByte** ppabyData) const
-{
- GByte* pabyData = *ppabyData;
-
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER_NAME, WT_DATA));
- WriteText(&pabyData, m_osName);
-
- for( const auto& poFeature: m_apoFeatures )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER_FEATURES, WT_DATA));
- WriteVarUInt(&pabyData, poFeature->getSize());
- poFeature->write(&pabyData);
- }
-
- for( const auto& osKey: m_aosKeys )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER_KEYS, WT_DATA));
- WriteText(&pabyData, osKey);
- }
-
- for( const auto& oValue: m_aoValues )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER_VALUES, WT_DATA));
- WriteVarUInt(&pabyData, oValue.getSize());
- oValue.write(&pabyData);
- }
-
- if( m_bHasExtent )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER_EXTENT, WT_VARINT));
- WriteVarUInt(&pabyData, m_nExtent);
- }
-
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER_VERSION, WT_VARINT));
- WriteVarUInt(&pabyData, m_nVersion);
-
- CPLAssert(pabyData == *ppabyData + getSize());
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-void MVTTileLayer::write(GByte* pabyData) const
-{
- write(&pabyData);
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-std::string MVTTileLayer::write() const
-{
- std::string buffer;
- size_t nSize = getSize();
- buffer.resize(nSize);
- write( reinterpret_cast<GByte*>(&buffer[0]) );
- return buffer;
-}
-
-/************************************************************************/
-/* read() */
-/************************************************************************/
-
-bool MVTTileLayer::read(const GByte** ppabyData, const GByte* pabyDataLimit)
-{
- const GByte* pabyData = *ppabyData;
-
- try
- {
- unsigned int nKey = 0;
- while( pabyData < pabyDataLimit )
- {
- READ_FIELD_KEY(nKey);
- if( nKey == MAKE_KEY(knLAYER_NAME, WT_DATA) )
- {
- char* pszLayerName = nullptr;
- READ_TEXT(pabyData, pabyDataLimit, pszLayerName);
- // cppcheck-suppress nullPointer
- setName(pszLayerName);
- CPLFree(pszLayerName);
- }
- else if( nKey == MAKE_KEY(knLAYER_FEATURES, WT_DATA) )
- {
- unsigned int nFeatureLength = 0;
- READ_SIZE(pabyData, pabyDataLimit, nFeatureLength);
- const GByte* pabyDataFeatureEnd = pabyData + nFeatureLength;
- std::shared_ptr<MVTTileLayerFeature> poFeature(
- new MVTTileLayerFeature());
- addFeature(poFeature);
- if( !poFeature->read(&pabyData, pabyDataFeatureEnd) )
- return false;
- pabyData = pabyDataFeatureEnd;
- }
- else if( nKey == MAKE_KEY(knLAYER_KEYS, WT_DATA) )
- {
- char* pszKey = nullptr;
- READ_TEXT(pabyData, pabyDataLimit, pszKey);
- // cppcheck-suppress nullPointer
- addKey(pszKey);
- CPLFree(pszKey);
- }
- else if( nKey == MAKE_KEY(knLAYER_VALUES, WT_DATA) )
- {
- unsigned int nValueLength = 0;
- READ_SIZE(pabyData, pabyDataLimit, nValueLength);
- const GByte* pabyDataValueEnd = pabyData + nValueLength;
- MVTTileLayerValue oValue;
- if( !oValue.read(&pabyData, pabyDataValueEnd) )
- return false;
- addValue(oValue);
- pabyData = pabyDataValueEnd;
- }
- else if( nKey == MAKE_KEY(knLAYER_EXTENT, WT_VARINT) )
- {
- unsigned int nExtent = 0;
- READ_VARUINT32(pabyData, pabyDataLimit, nExtent);
- setExtent(nExtent);
- }
- else if( nKey == MAKE_KEY(knLAYER_VERSION, WT_VARINT) )
- {
- unsigned int nVersion = 0;
- READ_VARUINT32(pabyData, pabyDataLimit, nVersion);
- setVersion(nVersion);
- }
- else
- {
- SKIP_UNKNOWN_FIELD(pabyData, pabyDataLimit, FALSE);
- }
- }
- *ppabyData = pabyData;
- return true;
- }
- catch( const GPBException& )
- {
- return false;
- }
-}
-
-/************************************************************************/
-/* read() */
-/************************************************************************/
-
-bool MVTTileLayer::read(const GByte* pabyData, const GByte* pabyEnd)
-{
- return read(&pabyData, pabyEnd);
-}
-
-/************************************************************************/
-/* MVTTile() */
-/************************************************************************/
-
-MVTTile::MVTTile()
-{
-}
-
-/************************************************************************/
-/* addLayer() */
-/************************************************************************/
-
-void MVTTile::addLayer(std::shared_ptr<MVTTileLayer> poLayer)
-{
- poLayer->setOwner(this);
- invalidateCachedSize();
- m_apoLayers.push_back(poLayer);
-}
-
-/************************************************************************/
-/* getSize() */
-/************************************************************************/
-
-size_t MVTTile::getSize() const
-{
- if( m_bCachedSize )
- return m_nCachedSize;
- m_nCachedSize = 0;
- for( const auto& poLayer: m_apoLayers )
- {
- const size_t nLayerSize = poLayer->getSize();
- m_nCachedSize += knSIZE_KEY + GetVarUIntSize(nLayerSize) + nLayerSize;
- }
- m_bCachedSize = true;
- return m_nCachedSize;
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-void MVTTile::write(GByte** ppabyData) const
-{
- GByte* pabyData = *ppabyData;
-
- for( const auto& poLayer: m_apoLayers )
- {
- WriteVarUIntSingleByte(&pabyData, MAKE_KEY(knLAYER, WT_DATA));
- WriteVarUInt(&pabyData, poLayer->getSize());
- poLayer->write(&pabyData);
- }
-
- CPLAssert(pabyData == *ppabyData + getSize());
- *ppabyData = pabyData;
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-void MVTTile::write(GByte* pabyData) const
-{
- write(&pabyData);
-}
-
-/************************************************************************/
-/* write() */
-/************************************************************************/
-
-std::string MVTTile::write() const
-{
- std::string buffer;
- size_t nSize = getSize();
- if( nSize )
- {
- buffer.resize(nSize);
- write( reinterpret_cast<GByte*>(&buffer[0]) );
- }
- return buffer;
-}
-
-#ifdef ADD_MVT_TILE_READ
-
-/************************************************************************/
-/* read() */
-/************************************************************************/
-
-bool MVTTile::read(const GByte** ppabyData, const GByte* pabyDataLimit)
-{
- const GByte* pabyData = *ppabyData;
-
- try
- {
- unsigned int nKey = 0;
- while( pabyData < pabyDataLimit )
- {
- READ_FIELD_KEY(nKey);
- if( nKey == MAKE_KEY(knLAYER, WT_DATA) )
- {
- unsigned int nLayerSize = 0;
- READ_SIZE(pabyData, pabyDataLimit, nLayerSize);
- const GByte* pabyDataLimitLayer = pabyData + nLayerSize;
- std::shared_ptr<MVTTileLayer> poLayer(new MVTTileLayer());
- addLayer(poLayer);
- if( !poLayer->read(&pabyData, pabyDataLimitLayer) )
- return false;
- pabyData = pabyDataLimitLayer;
- }
- else
- {
- SKIP_UNKNOWN_FIELD(pabyData, pabyDataLimit, FALSE);
- }
- }
- *ppabyData = pabyData;
- return true;
- }
- catch( const GPBException& )
- {
- return false;
- }
-}
-
-/************************************************************************/
-/* read() */
-/************************************************************************/
-
-bool MVTTile::read(const GByte* pabyData, const GByte* pabyEnd)
-{
- return read(&pabyData, pabyEnd);
-}
-
-#endif
Deleted: branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.h
===================================================================
--- branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Common/Renderers/mvt/mvt_tile.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,356 +0,0 @@
-/******************************************************************************
- *
- * Project: MVT Translator
- * Purpose: Mapbox Vector Tile decoder and encoder
- * Author: Even Rouault, Even Rouault <even dot rouault at spatialys dot com>
- *
- ******************************************************************************
- * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ****************************************************************************/
-
-#ifndef MVT_TILE_H
-#define MVT_TILE_H
-
-#define ADD_MVT_TILE_READ
-#include "mvt_port.h"
-
-#include <memory>
-#include <vector>
-
-/* See https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto */
-constexpr int knLAYER = 3;
-
-constexpr int knLAYER_NAME = 1;
-constexpr int knLAYER_FEATURES = 2;
-constexpr int knLAYER_KEYS = 3;
-constexpr int knLAYER_VALUES = 4;
-constexpr int knLAYER_EXTENT = 5;
-constexpr int knLAYER_VERSION = 15;
-
-constexpr int knVALUE_STRING = 1;
-constexpr int knVALUE_FLOAT = 2;
-constexpr int knVALUE_DOUBLE = 3;
-constexpr int knVALUE_INT = 4;
-constexpr int knVALUE_UINT = 5;
-constexpr int knVALUE_SINT = 6;
-constexpr int knVALUE_BOOL = 7;
-
-constexpr int knFEATURE_ID = 1;
-constexpr int knFEATURE_TAGS = 2;
-constexpr int knFEATURE_TYPE = 3;
-constexpr int knFEATURE_GEOMETRY = 4;
-
-constexpr int knGEOM_TYPE_UNKNOWN = 0;
-constexpr int knGEOM_TYPE_POINT = 1;
-constexpr int knGEOM_TYPE_LINESTRING = 2;
-constexpr int knGEOM_TYPE_POLYGON = 3;
-
-constexpr int knCMD_MOVETO = 1;
-constexpr int knCMD_LINETO = 2;
-constexpr int knCMD_CLOSEPATH = 7;
-
-constexpr unsigned knDEFAULT_EXTENT = 4096;
-
-/************************************************************************/
-/* MVTTileLayerValue */
-/************************************************************************/
-
-class MVTTileLayerValue
-{
- public:
- enum class ValueType
- {
- NONE,
- STRING,
- FLOAT,
- DOUBLE,
- INT,
- UINT,
- SINT,
- BOOL,
- STRING_MAX_8, // optimization for short strings.
- };
-
- private:
- // Layout optimized for small memory footprint
- union
- {
- float m_fValue;
- double m_dfValue;
- GInt64 m_nIntValue;
- GUInt64 m_nUIntValue;
- bool m_bBoolValue;
- char* m_pszValue;
- char m_achValue[8]; // optimization for short strings
- };
- ValueType m_eType = ValueType::NONE;
-
- void unset();
-
- public:
- MVTTileLayerValue();
- ~MVTTileLayerValue();
- MVTTileLayerValue(const MVTTileLayerValue& oOther);
- MVTTileLayerValue& operator=(const MVTTileLayerValue& oOther);
-
- bool operator <(const MVTTileLayerValue& rhs) const;
-
- ValueType getType() const { return m_eType; }
- bool isNumeric() const { return m_eType == ValueType::FLOAT ||
- m_eType == ValueType::DOUBLE ||
- m_eType == ValueType::INT ||
- m_eType == ValueType::UINT ||
- m_eType == ValueType::SINT; }
- bool isString() const { return m_eType == ValueType::STRING ||
- m_eType == ValueType::STRING_MAX_8; }
-
- float getFloatValue() const { return m_fValue; }
- double getDoubleValue() const { return m_dfValue; }
- GInt64 getIntValue() const { return m_nIntValue; }
- GUInt64 getUIntValue() const { return m_nUIntValue; }
- bool getBoolValue() const { return m_bBoolValue; }
-
- double getNumericValue() const
- { if( m_eType == ValueType::FLOAT )
- return m_fValue;
- if( m_eType == ValueType::DOUBLE )
- return m_dfValue;
- if( m_eType == ValueType::INT || m_eType == ValueType::SINT )
- return static_cast<double>(m_nIntValue);
- if( m_eType == ValueType::UINT )
- return static_cast<double>(m_nUIntValue);
- return 0.0;
- }
-
- std::string getStringValue() const
- { if( m_eType == ValueType::STRING )
- return m_pszValue;
- else if( m_eType == ValueType::STRING_MAX_8 )
- {
- char szBuf[8+1];
- memcpy(szBuf, m_achValue, 8);
- szBuf[8] = 0;
- return szBuf;
- }
- return std::string();
- }
-
- void setStringValue(const std::string& osValue);
- void setFloatValue(float fValue)
- { unset(); m_eType = ValueType::FLOAT; m_fValue = fValue; }
- void setDoubleValue(double dfValue)
- { unset(); m_eType = ValueType::DOUBLE; m_dfValue = dfValue; }
- void setIntValue(GInt64 nVal)
- { unset(); m_eType = ValueType::INT; m_nIntValue = nVal; }
- void setUIntValue(GUInt64 nVal)
- { unset(); m_eType = ValueType::UINT; m_nUIntValue = nVal; }
- void setSIntValue(GInt64 nVal)
- { unset(); m_eType = ValueType::SINT; m_nIntValue = nVal; }
- void setBoolValue(bool bVal)
- { unset(); m_eType = ValueType::BOOL; m_bBoolValue = bVal; }
-
- void setValue(double dfVal);
- void setValue(int nVal) { setValue(static_cast<GInt64>(nVal)); }
- void setValue(GInt64 nVal)
- { if (nVal < 0)
- setSIntValue(nVal);
- else
- setUIntValue(nVal);
- }
-
- size_t getSize() const;
- void write(GByte** ppabyData) const;
- bool read(const GByte** ppabyData, const GByte* pabyEnd);
-};
-
-/************************************************************************/
-/* MVTTileLayerFeature */
-/************************************************************************/
-
-class MVTTileLayer;
-
-class MVTTileLayerFeature
-{
- public:
- enum class GeomType: char
- {
- UNKNOWN = 0,
- POINT = 1,
- LINESTRING = 2,
- POLYGON = 3
- };
-
- private:
- mutable size_t m_nCachedSize = 0;
- GUInt64 m_nId = 0;
- std::vector<GUInt32> m_anTags;
- std::vector<GUInt32> m_anGeometry;
- GeomType m_eType = GeomType::UNKNOWN;
- mutable bool m_bCachedSize = false;
- bool m_bHasId = false;
- bool m_bHasType = false;
- MVTTileLayer* m_poOwner = nullptr;
-
- public:
- MVTTileLayerFeature();
- void setOwner(MVTTileLayer* poOwner);
-
- bool hasId() const { return m_bHasId; }
- GUInt64 getId() const { return m_nId; }
- const std::vector<GUInt32>& getTags() const { return m_anTags; }
- bool hasType() const { return m_bHasType; }
- GeomType getType() const { return m_eType; }
- GUInt32 getGeometryCount() const
- { return static_cast<GUInt32>(m_anGeometry.size()); }
- const std::vector<GUInt32>& getGeometry() const { return m_anGeometry; }
-
- void setId(GUInt64 nId)
- { m_bHasId = true;
- m_nId = nId;
- invalidateCachedSize(); }
- void addTag(GUInt32 nTag)
- { m_anTags.push_back(nTag);
- invalidateCachedSize(); }
- void setType(GeomType eType)
- { m_bHasType = true;
- m_eType = eType;
- invalidateCachedSize(); }
- void resizeGeometryArray(GUInt32 nNewSize)
- { m_anGeometry.resize(nNewSize);
- invalidateCachedSize(); }
- void addGeometry(GUInt32 nGeometry)
- { m_anGeometry.push_back(nGeometry);
- invalidateCachedSize(); }
- void setGeometry(GUInt32 nIdx, GUInt32 nVal)
- { m_anGeometry[nIdx] = nVal;
- invalidateCachedSize(); }
- void setGeometry(const std::vector<GUInt32>& anGeometry )
- { m_anGeometry = anGeometry;
- invalidateCachedSize(); }
-
- size_t getSize() const;
- void write(GByte** ppabyData) const;
- bool read(const GByte** ppabyData, const GByte* pabyEnd);
-
- void invalidateCachedSize();
-};
-
-/************************************************************************/
-/* MVTTileLayer */
-/************************************************************************/
-
-class MVTTile;
-
-class MVTTileLayer
-{
- mutable bool m_bCachedSize = false;
- mutable size_t m_nCachedSize = 0;
- GUInt32 m_nVersion = 1;
- std::string m_osName;
- std::vector<std::shared_ptr<MVTTileLayerFeature>> m_apoFeatures;
- std::vector<std::string> m_aosKeys;
- std::vector<MVTTileLayerValue> m_aoValues;
- bool m_bHasExtent = false;
- GUInt32 m_nExtent = 4096;
- MVTTile* m_poOwner = nullptr;
-
- public:
- MVTTileLayer();
- void setOwner(MVTTile* poOwner);
-
- GUInt32 getVersion() const { return m_nVersion; }
- const std::string& getName() const { return m_osName; }
- const std::vector<std::shared_ptr<MVTTileLayerFeature>>& getFeatures()
- const
- { return m_apoFeatures; }
- const std::vector<std::string>& getKeys() const { return m_aosKeys; }
- const std::vector<MVTTileLayerValue>& getValues() const
- { return m_aoValues; }
- GUInt32 getExtent() const { return m_nExtent; }
-
- void setVersion(GUInt32 nVersion)
- { m_nVersion = nVersion;
- invalidateCachedSize(); }
- void setName(const std::string& osName)
- { m_osName = osName;
- invalidateCachedSize(); }
- size_t addFeature(std::shared_ptr<MVTTileLayerFeature> poFeature);
- GUInt32 addKey(const std::string& osKey)
- {
- m_aosKeys.push_back(osKey);
- invalidateCachedSize();
- return static_cast<GUInt32>(m_aosKeys.size()) - 1;
- }
-
- GUInt32 addValue(const MVTTileLayerValue& oValue)
- {
- m_aoValues.push_back(oValue);
- invalidateCachedSize();
- return static_cast<GUInt32>(m_aoValues.size()) - 1;
- }
-
- void setExtent(GUInt32 nExtent)
- {
- m_nExtent = nExtent;
- m_bHasExtent = true;
- invalidateCachedSize();
- }
-
- size_t getSize() const;
- void write(GByte** ppabyData) const;
- void write(GByte* pabyData) const;
- std::string write() const;
- bool read(const GByte** ppabyData, const GByte* pabyEnd);
- bool read(const GByte* pabyData, const GByte* pabyEnd);
-
- void invalidateCachedSize();
-};
-
-/************************************************************************/
-/* MVTTile */
-/************************************************************************/
-
-class MVTTile
-{
- std::vector<std::shared_ptr<MVTTileLayer>> m_apoLayers;
- mutable size_t m_nCachedSize = 0;
- mutable bool m_bCachedSize = false;
-
- public:
- MVTTile();
-
- const std::vector<std::shared_ptr<MVTTileLayer>>& getLayers() const
- { return m_apoLayers; }
-
- void clear() { m_apoLayers.clear(); invalidateCachedSize(); }
- void addLayer(std::shared_ptr<MVTTileLayer> poLayer);
- size_t getSize() const;
- void write(GByte** ppabyData) const;
- void write(GByte* pabyData) const;
- std::string write() const;
-#ifdef ADD_MVT_TILE_READ
- bool read(const GByte** ppabyData, const GByte* pabyEnd);
- bool read(const GByte* pabyData, const GByte* pabyEnd);
-#endif
- void invalidateCachedSize() { m_bCachedSize = false; m_nCachedSize = 0; }
-};
-
-#endif // MVT_TILE_H
Modified: branches/4.0/MgDev/Doc/samples/samples.php
===================================================================
--- branches/4.0/MgDev/Doc/samples/samples.php 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Doc/samples/samples.php 2024-07-17 11:06:37 UTC (rev 10081)
@@ -129,7 +129,6 @@
<li><a href="clientsamples/mixed/index_ol.html">Basic Sheboygan mixed map (tiled and untiled) example</a></li>
<li><a href="clientsamples/utfgrid/index.html">Sheboygan map as XYZ layer with UTFGrid interaction tiles</a></li>
<li><a href="clientsamples/wms/index.html">Sheboygan map as WMS layers</a></li>
- <li><a href="clientsamples/mvt/index.html">Sheboygan map as Mapbox Vector Tiles</a></li>
<li><a href="clientsamples/geoprocessing/index_ol.html">Using Geo-Processing APIs</a></li>
</ul>
<? } ?>
Deleted: branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,111 +0,0 @@
-//
-// Copyright (C) 2004-2019 by Autodesk, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of version 2.1 of the GNU Lesser
-// General Public License as published by the Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#include "OpRenderTileMVT.h"
-#include "LogManager.h"
-
-MgOpRenderTileMVT::MgOpRenderTileMVT()
-{
-}
-
-MgOpRenderTileMVT::~MgOpRenderTileMVT()
-{
-}
-
-void MgOpRenderTileMVT::Execute()
-{
- ACE_DEBUG((LM_DEBUG, ACE_TEXT(" (%t) MgOpRenderTileMVT::Execute()\n")));
-
- MG_LOG_OPERATION_MESSAGE(L"MgOpRenderTileMVT");
-
- MG_TRY()
-
- MG_LOG_OPERATION_MESSAGE_INIT(m_packet.m_OperationVersion, m_packet.m_NumArguments);
-
- ACE_ASSERT(m_stream != NULL);
-
- if (6 == m_packet.m_NumArguments)
- {
- Ptr<MgMap> map = (MgMap*)m_stream->GetObject();
- Ptr<MgResourceIdentifier> resource = map->GetResourceId();
- map->SetDelayedLoadResourceService(m_resourceService);
-
- STRING baseMapLayerGroupName;
- m_stream->GetString(baseMapLayerGroupName);
-
- INT32 x = 0;
- m_stream->GetInt32(x);
-
- INT32 y = 0;
- m_stream->GetInt32(y);
-
- INT32 z = 0;
- m_stream->GetInt32(z);
-
- INT32 tileDpi = 0;
- m_stream->GetInt32(tileDpi);
-
- BeginExecution();
-
- MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
- MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
- MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
- MG_LOG_OPERATION_MESSAGE_ADD_STRING(baseMapLayerGroupName.c_str());
- MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
- MG_LOG_OPERATION_MESSAGE_ADD_INT32(x);
- MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
- MG_LOG_OPERATION_MESSAGE_ADD_INT32(y);
- MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
- MG_LOG_OPERATION_MESSAGE_ADD_INT32(z);
- MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
- MG_LOG_OPERATION_MESSAGE_ADD_INT32(tileDpi);
- MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
-
- Validate();
-
- Ptr<MgByteReader> byteReader = m_service->RenderTileMVT(map, baseMapLayerGroupName, x, y, z, tileDpi);
-
- EndExecution(byteReader);
- }
- else
- {
- MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
- MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
- }
-
- if (!m_argsRead)
- {
- throw new MgException(MgExceptionCodes::MgOperationProcessingException, L"MgOpRenderTileMVT.Execute",
- __LINE__, __WFILE__, NULL, L"", NULL);
- }
-
- // Successful operation
- MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
-
- MG_CATCH(L"MgOpRenderTileMVT.Execute")
-
- if (mgException != NULL)
- {
- // Failed operation
- MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
- }
-
- // Add access log entry for operation
- MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
-
- MG_THROW()
-}
Deleted: branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.h
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/OpRenderTileMVT.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -1,33 +0,0 @@
-//
-// Copyright (C) 2004-2019 by Autodesk, Inc.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of version 2.1 of the GNU Lesser
-// General Public License as published by the Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#ifndef MG_OP_RENDER_TILE_MVT_H
-#define MG_OP_RENDER_TILE_MVT_H
-
-#include "RenderingOperation.h"
-
-class MgOpRenderTileMVT : public MgRenderingOperation
-{
-public:
- MgOpRenderTileMVT();
- virtual ~MgOpRenderTileMVT();
-
-public:
- virtual void Execute();
-};
-
-#endif
\ No newline at end of file
Modified: branches/4.0/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/RenderingOperationFactory.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -153,17 +153,6 @@
L"MgRenderingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
}
break;
- case MgRenderingServiceOpId::RenderTileMVT:
- switch (VERSION_NO_PHASE(operationVersion))
- {
- case VERSION_SUPPORTED(4, 0):
- handler.reset(new MgOpRenderTileMVT());
- break;
- default:
- throw new MgException(MgExceptionCodes::MgInvalidOperationVersionException,
- L"MgRenderingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
- }
- break;
case MgRenderingServiceOpId::RenderDynamicOverlay:
switch (VERSION_NO_PHASE(operationVersion))
{
Modified: branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -20,7 +20,6 @@
#include "DefaultStylizer.h"
#include "AGGRenderer.h"
#include "UTFGridRenderer.h"
-#include "MVTRenderer.h"
#include "RSMgSymbolManager.h"
#include "RSMgFeatureReader.h"
#include "FeatureInfoRenderer.h"
@@ -39,9 +38,6 @@
#define XYZ_TILE_WIDTH 256
#define XYZ_TILE_HEIGHT 256
-#define MVT_TILE_WIDTH 4096
-#define MVT_TILE_HEIGHT 4096
-
// the maximum number of allowed pixels for rendered images
static const INT32 FILTER_VISIBLE = 1;
static const INT32 FILTER_SELECTABLE = 2;
@@ -444,133 +440,6 @@
return ret.Detach();
}
-MgByteReader* MgServerRenderingService::RenderTileMVT(MgMap * map,
- CREFSTRING baseMapLayerGroupName,
- INT32 x,
- INT32 y,
- INT32 z,
- INT32 dpi)
-{
- Ptr<MgByteReader> ret;
-
- MG_TRY()
-
- CHECKARGUMENTNULL(map, L"MgServerRenderingService.RenderTileMVT");
- CHECKARGUMENTEMPTYSTRING(baseMapLayerGroupName, L"MgServerRenderingService.RenderTileMVT");
-
- // get the layer group associated with the name
- Ptr<MgLayerGroupCollection> layerGroups = map->GetLayerGroups();
- Ptr<MgLayerGroup> baseGroup = layerGroups->GetItem(baseMapLayerGroupName);
- if (baseGroup == NULL)
- {
- MgStringCollection arguments;
- arguments.Add(L"2");
- arguments.Add(baseMapLayerGroupName);
-
- throw new MgException(MgExceptionCodes::MgInvalidArgumentException, L"MgServerRenderingService.RenderTileMVT",
- __LINE__, __WFILE__, &arguments, L"MgMapLayerGroupNameNotFound", NULL);
- }
-
- //Set the dpi
- map->SetDisplayDpi(dpi);
-
- int width = MVT_TILE_WIDTH;
- int height = MVT_TILE_HEIGHT;
-
- // MVT tiles are always written in web mercator
- STRING srs = m_pCSFactory->ConvertCoordinateSystemCodeToWkt(L"WGS84.PseudoMercator");
- Ptr<MgCoordinateSystem> dstCs = m_pCSFactory->Create(srs);
- double metersPerUnit = dstCs->ConvertCoordinateSystemUnitsToMeters(1.0);
-
- // Inlining same logic from RenderTile() overload below as we want the same logic, but we want to pass scale
- // instead of scale index
-
- // get map extent that corresponds to tile extent
- RS_Bounds extent;
- ComputeXYZTileExtents(dstCs, x, y, z, extent);
-
- INT32 drawWidth = width;
- INT32 drawHeight = height;
- double scale = 0.0;
- ComputeScaledDimensions(extent, width, height, dpi, metersPerUnit, drawWidth, drawHeight, scale);
-
- //printf("XYZ(%d, %d, %d) -> [%f, %f] [%f, %f] at %f -- (w: %d, h: %d, mpu: %f)\n", x, y, z, mcsMinX, mcsMinY, mcsMaxX, mcsMaxY, scale, width, height, map->GetMetersPerUnit());
-
- // create a temporary collection containing all the layers for the base group
- Ptr<MgLayerCollection> layers = map->GetLayers();
- Ptr<MgReadOnlyLayerCollection> roLayers = new MgReadOnlyLayerCollection();
- for (int i = 0; i<layers->GetCount(); i++)
- {
- Ptr<MgLayerBase> layer = layers->GetItem(i);
- Ptr<MgLayerGroup> parentGroup = layer->GetGroup();
- if (parentGroup == baseGroup)
- roLayers->Add(layer);
- }
-
- // of course the group has to also be visible
- bool groupVisible = baseGroup->GetVisible();
- baseGroup->SetVisible(true);
-
- // We'd like to re-use RenderMapInternal, but its design is biased towards image-based SE_Renderers (that expect to
- // save to some RS_ByteData that an MgByteReader is returned from.
- //
- // Our MVTRenderer is not such a renderer, so we have to inline the pertinent bits here
-
- // set the map scale to the requested scale
- map->SetViewScale(scale);
-
- RS_String units = dstCs.p ? dstCs->GetUnits() : L"";
-
- // get the session ID
- STRING sessionId;
- Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
- if (userInfo != NULL)
- sessionId = userInfo->GetMgSessionId();
-
-#ifdef _DEBUG
- ACE_DEBUG((LM_INFO, ACE_TEXT("(%t) Render MVT for (x: %d, y: %d, z: %d)\n"), x, y, z));
-#endif
- MVTRenderer dr(x, y, z);
-
- RSMgSymbolManager mgr(m_svcResource);
- dr.SetSymbolManager(&mgr);
-
- SEMgSymbolManager semgr(m_svcResource);
- DefaultStylizer ds(&semgr);
-
- RS_Color bgcolor(0, 0, 0, 255); //Not used by MVTRenderer
-
- Ptr<MgPoint> ptCenter = map->GetViewCenter();
- Ptr<MgCoordinate> coord = ptCenter->GetCoordinate();
- RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, units, bgcolor, coord->GetX(), coord->GetY(), scale);
-
- // begin map stylization
- dr.StartMap(&mapInfo, extent, scale, map->GetDisplayDpi(), map->GetMetersPerUnit(), NULL);
-
- // We can't use RenderMapInternal, but we can use RenderLayers, which is all we really need
- RenderLayers(map, roLayers, &ds, &dr, dstCs, true, scale, L"MVT", NULL);
-
- dr.EndMap();
-
- // restore the base group's visibility
- baseGroup->SetVisible(groupVisible);
-
- // Now extract the encoded MVT tile and pack it into a MgByteReader
- size_t size;
- auto buf = dr.GetMVTContent(size);
- Ptr<MgByte> mvtBytes = new MgByte(buf, size);
- dr.ReleaseMVTContent(buf);
- Ptr<MgByteSource> bs = new MgByteSource(mvtBytes);
-
- bs->SetMimeType(MgMimeType::Mvt);
-
- ret = bs->GetReader();
-
- MG_CATCH_AND_THROW(L"MgServerRenderingService.RenderTileMVT")
-
- return ret.Detach();
-}
-
///////////////////////////////////////////////////////////////////////////////
/// render a map using all layers from the baseGroup
MgByteReader* MgServerRenderingService::RenderTileInternal(MgMap* map,
Modified: branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.h
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.h 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.h 2024-07-17 11:06:37 UTC (rev 10081)
@@ -100,13 +100,6 @@
INT32 z,
INT32 dpi);
- virtual MgByteReader* RenderTileMVT(MgMap* map,
- CREFSTRING baseMapLayerGroupName,
- INT32 x,
- INT32 y,
- INT32 z,
- INT32 dpi);
-
virtual MgByteReader* RenderDynamicOverlay(MgMap* map,
MgSelection* selection,
CREFSTRING format);
Modified: branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj 2024-07-17 11:06:37 UTC (rev 10081)
@@ -252,12 +252,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="OpRenderTileMVT.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
- </ClCompile>
<ClCompile Include="OpRenderTileXYZ.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -324,7 +318,6 @@
<ClInclude Include="OpRenderMetatileXYZ.h" />
<ClInclude Include="OpRenderTile.h" />
<ClInclude Include="OpRenderTileFromMetatile.h" />
- <ClInclude Include="OpRenderTileMVT.h" />
<ClInclude Include="OpRenderTileXYZ.h" />
<ClInclude Include="OpRenderTileUTFGrid.h" />
<ClInclude Include="RenderingOperation.h" />
Modified: branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj.filters
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj.filters 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj.filters 2024-07-17 11:06:37 UTC (rev 10081)
@@ -51,9 +51,6 @@
<ClCompile Include="OpRenderTileFromMetatile.cpp">
<Filter>Ops</Filter>
</ClCompile>
- <ClCompile Include="OpRenderTileMVT.cpp">
- <Filter>Ops</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="OpQueryFeatureProperties.h">
@@ -101,9 +98,6 @@
<ClInclude Include="OpRenderTileFromMetatile.h">
<Filter>Ops</Filter>
</ClInclude>
- <ClInclude Include="OpRenderTileMVT.h">
- <Filter>Ops</Filter>
- </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ServerRenderingService.rc" />
Modified: branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingServiceBuild.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingServiceBuild.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Rendering/ServerRenderingServiceBuild.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -29,7 +29,6 @@
#include "OpRenderTile.cpp"
#include "OpRenderTileXYZ.cpp"
#include "OpRenderTileUTFGrid.cpp"
-#include "OpRenderTileMVT.cpp"
#include "OpQueryFeatures.cpp"
#include "OpQueryFeatureProperties.cpp"
#include "RenderingOperation.cpp"
Modified: branches/4.0/MgDev/Server/src/Services/Tile/ServerTileService.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Tile/ServerTileService.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Tile/ServerTileService.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -410,7 +410,6 @@
xml.append("<Value>JPG</Value>");
xml.append("<Value>GIF</Value>");
xml.append("<Value>UTFGRID</Value>");
- xml.append("<Value>MVT</Value>");
xml.append("</ConnectionProperty>\n");
//Property: RetinaScale
Modified: branches/4.0/MgDev/Server/src/Services/Tile/TileCacheXYZProvider.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/Services/Tile/TileCacheXYZProvider.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/Services/Tile/TileCacheXYZProvider.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -46,7 +46,7 @@
bool MgTileCacheXYZProvider::IsTileImageFormat()
{
- return m_format != L"UTFGRID" && m_format != L"MVT";
+ return m_format != L"UTFGRID";
}
MgByteReader* MgTileCacheXYZProvider::GetTile(CREFSTRING baseMapLayerGroupName,
@@ -83,14 +83,9 @@
if (svcRendering != NULL)
{
// Test for non-image formats first
- if (m_format == L"MVT")
+ if (m_format == L"UTFGRID")
{
// generate the tile
- img = svcRendering->RenderTileMVT(map, baseMapLayerGroupName, tileRow, tileColumn, scaleIndex, map->GetDisplayDpi());
- }
- else if (m_format == L"UTFGRID")
- {
- // generate the tile
img = svcRendering->RenderTileUTFGrid(map, baseMapLayerGroupName, tileRow, tileColumn, scaleIndex, map->GetDisplayDpi());
}
else //Assume it must be image-based at this point
@@ -116,15 +111,11 @@
INT32 MgTileCacheXYZProvider::GetDefaultTileSizeX()
{
- if (m_format == L"MVT")
- return 4096;
return 256 * m_retinaScale;
}
INT32 MgTileCacheXYZProvider::GetDefaultTileSizeY()
{
- if (m_format == L"MVT")
- return 4096;
return 256 * m_retinaScale;
}
@@ -152,10 +143,6 @@
{
return L"utfgrid";
}
- else if (m_format == L"MVT")
- {
- return L"mvt";
- }
else
{
return L"png";
Modified: branches/4.0/MgDev/Server/src/UnitTesting/TestRenderingService.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/UnitTesting/TestRenderingService.cpp 2024-07-10 09:53:10 UTC (rev 10080)
+++ branches/4.0/MgDev/Server/src/UnitTesting/TestRenderingService.cpp 2024-07-17 11:06:37 UTC (rev 10081)
@@ -20,7 +20,6 @@
#include "ServerSiteService.h"
#include "Fdo.h"
#include "StylizationDefs.h"
-#include "MVTRenderer.h"
//#include "AGGRenderer.h"
#include "FoundationDefs.h"
#include "SE_Renderer.h"
@@ -1504,74 +1503,6 @@
}
}
-TEST_CASE("RenderTileMVT", "[RenderingService]")
-{
- try
- {
- Ptr<MgRenderingService> m_svcRendering = TestServiceFactory::CreateRenderingService();
-
- Ptr<MgMap> map = CreateTestXYZMap();
-
- //For ease of visual verfication, render the XYZ image tiles as baseline
- Ptr<MgByteReader> imgTL = m_svcRendering->RenderTileXYZ(map, L"BaseLayers", 16797, 23893, 16, 96, MgImageFormats::Png);
- Ptr<MgByteReader> imgTR = m_svcRendering->RenderTileXYZ(map, L"BaseLayers", 16798, 23893, 16, 96, MgImageFormats::Png);
- Ptr<MgByteReader> imgBL = m_svcRendering->RenderTileXYZ(map, L"BaseLayers", 16797, 23894, 16, 96, MgImageFormats::Png);
- Ptr<MgByteReader> imgBR = m_svcRendering->RenderTileXYZ(map, L"BaseLayers", 16798, 23894, 16, 96, MgImageFormats::Png);
-
- imgTL->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_TL_ImageBaseline.png");
- imgTR->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_TR_ImageBaseline.png");
- imgBL->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_BL_ImageBaseline.png");
- imgBR->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_BR_ImageBaseline.png");
-
- //Now render the MVT tiles at the same place
- Ptr<MgByteReader> mvtTL = m_svcRendering->RenderTileMVT(map, L"BaseLayers", 16797, 23893, 16, 96);
- Ptr<MgByteReader> mvtTR = m_svcRendering->RenderTileMVT(map, L"BaseLayers", 16798, 23893, 16, 96);
- Ptr<MgByteReader> mvtBL = m_svcRendering->RenderTileMVT(map, L"BaseLayers", 16797, 23894, 16, 96);
- Ptr<MgByteReader> mvtBR = m_svcRendering->RenderTileMVT(map, L"BaseLayers", 16798, 23894, 16, 96);
-
- REQUIRE(MgMimeType::Mvt == mvtTL->GetMimeType());
- REQUIRE(MgMimeType::Mvt == mvtTR->GetMimeType());
- REQUIRE(MgMimeType::Mvt == mvtBL->GetMimeType());
- REQUIRE(MgMimeType::Mvt == mvtBR->GetMimeType());
-
- REQUIRE(mvtTL->GetLength() > 0);
- REQUIRE(mvtTR->GetLength() > 0);
- REQUIRE(mvtBL->GetLength() > 0);
- REQUIRE(mvtBR->GetLength() > 0);
-
- mvtTL->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_TL.mvt");
- mvtTR->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_TR.mvt");
- mvtBL->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_BL.mvt");
- mvtBR->ToFile(L"../UnitTestFiles/Results/RenderTileMVT_UR.mvt");
-
- mvtTL->Rewind();
- mvtTR->Rewind();
- mvtBL->Rewind();
- mvtBR->Rewind();
-
- Ptr<MgByteSink> sinkTL = new MgByteSink(mvtTL);
- Ptr<MgByteSink> sinkTR = new MgByteSink(mvtTR);
- Ptr<MgByteSink> sinkBL = new MgByteSink(mvtBL);
- Ptr<MgByteSink> sinkBR = new MgByteSink(mvtBR);
-
- Ptr<MgByte> bytesTL = sinkTL->ToBuffer();
- Ptr<MgByte> bytesTR = sinkTR->ToBuffer();
- Ptr<MgByte> bytesBL = sinkBL->ToBuffer();
- Ptr<MgByte> bytesBR = sinkBR->ToBuffer();
-
- REQUIRE(MVTRenderer::IsValidTile(bytesTL->Bytes(), bytesTL->GetLength()));
- REQUIRE(MVTRenderer::IsValidTile(bytesTR->Bytes(), bytesTR->GetLength()));
- REQUIRE(MVTRenderer::IsValidTile(bytesBL->Bytes(), bytesBL->GetLength()));
- REQUIRE(MVTRenderer::IsValidTile(bytesBR->Bytes(), bytesBR->GetLength()));
- }
- catch (MgException* e)
- {
- STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
- SAFE_RELEASE(e);
- FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
- }
-}
-
//TEST_CASE("RendererPerformance", "[Performance]")
//{
// /*
More information about the mapguide-commits
mailing list