[mapguide-commits] r9233 - in sandbox/jng/coordsys_mapagent: Common/MapGuideCommon/Services Common/PlatformBase/Services Server/src/Services/Feature UnitTest/WebTier/MapAgent/MapAgentForms Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Sep 12 06:55:04 PDT 2017


Author: jng
Date: 2017-09-12 06:55:03 -0700 (Tue, 12 Sep 2017)
New Revision: 9233

Modified:
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.cpp
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.h
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.h
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp
   sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.h
   sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.cpp
   sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.h
   sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/Reader.h
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.cpp
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.h
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.cpp
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.h
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.cpp
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.h
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.cpp
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.h
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.cpp
   sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.h
   sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectaggregatesform.html
   sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectfeaturesform.html
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.cpp
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.h
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.cpp
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.h
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.cpp
   sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.h
Log:
Add support for TRANSFORMTO for the following mapagent operations:

 - SELECTFEATURES
 - SELECTAGGREGATES

TRANSFORMTO is a CS-Map code for a coordinate system to transform any geometry data returned by any of the above operations to.

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -687,7 +687,7 @@
     BodyStartUtf8(str);
     while ( this->ReadNext() )
     {
-        CurrentToStringUtf8(str);
+        CurrentToStringUtf8(str, NULL);
     }
     BodyEndUtf8(str);
     ResponseEndUtf8(str);
@@ -740,7 +740,7 @@
     }
 }
 
-void MgProxyDataReader::CurrentToStringUtf8(string& str)
+void MgProxyDataReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     if (NULL != (MgBatchPropertyCollection*)m_set)
     {
@@ -748,6 +748,19 @@
         INT32 cnt = propCol->GetCount();
         if (propCol != NULL && cnt > 0)
         {
+            //If xform given, attach it to any geometry properties
+            if (NULL != xform)
+            {
+                for (INT32 i = 0; i < cnt; i++) 
+                {
+                    Ptr<MgProperty> prop = propCol->GetItem(i);
+                    if (prop->GetPropertyType() == MgPropertyType::Geometry) 
+                    {
+                        MgGeometryProperty* geomProp = static_cast<MgGeometryProperty*>(prop.p);
+                        geomProp->AttachTransform(xform);
+                    }
+                }
+            }
             str += "<PropertyCollection>";
             propCol->ToXml(str, false);
             str += "</PropertyCollection>";

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyDataReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -593,7 +593,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -838,7 +838,7 @@
         BodyStartUtf8(str);
         while ( this->ReadNext() )
         {
-            CurrentToStringUtf8(str);
+            CurrentToStringUtf8(str, NULL);
         }
         BodyEndUtf8(str);
         ResponseEndUtf8(str);
@@ -893,7 +893,7 @@
     }
 }
 
-void MgProxyFeatureReader::CurrentToStringUtf8(string& str)
+void MgProxyFeatureReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     if (NULL != (MgFeatureSet*)m_set)
     {
@@ -901,6 +901,19 @@
         INT32 cnt = propCol->GetCount();
         if (propCol != NULL && cnt > 0)
         {
+            //If xform given, attach it to any geometry properties
+            if (NULL != xform)
+            {
+                for (INT32 i = 0; i < cnt; i++)
+                {
+                    Ptr<MgProperty> prop = propCol->GetItem(i);
+                    if (prop->GetPropertyType() == MgPropertyType::Geometry)
+                    {
+                        MgGeometryProperty* geomProp = static_cast<MgGeometryProperty*>(prop.p);
+                        geomProp->AttachTransform(xform);
+                    }
+                }
+            }
             propCol->ToFeature(str);
         }
     }

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyFeatureReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -566,7 +566,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -773,7 +773,7 @@
         BodyStartUtf8(str);
         while ( this->ReadNext() )
         {
-            CurrentToStringUtf8(str);
+            CurrentToStringUtf8(str, NULL);
         }
         BodyEndUtf8(str);
         ResponseEndUtf8(str);
@@ -828,7 +828,7 @@
     }
 }
 
-void MgProxyGwsFeatureReader::CurrentToStringUtf8(string& str)
+void MgProxyGwsFeatureReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     if (NULL != (MgFeatureSet*)m_set)
     {
@@ -836,6 +836,19 @@
         INT32 cnt = propCol->GetCount();
         if (propCol != NULL && cnt > 0)
         {
+            //If xform given, attach it to any geometry properties
+            if (NULL != xform)
+            {
+                for (INT32 i = 0; i < cnt; i++)
+                {
+                    Ptr<MgProperty> prop = propCol->GetItem(i);
+                    if (prop->GetPropertyType() == MgPropertyType::Geometry)
+                    {
+                        MgGeometryProperty* geomProp = static_cast<MgGeometryProperty*>(prop.p);
+                        geomProp->AttachTransform(xform);
+                    }
+                }
+            }
             propCol->ToFeature(str);
         }
     }

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -540,7 +540,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -685,7 +685,7 @@
     BodyStartUtf8(str);
     while ( this->ReadNext() )
     {
-        CurrentToStringUtf8(str);
+        CurrentToStringUtf8(str, NULL);
     }
     BodyEndUtf8(str);
     ResponseEndUtf8(str);
@@ -738,7 +738,7 @@
     }
 }
 
-void MgProxySqlDataReader::CurrentToStringUtf8(string& str)
+void MgProxySqlDataReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     if (NULL != (MgBatchPropertyCollection*)m_set)
     {
@@ -746,6 +746,19 @@
         INT32 cnt = propCol->GetCount();
         if (propCol != NULL && cnt > 0)
         {
+            //If xform given, attach it to any geometry properties
+            if (NULL != xform)
+            {
+                for (INT32 i = 0; i < cnt; i++)
+                {
+                    Ptr<MgProperty> prop = propCol->GetItem(i);
+                    if (prop->GetPropertyType() == MgPropertyType::Geometry)
+                    {
+                        MgGeometryProperty* geomProp = static_cast<MgGeometryProperty*>(prop.p);
+                        geomProp->AttachTransform(xform);
+                    }
+                }
+            }
             propCol->ToRow(str);
         }
     }

Modified: sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/MapGuideCommon/Services/ProxySqlDataReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -563,7 +563,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -47,6 +47,7 @@
 MgGeometryProperty::MgGeometryProperty()
 {
     m_value = NULL;
+    m_xform = NULL;
 }
 
 /////////////////////////////////////////////////////////////////
@@ -133,7 +134,7 @@
             if (byteReader != NULL)
             {
                 MgAgfReaderWriter agfReader;
-                Ptr<MgGeometry> geom = agfReader.Read(byteReader);
+                Ptr<MgGeometry> geom = agfReader.Read(byteReader, m_xform);
 
                 // geom->ToXml(str); // TODO: we need this method
                 STRING awktStr = L"";
@@ -195,3 +196,8 @@
 
     m_value = stream->GetStream();
 }
+
+void MgGeometryProperty::AttachTransform(MgTransform* xform)
+{
+    m_xform = SAFE_ADDREF(xform);
+}
\ No newline at end of file

Modified: sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/GeometryProperty.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -170,6 +170,15 @@
     ///
     virtual void Deserialize(MgStream* stream);
 
+    //////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Attaches the given transform.
+    ///
+    /// \param xform
+    /// Transform
+    ///
+    void AttachTransform(MgTransform* xform);
+
 protected:
 
     /////////////////////////////////////////////////////////////////
@@ -200,6 +209,7 @@
 private:
 
     Ptr<MgByteReader>   m_value;
+    Ptr<MgTransform>    m_xform;
 
 CLASS_ID:
     static const INT32 m_cls_id = PlatformBase_FeatureService_GeometryProperty;

Modified: sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/Reader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/Reader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Common/PlatformBase/Services/Reader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -1216,7 +1216,7 @@
     /// \param str
     /// Destination string.
     ///
-    virtual void CurrentToStringUtf8(string& str) = 0;
+    virtual void CurrentToStringUtf8(string& str, MgTransform* xform) = 0;
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -1554,7 +1554,7 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
-void MgServerDataReader::CurrentToStringUtf8(string& str)
+void MgServerDataReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     throw new MgInvalidOperationException(L"MgServerDataReader.CurrentToStringUtf8",
         __LINE__, __WFILE__, NULL, L"", NULL);

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerDataReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -514,7 +514,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// <summary>

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -974,7 +974,7 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
-void MgServerFeatureReader::CurrentToStringUtf8(string& str)
+void MgServerFeatureReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     throw new MgInvalidOperationException(L"MgServerFeatureReader.CurrentToStringUtf8",
         __LINE__, __WFILE__, NULL, L"", NULL);

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerFeatureReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -479,7 +479,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// <summary>

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -1276,7 +1276,7 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
-void MgServerGwsFeatureReader::CurrentToStringUtf8(string& str)
+void MgServerGwsFeatureReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.CurrentToStringUtf8",
         __LINE__, __WFILE__, NULL, L"", NULL);

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerGwsFeatureReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -471,7 +471,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// <summary>

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -1394,7 +1394,7 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
-void MgServerSqlDataReader::CurrentToStringUtf8(string& str)
+void MgServerSqlDataReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
     throw new MgInvalidOperationException(L"MgServerSqlDataReader.CurrentToStringUtf8",
         __LINE__, __WFILE__, NULL, L"", NULL);

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/ServerSqlDataReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -489,7 +489,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// <summary>

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -378,9 +378,9 @@
     m_innerReader->BodyEndUtf8(str);
 }
 
-void MgTransformedGeometryFeatureReader::CurrentToStringUtf8(string& str)
+void MgTransformedGeometryFeatureReader::CurrentToStringUtf8(string& str, MgTransform* xform)
 {
-    m_innerReader->CurrentToStringUtf8(str);
+    m_innerReader->CurrentToStringUtf8(str, xform);
 }
 
 void MgTransformedGeometryFeatureReader::HeaderToStringUtf8(string& str)

Modified: sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Server/src/Services/Feature/TransformedGeometryFeatureReader.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -439,7 +439,7 @@
     /// \param str
     /// Destination string.
     ///
-    void CurrentToStringUtf8(string& str);
+    void CurrentToStringUtf8(string& str, MgTransform* xform);
 
     //////////////////////////////////////////////////////////////////
     /// <summary>

Modified: sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectaggregatesform.html
===================================================================
--- sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectaggregatesform.html	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectaggregatesform.html	2017-09-12 13:55:03 UTC (rev 9233)
@@ -39,6 +39,8 @@
                 Clean JSON: <input type="text" name="CLEAN" value="0" ID="TextClean">
             <p> Coordinate Precision (if requesting clean JSON):
                 <input type="text" name="PRECISION" value="7" size="10">
+            <p> Transform to (CS-Map code):
+                <input type="text" name="TRANSFORMTO">
             <p>
         <input type="submit" value="Submit" onclick="SetActionTarget()"> <input type="reset">
         </form>

Modified: sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectfeaturesform.html
===================================================================
--- sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectfeaturesform.html	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/UnitTest/WebTier/MapAgent/MapAgentForms/selectfeaturesform.html	2017-09-12 13:55:03 UTC (rev 9233)
@@ -39,6 +39,8 @@
                 Clean JSON: <input type="text" name="CLEAN" value="0" ID="TextClean">
             <p> Coordinate Precision (if requesting clean JSON):
                 <input type="text" name="PRECISION" value="7" size="10">
+            <p> Transform to (CS-Map code):
+                <input type="text" name="TRANSFORMTO">
             <p>
             <input type="submit" value="Submit" onclick="SetActionTarget()"> <input type="reset">
         </form>

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -55,6 +55,11 @@
             m_bEnablePrecision = true;
         }
     }
+    // Get transform flag (TRANSFORMTO). Only recognize this flag for 3.3.0 and above
+    if (m_userInfo->GetApiVersion() >= MG_API_VERSION(3, 3, 0))
+    {
+        m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
+    }
 }
 
 /// <summary>
@@ -123,8 +128,17 @@
 
     Ptr<MgFeatureReader> featureReader = service->SelectFeatures(&resId, m_className, qryOptions);
     //MgByteSource owns this and will clean it up when done
-    ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(featureReader, m_responseFormat, m_bCleanJson, m_bEnablePrecision, m_precision);
+    Ptr<MgTransform> xform;
+    if (!m_transformTo.empty())
+    {
+        STRING schemaName;
+        STRING className;
+        MgUtil::ParseQualifiedClassName(m_className, schemaName, className);
 
+        xform = MgHttpUtil::GetTransform(service, &resId, schemaName, className, m_transformTo);
+    }
+    ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(featureReader, m_responseFormat, m_bCleanJson, m_bEnablePrecision, m_precision, xform);
+
     Ptr<MgByteSource> byteSource = new MgByteSource(bsImpl);
     byteSource->SetMimeType(m_responseFormat);
     Ptr<MgByteReader> byteReader = byteSource->GetReader();

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeatures.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -48,6 +48,7 @@
     STRING  m_className;
     INT32   m_precision;
     bool    m_bEnablePrecision;
+    STRING  m_transformTo;
 };
 
 #endif  // _FS_SELECT_FEATURES_H

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -65,6 +65,12 @@
             m_bEnablePrecision = true;
         }
     }
+
+    // Get transform flag (TRANSFORMTO). Only recognize this flag for 3.3.0 and above
+    if (m_userInfo->GetApiVersion() >= MG_API_VERSION(3, 3, 0))
+    {
+        m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
+    }
 }
 
 /// <summary>
@@ -133,8 +139,17 @@
 
     Ptr<MgDataReader> dataReader = service->SelectAggregate(&resId, m_className, qryOptions);
     //MgByteSource owns this and will clean it up when done
-    ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(dataReader, m_responseFormat, m_bCleanJson, m_bEnablePrecision, m_precision);
+    Ptr<MgTransform> xform;
+    if (!m_transformTo.empty())
+    {
+        STRING schemaName;
+        STRING className;
+        MgUtil::ParseQualifiedClassName(m_className, schemaName, className);
 
+        xform = MgHttpUtil::GetTransform(service, &resId, schemaName, className, m_transformTo);
+    }
+    ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(dataReader, m_responseFormat, m_bCleanJson, m_bEnablePrecision, m_precision, xform);
+
     Ptr<MgByteSource> byteSource = new MgByteSource(bsImpl);
     byteSource->SetMimeType(m_responseFormat);
     Ptr<MgByteReader> byteReader = byteSource->GetReader();

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -51,6 +51,7 @@
     INT32   m_operation;
     INT32   m_precision;
     bool    m_bEnablePrecision;
+    STRING  m_transformTo;
 };
 
 #endif  // _FS_SELECT_FEATURES_SPATIALLY_H

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -86,3 +86,48 @@
         }
     }
 }
+
+MgTransform* MgHttpUtil::GetTransform(MgFeatureService* featSvc, MgResourceIdentifier* resId, CREFSTRING schemaName, CREFSTRING className, CREFSTRING transformTo)
+{
+    Ptr<MgTransform> transform;
+
+    MG_HTTP_HANDLER_TRY()
+
+    Ptr<MgCoordinateSystemFactory> factory = new MgCoordinateSystemFactory();
+    STRING targetWkt = factory->ConvertCoordinateSystemCodeToWkt(transformTo);
+    Ptr<MgClassDefinition> clsDef = featSvc->GetClassDefinition(resId, schemaName, className);
+    //Has a designated geometry property, use it's spatial context
+    if (!clsDef->GetDefaultGeometryPropertyName().empty())
+    {
+        Ptr<MgPropertyDefinitionCollection> props = clsDef->GetProperties();
+        INT32 idx = props->IndexOf(clsDef->GetDefaultGeometryPropertyName());
+        if (idx >= 0) 
+        {
+            Ptr<MgPropertyDefinition> pd = props->GetItem(idx);
+            if (pd->GetPropertyType() == MgFeaturePropertyType::GeometricProperty)
+            {
+                MgGeometricPropertyDefinition* geomProp = static_cast<MgGeometricPropertyDefinition*>(pd.p);
+                STRING scName = geomProp->GetSpatialContextAssociation();
+                Ptr<MgSpatialContextReader> scReader = featSvc->GetSpatialContexts(resId, false);
+                while (scReader->ReadNext()) 
+                {
+                    if (scReader->GetName() == scName) 
+                    {
+                        if (scReader->GetCoordinateSystemWkt() != targetWkt) 
+                        {
+                            Ptr<MgCoordinateSystem> targetCs = factory->CreateFromCode(transformTo);
+                            Ptr<MgCoordinateSystem> sourceCs = factory->Create(scReader->GetCoordinateSystemWkt());
+                            transform = factory->GetTransform(sourceCs, targetCs);
+                            break;
+                        }
+                    }
+                }
+                scReader->Close();
+            }
+        }
+    }
+
+    MG_HTTP_HANDLER_CATCH_AND_THROW(L"MgHttpUtil::GetTransform")
+
+    return transform.Detach();
+}
\ No newline at end of file

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/HttpUtil.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -73,6 +73,8 @@
     ~MgHttpUtil();
 
     static void LogException(MgException* exception);
+
+    static MgTransform* GetTransform(MgFeatureService* featSvc, MgResourceIdentifier* resId, CREFSTRING schemaName, CREFSTRING className, CREFSTRING transformTo);
 };
 
 #endif

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.cpp
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.cpp	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.cpp	2017-09-12 13:55:03 UTC (rev 9233)
@@ -17,7 +17,7 @@
 #include "ReaderByteSourceImpl.h"
 #include "PlatformBase.h"
 
-MgReaderByteSourceImpl::MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, bool bEnablePrecision, INT32 precision)
+MgReaderByteSourceImpl::MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, bool bEnablePrecision, INT32 precision, MgTransform* xform)
 {
     m_reader = SAFE_ADDREF(reader);
     m_format = format;
@@ -29,6 +29,7 @@
     m_bCleanJson = bCleanJson;
     m_bEnablePrecision = bEnablePrecision;
     m_precision = precision;
+    m_xform = SAFE_ADDREF(xform);
 }
 
 MgReaderByteSourceImpl::~MgReaderByteSourceImpl()
@@ -38,6 +39,7 @@
     m_reader->Close();
     MG_CATCH_AND_RELEASE()
     m_reader = NULL;
+    m_xform = NULL;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -175,11 +177,11 @@
                     if (m_reader->GetReaderType() == MgReaderType::FeatureReader)
                     {
                         MgFeatureReader* fr = static_cast<MgFeatureReader*>(m_reader.p);
-                        sGeoJson = geoJsonWriter.FeatureToGeoJson(fr, NULL);
+                        sGeoJson = geoJsonWriter.FeatureToGeoJson(fr, m_xform);
                     }
                     else 
                     {
-                        sGeoJson = geoJsonWriter.FeatureToGeoJson(m_reader, NULL, L"", L"");
+                        sGeoJson = geoJsonWriter.FeatureToGeoJson(m_reader, m_xform, L"", L"");
                     }
 
                     if (!m_bFirstRecord)
@@ -194,7 +196,7 @@
                 }
                 else
                 {
-                    m_reader->CurrentToStringUtf8(buf);
+                    m_reader->CurrentToStringUtf8(buf, m_xform);
                     //The body is a valid full XML element, so no need for gymnastics like its
                     //surrounding elements
                     MgXmlJsonConvert convert;
@@ -230,7 +232,7 @@
 #ifdef _DEBUG
                 m_buf += "<!-- BEGIN RECORD -->\n";
 #endif
-                m_reader->CurrentToStringUtf8(m_buf);
+                m_reader->CurrentToStringUtf8(m_buf, m_xform);
 #ifdef _DEBUG
                 m_buf += "<!-- END RECORD -->\n";
 #endif

Modified: sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.h
===================================================================
--- sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.h	2017-08-21 07:14:10 UTC (rev 9232)
+++ sandbox/jng/coordsys_mapagent/Web/src/HttpHandler/ReaderByteSourceImpl.h	2017-09-12 13:55:03 UTC (rev 9233)
@@ -29,7 +29,7 @@
     DECLARE_CLASSNAME(MgReaderByteSourceImpl)
 
 public:
-    MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, bool bEnablePrecision, INT32 precision);
+    MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, bool bEnablePrecision, INT32 precision, MgTransform* xform);
     virtual ~MgReaderByteSourceImpl();
 
     ///////////////////////////////////////////////////////////////////////////
@@ -84,6 +84,7 @@
     INT32 ReadInternalBuffer(BYTE_ARRAY_OUT buffer, INT32 fromIndex, INT32 length);
 
     Ptr<MgReader> m_reader;
+	Ptr<MgTransform> m_xform;
     STRING m_format;
     bool m_bCleanJson;
     bool m_bReadHeader;



More information about the mapguide-commits mailing list