Opened 8 years ago

Closed 6 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 8 years ago.
Updated to include changes to geography_in (cast from text)

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by smarshall

Attachment: geography_cast_patch.tar.gz added

Updated to include changes to geography_in (cast from text)

comment:1 Changed 8 years ago by robe

Milestone: PostGIS 1.5.3PostGIS 1.5.4

comment:2 Changed 8 years ago by pramsey

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 Changed 7 years ago by pramsey

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 Changed 6 years ago by robe


comment:5 Changed 6 years ago by strk

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 Changed 6 years ago by pramsey

Resolution: fixed
Status: newclosed

Done at r10670

Note: See TracTickets for help on using tickets.