Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions msautotest/config/expected/index_wms_onlineresource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"has-error":false,"key":"WMS_MAP_ONLINERESOURCE","layer-count":1,"linkset":[{"service-doc":[{"href":"http://127.0.0.1/cgi-bin/mapserv.exe?map=/my/path/index_wms_onlineresource.map&template=openlayers&mode=browse&layers=all","service":"CGI","title":"OpenLayers Viewer","type":"text/html"}],"title":"WMSMAP"},{"service-desc":[{"href":"http://127.0.0.1/cgi-bin/mapserv.exe?map=/my/path/index_wms_onlineresource.map&version=1.0.0&request=GetCapabilities&service=WMS","service":"WMS","title":"WMS GetCapabilities URL (version 1.0.0)","type":"text/xml"},{"href":"http://127.0.0.1/cgi-bin/mapserv.exe?map=/my/path/index_wms_onlineresource.map&version=1.1.0&request=GetCapabilities&service=WMS","service":"WMS","title":"WMS GetCapabilities URL (version 1.1.0)","type":"text/xml"},{"href":"http://127.0.0.1/cgi-bin/mapserv.exe?map=/my/path/index_wms_onlineresource.map&version=1.1.1&request=GetCapabilities&service=WMS","service":"WMS","title":"WMS GetCapabilities URL (version 1.1.1)","type":"text/xml"},{"href":"http://127.0.0.1/cgi-bin/mapserv.exe?map=/my/path/index_wms_onlineresource.map&version=1.3.0&request=GetCapabilities&service=WMS","service":"WMS","title":"WMS GetCapabilities URL (version 1.3.0)","type":"text/xml"}],"title":"MapServer WMS Demo Map"}],"name":"WMSMAP","title":"MapServer WMS Demo Map"}
18 changes: 13 additions & 5 deletions msautotest/config/expected/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,54 @@ <h1>MapServer Homepage</h1>
</tr>
<tr>
<td>3</td>
<td>WMS_MAP_ONLINERESOURCE</td>
<td>MapServer WMS Demo Map</td>
<td>1</td>
<td><a href="./WMS_MAP_ONLINERESOURCE/">WMS_MAP_ONLINERESOURCE</a></td>
<td><a href="./WMS_MAP_ONLINERESOURCE/?f=json">WMS_MAP_ONLINERESOURCE</a></td>
</tr>
<tr>
<td>4</td>
<td>WMS_MAP</td>
<td>MapServer WMS Demo Map</td>
<td>1</td>
<td><a href="./WMS_MAP/">WMS_MAP</a></td>
<td><a href="./WMS_MAP/?f=json">WMS_MAP</a></td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>WFS_MAP</td>
<td>MapServer WFS Demo Map</td>
<td>1</td>
<td><a href="./WFS_MAP/">WFS_MAP</a></td>
<td><a href="./WFS_MAP/?f=json">WFS_MAP</a></td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>WCS_MAP</td>
<td>WCS Demo Mapfile</td>
<td>1</td>
<td><a href="./WCS_MAP/">WCS_MAP</a></td>
<td><a href="./WCS_MAP/?f=json">WCS_MAP</a></td>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>WMS_MAP_NOCGI</td>
<td>MapServer WMS Demo Map with CGI Disabled</td>
<td>1</td>
<td><a href="./WMS_MAP_NOCGI/">WMS_MAP_NOCGI</a></td>
<td><a href="./WMS_MAP_NOCGI/?f=json">WMS_MAP_NOCGI</a></td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>MISSING_MAP</td>
<td> <b>Error loading the map</b></td>
<td>0</td>
<td><a href="./MISSING_MAP/">MISSING_MAP</a></td>
<td><a href="./MISSING_MAP/?f=json">MISSING_MAP</a></td>
</tr>
<tr>
<td>8</td>
<td>9</td>
<td>OGCAPI_MAP</td>
<td>MapServer OGC Features API Demo Map</td>
<td>1</td>
Expand Down
2 changes: 1 addition & 1 deletion msautotest/config/expected/landing.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"linkset":[{"has-error":false,"key":"KITCHENSINK_MAP","layer-count":2,"name":"Kitchensink Demo Mapfile","service-desc":[{"href":"./KITCHENSINK_MAP/?f=json","title":"KITCHENSINK_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./KITCHENSINK_MAP/","title":"KITCHENSINK_MAP","type":"text/html"}],"title":"MapServer Kitchensink Demo Map"},{"has-error":false,"key":"INDEX","layer-count":1,"name":"hello_world","service-desc":[{"href":"./INDEX/?f=json","title":"INDEX","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./INDEX/","title":"INDEX","type":"text/html"}],"title":"hello_world"},{"has-error":false,"key":"WMS_MAP","layer-count":1,"name":"WMSMAP","service-desc":[{"href":"./WMS_MAP/?f=json","title":"WMS_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WMS_MAP/","title":"WMS_MAP","type":"text/html"}],"title":"MapServer WMS Demo Map"},{"has-error":false,"key":"WFS_MAP","layer-count":1,"name":"WFSMAP","service-desc":[{"href":"./WFS_MAP/?f=json","title":"WFS_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WFS_MAP/","title":"WFS_MAP","type":"text/html"}],"title":"MapServer WFS Demo Map"},{"has-error":false,"key":"WCS_MAP","layer-count":1,"name":"WCS Demo Mapfile","service-desc":[{"href":"./WCS_MAP/?f=json","title":"WCS_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WCS_MAP/","title":"WCS_MAP","type":"text/html"}],"title":"WCS Demo Mapfile"},{"has-error":false,"key":"WMS_MAP_NOCGI","layer-count":1,"name":"WMSMAPNOCGI","service-desc":[{"href":"./WMS_MAP_NOCGI/?f=json","title":"WMS_MAP_NOCGI","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WMS_MAP_NOCGI/","title":"WMS_MAP_NOCGI","type":"text/html"}],"title":"MapServer WMS Demo Map with CGI Disabled"},{"has-error":true,"key":"MISSING_MAP","layer-count":0,"name":"MISSING_MAP","service-desc":[{"href":"./MISSING_MAP/?f=json","title":"MISSING_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./MISSING_MAP/","title":"MISSING_MAP","type":"text/html"}],"title":" <b>Error loading the map</b>"},{"has-error":false,"key":"OGCAPI_MAP","layer-count":1,"name":"OAPIF Demo Mapfile","service-desc":[{"href":"./OGCAPI_MAP/?f=json","title":"OGCAPI_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./OGCAPI_MAP/","title":"OGCAPI_MAP","type":"text/html"}],"title":"MapServer OGC Features API Demo Map"}]}
{"linkset":[{"has-error":false,"key":"KITCHENSINK_MAP","layer-count":2,"name":"Kitchensink Demo Mapfile","service-desc":[{"href":"./KITCHENSINK_MAP/?f=json","title":"KITCHENSINK_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./KITCHENSINK_MAP/","title":"KITCHENSINK_MAP","type":"text/html"}],"title":"MapServer Kitchensink Demo Map"},{"has-error":false,"key":"INDEX","layer-count":1,"name":"hello_world","service-desc":[{"href":"./INDEX/?f=json","title":"INDEX","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./INDEX/","title":"INDEX","type":"text/html"}],"title":"hello_world"},{"has-error":false,"key":"WMS_MAP_ONLINERESOURCE","layer-count":1,"name":"WMSMAP","service-desc":[{"href":"./WMS_MAP_ONLINERESOURCE/?f=json","title":"WMS_MAP_ONLINERESOURCE","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WMS_MAP_ONLINERESOURCE/","title":"WMS_MAP_ONLINERESOURCE","type":"text/html"}],"title":"MapServer WMS Demo Map"},{"has-error":false,"key":"WMS_MAP","layer-count":1,"name":"WMSMAP","service-desc":[{"href":"./WMS_MAP/?f=json","title":"WMS_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WMS_MAP/","title":"WMS_MAP","type":"text/html"}],"title":"MapServer WMS Demo Map"},{"has-error":false,"key":"WFS_MAP","layer-count":1,"name":"WFSMAP","service-desc":[{"href":"./WFS_MAP/?f=json","title":"WFS_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WFS_MAP/","title":"WFS_MAP","type":"text/html"}],"title":"MapServer WFS Demo Map"},{"has-error":false,"key":"WCS_MAP","layer-count":1,"name":"WCS Demo Mapfile","service-desc":[{"href":"./WCS_MAP/?f=json","title":"WCS_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WCS_MAP/","title":"WCS_MAP","type":"text/html"}],"title":"WCS Demo Mapfile"},{"has-error":false,"key":"WMS_MAP_NOCGI","layer-count":1,"name":"WMSMAPNOCGI","service-desc":[{"href":"./WMS_MAP_NOCGI/?f=json","title":"WMS_MAP_NOCGI","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./WMS_MAP_NOCGI/","title":"WMS_MAP_NOCGI","type":"text/html"}],"title":"MapServer WMS Demo Map with CGI Disabled"},{"has-error":true,"key":"MISSING_MAP","layer-count":0,"name":"MISSING_MAP","service-desc":[{"href":"./MISSING_MAP/?f=json","title":"MISSING_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./MISSING_MAP/","title":"MISSING_MAP","type":"text/html"}],"title":" <b>Error loading the map</b>"},{"has-error":false,"key":"OGCAPI_MAP","layer-count":1,"name":"OAPIF Demo Mapfile","service-desc":[{"href":"./OGCAPI_MAP/?f=json","title":"OGCAPI_MAP","type":"application/vnd.oai.openapi+json"}],"service-doc":[{"href":"./OGCAPI_MAP/","title":"OGCAPI_MAP","type":"text/html"}],"title":"MapServer OGC Features API Demo Map"}]}
1 change: 1 addition & 0 deletions msautotest/config/index.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CONFIG
INDEX "index.map"
WMS_MAP "index_wms.map"
WMS_MAP_NOCGI "index_wms_nocgi.map"
WMS_MAP_ONLINERESOURCE "index_wms_onlineresource.map"
WFS_MAP "index_wfs.map"
WCS_MAP "index_wcs.map"
OGCAPI_MAP "index_ogcapi.map"
Expand Down
35 changes: 35 additions & 0 deletions msautotest/config/index_wms_onlineresource.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# RUN_PARMS: index_wms_onlineresource.json [MAPSERV] -conf index.conf "PATH_INFO=/WMS_MAP_ONLINERESOURCE/" QUERY_STRING="f=json" > [RESULT_DEMIME]

MAP
NAME "WMSMAP"
IMAGETYPE "png"
SIZE 800 800
EXTENT -180.0 -90 180 90
PROJECTION
"EPSG:4326"
END
WEB
METADATA
"wms_enable_request" "GetCapabilities GetMap"
"wms_srs" "EPSG:4326"
"ows_title" "MapServer WMS Demo Map"
"ows_onlineresource" "http://127.0.0.1/cgi-bin/mapserv.exe?map=/my/path/index_wms_onlineresource.map&"
END
# required if using &mode=browse&template=openlayers
IMAGEPATH "/tmp/"
END

LAYER
NAME "ne_110m_land"
STATUS OFF
CONNECTION "./data/ne_110m_land.fgb"
TYPE POLYGON
CONNECTIONTYPE OGR
CLASS
NAME "land"
STYLE
COLOR "#556b2f"
END
END
END
END
18 changes: 16 additions & 2 deletions src/mapserv-index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ std::string getOnlineResource(mapObj *map, cgiRequestObj *request,
onlineResource = "./?";
}

if (!onlineResource.empty() && onlineResource.back() != '?') {
onlineResource += '?';
if (!onlineResource.empty()) {
if (onlineResource.find('?') != std::string::npos) {
// URL already has a query string
char last = onlineResource.back();
if (last != '?' && last != '&') {
onlineResource += '&';
}
} else {
// no query string so append '?'
onlineResource += '?';
}
}

return onlineResource;
Expand Down Expand Up @@ -325,6 +334,11 @@ static json createMapSummary(mapObj *map, const char *key,
onlineResource = "./"; // fallback
}

// make sure the root URL end with a '/'
if (!onlineResource.empty() && onlineResource.back() != '/') {
onlineResource += '/';
}

mapJson["service-desc"] =
json::array({{{"href", onlineResource + std::string(key) + "/?f=json"},
{"title", key},
Expand Down