Re: Feasibility of postgis fields?

2006-06-15 Thread nick

Hi thanks for the replies  - I'm surprised this is the only way to do
it as using the model api would seem neater.  Have you encountered many
problems separating out the geom fields like this (eg - not being
searchable in admin / whatever)?

Yes I'd be interested in an example of how custom sql is implemented
within the model code thanks.

So how are you injecting the data into the database?  Sounds like you'd
need to do it in 2 steps using this approach - 1) create the model
instance and commit, then 2) execute a method on the model from your
dataloader to manually update the geom field afterwards with custom
sql.

Thanks, Nick


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Feasibility of postgis fields?

2006-06-15 Thread Adrian Holovaty

On 6/15/06, nick <[EMAIL PROTECTED]> wrote:
> Hi - as a person investigating django for managing metadata that will
> also have a spatial/gis component (lat/lon bounding boxes), would the
> reccommended approach be to create a new field for use in my models?
> Admittedly this would be specific to the postgres+postgis backend.
>
> I'd be looking to implement a basic a polygon datatype and at runtime
> allowing for queries to search for intersections of these with
> user-defined points.  The postgres+postgis && operator acheives this in
> simple sql:
>
> SELECT
>   ID, NAME
> FROM ROADS_GEOM
> WHERE
>   GEOM && GeomFromText('POLYGON((191232 243117,191232 243119,191234
> 243117,191232 243117))',-1);

Hey Nick,

I've been using Django successfully with PostgreSQL/PostGIS for more
than a year on http://www.chicagocrime.org/ . What I do is
deliberately *exclude* the "GEOM" field from being defined in the
model (because it doesn't yet have a Python/Django field class), and I
use custom SQL statements in model methods to do the queries I want to
do. Django doesn't really care if the database defines columns that
aren't in the model, as long as you don't try to insert/change into
that undefined field with the Django database API -- so I'm exploiting
that.

So, yeah, it's totally possible and easy to do. I'd be happy to post
sample model code if you're interested.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Feasibility of postgis fields?

2006-06-15 Thread Jeroen Ruigrok van der Werven

Hi Nick,

On 6/15/06, nick <[EMAIL PROTECTED]> wrote:
> Hi - as a person investigating django for managing metadata that will
> also have a spatial/gis component (lat/lon bounding boxes), would the
> reccommended approach be to create a new field for use in my models?
> Admittedly this would be specific to the postgres+postgis backend.

About custom fields I cannot tell you anything, but I recently helped
the developer(s) of GeoTypes to release 0.6.0, which is also
installable through CheeseShop/easy_install. I think this could be
helpful providing you with the OpenGIS/PostGIS geometry types at
least.

See http://cheeseshop.python.org/pypi/GeoTypes/

-- 
Jeroen Ruigrok van der Werven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Feasibility of postgis fields?

2006-06-15 Thread nick

Hi - as a person investigating django for managing metadata that will
also have a spatial/gis component (lat/lon bounding boxes), would the
reccommended approach be to create a new field for use in my models?
Admittedly this would be specific to the postgres+postgis backend.

I'd be looking to implement a basic a polygon datatype and at runtime
allowing for queries to search for intersections of these with
user-defined points.  The postgres+postgis && operator acheives this in
simple sql:

SELECT
  ID, NAME
FROM ROADS_GEOM
WHERE
  GEOM && GeomFromText('POLYGON((191232 243117,191232 243119,191234
243117,191232 243117))',-1);

See http://postgis.refractions.net/docs/

Has anyone done this already and and I likely to run into any brick
walls from the framework if I attempt to implement additional backend
functionality through model fields?

An aside, there seems to be no implementation of interfaces for the
existing field types.  Is this deliberate?  Maybe I'm barking up the
wrong tree if they're not meant to be extended.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---