3 # This is a visual test case for the geopoly virtual table.
5 # Run this script in the sqlite3 CLI, and redirect output into an
6 # HTML file. This display the HTML in a webbrowser.
10 ** Lots of shapes to be displayed over a 1000x800 canvas.
12 CREATE TEMP TABLE basis(name TEXT, jshape TEXT);
13 INSERT INTO basis(name,jshape) VALUES
14 ('box-20','[[0,0],[20,0],[20,20],[0,20],[0,0]]'),
15 ('house-70','[[0,0],[50,0],[50,50],[25,70],[0,50],[0,0]]'),
16 ('line-40','[[0,0],[40,0],[40,5],[0,5],[0,0]]'),
17 ('line-80','[[0,0],[80,0],[80,7],[0,7],[0,0]]'),
18 ('arrow-50','[[0,0],[25,25],[0,50],[15,25],[0,0]]'),
19 ('triangle-30','[[0,0],[30,0],[15,30],[0,0]]'),
20 ('angle-30','[[0,0],[30,0],[30,30],[26,30],[26,4],[0,4],[0,0]]'),
21 ('star-10','[[1,0],[5,2],[9,0],[7,4],[10,8],[7,7],[5,10],[3,7],[0,8],[3,4],[1,0]]');
22 CREATE TEMP TABLE xform(A,B,C,D,clr);
23 INSERT INTO xform(A,B,clr) VALUES
28 CREATE TEMP TABLE xyoff(id1,id2,xoff,yoff,PRIMARY KEY(id1,id2,xoff,yoff))
30 INSERT INTO xyoff VALUES(1,1,811,659);
31 INSERT INTO xyoff VALUES(1,1,235,550);
32 INSERT INTO xyoff VALUES(1,1,481,620);
33 INSERT INTO xyoff VALUES(1,1,106,494);
34 INSERT INTO xyoff VALUES(1,1,487,106);
35 INSERT INTO xyoff VALUES(1,1,817,595);
36 INSERT INTO xyoff VALUES(1,1,240,504);
37 INSERT INTO xyoff VALUES(1,1,806,457);
38 INSERT INTO xyoff VALUES(1,1,608,107);
39 INSERT INTO xyoff VALUES(1,1,768,662);
40 INSERT INTO xyoff VALUES(1,2,808,528);
41 INSERT INTO xyoff VALUES(1,2,768,528);
42 INSERT INTO xyoff VALUES(1,2,771,171);
43 INSERT INTO xyoff VALUES(1,2,275,671);
44 INSERT INTO xyoff VALUES(1,2,326,336);
45 INSERT INTO xyoff VALUES(1,2,690,688);
46 INSERT INTO xyoff VALUES(1,2,597,239);
47 INSERT INTO xyoff VALUES(1,2,317,528);
48 INSERT INTO xyoff VALUES(1,2,366,223);
49 INSERT INTO xyoff VALUES(1,2,621,154);
50 INSERT INTO xyoff VALUES(1,3,829,469);
51 INSERT INTO xyoff VALUES(1,3,794,322);
52 INSERT INTO xyoff VALUES(1,3,358,387);
53 INSERT INTO xyoff VALUES(1,3,184,444);
54 INSERT INTO xyoff VALUES(1,3,729,500);
55 INSERT INTO xyoff VALUES(1,3,333,523);
56 INSERT INTO xyoff VALUES(1,3,117,595);
57 INSERT INTO xyoff VALUES(1,3,496,201);
58 INSERT INTO xyoff VALUES(1,3,818,601);
59 INSERT INTO xyoff VALUES(1,3,541,343);
60 INSERT INTO xyoff VALUES(1,4,603,248);
61 INSERT INTO xyoff VALUES(1,4,761,649);
62 INSERT INTO xyoff VALUES(1,4,611,181);
63 INSERT INTO xyoff VALUES(1,4,607,233);
64 INSERT INTO xyoff VALUES(1,4,860,206);
65 INSERT INTO xyoff VALUES(1,4,310,231);
66 INSERT INTO xyoff VALUES(1,4,727,539);
67 INSERT INTO xyoff VALUES(1,4,660,661);
68 INSERT INTO xyoff VALUES(1,4,403,133);
69 INSERT INTO xyoff VALUES(1,4,619,331);
70 INSERT INTO xyoff VALUES(2,1,712,578);
71 INSERT INTO xyoff VALUES(2,1,567,313);
72 INSERT INTO xyoff VALUES(2,1,231,423);
73 INSERT INTO xyoff VALUES(2,1,490,175);
74 INSERT INTO xyoff VALUES(2,1,898,353);
75 INSERT INTO xyoff VALUES(2,1,589,483);
76 INSERT INTO xyoff VALUES(2,1,188,462);
77 INSERT INTO xyoff VALUES(2,1,720,106);
78 INSERT INTO xyoff VALUES(2,1,793,380);
79 INSERT INTO xyoff VALUES(2,1,154,396);
80 INSERT INTO xyoff VALUES(2,2,324,218);
81 INSERT INTO xyoff VALUES(2,2,120,327);
82 INSERT INTO xyoff VALUES(2,2,655,133);
83 INSERT INTO xyoff VALUES(2,2,516,603);
84 INSERT INTO xyoff VALUES(2,2,529,572);
85 INSERT INTO xyoff VALUES(2,2,481,212);
86 INSERT INTO xyoff VALUES(2,2,802,107);
87 INSERT INTO xyoff VALUES(2,2,234,509);
88 INSERT INTO xyoff VALUES(2,2,501,269);
89 INSERT INTO xyoff VALUES(2,2,349,553);
90 INSERT INTO xyoff VALUES(2,3,495,685);
91 INSERT INTO xyoff VALUES(2,3,897,372);
92 INSERT INTO xyoff VALUES(2,3,350,681);
93 INSERT INTO xyoff VALUES(2,3,832,257);
94 INSERT INTO xyoff VALUES(2,3,778,149);
95 INSERT INTO xyoff VALUES(2,3,683,426);
96 INSERT INTO xyoff VALUES(2,3,693,217);
97 INSERT INTO xyoff VALUES(2,3,746,317);
98 INSERT INTO xyoff VALUES(2,3,805,369);
99 INSERT INTO xyoff VALUES(2,3,336,585);
100 INSERT INTO xyoff VALUES(2,4,890,255);
101 INSERT INTO xyoff VALUES(2,4,556,565);
102 INSERT INTO xyoff VALUES(2,4,865,555);
103 INSERT INTO xyoff VALUES(2,4,230,293);
104 INSERT INTO xyoff VALUES(2,4,247,251);
105 INSERT INTO xyoff VALUES(2,4,730,563);
106 INSERT INTO xyoff VALUES(2,4,318,282);
107 INSERT INTO xyoff VALUES(2,4,220,431);
108 INSERT INTO xyoff VALUES(2,4,828,336);
109 INSERT INTO xyoff VALUES(2,4,278,525);
110 INSERT INTO xyoff VALUES(3,1,324,656);
111 INSERT INTO xyoff VALUES(3,1,625,362);
112 INSERT INTO xyoff VALUES(3,1,155,570);
113 INSERT INTO xyoff VALUES(3,1,267,433);
114 INSERT INTO xyoff VALUES(3,1,599,121);
115 INSERT INTO xyoff VALUES(3,1,873,498);
116 INSERT INTO xyoff VALUES(3,1,789,520);
117 INSERT INTO xyoff VALUES(3,1,656,378);
118 INSERT INTO xyoff VALUES(3,1,831,601);
119 INSERT INTO xyoff VALUES(3,1,256,471);
120 INSERT INTO xyoff VALUES(3,2,332,258);
121 INSERT INTO xyoff VALUES(3,2,305,463);
122 INSERT INTO xyoff VALUES(3,2,796,341);
123 INSERT INTO xyoff VALUES(3,2,830,229);
124 INSERT INTO xyoff VALUES(3,2,413,271);
125 INSERT INTO xyoff VALUES(3,2,269,140);
126 INSERT INTO xyoff VALUES(3,2,628,441);
127 INSERT INTO xyoff VALUES(3,2,747,643);
128 INSERT INTO xyoff VALUES(3,2,584,435);
129 INSERT INTO xyoff VALUES(3,2,784,314);
130 INSERT INTO xyoff VALUES(3,3,722,233);
131 INSERT INTO xyoff VALUES(3,3,815,421);
132 INSERT INTO xyoff VALUES(3,3,401,267);
133 INSERT INTO xyoff VALUES(3,3,451,650);
134 INSERT INTO xyoff VALUES(3,3,329,485);
135 INSERT INTO xyoff VALUES(3,3,878,370);
136 INSERT INTO xyoff VALUES(3,3,162,616);
137 INSERT INTO xyoff VALUES(3,3,844,183);
138 INSERT INTO xyoff VALUES(3,3,161,216);
139 INSERT INTO xyoff VALUES(3,3,176,676);
140 INSERT INTO xyoff VALUES(3,4,780,128);
141 INSERT INTO xyoff VALUES(3,4,566,121);
142 INSERT INTO xyoff VALUES(3,4,646,120);
143 INSERT INTO xyoff VALUES(3,4,223,557);
144 INSERT INTO xyoff VALUES(3,4,251,117);
145 INSERT INTO xyoff VALUES(3,4,139,209);
146 INSERT INTO xyoff VALUES(3,4,813,597);
147 INSERT INTO xyoff VALUES(3,4,454,538);
148 INSERT INTO xyoff VALUES(3,4,616,198);
149 INSERT INTO xyoff VALUES(3,4,210,159);
150 INSERT INTO xyoff VALUES(4,1,208,415);
151 INSERT INTO xyoff VALUES(4,1,326,665);
152 INSERT INTO xyoff VALUES(4,1,612,133);
153 INSERT INTO xyoff VALUES(4,1,537,513);
154 INSERT INTO xyoff VALUES(4,1,638,438);
155 INSERT INTO xyoff VALUES(4,1,808,269);
156 INSERT INTO xyoff VALUES(4,1,552,121);
157 INSERT INTO xyoff VALUES(4,1,100,189);
158 INSERT INTO xyoff VALUES(4,1,643,664);
159 INSERT INTO xyoff VALUES(4,1,726,378);
160 INSERT INTO xyoff VALUES(4,2,478,409);
161 INSERT INTO xyoff VALUES(4,2,497,507);
162 INSERT INTO xyoff VALUES(4,2,233,148);
163 INSERT INTO xyoff VALUES(4,2,587,237);
164 INSERT INTO xyoff VALUES(4,2,604,166);
165 INSERT INTO xyoff VALUES(4,2,165,455);
166 INSERT INTO xyoff VALUES(4,2,320,258);
167 INSERT INTO xyoff VALUES(4,2,353,496);
168 INSERT INTO xyoff VALUES(4,2,347,495);
169 INSERT INTO xyoff VALUES(4,2,166,622);
170 INSERT INTO xyoff VALUES(4,3,461,332);
171 INSERT INTO xyoff VALUES(4,3,685,278);
172 INSERT INTO xyoff VALUES(4,3,427,594);
173 INSERT INTO xyoff VALUES(4,3,467,346);
174 INSERT INTO xyoff VALUES(4,3,125,548);
175 INSERT INTO xyoff VALUES(4,3,597,680);
176 INSERT INTO xyoff VALUES(4,3,820,445);
177 INSERT INTO xyoff VALUES(4,3,144,330);
178 INSERT INTO xyoff VALUES(4,3,557,434);
179 INSERT INTO xyoff VALUES(4,3,254,315);
180 INSERT INTO xyoff VALUES(4,4,157,339);
181 INSERT INTO xyoff VALUES(4,4,249,220);
182 INSERT INTO xyoff VALUES(4,4,391,323);
183 INSERT INTO xyoff VALUES(4,4,589,429);
184 INSERT INTO xyoff VALUES(4,4,859,592);
185 INSERT INTO xyoff VALUES(4,4,337,680);
186 INSERT INTO xyoff VALUES(4,4,410,288);
187 INSERT INTO xyoff VALUES(4,4,636,596);
188 INSERT INTO xyoff VALUES(4,4,734,433);
189 INSERT INTO xyoff VALUES(4,4,559,549);
190 INSERT INTO xyoff VALUES(5,1,549,607);
191 INSERT INTO xyoff VALUES(5,1,584,498);
192 INSERT INTO xyoff VALUES(5,1,699,116);
193 INSERT INTO xyoff VALUES(5,1,525,524);
194 INSERT INTO xyoff VALUES(5,1,304,667);
195 INSERT INTO xyoff VALUES(5,1,302,232);
196 INSERT INTO xyoff VALUES(5,1,403,149);
197 INSERT INTO xyoff VALUES(5,1,824,403);
198 INSERT INTO xyoff VALUES(5,1,697,203);
199 INSERT INTO xyoff VALUES(5,1,293,689);
200 INSERT INTO xyoff VALUES(5,2,199,275);
201 INSERT INTO xyoff VALUES(5,2,395,393);
202 INSERT INTO xyoff VALUES(5,2,657,642);
203 INSERT INTO xyoff VALUES(5,2,200,655);
204 INSERT INTO xyoff VALUES(5,2,882,234);
205 INSERT INTO xyoff VALUES(5,2,483,565);
206 INSERT INTO xyoff VALUES(5,2,755,640);
207 INSERT INTO xyoff VALUES(5,2,810,305);
208 INSERT INTO xyoff VALUES(5,2,731,655);
209 INSERT INTO xyoff VALUES(5,2,466,690);
210 INSERT INTO xyoff VALUES(5,3,563,584);
211 INSERT INTO xyoff VALUES(5,3,491,117);
212 INSERT INTO xyoff VALUES(5,3,779,292);
213 INSERT INTO xyoff VALUES(5,3,375,637);
214 INSERT INTO xyoff VALUES(5,3,253,553);
215 INSERT INTO xyoff VALUES(5,3,797,514);
216 INSERT INTO xyoff VALUES(5,3,229,480);
217 INSERT INTO xyoff VALUES(5,3,257,194);
218 INSERT INTO xyoff VALUES(5,3,449,555);
219 INSERT INTO xyoff VALUES(5,3,849,630);
220 INSERT INTO xyoff VALUES(5,4,329,286);
221 INSERT INTO xyoff VALUES(5,4,640,197);
222 INSERT INTO xyoff VALUES(5,4,104,150);
223 INSERT INTO xyoff VALUES(5,4,438,272);
224 INSERT INTO xyoff VALUES(5,4,773,226);
225 INSERT INTO xyoff VALUES(5,4,441,650);
226 INSERT INTO xyoff VALUES(5,4,242,340);
227 INSERT INTO xyoff VALUES(5,4,301,435);
228 INSERT INTO xyoff VALUES(5,4,171,397);
229 INSERT INTO xyoff VALUES(5,4,541,619);
230 INSERT INTO xyoff VALUES(6,1,651,301);
231 INSERT INTO xyoff VALUES(6,1,637,137);
232 INSERT INTO xyoff VALUES(6,1,765,643);
233 INSERT INTO xyoff VALUES(6,1,173,296);
234 INSERT INTO xyoff VALUES(6,1,263,192);
235 INSERT INTO xyoff VALUES(6,1,791,302);
236 INSERT INTO xyoff VALUES(6,1,860,601);
237 INSERT INTO xyoff VALUES(6,1,780,445);
238 INSERT INTO xyoff VALUES(6,1,462,214);
239 INSERT INTO xyoff VALUES(6,1,802,207);
240 INSERT INTO xyoff VALUES(6,2,811,685);
241 INSERT INTO xyoff VALUES(6,2,533,531);
242 INSERT INTO xyoff VALUES(6,2,390,614);
243 INSERT INTO xyoff VALUES(6,2,260,580);
244 INSERT INTO xyoff VALUES(6,2,116,377);
245 INSERT INTO xyoff VALUES(6,2,860,458);
246 INSERT INTO xyoff VALUES(6,2,438,590);
247 INSERT INTO xyoff VALUES(6,2,604,562);
248 INSERT INTO xyoff VALUES(6,2,241,242);
249 INSERT INTO xyoff VALUES(6,2,667,298);
250 INSERT INTO xyoff VALUES(6,3,787,698);
251 INSERT INTO xyoff VALUES(6,3,868,521);
252 INSERT INTO xyoff VALUES(6,3,412,587);
253 INSERT INTO xyoff VALUES(6,3,640,131);
254 INSERT INTO xyoff VALUES(6,3,748,410);
255 INSERT INTO xyoff VALUES(6,3,257,244);
256 INSERT INTO xyoff VALUES(6,3,411,195);
257 INSERT INTO xyoff VALUES(6,3,464,356);
258 INSERT INTO xyoff VALUES(6,3,157,339);
259 INSERT INTO xyoff VALUES(6,3,434,505);
260 INSERT INTO xyoff VALUES(6,4,480,671);
261 INSERT INTO xyoff VALUES(6,4,519,228);
262 INSERT INTO xyoff VALUES(6,4,404,513);
263 INSERT INTO xyoff VALUES(6,4,120,538);
264 INSERT INTO xyoff VALUES(6,4,403,663);
265 INSERT INTO xyoff VALUES(6,4,477,677);
266 INSERT INTO xyoff VALUES(6,4,690,154);
267 INSERT INTO xyoff VALUES(6,4,606,498);
268 INSERT INTO xyoff VALUES(6,4,430,665);
269 INSERT INTO xyoff VALUES(6,4,499,273);
270 INSERT INTO xyoff VALUES(7,1,118,526);
271 INSERT INTO xyoff VALUES(7,1,817,522);
272 INSERT INTO xyoff VALUES(7,1,388,638);
273 INSERT INTO xyoff VALUES(7,1,181,265);
274 INSERT INTO xyoff VALUES(7,1,442,332);
275 INSERT INTO xyoff VALUES(7,1,475,282);
276 INSERT INTO xyoff VALUES(7,1,722,633);
277 INSERT INTO xyoff VALUES(7,1,104,394);
278 INSERT INTO xyoff VALUES(7,1,631,262);
279 INSERT INTO xyoff VALUES(7,1,372,392);
280 INSERT INTO xyoff VALUES(7,2,600,413);
281 INSERT INTO xyoff VALUES(7,2,386,223);
282 INSERT INTO xyoff VALUES(7,2,839,174);
283 INSERT INTO xyoff VALUES(7,2,293,410);
284 INSERT INTO xyoff VALUES(7,2,281,391);
285 INSERT INTO xyoff VALUES(7,2,859,387);
286 INSERT INTO xyoff VALUES(7,2,478,347);
287 INSERT INTO xyoff VALUES(7,2,646,690);
288 INSERT INTO xyoff VALUES(7,2,713,234);
289 INSERT INTO xyoff VALUES(7,2,199,588);
290 INSERT INTO xyoff VALUES(7,3,389,256);
291 INSERT INTO xyoff VALUES(7,3,349,542);
292 INSERT INTO xyoff VALUES(7,3,363,345);
293 INSERT INTO xyoff VALUES(7,3,751,302);
294 INSERT INTO xyoff VALUES(7,3,423,386);
295 INSERT INTO xyoff VALUES(7,3,267,444);
296 INSERT INTO xyoff VALUES(7,3,243,182);
297 INSERT INTO xyoff VALUES(7,3,453,658);
298 INSERT INTO xyoff VALUES(7,3,126,345);
299 INSERT INTO xyoff VALUES(7,3,120,472);
300 INSERT INTO xyoff VALUES(7,4,359,654);
301 INSERT INTO xyoff VALUES(7,4,339,516);
302 INSERT INTO xyoff VALUES(7,4,710,452);
303 INSERT INTO xyoff VALUES(7,4,810,560);
304 INSERT INTO xyoff VALUES(7,4,644,692);
305 INSERT INTO xyoff VALUES(7,4,826,327);
306 INSERT INTO xyoff VALUES(7,4,465,462);
307 INSERT INTO xyoff VALUES(7,4,310,456);
308 INSERT INTO xyoff VALUES(7,4,577,613);
309 INSERT INTO xyoff VALUES(7,4,502,555);
310 INSERT INTO xyoff VALUES(8,1,601,620);
311 INSERT INTO xyoff VALUES(8,1,372,683);
312 INSERT INTO xyoff VALUES(8,1,758,399);
313 INSERT INTO xyoff VALUES(8,1,485,552);
314 INSERT INTO xyoff VALUES(8,1,159,563);
315 INSERT INTO xyoff VALUES(8,1,536,303);
316 INSERT INTO xyoff VALUES(8,1,122,263);
317 INSERT INTO xyoff VALUES(8,1,836,435);
318 INSERT INTO xyoff VALUES(8,1,544,146);
319 INSERT INTO xyoff VALUES(8,1,270,277);
320 INSERT INTO xyoff VALUES(8,2,849,281);
321 INSERT INTO xyoff VALUES(8,2,563,242);
322 INSERT INTO xyoff VALUES(8,2,704,463);
323 INSERT INTO xyoff VALUES(8,2,102,165);
324 INSERT INTO xyoff VALUES(8,2,797,524);
325 INSERT INTO xyoff VALUES(8,2,612,426);
326 INSERT INTO xyoff VALUES(8,2,345,372);
327 INSERT INTO xyoff VALUES(8,2,820,376);
328 INSERT INTO xyoff VALUES(8,2,789,156);
329 INSERT INTO xyoff VALUES(8,2,321,466);
330 INSERT INTO xyoff VALUES(8,3,150,332);
331 INSERT INTO xyoff VALUES(8,3,136,152);
332 INSERT INTO xyoff VALUES(8,3,468,528);
333 INSERT INTO xyoff VALUES(8,3,409,192);
334 INSERT INTO xyoff VALUES(8,3,820,216);
335 INSERT INTO xyoff VALUES(8,3,847,249);
336 INSERT INTO xyoff VALUES(8,3,801,267);
337 INSERT INTO xyoff VALUES(8,3,181,670);
338 INSERT INTO xyoff VALUES(8,3,398,563);
339 INSERT INTO xyoff VALUES(8,3,439,576);
340 INSERT INTO xyoff VALUES(8,4,123,309);
341 INSERT INTO xyoff VALUES(8,4,190,496);
342 INSERT INTO xyoff VALUES(8,4,571,531);
343 INSERT INTO xyoff VALUES(8,4,290,255);
344 INSERT INTO xyoff VALUES(8,4,244,412);
345 INSERT INTO xyoff VALUES(8,4,264,596);
346 INSERT INTO xyoff VALUES(8,4,253,420);
347 INSERT INTO xyoff VALUES(8,4,847,536);
348 INSERT INTO xyoff VALUES(8,4,120,288);
349 INSERT INTO xyoff VALUES(8,4,331,639);
351 /* Create the geopoly object from test data above */
352 CREATE VIRTUAL TABLE geo1 USING geopoly(type,clr);
353 INSERT INTO geo1(_shape,type,clr)
354 SELECT geopoly_xform(jshape,A,B,-B,A,xoff,yoff), basis.name, xform.clr
355 FROM basis, xform, xyoff
356 WHERE xyoff.id1=basis.rowid AND xyoff.id2=xform.rowid;
360 CREATE TEMP TABLE querypoly(poly JSON, clr TEXT);
361 INSERT INTO querypoly(clr, poly) VALUES
362 ('orange', '[[300,300],[400,350],[500,250],[480,500],[400,480],[300,550],[280,450],[320,400],[280,350],[300,300]]');
364 /* Generate the HTML */
366 .print '<h1>Everything</h1>'
367 .print '<svg width="1000" height="800" style="border:1px solid black">'
368 SELECT geopoly_svg(_shape,
369 printf('style="fill:none;stroke:%s;stroke-width:1"',clr)
372 SELECT geopoly_svg(poly,
373 printf('style="fill:%s;fill-opacity:0.5;"',clr)
378 .print '<h1>Overlap Query</h1>'
381 .print ' FROM geo1, querypoly'
382 .print ' WHERE geopoly_overlap(_shape, poly);'
385 SELECT geopoly_svg(_shape,
386 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
389 WHERE geopoly_overlap(_shape, poly);
391 .print '<svg width="1000" height="800" style="border:1px solid black">'
392 SELECT geopoly_svg(_shape,
393 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
396 WHERE geopoly_overlap(_shape, poly);
397 SELECT geopoly_svg(poly,
398 printf('style="fill:%s;fill-opacity:0.5;"',clr)
403 .print '<h1>Overlap Query And Result Bounding Box</h1>'
404 .print '<svg width="1000" height="800" style="border:1px solid black">'
405 SELECT geopoly_svg(_shape,
406 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
409 WHERE geopoly_overlap(_shape, poly);
410 SELECT geopoly_svg(geopoly_bbox(poly),
411 'style="fill:none;stroke:black;stroke-width:3"'
414 SELECT geopoly_svg(poly,
415 printf('style="fill:%s;fill-opacity:0.5;"',clr)
418 SELECT geopoly_svg(geopoly_group_bbox(_shape),
419 'style="fill:none;stroke:red;stroke-width:3"'
422 WHERE geopoly_overlap(_shape, poly);
425 .print '<h1>Bounding-Box Overlap Query</h1>'
426 .print '<svg width="1000" height="800" style="border:1px solid black">'
427 SELECT geopoly_svg(_shape,
428 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
430 geopoly_svg(geopoly_bbox(_shape),
431 'style="fill:none;stroke:black;stroke-width:1"'
434 WHERE geopoly_overlap(geopoly_bbox(_shape), geopoly_bbox(poly));
435 SELECT geopoly_svg(poly,
436 printf('style="fill:%s;fill-opacity:0.5;"',clr)
439 SELECT geopoly_svg(geopoly_bbox(poly),
440 'style="fill:none;stroke:black;stroke-width:3"'
445 .print '<h1>Within Query</h1>'
448 .print ' FROM geo1, querypoly'
449 .print ' WHERE geopoly_within(_shape, poly);'
452 SELECT geopoly_svg(_shape,
453 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
456 WHERE geopoly_within(_shape, poly);
458 .print '<svg width="1000" height="800" style="border:1px solid black">'
459 SELECT geopoly_svg(_shape,
460 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
463 WHERE geopoly_within(_shape, poly);
464 SELECT geopoly_svg(poly,
465 printf('style="fill:%s;fill-opacity:0.5;"',clr)
470 .print '<h1>Bounding-Box WITHIN Query</h1>'
471 .print '<svg width="1000" height="800" style="border:1px solid black">'
472 SELECT geopoly_svg(_shape,
473 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
475 geopoly_svg(geopoly_bbox(_shape),
476 'style="fill:none;stroke:black;stroke-width:1"'
479 WHERE geopoly_within(geopoly_bbox(_shape), geopoly_bbox(poly));
480 SELECT geopoly_svg(poly,
481 printf('style="fill:%s;fill-opacity:0.5;"',clr)
484 SELECT geopoly_svg(geopoly_bbox(poly),
485 'style="fill:none;stroke:black;stroke-width:3"'
490 .print '<h1>Not Overlap Query</h1>'
493 .print ' FROM geo1, querypoly'
494 .print ' WHERE NOT geopoly_overlap(_shape, poly);'
497 SELECT geopoly_svg(_shape,
498 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
501 WHERE NOT geopoly_overlap(_shape, poly);
503 .print '<svg width="1000" height="800" style="border:1px solid black">'
504 SELECT geopoly_svg(_shape,
505 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
508 WHERE NOT geopoly_overlap(_shape, poly);
509 SELECT geopoly_svg(poly,
510 printf('style="fill:%s;fill-opacity:0.5;"',clr)
515 .print '<h1>Not Within Query</h1>'
518 .print ' FROM geo1, querypoly'
519 .print ' WHERE NOT geopoly_within(_shape, poly);'
522 SELECT geopoly_svg(_shape,
523 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
526 WHERE NOT geopoly_within(_shape, poly);
528 .print '<svg width="1000" height="800" style="border:1px solid black">'
529 SELECT geopoly_svg(_shape,
530 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
533 WHERE NOT geopoly_within(_shape, poly);
534 SELECT geopoly_svg(poly,
535 printf('style="fill:%s;fill-opacity:0.5;"',clr)
540 .print '<h1>Color-Change For Overlapping Elements</h1>'
543 SET clr=CASE WHEN rowid IN (SELECT geo1.rowid FROM geo1, querypoly
544 WHERE geopoly_overlap(_shape,poly))
545 THEN 'red' ELSE 'blue' END;
546 .print '<svg width="1000" height="800" style="border:1px solid black">'
547 SELECT geopoly_svg(_shape,
548 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
551 SELECT geopoly_svg(poly,'style="fill:none;stroke:black;stroke-width:2"')
556 .print '<h1>Color-Change And Move Overlapping Elements</h1>'
559 SET clr=CASE WHEN rowid IN (SELECT geo1.rowid FROM geo1, querypoly
560 WHERE geopoly_overlap(_shape,poly))
561 THEN 'red' ELSE '#76ccff' END;
563 SET _shape=geopoly_xform(_shape,1,0,0,1,300,0)
564 WHERE geopoly_overlap(_shape,(SELECT poly FROM querypoly));
565 .print '<svg width="1000" height="800" style="border:1px solid black">'
566 SELECT geopoly_svg(_shape,
567 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
570 SELECT geopoly_svg(poly,'style="fill:none;stroke:black;stroke-width:2"')
576 .print '<h1>Overlap With Translated Query Polygon</h1>'
577 UPDATE querypoly SET poly=geopoly_xform(poly,1,0,0,1,300,0);
578 .print '<svg width="1000" height="800" style="border:1px solid black">'
579 SELECT geopoly_svg(_shape,
580 printf('style="fill:none;stroke:%s;stroke-width:1"',geo1.clr)
583 WHERE geopoly_overlap(_shape,(SELECT poly FROM querypoly));
584 SELECT geopoly_svg(poly,'style="fill:none;stroke:black;stroke-width:2"')
589 .print '<h1>Regular Polygons</h1>'
590 .print '<svg width="1000" height="200" style="border:1px solid black">'
591 SELECT geopoly_svg(geopoly_regular(100,100,40,3),'style="fill:none;stroke:red;stroke-width:1"');
592 SELECT geopoly_svg(geopoly_regular(200,100,40,4),'style="fill:none;stroke:orange;stroke-width:1"');
593 SELECT geopoly_svg(geopoly_regular(300,100,40,5),'style="fill:none;stroke:green;stroke-width:1"');
594 SELECT geopoly_svg(geopoly_regular(400,100,40,6),'style="fill:none;stroke:blue;stroke-width:1"');
595 SELECT geopoly_svg(geopoly_regular(500,100,40,7),'style="fill:none;stroke:purple;stroke-width:1"');
596 SELECT geopoly_svg(geopoly_regular(600,100,40,8),'style="fill:none;stroke:red;stroke-width:1"');
597 SELECT geopoly_svg(geopoly_regular(700,100,40,10),'style="fill:none;stroke:orange;stroke-width:1"');
598 SELECT geopoly_svg(geopoly_regular(800,100,40,20),'style="fill:none;stroke:green;stroke-width:1"');
599 SELECT geopoly_svg(geopoly_regular(900,100,40,30),'style="fill:none;stroke:blue;stroke-width:1"');