Tuesday, 1 August 2017

wms - OpenLayers WFS flip coordinates


I have a problem integrating WMS and WFS. Basically what i want is when user clicks on WMS then a clicked polygon is added to vector (and selected). The problem is that the WMS is in version 1.3.0 and WFS 1.1.0. OpenLayers automatically flips axis for WMS but when it calculates bbox for wfs request, it does not. I have the following code:







var map = new OpenLayers.Map({numZoomLevels: 20});

var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://sdi.geoportal.gov.pl/wms_dzkat/wmservice.aspx?",
{layers: ['Dzialki','Numery_dzialek'], version:'1.3.0'}
);
select = new OpenLayers.Layer.Vector("Selection", {styleMap:
new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
});


var protocol = new OpenLayers.Protocol.WFS({
version: "1.1.0",
//url: "http://sdi.geoportal.gov.pl/WFS_DzKat/service.svc/post",
url:'/GSIP/proxy/dopost/',
featureType: "Dzialki",
featureNS:'http://www.intergraph.com/geomedia/gml',
featurePrefix:'gmgml',
geometryName:"GEOMETRIA_DEG"
});


control = new OpenLayers.Control.GetFeature({
protocol: protocol,
box: true,
//hover: true,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});

control.events.register("featureselected", this, function(e) {

select.addFeatures([e.feature]);
});
control.events.register("featureunselected", this, function(e) {
select.removeFeatures([e.feature]);
});

map.addControl(control);
control.activate();



And generated request after click:






GEOMETRIA_DEG

19.143386078712 52.371721634254
19.143439722893 52.371775278435







The above request does not work (0 features returned) but when i flip coords so it looks like:


52.371721634254 19.143386078712
52.371775278435 19.143439722893

it works. How to force OpenLayers to build getFeature request with flipped coords? In WMS Layer there is attribute reverseAxisOrder but can't find it in Vector Layer





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...