X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=js%2Fsrc%2Fgeo%2FOpenLayersUtils.js;h=b85ad7d3ab46d290433c92c2cbaccfd5c000d0ba;hp=d223463133f2925d74a91cccdeb4b8e0bd9e7595;hb=e9978679e86dcd297270432e4ed953b782f1e7c6;hpb=36a9a4d540f617bd23170a109ee08e9e200e2143 diff --git a/js/src/geo/OpenLayersUtils.js b/js/src/geo/OpenLayersUtils.js index d223463..b85ad7d 100644 --- a/js/src/geo/OpenLayersUtils.js +++ b/js/src/geo/OpenLayersUtils.js @@ -1,7 +1,7 @@ import { transformExtent } from 'ol/proj.js'; -export function transformToLatLonExtent(extent, projection) { +export function transformToEpsg4326LatLonExtent(extent, projection) { const proj = projection.getCode(); if (proj === 'EPSG:4326') return toLatLonExtent(extent); @@ -9,6 +9,23 @@ export function transformToLatLonExtent(extent, projection) { return toLatLonExtent(transformed); } +/** From EPSG:4326 lat/lon to a proj lon/lat */ +export function transformToOlLonLatExtent(extent, projection) { + const proj = projection.getCode(); + if (proj === 'EPSG:4326') + return toLonLatExtent(extent); + const reordered = toLonLatExtent(extent); + var transformed = transformExtent(reordered, 'EPSG:4326', proj); + return transformed; +} + +/** Converts from an extent in OpenLayers order (lon/lat) to WFS 2.0 order (lat/lon). */ export function toLatLonExtent(extent) { return [extent[1], extent[0], extent[3], extent[2]]; -} \ No newline at end of file +} + +/** Converts from an extent in WFS 2.0 order (lat/lon) to OpenLayers order (lon/lat) . */ +export function toLonLatExtent(extent) { + return [extent[1], extent[0], extent[3], extent[2]]; +} +