# # Test cases for the geopoly_overlap() function of the geopoly.c extension. # To run these tests: # # (1) Build the geopoly extension and put the shared library in # the local directory. # # (2) Run: ./sqlite3 output.html # # (3) View the output.html in a web browser to see if the results # are correct. # .load ./geopoly CREATE TABLE polys( name TEXT, poly TEXT ); INSERT INTO polys(name,poly) VALUES ('rectangle-2', '[[0,0],[200,0],[200,200],[0,200],[0,0]]'), ('rectangle-1', '[[150,50],[200,50],[200,100],[150,100],[150,50]]'), ('backslash', '[[0,200],[200,0],[200,25],[0,225],[0,200]]'), ('forwardslash', '[[0,0],[200,200],[200,225],[0,25],[0,0]]'), ('diamond-2,0-2', '[[100,0],[200,100],[100,200],[0,100],[100,0]]'), ('diamond-2,1-3', '[[200,0],[300,100],[200,200],[100,100],[200,0]]'), ('diamond-2,2-4', '[[300,0],[400,100],[300,200],[200,100],[300,0]]'), ('v-bowtie', '[[50,0],[150,0],[125,75],[125,125],[150,200],[50,200], [75,125],[75,75],[50,0]]'), ('h-bowtie', '[[0,50],[75,75],[125,75],[200,50],[200,150],[125,125], [75,125],[0,150],[0,50]]'), ('letter-E', '[[0,0],[90,0],[20,10],[20,90],[80,100],[20,110],[20,190], [90,200],[0,200],[0,0]]'), ('backward-C', '[[30,50],[120,40],[120,160],[30,150],[100,140], [100,60],[30,50]]'), ('counter-cw', '[[100,200],[0,100],[100,0],[200,100],[150,150],[100,100], [150,140],[190,100],[100,10],[10,100],[100,190],[100,200]]'), ('clockwise', '[[200,150],[150,180],[50,100],[100,35],[150,100], [100,45],[60,100],[150,170],[200,140],[200,150]]'); CREATE TABLE overlap_meanings(id INTEGER PRIMARY KEY, x TEXT); INSERT INTO overlap_meanings(id,x) VALUES (0, 'disjoint'), (1, 'intersecting'), (2, 'A inside of B'), (3, 'B inside of A'), (4, 'identical'); .print .print

Note:

.print

Directions are reversed because SVG uses a left-handed .print coordinate system

.separator \n SELECT '


', '', geopoly_svg(x1.poly,'fill="blue"','fill-opacity="0.5"'), geopoly_svg(x2.poly,'fill="green"','fill-opacity="0.5"'), '
',
  'blue (A):  '||x1.name,
  'green (B): '||x2.name,
  (SELECT x FROM overlap_meanings
    WHERE id=geopoly_overlap(x1.poly,x2.poly)),
  '
' FROM polys AS x1, polys AS x2;