[mapguide-commits] r9693 - in sandbox/jng/ogc_viewer_representation: Server/src/Wms Web/src/DevHttpServer Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Jul 28 10:08:21 PDT 2020
Author: jng
Date: 2020-07-28 10:08:20 -0700 (Tue, 28 Jul 2020)
New Revision: 9693
Modified:
sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.0.0.xml.awd
sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.0.xml.awd
sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.1.xml.awd
sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.3.0.xml.awd
sandbox/jng/ogc_viewer_representation/Server/src/Wms/OgcWmsService.config.awd
sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/DevHttpServer.vcxproj
sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp
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:
Get the viewer representation to work across all supported WMS versions. Also add command-line arg support to MgDevHttpServer (via TCLAP) for custom listening port and CS-MAP path.
Modified: sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.0.0.xml.awd
===================================================================
--- sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.0.0.xml.awd 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.0.0.xml.awd 2020-07-28 17:08:20 UTC (rev 9693)
@@ -412,6 +412,15 @@
"features": [<?EnumFeatureInfo using="&FeatureInfo.json;" ?>]
}</Response>
+<!--
+
+ WMS GetFeatureInfo - OpenLayers viewer
+
+-->
+<Response request="GetMap" content-type="application/openlayers">
+&GetMap.html;
+</Response>
+
<!--
Exception format - XML
Modified: sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.0.xml.awd
===================================================================
--- sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.0.xml.awd 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.0.xml.awd 2020-07-28 17:08:20 UTC (rev 9693)
@@ -436,7 +436,15 @@
"features": [<?EnumFeatureInfo using="&FeatureInfo.json;" ?>]
}</Response>
+<!--
+ WMS GetFeatureInfo - OpenLayers viewer
+
+-->
+<Response request="GetMap" content-type="application/openlayers">
+&GetMap.html;
+</Response>
+
<!--
Exception Format - XML
Modified: sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.1.xml.awd
===================================================================
--- sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.1.xml.awd 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.1.1.xml.awd 2020-07-28 17:08:20 UTC (rev 9693)
@@ -416,7 +416,15 @@
"features": [<?EnumFeatureInfo using="&FeatureInfo.json;" ?>]
}</Response>
+<!--
+ WMS GetFeatureInfo - OpenLayers viewer
+
+-->
+<Response request="GetMap" content-type="application/openlayers">
+&GetMap.html;
+</Response>
+
<!--
Exception format - XML
Modified: sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.3.0.xml.awd
===================================================================
--- sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.3.0.xml.awd 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Server/src/Wms/1.3.0.xml.awd 2020-07-28 17:08:20 UTC (rev 9693)
@@ -423,68 +423,14 @@
"features": [<?EnumFeatureInfo using="&FeatureInfo.json;" ?>]
}</Response>
-<!--
+<!--
+
WMS GetFeatureInfo - OpenLayers viewer
-->
<Response request="GetMap" content-type="application/openlayers">
-<!DOCTYPE html>
-<html>
- <head>
- <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
- <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
- <!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
- <script src="https://unpkg.com/@openlayers/pepjs"></script>
- <script type="text/javascript" src="../viewerfiles/ol.js" charset="utf-8"></script>
- <link rel="stylesheet" href="../viewerfiles/ol.css" />
- <style type="text/css">
- .map {
- width: 100%;
- height:400px;
- }
- </style>
- </head>
- <body>
- <div id="map" class="map"></div>
- <script type="text/javascript">
- var bounds = [&Viewer.BBOX;];
- // Regardless of WMS version, normalize the BBOX to address any
- // axis orientation
- bounds = [
- Math.min(bounds[0], bounds[2]),
- Math.min(bounds[1], bounds[3]),
- Math.max(bounds[0], bounds[2]),
- Math.max(bounds[1], bounds[3])
- ];
- var layers = [
- new ol.layer.Tile({
- source: new ol.source.OSM()
- }),
- new ol.layer.Image({
- source: new ol.source.ImageWMS({
- url: "&Viewer.SelfUrl;",
- params: {
- "LAYERS": "&Viewer.LayersParam;",
- "TRANSPARENT": "TRUE"
- },
- ratio: 1
- })
- })
- ];
- var view = new ol.View({
- projection: "&Viewer.SRS;"
- });
- view.fit(bounds);
- var map = new ol.Map({
- layers: layers,
- target: "map",
- view: view
- });
-
- </script>
- </body>
-</html>
+&GetMap.html;
</Response>
<!--
Modified: sandbox/jng/ogc_viewer_representation/Server/src/Wms/OgcWmsService.config.awd
===================================================================
--- sandbox/jng/ogc_viewer_representation/Server/src/Wms/OgcWmsService.config.awd 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Server/src/Wms/OgcWmsService.config.awd 2020-07-28 17:08:20 UTC (rev 9693)
@@ -140,6 +140,7 @@
<item>image/png</item>
<item>image/jpeg</item>
<item>image/gif</item>
+ <item>application/openlayers</item>
</Define>
<!-- This value map permits FORMAT= parameters to be -->
@@ -246,6 +247,56 @@
<translate from="CRS:84">GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</translate>
</Define>
+ <Define item="GetMap.html"><!DOCTYPE html>
+<html>
+ <head>
+ <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
+ <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
+ <!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
+ <script src="https://unpkg.com/@openlayers/pepjs"></script>
+ <script type="text/javascript" src="../viewerfiles/ol.js" charset="utf-8"></script>
+ <link rel="stylesheet" href="../viewerfiles/ol.css" />
+ <style type="text/css">
+ .map {
+ width: 100%;
+ height:400px;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="map" class="map"></div>
+ <script type="text/javascript">
+ var bounds = [&Viewer.BBOX;];
+ var layers = [
+ new ol.layer.Tile({
+ source: new ol.source.OSM()
+ }),
+ new ol.layer.Image({
+ source: new ol.source.ImageWMS({
+ url: "&Viewer.SelfUrl;",
+ params: {
+ "LAYERS": "&Viewer.LayersParam;",
+ "VERSION": "&Viewer.ServiceVersion;",
+ "TRANSPARENT": "TRUE"
+ },
+ ratio: 1
+ })
+ })
+ ];
+ var view = new ol.View({
+ projection: "&Viewer.SRS;"
+ });
+ view.fit(bounds);
+ var map = new ol.Map({
+ layers: layers,
+ target: "map",
+ view: view
+ });
+ </script>
+ </body>
+</html>
+ </Define
+
</Definitions>
Modified: sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/DevHttpServer.vcxproj
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/DevHttpServer.vcxproj 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/DevHttpServer.vcxproj 2020-07-28 17:08:20 UTC (rev 9693)
@@ -94,7 +94,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\..\..\Oem\tclap-1.2.2\include;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_MAPAGENT_API_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -136,7 +136,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\..\..\Oem\tclap-1.2.2\include;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_MAPAGENT_API_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -178,7 +178,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
- <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\..\..\Oem\tclap-1.2.2\include;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_MAPAGENT_API_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -221,7 +221,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
- <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\..\Oem\cpp-httplib;..\..\..\Oem\tclap-1.2.2\include;..\HttpHandler;..\MapAgentCommon;..\WebSupport;..\WebApp;..\..\..\Common;..\..\..\Common\MdfModel;..\..\..\Common\Foundation;..\..\..\Common\Geometry;..\..\..\Common\PlatformBase;..\..\..\Common\MapGuideCommon;..\..\..\Oem\ACE\ACE_wrappers;..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\Oem\jsoncpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_MAPAGENT_API_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Modified: sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp 2020-07-28 14:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp 2020-07-28 17:08:20 UTC (rev 9693)
@@ -16,6 +16,7 @@
//
#include "httplib.h"
+#include <tclap/CmdLine.h>
#include <cstdio>
#include <string>
@@ -34,9 +35,11 @@
#include "MapAgentCommon.h"
#include "MapAgentStrings.h"
#include "Base64.h"
+#include "ProductVersion.h"
int port = 8000;
const char* host = "localhost";
+const char* version = "1.0.0";
std::unique_ptr<httplib::Server> g_server;
@@ -470,8 +473,38 @@
#endif
#endif
- putenv("MENTOR_DICTIONARY_PATH=..\\..\\..\\..\\Oem\\CsMap\\CsMapDev\\Dictionaries");
+ try
+ {
+ TCLAP::CmdLine cmd("MgDevHttpServer - Development HTTP Server for MapGuide", ' ', version);
+ TCLAP::ValueArg<std::string> argMentorPath("m", "mentor-dictionary-path", "The path to the CS-MAP dictionary data files. Not required if this path is set in webconfig.ini", false, "", "path");
+ TCLAP::ValueArg<int> argPort("p", "port", "The port this server will listen on", false, 8000, "integer");
+
+ cmd.add(argMentorPath);
+ cmd.add(argPort);
+
+ cmd.parse(argc, argv);
+
+ auto mentorPath = argMentorPath.getValue();
+ if (!mentorPath.empty())
+ {
+ std::string envExpr = "MENTOR_DICTIONARY_PATH=";
+ envExpr += mentorPath;
+ printf("Setting MENTOR_DICTIONARY_PATH to (%s) in the event this value is not set in webconfig.ini\n", mentorPath.c_str());
+ putenv(envExpr.c_str());
+ }
+
+ if (argPort.isSet())
+ {
+ port = argPort.getValue();
+ }
+ }
+ catch (TCLAP::ArgException& e)
+ {
+ printf("ERROR: %s for arg %s\n", e.error().c_str(), e.argId().c_str());
+ return -1;
+ }
+
bool bInit = false;
{
MG_TRY()
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:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/HttpWmsGetMap.cpp 2020-07-28 17:08:20 UTC (rev 9693)
@@ -179,7 +179,7 @@
// Construct a self url
auto selfUrl = m_hRequest->GetAgentUri();
STRING sLayers = GetRequestParameter(wms, MgHttpResourceStrings::reqWmsLayers);
- wms.GenerateViewerResponse(selfUrl, sLayers, m_crs, m_bbox);
+ wms.GenerateViewerResponse(selfUrl, m_version, sLayers, m_crs, m_bbox);
// Slurp the results.
// NOTE: The application/openlayers mime type is just a means to get to the code path
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:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.cpp 2020-07-28 17:08:20 UTC (rev 9693)
@@ -139,6 +139,7 @@
CPSZ kpszViewerLayersParam = _("Viewer.LayersParam");
CPSZ kpszViewerSrs = _("Viewer.SRS");
CPSZ kpszViewerBounds = _("Viewer.BBOX");
+CPSZ kpszViewerServiceVersion = _("Viewer.ServiceVersion");
// 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>");
@@ -1895,11 +1896,12 @@
ProcessExpandableText(pszTextWithExpansion,(int)szlen(pszTextWithExpansion));
}
-void MgOgcServer::GenerateViewerResponse(CREFSTRING selfUrl, CREFSTRING layers, CREFSTRING srs, CREFSTRING bbox)
+void MgOgcServer::GenerateViewerResponse(CREFSTRING selfUrl, CREFSTRING version, CREFSTRING layers, CREFSTRING srs, CREFSTRING bbox)
{
CDictionaryStackFrame forThis(this);
AddDefinition(kpszViewerSelfUrl, selfUrl);
+ AddDefinition(kpszViewerServiceVersion, version);
AddDefinition(kpszViewerLayersParam, layers);
AddDefinition(kpszViewerSrs, srs);
AddDefinition(kpszViewerBounds, bbox);
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:13:51 UTC (rev 9692)
+++ sandbox/jng/ogc_viewer_representation/Web/src/HttpHandler/OgcServer.h 2020-07-28 17:08:20 UTC (rev 9693)
@@ -553,7 +553,7 @@
// to actually do the loading. See signature, above.
static void SetLoader(DocLoaderFunc fnDocLoad);
- void GenerateViewerResponse(CREFSTRING selfUrl, CREFSTRING layers, CREFSTRING srs, CREFSTRING bbox);
+ void GenerateViewerResponse(CREFSTRING selfUrl, CREFSTRING version, CREFSTRING layers, CREFSTRING srs, CREFSTRING bbox);
private:
// Pointer to the document loader function; modified by SetLoader().
@@ -562,7 +562,7 @@
// Handles one <Define>...</Define> element in the template or global config.
// Assumes that the parser is positioned over the <Define> begin element.
// Used both by the global initialization, as well as each service instance.
- static void ProcessDefine( MgXmlParser& Template,MgUtilDictionary& Dictionary);
+ static void ProcessDefine(MgXmlParser& Template, MgUtilDictionary& Dictionary);
// Used by global initialization to process the default <Exception> form of response.
// Used as a fallback in case the service instance doesn't find a <Response> for
More information about the mapguide-commits
mailing list