Skip to content

Commit

Permalink
Merge pull request #10 from codeforberlin/feature/spatial-queries
Browse files Browse the repository at this point in the history
Fix lat/lon order for filters
  • Loading branch information
k-nut authored Apr 18, 2021
2 parents 095db37 + c243f34 commit ffab72f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def apply(self, query):
return query.filter(
models.School.location.intersects(
func.ST_MakeEnvelope(
self.values['left'], self.values['top'],
self.values['right'], self.values['bottom']
self.values['left'], self.values['bottom'],
self.values['right'], self.values['top']
)
)
)
Expand Down
10 changes: 5 additions & 5 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ def test_schools_by_bounding_box(self, client, db):
# Arrange
for school in [
SchoolFactory.create(location=None),
SchoolFactory.create(location='SRID=4326;POINT(52.00 13.00)'),
SchoolFactory.create(location='SRID=4326;POINT(51.00 11.00)'),
SchoolFactory.create(location='SRID=4326;POINT(50.00 11.00)'),
SchoolFactory.create(location='SRID=4326;POINT(50.00 9.00)')
SchoolFactory.create(location='SRID=4326;POINT(13.00 52.00)'),
SchoolFactory.create(location='SRID=4326;POINT(11.00 51.00)'),
SchoolFactory.create(location='SRID=4326;POINT(11.00 50.00)'),
SchoolFactory.create(location='SRID=4326;POINT(09.00 50.00)')
]:
db.add(school)
db.commit()

# Act
response = client.get("/schools?bb_top=12.00&bb_bottom=10&bb_left=49&bb_right=51")
response = client.get("/schools?bb_top=51.00&bb_bottom=49&bb_left=10&bb_right=12")

# Assert
assert response.status_code == 200
Expand Down

0 comments on commit ffab72f

Please sign in to comment.