[mapguide-commits] r8230 - trunk/MgDev/Server/src/Services/Rendering

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Jun 16 19:49:45 PDT 2014


Author: jng
Date: 2014-06-16 19:49:45 -0700 (Mon, 16 Jun 2014)
New Revision: 8230

Modified:
   trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp
   trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h
   trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.cpp
   trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.h
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
Log:
#2458: Fix FeaturePropRenderer not transforming bounding box data. Before layer stylization, pass in the current layer to map transform so the FeaturePropRenderer can perform the necessary transformations on any bounding boxes it encounters.

Modified: trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp	2014-06-17 01:53:37 UTC (rev 8229)
+++ trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.cpp	2014-06-17 02:49:45 UTC (rev 8230)
@@ -37,7 +37,8 @@
   m_layerInfo(NULL),
   m_fcInfo(NULL),
   m_pointTest(false),
-  m_impRenderer(impRenderer)
+  m_impRenderer(impRenderer),
+  m_currentTransform(NULL)
 {
     m_selection = SAFE_ADDREF(selection);
     m_keyEncode = new KeyEncode();
@@ -56,7 +57,7 @@
 {
     SAFE_RELEASE(m_props);
     SAFE_RELEASE(m_selection);
-
+    m_currentTransform = NULL;
     delete m_keyEncode;
 }
 
@@ -184,6 +185,8 @@
 void FeatureInfoRenderer::StartLayer(RS_LayerUIInfo*      layerInfo,
                                      RS_FeatureClassInfo* classInfo)
 {
+    m_currentTransform = NULL;
+
     // remember the layer/feature info
     m_layerInfo = layerInfo;
     m_fcInfo = classInfo;

Modified: trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h	2014-06-17 01:53:37 UTC (rev 8229)
+++ trunk/MgDev/Server/src/Services/Rendering/FeatureInfoRenderer.h	2014-06-17 02:49:45 UTC (rev 8230)
@@ -237,6 +237,11 @@
 
     void SetSelected();
 
+    void SetLayerToMapTransform(CSysTransformer* tx)
+    {
+        m_currentTransform = tx;
+    }
+
 protected:
     //common to FeaturePropRenderer and FeatureInfoRenderer
     RS_String m_layerId;
@@ -260,6 +265,7 @@
     double m_dpi;
     double m_scale;
 
+    CSysTransformer* m_currentTransform; //From stack-allocated TransformCacheMap. DO NOT FREE
 private:
     //specific to FeatureInfoRenderer
     RS_String m_url;

Modified: trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.cpp	2014-06-17 01:53:37 UTC (rev 8229)
+++ trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.cpp	2014-06-17 02:49:45 UTC (rev 8230)
@@ -128,52 +128,75 @@
     return false;
 }
 
-void FeaturePropRenderer::ProcessPolygon(LineBuffer*   lb,
-                                         RS_FillStyle& fill)
+void FeaturePropRenderer::GetGeometryBounds(const LineBuffer* lb, RS_Bounds& bounds)
 {
-    if (!m_bIncludeFeatureBBOX)
-        return;
-
     const RS_Bounds& featBounds = lb->bounds();
-    Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
+    
+    bounds.minx = featBounds.minx;
+    bounds.miny = featBounds.miny;
+    bounds.maxx = featBounds.maxx;
+    bounds.maxy = featBounds.maxy;
+
+    //printf("Current bounds: [%f, %f, %f, %f]\n", bounds.minx, bounds.miny, bounds.maxx, bounds.maxy);
+
+    if (m_currentTransform)
+    {
+        double minx = bounds.minx;
+        double miny = bounds.miny;
+        double maxx = bounds.maxx;
+        double maxy = bounds.maxy;
+
+        m_currentTransform->TransformExtent(minx, miny, maxx, maxy);
+        
+        bounds.minx = minx;
+        bounds.miny = miny;
+        bounds.maxx = maxx;
+        bounds.maxy = maxy;
+
+        //printf("Transformed bounds: [%f, %f, %f, %f]\n", bounds.minx, bounds.miny, bounds.maxx, bounds.maxy);
+    }
+}
+
+void FeaturePropRenderer::SetBBOXProperty(const RS_Bounds& bounds, MgStringProperty* bbox)
+{
     STRING val;
     STRING buf;
-    MgUtil::DoubleToString(featBounds.minx, buf);
+    MgUtil::DoubleToString(bounds.minx, buf);
     val += buf;
-    MgUtil::DoubleToString(featBounds.miny, buf);
+    MgUtil::DoubleToString(bounds.miny, buf);
     val += L" ";
     val += buf;
-    MgUtil::DoubleToString(featBounds.maxx, buf);
+    MgUtil::DoubleToString(bounds.maxx, buf);
     val += L" ";
     val += buf;
-    MgUtil::DoubleToString(featBounds.maxy, buf);
+    MgUtil::DoubleToString(bounds.maxy, buf);
     val += L" ";
     val += buf;
     bbox->SetValue(val);
 }
 
+void FeaturePropRenderer::ProcessPolygon(LineBuffer*   lb,
+                                         RS_FillStyle& fill)
+{
+    if (!m_bIncludeFeatureBBOX)
+        return;
+
+    RS_Bounds fbounds(0.0, 0.0, 0.0, 0.0);
+    GetGeometryBounds(lb, fbounds);
+    Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
+    SetBBOXProperty(fbounds, bbox);
+}
+
 void FeaturePropRenderer::ProcessPolyline(LineBuffer*    lb,
                                           RS_LineStroke& lsym)
 {
     if (!m_bIncludeFeatureBBOX)
         return;
 
-    const RS_Bounds& featBounds = lb->bounds();
+    RS_Bounds fbounds(0.0, 0.0, 0.0, 0.0);
+    GetGeometryBounds(lb, fbounds);
     Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
-    STRING val;
-    STRING buf;
-    MgUtil::DoubleToString(featBounds.minx, buf);
-    val += buf;
-    MgUtil::DoubleToString(featBounds.miny, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxx, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxy, buf);
-    val += L" ";
-    val += buf;
-    bbox->SetValue(val);
+    SetBBOXProperty(fbounds, bbox);
 }
 
 void FeaturePropRenderer::ProcessMarker(LineBuffer*   lb,
@@ -185,22 +208,10 @@
         return;
 
     //Should we inflate this a bit to represent an actual box?
-    const RS_Bounds& featBounds = lb->bounds();
+    RS_Bounds fbounds(0.0, 0.0, 0.0, 0.0);
+    GetGeometryBounds(lb, fbounds);
     Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
-    STRING val;
-    STRING buf;
-    MgUtil::DoubleToString(featBounds.minx, buf);
-    val += buf;
-    MgUtil::DoubleToString(featBounds.miny, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxx, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxy, buf);
-    val += L" ";
-    val += buf;
-    bbox->SetValue(val);
+    SetBBOXProperty(fbounds, bbox);
 }
 
 void FeaturePropRenderer::ProcessPoint(SE_ApplyContext* ctx,
@@ -211,22 +222,10 @@
         return;
 
     //Should we inflate this a bit to represent an actual box?
-    const RS_Bounds& featBounds = ctx->geometry->bounds();
+    RS_Bounds fbounds(0.0, 0.0, 0.0, 0.0);
+    GetGeometryBounds(ctx->geometry, fbounds);
     Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
-    STRING val;
-    STRING buf;
-    MgUtil::DoubleToString(featBounds.minx, buf);
-    val += buf;
-    MgUtil::DoubleToString(featBounds.miny, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxx, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxy, buf);
-    val += L" ";
-    val += buf;
-    bbox->SetValue(val);
+    SetBBOXProperty(fbounds, bbox);
 }
 
 void FeaturePropRenderer::ProcessLine(SE_ApplyContext* ctx,
@@ -236,22 +235,10 @@
         return;
 
     //Should we inflate this a bit to represent an actual box?
-    const RS_Bounds& featBounds = ctx->geometry->bounds();
+    RS_Bounds fbounds(0.0, 0.0, 0.0, 0.0);
+    GetGeometryBounds(ctx->geometry, fbounds);
     Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
-    STRING val;
-    STRING buf;
-    MgUtil::DoubleToString(featBounds.minx, buf);
-    val += buf;
-    MgUtil::DoubleToString(featBounds.miny, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxx, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxy, buf);
-    val += L" ";
-    val += buf;
-    bbox->SetValue(val);
+    SetBBOXProperty(fbounds, bbox);
 }
 
 void FeaturePropRenderer::ProcessArea(SE_ApplyContext* ctx,
@@ -261,20 +248,8 @@
         return;
 
     //Should we inflate this a bit to represent an actual box?
-    const RS_Bounds& featBounds = ctx->geometry->bounds();
+    RS_Bounds fbounds(0.0, 0.0, 0.0, 0.0);
+    GetGeometryBounds(ctx->geometry, fbounds);
     Ptr<MgStringProperty> bbox = dynamic_cast<MgStringProperty*>(m_currentFeature->GetItem(SPECIAL_PROP_BOUNDING_BOX));
-    STRING val;
-    STRING buf;
-    MgUtil::DoubleToString(featBounds.minx, buf);
-    val += buf;
-    MgUtil::DoubleToString(featBounds.miny, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxx, buf);
-    val += L" ";
-    val += buf;
-    MgUtil::DoubleToString(featBounds.maxy, buf);
-    val += L" ";
-    val += buf;
-    bbox->SetValue(val);
+    SetBBOXProperty(fbounds, bbox);
 }

Modified: trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.h
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.h	2014-06-17 01:53:37 UTC (rev 8229)
+++ trunk/MgDev/Server/src/Services/Rendering/FeaturePropRenderer.h	2014-06-17 02:49:45 UTC (rev 8230)
@@ -71,6 +71,9 @@
     virtual void ProcessArea(SE_ApplyContext* ctx,
                              SE_RenderAreaStyle* style);
 
+    void GetGeometryBounds(const LineBuffer* lb, RS_Bounds& bounds);
+    void SetBBOXProperty(const RS_Bounds& bounds, MgStringProperty* bbox);
+
     MgBatchPropertyCollection* GetProperties()
     {
         return SAFE_ADDREF(m_featprops);

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2014-06-17 01:53:37 UTC (rev 8229)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2014-06-17 02:49:45 UTC (rev 8230)
@@ -1432,6 +1432,8 @@
                     }
 
                     selRenderer->StartLayer(&layerinfo, &fcinfo);
+                    //Pass current layer xformer to renderer so it can transform any bbox data
+                    selRenderer->SetLayerToMapTransform(xformer);
                     ds.StylizeVectorLayer(vl, selRenderer, rsrdr.get(), NULL, scale, StylizeThatMany, selRenderer);
 
                     // Clear the readers in case they are reused below



More information about the mapguide-commits mailing list