[mapguide-commits] r7708 - in sandbox/jng/getruntimemap: Common/MapGuideCommon/Services Server/src/Services/Mapping Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jul 31 07:31:37 PDT 2013


Author: jng
Date: 2013-07-31 07:31:37 -0700 (Wed, 31 Jul 2013)
New Revision: 7708

Added:
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.cpp
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.h
Modified:
   sandbox/jng/getruntimemap/Common/MapGuideCommon/Services/MappingService.h
   sandbox/jng/getruntimemap/Server/src/Services/Mapping/MappingOperationFactory.cpp
   sandbox/jng/getruntimemap/Server/src/Services/Mapping/OpDescribeRuntimeMap.cpp
   sandbox/jng/getruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj.filters
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandlerBuild.cpp
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpRequest.cpp
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp
   sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.h
Log:
Expose DESCRIBERUNTIMEMAP to the mapagent. Also fix up the server-end of this operation.

Modified: sandbox/jng/getruntimemap/Common/MapGuideCommon/Services/MappingService.h
===================================================================
--- sandbox/jng/getruntimemap/Common/MapGuideCommon/Services/MappingService.h	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Common/MapGuideCommon/Services/MappingService.h	2013-07-31 14:31:37 UTC (rev 7708)
@@ -725,7 +725,9 @@
         opIdGeneratePlot3           =  0x1111EE0A,
         opIdGenerateLegendImage     =  0x1111EE0D,
         opIdCreateRuntimeMap        =  0x1111EE0E,
-        opIdCreateRuntimeMap2       =  0x1111EE0F
+        opIdCreateRuntimeMap2       =  0x1111EE0F,
+        opIdDescribeRuntimeMap      =  0x1111EE10,
+        opIdDescribeRuntimeMap2     =  0x1111EE11
     };
 };
 /// \}

Modified: sandbox/jng/getruntimemap/Server/src/Services/Mapping/MappingOperationFactory.cpp
===================================================================
--- sandbox/jng/getruntimemap/Server/src/Services/Mapping/MappingOperationFactory.cpp	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Server/src/Services/Mapping/MappingOperationFactory.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -19,6 +19,7 @@
 #include "MappingOperationFactory.h"
 
 #include "OpCreateRuntimeMap.h"
+#include "OpDescribeRuntimeMap.h"
 #include "OpGenerateMap.h"
 #include "OpGenerateMapUpdate.h"
 #include "OpGeneratePlot.h"
@@ -220,6 +221,30 @@
         }
         break;
 
+    case MgMappingService::opIdDescribeRuntimeMap:
+        switch (VERSION_NO_PHASE(operationVersion))
+        {
+        case VERSION_SUPPORTED(2,6):
+            handler.reset(new MgOpDescribeRuntimeMap());
+            break;
+        default:
+            throw new MgInvalidOperationVersionException(
+                L"MgDrawingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+        break;
+
+    case MgMappingService::opIdDescribeRuntimeMap2:
+        switch (VERSION_NO_PHASE(operationVersion))
+        {
+        case VERSION_SUPPORTED(2,6):
+            handler.reset(new MgOpDescribeRuntimeMap());
+            break;
+        default:
+            throw new MgInvalidOperationVersionException(
+                L"MgDrawingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+        break;
+
     default:
         throw new MgInvalidOperationException(
             L"MgMappingOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);

Modified: sandbox/jng/getruntimemap/Server/src/Services/Mapping/OpDescribeRuntimeMap.cpp
===================================================================
--- sandbox/jng/getruntimemap/Server/src/Services/Mapping/OpDescribeRuntimeMap.cpp	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Server/src/Services/Mapping/OpDescribeRuntimeMap.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -71,8 +71,6 @@
         map->SetDelayedLoadResourceService(m_resourceService);
         Ptr<MgResourceIdentifier> resource = map->GetResourceId();
 
-        m_stream->GetString(targetMapName);
-        m_stream->GetString(sessionId);
         m_stream->GetString(iconFormat);
         m_stream->GetInt32(iconWidth);
         m_stream->GetInt32(iconHeight);

Modified: sandbox/jng/getruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp
===================================================================
--- sandbox/jng/getruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Server/src/Services/Mapping/ServerMappingService.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -1891,6 +1891,9 @@
 
     MG_SERVER_MAPPING_SERVICE_TRY()
 
+    if (m_svcResource == NULL)
+        InitializeResourceService();
+
     STRING sessionId = map->GetSessionId();
     STRING targetMapName = map->GetName();
     Ptr<MgResourceIdentifier> mapDefinition = map->GetMapDefinition();

Added: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.cpp
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.cpp	                        (rev 0)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -0,0 +1,128 @@
+//
+//  Copyright (C) 2004-2013 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 "HttpDescribeRuntimeMap.h"
+#include "VectorLayerDefinition.h"
+#include "PointTypeStyle.h"
+#include "AreaTypeStyle.h"
+#include "LineTypeStyle.h"
+#include "CompositeTypeStyle.h"
+
+#define REQUEST_LAYER_STRUCTURE         1 /* Request layer and group structure */
+#define REQUEST_LAYER_ICONS             2 /* Request layer scale and icon information */
+#define REQUEST_LAYER_FEATURE_SOURCE    4 /* Request information about a layer's feature source */
+
+HTTP_IMPLEMENT_CREATE_OBJECT(MgHttpDescribeRuntimeMap)
+
+/// <summary>
+/// Initializes the common parameters and parameters specific to this request.
+/// </summary>
+/// <param name="name">Input
+/// MgHttpRequest
+/// This contains all the parameters of the request.
+/// </param>
+/// <returns>
+/// nothing
+/// </returns>
+MgHttpDescribeRuntimeMap::MgHttpDescribeRuntimeMap(MgHttpRequest *hRequest)
+{
+    InitializeCommonParameters(hRequest);
+
+    Ptr<MgHttpRequestParam> params = hRequest->GetRequestParam();
+    m_mapName = params->GetParameterValue(MgHttpResourceStrings::reqMappingMapName);
+    STRING mask = params->GetParameterValue(MgHttpResourceStrings::reqMappingRequestedFeatures);
+    if (mask.empty())
+        m_requestDataMask = 0;
+    else
+        m_requestDataMask = MgUtil::StringToInt32(mask);
+    m_iconLimitPerScaleRange = 25;
+    STRING sIconsPerScaleRange = params->GetParameterValue(MgHttpResourceStrings::reqMappingIconsPerScaleRange);
+    if (!sIconsPerScaleRange.empty())
+    {
+        m_iconLimitPerScaleRange = MgUtil::StringToInt32(sIconsPerScaleRange);
+    }
+    m_iconFormat = MgImageFormats::Png;
+    m_iconWidth = 16;
+    m_iconHeight = 16;
+    STRING sIconFormat = params->GetParameterValue(MgHttpResourceStrings::reqMappingIconFormat);
+    if (!sIconFormat.empty())
+    {
+        m_iconFormat = sIconFormat;
+    }
+    STRING sIconWidth = params->GetParameterValue(MgHttpResourceStrings::reqMappingIconWidth);
+    if (!sIconWidth.empty())
+    {
+        m_iconWidth = MgUtil::StringToInt32(sIconWidth);
+    }
+    STRING sIconHeight = params->GetParameterValue(MgHttpResourceStrings::reqMappingIconHeight);
+    if (!sIconHeight.empty())
+    {
+        m_iconHeight = MgUtil::StringToInt32(sIconHeight);
+    }
+}
+
+/// <summary>
+/// Executes the specific request.
+/// </summary>
+/// <returns>
+/// MgHttpResponse
+/// This contains the response (including MgHttpResult and StatusCode) from the server.
+/// </returns>
+void MgHttpDescribeRuntimeMap::Execute(MgHttpResponse& hResponse)
+{
+    Ptr<MgHttpResult> hResult = hResponse.GetResult();
+
+    MG_HTTP_HANDLER_TRY()
+
+    // Check common parameters
+    ValidateCommonParameters();
+
+    Ptr<MgByteReader> byteReader;
+
+    Ptr<MgMap> map = new MgMap(m_siteConn);
+    map->Open(m_mapName);
+
+    Ptr<MgMappingService> mappingService = (MgMappingService*)CreateService(MgServiceType::MappingService);
+    byteReader = mappingService->DescribeRuntimeMap(map, m_iconFormat, m_iconWidth, m_iconHeight, m_requestDataMask, m_iconLimitPerScaleRange);
+    // Convert to requested response format, if necessary
+    ProcessFormatConversion(byteReader);
+
+    hResult->SetResultObject(byteReader, byteReader->GetMimeType());
+
+    MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpDescribeRuntimeMap.Execute")
+}
+
+/// <summary>
+/// This method is responsible for checking if
+/// a valid version was given
+/// </summary>
+/// <returns>Returns nothing</returns>
+void MgHttpDescribeRuntimeMap::ValidateOperationVersion()
+{
+    MG_HTTP_HANDLER_TRY()
+
+    // There are multiple supported versions
+    INT32 version = m_userInfo->GetApiVersion();
+    if (version != MG_API_VERSION(2,6,0))
+    {
+        throw new MgInvalidOperationVersionException(
+        L"MgHttpDescribeRuntimeMap.ValidateOperationVersion", __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    MG_HTTP_HANDLER_CATCH_AND_THROW(L"MgHttpDescribeRuntimeMap.ValidateOperationVersion");
+}

Added: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.h
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.h	                        (rev 0)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpDescribeRuntimeMap.h	2013-07-31 14:31:37 UTC (rev 7708)
@@ -0,0 +1,72 @@
+//
+//  Copyright (C) 2004-2013 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 _HTTP_DESCRIBE_RUNTIME_MAP_
+#define _HTTP_DESCRIBE_RUNTIME_MAP_
+
+typedef std::map<STRING, MdfModel::LayerDefinition*> LayerDefinitionMap;
+
+class MgHttpDescribeRuntimeMap : 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>
+    MgHttpDescribeRuntimeMap(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; }
+
+    /// <summary>
+    /// This method is responsible for checking if
+    /// a valid version was given
+    /// </summary>
+    /// <returns>Returns nothing</returns>
+    virtual void ValidateOperationVersion();
+
+private:
+    STRING m_mapName;
+    STRING m_iconFormat;
+    INT32 m_iconWidth;
+    INT32 m_iconHeight;
+    INT32 m_requestDataMask;
+    INT32 m_iconLimitPerScaleRange;
+};
+
+#endif  // _HTTP_CREATE_RUNTIME_MAP_

Modified: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj	2013-07-31 14:31:37 UTC (rev 7708)
@@ -246,6 +246,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="HttpDescribeRuntimeMap.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="HttpEnumerateRepositories.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -951,6 +957,7 @@
     <ClInclude Include="HttpDeleteRepository.h" />
     <ClInclude Include="HttpDeleteResource.h" />
     <ClInclude Include="HttpDeleteResourceData.h" />
+    <ClInclude Include="HttpDescribeRuntimeMap.h" />
     <ClInclude Include="HttpEnumerateRepositories.h" />
     <ClInclude Include="HttpEnumerateResourceData.h" />
     <ClInclude Include="HttpEnumerateResourceReferences.h" />

Modified: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj.filters
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj.filters	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandler.vcxproj.filters	2013-07-31 14:31:37 UTC (rev 7708)
@@ -383,6 +383,9 @@
     <ClCompile Include="HttpCreateRuntimeMap.cpp">
       <Filter>Mapping Service</Filter>
     </ClCompile>
+    <ClCompile Include="HttpDescribeRuntimeMap.cpp">
+      <Filter>Mapping Service</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="HttpApplyResourcePackage.h">
@@ -754,6 +757,9 @@
     <ClInclude Include="HttpCreateRuntimeMap.h">
       <Filter>Mapping Service</Filter>
     </ClInclude>
+    <ClInclude Include="HttpDescribeRuntimeMap.h">
+      <Filter>Mapping Service</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="HttpHandler.rc" />

Modified: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandlerBuild.cpp
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandlerBuild.cpp	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpHandlerBuild.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -40,6 +40,7 @@
 #include "HttpDeleteResource.cpp"
 #include "HttpDeleteResourceData.cpp"
 #include "HttpDescribeDrawing.cpp"
+#include "HttpDescribeRuntimeMap.cpp"
 #include "HttpDescribeSchema.cpp"
 #include "HttpEnumerateDataStores.cpp"
 #include "HttpEnumerateDrawingLayers.cpp"

Modified: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpRequest.cpp
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpRequest.cpp	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpRequest.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -79,6 +79,7 @@
 #include "HttpGetPlot.h"
 #include "HttpGetLegendImage.h"
 #include "HttpGetFeatureSetEnvelope.h"
+#include "HttpDescribeRuntimeMap.h"
 
 // Http Rendering Service operations
 #include "HttpGetDynamicMapOverlayImage.h"
@@ -342,6 +343,7 @@
     //declare each Http class creator, associate the operation name with it
     //
     httpClassCreators[MgHttpResourceStrings::opCreateRuntimeMap] = MgHttpCreateRuntimeMap::CreateObject;
+    httpClassCreators[MgHttpResourceStrings::opDescribeRuntimeMap] = MgHttpDescribeRuntimeMap::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGetMap] = MgHttpGetMap::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGetMapUpdate] = MgHttpGetMapUpdate::CreateObject;
     httpClassCreators[MgHttpResourceStrings::opGetDrawing] = MgHttpGetDrawing::CreateObject;

Modified: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.cpp	2013-07-31 14:31:37 UTC (rev 7708)
@@ -189,6 +189,7 @@
 
 // Mapping Service Operation Requests
 const STRING MgHttpResourceStrings::opCreateRuntimeMap = L"CREATERUNTIMEMAP";
+const STRING MgHttpResourceStrings::opDescribeRuntimeMap = L"DESCRIBERUNTIMEMAP";
 const STRING MgHttpResourceStrings::opGetMap = L"GETMAP";
 const STRING MgHttpResourceStrings::opGetMapUpdate = L"GETMAPUPDATE";
 const STRING MgHttpResourceStrings::opGetPlot = L"GETPLOT";

Modified: sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.h
===================================================================
--- sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.h	2013-07-31 12:50:37 UTC (rev 7707)
+++ sandbox/jng/getruntimemap/Web/src/HttpHandler/HttpResourceStrings.h	2013-07-31 14:31:37 UTC (rev 7708)
@@ -298,6 +298,7 @@
 
     // Mapping services
     static const STRING opCreateRuntimeMap;
+    static const STRING opDescribeRuntimeMap;
     static const STRING opGetMap;
     static const STRING opGetMapUpdate;
     static const STRING opGetPlot;



More information about the mapguide-commits mailing list