[mapguide-commits] r9834 - in trunk/MgDev: . Common/Renderers Server/src/Services/Rendering

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Apr 12 04:52:58 PDT 2021


Author: jng
Date: 2021-04-12 04:52:58 -0700 (Mon, 12 Apr 2021)
New Revision: 9834

Modified:
   trunk/MgDev/
   trunk/MgDev/Common/Renderers/MVTRenderer.cpp
   trunk/MgDev/Common/Renderers/MVTRenderer.h
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
Log:
Merged revision(s) 9828-9833 from sandbox/jng/mvt_render_fixes:

#2836: Re-instate clipping of MVT tile geometries at the stylizer level by having MVTRenderer::RequiresClipping?() return true and having MVTRenderer::GetBounds?() return a buffered extents (where buffer is the default of 80 screen pixels). We still do not have the undesired tile border artifact, which tells us that we're buffering by the correct amount. Having said that, this commit also adds a flag to render tile borders for visual debugging purposes. If you see tile border artifacts, it should now be due to this new flag being true.

#2836: Remove geometry clipping code from the ProcessXXX renderer methods. This eliminates the tile border artifact we are experiencing in client applications like OpenLayers/QGIS. If we are meant to clip, we should probably do it at the Stylizer level by having our MVTRenderer return true for RequiresClipping?() and find a way to let the renderer customize the clip extents.
........


Index: trunk/MgDev
===================================================================
--- trunk/MgDev	2021-04-12 11:47:00 UTC (rev 9833)
+++ trunk/MgDev	2021-04-12 11:52:58 UTC (rev 9834)

Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
## -24,6 +24,7 ##
 /sandbox/jng/library_init:9700-9709
 /sandbox/jng/mvt:9527-9528,9535,9537,9546-9547
 /sandbox/jng/mvt_alt:9604-9629
+/sandbox/jng/mvt_render_fixes:9828-9833
 /sandbox/jng/ogc:9240-9255
 /sandbox/jng/ogc_viewer_representation:9678-9698
 /sandbox/jng/php56x:8975-8985
Modified: trunk/MgDev/Common/Renderers/MVTRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/MVTRenderer.cpp	2021-04-12 11:47:00 UTC (rev 9833)
+++ trunk/MgDev/Common/Renderers/MVTRenderer.cpp	2021-04-12 11:52:58 UTC (rev 9834)
@@ -61,7 +61,10 @@
         , m_dfTopY(kmMAX_GM)
         , m_dfTileDim0(2 * kmMAX_GM)
         , m_parent(parent)
-    { }
+        , m_nBuffer(0)
+    {
+        m_nBuffer = 5 * m_nExtent / 256;
+    }
 
     ~MVTImpl()
     {
@@ -68,6 +71,30 @@
 
     }
 
+    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>();
@@ -497,6 +524,8 @@
     double m_dfTopY;
     double m_dfTileDim0;
 
+    unsigned int m_nBuffer;
+
     unsigned int m_nExtent;
 };
 
@@ -505,6 +534,7 @@
     , m_mapInfo(nullptr)
     , m_layerInfo(nullptr)
     , m_fcInfo(nullptr)
+    , m_bRenderDebugTileBorders(false)
 {
 
 }
@@ -515,22 +545,24 @@
 //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;
 
-    // find scale used to convert to pixel coordinates
-    // need to take aspect ratios into account
-    /*
-    double arDisplay = (double)m_width / (double)m_height;
-    double arMap = m_extents.width() / m_extents.height();
+    //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;
 
-    double scale;
-    if (arDisplay > arMap)
-        scale = (double)m_height / m_extents.height();
-    else
-    */    
+    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();
 
@@ -560,6 +592,18 @@
 {
     // 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
@@ -597,20 +641,6 @@
     auto workbuffer = lb->Optimize(m_drawingScale, m_pPool);
     std::unique_ptr<LineBuffer> spLB(workbuffer);
 
-    //Also clip the geometry to the extents if required as we do not want to encode
-    //"out of tile" coordinates
-    auto clipped = workbuffer->Clip(m_extents, LineBuffer::ctArea, m_pPool);
-    if (workbuffer != clipped)
-    {
-        if (spLB.get())
-        {
-            LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
-        }
-
-        workbuffer = clipped;
-        spLB.reset(workbuffer);
-    }
-
     if (workbuffer)
         m_impl->ProcessPolygon(m_activeFeature, workbuffer);
 
@@ -625,20 +655,6 @@
     auto workbuffer = lb->Optimize(m_drawingScale, m_pPool);
     std::unique_ptr<LineBuffer> spLB(workbuffer);
 
-    //Also clip the geometry to the extents if required as we do not want to encode
-    //"out of tile" coordinates
-    auto clipped = workbuffer->Clip(m_extents, LineBuffer::ctLine, m_pPool);
-    if (workbuffer != clipped)
-    {
-        if (spLB.get())
-        {
-            LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
-        }
-
-        workbuffer = clipped;
-        spLB.reset(workbuffer);
-    }
-
     if (workbuffer)
         m_impl->ProcessPolyline(m_activeFeature, workbuffer);
 
@@ -662,20 +678,6 @@
     auto workbuffer = lb->Optimize(m_drawingScale, m_pPool);
     std::unique_ptr<LineBuffer> spLB(workbuffer);
 
-    //Also clip the geometry to the extents if required as we do not want to encode
-    //"out of tile" coordinates
-    auto clipped = workbuffer->Clip(m_extents, LineBuffer::ctPoint, m_pPool);
-    if (workbuffer != clipped)
-    {
-        if (spLB.get())
-        {
-            LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
-        }
-
-        workbuffer = clipped;
-        spLB.reset(workbuffer);
-    }
-
     if (workbuffer)
         m_impl->ProcessMarker(m_activeFeature, workbuffer);
 
@@ -749,7 +751,7 @@
 
 bool MVTRenderer::RequiresClipping()
 {
-    return false;
+    return true;
 }
 
 bool MVTRenderer::RequiresLabelClipping()

Modified: trunk/MgDev/Common/Renderers/MVTRenderer.h
===================================================================
--- trunk/MgDev/Common/Renderers/MVTRenderer.h	2021-04-12 11:47:00 UTC (rev 9833)
+++ trunk/MgDev/Common/Renderers/MVTRenderer.h	2021-04-12 11:52:58 UTC (rev 9834)
@@ -96,11 +96,14 @@
     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: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2021-04-12 11:47:00 UTC (rev 9833)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2021-04-12 11:52:58 UTC (rev 9834)
@@ -521,6 +521,7 @@
     if (userInfo != NULL)
         sessionId = userInfo->GetMgSessionId();
 
+    ACE_DEBUG((LM_INFO, ACE_TEXT("(%t) Render MVT for (x: %d, y: %d, z: %d)\n"), x, y, z));
     MVTRenderer dr(x, y, z);
 
     RSMgSymbolManager mgr(m_svcResource);



More information about the mapguide-commits mailing list