Fix order of coordinates in BBOX
[gpl/argeo-suite.git] / js / src / geo / OpenLayersUtils.js
diff --git a/js/src/geo/OpenLayersUtils.js b/js/src/geo/OpenLayersUtils.js
new file mode 100644 (file)
index 0000000..d223463
--- /dev/null
@@ -0,0 +1,14 @@
+import { transformExtent } from 'ol/proj.js';
+
+
+export function transformToLatLonExtent(extent, projection) {
+       const proj = projection.getCode();
+       if (proj === 'EPSG:4326')
+               return toLatLonExtent(extent);
+       var transformed = transformExtent(extent, proj, 'EPSG:4326');
+       return toLatLonExtent(transformed);
+}
+
+export function toLatLonExtent(extent) {
+       return [extent[1], extent[0], extent[3], extent[2]];
+}
\ No newline at end of file