[mapguide-commits] r9692 - sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jul 28 07:13:51 PDT 2020


Author: jng
Date: 2020-07-28 07:13:51 -0700 (Tue, 28 Jul 2020)
New Revision: 9692

Modified:
   sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/HttpWmsGetMap.cpp
   sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.cpp
   sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.h
Log:
Implement the OpenLayers viewer representation for WMS GetMap

Modified: sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/HttpWmsGetMap.cpp
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/HttpWmsGetMap.cpp	2020-07-28 14:12:57 UTC (rev 9691)
+++ sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/HttpWmsGetMap.cpp	2020-07-28 14:13:51 UTC (rev 9692)
@@ -178,28 +178,17 @@
             {
                 // Construct a self url
                 auto selfUrl = m_hRequest->GetAgentUri();
-                for (INT32 i = 0; i < requestParams.Count(); i++)
-                {
-                    if (i == 0)
-                        selfUrl += L"?";
-                    else
-                        selfUrl += L"&";
+                STRING sLayers = GetRequestParameter(wms, MgHttpResourceStrings::reqWmsLayers);
+                wms.GenerateViewerResponse(selfUrl, sLayers, m_crs, m_bbox);
 
-                    auto name = requestParams.Name(i);
-                    selfUrl += name;
-                    selfUrl += L"=";
-                    if (name == MgHttpResourceStrings::reqWmsFormat)
-                    {
-                        selfUrl += L"image/png"; //TODO: Surely default image format is defined somewhere
-                    }
-                    else
-                    {
-                        auto value = (CPSZ)requestParams.Value(i);
-                        selfUrl += value;
-                    }
-                }
+                // Slurp the results.
+                // NOTE: The application/openlayers mime type is just a means to get to the code path
+                // the actual mime type to serve back is HTML
+                responseStream.Stream().SetMimeType(MgMimeType::Html);
+                Ptr<MgByteReader> content = responseStream.Stream().GetReader();
 
-                wms.OutputViewerResponse(selfUrl, hResult);
+                // Set the result
+                hResult->SetResultObject(content, content->GetMimeType());
             }
             else
             {

Modified: sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.cpp
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.cpp	2020-07-28 14:12:57 UTC (rev 9691)
+++ sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.cpp	2020-07-28 14:13:51 UTC (rev 9692)
@@ -135,6 +135,11 @@
 CPSZ kpszNewline                    = _("\n");
 CPSZ kpszXmlSlash                   = _("/");
 
+CPSZ kpszViewerSelfUrl              = _("Viewer.SelfUrl");
+CPSZ kpszViewerLayersParam          = _("Viewer.LayersParam");
+CPSZ kpszViewerSrs                  = _("Viewer.SRS");
+CPSZ kpszViewerBounds               = _("Viewer.BBOX");
+
 // BEGIN LOCALIZATION --
 CPSZ kpszDefaultExceptionTemplate   = _("<html><head><title>Server Exception</title></head><body><h1>Server Exception:</h1><p>Type: &Exception.Type;</p><p>Message: &Exception.Message;</p><pre><?EnumDictionary?></pre></body></html>");
 CPSZ kpszInternalErrorNoSupportedVersions = _("Service Config file does not contain any SupportedVersions definition; unable to perform version negotiation.");
@@ -1890,18 +1895,16 @@
     ProcessExpandableText(pszTextWithExpansion,(int)szlen(pszTextWithExpansion));
 }
 
-void MgOgcServer::OutputViewerResponse(CREFSTRING selfUrl, MgHttpResult* hResult)
+void MgOgcServer::GenerateViewerResponse(CREFSTRING selfUrl, CREFSTRING layers, CREFSTRING srs, CREFSTRING bbox)
 {
-    STRING content = L"<html><head></head><body>";
-    content += L"<p>TODO: Display OpenLayers view with the following URL</p>";
-    content += selfUrl;
-    content += L"</body></html>";
+    CDictionaryStackFrame forThis(this);
 
-    std::string mbContent = MgUtil::WideCharToMultiByte(content);
-    Ptr<MgByteSource> bs = new MgByteSource((BYTE_ARRAY_IN)mbContent.c_str(), (INT32)mbContent.length());
-    bs->SetMimeType(MgMimeType::Html);
-    Ptr<MgByteReader> br = bs->GetReader();
-    hResult->SetResultObject(br, br->GetMimeType());
+    AddDefinition(kpszViewerSelfUrl, selfUrl);
+    AddDefinition(kpszViewerLayersParam, layers);
+    AddDefinition(kpszViewerSrs, srs);
+    AddDefinition(kpszViewerBounds, bbox);
+
+    GenerateResponse(kpszQueryValueGetMap, kpszOpenLayersMimeType);
 }
 
 MgOgcServer::CDictionaryStackFrame::CDictionaryStackFrame(MgOgcServer* pServer)

Modified: sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.h
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.h	2020-07-28 14:12:57 UTC (rev 9691)
+++ sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.h	2020-07-28 14:13:51 UTC (rev 9692)
@@ -553,7 +553,7 @@
     // to actually do the loading.  See signature, above.
     static void SetLoader(DocLoaderFunc fnDocLoad);
 
-    void OutputViewerResponse(CREFSTRING selfUrl, MgHttpResult* hResult);
+    void GenerateViewerResponse(CREFSTRING selfUrl, CREFSTRING layers, CREFSTRING srs, CREFSTRING bbox);
 
 private:
     // Pointer to the document loader function; modified by SetLoader().



More information about the mapguide-commits mailing list