/ Check-in [39209251]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test cases for geopoly_overlap(). (Later:) This branch is closed and the development of the geopoly logic is moved to the rtree-geopoly branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | geojson
Files: files | file ages | folders
SHA3-256:3920925128c2a91661dea5591c5d1c3762dd2c294782d5d24fe3f06546849f46
User & Date: drh 2018-05-12 23:59:28
Original Comment: Add test cases for geopoly_overlap().
Context
2018-05-12
23:59
Add test cases for geopoly_overlap(). (Later:) This branch is closed and the development of the geopoly logic is moved to the rtree-geopoly branch. Closed-Leaf check-in: 39209251 user: drh tags: geojson
23:56
Merge changes from trunk. check-in: 715740e3 user: drh tags: geojson
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added ext/misc/geopoly-test1.txt.





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
# 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 <geopoly-test1.txt >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 <html>
.print <h1>Note:</h1>
.print <p>Directions are reversed because SVG uses a left-handed
.print coordinate system<p>
.separator \n
SELECT
  '<hr>',
  '<svg width="400" height="225">',
  geopoly_svg(x1.poly,'fill="blue"','fill-opacity="0.5"'),
  geopoly_svg(x2.poly,'fill="green"','fill-opacity="0.5"'),
  '</svg><pre>',
  'blue (A):  '||x1.name,
  'green (B): '||x2.name,
  (SELECT x FROM overlap_meanings
    WHERE id=geopoly_overlap(x1.poly,x2.poly)),
  '</pre>'
  FROM polys AS x1, polys AS x2;