socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
427 stars 137 forks source link

Problem with " character in WMS getMap request #198

Open rmarzocchi84 opened 3 years ago

rmarzocchi84 commented 3 years ago

I have a Rasdaman WMS GetMap request (e.g. http://rasdaman.org/browser/systemtest/testcases_services/test_wms/queries/31-get_map_on_4d_coverage_dim_pressure_and_time_irregular_specified.test)

The time parameter need to be written with the " character

This is the request using this leaflet plugin that doesn't work

http://localhost:8081/rasdaman/ows?&service=WMS
&request=GetMap
&layers=fwi_202006
&styles=
&format=image%2Fpng
&transparent=true
&version=1.3.0
&time=2020-0630T00%3A00%3A00.000Z
&width=256
&height=256
&crs=EPSG%3A3857
&bbox=860986.6866042254,5713820.738373496,939258.203568246,5792092.255337515

This is the correct request:

http://localhost:8081/rasdaman/ows?&service=WMS
&request=GetMap
&layers=fwi_202006
&styles=
&format=image%2Fpng
&transparent=true
&version=1.3.0
&time="2020-0630T00%3A00%3A00.000Z"
&width=256
&height=256
&crs=EPSG%3A3857
&bbox=860986.6866042254,5713820.738373496,939258.203568246,5792092.255337515

It is possible to change the request adding the " character

bielfrontera commented 3 years ago

Hi @rmarzocchi84, you could create a new TimeDimension.Layer class and change how the url for a given time is built.

This should work:

L.TimeDimension.Layer.WMS.Rasdaman = L.TimeDimension.Layer.WMS.extend({

    _createLayerForTime:function(time){
        var wmsParams = this._baseLayer.options;
        var date = new Date(time);
        wmsParams.time = '"' + date.toISOString() + '"';
        return new this._baseLayer.constructor(this._baseLayer.getURL(), wmsParams);
    }

});

L.timeDimension.layer.wms.rasdaman = function(layer, options) {
    return new L.TimeDimension.Layer.WMS.Rasdaman(layer, options);
};