Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Last active December 27, 2015 14:09
Show Gist options
  • Save knownasilya/7338955 to your computer and use it in GitHub Desktop.
Save knownasilya/7338955 to your computer and use it in GitHub Desktop.
filter
geom = models.MultiPolygonField(srid=4326, null=True)
neighborhoodBounds = Polygon.from_bbox(data['neighborhoodBounds'].split(','))
neighborhoodBounds.srid = 4326
#print neighborhoodBounds
#POLYGON ((40.8116690000000020 -73.9644080000000059, 40.8116690000000020 -73.9349679999999978, 40.8355379999999997 -73.9349679999999978, 40.8355379999999997 -73.9644080000000059, 40.8116690000000020 -73.9644080000000059))
# No results..
filtered = BuildingData.objects.filter(geom__within = neighborhoodBounds)
# Doesn't work either:
#select bd.bin from buildings_buildingdata as bd
#where bin = 2082444 AND ST_Within(bd.geom,
#ST_GeometryFromText('POLYGON ((40.8408170000000013 -73.7898320000000041, 40.8408170000000013 -73.7797680000000042, 40.8467830000000021 -73.7797680000000042, 40.8467830000000021 -73.7898320000000041, 40.8408170000000013 -73.7898320000000041))'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment