[postgis-devel] [PostGIS] #304: Geography Best SRID or ?

PostGIS trac at osgeo.org
Sun Nov 15 14:29:57 PST 2009


#304: Geography Best SRID or ?
----------------------+-----------------------------------------------------
  Reporter:  robe     |       Owner:  pramsey      
      Type:  defect   |      Status:  reopened     
  Priority:  medium   |   Milestone:  postgis 1.5.0
 Component:  postgis  |     Version:  trunk        
Resolution:           |    Keywords:               
----------------------+-----------------------------------------------------
Changes (by robe):

  * status:  closed => reopened
  * resolution:  fixed =>

Comment:

 Not so fast cowboy. cough cough.  While it now passes the 2 above tests,
 it still fails my more exhaustive shotgun test even in cases where a
 simple utm hack gives a pleasing answer.


 {{{
 --helper function copied from wiki
  CREATE OR REPLACE FUNCTION utmzone(geometry)
    RETURNS integer AS
  $BODY$
  DECLARE
      geomgeog geometry;
      zone int;
      pref int;

  BEGIN
      geomgeog:= ST_Transform($1,4326);

      IF (ST_Y(geomgeog))>0 THEN
         pref:=32600;
      ELSE
         pref:=32700;
      END IF;

      zone:=floor((ST_X(geomgeog)+180)/6)+1;

      RETURN zone+pref;
  END;
  $BODY$ LANGUAGE 'plpgsql' IMMUTABLE
    COST 100;

 -- shotgun test
 SELECT ST_AsText(the_geog) as the_pt, ST_Area(ST_Buffer(the_geog,10)) As
 the_area,
 ST_Area(geography(ST_Transform(ST_Buffer(ST_Transform(geometry(the_geog),utm_srid),10),4326)))
 As geog_utm_area
 FROM (SELECT geography(ST_SetSRID(ST_Point(i*0.5,j*0.5),4326)) As
 the_geog, utmzone(ST_SetSRID(ST_Point(i*0.5,j*0.5),4326)) As utm_srid
         FROM generate_series(-350,350) As i
                 CROSS JOIN generate_series(-175,175) As j
                 ) As foo
 WHERE ST_Area(ST_Buffer(the_geog,10)) NOT between 310 and 314
 LIMIT 10;

 }}}

 Do not pass go until you can pass the above (e.g. no answers returned), or
 utm doesn't give a better answer or you can give a 4 paragraph or less
 reason why your best is the best you can do.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/304#comment:2>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list