Reputation: 208
i have a house model with these properties
centerpoint = PointField(srid=0, null=True, blank=True)
front_left = PointField(srid=0, null=True, blank=True)
front_right = PointField(srid=0, null=True, blank=True)
rear_left = PointField(srid=0, null=True, blank=True)
rear_right = PointField(srid=0, null=True, blank=True)
polygon = PolygonField(srid=0, null=True, blank=True)
direction = FloatField(null=True, blank=True) # the direction this house faces, in degrees
and i want to get the houses in front of a specific house... im having a hard time trying to use Distance and polygon__dwithin
i need to get the ones that are touching and the ones that have relative direction of less than 160 degrees:
for that i do:
House.objects.filter(polygon__touches=house_instance.polygon, direction__lt=160)
how can i modify this query to get the houses that are in front maximum one block and the ones that are one house away from my reference house?
EDIT: so "facing direction" its actually the direction field that contains in degrees the direction the house is facing by the front door
and this is an image of what i need in term of neighbors,
my polygon field its the actual "area" of the house in points...
sorry if my terminology is wacky im very new at this...
Upvotes: 0
Views: 180
Reputation: 30502
If you also hold the polygons (or even lines) of the streets, you can query for the street facing the house, and then query which houses face this street.
A cool workaround could be using reverse geocoding (for example, by google maps here to retrieve the house's street address and later the street addresses of the other houses and try matching them. This would work only if the reverse geocoding service possess this data for your area and is accurate enough.
Upvotes: 1