Opened 13 years ago

Closed 12 years ago

#799 closed enhancement (fixed)

Patch for casting geometry to geography

Reported by: smarshall Owned by: pramsey
Priority: medium Milestone: PostGIS 2.1.0
Component: postgis Version: 1.5.X
Keywords: Cc:


Related to a post by Radu Ilie on Jan 20, 2011, I have a patch for casting from geometry to geography that solves his problem. In particular, it will transform coordinates into the desired range for geography objects (-90 to 90 lat, -180 to 180 lon). The previous version detected this problem, but simply issued an error if it occurred.

The attached files add one new external function to the the postgis library (lwgeom_force_geodetic) and uses it in the function that casts geometry objects to geography objects (Datum geography_in). The logic is a very simple clone of the lwgeom_check_geodetic function, except it fixes any descrepancies it finds.

The API at the SQL level is not changed at all.

Attachments (1)

geography_cast_patch.tar.gz (1.9 KB ) - added by smarshall 13 years ago.
Updated to include changes to geography_in (cast from text)

Download all attachments as: .zip

Change History (7)

by smarshall, 13 years ago

Attachment: geography_cast_patch.tar.gz added

Updated to include changes to geography_in (cast from text)

comment:1 by robe, 13 years ago

Milestone: PostGIS 1.5.3PostGIS 1.5.4

comment:2 by pramsey, 13 years ago

Should note that the idea of auto-normalizing (and auto-projecting) coordinates while casting to geography was explicitly rejected by folks during the initial development. This issue should be discussed on postgis-devel before being applied.

comment:3 by pramsey, 12 years ago

Milestone: PostGIS 1.5.4PostGIS 2.1.0

I added geography nudging which pushes silghtly offside points onside. I don't think we can accept this for 1.5 in any event, it's a big behavior change.

comment:4 by robe, 12 years ago


comment:5 by strk, 12 years ago

Couple of comments:

  1. It would be better to raise a WARNING or NOTICE about normalization
  2. There may be the possibility to reduce coordinate copies in ptarray_force_geodetic by directly referencing the serialized point array.

comment:6 by pramsey, 12 years ago

Resolution: fixed
Status: newclosed

Done at r10670

Note: See TracTickets for help on using tickets.