[mapguide-commits] r9196 - in sandbox/jng/utfgrid: Common/Renderers Server/src/UnitTesting UnitTest/TestData/TileService

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jun 2 06:24:15 PDT 2017


Author: jng
Date: 2017-06-02 06:24:15 -0700 (Fri, 02 Jun 2017)
New Revision: 9196

Modified:
   sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp
   sandbox/jng/utfgrid/Common/Renderers/agg_utfgrid_context.h
   sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp
   sandbox/jng/utfgrid/UnitTest/TestData/TileService/UT_RoadCenterLines.ldf
Log:
- Add tooltip for UT_RoadCenterLines layer
- Setup a separate MgMap instance for XYZ/UTFGrid rendering that includes the tooltipped UT_RoadCenterLines
- Fix lines not rendering in UTFGrid content

Modified: sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp	2017-05-31 15:30:41 UTC (rev 9195)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp	2017-06-02 13:24:15 UTC (rev 9196)
@@ -172,12 +172,12 @@
     m_renderThisFeature = m_content->AddFeature(m_layerInfo, m_currentColor, feature, tooltip, url);
 }
 
-void UTFGridRenderer::ProcessPolygon(LineBuffer * lb, RS_FillStyle & fill)
+void UTFGridRenderer::ProcessPolygon(LineBuffer * lb, RS_FillStyle & /*fill*/)
 {
     if (!m_renderThisFeature)
         return;
 
-    DrawScreenPolygon(lb, &m_xform, fill.color().argb());
+    DrawScreenPolygon(lb, &m_xform, m_currentColor);
 }
 
 void UTFGridRenderer::ProcessPolyline(LineBuffer * lb, RS_LineStroke & /*lsym*/)
@@ -185,6 +185,7 @@
     if (!m_renderThisFeature)
         return;
 
+    m_lineStroke.color = m_currentColor;
     DrawScreenPolyline(lb, &m_xform, m_lineStroke);
 }
 
@@ -483,7 +484,7 @@
     if (srclb->geom_count() == 0)
         return;
 
-    double weightpx = rs_max(1.0, lineStroke.weight);
+    double weightpx = rs_max(1.0, lineStroke.weight) / c->m_resolution;
 
     // add to the agg path storage - here it doesn't matter
     // how many geometries there are in the line buffer,
@@ -530,16 +531,15 @@
         break;
     }
 
+    c->rasterizer.reset();
+    c->rasterizer.filling_rule(agg::fill_even_odd);
     c->rasterizer.add_path(stroke);
-    c->rasterizer.filling_rule(agg::fill_non_zero);
 
     c->renderer_scanline.color(utfpix32(UTFGridContent::EncodeChar(lineStroke.color)));
     agg::render_scanlines(c->rasterizer, c->scanline_utf, c->renderer_scanline);
-
-    c->rasterizer.filling_rule(agg::fill_even_odd);
 }
 
-void UTFGridRenderer::DrawScreenPolygon(LineBuffer * polygon, const SE_Matrix * xform, unsigned int /*fill*/)
+void UTFGridRenderer::DrawScreenPolygon(LineBuffer * polygon, const SE_Matrix * xform, unsigned int fill)
 {
     // if you have no geoms, why do you call us at all?
     if (polygon->geom_count() == 0)
@@ -554,7 +554,7 @@
         m_context->rasterizer.reset();
         m_context->rasterizer.add_path(m_context->ps, pathids[i]);
 
-        m_context->renderer_scanline.color(utfpix32(UTFGridContent::EncodeChar(m_currentColor)));
+        m_context->renderer_scanline.color(utfpix32(UTFGridContent::EncodeChar(fill)));
         agg::render_scanlines(m_context->rasterizer, m_context->scanline_utf, m_context->renderer_scanline);
     }
 }

Modified: sandbox/jng/utfgrid/Common/Renderers/agg_utfgrid_context.h
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/agg_utfgrid_context.h	2017-05-31 15:30:41 UTC (rev 9195)
+++ sandbox/jng/utfgrid/Common/Renderers/agg_utfgrid_context.h	2017-06-02 13:24:15 UTC (rev 9196)
@@ -50,8 +50,9 @@
 public:
     agg_utfgrid_context(int width, int height, unsigned int resolution)
     {
-        int bufWidth = width / resolution;
-        int bufHeight = height / resolution;
+        m_resolution = resolution;
+        int bufWidth = width / m_resolution;
+        int bufHeight = height / m_resolution;
 
         size_t len = bufWidth * bufHeight * sizeof(utfgrid_band_type);
         m_rows = new utfgrid_band_type[len];
@@ -70,6 +71,7 @@
     }
 
     // rendering buffer
+    unsigned int                m_resolution;
     utfgrid_band_type*          m_rows; //Not owned by this
     bool                        ownrows;
     utfgrid_rendering_buffer    rendering_buffer;

Modified: sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp
===================================================================
--- sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp	2017-05-31 15:30:41 UTC (rev 9195)
+++ sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp	2017-06-02 13:24:15 UTC (rev 9196)
@@ -107,6 +107,12 @@
         Ptr<MgByteReader> mdfrdr1 = mdfsrc1->GetReader();
         m_svcResource->SetResource(mapres1, mdfrdr1, NULL);
 
+        // publish tile set
+        Ptr<MgResourceIdentifier> tilesetres1 = new MgResourceIdentifier(L"Library://UnitTests/TileSets/XYZ.TileSetDefinition");
+        Ptr<MgByteSource> tsdsrc1 = new MgByteSource(L"../UnitTestFiles/UT_XYZ.tsd", false);
+        Ptr<MgByteReader> tsdrdr1 = tsdsrc1->GetReader();
+        m_svcResource->SetResource(tilesetres1, tsdrdr1, NULL);
+
         // publish the layer definitions
         Ptr<MgResourceIdentifier> ldfres1 = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
         Ptr<MgByteSource> ldfsrc1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.ldf", false);
@@ -446,6 +452,10 @@
         Ptr<MgResourceIdentifier> mapres1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
         m_svcResource->DeleteResource(mapres1);
 
+        // delete tile set
+        Ptr<MgResourceIdentifier> tilesetres1 = new MgResourceIdentifier(L"Library://UnitTests/TileSets/XYZ.TileSetDefinition");
+        m_svcResource->DeleteResource(tilesetres1);
+
         // delete the layer definitions
         Ptr<MgResourceIdentifier> ldfres1 = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
         m_svcResource->DeleteResource(ldfres1);
@@ -1349,6 +1359,29 @@
     return map;
 }
 
+MgMap* TestRenderingService::CreateTestXYZMap()
+{
+    Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/BaseMap.MapDefinition");
+    MgMap* map = new MgMap(m_siteConnection);
+    map->Create(mdfres, L"UnitTestSheboyganXYZ");
+
+    Ptr<MgLayerCollection> layers = map->GetLayers();
+    Ptr<MgLayerGroupCollection> groups = map->GetLayerGroups();
+    Ptr<MgLayerBase> roads = layers->GetItem(L"RoadCenterLines");
+    Ptr<MgLayerGroup> baseGroup = groups->GetItem(L"BaseLayers");
+    roads->SetGroup(baseGroup);
+
+    Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-87.733253, 43.746199);
+    Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+    map->SetViewCenter(ptNewCenter);
+    map->SetViewScale(75000.0);
+    map->SetDisplayDpi(96);
+    map->SetDisplayWidth(1024);
+    map->SetDisplayHeight(1024);
+
+    return map;
+}
+
 MgMap* TestRenderingService::CreateTestTiledMap()
 {
     Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/BaseMap.MapDefinition");
@@ -1765,7 +1798,7 @@
 {
     try
     {
-        Ptr<MgMap> map = CreateTestTiledMap();
+        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);

Modified: sandbox/jng/utfgrid/UnitTest/TestData/TileService/UT_RoadCenterLines.ldf
===================================================================
--- sandbox/jng/utfgrid/UnitTest/TestData/TileService/UT_RoadCenterLines.ldf	2017-05-31 15:30:41 UTC (rev 9195)
+++ sandbox/jng/utfgrid/UnitTest/TestData/TileService/UT_RoadCenterLines.ldf	2017-06-02 13:24:15 UTC (rev 9196)
@@ -5,6 +5,7 @@
     <FeatureName>Default:RoadCenterLines</FeatureName>
     <FeatureNameType>FeatureClass</FeatureNameType>
     <Geometry>Geometry</Geometry>
+    <ToolTip>NAME</ToolTip>
     <VectorScaleRange>
       <LineTypeStyle>
         <LineRule>



More information about the mapguide-commits mailing list