Wiki page
[benchmark-4.0] by
sandro
2012-11-10 11:59:21.
0000: 44 20 32 30 31 32 2d 31 31 2d 31 30 54 31 31 3a D 2012-11-10T11:
0010: 35 39 3a 32 31 2e 39 30 31 0a 4c 20 62 65 6e 63 59:21.901.L benc
0020: 68 6d 61 72 6b 2d 34 2e 30 0a 50 20 61 63 34 64 hmark-4.0.P ac4d
0030: 31 34 62 31 39 38 37 30 63 33 30 34 38 37 38 64 14b19870c304878d
0040: 30 33 30 39 32 30 61 65 39 34 61 66 63 61 37 39 030920ae94afca79
0050: 31 37 66 61 0a 55 20 73 61 6e 64 72 6f 0a 57 20 17fa.U sandro.W
0060: 31 32 36 35 36 0a 3c 68 32 3e 42 65 6e 63 68 6d 12656.<h2>Benchm
0070: 61 72 63 6b 20 28 61 6b 61 20 22 63 6f 6d 70 61 arck (aka "compa
0080: 72 69 6e 67 20 61 70 70 6c 65 73 20 61 6e 64 20 ring apples and
0090: 6f 72 61 6e 67 65 73 22 29 3c 2f 68 32 3e 0d 0a oranges")</h2>..
00a0: 42 61 63 6b 20 74 6f 20 3c 61 20 68 72 65 66 3d Back to <a href=
00b0: 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 "https://www.gai
00c0: 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f a-gis.it/fossil/
00d0: 6c 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 libspatialite/wi
00e0: 6b 69 3f 6e 61 6d 65 3d 73 77 69 74 63 68 69 6e ki?name=switchin
00f0: 67 2d 74 6f 2d 34 2e 30 23 76 69 72 74 75 61 6c g-to-4.0#virtual
0100: 6f 67 72 22 3e 6d 61 69 6e 20 70 61 67 65 3c 2f ogr">main page</
0110: 61 3e 0d 0a 3c 68 32 3e 49 6e 74 72 6f 64 75 63 a>..<h2>Introduc
0120: 74 69 6f 6e 3c 2f 68 32 3e 0d 0a 54 6f 64 61 79 tion</h2>..Today
0130: 20 49 27 76 65 20 63 61 73 75 61 6c 6c 79 20 72 I've casually r
0140: 65 61 64 20 74 68 69 73 20 3c 61 20 68 72 65 66 ead this <a href
0150: 3d 22 68 74 74 70 3a 2f 2f 67 66 6f 73 73 2e 62 ="http://gfoss.b
0160: 6c 6f 67 73 70 6f 74 2e 69 74 2f 32 30 31 32 2f logspot.it/2012/
0170: 31 31 2f 61 72 63 67 69 73 2d 76 73 2d 71 67 69 11/arcgis-vs-qgi
0180: 73 2d 65 74 63 2d 63 6c 69 70 70 69 6e 67 2d 63 s-etc-clipping-c
0190: 6f 6e 74 65 73 74 2e 68 74 6d 6c 22 3e 62 6c 6f ontest.html">blo
01a0: 67 20 70 61 67 65 3c 2f 61 3e 3b 20 6d 61 6e 79 g page</a>; many
01b0: 20 74 68 61 6e 6b 73 20 74 6f 20 6d 79 20 64 65 thanks to my de
01c0: 61 72 20 66 72 69 65 6e 64 20 4d 61 72 6b 75 73 ar friend Markus
01d0: 20 4e 65 74 65 6c 65 72 20 28 74 68 65 20 6d 61 Neteler (the ma
01e0: 69 6e 74 61 69 6e 65 72 20 6f 66 20 47 52 41 53 intainer of GRAS
01f0: 53 20 47 49 53 29 20 66 6f 72 20 70 6f 69 6e 74 S GIS) for point
0200: 69 6e 67 20 6d 79 20 61 74 74 65 6e 74 69 6f 6e ing my attention
0210: 20 6f 6e 20 74 68 69 73 20 74 6f 70 69 63 2e 3c on this topic.<
0220: 62 72 3e 0d 0a 54 68 65 20 6f 72 69 67 69 6e 61 br>..The origina
0230: 6c 20 3c 62 3e 43 6c 69 70 70 69 6e 67 20 43 6f l <b>Clipping Co
0240: 6e 74 65 73 74 3c 2f 62 3e 20 73 69 6d 70 6c 79 ntest</b> simply
0250: 20 63 6f 6d 70 61 72 65 64 20 73 65 76 65 72 61 compared severa
0260: 6c 20 70 6f 70 75 6c 61 72 20 44 65 73 6b 79 6f l popular Deskyo
0270: 70 20 47 49 53 20 28 41 72 63 47 69 73 2c 20 51 p GIS (ArcGis, Q
0280: 47 49 53 2c 20 67 76 53 49 47 2c 20 47 52 41 53 GIS, gvSIG, GRAS
0290: 53 20 61 6e 64 20 6f 74 68 65 72 73 29 2c 20 62 S and others), b
02a0: 75 74 20 74 68 65 72 65 20 77 61 73 20 61 6e 20 ut there was an
02b0: 6f 62 76 69 6f 75 73 20 6f 6d 69 73 73 69 6f 6e obvious omission
02c0: 2e 3c 62 72 3e 0d 0a 4e 6f 20 53 70 61 74 69 61 .<br>..No Spatia
02d0: 6c 20 44 42 4d 53 20 77 61 73 20 63 6f 6e 73 69 l DBMS was consi
02e0: 64 65 72 65 64 20 61 74 20 61 6c 6c 2e 20 28 3c dered at all. (<
02f0: 69 3e 74 6f 6f 20 62 61 64 3b 20 61 20 72 65 61 i>too bad; a rea
0300: 6c 6c 79 20 65 6d 62 61 72 72 61 73 73 69 6e 67 lly embarrassing
0310: 20 6f 6d 69 73 73 69 6f 6e 3c 2f 69 3e 29 3c 62 omission</i>)<b
0320: 72 3e 3c 62 72 3e 0d 0a 41 66 74 65 72 20 61 6c r><br>..After al
0330: 6c 20 61 20 3c 62 3e 43 6c 69 70 70 69 6e 67 20 l a <b>Clipping
0340: 43 6f 6e 74 65 73 74 3c 2f 62 3e 20 73 6f 75 6e Contest</b> soun
0350: 64 73 20 6d 6f 72 65 20 6c 69 6b 65 20 61 20 70 ds more like a p
0360: 75 72 65 20 64 61 74 61 2d 70 72 6f 63 65 73 73 ure data-process
0370: 69 6e 67 20 70 72 6f 62 6c 65 6d 20 74 68 61 6e ing problem than
0380: 20 6c 69 6b 65 20 61 20 74 79 70 69 63 61 6c 20 like a typical
0390: 47 49 53 2f 47 55 49 20 70 72 6f 62 6c 65 6d 2c GIS/GUI problem,
03a0: 20 73 6f 20 69 74 27 73 20 70 72 6f 62 61 62 6c so it's probabl
03b0: 79 20 75 73 65 66 75 6c 20 69 6e 74 72 6f 64 75 y useful introdu
03c0: 63 69 6e 67 20 73 6f 6d 65 20 53 70 61 74 69 61 cing some Spatia
03d0: 6c 20 44 42 4d 53 20 69 6e 74 6f 20 74 68 69 73 l DBMS into this
03e0: 20 43 6f 6e 74 65 73 74 2e 0d 0a 54 68 69 73 20 Contest...This
03f0: 77 61 73 20 6d 79 20 66 69 72 73 74 20 74 68 6f was my first tho
0400: 75 67 68 74 20 77 68 69 6c 65 20 72 65 61 64 69 ught while readi
0410: 6e 67 20 74 68 65 20 62 65 6e 63 68 6d 61 72 6b ng the benchmark
0420: 20 72 65 70 6f 72 74 2c 20 73 6f 20 49 20 64 75 report, so I du
0430: 6c 79 20 73 74 61 72 74 65 64 20 70 72 65 70 61 ly started prepa
0440: 72 69 6e 67 20 6d 79 20 6f 77 6e 20 74 65 73 74 ring my own test
0450: 62 65 64 20 62 61 73 65 64 20 6f 6e 20 53 70 61 bed based on Spa
0460: 74 69 61 4c 69 74 65 20 28 3c 69 3e 42 54 57 20 tiaLite (<i>BTW
0470: 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20 72 65 6c I'm going to rel
0480: 65 61 73 65 20 74 68 65 20 6e 65 77 20 76 65 72 ease the new ver
0490: 73 69 6f 6e 20 34 2e 30 2e 30 20 69 6e 20 74 68 sion 4.0.0 in th
04a0: 65 20 76 65 72 79 20 6e 65 78 74 20 64 61 79 73 e very next days
04b0: 2c 20 64 6f 20 61 66 74 65 72 20 61 6c 6c 20 70 , do after all p
04c0: 65 72 66 6f 72 6d 69 6e 67 20 73 6f 6d 65 20 66 erforming some f
04d0: 75 72 74 68 65 72 20 74 65 73 74 20 69 73 20 73 urther test is s
04e0: 75 72 65 6c 79 20 77 65 6c 63 6f 6d 65 3c 2f 69 urely welcome</i
04f0: 3e 29 2e 0d 0a 3c 68 32 3e 54 65 73 74 20 63 6f >)...<h2>Test co
0500: 6e 66 69 67 75 72 61 74 69 6f 6e 3c 2f 68 32 3e nfiguration</h2>
0510: 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 49 6e 74 65 ..<ul>..<li>Inte
0520: 6c 20 43 6f 72 65 20 69 35 20 33 2e 34 36 20 47 l Core i5 3.46 G
0530: 48 7a 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 34 20 47 Hz</li>..<li>4 G
0540: 42 20 52 41 4d 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e B RAM</li>..<li>
0550: 57 69 6e 64 6f 77 73 20 37 20 36 34 20 62 69 74 Windows 7 64 bit
0560: 20 28 70 68 79 73 69 63 61 6c 29 3c 2f 6c 69 3e (physical)</li>
0570: 0d 0a 3c 6c 69 3e 44 65 62 69 61 6e 20 53 71 75 ..<li>Debian Squ
0580: 65 65 7a 65 20 33 32 20 62 69 74 20 28 76 69 72 eeze 32 bit (vir
0590: 74 75 61 6c 20 6d 61 63 68 69 6e 65 29 3c 2f 6c tual machine)</l
05a0: 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 49 i>..</ul><br>..I
05b0: 20 74 65 73 74 65 64 20 62 6f 74 68 20 57 69 6e tested both Win
05c0: 64 6f 77 73 20 61 6e 64 20 44 65 62 69 61 6e 20 dows and Debian
05d0: 6f 6e 20 74 68 65 20 73 61 6d 65 20 68 61 72 64 on the same hard
05e0: 77 61 72 65 2e 3c 62 72 3e 0d 0a 54 68 65 20 6d ware.<br>..The m
05f0: 65 61 73 75 72 65 64 20 74 69 6d 69 6e 67 73 20 easured timings
0600: 61 72 65 20 72 61 74 68 65 72 20 73 69 6d 69 6c are rather simil
0610: 61 72 3b 20 61 6e 79 77 61 79 20 4c 69 6e 75 78 ar; anyway Linux
0620: 20 70 65 72 66 6f 72 6d 65 64 20 73 6c 69 67 68 performed sligh
0630: 74 6c 79 20 62 65 74 74 65 72 20 74 68 61 6e 20 tly better than
0640: 74 68 65 20 6e 61 74 69 76 65 20 57 69 6e 64 6f the native Windo
0650: 77 73 20 73 79 73 74 65 6d 20 28 6d 6f 72 65 20 ws system (more
0660: 6f 72 20 6c 65 73 73 2c 20 62 79 20 61 20 31 30 or less, by a 10
0670: 25 20 2d 20 32 30 25 20 66 61 63 74 6f 72 29 2e % - 20% factor).
0680: 3c 62 72 3e 0d 0a 54 68 69 73 20 69 73 20 6e 6f <br>..This is no
0690: 74 20 61 74 20 61 6c 6c 20 73 75 72 70 72 69 73 t at all surpris
06a0: 69 6e 67 20 66 6f 72 20 6d 65 2c 20 62 65 63 61 ing for me, beca
06b0: 75 73 65 20 74 68 69 73 20 74 72 65 6e 64 20 73 use this trend s
06c0: 65 65 6d 73 20 74 6f 20 62 65 20 63 6f 6e 73 74 eems to be const
06d0: 61 6e 74 6c 79 20 76 65 72 69 66 69 65 64 20 65 antly verified e
06e0: 61 63 68 20 74 69 6d 65 20 49 20 6d 61 6e 61 67 ach time I manag
06f0: 65 20 73 6f 6d 65 20 63 6f 6d 70 61 72 61 74 69 e some comparati
0700: 76 65 20 62 65 6e 63 68 6d 61 72 6b 2e 3c 62 72 ve benchmark.<br
0710: 3e 0d 0a 56 65 72 79 20 6f 66 74 65 6e 20 4c 69 >..Very often Li
0720: 6e 75 78 20 69 73 20 61 20 62 65 73 74 20 70 65 nux is a best pe
0730: 72 66 6f 72 6d 65 72 20 74 68 61 6e 20 57 69 6e rformer than Win
0740: 64 6f 77 73 2c 20 65 76 65 6e 20 77 68 65 6e 20 dows, even when
0750: 72 75 6e 6e 69 6e 67 20 61 73 20 61 20 56 69 72 running as a Vir
0760: 74 75 61 6c 20 4d 61 63 68 69 6e 65 20 6f 6e 20 tual Machine on
0770: 74 68 65 20 74 6f 70 20 6f 66 20 61 20 70 68 79 the top of a phy
0780: 73 69 63 61 6c 20 57 69 6e 64 6f 77 73 20 73 79 sical Windows sy
0790: 73 74 65 6d 2e 3c 62 72 3e 0d 0a 51 75 69 74 65 stem.<br>..Quite
07a0: 20 70 61 72 61 64 6f 78 69 63 61 6c 2c 20 62 75 paradoxical, bu
07b0: 74 20 69 6e 64 69 73 70 75 74 61 62 6c 79 20 74 t indisputably t
07c0: 72 75 65 20 61 6e 64 20 6f 62 6a 65 63 74 69 76 rue and objectiv
07d0: 65 6c 79 20 76 65 72 69 66 69 65 64 20 6d 61 6e ely verified man
07e0: 79 20 74 69 6d 65 73 2e 0d 0a 3c 68 32 3e 54 68 y times...<h2>Th
07f0: 65 20 73 61 6d 70 6c 65 20 64 61 74 61 73 65 74 e sample dataset
0800: 3c 2f 68 32 3e 0d 0a 49 27 76 65 20 73 69 6d 70 </h2>..I've simp
0810: 6c 79 20 64 6f 77 6e 6c 6f 61 64 65 64 20 74 68 ly downloaded th
0820: 65 20 73 61 6d 65 20 69 64 65 6e 74 69 63 61 6c e same identical
0830: 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f <a href="http:/
0840: 2f 77 77 77 2e 64 6f 6e 6d 65 6c 74 7a 2e 63 6f /www.donmeltz.co
0850: 6d 2f 5f 66 69 6c 65 73 2f 43 6f 6e 74 6f 75 72 m/_files/Contour
0860: 43 6c 69 70 54 65 73 74 2e 7a 69 70 22 3e 73 61 ClipTest.zip">sa
0870: 6d 70 6c 65 20 64 61 74 61 73 65 74 3c 2f 61 3e mple dataset</a>
0880: 20 61 6c 72 65 61 64 79 20 75 73 65 64 20 66 6f already used fo
0890: 72 20 61 6c 6c 20 6f 74 68 65 72 20 74 65 73 74 r all other test
08a0: 73 20 72 65 70 6f 72 74 65 64 20 69 6e 20 74 68 s reported in th
08b0: 65 20 43 6c 69 70 70 69 6e 67 20 43 6f 6e 74 65 e Clipping Conte
08c0: 73 74 2e 3c 62 72 3e 0d 0a 56 65 72 79 20 73 68 st.<br>..Very sh
08d0: 6f 72 74 6c 79 20 73 61 69 64 3a 20 69 74 27 73 ortly said: it's
08e0: 20 61 20 72 65 61 6c 6c 79 20 68 75 67 65 20 73 a really huge s
08f0: 65 74 20 6f 66 20 3c 62 3e 43 6f 6e 74 6f 75 72 et of <b>Contour
0900: 20 4c 69 6e 65 73 3c 2f 62 3e 20 28 74 68 65 20 Lines</b> (the
0910: 75 6e 63 6f 6d 70 72 65 73 73 65 64 20 53 68 61 uncompressed Sha
0920: 70 65 66 69 6c 65 20 69 73 20 61 62 6f 75 74 20 pefile is about
0930: 3c 62 3e 31 2c 33 20 47 42 3c 2f 62 3e 29 3c 62 <b>1,3 GB</b>)<b
0940: 72 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 63 r><br>..<table c
0950: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 36 22 20 63 ellspacing="6" c
0960: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 36 22 3e 0d ellpadding="6">.
0970: 0a 3c 74 72 3e 3c 74 64 3e 3c 68 33 3e 46 69 67 .<tr><td><h3>Fig
0980: 2e 20 31 3c 2f 68 33 3e 0d 0a 54 68 69 73 20 6f . 1</h3>..This o
0990: 6e 65 20 69 73 20 74 68 65 20 6f 72 69 67 69 6e ne is the origin
09a0: 61 6c 20 73 65 74 20 6f 66 20 43 6f 6e 74 6f 75 al set of Contou
09b0: 72 20 4c 69 6e 65 73 20 74 6f 20 62 65 20 63 6c r Lines to be cl
09c0: 69 70 70 65 64 2e 3c 2f 74 64 3e 0d 0a 3c 74 64 ipped.</td>..<td
09d0: 3e 3c 69 6d 67 20 62 6f 72 64 65 72 3d 22 31 22 ><img border="1"
09e0: 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 src="http://www
09f0: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 .gaia-gis.it/gai
0a00: 61 2d 73 69 6e 73 2f 76 69 72 74 75 61 6c 6f 67 a-sins/virtualog
0a10: 72 2f 63 6c 69 70 2d 30 2e 70 6e 67 22 20 61 6c r/clip-0.png" al
0a20: 74 3d 22 6f 72 69 67 69 6e 61 6c 20 64 61 74 61 t="original data
0a30: 73 65 74 22 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 0d set"></td></tr>.
0a40: 0a 3c 74 72 3e 3c 74 64 3e 3c 68 33 3e 46 69 67 .<tr><td><h3>Fig
0a50: 2e 20 32 3c 2f 68 33 3e 0d 0a 54 68 69 73 20 69 . 2</h3>..This i
0a60: 73 20 74 68 65 20 66 69 6e 61 6c 20 72 65 73 75 s the final resu
0a70: 6c 74 20 6f 66 20 74 68 65 20 63 6c 69 70 70 69 lt of the clippi
0a80: 6e 67 20 6f 70 65 72 61 74 69 6f 6e 2e 3c 75 6c ng operation.<ul
0a90: 3e 0d 0a 3c 6c 69 3e 74 68 65 20 53 74 75 64 79 >..<li>the Study
0aa0: 20 41 72 65 61 20 62 6f 75 6e 64 61 72 79 20 28 Area boundary (
0ab0: 70 6f 6c 79 67 6f 6e 29 20 69 73 20 72 65 70 72 polygon) is repr
0ac0: 65 73 65 6e 74 65 64 20 69 6e 20 72 65 64 2e 3c esented in red.<
0ad0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20 43 6f /li>..<li>the Co
0ae0: 6e 74 6f 75 72 20 4c 69 6e 65 73 20 61 72 65 20 ntour Lines are
0af0: 72 65 70 72 65 73 65 6e 74 65 64 20 69 6e 20 64 represented in d
0b00: 61 72 6b 20 62 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a ark blue.</li>..
0b10: 3c 6c 69 3e 74 68 65 20 61 7a 75 72 65 20 72 65 <li>the azure re
0b20: 63 74 61 6e 67 6c 65 20 73 69 6d 70 6c 79 20 6d ctangle simply m
0b30: 61 72 6b 73 20 74 68 65 20 64 65 74 61 69 6c 20 arks the detail
0b40: 61 72 65 61 20 73 68 6f 77 6e 20 69 6e 20 74 68 area shown in th
0b50: 65 20 6e 65 78 74 20 66 69 67 75 72 65 2e 3c 2f e next figure.</
0b60: 6c 69 3e 20 0d 0a 3c 2f 75 6c 3e 3c 2f 74 64 3e li> ..</ul></td>
0b70: 0d 0a 3c 74 64 3e 3c 69 6d 67 20 62 6f 72 64 65 ..<td><img borde
0b80: 72 3d 22 31 22 20 73 72 63 3d 22 68 74 74 70 3a r="1" src="http:
0b90: 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 //www.gaia-gis.i
0ba0: 74 2f 67 61 69 61 2d 73 69 6e 73 2f 76 69 72 74 t/gaia-sins/virt
0bb0: 75 61 6c 6f 67 72 2f 63 6c 69 70 2d 31 2e 70 6e ualogr/clip-1.pn
0bc0: 67 22 20 61 6c 74 3d 22 63 6c 69 70 70 65 64 22 g" alt="clipped"
0bd0: 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 ></td></tr>..<tr
0be0: 3e 3c 74 64 3e 3c 68 33 3e 46 69 67 2e 20 33 3c ><td><h3>Fig. 3<
0bf0: 2f 68 33 3e 54 68 69 73 20 69 73 20 61 20 6d 61 /h3>This is a ma
0c00: 67 6e 69 66 69 65 64 20 64 65 74 61 69 6c 20 6f gnified detail o
0c10: 66 20 74 68 65 20 53 74 75 64 79 20 41 72 65 61 f the Study Area
0c20: 20 61 6e 64 20 43 6c 69 70 70 65 64 20 43 6f 6e and Clipped Con
0c30: 74 6f 75 72 20 4c 69 6e 65 73 2e 3c 62 72 3e 0d tour Lines.<br>.
0c40: 0a 41 73 20 79 6f 75 20 63 61 6e 20 65 61 73 69 .As you can easi
0c50: 6c 79 20 6e 6f 74 69 63 65 20 74 68 65 72 65 20 ly notice there
0c60: 61 72 65 20 6c 6f 74 73 20 6f 66 20 43 6f 6e 74 are lots of Cont
0c70: 6f 75 72 20 4c 69 6e 65 73 3b 20 61 6e 64 20 65 our Lines; and e
0c80: 61 63 68 20 4c 69 6e 65 20 68 61 73 20 6d 61 6e ach Line has man
0c90: 79 20 76 65 72 74 65 78 65 73 2e 3c 62 72 3e 3c y vertexes.<br><
0ca0: 62 72 3e 0d 0a 54 68 69 73 20 6f 6e 65 20 69 73 br>..This one is
0cb0: 20 61 20 72 61 74 68 65 72 20 63 6f 6d 70 6c 65 a rather comple
0cc0: 78 20 70 72 6f 62 6c 65 6d 20 74 6f 20 62 65 20 x problem to be
0cd0: 72 65 73 6f 6c 76 65 64 3a 20 61 6e 64 20 69 74 resolved: and it
0ce0: 20 73 75 72 65 6c 79 20 72 65 70 72 65 73 65 6e surely represen
0cf0: 74 73 20 61 20 74 68 6f 72 6f 75 67 68 20 61 6e ts a thorough an
0d00: 64 20 64 65 6d 61 6e 64 69 6e 67 20 74 65 73 74 d demanding test
0d10: 2e 3c 2f 74 64 3e 0d 0a 3c 74 64 3e 3c 69 6d 67 .</td>..<td><img
0d20: 20 62 6f 72 64 65 72 3d 22 31 22 20 73 72 63 3d border="1" src=
0d30: 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 "http://www.gaia
0d40: 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e -gis.it/gaia-sin
0d50: 73 2f 76 69 72 74 75 61 6c 6f 67 72 2f 63 6c 69 s/virtualogr/cli
0d60: 70 2d 32 2e 70 6e 67 22 20 61 6c 74 3d 22 6c 6f p-2.png" alt="lo
0d70: 61 64 5f 65 78 74 65 6e 73 69 6f 6e 22 3e 3c 2f ad_extension"></
0d80: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c td></tr>..</tabl
0d90: 65 3e 0d 0a 3c 68 32 3e 54 68 65 20 53 70 61 74 e>..<h2>The Spat
0da0: 69 61 6c 20 53 51 4c 20 61 70 70 72 6f 61 63 68 ial SQL approach
0db0: 3c 2f 68 32 3e 0d 0a 54 68 69 73 20 69 73 20 61 </h2>..This is a
0dc0: 20 70 75 72 65 20 64 61 74 61 2d 70 72 6f 63 65 pure data-proce
0dd0: 73 73 69 6e 67 20 61 70 70 72 6f 61 63 68 3b 20 ssing approach;
0de0: 77 65 27 6c 6c 20 75 73 65 20 74 68 65 20 6d 6f we'll use the mo
0df0: 73 74 20 63 6c 61 73 73 69 63 61 6c 20 3c 62 3e st classical <b>
0e00: 3c 69 3e 53 70 61 74 69 61 6c 20 49 73 20 4e 6f <i>Spatial Is No
0e10: 74 20 53 70 65 63 69 61 6c 3c 2f 69 3e 3c 2f 62 t Special</i></b
0e20: 3e 20 6d 65 74 68 6f 64 6f 6c 6f 67 79 2c 20 69 > methodology, i
0e30: 2e 65 2e 20 77 65 27 6c 6c 20 67 6f 20 70 65 72 .e. we'll go per
0e40: 66 6f 72 6d 69 6e 67 20 74 68 65 20 3c 62 3e 43 forming the <b>C
0e50: 6c 69 70 70 69 6e 67 20 43 6f 6e 74 65 73 74 3c lipping Contest<
0e60: 2f 62 3e 20 65 78 61 63 74 6c 79 20 61 73 20 69 /b> exactly as i
0e70: 66 20 69 74 20 77 61 73 20 61 20 74 72 69 76 69 f it was a trivi
0e80: 61 6c 20 6f 72 64 69 6e 61 72 79 20 53 51 4c 20 al ordinary SQL
0e90: 71 75 65 72 79 20 70 65 72 66 6f 72 6d 65 64 20 query performed
0ea0: 6f 6e 20 62 65 68 61 6c 66 20 6f 66 20 70 6c 61 on behalf of pla
0eb0: 69 6e 20 67 65 6e 65 72 69 63 20 64 61 74 61 2e in generic data.
0ec0: 3c 62 72 3e 0d 0a 57 65 27 6c 6c 20 6e 6f 74 20 <br>..We'll not
0ed0: 75 73 65 20 61 74 20 61 6c 6c 20 61 6e 79 20 47 use at all any G
0ee0: 49 53 2d 73 70 65 63 69 66 69 63 20 66 72 69 6c IS-specific fril
0ef0: 6c 2c 20 61 6e 64 20 77 65 27 6c 6c 20 73 69 6d l, and we'll sim
0f00: 70 6c 79 20 75 73 65 20 61 20 63 6f 75 70 6c 65 ply use a couple
0f10: 20 6f 66 20 53 70 61 74 69 61 6c 20 53 51 4c 20 of Spatial SQL
0f20: 66 75 6e 63 74 69 6f 6e 73 20 77 68 65 72 65 20 functions where
0f30: 73 74 72 69 63 74 6c 79 20 72 65 71 75 69 72 65 strictly require
0f40: 64 2e 3c 62 72 3e 0d 0a 28 3c 69 3e 42 54 57 20 d.<br>..(<i>BTW
0f50: 69 74 27 73 20 61 20 67 6f 6f 64 20 6f 70 70 6f it's a good oppo
0f60: 72 74 75 6e 69 74 79 20 74 6f 20 69 6e 74 72 6f rtunity to intro
0f70: 64 75 63 65 20 66 65 77 20 62 61 73 69 63 20 63 duce few basic c
0f80: 6f 6e 63 65 70 74 73 20 61 62 6f 75 74 20 53 70 oncepts about Sp
0f90: 61 74 69 61 6c 20 53 51 4c 3c 2f 69 3e 29 2e 3c atial SQL</i>).<
0fa0: 62 72 3e 0d 0a 4c 65 74 27 73 20 67 6f 20 2e 2e br>..Let's go ..
0fb0: 2e 0d 0a 3c 68 34 3e 50 72 65 70 61 72 69 6e 67 ...<h4>Preparing
0fc0: 20 74 68 65 20 53 51 4c 20 73 63 72 69 70 74 3c the SQL script<
0fd0: 2f 68 34 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e /h4>..<verbatim>
0fe0: 0d 0a 2d 2d 0d 0a 2d 2d 20 53 51 4c 20 73 63 72 ..--..-- SQL scr
0ff0: 69 70 74 20 70 65 72 66 6f 72 6d 69 6e 67 20 74 ipt performing t
1000: 68 65 20 43 6c 69 70 70 69 6e 67 20 43 6f 6e 74 he Clipping Cont
1010: 65 73 74 0d 0a 2d 2d 20 54 61 72 67 65 74 20 44 est..-- Target D
1020: 42 4d 53 3a 20 53 51 4c 69 74 65 20 77 69 74 68 BMS: SQLite with
1030: 20 53 70 61 74 69 61 4c 69 74 65 20 65 78 74 65 SpatiaLite exte
1040: 6e 73 69 6f 6e 0d 0a 2d 2d 0d 0a 0d 0a 53 45 4c nsion..--....SEL
1050: 45 43 54 20 44 61 74 65 54 69 6d 65 28 27 6e 6f ECT DateTime('no
1060: 77 27 29 2c 20 27 4c 6f 61 64 69 6e 67 20 74 68 w'), 'Loading th
1070: 65 20 53 74 75 64 79 41 72 65 61 20 53 48 50 27 e StudyArea SHP'
1080: 3b 0d 0a 2d 2d 0d 0a 2d 2d 20 6c 6f 61 64 69 6e ;..--..-- loadin
1090: 67 20 74 68 65 20 53 74 75 64 79 41 72 65 61 20 g the StudyArea
10a0: 53 68 61 70 65 66 69 6c 65 20 69 6e 74 6f 20 74 Shapefile into t
10b0: 68 65 20 44 42 0d 0a 2d 2d 0d 0a 2e 6c 6f 61 64 he DB..--...load
10c0: 73 68 70 20 53 74 75 64 79 41 72 65 61 31 4d 69 shp StudyArea1Mi
10d0: 6c 65 42 75 66 66 65 72 20 53 74 75 64 79 41 72 leBuffer StudyAr
10e0: 65 61 31 4d 69 6c 65 42 75 66 66 65 72 20 43 50 ea1MileBuffer CP
10f0: 31 32 35 32 20 32 32 36 30 20 47 65 6f 6d 65 74 1252 2260 Geomet
1100: 72 79 20 49 64 20 50 4f 4c 59 47 4f 4e 20 32 64 ry Id POLYGON 2d
1110: 20 6e 6f 20 6e 6f 5f 73 70 61 74 69 61 6c 5f 69 no no_spatial_i
1120: 6e 64 65 78 0d 0a 0d 0a 53 45 4c 45 43 54 20 44 ndex....SELECT D
1130: 61 74 65 54 69 6d 65 28 27 6e 6f 77 27 29 2c 20 ateTime('now'),
1140: 27 4c 6f 61 64 69 6e 67 20 74 68 65 20 43 6f 6e 'Loading the Con
1150: 74 6f 75 72 73 20 53 48 50 27 3b 0d 0a 2d 2d 0d tours SHP';..--.
1160: 0a 2d 2d 20 6c 6f 61 64 69 6e 67 20 74 68 65 20 .-- loading the
1170: 43 6f 6e 74 6f 75 72 20 53 68 61 70 65 66 69 6c Contour Shapefil
1180: 65 20 69 6e 74 6f 20 74 68 65 20 44 42 0d 0a 2d e into the DB..-
1190: 2d 0d 0a 2e 6c 6f 61 64 73 68 70 20 43 6f 6e 74 -...loadshp Cont
11a0: 6f 75 72 73 32 30 46 74 20 43 6f 6e 74 6f 75 72 ours20Ft Contour
11b0: 73 32 30 46 74 20 43 50 31 32 35 32 20 32 32 36 s20Ft CP1252 226
11c0: 30 20 47 65 6f 6d 65 74 72 79 20 49 64 20 4c 49 0 Geometry Id LI
11d0: 4e 45 53 54 52 49 4e 47 20 32 64 20 6e 6f 20 77 NESTRING 2d no w
11e0: 69 74 68 5f 73 70 61 74 69 61 6c 5f 69 6e 64 65 ith_spatial_inde
11f0: 78 0d 0a 0d 0a 53 45 4c 45 43 54 20 44 61 74 65 x....SELECT Date
1200: 54 69 6d 65 28 27 6e 6f 77 27 29 2c 20 27 43 6c Time('now'), 'Cl
1210: 69 70 70 69 6e 67 20 2e 2e 2e 20 70 6c 65 61 73 ipping ... pleas
1220: 65 20 77 61 69 74 27 3b 0d 0a 2d 2d 0d 0a 2d 2d e wait';..--..--
1230: 20 63 72 65 61 74 69 6e 67 20 61 20 6e 65 77 20 creating a new
1240: 74 61 62 6c 65 20 63 6f 6e 74 61 69 6e 69 6e 67 table containing
1250: 20 74 68 65 20 43 6c 69 70 70 65 64 20 43 6f 6e the Clipped Con
1260: 74 6f 75 72 73 0d 0a 2d 2d 0d 0a 43 52 45 41 54 tours..--..CREAT
1270: 45 20 54 41 42 4c 45 20 43 6f 6e 74 6f 75 72 73 E TABLE Contours
1280: 32 30 46 74 43 6c 69 70 70 65 64 20 41 53 0d 0a 20FtClipped AS..
1290: 53 45 4c 45 43 54 20 63 2e 49 64 20 41 53 20 49 SELECT c.Id AS I
12a0: 64 2c 20 63 2e 4f 42 4a 45 43 54 49 44 20 41 53 d, c.OBJECTID AS
12b0: 20 4f 42 4a 45 43 54 49 44 2c 20 0d 0a 20 20 63 OBJECTID, .. c
12c0: 2e 43 6f 6e 74 6f 75 72 20 41 53 20 43 6f 6e 74 .Contour AS Cont
12d0: 6f 75 72 2c 20 63 2e 53 68 61 70 65 5f 4c 65 6e our, c.Shape_Len
12e0: 67 20 41 53 20 53 68 61 70 65 5f 4c 65 6e 67 2c g AS Shape_Leng,
12f0: 0d 0a 20 20 43 61 73 74 54 6f 4d 75 6c 74 69 4c .. CastToMultiL
1300: 69 6e 65 73 74 72 69 6e 67 28 53 54 5f 49 6e 74 inestring(ST_Int
1310: 65 72 73 65 63 74 69 6f 6e 28 0d 0a 20 20 20 20 ersection(..
1320: 20 20 63 2e 47 65 6f 6d 65 74 72 79 2c 20 61 2e c.Geometry, a.
1330: 47 65 6f 6d 65 74 72 79 29 29 20 41 53 20 47 65 Geometry)) AS Ge
1340: 6f 6d 65 74 72 79 0d 0a 46 52 4f 4d 20 43 6f 6e ometry..FROM Con
1350: 74 6f 75 72 73 32 30 46 74 20 41 53 20 63 2c 20 tours20Ft AS c,
1360: 53 74 75 64 79 41 72 65 61 31 4d 69 6c 65 42 75 StudyArea1MileBu
1370: 66 66 65 72 20 41 53 20 61 0d 0a 57 48 45 52 45 ffer AS a..WHERE
1380: 20 63 2e 52 4f 57 49 44 20 49 4e 20 28 0d 0a 20 c.ROWID IN (..
1390: 20 20 20 53 45 4c 45 43 54 20 52 4f 57 49 44 20 SELECT ROWID
13a0: 0d 0a 20 20 20 20 46 52 4f 4d 20 53 70 61 74 69 .. FROM Spati
13b0: 61 6c 49 6e 64 65 78 0d 0a 20 20 20 20 57 48 45 alIndex.. WHE
13c0: 52 45 20 66 5f 74 61 62 6c 65 5f 6e 61 6d 65 20 RE f_table_name
13d0: 3d 20 27 43 6f 6e 74 6f 75 72 73 32 30 46 74 27 = 'Contours20Ft'
13e0: 20 0d 0a 20 20 20 20 20 20 20 20 41 4e 44 20 73 .. AND s
13f0: 65 61 72 63 68 5f 66 72 61 6d 65 20 3d 20 61 2e earch_frame = a.
1400: 47 65 6f 6d 65 74 72 79 0d 0a 29 3b 0d 0a 0d 0a Geometry..);....
1410: 53 45 4c 45 43 54 20 44 61 74 65 54 69 6d 65 28 SELECT DateTime(
1420: 27 6e 6f 77 27 29 2c 20 27 64 65 6c 65 74 69 6e 'now'), 'deletin
1430: 67 20 4e 55 4c 4c 20 47 65 6f 6d 65 74 72 69 65 g NULL Geometrie
1440: 73 27 3b 0d 0a 2d 2d 0d 0a 2d 2d 20 63 6c 65 61 s';..--..-- clea
1450: 6e 20 75 70 0d 0a 2d 2d 20 64 65 6c 65 74 69 6e n up..-- deletin
1460: 67 20 61 6e 79 20 4e 55 4c 4c 20 47 65 6f 6d 65 g any NULL Geome
1470: 74 72 79 20 66 72 6f 6d 20 43 6c 69 70 70 65 64 try from Clipped
1480: 20 43 6f 6e 74 6f 75 72 73 0d 0a 2d 2d 0d 0a 44 Contours..--..D
1490: 45 4c 45 54 45 20 46 52 4f 4d 20 43 6f 6e 74 6f ELETE FROM Conto
14a0: 75 72 73 32 30 46 74 43 6c 69 70 70 65 64 20 0d urs20FtClipped .
14b0: 0a 57 48 45 52 45 20 47 65 6f 6d 65 74 72 79 20 .WHERE Geometry
14c0: 49 53 20 4e 55 4c 4c 3b 0d 0a 0d 0a 53 45 4c 45 IS NULL;....SELE
14d0: 43 54 20 44 61 74 65 54 69 6d 65 28 27 6e 6f 77 CT DateTime('now
14e0: 27 29 2c 20 27 72 65 63 6f 76 65 72 69 6e 67 20 '), 'recovering
14f0: 61 20 67 65 6e 75 69 6e 65 20 47 65 6f 6d 65 74 a genuine Geomet
1500: 72 79 20 63 6f 6c 75 6d 6e 27 3b 0d 0a 2d 2d 0d ry column';..--.
1510: 0a 2d 2d 20 72 65 63 6f 76 65 72 69 6e 67 20 61 .-- recovering a
1520: 20 67 65 6e 75 69 6e 65 20 47 65 6f 6d 65 74 72 genuine Geometr
1530: 79 20 43 6f 6c 75 6d 6e 20 28 43 6c 69 70 70 65 y Column (Clippe
1540: 64 20 43 6f 6e 74 6f 75 72 73 29 0d 0a 2d 2d 2d d Contours)..---
1550: 0d 0a 53 45 4c 45 43 54 20 52 65 63 6f 76 65 72 ..SELECT Recover
1560: 47 65 6f 6d 65 74 72 79 43 6f 6c 75 6d 6e 28 27 GeometryColumn('
1570: 43 6f 6e 74 6f 75 72 73 32 30 46 74 43 6c 69 70 Contours20FtClip
1580: 70 65 64 27 2c 20 27 47 65 6f 6d 65 74 72 79 27 ped', 'Geometry'
1590: 2c 20 32 32 36 30 2c 20 27 4d 55 4c 54 49 4c 49 , 2260, 'MULTILI
15a0: 4e 45 53 54 52 49 4e 47 27 2c 20 32 29 3b 0d 0a NESTRING', 2);..
15b0: 0d 0a 53 45 4c 45 43 54 20 44 61 74 65 54 69 6d ..SELECT DateTim
15c0: 65 28 27 6e 6f 77 27 29 2c 20 27 63 72 65 61 74 e('now'), 'creat
15d0: 69 6e 67 20 74 68 65 20 53 70 61 74 69 61 6c 20 ing the Spatial
15e0: 49 6e 64 65 78 27 3b 0d 0a 2d 2d 0d 0a 2d 2d 20 Index';..--..--
15f0: 63 72 65 61 74 69 6e 67 20 61 20 53 70 61 74 69 creating a Spati
1600: 61 6c 20 28 49 6e 64 65 78 20 73 75 70 70 6f 72 al (Index suppor
1610: 74 69 6e 67 20 43 6c 69 70 70 65 64 20 43 6f 6e ting Clipped Con
1620: 74 6f 75 72 73 29 0d 0a 2d 2d 0d 0a 53 45 4c 45 tours)..--..SELE
1630: 43 54 20 43 72 65 61 74 65 53 70 61 74 69 61 6c CT CreateSpatial
1640: 49 6e 64 65 78 28 27 43 6f 6e 74 6f 75 72 73 32 Index('Contours2
1650: 30 46 74 43 6c 69 70 70 65 64 27 2c 20 27 47 65 0FtClipped', 'Ge
1660: 6f 6d 65 74 72 79 27 29 3b 0d 0a 0d 0a 0d 0a 53 ometry');......S
1670: 45 4c 45 43 54 20 44 61 74 65 54 69 6d 65 28 27 ELECT DateTime('
1680: 6e 6f 77 27 29 2c 20 27 61 6c 6c 20 64 6f 6e 65 now'), 'all done
1690: 20 2e 2e 2e 20 71 75 69 74 74 69 6e 67 27 3b 0d ... quitting';.
16a0: 0a 2d 2d 0d 0a 2d 2d 20 65 6e 64 20 6a 6f 62 0d .--..-- end job.
16b0: 0a 2d 2d 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e .--..</verbatim>
16c0: 0d 0a 44 6f 6e 27 74 20 62 65 20 66 6f 75 6c 65 ..Don't be foule
16d0: 64 3b 20 63 6f 6d 70 6c 65 78 69 74 79 20 69 73 d; complexity is
16e0: 20 6d 6f 72 65 20 61 70 70 61 72 65 6e 74 20 74 more apparent t
16f0: 68 61 6e 20 72 65 61 6c 2e 20 54 68 65 20 66 6f han real. The fo
1700: 6c 6c 6f 77 69 6e 67 20 69 73 20 61 20 71 75 69 llowing is a qui
1710: 63 6b 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20 6f ck explanation o
1720: 66 20 74 68 65 20 73 74 65 70 20 62 79 20 73 74 f the step by st
1730: 65 70 20 70 72 6f 63 65 73 73 20 64 65 66 69 6e ep process defin
1740: 65 64 20 62 79 20 74 68 65 20 61 62 6f 76 65 20 ed by the above
1750: 53 51 4c 20 73 63 72 69 70 74 2e 0d 0a 3c 74 61 SQL script...<ta
1760: 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d ble cellspacing=
1770: 22 36 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d "6" cellpadding=
1780: 22 36 22 3e 0d 0a 3c 74 72 3e 3c 74 64 20 62 67 "6">..<tr><td bg
1790: 63 6f 6c 6f 72 3d 22 23 66 34 66 34 66 34 22 3e color="#f4f4f4">
17a0: 3c 62 3e 2e 6c 6f 61 64 73 68 70 3c 2f 62 3e 20 <b>.loadshp</b>
17b0: 3c 69 3e 70 61 72 61 6d 65 74 65 72 73 3c 2f 69 <i>parameters</i
17c0: 3e 3c 2f 74 64 3e 0d 0a 3c 74 64 3e 3c 68 33 3e ></td>..<td><h3>
17d0: 53 74 65 70 20 23 31 3c 2f 68 33 3e 0d 0a 73 69 Step #1</h3>..si
17e0: 6d 70 6c 79 20 61 20 3c 62 3e 64 6f 74 20 6d 61 mply a <b>dot ma
17f0: 63 72 6f 20 63 6f 6d 6d 61 6e 64 3c 2f 62 3e 20 cro command</b>
1800: 75 6e 64 65 72 73 74 6f 6f 64 20 62 79 20 74 68 understood by th
1810: 65 20 53 70 61 74 69 61 4c 69 74 65 20 66 72 6f e SpatiaLite fro
1820: 6e 74 2d 65 6e 64 20 74 6f 6f 6c 2c 20 61 6c 6c nt-end tool, all
1830: 6f 77 69 6e 67 20 74 6f 20 64 69 72 65 63 74 6c owing to directl
1840: 79 20 69 6d 70 6f 72 74 20 61 6e 20 65 78 74 65 y import an exte
1850: 72 6e 61 6c 20 53 68 61 70 65 66 69 6c 65 20 69 rnal Shapefile i
1860: 6e 74 6f 20 61 20 63 6f 72 72 65 73 70 6f 6e 64 nto a correspond
1870: 69 6e 67 20 53 70 61 74 69 61 6c 20 54 61 62 6c ing Spatial Tabl
1880: 65 20 77 69 74 68 69 6e 20 74 68 65 20 44 42 2e e within the DB.
1890: 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </td></tr>..<tr>
18a0: 3c 74 64 3e 3c 76 65 72 62 61 74 69 6d 3e 0d 0a <td><verbatim>..
18b0: 43 52 45 41 54 45 20 54 41 42 4c 45 20 43 6f 6e CREATE TABLE Con
18c0: 74 6f 75 72 73 32 30 46 74 43 6c 69 70 70 65 64 tours20FtClipped
18d0: 20 41 53 0d 0a 53 45 4c 45 43 54 20 63 2e 49 64 AS..SELECT c.Id
18e0: 20 41 53 20 49 64 2c 20 63 2e 4f 42 4a 45 43 54 AS Id, c.OBJECT
18f0: 49 44 20 41 53 20 4f 42 4a 45 43 54 49 44 2c 20 ID AS OBJECTID,
1900: 0d 0a 20 20 63 2e 43 6f 6e 74 6f 75 72 20 41 53 .. c.Contour AS
1910: 20 43 6f 6e 74 6f 75 72 2c 20 63 2e 53 68 61 70 Contour, c.Shap
1920: 65 5f 4c 65 6e 67 20 41 53 20 53 68 61 70 65 5f e_Leng AS Shape_
1930: 4c 65 6e 67 2c 0d 0a 20 20 43 61 73 74 54 6f 4d Leng,.. CastToM
1940: 75 6c 74 69 4c 69 6e 65 73 74 72 69 6e 67 28 53 ultiLinestring(S
1950: 54 5f 49 6e 74 65 72 73 65 63 74 69 6f 6e 28 0d T_Intersection(.
1960: 0a 20 20 20 20 20 20 63 2e 47 65 6f 6d 65 74 72 . c.Geometr
1970: 79 2c 20 61 2e 47 65 6f 6d 65 74 72 79 29 29 20 y, a.Geometry))
1980: 41 53 20 47 65 6f 6d 65 74 72 79 0d 0a 46 52 4f AS Geometry..FRO
1990: 4d 20 43 6f 6e 74 6f 75 72 73 32 30 46 74 20 41 M Contours20Ft A
19a0: 53 20 63 2c 20 53 74 75 64 79 41 72 65 61 31 4d S c, StudyArea1M
19b0: 69 6c 65 42 75 66 66 65 72 20 41 53 20 61 0d 0a ileBuffer AS a..
19c0: 57 48 45 52 45 20 63 2e 52 4f 57 49 44 20 49 4e WHERE c.ROWID IN
19d0: 20 28 0d 0a 20 20 20 20 53 45 4c 45 43 54 20 52 (.. SELECT R
19e0: 4f 57 49 44 20 0d 0a 20 20 20 20 46 52 4f 4d 20 OWID .. FROM
19f0: 53 70 61 74 69 61 6c 49 6e 64 65 78 0d 0a 20 20 SpatialIndex..
1a00: 20 20 57 48 45 52 45 20 66 5f 74 61 62 6c 65 5f WHERE f_table_
1a10: 6e 61 6d 65 20 3d 20 27 43 6f 6e 74 6f 75 72 73 name = 'Contours
1a20: 32 30 46 74 27 20 0d 0a 20 20 20 20 20 20 20 20 20Ft' ..
1a30: 41 4e 44 20 73 65 61 72 63 68 5f 66 72 61 6d 65 AND search_frame
1a40: 20 3d 20 61 2e 47 65 6f 6d 65 74 72 79 0d 0a 29 = a.Geometry..)
1a50: 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 3c 2f ;..</verbatim></
1a60: 74 64 3e 0d 0a 3c 74 64 3e 3c 68 33 3e 53 74 65 td>..<td><h3>Ste
1a70: 70 20 23 32 3c 2f 68 33 3e 0d 0a 74 68 69 73 20 p #2</h3>..this
1a80: 73 69 6e 67 6c 65 20 53 51 4c 20 71 75 65 72 79 single SQL query
1a90: 20 70 65 72 66 6f 72 6d 73 20 61 6c 6c 20 74 68 performs all th
1aa0: 65 20 61 63 74 75 61 6c 20 43 6c 69 70 70 69 6e e actual Clippin
1ab0: 67 20 74 61 73 6b 2e 3c 62 72 3e 0d 0a 3c 62 3e g task.<br>..<b>
1ac0: 53 54 5f 49 6e 74 65 72 73 65 63 74 69 6f 6e 28 ST_Intersection(
1ad0: 29 3c 2f 62 3e 20 69 73 20 61 20 53 70 61 74 69 )</b> is a Spati
1ae0: 61 6c 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 al SQL function
1af0: 63 6f 6d 70 75 74 69 6e 67 20 74 68 65 20 69 6e computing the in
1b00: 74 65 72 73 65 63 74 69 6f 6e 20 62 65 74 77 65 tersection betwe
1b10: 65 6e 20 74 68 65 20 3c 62 3e 53 74 75 64 79 20 en the <b>Study
1b20: 41 72 65 61 3c 2f 62 3e 20 28 3c 69 3e 70 6f 6c Area</b> (<i>pol
1b30: 79 67 6f 6e 3c 2f 69 3e 29 20 61 6e 64 20 65 61 ygon</i>) and ea
1b40: 63 68 20 3c 62 3e 43 6f 6e 74 6f 75 72 20 4c 69 ch <b>Contour Li
1b50: 6e 65 3c 2f 62 3e 20 28 3c 69 3e 6c 69 6e 65 73 ne</b> (<i>lines
1b60: 74 72 69 6e 67 3c 2f 69 3e 29 2e 20 54 68 69 73 tring</i>). This
1b70: 20 63 6f 75 6c 64 20 62 65 3a 3c 75 6c 3e 0d 0a could be:<ul>..
1b80: 3c 6c 69 3e 61 20 4c 69 6e 65 73 74 72 69 6e 67 <li>a Linestring
1b90: 20 6f 72 20 61 20 4d 75 6c 74 69 4c 69 6e 65 73 or a MultiLines
1ba0: 74 72 69 6e 67 20 28 64 65 70 65 6e 64 69 6e 67 tring (depending
1bb0: 20 6f 6e 20 74 68 65 20 73 70 65 63 69 66 69 63 on the specific
1bc0: 20 73 68 61 70 65 20 6f 66 20 62 6f 74 68 20 67 shape of both g
1bd0: 65 6f 6d 65 74 72 69 65 73 29 3c 2f 6c 69 3e 0d eometries)</li>.
1be0: 0a 3c 6c 69 3e 61 20 4e 55 4c 4c 20 28 69 2e 65 .<li>a NULL (i.e
1bf0: 2e 20 3c 2f 69 3e 61 62 73 6f 6c 75 74 65 6c 79 . </i>absolutely
1c00: 20 6e 6f 74 68 69 6e 67 3c 2f 69 3e 29 20 69 66 nothing</i>) if
1c10: 20 74 68 65 20 43 6f 6e 74 6f 75 72 20 4c 69 6e the Contour Lin
1c20: 65 20 61 6e 64 20 74 68 65 20 53 74 75 64 79 20 e and the Study
1c30: 41 72 65 61 20 64 6f 20 6e 6f 74 20 69 6e 74 65 Area do not inte
1c40: 72 73 65 63 74 20 61 74 20 61 6c 6c 2e 3c 2f 6c rsect at all.</l
1c50: 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 43 61 73 74 54 i>..<li><b>CastT
1c60: 6f 4d 75 6c 74 69 4c 69 6e 65 73 74 72 69 6e 67 oMultiLinestring
1c70: 28 29 3c 2f 62 3e 20 73 69 6d 70 6c 79 20 69 73 ()</b> simply is
1c80: 20 61 20 3c 75 3e 3c 69 3e 63 61 73 74 20 6f 70 a <u><i>cast op
1c90: 65 72 61 74 6f 72 3c 2f 69 3e 3c 2f 75 3e 20 65 erator</i></u> e
1ca0: 6e 73 75 72 69 6e 67 20 74 68 61 74 20 61 6c 6c nsuring that all
1cb0: 20 72 65 74 75 72 6e 65 64 20 67 65 6f 6d 65 74 returned geomet
1cc0: 72 69 65 73 20 77 69 6c 6c 20 62 65 20 6f 66 20 ries will be of
1cd0: 74 68 65 20 73 61 6d 65 20 74 79 70 65 2e 3c 2f the same type.</
1ce0: 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20 69 6e 6e li>..<li>the inn
1cf0: 65 72 20 73 75 62 2d 71 75 65 72 79 20 3c 62 3e er sub-query <b>
1d00: 53 45 4c 45 43 54 20 52 4f 57 49 44 20 46 52 4f SELECT ROWID FRO
1d10: 4d 20 53 70 61 74 69 61 6c 49 6e 64 65 78 20 2e M SpatialIndex .
1d20: 2e 2e 3c 2f 62 3e 20 69 73 20 73 69 6d 70 6c 79 ..</b> is simply
1d30: 20 69 6e 74 65 6e 64 65 64 20 74 6f 20 61 63 63 intended to acc
1d40: 65 73 73 20 74 68 65 20 53 70 61 74 69 61 6c 20 ess the Spatial
1d50: 49 6e 64 65 78 20 73 75 70 70 6f 72 74 69 6e 67 Index supporting
1d60: 20 74 68 65 20 43 6f 6e 74 6f 75 72 20 4c 69 6e the Contour Lin
1d70: 65 73 2c 20 73 6f 20 74 6f 20 73 70 65 65 64 20 es, so to speed
1d80: 75 70 20 74 68 65 20 77 68 6f 6c 65 20 71 75 65 up the whole que
1d90: 72 79 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 ry.</li>..<li><b
1da0: 3e 43 52 45 41 54 45 20 54 41 42 4c 45 20 43 6f >CREATE TABLE Co
1db0: 6e 74 6f 75 72 73 32 30 46 74 43 6c 69 70 70 65 ntours20FtClippe
1dc0: 64 20 41 53 3c 2f 62 3e 20 73 69 6d 70 6c 79 20 d AS</b> simply
1dd0: 69 6e 74 65 6e 64 73 20 74 68 61 74 20 74 68 65 intends that the
1de0: 20 72 65 73 75 6c 74 73 65 74 20 72 65 74 75 72 resultset retur
1df0: 6e 65 64 20 62 79 20 74 68 69 73 20 53 51 4c 20 ned by this SQL
1e00: 71 75 65 72 79 20 68 61 73 20 74 6f 20 62 65 20 query has to be
1e10: 70 65 72 6d 61 6e 65 6e 74 6c 79 20 73 61 76 65 permanently save
1e20: 64 20 69 6e 74 6f 20 79 65 74 20 61 6e 6f 74 68 d into yet anoth
1e30: 65 72 20 74 61 62 6c 65 20 28 74 6f 20 62 65 20 er table (to be
1e40: 63 72 65 61 74 65 64 20 6f 6e 20 74 68 65 20 66 created on the f
1e50: 6c 79 29 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e ly).</li>..</ul>
1e60: 3c 62 72 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e <br>..</td></tr>
1e70: 0d 0a 3c 74 72 3e 3c 74 64 3e 3c 76 65 72 62 61 ..<tr><td><verba
1e80: 74 69 6d 3e 0d 0a 44 45 4c 45 54 45 20 46 52 4f tim>..DELETE FRO
1e90: 4d 20 43 6f 6e 74 6f 75 72 73 32 30 46 74 43 6c M Contours20FtCl
1ea0: 69 70 70 65 64 20 0d 0a 57 48 45 52 45 20 47 65 ipped ..WHERE Ge
1eb0: 6f 6d 65 74 72 79 20 49 53 20 4e 55 4c 4c 3b 0d ometry IS NULL;.
1ec0: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 3c 2f 74 64 .</verbatim></td
1ed0: 3e 0d 0a 3c 74 64 3e 3c 68 33 3e 53 74 65 70 20 >..<td><h3>Step
1ee0: 23 33 3c 2f 68 33 3e 0d 0a 6a 75 73 74 20 61 20 #3</h3>..just a
1ef0: 73 74 75 70 69 64 20 70 6f 73 74 2d 70 72 6f 63 stupid post-proc
1f00: 65 73 73 69 6e 67 20 73 74 65 70 3b 20 74 68 65 essing step; the
1f10: 20 70 72 65 76 69 6f 75 73 20 71 75 65 72 79 20 previous query
1f20: 68 61 73 20 73 75 72 65 6c 79 20 67 65 6e 65 72 has surely gener
1f30: 61 74 65 64 20 6d 61 6e 79 20 4e 55 4c 4c 20 67 ated many NULL g
1f40: 65 6f 6d 65 74 72 69 65 73 2c 20 61 6e 64 20 77 eometries, and w
1f50: 65 27 6c 6c 20 6e 6f 77 20 67 65 74 20 72 69 64 e'll now get rid
1f60: 20 6f 66 20 61 6c 6c 20 74 68 65 6d 2e 3c 2f 6c of all them.</l
1f70: 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c i>..</ul><br>..<
1f80: 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /td></tr>..<tr><
1f90: 74 64 3e 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 td><verbatim>..S
1fa0: 45 4c 45 43 54 20 52 65 63 6f 76 65 72 47 65 6f ELECT RecoverGeo
1fb0: 6d 65 74 72 79 43 6f 6c 75 6d 6e 28 27 43 6f 6e metryColumn('Con
1fc0: 74 6f 75 72 73 32 30 46 74 43 6c 69 70 70 65 64 tours20FtClipped
1fd0: 27 2c 20 27 47 65 6f 6d 65 74 72 79 27 2c 20 0d ', 'Geometry', .
1fe0: 0a 20 20 20 20 32 32 36 30 2c 20 27 4d 55 4c 54 . 2260, 'MULT
1ff0: 49 4c 49 4e 45 53 54 52 49 4e 47 27 2c 20 32 29 ILINESTRING', 2)
2000: 3b 0d 0a 53 45 4c 45 43 54 20 43 72 65 61 74 65 ;..SELECT Create
2010: 53 70 61 74 69 61 6c 49 6e 64 65 78 28 27 43 6f SpatialIndex('Co
2020: 6e 74 6f 75 72 73 32 30 46 74 43 6c 69 70 70 65 ntours20FtClippe
2030: 64 27 2c 20 27 47 65 6f 6d 65 74 72 79 27 29 3b d', 'Geometry');
2040: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 3c 2f 74 ..</verbatim></t
2050: 64 3e 0d 0a 3c 74 64 3e 3c 68 33 3e 53 74 65 70 d>..<td><h3>Step
2060: 20 23 34 3c 2f 68 33 3e 0d 0a 74 68 65 20 76 65 #4</h3>..the ve
2070: 72 79 20 66 69 6e 61 6c 20 70 6f 73 74 2d 70 72 ry final post-pr
2080: 6f 63 65 73 73 69 6e 67 20 73 74 65 70 3a 20 74 ocessing step: t
2090: 72 61 6e 73 66 6f 72 6d 69 6e 67 20 74 68 65 20 ransforming the
20a0: 74 61 62 6c 65 20 63 6f 6e 74 61 69 6e 69 6e 67 table containing
20b0: 20 61 6c 6c 20 43 6c 69 70 70 65 64 20 43 6f 6e all Clipped Con
20c0: 74 6f 75 72 20 4c 69 6e 65 73 20 69 6e 74 6f 20 tour Lines into
20d0: 61 20 67 65 6e 75 69 6e 65 20 53 70 61 74 69 61 a genuine Spatia
20e0: 6c 20 54 61 62 6c 65 20 73 75 70 70 6f 72 74 65 l Table supporte
20f0: 64 20 62 79 20 69 74 73 20 6f 77 6e 20 53 70 61 d by its own Spa
2100: 74 69 61 6c 20 49 6e 64 65 78 2e 3c 2f 6c 69 3e tial Index.</li>
2110: 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 2f 74 ..</ul><br>..</t
2120: 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 d></tr>..<tr><td
2130: 3e 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c ><verbatim>..SEL
2140: 45 43 54 20 44 61 74 65 54 69 6d 65 28 27 6e 6f ECT DateTime('no
2150: 77 27 29 2c 20 27 73 6f 6d 65 20 6d 65 73 73 61 w'), 'some messa
2160: 67 65 27 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d ge';..</verbatim
2170: 3e 3c 2f 74 64 3e 0d 0a 3c 74 64 3e 3c 68 33 3e ></td>..<td><h3>
2180: 6d 65 61 73 75 72 69 6e 67 20 74 68 65 20 74 69 measuring the ti
2190: 6d 65 3c 2f 68 33 3e 74 68 69 73 20 73 69 6d 70 me</h3>this simp
21a0: 6c 79 20 69 73 20 61 20 77 65 69 72 64 20 53 51 ly is a weird SQ
21b0: 4c 20 74 72 69 63 6b 3b 20 77 65 27 6c 6c 20 71 L trick; we'll q
21c0: 75 65 72 79 20 74 68 65 20 73 79 73 74 65 6d 20 uery the system
21d0: 63 6c 6f 63 6b 20 69 6d 6d 65 64 69 61 74 65 6c clock immediatel
21e0: 79 20 62 65 66 6f 72 65 20 61 6e 64 20 61 66 74 y before and aft
21f0: 65 72 20 70 65 72 66 6f 72 6d 69 6e 67 20 65 61 er performing ea
2200: 63 68 20 73 74 65 70 2c 20 73 6f 20 74 6f 20 67 ch step, so to g
2210: 65 74 20 66 75 6c 6c 20 74 72 61 63 65 20 6f 66 et full trace of
2220: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 the correspondi
2230: 6e 67 20 74 69 6d 69 6e 67 73 2e 3c 2f 6c 69 3e ng timings.</li>
2240: 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 2f 74 ..</ul><br>..</t
2250: 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 d></tr>..</table
2260: 3e 0d 0a 3c 68 34 3e 42 72 69 6e 67 69 6e 67 20 >..<h4>Bringing
2270: 74 68 69 6e 67 73 20 74 6f 20 61 20 68 65 61 64 things to a head
2280: 3a 20 72 75 6e 6e 69 6e 67 20 74 68 65 20 74 65 : running the te
2290: 73 74 3c 2f 68 34 3e 0d 0a 3c 76 65 72 62 61 74 st</h4>..<verbat
22a0: 69 6d 3e 0d 0a 23 20 73 70 61 74 69 61 6c 69 74 im>..# spatialit
22b0: 65 20 6d 79 5f 74 65 73 74 2e 73 71 6c 69 74 65 e my_test.sqlite
22c0: 20 3c 20 74 65 73 74 2e 73 71 6c 0d 0a 0d 0a 53 < test.sql....S
22d0: 70 61 74 69 61 4c 69 74 65 20 76 65 72 73 69 6f patiaLite versio
22e0: 6e 20 2e 2e 3a 20 34 2e 30 2e 30 2d 52 43 32 09 n ..: 4.0.0-RC2.
22f0: 53 75 70 70 6f 72 74 65 64 20 45 78 74 65 6e 73 Supported Extens
2300: 69 6f 6e 73 3a 0d 0a 09 2d 20 27 56 69 72 74 75 ions:...- 'Virtu
2310: 61 6c 53 68 61 70 65 27 09 5b 64 69 72 65 63 74 alShape'.[direct
2320: 20 53 68 61 70 65 66 69 6c 65 20 61 63 63 65 73 Shapefile acces
2330: 73 5d 0d 0a 09 2d 20 27 56 69 72 74 75 61 6c 44 s]...- 'VirtualD
2340: 62 66 27 09 09 5b 64 69 72 65 63 74 20 44 42 46 bf'..[direct DBF
2350: 20 61 63 63 65 73 73 5d 0d 0a 09 2d 20 27 56 69 access]...- 'Vi
2360: 72 74 75 61 6c 58 4c 27 09 09 5b 64 69 72 65 63 rtualXL'..[direc
2370: 74 20 58 4c 53 20 61 63 63 65 73 73 5d 0d 0a 09 t XLS access]...
2380: 2d 20 27 56 69 72 74 75 61 6c 54 65 78 74 27 09 - 'VirtualText'.
2390: 09 5b 64 69 72 65 63 74 20 43 53 56 2f 54 58 54 .[direct CSV/TXT
23a0: 20 61 63 63 65 73 73 5d 0d 0a 09 2d 20 27 56 69 access]...- 'Vi
23b0: 72 74 75 61 6c 4e 65 74 77 6f 72 6b 27 09 5b 44 rtualNetwork'.[D
23c0: 69 6a 6b 73 74 72 61 20 73 68 6f 72 74 65 73 74 ijkstra shortest
23d0: 20 70 61 74 68 5d 0d 0a 09 2d 20 27 52 54 72 65 path]...- 'RTre
23e0: 65 27 09 09 5b 53 70 61 74 69 61 6c 20 49 6e 64 e'..[Spatial Ind
23f0: 65 78 20 2d 20 52 2a 54 72 65 65 5d 0d 0a 09 2d ex - R*Tree]...-
2400: 20 27 4d 62 72 43 61 63 68 65 27 09 09 5b 53 70 'MbrCache'..[Sp
2410: 61 74 69 61 6c 20 49 6e 64 65 78 20 2d 20 4d 42 atial Index - MB
2420: 52 20 63 61 63 68 65 5d 0d 0a 09 2d 20 27 56 69 R cache]...- 'Vi
2430: 72 74 75 61 6c 53 70 61 74 69 61 6c 49 6e 64 65 rtualSpatialInde
2440: 78 27 09 5b 52 2a 54 72 65 65 20 6d 65 74 61 68 x'.[R*Tree metah
2450: 61 6e 64 6c 65 72 5d 0d 0a 09 2d 20 27 56 69 72 andler]...- 'Vir
2460: 74 75 61 6c 46 44 4f 27 09 09 5b 46 44 4f 2d 4f tualFDO'..[FDO-O
2470: 47 52 20 69 6e 74 65 72 6f 70 65 72 61 62 69 6c GR interoperabil
2480: 69 74 79 5d 0d 0a 09 2d 20 27 53 70 61 74 69 61 ity]...- 'Spatia
2490: 4c 69 74 65 27 09 09 5b 53 70 61 74 69 61 6c 20 Lite'..[Spatial
24a0: 53 51 4c 20 2d 20 4f 47 43 5d 0d 0a 50 52 4f 4a SQL - OGC]..PROJ
24b0: 2e 34 20 76 65 72 73 69 6f 6e 20 2e 2e 2e 2e 2e .4 version .....
24c0: 2e 3a 20 52 65 6c 2e 20 34 2e 37 2e 31 2c 20 32 .: Rel. 4.7.1, 2
24d0: 33 20 53 65 70 74 65 6d 62 65 72 20 32 30 30 39 3 September 2009
24e0: 0d 0a 47 45 4f 53 20 76 65 72 73 69 6f 6e 20 2e ..GEOS version .
24f0: 2e 2e 2e 2e 2e 2e 2e 3a 20 33 2e 32 2e 30 2d 43 .......: 3.2.0-C
2500: 41 50 49 2d 31 2e 36 2e 30 0d 0a 0d 0a 32 30 31 API-1.6.0....201
2510: 32 2d 31 31 2d 31 30 20 30 30 3a 30 33 3a 35 32 2-11-10 00:03:52
2520: 7c 4c 6f 61 64 69 6e 67 20 74 68 65 20 53 74 75 |Loading the Stu
2530: 64 79 41 72 65 61 20 53 48 50 0d 0a 32 30 31 32 dyArea SHP..2012
2540: 2d 31 31 2d 31 30 20 30 30 3a 30 33 3a 35 32 7c -11-10 00:03:52|
2550: 4c 6f 61 64 69 6e 67 20 74 68 65 20 43 6f 6e 74 Loading the Cont
2560: 6f 75 72 73 20 53 48 50 0d 0a 32 30 31 32 2d 31 ours SHP..2012-1
2570: 31 2d 31 30 20 30 30 3a 30 34 3a 35 34 7c 43 6c 1-10 00:04:54|Cl
2580: 69 70 70 69 6e 67 20 2e 2e 2e 20 70 6c 65 61 73 ipping ... pleas
2590: 65 20 77 61 69 74 0d 0a 32 30 31 32 2d 31 31 2d e wait..2012-11-
25a0: 31 30 20 30 30 3a 30 37 3a 33 31 7c 64 65 6c 65 10 00:07:31|dele
25b0: 74 69 6e 67 20 4e 55 4c 4c 20 47 65 6f 6d 65 74 ting NULL Geomet
25c0: 72 69 65 73 0d 0a 32 30 31 32 2d 31 31 2d 31 30 ries..2012-11-10
25d0: 20 30 30 3a 30 37 3a 33 33 7c 72 65 63 6f 76 65 00:07:33|recove
25e0: 72 69 6e 67 20 61 20 67 65 6e 75 69 6e 65 20 47 ring a genuine G
25f0: 65 6f 6d 65 74 72 79 20 63 6f 6c 75 6d 6e 0d 0a eometry column..
2600: 32 30 31 32 2d 31 31 2d 31 30 20 30 30 3a 30 37 2012-11-10 00:07
2610: 3a 33 34 7c 63 72 65 61 74 69 6e 67 20 74 68 65 :34|creating the
2620: 20 53 70 61 74 69 61 6c 20 49 6e 64 65 78 0d 0a Spatial Index..
2630: 32 30 31 32 2d 31 31 2d 31 30 20 30 30 3a 30 37 2012-11-10 00:07
2640: 3a 33 36 7c 61 6c 6c 20 64 6f 6e 65 20 2e 2e 2e :36|all done ...
2650: 20 71 75 69 74 74 69 6e 67 0d 0a 23 0d 0a 3c 2f quitting..#..</
2660: 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 68 32 3e 46 verbatim>..<h2>F
2670: 69 6e 61 6c 20 63 6f 6e 73 69 64 65 72 61 74 69 inal considerati
2680: 6f 6e 73 3c 2f 68 32 3e 0d 0a 3c 75 6c 3e 0d 0a ons</h2>..<ul>..
2690: 3c 6c 69 3e 54 68 65 20 77 68 6f 6c 65 20 70 72 <li>The whole pr
26a0: 6f 63 65 73 73 20 74 6f 6f 6b 20 6c 65 73 73 20 ocess took less
26b0: 74 68 61 6e 20 3c 62 3e 34 20 6d 69 6e 75 74 65 than <b>4 minute
26c0: 73 3c 2f 62 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e s</b></li>..<li>
26d0: 41 62 6f 75 74 20 3c 62 3e 31 20 6d 69 6e 75 74 About <b>1 minut
26e0: 65 3c 2f 62 3e 20 77 61 73 20 73 70 65 6e 74 20 e</b> was spent
26f0: 6c 6f 61 64 69 6e 67 20 74 68 65 20 53 68 61 70 loading the Shap
2700: 65 66 69 6c 65 73 20 61 6e 64 20 62 75 69 6c 64 efiles and build
2710: 69 6e 67 20 74 68 65 20 73 75 70 70 6f 72 74 69 ing the supporti
2720: 6e 67 20 53 70 61 74 69 61 6c 20 49 6e 64 65 78 ng Spatial Index
2730: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4c 65 73 73 20 </li>..<li>Less
2740: 74 68 61 6e 20 3c 62 3e 31 30 20 73 65 63 6f 6e than <b>10 secon
2750: 64 73 3c 2f 62 3e 20 77 65 72 65 20 73 70 65 6e ds</b> were spen
2760: 74 20 70 65 72 66 6f 72 6d 69 6e 67 20 70 6f 73 t performing pos
2770: 74 2d 70 72 6f 63 65 73 73 69 6e 67 20 73 74 65 t-processing ste
2780: 70 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 54 68 ps.</li>..<li>Th
2790: 65 20 68 61 72 64 2d 63 6f 72 65 20 70 72 6f 62 e hard-core prob
27a0: 6c 65 6d 20 69 74 73 65 6c 66 20 28 67 65 6e 65 lem itself (gene
27b0: 72 61 74 69 6e 67 20 61 20 43 6c 69 70 70 65 64 rating a Clipped
27c0: 20 73 65 74 20 6f 66 20 43 6f 6e 74 6f 75 72 20 set of Contour
27d0: 4c 69 6e 65 73 29 20 74 6f 6f 6b 20 61 62 6f 75 Lines) took abou
27e0: 74 20 3c 62 3e 32 20 6d 69 6e 75 74 65 73 20 61 t <b>2 minutes a
27f0: 6e 64 20 68 61 6c 66 3c 2f 62 3e 2e 3c 2f 6c 69 nd half</b>.</li
2800: 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 75 >..</ul><br>..<u
2810: 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e >Please note</u>
2820: 3a 20 74 68 69 73 20 3c 62 3e 43 6c 69 70 70 69 : this <b>Clippi
2830: 6e 67 20 43 6f 6e 74 65 73 74 3c 2f 62 3e 20 72 ng Contest</b> r
2840: 65 61 6c 6c 79 20 69 73 20 6c 69 6b 65 20 3c 62 eally is like <b
2850: 3e 63 6f 6d 70 61 72 69 6e 67 20 61 70 70 6c 65 >comparing apple
2860: 73 20 61 6e 64 20 6f 72 61 6e 67 65 73 3c 2f 62 s and oranges</b
2870: 3e 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 74 68 >...<ul>..<li>th
2880: 65 20 43 50 55 73 20 75 73 65 64 20 74 6f 20 61 e CPUs used to a
2890: 63 74 75 61 6c 6c 79 20 72 75 6e 20 74 68 65 20 ctually run the
28a0: 74 65 73 74 73 20 61 72 65 20 6f 66 20 64 69 66 tests are of dif
28b0: 66 65 72 65 6e 74 20 67 65 6e 65 72 61 74 69 6f ferent generatio
28c0: 6e 73 2c 20 61 6e 64 20 6f 62 76 69 6f 75 73 6c ns, and obviousl
28d0: 79 20 68 61 76 65 20 64 69 66 66 65 72 65 6e 74 y have different
28e0: 20 69 6e 74 72 69 6e 73 69 63 20 73 70 65 65 64 intrinsic speed
28f0: 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 s.</li>..<li>the
2900: 20 61 6d 6f 75 6e 74 20 6f 66 20 61 76 61 69 6c amount of avail
2910: 61 62 6c 65 20 52 41 4d 20 69 73 20 61 62 73 6f able RAM is abso
2920: 6c 75 74 65 6c 79 20 6e 6f 74 20 72 65 6c 65 76 lutely not relev
2930: 61 6e 74 3b 20 74 68 69 73 20 43 6f 6e 74 65 73 ant; this Contes
2940: 74 20 63 6f 75 6c 64 20 65 76 65 6e 74 75 61 6c t could eventual
2950: 6c 79 20 62 65 6e 65 66 69 74 20 66 72 6f 6d 20 ly benefit from
2960: 61 20 66 61 73 74 65 72 20 43 50 55 2c 20 62 75 a faster CPU, bu
2970: 74 20 74 68 65 20 72 65 71 75 69 72 65 64 20 6d t the required m
2980: 65 6d 6f 72 79 20 66 6f 6f 74 70 72 69 6e 74 20 emory footprint
2990: 69 73 20 6d 69 6e 69 6d 61 6c 20 28 6a 75 73 74 is minimal (just
29a0: 20 66 65 77 20 68 75 6e 64 72 65 64 74 68 20 4d few hundredth M
29b0: 42 20 69 6e 20 74 68 65 20 53 70 61 74 69 61 4c B in the SpatiaL
29c0: 69 74 65 27 73 20 63 61 73 65 29 2e 3c 2f 6c 69 ite's case).</li
29d0: 3e 0d 0a 3c 6c 69 3e 61 64 6f 70 74 69 6e 67 20 >..<li>adopting
29e0: 73 6f 6d 65 20 6b 69 6e 64 20 6f 66 20 70 61 72 some kind of par
29f0: 61 6c 6c 65 6c 20 70 72 6f 63 65 73 73 69 6e 67 allel processing
2a00: 20 77 69 6c 6c 20 6f 62 76 69 6f 75 73 6c 79 20 will obviously
2a10: 69 6e 74 72 6f 64 75 63 65 20 61 20 6e 6f 74 69 introduce a noti
2a20: 63 65 61 62 6c 65 20 70 65 72 66 6f 72 6d 61 6e ceable performan
2a30: 63 65 20 62 6f 6f 73 74 20 28 53 70 61 74 69 61 ce boost (Spatia
2a40: 4c 69 74 65 20 69 73 20 73 69 6e 67 6c 65 20 74 Lite is single t
2a50: 68 72 65 61 64 65 64 3b 20 73 6f 20 75 73 69 6e hreaded; so usin
2a60: 67 20 61 20 71 75 61 64 2d 63 6f 72 65 20 70 72 g a quad-core pr
2a70: 6f 63 65 73 73 6f 72 20 68 61 64 20 61 62 73 6f ocessor had abso
2a80: 6c 75 74 65 6c 79 20 6e 6f 20 65 66 66 65 63 74 lutely no effect
2a90: 20 61 74 20 61 6c 6c 29 2e 3c 2f 6c 69 3e 0d 0a at all).</li>..
2aa0: 3c 2f 75 6c 3e 0d 0a 3c 68 34 3e 57 68 61 74 20 </ul>..<h4>What
2ab0: 61 72 65 20 77 65 20 6d 65 61 73 75 72 69 6e 67 are we measuring
2ac0: 2c 20 72 65 61 6c 6c 79 20 3f 3c 2f 68 34 3e 0d , really ?</h4>.
2ad0: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 4d 61 6e 79 20 .<ul>..<li>Many
2ae0: 47 46 4f 53 53 20 69 6d 70 6c 65 6d 65 6e 74 61 GFOSS implementa
2af0: 74 69 6f 6e 73 20 28 51 47 49 53 2c 20 50 6f 73 tions (QGIS, Pos
2b00: 74 47 49 53 2c 20 53 70 61 74 69 61 4c 69 74 65 tGIS, SpatiaLite
2b10: 29 20 61 72 65 20 62 61 73 65 64 20 6f 6e 20 3c ) are based on <
2b20: 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f 74 a href="http://t
2b30: 72 61 63 2e 6f 73 67 65 6f 2e 6f 72 67 2f 67 65 rac.osgeo.org/ge
2b40: 6f 73 2f 22 3e 47 45 4f 53 3c 2f 61 3e 3b 20 73 os/">GEOS</a>; s
2b50: 6f 20 61 6e 79 20 6d 65 61 73 75 72 65 64 20 74 o any measured t
2b60: 69 6d 65 20 65 66 66 65 63 74 69 76 65 6c 79 20 ime effectively
2b70: 72 65 70 72 65 73 65 6e 74 73 20 74 68 65 20 69 represents the i
2b80: 6e 74 72 69 6e 73 69 63 20 65 66 66 69 63 69 65 ntrinsic efficie
2b90: 6e 63 79 20 6f 66 20 47 45 4f 53 20 6d 75 63 68 ncy of GEOS much
2ba0: 20 6d 6f 72 65 20 74 68 61 6e 20 74 68 65 20 65 more than the e
2bb0: 66 66 69 63 69 65 6e 63 79 20 6f 66 20 74 68 65 fficiency of the
2bc0: 20 74 6f 70 2d 6c 65 76 65 6c 20 61 70 70 6c 69 top-level appli
2bd0: 63 61 74 69 6f 6e 20 69 74 73 65 6c 66 2e 3c 62 cation itself.<b
2be0: 72 3e 0d 0a 49 66 20 61 20 64 69 66 66 65 72 65 r>..If a differe
2bf0: 6e 63 65 20 65 78 69 73 74 73 20 62 65 74 77 65 nce exists betwe
2c00: 65 6e 20 64 69 66 66 65 72 65 6e 74 20 47 45 4f en different GEO
2c10: 53 2d 62 61 73 65 64 20 61 70 70 73 2c 20 74 68 S-based apps, th
2c20: 69 73 20 69 73 20 73 69 6d 70 6c 79 20 77 68 65 is is simply whe
2c30: 6e 20 74 68 65 20 74 6f 70 2d 6c 65 76 65 6c 20 n the top-level
2c40: 61 70 70 73 20 62 61 64 6c 79 20 69 6e 74 72 6f apps badly intro
2c50: 64 75 63 65 73 20 73 6f 6d 65 20 66 75 72 74 68 duces some furth
2c60: 65 72 20 6f 76 65 72 68 65 61 64 20 74 68 75 73 er overhead thus
2c70: 20 72 65 64 75 63 69 6e 67 20 74 68 65 20 6f 76 reducing the ov
2c80: 65 72 61 6c 6c 20 65 66 66 69 63 69 65 6e 63 79 erall efficiency
2c90: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4f 74 68 65 .</li>..<li>Othe
2ca0: 72 20 47 46 4f 53 53 20 4a 61 76 61 20 69 6d 70 r GFOSS Java imp
2cb0: 6c 65 6d 65 6e 74 61 74 69 6f 6e 73 20 28 67 76 lementations (gv
2cc0: 53 49 47 2c 20 4f 70 65 6e 4a 75 6d 70 2c 20 75 SIG, OpenJump, u
2cd0: 44 49 47 29 20 61 72 65 20 62 61 73 65 64 20 6f DIG) are based o
2ce0: 6e 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a n <a href="http:
2cf0: 2f 2f 77 77 77 2e 76 69 76 69 64 73 6f 6c 75 74 //www.vividsolut
2d00: 69 6f 6e 73 2e 63 6f 6d 2f 6a 74 73 2f 6a 74 73 ions.com/jts/jts
2d10: 68 6f 6d 65 2e 68 74 6d 22 3e 4a 54 53 3c 2f 61 home.htm">JTS</a
2d20: 3e 3b 20 62 75 74 20 47 45 4f 53 20 73 69 6d 70 >; but GEOS simp
2d30: 6c 79 20 69 73 20 61 20 74 72 61 6e 73 70 6f 73 ly is a transpos
2d40: 69 74 69 6f 6e 20 69 6e 20 43 2b 2b 20 6f 66 20 ition in C++ of
2d50: 4a 54 53 2c 20 74 68 65 20 75 6e 64 65 72 6c 61 JTS, the underla
2d60: 79 69 6e 67 20 61 6c 67 6f 72 69 74 68 6d 73 20 ying algorithms
2d70: 61 72 65 20 65 78 61 63 74 6c 79 20 74 68 65 20 are exactly the
2d80: 73 61 6d 65 2e 3c 62 72 3e 0d 0a 53 6f 2c 20 72 same.<br>..So, r
2d90: 6f 75 67 68 6c 79 20 73 70 65 61 6b 69 6e 67 2c oughly speaking,
2da0: 20 61 6c 6c 20 47 46 4f 53 53 20 61 70 70 6c 69 all GFOSS appli
2db0: 63 61 74 69 6f 6e 73 20 28 62 6f 74 68 20 43 2c cations (both C,
2dc0: 20 43 2b 2b 20 61 6e 64 20 4a 61 76 61 29 20 61 C++ and Java) a
2dd0: 66 74 65 72 20 61 6c 6c 20 61 72 65 20 62 61 73 fter all are bas
2de0: 65 64 20 6f 6e 20 74 68 65 20 74 6f 70 20 6f 66 ed on the top of
2df0: 20 74 68 65 20 73 61 6d 65 20 62 61 73 65 2d 6c the same base-l
2e00: 65 76 65 6c 20 61 6c 67 6f 72 69 74 68 6d 73 2e evel algorithms.
2e10: 3c 62 72 3e 0d 0a 41 6e 64 20 6e 6f 74 20 61 74 <br>..And not at
2e20: 20 61 6c 6c 20 73 75 72 70 72 69 73 69 6e 67 6c all surprisingl
2e30: 79 20 61 6c 6c 20 6d 65 61 73 75 72 65 64 20 74 y all measured t
2e40: 69 6d 69 6e 67 73 20 61 72 65 20 71 75 69 74 65 imings are quite
2e50: 20 65 78 61 63 74 6c 79 20 74 68 65 20 73 61 6d exactly the sam
2e60: 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 57 69 74 e.</li>..<li>Wit
2e70: 68 20 74 68 65 20 72 65 6d 61 72 6b 61 62 6c 65 h the remarkable
2e80: 20 65 78 63 65 70 74 69 6f 6e 20 6f 66 20 47 52 exception of GR
2e90: 41 53 53 20 47 49 53 3b 20 74 68 69 73 20 6f 6e ASS GIS; this on
2ea0: 65 20 61 64 6f 70 74 73 20 61 6e 20 6f 72 69 67 e adopts an orig
2eb0: 69 6e 61 6c 20 61 70 70 72 6f 61 63 68 20 6f 66 inal approach of
2ec0: 20 69 74 73 20 6f 77 6e 2c 20 62 65 69 6e 67 20 its own, being
2ed0: 62 61 73 65 64 20 6f 6e 20 61 20 63 6f 6e 63 65 based on a conce
2ee0: 70 74 75 61 6c 6c 79 20 64 69 66 66 65 72 65 6e ptually differen
2ef0: 74 20 47 65 6f 6d 65 74 72 79 20 6d 6f 64 65 6c t Geometry model
2f00: 20 28 74 6f 70 6f 6c 6f 67 79 20 76 73 20 73 69 (topology vs si
2f10: 6d 70 6c 65 20 66 65 61 74 75 72 65 73 29 2e 0d mple features)..
2f20: 0a 41 6e 79 77 61 79 2c 20 69 6e 20 74 68 69 73 .Anyway, in this
2f30: 20 63 61 73 65 20 74 6f 6f 20 74 69 6d 69 6e 67 case too timing
2f40: 73 20 61 72 65 20 76 65 72 79 20 73 69 6d 69 6c s are very simil
2f50: 61 72 20 74 6f 20 74 68 65 20 6f 74 68 65 72 73 ar to the others
2f60: 2e 3c 62 72 3e 0d 0a 49 4d 48 4f 20 69 74 27 73 .<br>..IMHO it's
2f70: 20 61 20 67 6f 6f 64 20 64 65 6d 6f 6e 73 74 72 a good demonstr
2f80: 61 74 69 6f 6e 20 74 68 61 74 20 77 65 20 68 61 ation that we ha
2f90: 76 65 20 63 6f 6d 70 6c 65 73 73 69 76 65 6c 79 ve complessively
2fa0: 20 72 65 61 63 68 65 64 20 74 68 65 20 62 65 73 reached the bes
2fb0: 74 20 70 6f 73 73 69 62 6c 65 20 65 66 66 69 63 t possible effic
2fc0: 69 65 6e 63 79 20 66 6f 72 20 74 68 69 73 20 6b iency for this k
2fd0: 69 6e 64 20 6f 66 20 70 72 6f 62 6c 65 6d 73 2e ind of problems.
2fe0: 20 41 6e 64 20 74 68 61 74 20 6f 70 65 6e 6e 65 And that openne
2ff0: 73 73 20 63 6f 6d 62 69 6e 65 64 20 77 69 74 68 ss combined with
3000: 20 63 6f 6c 6c 61 62 6f 72 61 74 69 6f 6e 2f 63 collaboration/c
3010: 6f 6d 70 65 74 69 74 69 6f 6e 20 62 65 74 77 65 ompetition betwe
3020: 65 6e 20 6d 61 6e 79 20 64 69 66 66 65 72 65 6e en many differen
3030: 74 20 69 6e 64 65 70 65 6e 64 65 6e 74 20 70 72 t independent pr
3040: 6f 6a 65 63 74 73 20 6c 65 61 64 73 20 74 6f 20 ojects leads to
3050: 67 6f 6f 64 2c 20 72 6f 62 75 73 74 20 61 6e 64 good, robust and
3060: 20 65 66 66 69 63 69 65 6e 74 20 73 6f 66 74 77 efficient softw
3070: 61 72 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4d are.</li>..<li>M
3080: 61 6e 79 20 70 72 6f 70 72 69 65 74 61 72 79 20 any proprietary
3090: 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 73 20 implementations
30a0: 6c 6f 6f 6b 73 20 74 6f 20 62 65 20 65 6d 62 61 looks to be emba
30b0: 72 72 61 73 73 61 6e 67 6c 79 20 6c 65 73 73 20 rrassangly less
30c0: 65 66 66 69 63 69 65 6e 74 2e 0d 0a 41 20 73 61 efficient...A sa
30d0: 64 20 64 65 6d 6f 6e 73 74 72 61 74 69 6f 6e 20 d demonstration
30e0: 74 68 61 74 20 61 20 64 65 76 65 6c 6f 70 6d 65 that a developme
30f0: 6e 74 20 70 6f 6c 69 63 79 20 62 61 73 65 64 20 nt policy based
3100: 6f 6e 20 63 6c 6f 73 65 64 6e 65 73 73 20 61 6e on closedness an
3110: 64 20 73 65 63 72 65 63 79 20 76 65 72 79 20 64 d secrecy very d
3120: 69 66 66 69 63 75 6c 74 6c 79 20 70 61 79 73 20 ifficultly pays
3130: 6f 6e 20 6c 6f 6e 67 20 74 65 72 6d 20 70 65 72 on long term per
3140: 69 6f 64 73 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 6c 69 iods.</li>..</li
3150: 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 62 72 3e 3c 68 >..</ul>..<br><h
3160: 72 3e 0d 0a 42 61 63 6b 20 74 6f 20 3c 61 20 68 r>..Back to <a h
3170: 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 ref="https://www
3180: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 .gaia-gis.it/fos
3190: 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 sil/libspatialit
31a0: 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 73 77 69 74 e/wiki?name=swit
31b0: 63 68 69 6e 67 2d 74 6f 2d 34 2e 30 23 76 69 72 ching-to-4.0#vir
31c0: 74 75 61 6c 6f 67 72 22 3e 6d 61 69 6e 20 70 61 tualogr">main pa
31d0: 67 65 3c 2f 61 3e 0a 5a 20 38 33 63 37 66 37 38 ge</a>.Z 83c7f78
31e0: 39 32 32 35 66 32 62 61 65 62 35 65 66 65 64 36 9225f2baeb5efed6
31f0: 33 30 39 30 35 64 32 33 66 0a 30905d23f.