views:

13

answers:

0

I'm having trouble deciding on how exactly to represent location data in a project I'm starting.

The data is essentially a floor plan, with things existing at points.

My first approach was to create a Point class which things will ForeignKey to. However, I quickly realized several problems.

The first is that I need a way to represent a bordering shape of a Room. A many-to-one relationship almost works, except that a room is defined by a bit more than just the points that border it -- the edges are important, since it isn't clear as to which they belong. I took a step back when I started to think about "Wall" classes to see if there's a better way to do this.

Two operations are important: I need a way to represent a Room that I can easily check if a point exists inside it. I need to be able to fairly quickly draw the room.

If I wasn't trying to use Django's ORM, I'd use a variant of a Quadtree. However, I'd like some input on how I could accomplish this using Django's ORM.