aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2023-09-27 18:14:17 +0200
committerGuilhem Moulin <guilhem@fripost.org>2023-09-27 18:14:17 +0200
commit2f99bb69f87c29ee252a597aa76907cc2d94d9c1 (patch)
tree046afd69bbec76e25f67a5a930f931197cca0bd4
parent4f6ec04e1c14008db19e4090c08feccb82634a48 (diff)
Search filter: Use traditional GIS order for WGS coordinates.
The search filter expects longitude first.
-rwxr-xr-xgis-observation-map7
1 files 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 = []