[mapguide-commits] r9188 - in sandbox/jng/utfgrid: Common/Renderers Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue May 2 08:31:43 PDT 2017


Author: jng
Date: 2017-05-02 08:31:43 -0700 (Tue, 02 May 2017)
New Revision: 9188

Modified:
   sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.cpp
   sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.h
   sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp
   sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h
   sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp
Log:
- Fix off-by-one case where last rendered feature has a key, but no matching data
- Skip geometry/raster properties when rendering attributes

Modified: sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.cpp
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.cpp	2017-05-02 14:48:29 UTC (rev 9187)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.cpp	2017-05-02 15:31:43 UTC (rev 9188)
@@ -18,7 +18,7 @@
     return mbContent;
 }
 
-bool UTFGridContent::AddFeature(unsigned int color, RS_FeatureReader* feature)
+bool UTFGridContent::AddFeature(unsigned int decodedColor, RS_FeatureReader* feature)
 {
     static const size_t MAX_STRING = 64;
 
@@ -28,17 +28,26 @@
     {
         std::wstring wVal = L"{";
 
+        auto geomName = feature->GetGeomPropName();
+        auto rasterName = feature->GetRasterPropName();
+
         bool bFirst = true;
         int count = 0;
-        auto propNames = feature->GetIdentPropNames(count);
+        auto propNames = feature->GetPropNames(count);
         for (int i = 0; i < count; i++)
         {
+            auto propName = propNames[i];
+            //Skip geometry/raster
+            if ((geomName && wcscmp(propName, geomName) == 0) ||
+                (rasterName && wcscmp(propName, rasterName) == 0))
+            {
+                continue;
+            }
+
             if (!bFirst)
             {
                 wVal.append(L",");
             }
-
-            auto propName = propNames[i];
             auto propVal = feature->GetAsString(propName);
 
             wVal.append(L"\"");
@@ -56,12 +65,14 @@
             {
                 wVal.append(propVal);
             }
+
+            bFirst = false;
         }
 
         wVal += L"}";
 
         m_features.insert(std::make_pair(key, wVal));
-        m_pixels.insert(std::make_pair(color, key));
+        m_pixels.insert(std::make_pair(decodedColor, key));
         return true;
     }
     return false;
@@ -82,7 +93,7 @@
 
 void UTFGridContent::AppendRowPixel(unsigned int pixel)
 {
-    m_trackedColors.insert(pixel);
+    m_trackedEncodedColors.insert(pixel);
     m_content << (wchar_t)pixel;
 }
 
@@ -100,9 +111,9 @@
 {
     m_content << "," << std::endl;
     m_content << "  \"keys\": [" << std::endl;
-    for (auto it = m_trackedColors.begin(); it != m_trackedColors.end(); it++)
+    for (auto it = m_trackedEncodedColors.begin(); it != m_trackedEncodedColors.end(); it++)
     {
-        if (it != m_trackedColors.begin())
+        if (it != m_trackedEncodedColors.begin())
             m_content << "," << std::endl;
 
         if (*it == 32) // This is the "empty space" pixel
@@ -123,7 +134,7 @@
     m_content << "," << std::endl;
     m_content << "  \"data\": {" << std::endl;
     bool bFirst = true;
-    for (auto it = m_trackedColors.begin(); it != m_trackedColors.end(); it++)
+    for (auto it = m_trackedEncodedColors.begin(); it != m_trackedEncodedColors.end(); it++)
     {
         if (*it == 32) // This is the "empty space" pixel
         {

Modified: sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.h
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.h	2017-05-02 14:48:29 UTC (rev 9187)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridContent.h	2017-05-02 15:31:43 UTC (rev 9188)
@@ -52,7 +52,7 @@
 private:
 
     std::wstringstream m_content;
-    std::set<unsigned int> m_trackedColors;
+    std::set<unsigned int> m_trackedEncodedColors;
 
     KeyFeatureMap m_features;
     ColorKeyMap m_pixels;

Modified: sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp	2017-05-02 14:48:29 UTC (rev 9187)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp	2017-05-02 15:31:43 UTC (rev 9188)
@@ -151,9 +151,10 @@
 
 void UTFGridRenderer::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_currentColor++;
     m_renderThisFeature = m_content->AddFeature(m_currentColor, feature);
-    if (m_renderThisFeature)
-        m_currentColor++;
+    if (!m_renderThisFeature)
+        m_currentColor--; //Rewind
 }
 
 void UTFGridRenderer::ProcessPolygon(LineBuffer * lb, RS_FillStyle & fill)

Modified: sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h	2017-05-02 14:48:29 UTC (rev 9187)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h	2017-05-02 15:31:43 UTC (rev 9188)
@@ -78,7 +78,6 @@
     RENDERERS_API static void DrawScreenPolyline(agg_utfgrid_context* cxt, LineBuffer* polyline, const SE_Matrix* xform, const SE_LineStroke& lineStroke);
 
 private:
-
     void ProcessOneMarker(double x, double y, RS_MarkerDef& mdef, bool allowOverpost);
     double _MeterToMapSize(RS_Units unit, double number);
     static void _TransferPoints(agg_utfgrid_context* c, LineBuffer* src, const SE_Matrix* xform, unsigned int* pathids);

Modified: sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp
===================================================================
--- sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp	2017-05-02 14:48:29 UTC (rev 9187)
+++ sandbox/jng/utfgrid/Server/src/UnitTesting/TestRenderingService.cpp	2017-05-02 15:31:43 UTC (rev 9188)
@@ -811,7 +811,7 @@
 
         map->SetViewScale(12000.0);
         Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, imageFormat);
-		rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderMapWithWatermark12k", imageFormat, extension));
+        rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderMapWithWatermark12k", imageFormat, extension));
     }
     catch (MgException* e)
     {
@@ -1786,13 +1786,13 @@
 
 STRING TestRenderingService::GetPath(CREFSTRING basePath, CREFSTRING imageFormat, CREFSTRING extension)
 {
-	STRING ret;
-	ret += basePath;
-	ret += L"_";
-	ret += imageFormat;
-	ret += L".";
-	ret += extension;
-	return ret;
+    STRING ret;
+    ret += basePath;
+    ret += L"_";
+    ret += imageFormat;
+    ret += L".";
+    ret += extension;
+    return ret;
 }
 
 //void TestRenderingService::TestCase_RendererPerformance()



More information about the mapguide-commits mailing list