[postgis] ST_TRANSFORM: proposal for postgis projection tranformation

Dave Blasby dblasby at refractions.net
Tue Dec 18 12:57:51 PST 2001

I've been doing a little bit of thinking about adding projection
tranformation support in postgis.  
OGC SF SQL doesnt have function for doing transforms, but SQL/MM (based
on SF SQL) does.



Add optional function  "transform(GEOMETRY,INTEGER)" which takes a
geometry and returns a new geometry
in the spatial referencing system given by the SRID.

1. If transform support not compiled in, tranform() will return the
original geometry (unchanged)
2. If the geometry has SRID -1, then an error is thrown


We're going to be using proj4 to do the tranformation, and steal the
wkt->proj4 parser from Frank's OGR.

1. Add column (proj4text text) to spatial_ref_sys table.  
2. Add function wkt_to_proj4(text) to convert wkt to proj4 strings
3. Add function tranform(GEOMETRY,INTEGER)
	a. extracts SRID from geometry
	b. get proj4text string from spatial_ref_sys table
		i. if proj4text string is empty, call the wkt_to_proj4() function to
get a proj4 string
	c. get proj4text string for new SRID from spatial_ref_sys table
		i.  if proj4text string is empty, call the wkt_to_proj4() function to
get a proj4 string
	d. call a C function convert_geom(geometry,proj4string, proj4string,
			i. allocate 2 new proj4 projection objects
			ii. rip apart all the objects inside the geometry and run them
				proj4 to convert them to the new projection
			iii. rebuild the geometry with the new points.

	I want to add the proj4text column instead of always using the
wkt_to_proj4() function because
	   there will be cases when a better proj4 string can be supplied (ie.
including datum transformation info)

ie. select transform(the_geom,4512) from mygeom;

>From the above discussion, it would appear this query would cause 2 (or
4) subselects for each row in mygeom.  But steps 3b and 3c are cachable
functions, so they should only be called once.

This version of transform() could be very inefficient because it builds
the 2 proj4 objects for *each* row in the query.  I'm not sure if the
proj4 objs can be easily serialized.

what think?

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Unlimited PC-PC calling at Crystal Voice! - Only $1/Mo.
Download your free 30 day trial. Click here.

To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the postgis-users mailing list