bug: error in code for geopoly_ccw function

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

bug: error in code for geopoly_ccw function

Graham Hardman

In my posting on 20th November I supplied output from the cli buit from
the snapshot that includes the new geopoly function geopoly_ccw.

That output showed incorrect results being returned from an attempt to
reverse the direction of a polygon in CW mode after a mirror transform
of a CCW polygon about the X axis.

There has been no response to that mail, so as I am convinced there is
an error in the program code I decided to resend my report rephrased as
a bug report.

Looking at the code from the sqlite3.c file I can see that the for loop
"for(ii=2, jj=p->nVertex*2 - 4; ii<jj; ii+=2, jj-=2)" will always leave
the first and last vertices untouched. Whilst this may make sense if the
code was directed at polygon data formatted as a Json string it is not
correct for data coded as a blob, because then the 2nd vertex must be
interchanged with the final vertex. This analysis is supported by my
previous posting - the relevant part of which is copied below.

sqlite> create virtual table newtab using geopoly(a,b,c);

sqlite> insert into newtab (_shape) values

sqlite> select geopoly_json(_shape) from newtab;

sqlite> select geopoly_json(geopoly_xform(_shape, 1,0,0,-1,0,0)) from

sqlite> select geopoly_json(geopoly_ccw(geopoly_xform(_shape,
1,0,0,-1,0,0))) from newtab;

The correct output should have been


Please accept my apologies if this matter had already been taken into
consideration. I do understand that the authors are very busy people.


sqlite-users mailing list
[hidden email]