Google Groups Home
Help | Sign in
geodjango
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jeremy Dunck  
View profile
 More options Feb 27 2007, 11:22 am
From: "Jeremy Dunck" <jdu...@gmail.com>
Date: Tue, 27 Feb 2007 10:22:01 -0600
Local: Tues, Feb 27 2007 11:22 am
Subject: Re: geodjango
On 2/26/07, Travis Pinney <travis.pin...@gmail.com> wrote:

> Hi Jeremy,

> I have geometric queries working now.

> Right now I have it set up as

> bbox = "POLYGON((-95.36819458007812
> 30.2184318620219,-95.36819458007812
> 30.084840018486364,-95.55702209472656
> 30.084840018486364,-95.55702209472656
> 30.2184318620219,-95.36819458007812 30.2184318620219))"

> schs = School.objects.filter(geom__overlaps=bbox)

Is that done by adding lookup types to django.db.models.QUERY_TERMS ?
If so, we need to avoid that in order to package as a contrib app.

> I am not sure if this is the best way to go about it. You probably
> want the string of bbox to be some type of geos object instead of a
> string, where its __str__ is a WKT.

I didn't realize until just now that postgis could handle the WKT
without the helping GeomFromText(wkt) wrapper.  Nice.  Perhaps that
means we don't need GeoTypes after all.  I'll test that.

> I saw from the wiki that you had geo_near, geo_with, which I guess you
> create a geometry class which inherits from the model class . If you
> have this, where will the geometry be stored for that object?

Actually, no.  objects.geo_near and .geo_within, etc, are methods of a
custom manager and queryset, not model.   I mistakenly left out the
column from the methods.  :-/

http://www.djangoproject.com/documentation/model_api/#managers

In a model, someone might do this:

from django.db import models
from django.contrib.gis import db as gis_db

class School(meta.Model):
   name = ...
   objects = gis_db.Manager()

Assume a location column has already been added to the DB, e.g.
select addgeometrycolumn('','schools_school','location',-1, 'POINT', 2);

Then this would work:
from django.contrib.gis.geometry import Point
x = Point(-95.36819458007812, 30.2184318620219)
School.objects.geo_near('location', point=x, radius=1.0)

This could construct a LinearRing approximating the circle around x
and issue something like:

poly = "POLYGON (...points from curve approximation...)"
_where.append("""
where schools_school.location && %s and
within(schools_school.location, %s)
""")
_params.append(poly, poly)

> I would
> like to go over some of the pros and cons for doing it either way.

Sure.  IRC?

> I am working on the GeometryField right now.

If you think you can do that in a reasonable time, OK, but I hadn't
planned on supporting it right away.  In-app GIS modification wasn't
something I had an immediate need for, so I was hoping to get the
query functionality done sooner.  It was my impression that doing a
custom Field would be fairly involved.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google