Skip to content

Commit

Permalink
fix: fix basic polygon searches
Browse files Browse the repository at this point in the history
Two issues - lat/lon the wrong way round and also the list of points wasn't wrapped in enough lists for GeoJSON.
  • Loading branch information
jrdh committed Sep 19, 2024
1 parent f550886 commit 301d90c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ckanext/versioned_datastore/lib/query/search/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
hash_query,
validate_query,
translate_query,
get_latest_query_version, normalise_query,
get_latest_query_version,
normalise_query,
)


Expand Down Expand Up @@ -265,13 +266,19 @@ def create_multipolygon_filter(coordinates):
"type": "Polygon",
# format the polygon point data appropriately
"coordinates": [
[float(point[1]), float(point[0])] for point in points
[[float(point[0]), float(point[1])] for point in points]
],
}
},
}
should.append(Q("geo_shape", **options))
return Bool(should=should, minimum_should_match=1)

if len(should) == 1:
# no point in producing an or query if we don't need to
return should[0]
else:
# otherwise, create an or over the series of polygons
return Bool(should=should, minimum_should_match=1)

@staticmethod
def create_polygon_filter(coordinates):
Expand Down

0 comments on commit 301d90c

Please sign in to comment.