Closed giovanniborella closed 1 day ago
It's $_SERVER["QUERY_STRING"], which is passed to parse_url:
parse_url("LAYERS=public.wms&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=1169005.4148614,7370812.4847207,1189077.300755,7376022.145929&WIDTH=4201&HEIGHT=1090")
Which yields:
Array
(
[path] => LAYERS=public.wms&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=1169005.4148614,7370812.4847207,1189077.300755,7376022.145929&WIDTH=4201&HEIGHT=1090
)
But I found an issue: bbox is passed through from GC2 and Vidi, but SRS/CRS is not. BBOX from GC2/Vidi is EPSG:3857, but the WMS source often has UTM EPSG. So, SRS/CRS must all be passed through from GC2/Vidi.
Something like this will do it, I guess:
if ($source = $this->getWmsSource($db, $postgisschema, $layers)) {
parse_str(parse_url($_SERVER["QUERY_STRING"])['path'], $query);
$query = array_change_key_case($query, CASE_UPPER);
// Use parameters from WMS source if set and use those from query for not set parameters
$mergedQuery = array_merge($query, $source['query']);
// Always use these from the query
$mergedQuery['BBOX'] = $query['BBOX'];
$mergedQuery['WIDTH'] = $query['WIDTH'];
$mergedQuery['HEIGHT'] = $query['HEIGHT'];
$mergedQuery['VERSION'] = $query['VERSION'];
// Set SRS or CRS (WMS version 1.1.0 and 1.3.0)
$bits = explode('.', $query['VERSION']);
if ((int)$bits[1] < 3) {
$mergedQuery['SRS'] = $query['SRS'];
} else {
$mergedQuery['CRS'] = $query['CRS'];
}
// Set REQUEST TO GetMap
$mergedQuery['REQUEST'] = 'GetMap';
$url = $source['scheme'] . "://" . $source['host'] . $source['path'] . '?' . http_build_query($mergedQuery);
$useWmsSource = true;
}
maybe we are lookin at this from 2 different points of view - when getting the layer from vidi using an url like:
then the resulting $url in the script you posted will evaluate to something like this: https://cloudconnectapi.geopartner.dk/prod/service/wms?LABELS=true&CONFIG=&TOKEN=9ca5d0f5-9ea5-49d0-aa90-d5d9f8cd0896&TRANSPARENT=TRUE&STYLE=default&SERVICE=WMS&FORMAT=image%2Fpng&APIKEY=8ac1f487-32dc-44cd-ab9a-9667ae109c96&LAYERS=Samlet_tif&REQUEST=GetMap
lacking the parameters for getting the relevant image from external service.
the layer is setup with a wmssource.
using mapcache the layer works fine - but directly, it fails
The URL has two ?
- that's not valid. So this is a bug in Vidi I guess
this pr should still be merged
bbox, width, height was not passed through to the final url, parse_url did nothing to the path element because QUERY_STRING was not a complete url - but just the query.