Opened 5 years ago

Closed 5 years ago

#4370 closed enhancement (wontfix)

Remove ST_ForceRHR

Reported by: dbaston Owned by: pramsey
Priority: medium Milestone: PostGIS 3.0.0
Component: postgis Version: master
Keywords: Cc:

Description

I'd suggest removing ST_ForceRHR for PostGIS 3.0, now that ST_ForcePolygonCW is available. The definition of "right-hand-rule" implemented by ST_ForceRHR is the opposite of how "right-hand-rule" is typically defined, including in specs such as GeoJSON.

Change History (8)

comment:1 by strk, 5 years ago

I don't like change for the sake of change. The function existed for a long time, is properly documented, what's wrong with keeping ? You find it confusing ? I find it more confusing to have a tool that keeps changing for no reason. "PolygonCW" isn't clear either, to me, btw….

My mnemonic for "right hand rule" is that the area covered by the polygon is on your right hand if you walk on the polygon boundary. Is that not the case ?

comment:2 by strk, 5 years ago

strk=# SELECT ST_AsText(ST_ForceRHR(ST_MakePolygon('LINESTRING(0 0, 10 0, 5 10, 0 0)'::geometry)));

POLYGON((0 0,5 10,10 0,0 0))

strk=# select postgis_lib_version(), postgis_svn_version();

3.0.0dev | 17364

comment:3 by dbaston, 5 years ago

The term "right-hand rule" is commonly understood to mean the opposite; if you hold your right hand with your thumb facing your face, your fingers curl in a counter-clockwise direction. See for example the GeoJSON spec:

https://tools.ietf.org/html/rfc7946#section-3.1.6

Or the GDAL documentation:

https://www.gdal.org/drv_geojson.html

See also #3689 and https://github.com/tilemill-project/tilemill/issues/2110#issuecomment-169725086

Last edited 5 years ago by dbaston (previous) (diff)

comment:4 by strk, 5 years ago

if you hold your right hand with your thumb facing your face, your fingers curl in a counter-clockwise direction.

Should the above be clearer than my definition ? I swear I don't understand it, how does my face interact with the polygon's interior ?

comment:5 by pramsey, 5 years ago

Both mnemonics are pretty good, I learned them both, at different times. I learned the hand-in-the-polygon in a GIS context in BC though, and it is exactly from that context that we got the function signature. The FME, for example, came out of BC in the same era and has the same understanding of what "right hand rule" means https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/orientor.htm.

I am with strk, we should keep the function, explain what we mean by "right hand rule" and use the clock to further be clear about what we mean, even though I'm also with Dan, and note that the computer graphics definition seems to have become the commonly accepted one, and the hand-in-the-water version is hard to find in the wild anymore.

comment:6 by pramsey, 5 years ago

In a nod to the problems of history, FME actually uses "right hand rule" in both senses in its own documentation. In the "GIS sense" in its documentation of vertex order for bounded areas, and in "computer graphics" sense in documentation of orientation angles in 3-space, (see https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/pointpropertyextractor.htm in the Orientation Mode section). There is no spoon.

comment:7 by dbaston, 5 years ago

The only problem with explaining what we mean (and we do) is that it supposes that someone is going to read the docs for what appears to be an obvious function.

Anyway, it just seemed like a good opportunity to remove a wart in a major-version change. Not a hill I want do die on.

comment:8 by dbaston, 5 years ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.