From 2f99bb69f87c29ee252a597aa76907cc2d94d9c1 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 27 Sep 2023 18:14:17 +0200 Subject: Search filter: Use traditional GIS order for WGS coordinates. The search filter expects longitude first. --- gis-observation-map | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gis-observation-map b/gis-observation-map index 7fa1360..1b6ba44 100755 --- a/gis-observation-map +++ b/gis-observation-map @@ -178,6 +178,8 @@ def idx_intersects(idx_path, geometries): print(f'WARN: {idx_path}: has {ds.GetLayerCount()} != 1 layers', file=sys.stderr) layer = ds.GetLayer() + source_srs = layer.GetSpatialRef() + transform_srs = osr.CoordinateTransformation(source_srs, target_srs) locFieldIdx = layer.FindFieldIndex("location", True) locations = [] @@ -278,8 +280,8 @@ def geometricFilterPolygon(polygon): raise Exception('Not a linear ring') ring2 = [] for i in range(n): - lat, lon = ring.GetPoint_2D(i) - ring2.append([lat, lon]) + lon, lat = ring.GetPoint_2D(i) + ring2.append([lon, lat]) polygon2.append(ring2) return { @@ -291,6 +293,7 @@ def geometricFilterPolygon(polygon): def geometricFilter(geometries): wgs84 = osr.SpatialReference() wgs84.ImportFromEPSG(4326) # WGS84 + wgs84.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) towgs84 = osr.CoordinateTransformation(target_srs, wgs84) myGeometries = [] -- cgit v1.2.3