Wiki page
[liblwgeom-4.0] by
sandro
2014-08-27 13:00:34.
0000: 44 20 32 30 31 34 2d 30 38 2d 32 37 54 31 33 3a D 2014-08-27T13:
0010: 30 30 3a 33 34 2e 39 34 39 0a 4c 20 6c 69 62 6c 00:34.949.L libl
0020: 77 67 65 6f 6d 2d 34 2e 30 0a 50 20 39 37 34 62 wgeom-4.0.P 974b
0030: 30 32 65 62 34 64 38 36 37 30 35 61 63 32 32 37 02eb4d86705ac227
0040: 66 38 31 61 30 64 30 32 37 34 33 30 39 66 62 33 f81a0d0274309fb3
0050: 64 66 39 35 0a 55 20 73 61 6e 64 72 6f 0a 57 20 df95.U sandro.W
0060: 31 34 33 34 36 0a 3c 68 32 3e 53 51 4c 20 66 75 14346.<h2>SQL fu
0070: 6e 63 74 69 6f 6e 73 20 62 61 73 65 64 20 6f 6e nctions based on
0080: 20 6c 69 62 6c 77 67 65 6f 6d 20 73 75 70 70 6f liblwgeom suppo
0090: 72 74 20 69 6e 20 76 65 72 73 69 6f 6e 20 34 2e rt in version 4.
00a0: 30 2e 30 3c 2f 68 32 3e 0d 0a 3c 61 20 68 72 65 0.0</h2>..<a hre
00b0: 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 f="https://www.g
00c0: 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 aia-gis.it/fossi
00d0: 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 65 2f l/libspatialite/
00e0: 77 69 6b 69 3f 6e 61 6d 65 3d 34 2e 32 2e 30 2d wiki?name=4.2.0-
00f0: 64 6f 63 22 3e 62 61 63 6b 3c 2f 61 3e 0d 0a 3c doc">back</a>..<
0100: 68 33 3e 4d 61 6b 69 6e 67 20 69 6e 76 61 6c 69 h3>Making invali
0110: 64 20 47 65 6f 6d 65 74 72 69 65 73 20 74 6f 20 d Geometries to
0120: 62 65 63 6f 6d 65 20 70 65 72 66 65 63 74 6c 79 become perfectly
0130: 20 76 61 6c 69 64 20 6f 6e 65 73 3c 2f 68 33 3e valid ones</h3>
0140: 0d 0a 41 73 20 79 6f 75 20 61 6c 72 65 61 64 79 ..As you already
0150: 20 73 75 72 65 6c 79 20 6b 6e 6f 77 2c 20 6e 6f surely know, no
0160: 74 20 61 6c 6c 20 67 65 6f 6d 65 74 72 69 65 73 t all geometries
0170: 20 61 72 65 20 76 61 6c 69 64 20 6f 6e 65 73 3a are valid ones:
0180: 20 6d 6f 73 74 20 6e 6f 74 61 62 6c 79 20 69 6e most notably in
0190: 20 74 68 65 20 73 70 65 63 69 66 69 63 20 63 61 the specific ca
01a0: 73 65 20 6f 66 20 50 6f 6c 79 67 6f 6e 61 6c 20 se of Polygonal
01b0: 67 65 6f 6d 65 74 72 69 65 73 20 74 68 65 72 65 geometries there
01c0: 20 61 72 65 20 6d 61 6e 79 20 66 6f 72 6d 61 6c are many formal
01d0: 20 72 75 6c 65 73 20 74 6f 20 62 65 20 63 61 72 rules to be car
01e0: 65 66 75 6c 6c 79 20 72 65 73 70 65 63 74 65 64 efully respected
01f0: 2e 0d 0a 49 6e 66 72 69 6e 67 69 6e 67 20 6f 6e ...Infringing on
0200: 65 20 6f 66 20 73 75 63 68 20 72 75 6c 65 73 20 e of such rules
0210: 64 69 72 65 63 74 6c 79 20 6c 65 61 64 73 20 74 directly leads t
0220: 6f 20 73 6f 6d 65 20 69 6e 76 61 6c 69 64 20 47 o some invalid G
0230: 65 6f 6d 65 74 72 79 3a 20 61 6e 64 20 61 6e 20 eometry: and an
0240: 69 6e 76 61 6c 69 64 20 47 65 6f 6d 65 74 72 79 invalid Geometry
0250: 20 63 6f 75 6c 64 20 63 61 75 73 65 20 69 6e 76 could cause inv
0260: 61 6c 69 64 20 72 65 73 75 6c 74 73 20 74 6f 20 alid results to
0270: 62 65 20 72 65 74 75 72 6e 65 64 2c 20 6f 72 20 be returned, or
0280: 63 6f 75 6c 64 20 65 76 65 6e 74 75 61 6c 6c 79 could eventually
0290: 20 63 61 75 73 65 20 73 6f 6d 65 20 75 6e 65 78 cause some unex
02a0: 70 65 63 74 65 64 20 6e 61 73 74 79 20 63 72 61 pected nasty cra
02b0: 73 68 20 69 6e 20 74 68 65 20 77 6f 72 73 74 20 sh in the worst
02c0: 63 61 73 65 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 47 case.<br><br>..G
02d0: 45 4f 53 20 28 61 6e 64 20 74 68 75 73 20 53 70 EOS (and thus Sp
02e0: 61 74 69 61 4c 69 74 65 29 20 61 6c 72 65 61 64 atiaLite) alread
02f0: 79 20 73 75 70 70 6f 72 74 73 20 74 68 65 20 3c y supports the <
0300: 62 3e 53 54 5f 49 73 56 61 6c 69 64 28 29 3c 2f b>ST_IsValid()</
0310: 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 3b b> SQL function;
0320: 20 62 79 20 69 6e 76 6f 6b 69 6e 67 20 74 68 69 by invoking thi
0330: 73 20 66 75 6e 63 74 69 6f 6e 20 79 6f 75 20 63 s function you c
0340: 61 6e 20 65 61 73 69 6c 79 20 69 64 65 6e 74 69 an easily identi
0350: 66 79 20 61 6c 6c 20 6f 66 66 65 6e 64 69 6e 67 fy all offending
0360: 20 47 65 6f 6d 65 74 72 69 65 73 20 65 76 65 6e Geometries even
0370: 74 75 61 6c 6c 79 20 63 6f 6e 74 61 69 6e 65 64 tually contained
0380: 20 77 69 74 68 69 6e 20 79 6f 75 72 20 74 61 62 within your tab
0390: 6c 65 73 3b 20 61 6e 79 77 61 79 20 79 6f 75 20 les; anyway you
03a0: 63 61 6e 6e 6f 74 20 61 74 74 65 6d 70 74 20 74 cannot attempt t
03b0: 6f 20 3c 69 3e 73 61 6e 69 74 69 7a 65 3c 2f 69 o <i>sanitize</i
03c0: 3e 20 74 68 65 6d 2e 3c 62 72 3e 0d 0a 53 70 61 > them.<br>..Spa
03d0: 74 69 61 4c 69 74 65 20 61 6c 72 65 61 64 79 20 tiaLite already
03e0: 73 75 70 70 6f 72 74 65 64 20 61 20 3c 62 3e 53 supported a <b>S
03f0: 54 5f 53 61 6e 69 74 69 7a 65 47 65 6f 6d 65 74 T_SanitizeGeomet
0400: 72 79 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e ry()</b> SQL fun
0410: 63 74 69 6f 6e 3b 20 62 75 74 20 74 68 69 73 20 ction; but this
0420: 77 61 73 20 73 69 6d 70 6c 79 20 63 61 70 61 62 was simply capab
0430: 6c 65 20 74 6f 20 65 66 66 65 63 74 69 76 65 6c le to effectivel
0440: 79 20 72 65 73 6f 6c 76 65 20 6a 75 73 74 20 66 y resolve just f
0450: 65 77 20 69 6e 76 61 6c 69 64 69 74 79 20 63 61 ew invalidity ca
0460: 75 73 65 73 2c 20 61 6e 64 20 77 61 73 6e 27 74 uses, and wasn't
0470: 20 61 74 20 61 6c 6c 20 61 20 67 65 6e 65 72 61 at all a genera
0480: 6c 20 73 6f 6c 75 74 69 6f 6e 20 66 6f 72 20 74 l solution for t
0490: 68 69 73 20 70 72 6f 62 6c 65 6d 2e 3c 62 72 3e his problem.<br>
04a0: 3c 62 72 3e 0d 0a 4e 6f 77 2c 20 74 68 61 6e 6b <br>..Now, thank
04b0: 73 20 74 6f 20 3c 69 3e 6c 69 62 6c 77 67 65 6f s to <i>liblwgeo
04c0: 6d 3c 2f 69 3e 2c 20 53 70 61 74 69 61 4c 69 74 m</i>, SpatiaLit
04d0: 65 20 63 61 6e 20 73 75 70 70 6f 72 74 20 74 68 e can support th
04e0: 65 20 73 61 6d 65 20 69 64 65 6e 74 69 63 61 6c e same identical
04f0: 20 3c 62 3e 53 54 5f 4d 61 6b 65 56 61 6c 69 64 <b>ST_MakeValid
0500: 28 29 3c 2f 62 3e 20 61 6c 72 65 61 64 79 20 73 ()</b> already s
0510: 75 70 70 6f 72 74 65 64 20 62 79 20 50 6f 73 74 upported by Post
0520: 47 49 53 3b 20 66 65 77 20 73 6d 61 6c 6c 20 69 GIS; few small i
0530: 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 64 65 mplementation de
0540: 74 61 69 6c 73 20 64 69 66 66 65 72 20 28 64 75 tails differ (du
0550: 65 20 74 6f 20 74 68 65 20 68 75 67 65 20 61 72 e to the huge ar
0560: 63 68 69 74 65 63 74 75 72 61 6c 20 64 69 66 66 chitectural diff
0570: 65 72 65 6e 63 65 73 20 64 69 73 74 69 6e 67 75 erences distingu
0580: 69 73 68 69 6e 67 20 50 6f 73 74 47 49 53 20 61 ishing PostGIS a
0590: 6e 64 20 53 70 61 74 69 61 4c 69 74 65 29 2c 20 nd SpatiaLite),
05a0: 62 75 74 20 74 68 65 20 75 6e 64 65 72 6c 79 69 but the underlyi
05b0: 6e 67 20 63 6f 64 65 20 69 73 20 65 78 61 63 74 ng code is exact
05c0: 6c 79 20 6f 6e 65 20 61 6e 64 20 74 68 65 20 73 ly one and the s
05d0: 61 6d 65 20 66 6f 72 20 62 6f 74 68 2e 0d 0a 3c ame for both...<
05e0: 68 34 3e 61 20 66 69 72 73 74 20 62 61 73 69 63 h4>a first basic
05f0: 20 65 78 61 6d 70 6c 65 3c 2f 68 34 3e 0d 0a 57 example</h4>..W
0600: 65 27 6c 6c 20 73 74 61 72 74 20 6c 6f 61 64 69 e'll start loadi
0610: 6e 67 20 74 68 65 20 4c 6f 63 61 6c 20 43 6f 75 ng the Local Cou
0620: 6e 63 69 6c 73 20 61 64 6d 69 6e 69 73 74 72 61 ncils administra
0630: 74 69 76 65 20 62 6f 75 6e 64 61 72 69 65 73 20 tive boundaries
0640: 73 75 70 70 6c 69 65 64 20 62 79 20 49 53 54 41 supplied by ISTA
0650: 54 20 28 74 68 65 20 49 74 61 6c 69 61 6e 20 4e T (the Italian N
0660: 61 74 69 6f 6e 61 6c 20 53 74 61 74 69 63 73 20 ational Statics
0670: 41 67 65 6e 63 79 29 3a 20 74 68 69 73 20 64 61 Agency): this da
0680: 74 61 73 65 74 20 69 73 20 66 72 65 65 6c 79 20 taset is freely
0690: 61 76 61 69 6c 61 62 6c 65 20 66 6f 72 20 3c 61 available for <a
06a0: 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 href="http://ww
06b0: 77 2e 69 73 74 61 74 2e 69 74 2f 75 70 6c 6f 61 w.istat.it/uploa
06c0: 64 73 2f 63 6f 6d 32 30 31 31 2e 7a 69 70 22 3e ds/com2011.zip">
06d0: 64 6f 77 6e 6c 6f 61 64 3c 2f 61 3e 20 75 6e 64 download</a> und
06e0: 65 72 20 61 20 43 43 2d 42 59 20 6c 69 63 65 6e er a CC-BY licen
06f0: 73 65 2e 0d 0a 4a 75 73 74 20 61 20 71 75 69 63 se...Just a quic
0700: 6b 20 63 68 65 63 6b 2c 20 61 6e 64 20 77 65 27 k check, and we'
0710: 6c 6c 20 73 6f 6f 6e 20 64 69 73 63 6f 76 65 72 ll soon discover
0720: 20 74 68 61 74 20 74 68 69 73 20 64 61 74 61 73 that this datas
0730: 65 74 20 61 63 74 75 61 6c 6c 79 20 63 6f 6e 74 et actually cont
0740: 61 69 6e 73 20 73 65 76 65 72 61 6c 20 6d 61 6c ains several mal
0750: 66 6f 72 6d 65 64 20 50 6f 6c 79 67 6f 6e 73 3a formed Polygons:
0760: 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 ..<table bgcolor
0770: 3d 22 23 65 30 65 30 65 30 22 20 63 65 6c 6c 73 ="#e0e0e0" cells
0780: 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 pacing="4" cellp
0790: 61 64 64 69 6e 67 3d 22 38 22 3e 0d 0a 3c 74 72 adding="8">..<tr
07a0: 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 ><td>..<b>SELECT
07b0: 20 43 6f 75 6e 74 28 2a 29 3c 62 72 3e 0d 0a 46 Count(*)<br>..F
07c0: 52 4f 4d 20 63 6f 6d 32 30 31 31 3c 62 72 3e 0d ROM com2011<br>.
07d0: 0a 57 48 45 52 45 20 53 54 5f 49 73 56 61 6c 69 .WHERE ST_IsVali
07e0: 64 28 67 65 6f 6d 65 74 72 79 29 20 3d 20 30 3b d(geometry) = 0;
07f0: 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a 31 39 0d 0a </b>..<hr>..19..
0800: 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 </td></tr>..</ta
0810: 62 6c 65 3e 3c 62 72 3e 0d 0a 52 65 63 6f 76 65 ble><br>..Recove
0820: 72 69 6e 67 20 61 6c 6c 20 6d 61 6c 66 6f 72 6d ring all malform
0830: 65 64 20 47 65 6f 6d 65 74 72 69 65 73 20 69 73 ed Geometries is
0840: 20 6e 6f 77 20 61 62 73 6f 6c 75 74 65 6c 79 20 now absolutely
0850: 73 69 6d 70 6c 65 20 61 6e 64 20 65 61 73 79 3a simple and easy:
0860: 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 ..<table bgcolor
0870: 3d 22 23 65 30 65 30 65 30 22 20 63 65 6c 6c 73 ="#e0e0e0" cells
0880: 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 pacing="4" cellp
0890: 61 64 64 69 6e 67 3d 22 38 22 3e 3c 74 72 3e 3c adding="8"><tr><
08a0: 74 64 3e 0d 0a 3c 62 3e 55 50 44 41 54 45 20 63 td>..<b>UPDATE c
08b0: 6f 6d 32 30 31 31 20 53 45 54 20 67 65 6f 6d 65 om2011 SET geome
08c0: 74 72 79 20 3d 20 53 54 5f 4d 61 6b 65 56 61 6c try = ST_MakeVal
08d0: 69 64 28 67 65 6f 6d 65 74 72 79 29 3c 62 72 3e id(geometry)<br>
08e0: 0d 0a 57 48 45 52 45 20 53 54 5f 49 73 56 61 6c ..WHERE ST_IsVal
08f0: 69 64 28 67 65 6f 6d 65 74 72 79 29 20 3d 20 30 id(geometry) = 0
0900: 3b 3c 2f 62 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 ;</b>..</td></tr
0910: 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e >..<tr><td>..<b>
0920: 53 45 4c 45 43 54 20 43 6f 75 6e 74 28 2a 29 3c SELECT Count(*)<
0930: 62 72 3e 0d 0a 46 52 4f 4d 20 63 6f 6d 32 30 31 br>..FROM com201
0940: 31 3c 62 72 3e 0d 0a 57 48 45 52 45 20 53 54 5f 1<br>..WHERE ST_
0950: 49 73 56 61 6c 69 64 28 67 65 6f 6d 65 74 72 79 IsValid(geometry
0960: 29 20 3d 20 30 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e ) = 0;</b>..<hr>
0970: 0d 0a 30 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d ..0..</td></tr>.
0980: 0a 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c .</table><br>..<
0990: 74 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 table border="1"
09a0: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
09b0: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 cellpadding="4"
09c0: 3e 0d 0a 3c 74 72 3e 3c 74 68 20 63 6f 6c 73 70 >..<tr><th colsp
09d0: 61 6e 3d 22 32 22 3e 57 68 79 20 74 68 65 20 42 an="2">Why the B
09e0: 72 6f 6e 74 65 20 4c 6f 63 61 6c 20 43 6f 75 6e ronte Local Coun
09f0: 63 69 6c 20 62 6f 75 6e 64 61 72 79 20 77 61 73 cil boundary was
0a00: 20 6d 61 6c 66 6f 72 6d 65 64 20 3f 3c 62 72 3e malformed ?<br>
0a10: 0d 0a 61 20 71 75 69 63 6b 20 61 6e 61 6c 79 73 ..a quick analys
0a20: 69 73 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 is</th></tr>..<t
0a30: 72 3e 3c 74 68 3e 6d 61 6c 66 6f 72 6d 65 64 20 r><th>malformed
0a40: 2f 20 69 6e 76 61 6c 69 64 3c 2f 74 68 3e 3c 74 / invalid</th><t
0a50: 68 3e 76 61 6c 69 64 3c 2f 74 68 3e 3c 2f 74 72 h>valid</th></tr
0a60: 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 69 6d >..<tr><td>..<im
0a70: 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 g src="http://ww
0a80: 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 w.gaia-gis.it/ga
0a90: 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 ia-sins/write-vi
0aa0: 65 77 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d 69 ew-pics/bronte-i
0ab0: 6e 76 61 6c 69 64 2e 70 6e 67 22 20 61 6c 74 3d nvalid.png" alt=
0ac0: 22 62 72 6f 6e 74 65 20 69 6e 76 61 6c 69 64 22 "bronte invalid"
0ad0: 3e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 >..</td><td>..<i
0ae0: 6d 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 mg src="http://w
0af0: 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 ww.gaia-gis.it/g
0b00: 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 aia-sins/write-v
0b10: 69 65 77 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d iew-pics/bronte-
0b20: 76 61 6c 69 64 2e 70 6e 67 22 20 61 6c 74 3d 22 valid.png" alt="
0b30: 62 72 6f 6e 74 65 20 76 61 6c 69 64 22 3e 0d 0a bronte valid">..
0b40: 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </td></tr>..<tr>
0b50: 3c 74 64 20 63 6f 6c 73 70 61 6e 3d 22 32 22 3e <td colspan="2">
0b60: 0d 0a 41 73 20 79 6f 75 20 63 61 6e 20 65 61 73 ..As you can eas
0b70: 69 6c 79 20 6e 6f 74 69 63 65 2c 20 74 68 65 20 ily notice, the
0b80: 3c 69 3e 69 6e 76 61 6c 69 64 3c 2f 69 3e 20 70 <i>invalid</i> p
0b90: 6f 6c 79 67 6f 6e 20 77 61 73 20 73 69 6d 70 6c olygon was simpl
0ba0: 79 20 72 65 70 72 65 73 65 6e 74 20 62 79 20 74 y represent by t
0bb0: 68 65 20 3c 69 3e 65 78 74 65 72 69 6f 72 20 72 he <i>exterior r
0bc0: 69 6e 67 3c 2f 69 3e 3a 20 62 75 74 20 74 68 65 ing</i>: but the
0bd0: 72 65 20 69 73 20 61 20 68 75 67 65 20 69 6e 74 re is a huge int
0be0: 65 72 6e 61 6c 20 68 6f 6c 65 20 69 6e 20 74 68 ernal hole in th
0bf0: 69 73 20 50 6f 6c 79 67 6f 6e 2e 0d 0a 54 68 69 is Polygon...Thi
0c00: 73 20 6f 64 64 20 63 6f 6e 64 69 74 69 6f 6e 20 s odd condition
0c10: 69 73 20 72 65 70 75 74 65 64 20 70 65 72 66 65 is reputed perfe
0c20: 63 74 6c 79 20 76 61 6c 69 64 20 62 79 20 73 6f ctly valid by so
0c30: 6d 65 20 6d 61 69 6e 73 74 72 65 61 6d 20 70 72 me mainstream pr
0c40: 6f 70 72 69 65 74 61 72 79 20 73 6f 66 74 77 61 oprietary softwa
0c50: 72 65 3b 20 61 6e 79 77 61 79 2c 20 69 73 20 61 re; anyway, is a
0c60: 63 74 75 61 6c 6c 79 20 3c 69 3e 69 6e 76 61 6c ctually <i>inval
0c70: 69 64 3c 2f 69 3e 20 61 63 63 6f 72 64 69 6e 67 id</i> according
0c80: 6c 79 20 74 6f 20 73 74 61 6e 64 61 72 64 20 72 ly to standard r
0c90: 75 6c 65 73 2e 3c 62 72 3e 0d 0a 53 6f 20 74 68 ules.<br>..So th
0ca0: 65 20 63 6f 72 72 65 63 74 20 72 65 70 72 65 73 e correct repres
0cb0: 65 6e 74 61 74 69 6f 6e 20 66 6f 72 20 74 68 69 entation for thi
0cc0: 73 20 50 6f 6c 79 67 6f 6e 20 72 65 71 75 69 72 s Polygon requir
0cd0: 65 73 20 61 6e 20 3c 69 3e 65 78 74 65 72 69 6f es an <i>exterio
0ce0: 72 20 72 69 6e 67 3c 2f 69 3e 20 61 6e 64 20 61 r ring</i> and a
0cf0: 20 73 65 70 61 72 61 74 65 20 3c 69 3e 69 6e 74 separate <i>int
0d00: 65 72 69 6f 72 20 72 69 6e 67 3c 2f 69 3e 3b 20 erior ring</i>;
0d10: 53 54 5f 4d 61 6b 65 56 61 6c 69 64 28 29 20 64 ST_MakeValid() d
0d20: 6f 65 73 20 74 68 65 20 6d 61 67 69 63 2c 20 74 oes the magic, t
0d30: 68 75 73 20 72 65 63 6f 76 65 72 69 6e 67 20 61 hus recovering a
0d40: 20 66 75 6c 6c 20 76 61 6c 69 64 20 50 6f 6c 79 full valid Poly
0d50: 67 6f 6e 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e gon...</td></tr>
0d60: 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 68 34 3e ..</table>..<h4>
0d70: 61 20 73 65 63 6f 6e 64 20 6d 6f 72 65 20 65 6c a second more el
0d80: 61 62 6f 72 61 74 65 20 65 78 61 6d 70 6c 65 3c aborate example<
0d90: 2f 68 34 3e 0d 0a 54 68 69 73 20 74 69 6d 65 20 /h4>..This time
0da0: 77 65 27 6c 6c 20 70 75 72 70 6f 73 65 6c 79 20 we'll purposely
0db0: 63 72 65 61 74 65 20 61 20 73 65 76 65 72 65 6c create a severel
0dc0: 79 20 6d 61 6c 66 6f 72 6d 65 64 20 50 6f 6c 79 y malformed Poly
0dd0: 67 6f 6e 3a 0d 0a 3c 74 61 62 6c 65 20 62 67 63 gon:..<table bgc
0de0: 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 olor="#e0e0e0" c
0df0: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
0e00: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e 0d ellpadding="8">.
0e10: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 .<tr><td>..<b>SE
0e20: 4c 45 43 54 20 67 2c 20 53 54 5f 4d 61 6b 65 56 LECT g, ST_MakeV
0e30: 61 6c 69 64 28 67 29 2c 20 53 54 5f 4d 61 6b 65 alid(g), ST_Make
0e40: 56 61 6c 69 64 44 69 73 63 61 72 64 65 64 28 67 ValidDiscarded(g
0e50: 29 3c 62 72 3e 0d 0a 46 52 4f 4d 20 28 3c 62 72 )<br>..FROM (<br
0e60: 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 47 65 6f >..SELECT ST_Geo
0e70: 6d 46 72 6f 6d 54 65 78 74 28 27 50 4f 4c 59 47 mFromText('POLYG
0e80: 4f 4e 28 28 30 20 30 2c 20 30 20 31 30 2c 20 31 ON((0 0, 0 10, 1
0e90: 31 20 31 30 2c 20 31 30 20 31 30 2c 20 31 30 20 1 10, 10 10, 10
0ea0: 31 2c 20 35 20 31 2c 20 35 20 39 2c 20 35 20 31 1, 5 1, 5 9, 5 1
0eb0: 2c 20 30 20 31 2c 20 30 20 30 29 29 27 29 20 41 , 0 1, 0 0))') A
0ec0: 53 20 67 3c 62 72 3e 0d 0a 29 3b 3c 2f 62 3e 0d S g<br>..);</b>.
0ed0: 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 .</td></tr>..</t
0ee0: 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c able><br>..<tabl
0ef0: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 e cellspacing="4
0f00: 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 " cellpadding="4
0f10: 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 ">..<tr><td>..Th
0f20: 69 73 20 66 69 67 75 72 65 20 72 65 70 72 65 73 is figure repres
0f30: 65 6e 74 73 20 74 68 65 20 3c 69 3e 69 6e 76 61 ents the <i>inva
0f40: 6c 69 64 3c 2f 69 3e 20 50 6f 6c 79 67 6f 6e 20 lid</i> Polygon
0f50: 72 65 74 75 72 6e 65 64 20 62 79 20 3c 62 3e 53 returned by <b>S
0f60: 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 29 T_GeomFromText()
0f70: 3c 2f 62 3e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 54 </b>.<br><br>..T
0f80: 68 65 72 65 20 61 72 65 20 74 68 72 65 65 20 3c here are three <
0f90: 69 3e 73 70 69 6b 65 73 3c 2f 69 3e 20 69 6e 20 i>spikes</i> in
0fa0: 74 68 65 20 3c 69 3e 65 78 74 65 72 69 6f 72 20 the <i>exterior
0fb0: 72 69 6e 67 3c 2f 69 3e 2c 20 61 6e 64 20 74 68 ring</i>, and th
0fc0: 69 73 20 6f 6e 65 20 73 75 72 65 6c 79 20 69 73 is one surely is
0fd0: 20 61 20 73 65 76 65 72 65 20 69 6e 76 61 6c 69 a severe invali
0fe0: 64 69 74 79 20 63 61 75 73 65 2e 0d 0a 3c 2f 74 dity cause...</t
0ff0: 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 d><td>..<img src
1000: 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 ="http://www.gai
1010: 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 a-gis.it/gaia-si
1020: 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 ns/write-view-pi
1030: 63 73 2f 73 70 69 6b 65 2d 69 6e 76 61 6c 69 64 cs/spike-invalid
1040: 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 69 6b 65 .png" alt="spike
1050: 20 69 6e 76 61 6c 69 64 22 3e 0d 0a 3c 2f 74 64 invalid">..</td
1060: 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e ></tr>..<tr><td>
1070: 0d 0a 54 68 69 73 20 66 69 67 75 72 65 20 72 65 ..This figure re
1080: 70 72 65 73 65 6e 74 73 20 74 68 65 20 3c 69 3e presents the <i>
1090: 76 61 6c 69 64 3c 2f 69 3e 20 50 6f 6c 79 67 6f valid</i> Polygo
10a0: 6e 20 72 65 74 75 72 6e 65 64 20 62 79 20 3c 62 n returned by <b
10b0: 3e 53 54 5f 4d 61 6b 65 56 61 6c 69 64 28 29 3c >ST_MakeValid()<
10c0: 2f 62 3e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 4e 6f /b>.<br><br>..No
10d0: 77 20 77 65 20 68 61 76 65 20 61 20 6e 69 63 65 w we have a nice
10e0: 20 72 65 67 75 6c 61 72 20 72 65 63 74 61 6e 67 regular rectang
10f0: 6c 65 2c 20 61 6c 6c 20 3c 69 3e 73 70 69 6b 65 le, all <i>spike
1100: 73 3c 2f 69 3e 20 68 61 76 65 20 62 65 65 6e 20 s</i> have been
1110: 72 65 6d 6f 76 65 64 2e 0d 0a 3c 2f 74 64 3e 3c removed...</td><
1120: 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 td>..<img src="h
1130: 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 ttp://www.gaia-g
1140: 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f is.it/gaia-sins/
1150: 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f write-view-pics/
1160: 73 70 69 6b 65 2d 76 61 6c 69 64 2e 70 6e 67 22 spike-valid.png"
1170: 20 61 6c 74 3d 22 73 70 69 6b 65 20 76 61 6c 69 alt="spike vali
1180: 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d d">..</td></tr>.
1190: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 41 6e 79 77 61 .<tr><td>..Anywa
11a0: 79 20 74 68 65 20 72 65 6d 6f 76 65 64 20 3c 69 y the removed <i
11b0: 3e 73 70 69 6b 65 73 3c 2f 69 3e 20 61 72 65 6e >spikes</i> aren
11c0: 27 74 20 73 69 6d 70 6c 79 20 76 61 6e 69 73 68 't simply vanish
11d0: 65 64 20 69 6e 74 6f 20 6e 6f 74 68 69 6e 67 2e ed into nothing.
11e0: 0d 0a 59 6f 75 20 63 6f 75 6c 64 20 65 76 65 6e ..You could even
11f0: 74 75 61 6c 6c 79 20 72 65 74 72 69 65 76 65 20 tually retrieve
1200: 28 61 6e 64 20 6d 61 79 20 62 65 2c 20 73 61 76 (and may be, sav
1210: 69 6e 67 20 73 6f 6d 65 77 68 65 72 65 20 66 6f ing somewhere fo
1220: 72 20 66 75 72 74 68 65 72 20 70 72 6f 63 65 73 r further proces
1230: 73 69 6e 67 20 2f 20 65 64 69 74 69 6e 67 29 20 sing / editing)
1240: 61 6c 6c 20 6f 66 66 65 6e 64 69 6e 67 20 65 6c all offending el
1250: 65 6d 65 6e 74 73 20 62 65 69 6e 67 20 64 69 73 ements being dis
1260: 63 61 72 64 65 64 20 64 75 72 69 6e 67 20 74 68 carded during th
1270: 65 20 76 61 6c 69 64 61 74 69 6f 6e 20 70 72 6f e validation pro
1280: 63 65 73 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 59 cess.<br><br>..Y
1290: 6f 75 20 73 69 6d 70 6c 79 20 68 61 76 65 20 74 ou simply have t
12a0: 6f 20 69 6e 76 6f 6b 65 20 3c 62 3e 53 54 5f 4d o invoke <b>ST_M
12b0: 61 6b 65 56 61 6c 69 64 44 69 73 63 61 72 64 65 akeValidDiscarde
12c0: 64 28 29 3c 2f 62 3e 3c 62 72 3e 3c 62 72 3e 0d d()</b><br><br>.
12d0: 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c .<u>Please note<
12e0: 2f 75 3e 3a 20 74 68 69 73 20 69 73 20 73 74 72 /u>: this is str
12f0: 6f 6e 67 6c 79 20 64 69 66 66 65 72 65 6e 74 20 ongly different
1300: 66 72 6f 6d 20 74 68 65 20 50 6f 73 74 47 49 53 from the PostGIS
1310: 20 6f 77 6e 20 69 6d 70 6c 65 6d 65 6e 74 61 74 own implementat
1320: 69 6f 6e 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d ion...</td><td>.
1330: 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 70 3a .<img src="http:
1340: 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 //www.gaia-gis.i
1350: 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 t/gaia-sins/writ
1360: 65 2d 76 69 65 77 2d 70 69 63 73 2f 73 70 69 6b e-view-pics/spik
1370: 65 2d 64 69 73 63 61 72 64 65 64 2e 70 6e 67 22 e-discarded.png"
1380: 20 61 6c 74 3d 22 73 70 69 6b 65 20 64 69 73 63 alt="spike disc
1390: 61 72 64 65 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f arded">..</td></
13a0: 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c tr>..</table>..<
13b0: 62 72 3e 3c 68 72 3e 0d 0a 3c 68 33 3e 53 70 6c br><hr>..<h3>Spl
13c0: 69 74 74 69 6e 67 20 67 65 6f 6d 65 74 72 69 65 itting geometrie
13d0: 73 20 69 6e 20 74 77 6f 20 68 61 6c 76 65 73 3c s in two halves<
13e0: 2f 68 33 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f /h3>..The <b>ST_
13f0: 53 70 6c 69 74 28 29 3c 2f 62 3e 20 53 70 61 74 Split()</b> Spat
1400: 69 61 6c 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e ial SQL function
1410: 20 69 73 20 69 6e 74 65 6e 64 65 64 20 74 6f 20 is intended to
1420: 3c 69 3e 63 75 74 3c 2f 69 3e 20 61 20 47 65 6f <i>cut</i> a Geo
1430: 6d 65 74 72 79 2e 3c 62 72 3e 0d 0a 54 68 69 73 metry.<br>..This
1440: 20 66 75 6e 63 74 69 6f 6e 20 61 6c 77 61 79 73 function always
1450: 20 72 65 71 75 69 72 65 73 20 74 6f 20 70 61 73 requires to pas
1460: 73 20 74 77 6f 20 64 69 66 66 65 72 65 6e 74 20 s two different
1470: 47 65 6f 6d 65 74 72 69 65 73 3a 3c 75 6c 3e 0d Geometries:<ul>.
1480: 0a 3c 6c 69 3e 74 68 65 20 66 69 72 73 74 20 47 .<li>the first G
1490: 65 6f 6d 65 74 72 79 20 69 73 20 61 73 73 75 6d eometry is assum
14a0: 65 64 20 74 6f 20 72 65 70 72 65 73 65 6e 74 20 ed to represent
14b0: 74 68 65 20 3c 62 3e 69 6e 70 75 74 3c 2f 62 3e the <b>input</b>
14c0: 20 61 6b 61 20 3c 62 3e 74 61 72 67 65 74 3c 2f aka <b>target</
14d0: 62 3e 20 74 6f 20 62 65 20 73 70 6c 69 74 2e 3c b> to be split.<
14e0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20 73 65 /li>..<li>the se
14f0: 63 6f 6e 64 20 47 65 6f 6d 65 74 72 79 20 69 73 cond Geometry is
1500: 20 61 73 73 75 6d 65 64 20 74 6f 20 72 65 70 72 assumed to repr
1510: 65 73 65 6e 74 20 74 68 65 20 3c 62 3e 62 6c 61 esent the <b>bla
1520: 64 65 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 2f de</b>.</li>..</
1530: 75 6c 3e 0d 0a 4f 6e 6c 79 20 74 68 65 20 66 6f ul>..Only the fo
1540: 6c 6c 6f 77 69 6e 67 20 63 6f 6e 66 69 67 75 72 llowing configur
1550: 61 74 69 6f 6e 73 20 61 72 65 20 61 73 73 75 6d ations are assum
1560: 65 64 20 74 6f 20 62 65 20 76 61 6c 69 64 3a 3c ed to be valid:<
1570: 75 6c 3e 0d 0a 3c 6c 69 3e 4c 69 6e 65 73 74 72 ul>..<li>Linestr
1580: 69 6e 67 20 74 61 72 67 65 74 20 2f 20 50 6f 69 ing target / Poi
1590: 6e 74 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d 0a nt blade.</li>..
15a0: 3c 6c 69 3e 4d 75 6c 74 69 4c 69 6e 65 73 74 72 <li>MultiLinestr
15b0: 69 6e 67 20 74 61 72 67 65 74 20 2f 20 50 6f 69 ing target / Poi
15c0: 6e 74 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d 0a nt blade.</li>..
15d0: 3c 6c 69 3e 47 65 6f 6d 65 74 72 79 43 6f 6c 6c <li>GeometryColl
15e0: 65 63 74 69 6f 6e 20 28 63 6f 6e 74 61 69 6e 69 ection (containi
15f0: 6e 67 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 ng at least one
1600: 4c 69 6e 65 73 74 72 69 6e 67 29 20 2f 20 50 6f Linestring) / Po
1610: 69 6e 74 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d int blade.</li>.
1620: 0a 3c 6c 69 3e 4c 69 6e 65 73 74 72 69 6e 67 20 .<li>Linestring
1630: 74 61 72 67 65 74 20 2f 20 4c 69 6e 65 73 74 72 target / Linestr
1640: 69 6e 67 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d ing blade.</li>.
1650: 0a 3c 6c 69 3e 4d 75 6c 74 69 4c 69 6e 65 73 74 .<li>MultiLinest
1660: 72 69 6e 67 20 74 61 72 67 65 74 20 2f 20 4c 69 ring target / Li
1670: 6e 65 73 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c nestring blade.<
1680: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 50 6f 6c 79 67 6f /li>..<li>Polygo
1690: 6e 20 74 61 72 67 65 74 20 2f 20 4c 69 6e 65 73 n target / Lines
16a0: 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c 2f 6c 69 tring blade.</li
16b0: 3e 0d 0a 3c 6c 69 3e 4d 75 6c 74 69 50 6f 6c 79 >..<li>MultiPoly
16c0: 67 6f 6e 20 74 61 72 67 65 74 20 2f 20 4c 69 6e gon target / Lin
16d0: 65 73 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c 2f estring blade.</
16e0: 6c 69 3e 0d 0a 3c 6c 69 3e 47 65 6f 6d 65 74 72 li>..<li>Geometr
16f0: 79 43 6f 6c 6c 65 63 74 69 6f 6e 20 2f 20 4c 69 yCollection / Li
1700: 6e 65 73 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c nestring blade.<
1710: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 50 6c 65 61 73 65 /li>..<li>Please
1720: 20 6e 6f 74 69 63 65 3a 20 74 68 65 20 74 61 72 notice: the tar
1730: 67 65 74 20 47 65 6f 6d 65 74 72 79 20 73 68 6f get Geometry sho
1740: 75 6c 64 20 6e 65 76 65 72 20 63 6f 6e 74 61 69 uld never contai
1750: 6e 20 61 20 50 6f 69 6e 74 2e 3c 2f 6c 69 3e 0d n a Point.</li>.
1760: 0a 3c 2f 75 6c 3e 0d 0a 3c 68 34 3e 45 78 61 6d .</ul>..<h4>Exam
1770: 70 6c 65 20 23 31 20 2d 20 73 70 6c 69 74 74 69 ple #1 - splitti
1780: 6e 67 20 61 20 4c 69 6e 65 73 74 72 69 6e 67 20 ng a Linestring
1790: 62 79 20 61 20 50 6f 69 6e 74 20 62 6c 61 64 65 by a Point blade
17a0: 3c 2f 68 34 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 </h4>..<table bg
17b0: 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 color="#e0e0e0"
17c0: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 cellspacing="4"
17d0: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e cellpadding="8">
17e0: 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 ..<tr><td>..<b>S
17f0: 45 4c 45 43 54 20 53 54 5f 53 70 6c 69 74 28 69 ELECT ST_Split(i
1800: 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 nput.g, blade.g)
1810: 2c 20 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 69 , ST_SplitLeft(i
1820: 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 nput.g, blade.g)
1830: 2c 20 53 54 5f 53 70 6c 69 74 52 69 67 68 74 28 , ST_SplitRight(
1840: 69 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 input.g, blade.g
1850: 29 3c 62 72 3e 0d 0a 46 52 4f 4d 3c 62 72 3e 20 )<br>..FROM<br>
1860: 0d 0a 28 53 45 4c 45 43 54 20 47 65 6f 6d 46 72 ..(SELECT GeomFr
1870: 6f 6d 54 65 78 74 28 27 4c 49 4e 45 53 54 52 49 omText('LINESTRI
1880: 4e 47 28 30 20 31 30 2c 20 32 20 30 2c 20 34 20 NG(0 10, 2 0, 4
1890: 34 2c 20 36 20 30 2c 20 31 30 20 31 30 29 27 29 4, 6 0, 10 10)')
18a0: 20 41 53 20 67 29 20 41 53 20 69 6e 70 75 74 2c AS g) AS input,
18b0: 3c 62 72 3e 0d 0a 28 53 45 4c 45 43 54 20 47 65 <br>..(SELECT Ge
18c0: 6f 6d 46 72 6f 6d 54 65 78 74 28 27 50 4f 49 4e omFromText('POIN
18d0: 54 28 33 20 32 29 27 29 20 41 53 20 67 29 20 41 T(3 2)') AS g) A
18e0: 53 20 62 6c 61 64 65 3b 3c 2f 62 3e 0d 0a 3c 2f S blade;</b>..</
18f0: 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e td></tr></table>
1900: 0d 0a 3c 74 61 62 6c 65 20 63 65 6c 6c 73 70 61 ..<table cellspa
1910: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 cing="4" cellpad
1920: 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c ding="4">..<tr><
1930: 74 64 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 td>..The <b>ST_S
1940: 70 6c 69 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 plit()</b> SQL f
1950: 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 73 69 6d unction will sim
1960: 70 6c 79 20 72 65 74 75 72 6e 20 61 20 3c 69 3e ply return a <i>
1970: 63 6f 6c 6c 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 collection</i> a
1980: 67 67 72 65 67 61 74 69 6e 67 20 61 6c 6c 20 66 ggregating all f
1990: 72 61 67 6d 65 6e 74 73 20 64 65 72 69 76 69 6e ragments derivin
19a0: 67 20 66 72 6f 6d 20 74 68 65 20 63 75 74 2e 0d g from the cut..
19b0: 0a 54 68 69 73 20 69 73 6e 27 74 20 72 65 61 6c .This isn't real
19c0: 6c 79 20 75 73 65 66 75 6c 20 6f 6e 20 6d 61 6e ly useful on man
19d0: 79 20 63 61 73 65 73 2e 3c 62 72 3e 3c 62 72 3e y cases.<br><br>
19e0: 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 ..<u>Please note
19f0: 3c 2f 75 3e 3a 20 3c 69 3e 63 6f 6c 6c 65 63 74 </u>: <i>collect
1a00: 69 6f 6e 73 3c 2f 69 3e 20 69 6e 20 53 70 61 74 ions</i> in Spat
1a10: 69 61 4c 69 74 65 20 62 65 68 61 76 65 20 71 75 iaLite behave qu
1a20: 69 74 65 20 64 69 66 66 65 72 65 6e 74 6c 79 20 ite differently
1a30: 66 72 6f 6d 20 50 6f 73 74 47 69 73 2e 0d 0a 3c from PostGis...<
1a40: 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 /td><td>..<img s
1a50: 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 rc="http://www.g
1a60: 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d aia-gis.it/gaia-
1a70: 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d sins/write-view-
1a80: 70 69 63 73 2f 73 70 6c 69 74 2d 6c 6e 2e 70 6e pics/split-ln.pn
1a90: 67 22 20 61 6c 74 3d 22 73 70 6c 69 74 20 6c 69 g" alt="split li
1aa0: 6e 65 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e ne">..</td></tr>
1ab0: 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 20 ..<tr><td>..The
1ac0: 3c 62 3e 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 <b>ST_SplitLeft(
1ad0: 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 )</b> SQL functi
1ae0: 6f 6e 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 69 on will return i
1af0: 6e 73 74 65 61 64 20 61 20 3c 69 3e 63 6f 6c 6c nstead a <i>coll
1b00: 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 ection</i> aggre
1b10: 67 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d gating all fragm
1b20: 65 6e 74 73 20 6c 61 79 69 6e 67 20 6f 6e 20 74 ents laying on t
1b30: 68 65 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 73 he <i>left</i> s
1b40: 69 64 65 20 6f 66 20 74 68 65 20 63 75 74 2e 3c ide of the cut.<
1b50: 62 72 3e 0d 0a 46 6f 72 20 4c 69 6e 65 73 74 72 br>..For Linestr
1b60: 69 6e 67 73 20 79 6f 75 20 63 61 6e 6e 6f 74 20 ings you cannot
1b70: 69 6e 74 65 6e 64 20 3c 69 3e 6c 65 66 74 3c 2f intend <i>left</
1b80: 69 3e 20 69 6e 20 74 68 65 20 76 65 72 79 20 6c i> in the very l
1b90: 69 74 65 72 61 6c 20 73 65 6e 73 65 3b 20 74 68 iteral sense; th
1ba0: 69 73 20 72 65 61 6c 6c 79 20 6d 65 61 6e 73 20 is really means
1bb0: 3c 69 3e 74 68 65 20 73 69 64 65 20 77 68 65 72 <i>the side wher
1bc0: 65 20 74 68 65 20 73 74 61 72 74 2d 70 6f 69 6e e the start-poin
1bd0: 74 20 6c 61 79 3c 2f 69 3e 2e 3c 62 72 3e 3c 62 t lay</i>.<br><b
1be0: 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f r>..<u>Please no
1bf0: 74 65 3c 2f 75 3e 3a 20 69 66 20 74 68 65 20 3c te</u>: if the <
1c00: 69 3e 62 6c 61 64 65 3c 2f 69 3e 20 64 6f 65 73 i>blade</i> does
1c10: 6e 27 74 20 69 6e 74 65 72 63 65 70 74 73 20 74 n't intercepts t
1c20: 68 65 20 74 61 72 67 65 74 20 61 74 20 61 6c 6c he target at all
1c30: 2c 20 74 68 61 6e 20 6e 6f 20 63 75 74 20 77 6f , than no cut wo
1c40: 75 6c 64 20 62 65 20 6f 62 76 69 6f 75 73 6c 79 uld be obviously
1c50: 20 70 6f 73 73 69 62 6c 65 2e 20 49 6e 20 74 68 possible. In th
1c60: 69 73 20 73 70 65 63 69 61 6c 20 63 61 73 65 20 is special case
1c70: 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 74 61 72 the original tar
1c80: 67 65 74 20 47 65 6f 6d 65 74 72 79 20 77 69 6c get Geometry wil
1c90: 6c 20 62 65 20 61 6c 77 61 79 73 20 72 65 74 75 l be always retu
1ca0: 72 6e 65 64 20 28 61 62 73 6f 6c 75 74 65 6c 79 rned (absolutely
1cb0: 20 75 6e 63 68 61 6e 67 65 64 29 20 6f 6e 20 74 unchanged) on t
1cc0: 68 65 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 73 he <i>left</i> s
1cd0: 69 64 65 20 63 6f 6c 6c 65 63 74 69 6f 6e 2e 0d ide collection..
1ce0: 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 .</td><td>..<img
1cf0: 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 src="http://www
1d00: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 .gaia-gis.it/gai
1d10: 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 a-sins/write-vie
1d20: 77 2d 70 69 63 73 2f 73 70 6c 69 74 2d 6c 6e 2d w-pics/split-ln-
1d30: 4c 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 6c 69 L.png" alt="spli
1d40: 74 2d 6c 65 66 74 20 6c 69 6e 65 22 3e 0d 0a 3c t-left line">..<
1d50: 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /td></tr>..<tr><
1d60: 74 64 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 td>..The <b>ST_S
1d70: 70 6c 69 74 52 69 67 68 74 28 29 3c 2f 62 3e 20 plitRight()</b>
1d80: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c SQL function wil
1d90: 6c 20 72 65 74 75 72 6e 20 61 20 3c 69 3e 63 6f l return a <i>co
1da0: 6c 6c 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 llection</i> agg
1db0: 72 65 67 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 regating all fra
1dc0: 67 6d 65 6e 74 73 20 6c 61 79 69 6e 67 20 6f 6e gments laying on
1dd0: 20 74 68 65 20 3c 69 3e 72 69 67 68 74 3c 2f 69 the <i>right</i
1de0: 3e 20 73 69 64 65 20 6f 66 20 74 68 65 20 63 75 > side of the cu
1df0: 74 2e 3c 62 72 3e 0d 0a 46 6f 72 20 4c 69 6e 65 t.<br>..For Line
1e00: 73 74 72 69 6e 67 73 20 79 6f 75 20 63 61 6e 6e strings you cann
1e10: 6f 74 20 69 6e 74 65 6e 64 20 3c 69 3e 72 69 67 ot intend <i>rig
1e20: 68 74 3c 2f 69 3e 20 69 6e 20 74 68 65 20 76 65 ht</i> in the ve
1e30: 72 79 20 6c 69 74 65 72 61 6c 20 73 65 6e 73 65 ry literal sense
1e40: 3b 20 74 68 69 73 20 72 65 61 6c 6c 79 20 6d 65 ; this really me
1e50: 61 6e 73 20 3c 69 3e 74 68 65 20 73 69 64 65 20 ans <i>the side
1e60: 77 68 65 72 65 20 74 68 65 20 65 6e 64 2d 70 6f where the end-po
1e70: 69 6e 74 20 6c 61 79 3c 2f 69 3e 2e 3c 62 72 3e int lay</i>.<br>
1e80: 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 <br>..<u>Please
1e90: 6e 6f 74 65 3c 2f 75 3e 3a 20 69 66 20 74 68 65 note</u>: if the
1ea0: 20 3c 69 3e 62 6c 61 64 65 3c 2f 69 3e 20 64 6f <i>blade</i> do
1eb0: 65 73 6e 27 74 20 69 6e 74 65 72 63 65 70 74 73 esn't intercepts
1ec0: 20 74 68 65 20 74 61 72 67 65 74 20 61 74 20 61 the target at a
1ed0: 6c 6c 2c 20 74 68 61 6e 20 6e 6f 20 63 75 74 20 ll, than no cut
1ee0: 77 6f 75 6c 64 20 62 65 20 6f 62 76 69 6f 75 73 would be obvious
1ef0: 6c 79 20 70 6f 73 73 69 62 6c 65 2e 20 49 6e 20 ly possible. In
1f00: 74 68 69 73 20 73 70 65 63 69 61 6c 20 63 61 73 this special cas
1f10: 65 20 74 68 65 20 3c 69 3e 72 69 67 68 74 3c 2f e the <i>right</
1f20: 69 3e 20 73 69 64 65 20 63 6f 6c 6c 65 63 74 69 i> side collecti
1f30: 6f 6e 20 77 69 6c 6c 20 62 65 20 4e 55 4c 4c 2e on will be NULL.
1f40: 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d ..</td><td>..<im
1f50: 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 g src="http://ww
1f60: 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 w.gaia-gis.it/ga
1f70: 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 ia-sins/write-vi
1f80: 65 77 2d 70 69 63 73 2f 73 70 6c 69 74 2d 6c 6e ew-pics/split-ln
1f90: 2d 52 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 6c -R.png" alt="spl
1fa0: 69 74 2d 72 69 67 68 74 20 6c 69 6e 65 22 3e 0d it-right line">.
1fb0: 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 .</td></tr>..</t
1fc0: 61 62 6c 65 3e 0d 0a 3c 68 34 3e 45 78 61 6d 70 able>..<h4>Examp
1fd0: 6c 65 20 23 32 20 2d 20 73 70 6c 69 74 74 69 6e le #2 - splittin
1fe0: 67 20 61 20 50 6f 6c 79 67 6f 6e 20 62 79 20 61 g a Polygon by a
1ff0: 20 4c 69 6e 65 73 74 72 69 6e 67 20 62 6c 61 64 Linestring blad
2000: 65 3c 2f 68 34 3e 0d 0a 3c 74 61 62 6c 65 20 62 e</h4>..<table b
2010: 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 gcolor="#e0e0e0"
2020: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
2030: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 cellpadding="8"
2040: 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e >..<tr><td>..<b>
2050: 53 45 4c 45 43 54 20 53 54 5f 53 70 6c 69 74 28 SELECT ST_Split(
2060: 69 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 input.g, blade.g
2070: 29 2c 20 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 ), ST_SplitLeft(
2080: 69 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 input.g, blade.g
2090: 29 2c 20 53 54 5f 53 70 6c 69 74 52 69 67 68 74 ), ST_SplitRight
20a0: 28 69 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e (input.g, blade.
20b0: 67 29 3c 62 72 3e 0d 0a 46 52 4f 4d 3c 62 72 3e g)<br>..FROM<br>
20c0: 20 0d 0a 28 53 45 4c 45 43 54 20 47 65 6f 6d 46 ..(SELECT GeomF
20d0: 72 6f 6d 54 65 78 74 28 27 50 4f 4c 59 47 4f 4e romText('POLYGON
20e0: 28 28 30 20 31 2c 20 31 30 20 31 2c 20 31 30 20 ((0 1, 10 1, 10
20f0: 39 2c 20 30 20 39 2c 20 30 20 31 29 2c 20 28 32 9, 0 9, 0 1), (2
2100: 20 32 2c 20 37 20 32 2c 20 37 20 36 2c 20 32 20 2, 7 2, 7 6, 2
2110: 36 2c 20 32 20 32 29 29 27 29 20 41 53 20 67 29 6, 2 2))') AS g)
2120: 20 41 53 20 69 6e 70 75 74 2c 3c 62 72 3e 20 0d AS input,<br> .
2130: 0a 28 53 45 4c 45 43 54 20 47 65 6f 6d 46 72 6f .(SELECT GeomFro
2140: 6d 54 65 78 74 28 27 4c 49 4e 45 53 54 52 49 4e mText('LINESTRIN
2150: 47 28 32 20 30 2c 20 36 20 31 30 29 27 29 20 41 G(2 0, 6 10)') A
2160: 53 20 67 29 20 41 53 20 62 6c 61 64 65 3b 3c 2f S g) AS blade;</
2170: 62 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a b>..</td></tr>..
2180: 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 </table><br>..<t
2190: 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 able cellspacing
21a0: 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 ="4" cellpadding
21b0: 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d ="4">..<tr><td>.
21c0: 0a 54 68 65 20 3c 62 3e 53 54 5f 53 70 6c 69 74 .The <b>ST_Split
21d0: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
21e0: 69 6f 6e 20 77 69 6c 6c 20 73 69 6d 70 6c 79 20 ion will simply
21f0: 72 65 74 75 72 6e 20 61 20 3c 69 3e 63 6f 6c 6c return a <i>coll
2200: 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 ection</i> aggre
2210: 67 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d gating all fragm
2220: 65 6e 74 73 20 64 65 72 69 76 69 6e 67 20 66 72 ents deriving fr
2230: 6f 6d 20 74 68 65 20 63 75 74 2e 3c 62 72 3e 0d om the cut.<br>.
2240: 0a 45 78 61 63 74 6c 79 20 61 73 20 77 65 20 68 .Exactly as we h
2250: 61 76 65 20 61 6c 72 65 61 64 79 20 70 72 65 76 ave already prev
2260: 69 6f 75 73 6c 79 20 73 65 65 6e 20 6f 6e 20 74 iously seen on t
2270: 68 65 20 4c 69 6e 65 73 74 72 69 6e 67 20 63 61 he Linestring ca
2280: 73 65 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 2f 74 se.<br><br>..</t
2290: 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 d><td>..<img src
22a0: 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 ="http://www.gai
22b0: 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 a-gis.it/gaia-si
22c0: 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 ns/write-view-pi
22d0: 63 73 2f 73 70 6c 69 74 2d 70 67 2e 70 6e 67 22 cs/split-pg.png"
22e0: 20 61 6c 74 3d 22 73 70 6c 69 74 20 70 6f 6c 79 alt="split poly
22f0: 67 6f 6e 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 gon">..</td></tr
2300: 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 >..<tr><td>..The
2310: 20 3c 62 3e 53 54 5f 53 70 6c 69 74 4c 65 66 74 <b>ST_SplitLeft
2320: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
2330: 69 6f 6e 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 ion will return
2340: 69 6e 73 74 65 61 64 20 61 20 3c 69 3e 63 6f 6c instead a <i>col
2350: 6c 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 lection</i> aggr
2360: 65 67 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 egating all frag
2370: 6d 65 6e 74 73 20 6c 61 79 69 6e 67 20 6f 6e 20 ments laying on
2380: 74 68 65 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 the <i>left</i>
2390: 73 69 64 65 20 6f 66 20 74 68 65 20 63 75 74 2e side of the cut.
23a0: 3c 62 72 3e 0d 0a 46 6f 72 20 50 6f 6c 79 67 6f <br>..For Polygo
23b0: 6e 73 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 72 ns <i>left</i> r
23c0: 65 61 6c 6c 79 20 6d 65 61 6e 73 20 3c 69 3e 6c eally means <i>l
23d0: 65 66 74 20 73 69 64 65 3c 2f 69 3e 20 28 61 74 eft side</i> (at
23e0: 20 6c 65 61 73 74 2c 20 74 68 69 73 20 69 73 20 least, this is
23f0: 74 72 75 65 20 77 68 65 6e 20 74 68 65 20 62 6c true when the bl
2400: 61 64 65 20 69 73 20 61 6c 6d 6f 73 74 20 76 65 ade is almost ve
2410: 72 74 69 63 61 6c 6c 79 20 6f 72 69 65 6e 74 65 rtically oriente
2420: 64 29 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 3e d).<br><br>..<u>
2430: 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a Please note</u>:
2440: 20 69 66 20 74 68 65 20 3c 69 3e 62 6c 61 64 65 if the <i>blade
2450: 3c 2f 69 3e 20 64 6f 65 73 6e 27 74 20 69 6e 74 </i> doesn't int
2460: 65 72 63 65 70 74 73 20 74 68 65 20 74 61 72 67 ercepts the targ
2470: 65 74 20 61 74 20 61 6c 6c 2c 20 74 68 61 6e 20 et at all, than
2480: 6e 6f 20 63 75 74 20 77 6f 75 6c 64 20 62 65 20 no cut would be
2490: 6f 62 76 69 6f 75 73 6c 79 20 70 6f 73 73 69 62 obviously possib
24a0: 6c 65 2e 20 49 6e 20 74 68 69 73 20 73 70 65 63 le. In this spec
24b0: 69 61 6c 20 63 61 73 65 20 74 68 65 20 6f 72 69 ial case the ori
24c0: 67 69 6e 61 6c 20 74 61 72 67 65 74 20 47 65 6f ginal target Geo
24d0: 6d 65 74 72 79 20 77 69 6c 6c 20 62 65 20 61 6c metry will be al
24e0: 77 61 79 73 20 72 65 74 75 72 6e 65 64 20 28 61 ways returned (a
24f0: 62 73 6f 6c 75 74 65 6c 79 20 75 6e 63 68 61 6e bsolutely unchan
2500: 67 65 64 29 20 6f 6e 20 74 68 65 20 3c 69 3e 6c ged) on the <i>l
2510: 65 66 74 3c 2f 69 3e 20 73 69 64 65 20 63 6f 6c eft</i> side col
2520: 6c 65 63 74 69 6f 6e 2e 0d 0a 3c 2f 74 64 3e 3c lection...</td><
2530: 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 td>..<img src="h
2540: 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 ttp://www.gaia-g
2550: 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f is.it/gaia-sins/
2560: 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f write-view-pics/
2570: 73 70 6c 69 74 2d 70 67 2d 4c 2e 70 6e 67 22 20 split-pg-L.png"
2580: 61 6c 74 3d 22 73 70 6c 69 74 2d 6c 65 66 74 20 alt="split-left
2590: 70 6f 6c 79 67 6f 6e 22 3e 0d 0a 3c 2f 74 64 3e polygon">..</td>
25a0: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d </tr>..<tr><td>.
25b0: 0a 54 68 65 20 3c 62 3e 53 54 5f 53 70 6c 69 74 .The <b>ST_Split
25c0: 52 69 67 68 74 28 29 3c 2f 62 3e 20 53 51 4c 20 Right()</b> SQL
25d0: 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 function will re
25e0: 74 75 72 6e 20 61 20 3c 69 3e 63 6f 6c 6c 65 63 turn a <i>collec
25f0: 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 67 61 tion</i> aggrega
2600: 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d 65 6e ting all fragmen
2610: 74 73 20 6c 61 79 69 6e 67 20 6f 6e 20 74 68 65 ts laying on the
2620: 20 3c 69 3e 72 69 67 68 74 3c 2f 69 3e 20 73 69 <i>right</i> si
2630: 64 65 20 6f 66 20 74 68 65 20 63 75 74 2e 3c 62 de of the cut.<b
2640: 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f r>..<u>Please no
2650: 74 65 3c 2f 75 3e 3a 20 69 66 20 74 68 65 20 3c te</u>: if the <
2660: 69 3e 62 6c 61 64 65 3c 2f 69 3e 20 64 6f 65 73 i>blade</i> does
2670: 6e 27 74 20 69 6e 74 65 72 63 65 70 74 73 20 74 n't intercepts t
2680: 68 65 20 74 61 72 67 65 74 20 61 74 20 61 6c 6c he target at all
2690: 2c 20 74 68 61 6e 20 6e 6f 20 63 75 74 20 77 6f , than no cut wo
26a0: 75 6c 64 20 62 65 20 6f 62 76 69 6f 75 73 6c 79 uld be obviously
26b0: 20 70 6f 73 73 69 62 6c 65 2e 20 49 6e 20 74 68 possible. In th
26c0: 69 73 20 73 70 65 63 69 61 6c 20 63 61 73 65 20 is special case
26d0: 74 68 65 20 3c 69 3e 72 69 67 68 74 3c 2f 69 3e the <i>right</i>
26e0: 20 73 69 64 65 20 63 6f 6c 6c 65 63 74 69 6f 6e side collection
26f0: 20 77 69 6c 6c 20 62 65 20 4e 55 4c 4c 2e 0d 0a will be NULL...
2700: 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 </td><td>..<img
2710: 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e src="http://www.
2720: 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 gaia-gis.it/gaia
2730: 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 -sins/write-view
2740: 2d 70 69 63 73 2f 73 70 6c 69 74 2d 70 67 2d 52 -pics/split-pg-R
2750: 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 6c 69 74 .png" alt="split
2760: 2d 72 69 67 68 74 20 70 6f 6c 79 67 6f 6e 22 3e -right polygon">
2770: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f ..</td></tr>..</
2780: 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 72 3e table>..<br><hr>
2790: 0d 0a 3c 68 33 3e 53 65 67 6d 65 6e 74 69 7a 61 ..<h3>Segmentiza
27a0: 74 69 6f 6e 3c 2f 68 33 3e 0d 0a 53 6f 6d 65 74 tion</h3>..Somet
27b0: 69 6d 65 73 20 69 74 20 63 6f 75 6c 64 20 62 65 imes it could be
27c0: 20 75 73 65 66 75 6c 20 3c 69 3e 69 6e 74 65 72 useful <i>inter
27d0: 70 6f 6c 61 74 69 6e 67 3c 2f 69 3e 20 6d 61 6e polating</i> man
27e0: 79 20 66 75 72 74 68 65 72 20 76 65 72 74 69 63 y further vertic
27f0: 65 73 20 69 6e 74 6f 20 73 6f 6d 65 20 76 65 72 es into some ver
2800: 79 20 6c 6f 6e 67 20 4c 69 6e 65 73 74 72 69 6e y long Linestrin
2810: 67 20 6f 72 20 50 6f 6c 79 67 6f 6e 27 73 20 52 g or Polygon's R
2820: 69 6e 67 2c 20 73 6f 20 74 6f 20 6f 62 74 61 69 ing, so to obtai
2830: 6e 20 6d 61 6e 79 20 73 6d 61 6c 6c 65 72 20 73 n many smaller s
2840: 65 67 6d 65 6e 74 73 20 6f 66 20 74 68 65 20 73 egments of the s
2850: 61 6d 65 20 69 64 65 6e 74 69 63 61 6c 20 6c 65 ame identical le
2860: 6e 67 74 68 2e 0d 0a 3c 74 61 62 6c 65 20 62 67 ngth...<table bg
2870: 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 color="#e0e0e0"
2880: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 cellspacing="4"
2890: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e cellpadding="8">
28a0: 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 ..<tr><td>..<b>S
28b0: 45 4c 45 43 54 20 67 65 6f 6d 65 74 72 79 2c 20 ELECT geometry,
28c0: 53 54 5f 53 65 67 6d 65 6e 74 69 7a 65 28 67 65 ST_Segmentize(ge
28d0: 6f 6d 65 74 72 79 2c 20 31 30 2e 30 29 3c 62 72 ometry, 10.0)<br
28e0: 3e 0d 0a 46 52 4f 4d 20 63 6f 6d 32 30 31 31 3c >..FROM com2011<
28f0: 62 72 3e 0d 0a 57 48 45 52 45 20 6e 6f 6d 65 5f br>..WHERE nome_
2900: 63 6f 6d 20 3d 20 27 42 72 6f 6e 74 65 27 3b 3c com = 'Bronte';<
2910: 2f 62 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c /b>..</td></tr><
2920: 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 61 /table><br>..<ta
2930: 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 ble border="1" c
2940: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
2950: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d ellpadding="4">.
2960: 0a 3c 74 72 3e 3c 74 68 3e 6f 72 69 67 69 6e 61 .<tr><th>origina
2970: 6c 3c 2f 74 68 3e 3c 74 68 3e 73 65 67 6d 65 6e l</th><th>segmen
2980: 74 69 7a 65 64 3c 2f 74 68 3e 3c 2f 74 72 3e 0d tized</th></tr>.
2990: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 .<tr><td>..<img
29a0: 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e src="http://www.
29b0: 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 gaia-gis.it/gaia
29c0: 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 -sins/write-view
29d0: 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d 6f 72 69 -pics/bronte-ori
29e0: 67 69 6e 61 6c 2e 70 6e 67 22 20 61 6c 74 3d 22 ginal.png" alt="
29f0: 62 72 6f 6e 74 65 20 6f 72 69 67 69 6e 61 6c 22 bronte original"
2a00: 3e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 >..</td><td>..<i
2a10: 6d 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 mg src="http://w
2a20: 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 ww.gaia-gis.it/g
2a30: 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 aia-sins/write-v
2a40: 69 65 77 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d iew-pics/bronte-
2a50: 73 65 67 6d 65 6e 74 69 7a 65 64 2e 70 6e 67 22 segmentized.png"
2a60: 20 61 6c 74 3d 22 62 72 6f 6e 74 65 20 73 65 67 alt="bronte seg
2a70: 6d 65 6e 74 69 7a 65 64 22 3e 0d 0a 3c 2f 74 64 mentized">..</td
2a80: 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 20 ></tr>..<tr><td
2a90: 63 6f 6c 73 70 61 6e 3d 22 32 22 3e 0d 0a 41 73 colspan="2">..As
2aa0: 20 79 6f 75 20 63 61 6e 20 65 61 73 69 6c 79 20 you can easily
2ab0: 6e 6f 74 69 63 65 2c 20 74 68 65 72 65 20 61 72 notice, there ar
2ac0: 65 20 6d 61 6e 79 20 6d 6f 72 65 20 76 65 72 74 e many more vert
2ad0: 69 63 65 73 20 69 6e 20 74 68 65 20 73 65 67 6d ices in the segm
2ae0: 65 6e 74 69 7a 65 64 20 47 65 6f 6d 65 74 72 79 entized Geometry
2af0: 2e 3c 62 72 3e 0d 0a 57 65 20 69 6d 70 6f 73 65 .<br>..We impose
2b00: 64 20 74 68 65 20 63 6f 6e 73 74 72 61 69 6e 74 d the constraint
2b10: 20 74 68 61 74 20 6e 6f 20 73 65 67 6d 65 6e 74 that no segment
2b20: 20 63 6f 75 6c 64 20 62 65 20 6c 6f 6e 67 65 72 could be longer
2b30: 20 74 68 61 6e 20 3c 62 3e 31 30 6d 3c 2f 62 3e than <b>10m</b>
2b40: 2c 20 74 68 75 73 20 63 61 75 73 69 6e 67 20 6d , thus causing m
2b50: 61 6e 79 20 6d 6f 72 65 20 76 65 72 74 69 63 65 any more vertice
2b60: 73 20 74 6f 20 62 65 20 69 6e 74 65 72 70 6f 6c s to be interpol
2b70: 61 74 65 64 2e 3c 62 72 3e 0d 0a 54 68 65 20 6f ated.<br>..The o
2b80: 76 65 72 61 6c 6c 20 73 68 61 70 65 20 69 73 20 verall shape is
2b90: 61 62 73 6f 6c 75 74 65 6c 79 20 75 6e 63 68 61 absolutely uncha
2ba0: 6e 67 65 64 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 nged...</td></tr
2bb0: 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 >..</table>..<br
2bc0: 3e 3c 68 72 3e 0d 0a 3c 68 33 3e 41 7a 69 6d 75 ><hr>..<h3>Azimu
2bd0: 74 68 3c 2f 68 33 3e 0d 0a 50 72 6f 62 61 62 6c th</h3>..Probabl
2be0: 79 20 6e 6f 74 20 74 68 65 20 6d 6f 73 74 20 69 y not the most i
2bf0: 6e 74 65 72 65 73 74 69 6e 67 20 66 75 6e 63 74 nteresting funct
2c00: 69 6f 6e 20 73 75 70 70 6f 72 74 65 64 20 62 79 ion supported by
2c10: 20 3c 69 3e 6c 69 62 6c 77 67 65 6f 6d 3c 2f 69 <i>liblwgeom</i
2c20: 3e 3b 20 61 6e 79 77 61 79 20 69 74 27 73 20 74 >; anyway it's t
2c30: 68 65 72 65 2c 20 61 6e 64 20 69 73 20 77 6f 72 here, and is wor
2c40: 74 68 20 65 6e 6f 75 67 68 20 74 6f 20 62 65 20 th enough to be
2c50: 73 75 70 70 6f 72 74 65 64 20 62 79 20 53 70 61 supported by Spa
2c60: 74 69 61 4c 69 74 65 20 61 73 20 77 65 6c 6c 2e tiaLite as well.
2c70: 3c 62 72 3e 0d 0a 50 72 6f 62 61 62 6c 79 20 68 <br>..Probably h
2c80: 69 67 68 6c 79 20 61 70 70 72 65 63 69 61 74 65 ighly appreciate
2c90: 64 20 6f 6e 20 3c 62 3e 47 50 53 20 64 65 76 69 d on <b>GPS devi
2ca0: 63 65 73 3c 2f 62 3e 20 73 6f 20 74 6f 20 64 65 ces</b> so to de
2cb0: 74 65 72 6d 69 6e 65 20 74 68 65 20 63 75 72 72 termine the curr
2cc0: 65 6e 74 20 62 65 61 72 69 6e 67 2e 0d 0a 3c 74 ent bearing...<t
2cd0: 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 65 able bgcolor="#e
2ce0: 30 65 30 65 30 22 20 63 65 6c 6c 73 70 61 63 69 0e0e0" cellspaci
2cf0: 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 ng="4" cellpaddi
2d00: 6e 67 3d 22 38 22 3e 0d 0a 3c 74 72 3e 3c 74 64 ng="8">..<tr><td
2d10: 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 44 65 67 >..<b>SELECT Deg
2d20: 72 65 65 73 28 53 54 5f 41 7a 69 6d 75 74 68 28 rees(ST_Azimuth(
2d30: 4d 61 6b 65 50 6f 69 6e 74 28 30 2c 20 30 29 2c MakePoint(0, 0),
2d40: 20 4d 61 6b 65 50 6f 69 6e 74 28 30 2c 20 31 29 MakePoint(0, 1)
2d50: 29 29 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a 30 ));</b>..<hr>..0
2d60: 2e 30 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a .0..</td></tr>..
2d70: 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c <tr><td>..<b>SEL
2d80: 45 43 54 20 44 65 67 72 65 65 73 28 53 54 5f 41 ECT Degrees(ST_A
2d90: 7a 69 6d 75 74 68 28 4d 61 6b 65 50 6f 69 6e 74 zimuth(MakePoint
2da0: 28 30 2c 20 30 29 2c 20 4d 61 6b 65 50 6f 69 6e (0, 0), MakePoin
2db0: 74 28 31 2c 20 31 29 29 29 3b 3c 2f 62 3e 0d 0a t(1, 1)));</b>..
2dc0: 3c 68 72 3e 0d 0a 34 35 2e 30 0d 0a 3c 2f 74 64 <hr>..45.0..</td
2dd0: 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e ></tr>..<tr><td>
2de0: 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 44 65 67 72 ..<b>SELECT Degr
2df0: 65 65 73 28 53 54 5f 41 7a 69 6d 75 74 68 28 4d ees(ST_Azimuth(M
2e00: 61 6b 65 50 6f 69 6e 74 28 30 2c 20 30 29 2c 20 akePoint(0, 0),
2e10: 4d 61 6b 65 50 6f 69 6e 74 28 31 2c 20 30 29 29 MakePoint(1, 0))
2e20: 29 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a 39 30 );</b>..<hr>..90
2e30: 2e 30 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a .0..</td></tr>..
2e40: 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c <tr><td>..<b>SEL
2e50: 45 43 54 20 44 65 67 72 65 65 73 28 53 54 5f 41 ECT Degrees(ST_A
2e60: 7a 69 6d 75 74 68 28 4d 61 6b 65 50 6f 69 6e 74 zimuth(MakePoint
2e70: 28 30 2c 20 30 29 2c 20 4d 61 6b 65 50 6f 69 6e (0, 0), MakePoin
2e80: 74 28 30 2c 20 2d 31 29 29 29 3b 3c 2f 62 3e 0d t(0, -1)));</b>.
2e90: 0a 3c 68 72 3e 0d 0a 31 38 30 2e 30 0d 0a 3c 2f .<hr>..180.0..</
2ea0: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c td></tr>..</tabl
2eb0: 65 3e 3c 62 72 3e 0d 0a 3c 62 72 3e 3c 68 72 3e e><br>..<br><hr>
2ec0: 0d 0a 3c 68 33 3e 53 6e 61 70 70 69 6e 67 20 47 ..<h3>Snapping G
2ed0: 65 6f 6d 65 74 72 69 65 73 20 74 6f 20 61 20 70 eometries to a p
2ee0: 72 65 64 65 66 69 6e 65 64 20 67 72 69 64 3c 2f redefined grid</
2ef0: 68 33 3e 0d 0a 54 68 69 73 20 66 65 61 74 75 72 h3>..This featur
2f00: 65 20 72 65 61 6c 6c 79 20 69 73 20 3c 69 3e 3c e really is <i><
2f10: 75 3e 74 68 65 20 6d 6f 74 68 65 72 20 6f 66 20 u>the mother of
2f20: 74 6f 70 6f 6c 6f 67 69 63 61 6c 20 63 6f 6e 73 topological cons
2f30: 69 73 74 65 6e 63 79 3c 2f 75 3e 3c 2f 69 3e 3b istency</u></i>;
2f40: 20 69 6d 70 6f 73 69 6e 67 20 74 68 61 74 20 61 imposing that a
2f50: 6c 6c 20 70 6f 69 6e 74 73 20 2f 20 76 65 72 74 ll points / vert
2f60: 69 63 65 73 20 73 68 6f 75 6c 64 20 62 65 20 73 ices should be s
2f70: 74 72 69 63 74 6c 79 20 61 6c 69 67 6e 65 64 20 trictly aligned
2f80: 74 6f 20 74 68 65 20 73 61 6d 65 20 67 72 69 64 to the same grid
2f90: 20 77 69 6c 6c 20 73 75 72 65 6c 79 20 6d 61 6b will surely mak
2fa0: 65 20 65 61 73 69 65 72 20 65 6e 73 75 72 69 6e e easier ensurin
2fb0: 67 20 61 20 73 74 72 6f 6e 67 20 63 6f 6e 73 69 g a strong consi
2fc0: 73 74 65 6e 63 79 20 62 65 74 77 65 65 6e 20 64 stency between d
2fd0: 69 66 66 65 72 65 6e 74 20 47 65 6f 6d 65 74 72 ifferent Geometr
2fe0: 69 65 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 ies.<br><br>..<u
2ff0: 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e >Please note</u>
3000: 3a 20 64 75 65 20 74 6f 20 74 65 63 68 6e 69 63 : due to technic
3010: 61 6c 20 72 65 61 73 6f 6e 73 20 74 68 65 20 63 al reasons the c
3020: 75 72 72 65 6e 74 20 76 65 72 73 69 6f 6e 20 6f urrent version o
3030: 66 20 3c 69 3e 6c 69 62 6c 77 67 65 6f 6d 3c 2f f <i>liblwgeom</
3040: 69 3e 20 64 6f 65 73 6e 27 74 20 65 78 70 6f 73 i> doesn't expos
3050: 65 73 20 74 6f 20 74 68 65 20 65 78 74 65 72 69 es to the exteri
3060: 6f 72 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e or the correspon
3070: 64 69 6e 67 20 6c 69 6e 6b 20 73 79 6d 62 6f 6c ding link symbol
3080: 73 2e 3c 62 72 3e 0d 0a 53 6f 20 74 68 65 20 63 s.<br>..So the c
3090: 75 72 72 65 6e 74 20 69 6d 70 6c 65 6d 65 6e 74 urrent implement
30a0: 61 74 69 6f 6e 20 61 76 61 69 6c 61 62 6c 65 20 ation available
30b0: 6f 6e 20 53 70 61 74 69 61 4c 69 74 65 20 69 73 on SpatiaLite is
30c0: 20 61 6e 20 69 6e 64 65 70 65 6e 64 65 6e 74 20 an independent
30d0: 6f 6e 65 20 28 61 6c 74 68 6f 75 67 68 20 62 65 one (although be
30e0: 69 6e 67 20 64 69 72 65 63 74 6c 79 20 69 6e 73 ing directly ins
30f0: 70 69 72 65 64 20 62 79 20 74 68 65 20 3c 69 3e pired by the <i>
3100: 6c 69 62 6c 77 67 65 6f 6d 3c 2f 69 3e 20 6f 6e liblwgeom</i> on
3110: 65 29 2e 3c 62 72 3e 20 20 0d 0a 3c 74 61 62 6c e).<br> ..<tabl
3120: 65 20 62 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 e bgcolor="#e0e0
3130: 65 30 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d e0" cellspacing=
3140: 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d "4" cellpadding=
3150: 22 38 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a "8">..<tr><td>..
3160: 3c 62 3e 53 45 4c 45 43 54 20 53 54 5f 53 6e 61 <b>SELECT ST_Sna
3170: 70 54 6f 47 72 69 64 28 67 65 6f 6d 65 74 72 79 pToGrid(geometry
3180: 2c 20 32 35 30 2e 30 29 3c 62 72 3e 0d 0a 46 52 , 250.0)<br>..FR
3190: 4f 4d 20 63 6f 6d 32 30 31 31 3c 62 72 3e 0d 0a OM com2011<br>..
31a0: 57 48 45 52 45 20 6e 6f 6d 65 5f 63 6f 6d 20 3d WHERE nome_com =
31b0: 20 27 42 72 6f 6e 74 65 27 3b 3c 2f 62 3e 0d 0a 'Bronte';</b>..
31c0: 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c </td></tr></tabl
31d0: 65 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 63 e><br>..<table c
31e0: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
31f0: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d ellpadding="4">.
3200: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 59 65 74 20 61 .<tr><td>..Yet a
3210: 67 61 69 6e 20 61 6e 6f 74 68 65 72 20 74 69 6d gain another tim
3220: 65 20 74 68 65 20 42 72 6f 6e 74 65 20 4c 6f 63 e the Bronte Loc
3230: 61 6c 20 43 6f 75 6e 63 69 6c 20 62 6f 75 6e 64 al Council bound
3240: 61 72 79 2e 3c 62 72 3e 0d 0a 42 79 20 69 6e 76 ary.<br>..By inv
3250: 6f 6b 69 6e 67 20 3c 62 3e 53 54 5f 53 6e 61 70 oking <b>ST_Snap
3260: 54 6f 47 72 69 64 28 29 3c 2f 62 3e 20 74 68 69 ToGrid()</b> thi
3270: 73 20 74 69 6d 65 20 74 68 65 20 47 65 6f 6d 65 s time the Geome
3280: 74 72 79 20 68 61 73 20 62 65 65 6e 20 73 74 72 try has been str
3290: 6f 6e 67 6c 79 20 73 69 6d 70 6c 69 66 69 65 64 ongly simplified
32a0: 20 28 70 6c 65 61 73 65 20 6e 6f 74 69 63 65 3b (please notice;
32b0: 20 6d 61 6e 79 20 76 65 72 74 69 63 65 73 20 68 many vertices h
32c0: 61 76 65 20 62 65 65 6e 20 73 75 70 70 72 65 73 ave been suppres
32d0: 73 65 64 29 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 54 sed).<br><br>..T
32e0: 68 65 20 69 6d 70 6f 73 65 64 20 3c 69 3e 67 72 he imposed <i>gr
32f0: 69 64 20 73 69 7a 65 3c 2f 69 3e 20 28 3c 62 3e id size</i> (<b>
3300: 32 35 30 6d 3c 2f 62 3e 29 20 69 73 20 61 62 73 250m</b>) is abs
3310: 6f 6c 75 74 65 6c 79 20 75 6e 72 65 61 6c 69 73 olutely unrealis
3320: 74 69 63 20 61 6e 64 20 65 78 61 67 67 65 72 61 tic and exaggera
3330: 74 65 64 20 66 6f 72 20 61 6e 79 20 70 72 61 63 ted for any prac
3340: 74 69 63 61 6c 20 70 75 72 70 6f 73 65 2e 3c 62 tical purpose.<b
3350: 72 3e 0d 0a 41 6e 79 77 61 79 20 61 20 73 75 63 r>..Anyway a suc
3360: 68 20 73 74 72 6f 6e 67 20 66 61 63 74 6f 72 20 h strong factor
3370: 69 73 20 75 73 65 66 75 6c 20 69 6e 20 6f 72 64 is useful in ord
3380: 65 72 20 74 6f 20 63 6c 65 61 72 6c 79 20 73 68 er to clearly sh
3390: 6f 77 20 77 68 61 74 20 72 65 61 6c 6c 79 20 68 ow what really h
33a0: 61 70 70 65 6e 73 3a 3c 75 6c 3e 0d 0a 3c 6c 69 appens:<ul>..<li
33b0: 3e 61 6c 6c 20 76 65 72 74 69 63 65 73 20 61 72 >all vertices ar
33c0: 65 20 6e 6f 77 20 73 74 72 69 63 74 6c 79 20 61 e now strictly a
33d0: 6c 69 67 6e 65 64 20 74 6f 20 74 68 65 20 67 72 ligned to the gr
33e0: 69 64 20 6e 6f 64 65 73 2e 3c 2f 6c 69 3e 0d 0a id nodes.</li>..
33f0: 3c 6c 69 3e 61 6c 6c 20 76 65 72 74 69 63 65 73 <li>all vertices
3400: 20 66 61 6c 6c 69 6e 67 20 77 69 74 68 69 6e 20 falling within
3410: 74 68 65 20 73 61 6d 65 20 67 72 69 64 20 63 65 the same grid ce
3420: 6c 6c 20 68 61 76 65 20 62 65 65 6e 20 73 75 70 ll have been sup
3430: 70 72 65 73 73 65 64 2c 20 73 74 69 6c 6c 20 70 pressed, still p
3440: 72 65 73 65 72 76 69 6e 67 20 6f 6e 6c 79 20 6f reserving only o
3450: 6e 65 20 6f 66 20 74 68 65 6d 2e 3c 2f 6c 69 3e ne of them.</li>
3460: 0d 0a 3c 6c 69 3e 73 6f 20 74 68 65 20 6f 76 65 ..<li>so the ove
3470: 72 61 6c 6c 20 65 66 66 65 63 74 20 69 73 20 74 rall effect is t
3480: 68 65 20 6f 6e 65 20 6c 65 61 64 69 6e 67 20 74 he one leading t
3490: 6f 20 61 20 72 69 67 6f 72 6f 75 73 6c 79 20 3c o a rigorously <
34a0: 69 3e 6e 6f 72 6d 61 6c 69 7a 65 64 3c 2f 69 3e i>normalized</i>
34b0: 20 61 6e 64 20 28 6d 61 79 20 62 65 29 20 3c 69 and (may be) <i
34c0: 3e 73 69 6d 70 6c 69 66 69 65 64 3c 2f 69 3e 20 >simplified</i>
34d0: 47 65 6f 6d 65 74 72 79 3b 20 61 6e 64 20 74 68 Geometry; and th
34e0: 69 73 20 77 69 6c 6c 20 73 75 72 65 6c 79 20 6d is will surely m
34f0: 61 6b 65 20 65 61 73 69 65 72 20 65 6e 73 75 72 ake easier ensur
3500: 69 6e 67 20 74 68 65 20 72 65 71 75 69 72 65 64 ing the required
3510: 20 74 6f 70 6f 6c 6f 67 69 63 61 6c 20 63 6f 6e topological con
3520: 73 69 73 74 65 6e 63 79 20 77 69 74 68 20 61 6e sistency with an
3530: 79 20 6f 74 68 65 72 20 61 64 6a 61 63 65 6e 74 y other adjacent
3540: 20 4c 6f 63 61 6c 20 43 6f 75 6e 63 69 6c 2e 3c Local Council.<
3550: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 2f 74 /li>..</ul>..</t
3560: 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 d><td>..<img src
3570: 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 ="http://www.gai
3580: 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 a-gis.it/gaia-si
3590: 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 ns/write-view-pi
35a0: 63 73 2f 73 6e 61 70 2d 74 6f 2d 67 72 69 64 2e cs/snap-to-grid.
35b0: 70 6e 67 22 20 61 6c 74 3d 22 73 6e 61 70 20 74 png" alt="snap t
35c0: 6f 20 67 72 69 64 22 3e 0d 0a 3c 2f 74 64 3e 3c o grid">..</td><
35d0: 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a /tr>..</table>..
35e0: 3c 62 72 3e 3c 68 72 3e 0d 0a 3c 74 61 62 6c 65 <br><hr>..<table
35f0: 20 62 67 63 6f 6c 6f 72 3d 22 23 64 37 66 66 66 bgcolor="#d7fff
3600: 66 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 f" cellspacing="
3610: 36 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 6" cellpadding="
3620: 31 30 22 20 77 69 64 74 68 3d 22 31 30 30 25 22 10" width="100%"
3630: 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 72 65 64 69 >..<tr><th>Credi
3640: 74 73 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 ts</th></tr>..<t
3650: 72 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 63 65 6e r><td align="cen
3660: 74 65 72 22 3e 0d 0a 54 68 69 73 20 77 6f 72 6b ter">..This work
3670: 20 28 65 78 70 6f 73 69 6e 67 20 3c 69 3e 6c 69 (exposing <i>li
3680: 62 6c 77 67 65 6f 6d 3c 2f 69 3e 20 41 50 49 73 blwgeom</i> APIs
3690: 20 61 73 20 53 70 61 74 69 61 4c 69 74 65 20 6f as SpatiaLite o
36a0: 77 6e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 wn SQL functions
36b0: 29 20 68 61 73 20 62 65 65 6e 20 65 6e 74 69 72 ) has been entir
36c0: 65 6c 79 20 66 75 6e 64 65 64 20 62 79 3a 3c 62 ely funded by:<b
36d0: 72 3e 0d 0a 3c 61 20 68 72 65 66 3d 22 68 74 74 r>..<a href="htt
36e0: 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61 p://en.wikipedia
36f0: 2e 6f 72 67 2f 77 69 6b 69 2f 54 75 73 63 61 6e .org/wiki/Tuscan
3700: 79 22 3e 54 75 73 63 61 6e 79 20 52 65 67 69 6f y">Tuscany Regio
3710: 6e 3c 2f 61 3e 20 2d 20 54 65 72 72 69 74 6f 72 n</a> - Territor
3720: 69 61 6c 20 61 6e 64 20 45 6e 76 69 72 6f 6e 6d ial and Environm
3730: 65 6e 74 61 6c 20 49 6e 66 6f 72 6d 61 74 69 6f ental Informatio
3740: 6e 20 53 79 73 74 65 6d 3c 62 72 3e 0d 0a 3c 61 n System<br>..<a
3750: 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 href="http://ww
3760: 77 2e 72 65 67 69 6f 6e 65 2e 74 6f 73 63 61 6e w.regione.toscan
3770: 61 2e 69 74 2f 61 6d 62 69 65 6e 74 65 65 74 65 a.it/ambienteete
3780: 72 72 69 74 6f 72 69 6f 2f 67 65 6f 67 72 61 66 rritorio/geograf
3790: 69 61 67 65 6f 6c 6f 67 69 61 2f 69 6e 64 65 78 iageologia/index
37a0: 2e 68 74 6d 6c 22 3e 52 65 67 69 6f 6e 65 20 54 .html">Regione T
37b0: 6f 73 63 61 6e 61 3c 2f 61 3e 20 2d 20 53 65 74 oscana</a> - Set
37c0: 74 6f 72 65 20 53 69 73 74 65 6d 61 20 49 6e 66 tore Sistema Inf
37d0: 6f 72 6d 61 74 69 76 6f 20 54 65 72 72 69 74 6f ormativo Territo
37e0: 72 69 61 6c 65 20 65 64 20 41 6d 62 69 65 6e 74 riale ed Ambient
37f0: 61 6c 65 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e ale...</td></tr>
3800: 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e ..</table>..<br>
3810: 3c 68 72 3e 0d 0a 3c 61 20 68 72 65 66 3d 22 68 <hr>..<a href="h
3820: 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d ttps://www.gaia-
3830: 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 gis.it/fossil/li
3840: 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 6b 69 bspatialite/wiki
3850: 3f 6e 61 6d 65 3d 34 2e 32 2e 30 2d 64 6f 63 22 ?name=4.2.0-doc"
3860: 3e 6d 61 69 6e 20 70 61 67 65 3c 2f 61 3e 0d 0a >main page</a>..
3870: 0a 5a 20 62 62 32 66 37 34 66 65 66 65 34 34 37 .Z bb2f74fefe447
3880: 32 63 36 30 36 62 64 31 64 31 38 39 65 66 33 62 2c606bd1d189ef3b
3890: 35 64 34 0a 5d4.