[OSM-dev] osm2pgsql - strange behaviour

James Marca jmarca at translab.its.uci.edu
Fri Jun 22 18:41:09 BST 2007


On Fri, Jun 22, 2007 at 03:47:17PM +0100, Artem Pavlenko scribeth thusly:
> 
> On 22 Jun 2007, at 14:39, Jon Burgess wrote:
> 
> >Yes the code reprojects to mercator as part of the import (search for
> >references to 'project'). You can switch to latlong by commenting out
> >the reprojection (you'll probably also want to change the SCALE used
> >for the fixed point in middle-ram.c too if you change this otherwise
> >you'll lose some precision).
> >
> >I suppose that this SRID is wrong and should of been changed when the
> >reprojection got added. Anyone know what SRID would be appropriate?
> >
> >
> 
> I think we can change it to 41001. Apparently there's no 'official'  
> code for Mercator but google return 41001.

That won't work in postgis unless there actually is a defined
srid=41001 in the table spatial_ref_sys;

check by doing:
select * from spatial_ref_sys where srid=41001;

With a default install of srid table, I get nothing.

Two thoughts on this.  First, you can "define" a google type
projection as 

insert into spatial_ref_sys (srid,auth_name,proj4text) values
(41001,GoogleMerc,'+proj=merc +latts=0 +lon0=0 +k=1.0 +x0=0 +y0=0  +units=m +a=6378137.0 +b=6378137.0');

(obviously make sure that srid=41001 is empty before you do that)

I got the proj text from :

http://cfis.savagexi.com/articles/2006/05/03/google-maps-deconstructed

but I am not a proj guru---see also the note at the bottom of
http://proj.maptools.org/faq.html

Using that I can convert to and from the different srid, but I am not
so sure it is "accurate"

The other alternative is to use a UTM projection in your zone.  I use
srid=32611 for zone 11.  But I am not a cartographer and have not idea
if that is a good approach for this.  32611 is just what I use when I
plot local maps (I live in zone 11).

James



> Artem
> >On 22/06/07, Artem Pavlenko <artem at mapnik.org> wrote:
> >>Nick,
> >>
> >>osm2pgsql projects coordinates to Mercator.
> >>
> >>Artem
> >>
> >>On 22 Jun 2007, at 13:24, Nick Black wrote:
> >>
> >>Hello,
> >>
> >>Trying to run osm2pgsql I get some strange values in the geometry  
> >>columns of
> >>postgis.  For example, if I import the following made up osm file:
> >>
> >>
> >><?xml version="1.0" encoding="UTF-8"?>
> >><osm version="0.4" generator="OpenStreetMap server">
> >>  <way id="1" visible="true"
> >>timestamp="2006-08-18T22:51:40+01:00" user="dankarran">
> >>    <seg id="1"/>
> >>    <tag k="created_by" v="JOSM"/>
> >>    <tag k="name" v="Marine Drive"/>
> >>    <tag k="highway" v="secondary"/>
> >>  </way>
> >>  <segment id="1"  visible="true"
> >>timestamp="2006-08-18T22:51:40+01:00" from='1' to='2'>
> >>   </segment>
> >>  <node id='1'  timestamp='2006-08-15 02:08:50' visible='true'  
> >>lat='1.2345'
> >>lon='-6.789'>
> >>    <tag k='source' v='PGS' />
> >>     <tag k='created_by' v='almien_coastlines' />
> >>  </node>
> >>  <node id='2'  timestamp='2006-08-15 02:08:50' visible='true'  
> >>lat='2.2345'
> >>lon='-7.789'>
> >>    <tag k='source' v='PGS' />
> >>    <tag k='created_by' v='almien_coastlines' />
> >>  </node>
> >>
> >></osm>
> >>
> >>and then do :
> >>
> >># select astext(way) from planet_osm_roads ;
> >>
> >>I get:
> >>
> >> LINESTRING(-755748.02 136514.64,-867067.51 247141.71)
> >>
> >>Which isnt what the values should be. Is there some kind of  
> >>reprojection
> >>going on somewhere?  I have geometry columns and spatial ref sys  
> >>set up
> >>seemingly correctly, with planet_osm_roads referencing srid 4326,  
> >>which has
> >>the following entry ins spatial_ref_sys:
> >>
> >>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS
> >>84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84 
> >>[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 
> >>0,AUTHORITY["EPSG","8901"]],UNIT["degree",
> >>0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY 
> >>["EPSG","4326"]]
> >>| +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
> >>
> >>I'm taking a look through the osm2pgsql src to see how the database
> >>connections work, but the c++ will take me a while to figure out...
> >>




More information about the dev mailing list