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
hi,

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
('[[0,0],[88,0],[88,80],[60,80],[30,40],[0,40],[0,0]]');

sqlite> select geopoly_json(_shape) from newtab;
[[0.0,0.0],[88.0,0.0],[88.0,80.0],[60.0,80.0],[30.0,40.0],[0.0,40.0],[0.0,0.0]]

sqlite> select geopoly_json(geopoly_xform(_shape, 1,0,0,-1,0,0)) from
newtab;
[[0.0,0.0],[88.0,0.0],[88.0,-80.0],[60.0,-80.0],[30.0,-40.0],[0.0,-40.0],[0.0,0.0]]

sqlite> select geopoly_json(geopoly_ccw(geopoly_xform(_shape,
1,0,0,-1,0,0))) from newtab;
[[0.0,0.0],[30.0,-40.0],[60.0,-80.0],[88.0,-80.0],[88.0,0.0],[0.0,-40.0],[0.0,0.0]]


The correct output should have been

[[0,0][0,-40][30,-40][60,-80][88,-80][88,0][0,0]]

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

regards,

Graham
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users