Trouble with Admin default_lon, default_lat

114 views
Skip to first unread message

Ulrich Petri

unread,
Oct 13, 2009, 2:13:19 PM10/13/09
to geodjango
Hi,

I'm new to the geo part of geodjango and I'm conpletely in awe about
it.

I have, however, one (for now ;)) problem with the GeoModelAdmin in
that it seems to default to 0.0, 0.0 coordinates for new objects.

After looking at the GeoModelAdmin source I created a subclass and set
default_lon and default_lat (I also confirmed via firebug that the
values did indeed make it to the admin js). However that seems to have
no effect. The map still loads with left border of africa looking at
me.

Am I doing something wrong here or is this a bug?

Thanks
Ulrich

Ben G

unread,
Oct 15, 2009, 7:02:59 PM10/15/09
to geodjango
I have a similar problem and would love to know the answer. I
"solved" it once by reinstalling django, gdal, and proj4, but after a
couple of months it came back. Granted, I'm constantly tinkering with
my web app, I must be inadvertently doing something that interferes
with it.

Now, nothing I try solves it. Anything I try to edit in admin loses
its geometry. The map in admin will not even load in many cases. As
long as I don't edit in Admin, all my points are OK... If you find
anything out, please drop me a note!

help...

Ben

Justin Bronn

unread,
Oct 15, 2009, 8:06:03 PM10/15/09
to geod...@googlegroups.com
Ben G wrote:
> Now, nothing I try solves it. Anything I try to edit in admin loses
> its geometry. The map in admin will not even load in many cases. As
> long as I don't edit in Admin, all my points are OK... If you find
> anything out, please drop me a note!

I believe this is a separate issue than what Ulrich is experiencing.
The OSMGeoAdmin uses the spherical mercator projection (900913), which
in turn requires a 'null' datum shifting file that is not included with
a binary distributions (e.g., ubuntu). On installations missing this
file, when a geometry is transformed to 900913 it is turned to rubbish.

You can either install PROJ.4 from source or generate the null grid
using the `nad2bin` program. An example of generating this file is the
note inside the ubuntu part of the docs:

http://geodjango.org/docs/install.html#ibex

>> I have, however, one (for now ;)) problem with the GeoModelAdmin in
>> that it seems to default to 0.0, 0.0 coordinates for new objects.
>>
>> After looking at the GeoModelAdmin source I created a subclass and set
>> default_lon and default_lat (I also confirmed via firebug that the
>> values did indeed make it to the admin js). However that seems to have
>> no effect. The map still loads with left border of africa looking at
>> me.

In order for the default lon/lat values to be accepted they need to be
in the right coordinate system (e.g., transformed to 900913 if using the
OSMGeoAdmin), and a zoom level must be specified via a `default_zoom`
attribute.

Regards,
-Justin

Ben G

unread,
Oct 16, 2009, 12:09:02 PM10/16/09
to geodjango
Justin,
Thank you for your response. I'm actually doing this on a Windows
machine and the null.lla was included with proj4. But, I did double
check to make sure it is there and I re-installed it to make sure it
wasn't corrupt. Still no go. I think you're right that it's the
transformation from 4326 to 900913 that is causing the bomb out, but
it was working before then stopped. I'm just not good enough with
Django to figure out what's wrong. I appreciate any other ideas you
might have- thanks!

Ulrich Petri

unread,
Nov 2, 2009, 12:46:12 PM11/2/09
to geodjango


On 16 Okt., 01:06, Justin Bronn <jbr...@gmail.com> wrote:
> In order for the default lon/lat values to be accepted they need to be
> in the right coordinate system (e.g., transformed to 900913 if using the
> OSMGeoAdmin), and a zoom level must be specified via a `default_zoom`
> attribute.

Thanks for the response.
I kind of figured this out on my own in the meantime but only by
manualy setting the point in the admin map and then looking at the
coordinates in the database.

Could you point me to some documentation with which python api I can
transform "normal" coordinates (i.e. what you get from the google
geocoder api, e.g. 50.110781,8.679457 is somwhere in the center of
Frankfurt, Germany) to the 900913 system?

Thanks
Ulrich
Reply all
Reply to author
Forward
0 new messages