0

I'm looking for some hints (Javascript custom function or openlayers 4 function) ...) that can help me to convert a wms response URL parameters to get my click coordinates.

Here an example of url to convert to a click coordinate.

https://ws.mapserver.transports.gouv.qc.ca/swtq?SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetFeatureInfo
&BBOX=-7859605.72457123640924692,5954835.61684618983417749,-7802662.21180228982120752,5988064.99139707256108522
&CRS=EPSG:3857
&WIDTH=1155
&HEIGHT=674
&LAYERS=histo_stations_meteoroutieres
&STYLES=
&FORMAT=image/png
&QUERY_LAYERS=histo_stations_meteoroutieres
&INFO_FORMAT=text/html
&I=722
&J=403
&FEATURE_COUNT=10

My goal is to recreate a gml from this query based on derived wkt Point.

1

Your click coordinates are 722,403 px on a window that is 1155x674px with a real world bounding box of -7859605.72457123640924692, 5954835.61684618983417749, -7802662.21180228982120752, 5988064.99139707256108522.

So simple maths gives you

x = (-7802662.2118022898212 - -7859605.72457123640924692) * 722/1155
y = (5988064.99139707256108522 - 5954835.61684618983417749) * 403/674

converting to javascript is left as an exercise for the reader.

But if it was me I'd remember the event coordinates I used to construct the URL in the first place.

3
  • But how to manage the correct projection as with local projection (utm?) how the coordinates increases? – PEL Sep 19 '17 at 15:13
  • that doesn't matter – Ian Turton Sep 19 '17 at 15:22
  • This calculation, can you tell me a little? – Ömür Bilgili Sep 21 '17 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.