[mapguide-commits] r9223 - in sandbox/jng/geoprocessing: UnitTest/WebTier/MapAgent/MapAgentForms Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Jun 25 03:38:15 PDT 2017


Author: jng
Date: 2017-06-25 03:38:15 -0700 (Sun, 25 Jun 2017)
New Revision: 9223

Added:
   sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/boundaryform.html
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h
Modified:
   sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/geoprocessingapi.html
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj.filters
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandlerBuild.cpp
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpRequest.cpp
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.cpp
   sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.h
Log:
Add the following operations to the mapagent:

 - GEO.BOUNDARY
   - Returns a geometry that represents the boundary of the given input geometry (in WKT). This is a straight pass-through to MgGeometry::Boundary()

With this commit, the mapagent has the same API surface as the MgGeometry API

Added: sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/boundaryform.html
===================================================================
--- sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/boundaryform.html	                        (rev 0)
+++ sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/boundaryform.html	2017-06-25 10:38:15 UTC (rev 9223)
@@ -0,0 +1,33 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<script type="text/javascript" src="setactiontarget.js" >
+</script>
+</head>
+<body>
+<form name="input" action="" method="get">
+<b>Operation:</b>
+<input type="text" name="OPERATION" value="GEO.BOUNDARY" size="50">
+<p> Version:
+<input type="text" name="VERSION" value="3.3.0" size="10">
+<p> Locale:
+<input type="text" name="LOCALE" value="en" size="10">
+<p> Client Agent:
+<input type="text" name="CLIENTAGENT" value="MapGuide Developer" size="100">
+<p> Geometry (WKT):
+<input type="text" name="GEOMETRY" value="" size="100">
+<p> Output Format:
+<select name="FORMAT">
+    <option value="WKT">Geometry Well-Known Text</option>
+    <option value="GEOJSON">GeoJSON</option>
+</select>
+<p> Input Coordinate System (CS-Map Code):
+<input type="text" name="COORDINATESYSTEM" value="" size="10">
+<p> Output Coordinate System (CS-Map Code):
+<input type="text" name="TRANSFORMTO" value="" size="10">
+<p>
+<input type="submit" value="Submit" onclick="SetActionTarget()"> <input type="reset">
+</form>
+</body>
+</html>
+<html>

Modified: sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/geoprocessingapi.html
===================================================================
--- sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/geoprocessingapi.html	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/UnitTest/WebTier/MapAgent/MapAgentForms/geoprocessingapi.html	2017-06-25 10:38:15 UTC (rev 9223)
@@ -9,6 +9,8 @@
     <body>
         <UL>
             <LI>
+                <A href="boundaryform.html" target="showform">Boundary</A>
+            <LI>
                 <A href="bufferform.html" target="showform">Buffer</A>
             <LI>
                 <A href="convexhullform.html" target="showform">ConvexHull</A>

Added: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp	                        (rev 0)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp	2017-06-25 10:38:15 UTC (rev 9223)
@@ -0,0 +1,104 @@
+//
+//  Copyright (C) 2004-2017 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "HttpHandler.h"
+#include "HttpGeoBoundary.h"
+
+HTTP_IMPLEMENT_CREATE_OBJECT(MgHttpGeoBoundary)
+
+MgHttpGeoBoundary::MgHttpGeoBoundary(MgHttpRequest* hRequest)
+{
+    InitializeCommonParameters(hRequest);
+    Ptr<MgHttpRequestParam> params = hRequest->GetRequestParam();
+    m_geomWKT = params->GetParameterValue(MgHttpResourceStrings::reqFeatGeometry);
+    m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
+    m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
+    m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
+}
+
+void MgHttpGeoBoundary::Execute(MgHttpResponse & hResponse)
+{
+    Ptr<MgHttpResult> hResult = hResponse.GetResult();
+
+    MG_HTTP_HANDLER_TRY()
+
+        // Check common parameters
+        ValidateCommonParameters();
+
+    if (m_geomWKT.empty())
+    {
+        MgStringCollection arguments;
+        arguments.Add(MgHttpResourceStrings::reqFeatGeometry);
+        arguments.Add(MgResources::BlankArgument);
+
+        throw new MgInvalidArgumentException(L"MgHttpGeoBoundary.Execute",
+            __LINE__, __WFILE__, &arguments, L"MgStringEmpty", NULL);
+    }
+
+    Ptr<MgWktReaderWriter> wktRw = new MgWktReaderWriter();
+    Ptr<MgGeometry> input = wktRw->Read(m_geomWKT);
+    Ptr<MgGeometry> result = input->ConvexHull();
+
+    if (!m_transformTo.empty())
+    {
+        Ptr<MgCoordinateSystemFactory> csFactory = new MgCoordinateSystemFactory();
+        Ptr<MgCoordinateSystem> cs = csFactory->CreateFromCode(m_coordinateSystem);
+        Ptr<MgCoordinateSystem> target = csFactory->CreateFromCode(m_transformTo);
+        Ptr<MgCoordinateSystemTransform> xform = csFactory->GetTransform(cs, target);
+        Ptr<MgGeometry> xGeom = (MgGeometry*)result->Transform(xform);
+
+        result = xGeom;
+    }
+
+    if (m_format == L"WKT")
+    {
+        STRING wkt = wktRw->Write(result);
+        Ptr<MgHttpPrimitiveValue> value = new MgHttpPrimitiveValue(wkt);
+        hResult->SetResultObject(value, MgMimeType::Text);
+    }
+    else if (m_format == L"GEOJSON")
+    {
+        MgGeoJsonWriter gw;
+        STRING geoJson = gw.GeometryToGeoJson(result);
+
+        std::string mbGeoJson;
+        MgUtil::WideCharToMultiByte(geoJson, mbGeoJson);
+
+        Ptr<MgByteSource> byteSource = new MgByteSource((BYTE_ARRAY_IN)mbGeoJson.c_str(), (INT32)mbGeoJson.length());
+        byteSource->SetMimeType(MgMimeType::Json);
+        Ptr<MgByteReader> byteReader = byteSource->GetReader();
+
+        hResult->SetResultObject(byteReader, byteReader->GetMimeType());
+    }
+
+    MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpGeoBoundary.Execute")
+}
+
+void MgHttpGeoBoundary::ValidateOperationVersion()
+{
+    MG_HTTP_HANDLER_TRY()
+
+        // There are multiple supported versions
+        INT32 version = m_userInfo->GetApiVersion();
+    if (version != MG_API_VERSION(3, 3, 0))
+    {
+        throw new MgInvalidOperationVersionException(
+            L"MgHttpGeoBoundary.ValidateOperationVersion", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    MG_HTTP_HANDLER_CATCH_AND_THROW(L"MgHttpGeoBoundary.ValidateOperationVersion");
+}

Added: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h	                        (rev 0)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h	2017-06-25 10:38:15 UTC (rev 9223)
@@ -0,0 +1,63 @@
+//
+//  Copyright (C) 2004-2017 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_HTTP_GEO_BOUNDARY_H
+#define MG_HTTP_GEO_BOUNDARY_H
+
+class MgHttpGeoBoundary : public MgHttpRequestResponseHandler
+{
+    HTTP_DECLARE_CREATE_OBJECT()
+
+public:
+    /// <summary>
+    /// Initializes the common parameters of the request.
+    /// </summary>
+    /// <param name="name">Input
+    /// MgHttpRequest
+    /// This contains all the parameters of the request.
+    /// </param>
+    /// <returns>
+    /// nothing
+    /// </returns>
+    MgHttpGeoBoundary(MgHttpRequest *hRequest);
+
+    /// <summary>
+    /// Executes the specific request.
+    /// </summary>
+    /// <param name="hResponse">Input
+    /// This contains the response (including MgHttpResult and StatusCode) from the server.
+    /// </param>
+    void Execute(MgHttpResponse& hResponse);
+
+    /// <summary>
+    /// Returns the classification of this request/response handler
+    /// </summary>
+    /// <returns>
+    /// Classification of handler
+    /// </returns>
+    MgRequestClassification GetRequestClassification() { return MgHttpRequestResponseHandler::mrcViewer; }
+
+    virtual void ValidateOperationVersion();
+
+private:
+    STRING m_geomWKT;
+    STRING m_format;
+    STRING m_coordinateSystem;
+    STRING m_transformTo;
+};
+
+#endif

Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj	2017-06-25 10:38:15 UTC (rev 9223)
@@ -210,6 +210,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="HttpGeoBoundary.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="HttpGeoConvexHull.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -993,6 +999,7 @@
   <ItemGroup>
     <ClInclude Include="HttpApplyResourcePackage.h" />
     <ClInclude Include="HttpChangeResourceOwner.h" />
+    <ClInclude Include="HttpGeoBoundary.h" />
     <ClInclude Include="HttpGeoConvexHull.h" />
     <ClInclude Include="HttpCopyResource.h" />
     <ClInclude Include="HttpCreateRepository.h" />

Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj.filters
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj.filters	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandler.vcxproj.filters	2017-06-25 10:38:15 UTC (rev 9223)
@@ -413,6 +413,9 @@
     <ClCompile Include="HttpGeoTessellate.cpp">
       <Filter>GeoProcessing</Filter>
     </ClCompile>
+    <ClCompile Include="HttpGeoBoundary.cpp">
+      <Filter>GeoProcessing</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="HttpApplyResourcePackage.h">
@@ -808,6 +811,9 @@
     <ClInclude Include="HttpGeoTessellate.h">
       <Filter>GeoProcessing</Filter>
     </ClInclude>
+    <ClInclude Include="HttpGeoBoundary.h">
+      <Filter>GeoProcessing</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="HttpHandler.rc" />

Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandlerBuild.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandlerBuild.cpp	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpHandlerBuild.cpp	2017-06-25 10:38:15 UTC (rev 9223)
@@ -55,6 +55,7 @@
 #include "HttpEnumerateApplicationTemplates.cpp"
 #include "HttpEnumerateApplicationWidgets.cpp"
 #include "HttpEnumerateApplicationContainers.cpp"
+#include "HttpGeoBoundary.cpp"
 #include "HttpGeoBuffer.cpp"
 #include "HttpGeoBinaryOperation.cpp"
 #include "HttpGeoConvexHull.cpp"

Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpRequest.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpRequest.cpp	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpRequest.cpp	2017-06-25 10:38:15 UTC (rev 9223)
@@ -125,6 +125,7 @@
 #include "HttpCsIsValid.h"
 
 // Geo-Processing
+#include "HttpGeoBoundary.h"
 #include "HttpGeoBuffer.h"
 #include "HttpGeoBinaryOperation.h"
 #include "HttpGeoConvexHull.h"
@@ -441,6 +442,7 @@
     httpClassCreators[MgHttpResourceStrings::opEnumerateApplicationContainers] = MgHttpEnumerateApplicationContainers::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGetDefaultTileSizeX] = MgHttpGetDefaultTileSizeX::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGetDefaultTileSizeY] = MgHttpGetDefaultTileSizeY::CreateObject;
+    httpClassCreators[MgHttpResourceStrings::opGeoBoundary] = MgHttpGeoBoundary::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGeoBuffer] = MgHttpGeoBuffer::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGeoBinaryOperation] = MgHttpGeoBinaryOperation::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGeoConvexHull] = MgHttpGeoConvexHull::CreateObject;

Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.cpp	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.cpp	2017-06-25 10:38:15 UTC (rev 9223)
@@ -365,6 +365,7 @@
 const STRING MgHttpResourceStrings::opEnumerateApplicationContainers = L"ENUMERATEAPPLICATIONCONTAINERS";
 
 // Geo-Processing Operations
+const STRING MgHttpResourceStrings::opGeoBoundary = L"GEO.BOUNDARY";
 const STRING MgHttpResourceStrings::opGeoBuffer = L"GEO.BUFFER";
 const STRING MgHttpResourceStrings::opGeoConvexHull = L"GEO.CONVEXHULL";
 const STRING MgHttpResourceStrings::opGeoDistance = L"GEO.DISTANCE";

Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.h	2017-06-25 10:36:25 UTC (rev 9222)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpResourceStrings.h	2017-06-25 10:38:15 UTC (rev 9223)
@@ -369,6 +369,7 @@
     static const STRING opEnumerateApplicationContainers;
 
     // Geo-Processing Operations
+    static const STRING opGeoBoundary;
     static const STRING opGeoBuffer;
     static const STRING opGeoConvexHull;
     static const STRING opGeoDistance;



More information about the mapguide-commits mailing list