st_asbinary seems to change the orientation of polygons

Discussion created by glau on Jan 19, 2014
Latest reply on Jan 20, 2014 by glau
The environment
Oracle on Solaris, SDE , using st_geometry
Oracle Database 11g Enterprise Edition Release - 64bit Production
PL/SQL Release - Production
CORE      Production
TNS for Solaris: Version - Production
NLSRTL Version - Production

ArcSDE 10.1

The problem

While testing an Oracle trigger using a table with st_geometry I found that an valid sdo_geometry, when cast to st_geometry and back becomes invalid because the polygon orientation is reversed (Oracle requires exterior polygons to have anti-clockwise orientation).

I created the attached script to test the various combinations of casting using well-known-text and well-known-binary and have found that when an st_geometry is converted to an sdo_geometry using well-known-binary, the polygon orientation is reversed (anti-clockwise becomes clockwise and vice versa)

This seems to me to be a bug in st_asbinary, at least as implemented in the Solaris libraries we have on our database server.

Can someone please test on their environment and confirm?

The critical parts of my script are the tests 8 and 9 where I construct an st_geometry with coordinates 100 100, 200 100, 200 200, 100 200, 100 100.

Casting to sdo_geometry using wkt gives the correct result, but casting using wkb gives 100 100, 100 200, 200 200, 200 100, 100 100.