Wiki page
[liblwgeom-4.0] by
sandro
2012-08-30 19:15:49.
0000: 44 20 32 30 31 32 2d 30 38 2d 33 30 54 31 39 3a D 2012-08-30T19:
0010: 31 35 3a 34 39 2e 36 38 36 0a 4c 20 6c 69 62 6c 15:49.686.L libl
0020: 77 67 65 6f 6d 2d 34 2e 30 0a 50 20 35 31 38 34 wgeom-4.0.P 5184
0030: 61 63 39 65 33 61 39 64 31 32 61 36 63 63 65 63 ac9e3a9d12a6ccec
0040: 65 66 61 36 31 34 34 64 65 30 34 62 32 62 30 38 efa6144de04b2b08
0050: 35 30 61 33 0a 55 20 73 61 6e 64 72 6f 0a 57 20 50a3.U sandro.W
0060: 31 34 32 35 37 0a 3c 68 32 3e 53 51 4c 20 66 75 14257.<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 42 61 63 6b 20 74 0.0</h2>..Back t
00b0: 6f 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 73 o <a href="https
00c0: 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e ://www.gaia-gis.
00d0: 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61 it/fossil/libspa
00e0: 74 69 61 6c 69 74 65 2f 77 69 6b 69 3f 6e 61 6d tialite/wiki?nam
00f0: 65 3d 73 77 69 74 63 68 69 6e 67 2d 74 6f 2d 34 e=switching-to-4
0100: 2e 30 23 6c 69 62 6c 77 67 65 6f 6d 22 3e 6d 61 .0#liblwgeom">ma
0110: 69 6e 20 70 61 67 65 3c 2f 61 3e 0d 0a 3c 68 33 in page</a>..<h3
0120: 3e 4d 61 6b 69 6e 67 20 69 6e 76 61 6c 69 64 20 >Making invalid
0130: 47 65 6f 6d 65 74 72 69 65 73 20 74 6f 20 62 65 Geometries to be
0140: 63 6f 6d 65 20 70 65 72 66 65 63 74 6c 79 20 76 come perfectly v
0150: 61 6c 69 64 20 6f 6e 65 73 3c 2f 68 33 3e 0d 0a alid ones</h3>..
0160: 41 73 20 79 6f 75 20 61 6c 72 65 61 64 79 20 73 As you already s
0170: 75 72 65 6c 79 20 6b 6e 6f 77 2c 20 6e 6f 74 20 urely know, not
0180: 61 6c 6c 20 67 65 6f 6d 65 74 72 69 65 73 20 61 all geometries a
0190: 72 65 20 76 61 6c 69 64 20 6f 6e 65 73 3a 20 6d re valid ones: m
01a0: 6f 73 74 20 6e 6f 74 61 62 6c 79 20 69 6e 20 74 ost notably in t
01b0: 68 65 20 73 70 65 63 69 66 69 63 20 63 61 73 65 he specific case
01c0: 20 6f 66 20 50 6f 6c 79 67 6f 6e 61 6c 20 67 65 of Polygonal ge
01d0: 6f 6d 65 74 72 69 65 73 20 74 68 65 72 65 20 61 ometries there a
01e0: 72 65 20 6d 61 6e 79 20 64 65 74 61 69 6c 65 64 re many detailed
01f0: 20 72 75 6c 65 73 20 74 6f 20 62 65 20 72 65 73 rules to be res
0200: 70 65 63 74 65 64 2e 0d 0a 49 6e 66 72 69 6e 67 pected...Infring
0210: 69 6e 67 20 6f 6e 65 20 6f 66 20 73 75 63 68 20 ing one of such
0220: 72 75 6c 65 73 20 64 69 72 65 63 74 6c 79 20 6c rules directly l
0230: 65 61 64 73 20 74 6f 20 73 6f 6d 65 20 69 6e 76 eads to some inv
0240: 61 6c 69 64 20 47 65 6f 6d 65 74 72 79 3a 20 61 alid Geometry: a
0250: 6e 64 20 61 6e 20 69 6e 76 61 6c 69 64 20 47 65 nd an invalid Ge
0260: 6f 6d 65 74 72 79 20 63 6f 75 6c 64 20 63 61 75 ometry could cau
0270: 73 65 20 69 6e 76 61 6c 69 64 20 72 65 73 75 6c se invalid resul
0280: 74 73 20 74 6f 20 62 65 20 72 65 74 75 72 6e 65 ts to be returne
0290: 64 2c 20 6f 72 20 63 6f 75 6c 64 20 65 76 65 6e d, or could even
02a0: 74 75 61 6c 6c 79 20 63 61 75 73 65 20 73 6f 6d tually cause som
02b0: 65 20 75 6e 65 78 70 65 63 74 65 64 20 6e 61 73 e unexpected nas
02c0: 74 79 20 63 72 61 73 68 20 69 6e 20 74 68 65 20 ty crash in the
02d0: 77 6f 72 73 74 20 63 61 73 65 2e 3c 62 72 3e 3c worst case.<br><
02e0: 62 72 3e 0d 0a 47 45 4f 53 20 28 61 6e 64 20 74 br>..GEOS (and t
02f0: 68 75 73 20 53 70 61 74 69 61 4c 69 74 65 29 20 hus SpatiaLite)
0300: 61 6c 72 65 61 64 79 20 73 75 70 70 6f 72 74 20 already support
0310: 74 68 65 20 3c 62 3e 53 54 5f 49 73 56 61 6c 69 the <b>ST_IsVali
0320: 64 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 d()</b> SQL func
0330: 74 69 6f 6e 3b 20 62 79 20 69 6e 76 6f 6b 69 6e tion; by invokin
0340: 67 20 74 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 g this function
0350: 79 6f 75 20 63 61 6e 20 65 61 73 69 6c 79 20 69 you can easily i
0360: 64 65 6e 74 69 66 79 20 61 6c 6c 20 6f 66 66 65 dentify all offe
0370: 6e 64 69 6e 67 20 47 65 6f 6d 65 74 72 69 65 73 nding Geometries
0380: 20 65 76 65 6e 74 75 61 6c 6c 79 20 63 6f 6e 74 eventually cont
0390: 61 69 6e 65 64 20 77 69 74 68 69 6e 20 79 6f 75 ained within you
03a0: 72 20 74 61 62 6c 65 73 3b 20 61 6e 79 77 61 79 r tables; anyway
03b0: 20 79 6f 75 20 63 61 6e 6e 6f 74 20 61 74 74 65 you cannot atte
03c0: 6d 70 74 20 74 6f 20 3c 69 3e 73 61 6e 69 74 69 mpt to <i>saniti
03d0: 7a 65 3c 2f 69 3e 20 74 68 65 6d 2e 3c 62 72 3e ze</i> them.<br>
03e0: 0d 0a 53 70 61 74 69 61 4c 69 74 65 20 61 6c 72 ..SpatiaLite alr
03f0: 65 61 64 79 20 73 75 70 70 6f 72 74 65 64 20 61 eady supported a
0400: 20 3c 62 3e 53 54 5f 53 61 6e 69 74 69 7a 65 47 <b>ST_SanitizeG
0410: 65 6f 6d 65 74 72 79 28 29 3c 2f 62 3e 20 53 51 eometry()</b> SQ
0420: 4c 20 66 75 6e 63 74 69 6f 6e 3b 20 62 75 74 20 L function; but
0430: 74 68 69 73 20 77 61 73 20 73 69 6d 70 6c 79 20 this was simply
0440: 63 61 70 61 62 6c 65 20 74 6f 20 65 66 66 65 63 capable to effec
0450: 74 69 76 65 6c 79 20 72 65 73 6f 6c 76 65 20 6a tively resolve j
0460: 75 73 74 20 66 65 77 20 69 6e 76 61 6c 69 64 69 ust few invalidi
0470: 74 79 20 63 61 75 73 65 73 2c 20 61 6e 64 20 77 ty causes, and w
0480: 61 73 6e 27 74 20 61 74 20 61 6c 6c 20 61 20 67 asn't at all a g
0490: 65 6e 65 72 61 6c 20 73 6f 6c 75 74 69 6f 6e 20 eneral solution
04a0: 66 6f 72 20 74 68 69 73 20 70 72 6f 62 6c 65 6d for this problem
04b0: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 4e 6f 77 2c 20 .<br><br>..Now,
04c0: 74 68 61 6e 6b 73 20 74 6f 20 3c 69 3e 6c 69 62 thanks to <i>lib
04d0: 6c 77 67 65 6f 6d 3c 2f 69 3e 2c 20 53 70 61 74 lwgeom</i>, Spat
04e0: 69 61 4c 69 74 65 20 63 61 6e 20 73 75 70 70 6f iaLite can suppo
04f0: 72 74 20 74 68 65 20 73 61 6d 65 20 69 64 65 6e rt the same iden
0500: 74 69 63 61 6c 20 3c 62 3e 53 54 5f 4d 61 6b 65 tical <b>ST_Make
0510: 56 61 6c 69 64 28 29 3c 2f 62 3e 20 61 6c 72 65 Valid()</b> alre
0520: 61 64 79 20 73 75 70 70 6f 72 74 65 64 20 62 79 ady supported by
0530: 20 50 6f 73 74 47 49 53 3b 20 66 65 77 20 73 6d PostGIS; few sm
0540: 61 6c 6c 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 all implementati
0550: 6f 6e 20 64 65 74 61 69 6c 73 20 64 69 66 66 65 on details diffe
0560: 72 20 28 64 75 65 20 74 6f 20 74 68 65 20 68 75 r (due to the hu
0570: 67 65 20 61 72 63 68 69 74 65 63 74 75 72 61 6c ge architectural
0580: 20 64 69 66 66 65 72 65 6e 63 65 73 20 64 69 73 differences dis
0590: 74 69 6e 67 75 69 73 68 69 6e 67 20 50 6f 73 74 tinguishing Post
05a0: 47 49 53 20 61 6e 64 20 53 70 61 74 69 61 4c 69 GIS and SpatiaLi
05b0: 74 65 29 2c 20 62 75 74 20 74 68 65 20 75 6e 64 te), but the und
05c0: 65 72 6c 79 69 6e 67 20 63 6f 64 65 20 69 73 20 erlying code is
05d0: 65 78 61 63 74 65 6c 79 20 6f 6e 65 20 61 6e 64 exactely one and
05e0: 20 74 68 65 20 73 61 6d 65 20 66 6f 72 20 62 6f the same for bo
05f0: 74 68 2e 0d 0a 3c 68 34 3e 61 20 66 69 72 73 74 th...<h4>a first
0600: 20 62 61 73 69 63 20 65 78 61 6d 70 6c 65 3c 2f basic example</
0610: 68 34 3e 0d 0a 57 65 27 6c 6c 20 73 74 61 72 74 h4>..We'll start
0620: 20 6c 6f 61 64 69 6e 67 20 74 68 65 20 4c 6f 63 loading the Loc
0630: 61 6c 20 43 6f 75 6e 63 69 6c 73 20 61 64 6d 69 al Councils admi
0640: 6e 69 73 74 72 61 74 69 76 65 20 62 6f 75 6e 64 nistrative bound
0650: 61 72 69 65 73 20 73 75 70 70 6c 69 65 64 20 62 aries supplied b
0660: 79 20 49 53 54 41 54 20 28 74 68 65 20 49 74 61 y ISTAT (the Ita
0670: 6c 69 61 6e 20 4e 61 74 69 6f 6e 61 6c 20 53 74 lian National St
0680: 61 74 69 63 73 20 41 67 65 6e 63 79 29 3a 20 74 atics Agency): t
0690: 68 69 73 20 64 61 74 61 73 61 74 20 69 73 20 66 his datasat is f
06a0: 72 65 65 6c 79 20 61 76 61 69 6c 61 62 6c 65 20 reely available
06b0: 66 6f 72 20 3c 61 20 68 72 65 66 3d 22 68 74 74 for <a href="htt
06c0: 70 3a 2f 2f 77 77 77 2e 69 73 74 61 74 2e 69 74 p://www.istat.it
06d0: 2f 75 70 6c 6f 61 64 73 2f 63 6f 6d 32 30 31 31 /uploads/com2011
06e0: 2e 7a 69 70 22 3e 64 6f 77 6e 6c 6f 61 64 3c 2f .zip">download</
06f0: 61 3e 20 75 6e 64 65 72 20 61 20 43 43 2d 42 59 a> under a CC-BY
0700: 20 6c 69 63 65 6e 73 65 2e 0d 0a 4a 75 73 74 20 license...Just
0710: 61 20 71 75 69 63 6b 20 63 68 65 63 6b 2c 20 61 a quick check, a
0720: 6e 64 20 77 65 27 6c 6c 20 73 6f 6f 6e 20 64 69 nd we'll soon di
0730: 73 63 6f 76 65 72 20 74 68 61 74 20 74 68 69 73 scover that this
0740: 20 64 61 74 61 73 65 74 20 61 63 74 75 61 6c 6c dataset actuall
0750: 79 20 63 6f 6e 74 61 69 6e 73 20 73 65 76 65 72 y contains sever
0760: 61 6c 20 6d 61 6c 66 6f 72 6d 65 64 20 50 6f 6c al malformed Pol
0770: 79 67 6f 6e 73 3a 0d 0a 3c 74 61 62 6c 65 20 62 ygons:..<table b
0780: 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 gcolor="#e0e0e0"
0790: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
07a0: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 cellpadding="8"
07b0: 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e >..<tr><td>..<b>
07c0: 53 45 4c 45 43 54 20 43 6f 75 6e 74 28 2a 29 3c SELECT Count(*)<
07d0: 62 72 3e 0d 0a 46 52 4f 4d 20 63 6f 6d 32 30 31 br>..FROM com201
07e0: 31 3c 62 72 3e 0d 0a 57 48 45 52 45 20 53 54 5f 1<br>..WHERE ST_
07f0: 49 73 56 61 6c 69 64 28 67 65 6f 6d 65 74 72 79 IsValid(geometry
0800: 29 20 3d 20 30 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e ) = 0;</b>..<hr>
0810: 0d 0a 31 39 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e ..19..</td></tr>
0820: 0d 0a 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a ..</table><br>..
0830: 52 65 63 6f 76 65 72 69 6e 67 20 61 6c 6c 20 6d Recovering all m
0840: 61 6c 66 6f 72 6d 65 64 20 47 65 6f 6d 65 74 72 alformed Geometr
0850: 69 65 73 20 69 73 20 6e 6f 77 20 61 62 73 6f 6c ies is now absol
0860: 75 74 65 6c 79 20 73 69 6d 70 6c 65 20 61 6e 64 utely simple and
0870: 20 65 61 73 79 3a 0d 0a 3c 74 61 62 6c 65 20 62 easy:..<table b
0880: 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 gcolor="#e0e0e0"
0890: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
08a0: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 cellpadding="8"
08b0: 3e 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 55 50 ><tr><td>..<b>UP
08c0: 44 41 54 45 20 63 6f 6d 32 30 31 31 20 53 45 54 DATE com2011 SET
08d0: 20 67 65 6f 6d 65 74 72 79 20 3d 20 53 54 5f 4d geometry = ST_M
08e0: 61 6b 65 56 61 6c 69 64 28 67 65 6f 6d 65 74 72 akeValid(geometr
08f0: 79 29 3c 62 72 3e 0d 0a 57 48 45 52 45 20 53 54 y)<br>..WHERE ST
0900: 5f 49 73 56 61 6c 69 64 28 67 65 6f 6d 65 74 72 _IsValid(geometr
0910: 79 29 20 3d 20 30 3b 3c 2f 62 3e 0d 0a 3c 2f 74 y) = 0;</b>..</t
0920: 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 d></tr>..<tr><td
0930: 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 43 6f 75 >..<b>SELECT Cou
0940: 6e 74 28 2a 29 3c 62 72 3e 0d 0a 46 52 4f 4d 20 nt(*)<br>..FROM
0950: 63 6f 6d 32 30 31 31 3c 62 72 3e 0d 0a 57 48 45 com2011<br>..WHE
0960: 52 45 20 53 54 5f 49 73 56 61 6c 69 64 28 67 65 RE ST_IsValid(ge
0970: 6f 6d 65 74 72 79 29 20 3d 20 30 3b 3c 2f 62 3e ometry) = 0;</b>
0980: 0d 0a 3c 68 72 3e 0d 0a 30 0d 0a 3c 2f 74 64 3e ..<hr>..0..</td>
0990: 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 3c </tr>..</table><
09a0: 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 br>..<table bord
09b0: 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69 er="1" cellspaci
09c0: 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 ng="4" cellpaddi
09d0: 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 ng="4">..<tr><th
09e0: 20 63 6f 6c 73 70 61 6e 3d 22 32 22 3e 57 68 79 colspan="2">Why
09f0: 20 74 68 65 20 42 72 6f 6e 74 65 20 4c 6f 63 61 the Bronte Loca
0a00: 6c 20 43 6f 75 6e 63 69 6c 20 62 6f 75 6e 64 61 l Council bounda
0a10: 72 79 20 77 61 73 20 6d 61 6c 66 6f 72 6d 65 64 ry was malformed
0a20: 20 3f 3c 62 72 3e 0d 0a 61 20 71 75 69 63 6b 20 ?<br>..a quick
0a30: 61 6e 61 6c 79 73 69 73 3c 2f 74 68 3e 3c 2f 74 analysis</th></t
0a40: 72 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 6d 61 6c 66 r>..<tr><th>malf
0a50: 6f 72 6d 65 64 20 2f 20 69 6e 76 61 6c 69 64 3c ormed / invalid<
0a60: 2f 74 68 3e 3c 74 68 3e 76 61 6c 69 64 3c 2f 74 /th><th>valid</t
0a70: 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 h></tr>..<tr><td
0a80: 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 >..<img src="htt
0a90: 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 p://www.gaia-gis
0aa0: 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 72 .it/gaia-sins/wr
0ab0: 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f 62 72 ite-view-pics/br
0ac0: 6f 6e 74 65 2d 69 6e 76 61 6c 69 64 2e 70 6e 67 onte-invalid.png
0ad0: 22 20 61 6c 74 3d 22 62 72 6f 6e 74 65 20 69 6e " alt="bronte in
0ae0: 76 61 6c 69 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 74 valid">..</td><t
0af0: 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 d>..<img src="ht
0b00: 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 tp://www.gaia-gi
0b10: 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 s.it/gaia-sins/w
0b20: 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f 62 rite-view-pics/b
0b30: 72 6f 6e 74 65 2d 76 61 6c 69 64 2e 70 6e 67 22 ronte-valid.png"
0b40: 20 61 6c 74 3d 22 62 72 6f 6e 74 65 20 76 61 6c alt="bronte val
0b50: 69 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e id">..</td></tr>
0b60: 0d 0a 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61 ..<tr><td colspa
0b70: 6e 3d 22 32 22 3e 0d 0a 41 73 20 79 6f 75 20 63 n="2">..As you c
0b80: 61 6e 20 65 61 73 69 6c 79 20 6e 6f 74 69 63 65 an easily notice
0b90: 2c 20 74 68 65 20 3c 69 3e 69 6e 76 61 6c 69 64 , the <i>invalid
0ba0: 3c 2f 69 3e 20 70 6f 6c 79 67 6f 6e 20 77 61 73 </i> polygon was
0bb0: 20 73 69 6d 70 6c 79 20 72 65 70 72 65 73 65 6e simply represen
0bc0: 74 20 62 79 20 74 68 65 20 3c 69 3e 65 78 74 65 t by the <i>exte
0bd0: 72 69 6f 72 20 72 69 6e 67 3c 2f 69 3e 3a 20 62 rior ring</i>: b
0be0: 75 74 20 74 68 65 72 65 20 69 73 20 61 20 68 75 ut there is a hu
0bf0: 67 65 20 69 6e 74 65 72 6e 61 6c 20 68 6f 6c 65 ge internal hole
0c00: 20 69 6e 20 74 68 69 73 20 50 6f 6c 79 67 6f 6e in this Polygon
0c10: 2e 0d 0a 54 68 69 73 20 6f 64 64 20 63 6f 6e 64 ...This odd cond
0c20: 69 74 69 6f 6e 20 69 73 20 72 65 70 75 74 65 64 ition is reputed
0c30: 20 70 65 72 66 65 63 74 6c 79 20 76 61 6c 69 64 perfectly valid
0c40: 20 62 79 20 73 6f 6d 65 20 6d 61 69 6e 73 74 72 by some mainstr
0c50: 65 61 6d 20 70 72 6f 70 72 69 65 74 61 72 79 20 eam proprietary
0c60: 73 6f 66 74 77 61 72 65 3b 20 61 6e 79 77 61 79 software; anyway
0c70: 2c 20 69 73 20 61 63 74 75 61 6c 6c 79 20 3c 69 , is actually <i
0c80: 3e 69 6e 76 61 6c 69 64 3c 2f 69 3e 20 61 63 63 >invalid</i> acc
0c90: 6f 72 64 69 6e 67 6c 79 20 74 6f 20 73 74 61 6e ordingly to stan
0ca0: 64 61 72 64 20 72 75 6c 65 73 2e 3c 62 72 3e 0d dard rules.<br>.
0cb0: 0a 53 6f 20 74 68 65 20 63 6f 72 72 65 63 74 20 .So the correct
0cc0: 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 20 66 representation f
0cd0: 6f 72 20 74 68 69 73 20 50 6f 6c 79 67 6f 6e 20 or this Polygon
0ce0: 72 65 71 75 69 72 65 73 20 61 6e 20 3c 69 3e 65 requires an <i>e
0cf0: 78 74 65 72 69 6f 72 20 72 69 6e 67 3c 2f 69 3e xterior ring</i>
0d00: 20 61 6e 64 20 61 20 73 65 70 61 72 61 74 65 20 and a separate
0d10: 3c 69 3e 69 6e 74 65 72 69 6f 72 20 72 69 6e 67 <i>interior ring
0d20: 3c 2f 69 3e 3b 20 53 54 5f 4d 61 6b 65 56 61 6c </i>; ST_MakeVal
0d30: 69 64 28 29 20 64 6f 65 73 20 74 68 65 20 6d 61 id() does the ma
0d40: 67 69 63 2c 20 74 68 75 73 20 72 65 63 6f 76 65 gic, thus recove
0d50: 72 69 6e 67 20 61 20 66 75 6c 6c 20 76 61 6c 69 ring a full vali
0d60: 64 20 50 6f 6c 79 67 6f 6e 2e 0d 0a 3c 2f 74 64 d Polygon...</td
0d70: 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e ></tr>..</table>
0d80: 0d 0a 3c 68 34 3e 61 20 73 65 63 6f 6e 64 20 6d ..<h4>a second m
0d90: 6f 72 65 20 65 6c 61 62 6f 72 61 74 65 20 65 78 ore elaborate ex
0da0: 61 6d 70 6c 65 3c 2f 68 34 3e 0d 0a 54 68 69 73 ample</h4>..This
0db0: 20 74 69 6d 65 20 77 65 27 6c 6c 20 70 75 72 70 time we'll purp
0dc0: 6f 73 65 6c 79 20 63 72 65 61 74 65 20 61 20 73 osely create a s
0dd0: 65 76 65 72 65 6c 79 20 6d 61 6c 66 6f 72 6d 65 everely malforme
0de0: 64 20 50 6f 6c 79 67 6f 6e 3a 0d 0a 3c 74 61 62 d Polygon:..<tab
0df0: 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 65 30 65 le bgcolor="#e0e
0e00: 30 65 30 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 0e0" cellspacing
0e10: 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 ="4" cellpadding
0e20: 3d 22 38 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d ="8">..<tr><td>.
0e30: 0a 3c 62 3e 53 45 4c 45 43 54 20 67 2c 20 53 54 .<b>SELECT g, ST
0e40: 5f 4d 61 6b 65 56 61 6c 69 64 28 67 29 2c 20 53 _MakeValid(g), S
0e50: 54 5f 4d 61 6b 65 56 61 6c 69 64 44 69 73 63 61 T_MakeValidDisca
0e60: 72 64 65 64 28 67 29 3c 62 72 3e 0d 0a 46 52 4f rded(g)<br>..FRO
0e70: 4d 20 28 3c 62 72 3e 0d 0a 53 45 4c 45 43 54 20 M (<br>..SELECT
0e80: 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 ST_GeomFromText(
0e90: 27 50 4f 4c 59 47 4f 4e 28 28 30 20 30 2c 20 30 'POLYGON((0 0, 0
0ea0: 20 31 30 2c 20 31 31 20 31 30 2c 20 31 30 20 31 10, 11 10, 10 1
0eb0: 30 2c 20 31 30 20 31 2c 20 35 20 31 2c 20 35 20 0, 10 1, 5 1, 5
0ec0: 39 2c 20 35 20 31 2c 20 30 20 31 2c 20 30 20 30 9, 5 1, 0 1, 0 0
0ed0: 29 29 27 29 20 41 53 20 67 3c 62 72 3e 0d 0a 29 ))') AS g<br>..)
0ee0: 3b 3c 2f 62 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 ;</b>..</td></tr
0ef0: 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d >..</table><br>.
0f00: 0a 3c 74 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 .<table cellspac
0f10: 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 ing="4" cellpadd
0f20: 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 ing="4">..<tr><t
0f30: 64 3e 0d 0a 54 68 69 73 20 66 69 67 75 72 65 20 d>..This figure
0f40: 72 65 70 72 65 73 65 6e 74 73 20 74 68 65 20 3c represents the <
0f50: 69 3e 69 6e 76 61 6c 69 64 3c 2f 69 3e 20 50 6f i>invalid</i> Po
0f60: 6c 79 67 6f 6e 20 72 65 74 75 72 6e 65 64 20 62 lygon returned b
0f70: 79 20 3c 62 3e 53 54 5f 47 65 6f 6d 46 72 6f 6d y <b>ST_GeomFrom
0f80: 54 65 78 74 28 29 3c 2f 62 3e 2e 3c 62 72 3e 3c Text()</b>.<br><
0f90: 62 72 3e 0d 0a 54 68 65 72 65 20 61 72 65 20 74 br>..There are t
0fa0: 68 72 65 65 20 3c 69 3e 73 70 69 6b 65 73 3c 2f hree <i>spikes</
0fb0: 69 3e 20 69 6e 20 74 68 65 20 3c 69 3e 65 78 74 i> in the <i>ext
0fc0: 65 72 69 6f 72 20 72 69 6e 67 3c 2f 69 3e 2c 20 erior ring</i>,
0fd0: 61 6e 64 20 74 68 69 73 20 6f 6e 65 20 73 75 72 and this one sur
0fe0: 65 6c 79 20 69 73 20 61 20 73 65 76 65 72 65 20 ely is a severe
0ff0: 69 6e 76 61 6c 69 64 69 74 79 20 63 61 75 73 65 invalidity cause
1000: 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 ...</td><td>..<i
1010: 6d 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 mg src="http://w
1020: 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 ww.gaia-gis.it/g
1030: 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 aia-sins/write-v
1040: 69 65 77 2d 70 69 63 73 2f 73 70 69 6b 65 2d 69 iew-pics/spike-i
1050: 6e 76 61 6c 69 64 2e 70 6e 67 22 20 61 6c 74 3d nvalid.png" alt=
1060: 22 73 70 69 6b 65 20 69 6e 76 61 6c 69 64 22 3e "spike invalid">
1070: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 ..</td></tr>..<t
1080: 72 3e 3c 74 64 3e 0d 0a 54 68 69 73 20 66 69 67 r><td>..This fig
1090: 75 72 65 20 72 65 70 72 65 73 65 6e 74 73 20 74 ure represents t
10a0: 68 65 20 3c 69 3e 76 61 6c 69 64 3c 2f 69 3e 20 he <i>valid</i>
10b0: 50 6f 6c 79 67 6f 6e 20 72 65 74 75 72 6e 65 64 Polygon returned
10c0: 20 62 79 20 3c 62 3e 53 54 5f 4d 61 6b 65 56 61 by <b>ST_MakeVa
10d0: 6c 69 64 28 29 3c 2f 62 3e 2e 3c 62 72 3e 3c 62 lid()</b>.<br><b
10e0: 72 3e 0d 0a 4e 6f 77 20 77 65 20 68 61 76 65 20 r>..Now we have
10f0: 61 20 6e 69 63 65 20 72 65 67 75 6c 61 72 20 72 a nice regular r
1100: 65 63 74 61 6e 67 6c 65 2c 20 61 6c 6c 20 3c 69 ectangle, all <i
1110: 3e 73 70 69 6b 65 73 3c 2f 69 3e 20 68 61 76 65 >spikes</i> have
1120: 20 62 65 65 6e 20 72 65 6d 6f 76 65 64 2e 0d 0a been removed...
1130: 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 </td><td>..<img
1140: 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e src="http://www.
1150: 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 gaia-gis.it/gaia
1160: 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 -sins/write-view
1170: 2d 70 69 63 73 2f 73 70 69 6b 65 2d 76 61 6c 69 -pics/spike-vali
1180: 64 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 69 6b d.png" alt="spik
1190: 65 20 76 61 6c 69 64 22 3e 0d 0a 3c 2f 74 64 3e e valid">..</td>
11a0: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d </tr>..<tr><td>.
11b0: 0a 41 6e 79 77 61 79 20 74 68 65 20 72 65 6d 6f .Anyway the remo
11c0: 76 65 64 20 3c 69 3e 73 70 69 6b 65 73 3c 2f 69 ved <i>spikes</i
11d0: 3e 20 61 72 65 6e 27 74 20 73 69 6d 70 6c 79 20 > aren't simply
11e0: 76 61 6e 69 73 68 65 64 20 69 6e 74 6f 20 6e 6f vanished into no
11f0: 74 68 69 6e 67 2e 0d 0a 59 6f 75 20 63 6f 75 6c thing...You coul
1200: 64 20 65 76 65 6e 74 75 61 6c 6c 79 20 72 65 74 d eventually ret
1210: 72 69 65 76 65 20 28 61 6e 64 20 6d 61 79 20 62 rieve (and may b
1220: 65 2c 20 73 61 76 69 6e 67 20 73 6f 6d 65 77 68 e, saving somewh
1230: 65 72 65 29 20 61 6c 6c 20 6f 66 66 65 6e 64 69 ere) all offendi
1240: 6e 67 20 65 6c 65 6d 65 6e 74 73 20 62 65 69 6e ng elements bein
1250: 67 20 64 69 73 63 61 72 64 65 64 20 64 75 72 69 g discarded duri
1260: 6e 67 20 74 68 65 20 76 61 6c 69 64 61 74 69 6f ng the validatio
1270: 6e 20 70 72 6f 63 65 73 73 2e 3c 62 72 3e 3c 62 n process.<br><b
1280: 72 3e 0d 0a 59 6f 75 20 73 69 6d 70 6c 79 20 68 r>..You simply h
1290: 61 76 65 20 74 6f 20 69 6e 76 6f 6b 65 20 3c 62 ave to invoke <b
12a0: 3e 53 54 5f 4d 61 6b 65 56 61 6c 69 64 44 69 73 >ST_MakeValidDis
12b0: 63 61 72 64 65 64 28 29 3c 2f 62 3e 3c 62 72 3e carded()</b><br>
12c0: 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 <br>..<u>Please
12d0: 6e 6f 74 65 3c 2f 75 3e 3a 20 74 68 69 73 20 69 note</u>: this i
12e0: 73 20 73 74 72 6f 6e 67 6c 79 20 64 69 66 66 65 s strongly diffe
12f0: 72 65 6e 74 20 66 72 6f 6d 20 74 68 65 20 50 6f rent from the Po
1300: 73 74 47 49 53 20 6f 77 6e 20 69 6d 70 6c 65 6d stGIS own implem
1310: 65 6e 74 61 74 69 6f 6e 2e 0d 0a 3c 2f 74 64 3e entation...</td>
1320: 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 <td>..<img src="
1330: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d http://www.gaia-
1340: 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 gis.it/gaia-sins
1350: 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 /write-view-pics
1360: 2f 73 70 69 6b 65 2d 64 69 73 63 61 72 64 65 64 /spike-discarded
1370: 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 69 6b 65 .png" alt="spike
1380: 20 64 69 73 63 61 72 64 65 64 22 3e 0d 0a 3c 2f discarded">..</
1390: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c td></tr>..</tabl
13a0: 65 3e 0d 0a 3c 62 72 3e 3c 68 72 3e 0d 0a 3c 68 e>..<br><hr>..<h
13b0: 33 3e 53 70 6c 69 74 74 69 6e 67 20 67 65 6f 6d 3>Splitting geom
13c0: 65 74 72 69 65 73 20 69 6e 20 74 77 6f 20 68 61 etries in two ha
13d0: 6c 76 65 73 3c 2f 68 33 3e 0d 0a 54 68 65 20 3c lves</h3>..The <
13e0: 62 3e 53 54 5f 53 70 6c 69 74 28 29 3c 2f 62 3e b>ST_Split()</b>
13f0: 20 53 70 61 74 69 61 6c 20 53 51 4c 20 66 75 6e Spatial SQL fun
1400: 63 74 69 6f 6e 20 69 73 20 69 6e 74 65 6e 64 65 ction is intende
1410: 64 20 74 6f 20 3c 69 3e 63 75 74 3c 2f 69 3e 20 d to <i>cut</i>
1420: 61 20 47 65 6f 6d 65 74 72 79 2e 3c 62 72 3e 0d a Geometry.<br>.
1430: 0a 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 61 .This function a
1440: 6c 77 61 79 73 20 72 65 71 75 69 72 65 73 20 74 lways requires t
1450: 6f 20 70 61 73 73 20 74 77 6f 20 64 69 66 66 65 o pass two diffe
1460: 72 65 6e 74 20 47 65 6f 6d 65 74 72 69 65 73 3a rent Geometries:
1470: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 74 68 65 20 66 69 <ul>..<li>the fi
1480: 72 73 74 20 47 65 6f 6d 65 74 72 79 20 69 73 20 rst Geometry is
1490: 61 73 73 75 6d 65 64 20 74 6f 20 72 65 70 72 65 assumed to repre
14a0: 73 65 6e 74 20 74 68 65 20 3c 62 3e 69 6e 70 75 sent the <b>inpu
14b0: 74 3c 2f 62 3e 20 61 6b 61 20 3c 62 3e 74 61 72 t</b> aka <b>tar
14c0: 67 65 74 3c 2f 62 3e 20 74 6f 20 62 65 20 73 70 get</b> to be sp
14d0: 6c 69 74 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 lit.</li>..<li>t
14e0: 68 65 20 73 65 63 6f 6e 64 20 47 65 6f 6d 65 74 he second Geomet
14f0: 72 79 20 69 73 20 61 73 73 75 6d 65 64 20 74 6f ry is assumed to
1500: 20 72 65 70 72 65 73 65 6e 74 20 74 68 65 20 3c represent the <
1510: 62 3e 62 6c 61 64 65 3c 2f 62 3e 2e 3c 2f 6c 69 b>blade</b>.</li
1520: 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 4f 6e 6c 79 20 74 >..</ul>..Only t
1530: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f 6e he following con
1540: 66 69 67 75 72 61 74 69 6f 6e 73 20 61 72 65 20 figurations are
1550: 61 73 73 75 6d 65 64 20 74 6f 20 62 65 20 76 61 assumed to be va
1560: 6c 69 64 3a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 4c 69 lid:<ul>..<li>Li
1570: 6e 65 73 74 72 69 6e 67 20 74 61 72 67 65 74 20 nestring target
1580: 2f 20 50 6f 69 6e 74 20 62 6c 61 64 65 2e 3c 2f / Point blade.</
1590: 6c 69 3e 0d 0a 3c 6c 69 3e 4d 75 6c 74 69 4c 69 li>..<li>MultiLi
15a0: 6e 65 73 74 72 69 6e 67 20 74 61 72 67 65 74 20 nestring target
15b0: 2f 20 50 6f 69 6e 74 20 62 6c 61 64 65 2e 3c 2f / Point blade.</
15c0: 6c 69 3e 0d 0a 3c 6c 69 3e 47 65 6f 6d 65 74 72 li>..<li>Geometr
15d0: 79 43 6f 6c 6c 65 63 74 69 6f 6e 20 28 63 6f 6e yCollection (con
15e0: 74 61 69 6e 69 6e 67 20 61 74 20 6c 65 61 73 74 taining at least
15f0: 20 6f 6e 65 20 4c 69 6e 65 73 74 72 69 6e 67 29 one Linestring)
1600: 20 2f 20 50 6f 69 6e 74 20 62 6c 61 64 65 2e 3c / Point blade.<
1610: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4c 69 6e 65 73 74 /li>..<li>Linest
1620: 72 69 6e 67 20 74 61 72 67 65 74 20 2f 20 4c 69 ring target / Li
1630: 6e 65 73 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c nestring blade.<
1640: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4d 75 6c 74 69 4c /li>..<li>MultiL
1650: 69 6e 65 73 74 72 69 6e 67 20 74 61 72 67 65 74 inestring target
1660: 20 2f 20 4c 69 6e 65 73 74 72 69 6e 67 20 62 6c / Linestring bl
1670: 61 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 50 ade.</li>..<li>P
1680: 6f 6c 79 67 6f 6e 20 74 61 72 67 65 74 20 2f 20 olygon target /
1690: 4c 69 6e 65 73 74 72 69 6e 67 20 62 6c 61 64 65 Linestring blade
16a0: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4d 75 6c 74 .</li>..<li>Mult
16b0: 69 50 6f 6c 79 67 6f 6e 20 74 61 72 67 65 74 20 iPolygon target
16c0: 2f 20 4c 69 6e 65 73 74 72 69 6e 67 20 62 6c 61 / Linestring bla
16d0: 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 47 65 de.</li>..<li>Ge
16e0: 6f 6d 65 74 72 79 43 6f 6c 6c 65 63 74 69 6f 6e ometryCollection
16f0: 20 2f 20 4c 69 6e 65 73 74 72 69 6e 67 20 62 6c / Linestring bl
1700: 61 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 50 ade.</li>..<li>P
1710: 6c 65 61 73 65 20 6e 6f 74 69 63 65 3a 20 74 68 lease notice: th
1720: 65 20 74 61 72 67 65 74 20 47 65 6f 6d 65 74 72 e target Geometr
1730: 79 20 73 68 6f 75 6c 64 20 6e 65 76 65 72 20 63 y should never c
1740: 6f 6e 74 61 69 6e 20 61 20 50 6f 69 6e 74 2e 3c ontain a Point.<
1750: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 68 34 /li>..</ul>..<h4
1760: 3e 45 78 61 6d 70 6c 65 20 23 31 20 2d 20 73 70 >Example #1 - sp
1770: 6c 6c 74 74 69 6e 67 20 61 20 4c 69 6e 65 73 74 lltting a Linest
1780: 72 69 6e 67 20 62 79 20 61 20 50 6f 69 6e 74 20 ring by a Point
1790: 62 6c 61 64 65 3c 2f 68 34 3e 0d 0a 3c 74 61 62 blade</h4>..<tab
17a0: 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 65 30 65 le bgcolor="#e0e
17b0: 30 65 30 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 0e0" cellspacing
17c0: 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 ="4" cellpadding
17d0: 3d 22 38 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d ="8">..<tr><td>.
17e0: 0a 3c 62 3e 53 45 4c 45 43 54 20 53 54 5f 53 70 .<b>SELECT ST_Sp
17f0: 6c 69 74 28 69 6e 70 75 74 2e 67 2c 20 62 6c 61 lit(input.g, bla
1800: 64 65 2e 67 29 2c 20 53 54 5f 53 70 6c 69 74 4c de.g), ST_SplitL
1810: 65 66 74 28 69 6e 70 75 74 2e 67 2c 20 62 6c 61 eft(input.g, bla
1820: 64 65 2e 67 29 2c 20 53 54 5f 53 70 6c 69 74 52 de.g), ST_SplitR
1830: 69 67 68 74 28 69 6e 70 75 74 2e 67 2c 20 62 6c ight(input.g, bl
1840: 61 64 65 2e 67 29 3c 62 72 3e 0d 0a 46 52 4f 4d ade.g)<br>..FROM
1850: 3c 62 72 3e 20 0d 0a 28 53 45 4c 45 43 54 20 47 <br> ..(SELECT G
1860: 65 6f 6d 46 72 6f 6d 54 65 78 74 28 27 4c 49 4e eomFromText('LIN
1870: 45 53 54 52 49 4e 47 28 30 20 31 30 2c 20 32 20 ESTRING(0 10, 2
1880: 30 2c 20 34 20 34 2c 20 36 20 30 2c 20 31 30 20 0, 4 4, 6 0, 10
1890: 31 30 29 27 29 20 41 53 20 67 29 20 41 53 20 69 10)') AS g) AS i
18a0: 6e 70 75 74 2c 3c 62 72 3e 0d 0a 28 53 45 4c 45 nput,<br>..(SELE
18b0: 43 54 20 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 CT GeomFromText(
18c0: 27 50 4f 49 4e 54 28 33 20 32 29 27 29 20 41 53 'POINT(3 2)') AS
18d0: 20 67 29 20 41 53 20 62 6c 61 64 65 3b 3c 2f 62 g) AS blade;</b
18e0: 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 >..</td></tr></t
18f0: 61 62 6c 65 3e 0d 0a 3c 74 61 62 6c 65 20 63 65 able>..<table ce
1900: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 llspacing="4" ce
1910: 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a llpadding="4">..
1920: 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 20 3c 62 <tr><td>..The <b
1930: 3e 53 54 5f 53 70 6c 69 74 28 29 3c 2f 62 3e 20 >ST_Split()</b>
1940: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c SQL function wil
1950: 6c 20 73 69 6d 70 6c 79 20 72 65 74 75 72 6e 20 l simply return
1960: 61 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f 6e 3c a <i>collection<
1970: 2f 69 3e 20 61 67 67 72 65 67 61 74 69 6e 67 20 /i> aggregating
1980: 61 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 64 65 all fragments de
1990: 72 69 76 69 6e 67 20 66 72 6f 6d 20 74 68 65 20 riving from the
19a0: 63 75 74 2e 3c 62 72 3e 0d 0a 54 68 69 73 20 69 cut.<br>..This i
19b0: 73 6e 27 74 20 72 65 61 6c 6c 79 20 75 73 65 66 sn't really usef
19c0: 75 6c 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 3e ul.<br><br>..<u>
19d0: 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a Please note</u>:
19e0: 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f 6e 73 3c <i>collections<
19f0: 2f 69 3e 20 69 6e 20 53 70 61 74 69 61 4c 69 74 /i> in SpatiaLit
1a00: 65 20 62 65 68 61 76 65 20 71 75 69 74 65 20 64 e behave quite d
1a10: 69 66 66 65 6e 74 6c 79 20 66 72 6f 6d 20 50 6f iffently from Po
1a20: 73 74 47 69 73 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 stGis...</td><td
1a30: 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 >..<img src="htt
1a40: 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 p://www.gaia-gis
1a50: 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 72 .it/gaia-sins/wr
1a60: 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f 73 70 ite-view-pics/sp
1a70: 6c 69 74 2d 6c 6e 2e 70 6e 67 22 20 61 6c 74 3d lit-ln.png" alt=
1a80: 22 73 70 6c 69 74 20 6c 69 6e 65 22 3e 0d 0a 3c "split line">..<
1a90: 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /td></tr>..<tr><
1aa0: 74 64 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 td>..The <b>ST_S
1ab0: 70 6c 69 74 4c 65 66 74 28 29 3c 2f 62 3e 20 53 plitLeft()</b> S
1ac0: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c QL function will
1ad0: 20 72 65 74 75 72 6e 20 69 6e 73 74 65 61 64 20 return instead
1ae0: 61 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f 6e 3c a <i>collection<
1af0: 2f 69 3e 20 61 67 67 72 65 67 61 74 69 6e 67 20 /i> aggregating
1b00: 61 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 6c 61 all fragments la
1b10: 79 69 6e 67 20 6f 6e 20 74 68 65 20 3c 69 3e 6c ying on the <i>l
1b20: 65 66 74 3c 2f 69 3e 20 73 69 64 65 20 6f 66 20 eft</i> side of
1b30: 74 68 65 20 63 75 74 2e 3c 62 72 3e 0d 0a 46 6f the cut.<br>..Fo
1b40: 72 20 4c 69 6e 65 73 74 72 69 6e 67 73 20 79 6f r Linestrings yo
1b50: 75 20 63 61 6e 6e 6f 74 20 69 6e 74 65 6e 64 20 u cannot intend
1b60: 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 69 6e 20 74 <i>left</i> in t
1b70: 68 65 20 76 65 72 79 20 6c 69 74 65 72 61 6c 20 he very literal
1b80: 73 65 6e 73 65 3b 20 74 68 69 73 20 72 65 61 6c sense; this real
1b90: 6c 79 20 6d 65 61 6e 73 20 3c 69 3e 74 68 65 20 ly means <i>the
1ba0: 73 69 64 65 20 77 68 65 72 65 20 74 68 65 20 73 side where the s
1bb0: 74 61 72 74 2d 70 6f 69 6e 74 20 6c 61 79 3c 2f tart-point lay</
1bc0: 69 3e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 3e i>.<br><br>..<u>
1bd0: 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a Please note</u>:
1be0: 20 69 66 20 74 68 65 20 3c 69 3e 62 6c 61 64 65 if the <i>blade
1bf0: 3c 2f 69 3e 20 64 6f 65 73 6e 27 74 20 69 6e 74 </i> doesn't int
1c00: 65 72 63 65 70 74 73 20 74 68 65 20 74 61 72 67 ercepts the targ
1c10: 65 74 20 61 74 20 61 6c 6c 2c 20 74 68 61 6e 20 et at all, than
1c20: 6e 6f 20 63 75 74 20 77 6f 75 6c 64 20 62 65 20 no cut would be
1c30: 6f 62 76 69 6f 75 73 6c 79 20 70 6f 73 73 69 62 obviously possib
1c40: 6c 65 2e 20 49 6e 20 74 68 69 73 20 73 70 65 63 le. In this spec
1c50: 69 61 6c 20 63 61 73 65 20 74 68 65 20 6f 72 69 ial case the ori
1c60: 67 69 6e 61 6c 20 74 61 72 67 65 74 20 47 65 6f ginal target Geo
1c70: 6d 65 74 72 79 20 77 69 6c 6c 20 62 65 20 61 6c metry will be al
1c80: 77 61 79 73 20 72 65 74 75 72 6e 65 64 20 28 61 ways returned (a
1c90: 62 73 6f 6c 75 74 65 6c 79 20 75 6e 63 68 61 6e bsolutely unchan
1ca0: 67 65 64 29 20 6f 6e 20 74 68 65 20 3c 69 3e 6c ged) on the <i>l
1cb0: 65 66 74 3c 2f 69 3e 20 73 69 64 65 20 63 6f 6c eft</i> side col
1cc0: 6c 65 63 74 69 6f 6e 2e 0d 0a 3c 2f 74 64 3e 3c lection...</td><
1cd0: 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 td>..<img src="h
1ce0: 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 ttp://www.gaia-g
1cf0: 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f is.it/gaia-sins/
1d00: 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f write-view-pics/
1d10: 73 70 6c 69 74 2d 6c 6e 2d 4c 2e 70 6e 67 22 20 split-ln-L.png"
1d20: 61 6c 74 3d 22 73 70 6c 69 74 2d 6c 65 66 74 20 alt="split-left
1d30: 6c 69 6e 65 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 line">..</td></t
1d40: 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 r>..<tr><td>..Th
1d50: 65 20 3c 62 3e 53 54 5f 53 70 6c 69 74 52 69 67 e <b>ST_SplitRig
1d60: 68 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e ht()</b> SQL fun
1d70: 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 74 75 72 ction will retur
1d80: 6e 20 61 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f n a <i>collectio
1d90: 6e 3c 2f 69 3e 20 61 67 67 72 65 67 61 74 69 6e n</i> aggregatin
1da0: 67 20 61 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 g all fragments
1db0: 6c 61 79 69 6e 67 20 6f 6e 20 74 68 65 20 3c 69 laying on the <i
1dc0: 3e 72 69 67 68 74 3c 2f 69 3e 20 73 69 64 65 20 >right</i> side
1dd0: 6f 66 20 74 68 65 20 63 75 74 2e 3c 62 72 3e 0d of the cut.<br>.
1de0: 0a 46 6f 72 20 4c 69 6e 65 73 74 72 69 6e 67 73 .For Linestrings
1df0: 20 79 6f 75 20 63 61 6e 6e 6f 74 20 69 6e 74 65 you cannot inte
1e00: 6e 64 20 3c 69 3e 72 69 67 68 74 3c 2f 69 3e 20 nd <i>right</i>
1e10: 69 6e 20 74 68 65 20 76 65 72 79 20 6c 69 74 65 in the very lite
1e20: 72 61 6c 20 73 65 6e 73 65 3b 20 74 68 69 73 20 ral sense; this
1e30: 72 65 61 6c 6c 79 20 6d 65 61 6e 73 20 3c 69 3e really means <i>
1e40: 74 68 65 20 73 69 64 65 20 77 68 65 72 65 20 74 the side where t
1e50: 68 65 20 65 6e 64 2d 70 6f 69 6e 74 20 6c 61 79 he end-point lay
1e60: 3c 2f 69 3e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c </i>.<br><br>..<
1e70: 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 u>Please note</u
1e80: 3e 3a 20 69 66 20 74 68 65 20 3c 69 3e 62 6c 61 >: if the <i>bla
1e90: 64 65 3c 2f 69 3e 20 64 6f 65 73 6e 27 74 20 69 de</i> doesn't i
1ea0: 6e 74 65 72 63 65 70 74 73 20 74 68 65 20 74 61 ntercepts the ta
1eb0: 72 67 65 74 20 61 74 20 61 6c 6c 2c 20 74 68 61 rget at all, tha
1ec0: 6e 20 6e 6f 20 63 75 74 20 77 6f 75 6c 64 20 62 n no cut would b
1ed0: 65 20 6f 62 76 69 6f 75 73 6c 79 20 70 6f 73 73 e obviously poss
1ee0: 69 62 6c 65 2e 20 49 6e 20 74 68 69 73 20 73 70 ible. In this sp
1ef0: 65 63 69 61 6c 20 63 61 73 65 20 74 68 65 20 3c ecial case the <
1f00: 69 3e 72 69 67 68 74 3c 2f 69 3e 20 73 69 64 65 i>right</i> side
1f10: 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 77 69 6c 6c collection will
1f20: 20 62 65 20 4e 55 4c 4c 2e 0d 0a 3c 2f 74 64 3e be NULL...</td>
1f30: 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 <td>..<img src="
1f40: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d http://www.gaia-
1f50: 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 gis.it/gaia-sins
1f60: 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 /write-view-pics
1f70: 2f 73 70 6c 69 74 2d 6c 6e 2d 52 2e 70 6e 67 22 /split-ln-R.png"
1f80: 20 61 6c 74 3d 22 73 70 6c 69 74 2d 72 69 67 68 alt="split-righ
1f90: 74 20 6c 69 6e 65 22 3e 0d 0a 3c 2f 74 64 3e 3c t line">..</td><
1fa0: 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a /tr>..</table>..
1fb0: 3c 68 34 3e 45 78 61 6d 70 6c 65 20 23 32 20 2d <h4>Example #2 -
1fc0: 20 73 70 6c 6c 74 74 69 6e 67 20 61 20 50 6f 6c splltting a Pol
1fd0: 79 67 6f 6e 20 62 79 20 61 20 4c 69 6e 65 73 74 ygon by a Linest
1fe0: 72 69 6e 67 20 62 6c 61 64 65 3c 2f 68 34 3e 0d ring blade</h4>.
1ff0: 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d .<table bgcolor=
2000: 22 23 65 30 65 30 65 30 22 20 63 65 6c 6c 73 70 "#e0e0e0" cellsp
2010: 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 acing="4" cellpa
2020: 64 64 69 6e 67 3d 22 38 22 3e 0d 0a 3c 74 72 3e dding="8">..<tr>
2030: 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 <td>..<b>SELECT
2040: 53 54 5f 53 70 6c 69 74 28 69 6e 70 75 74 2e 67 ST_Split(input.g
2050: 2c 20 62 6c 61 64 65 2e 67 29 2c 20 53 54 5f 53 , blade.g), ST_S
2060: 70 6c 69 74 4c 65 66 74 28 69 6e 70 75 74 2e 67 plitLeft(input.g
2070: 2c 20 62 6c 61 64 65 2e 67 29 2c 20 53 54 5f 53 , blade.g), ST_S
2080: 70 6c 69 74 52 69 67 68 74 28 69 6e 70 75 74 2e plitRight(input.
2090: 67 2c 20 62 6c 61 64 65 2e 67 29 3c 62 72 3e 0d g, blade.g)<br>.
20a0: 0a 46 52 4f 4d 3c 62 72 3e 20 0d 0a 28 53 45 4c .FROM<br> ..(SEL
20b0: 45 43 54 20 47 65 6f 6d 46 72 6f 6d 54 65 78 74 ECT GeomFromText
20c0: 28 27 50 4f 4c 59 47 4f 4e 28 28 30 20 31 2c 20 ('POLYGON((0 1,
20d0: 31 30 20 31 2c 20 31 30 20 39 2c 20 30 20 39 2c 10 1, 10 9, 0 9,
20e0: 20 30 20 31 29 2c 20 28 32 20 32 2c 20 37 20 32 0 1), (2 2, 7 2
20f0: 2c 20 37 20 36 2c 20 32 20 36 2c 20 32 20 32 29 , 7 6, 2 6, 2 2)
2100: 29 27 29 20 41 53 20 67 29 20 41 53 20 69 6e 70 )') AS g) AS inp
2110: 75 74 2c 3c 62 72 3e 20 0d 0a 28 53 45 4c 45 43 ut,<br> ..(SELEC
2120: 54 20 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 27 T GeomFromText('
2130: 4c 49 4e 45 53 54 52 49 4e 47 28 32 20 30 2c 20 LINESTRING(2 0,
2140: 36 20 31 30 29 27 29 20 41 53 20 67 29 20 41 53 6 10)') AS g) AS
2150: 20 62 6c 61 64 65 3b 3c 2f 62 3e 0d 0a 3c 2f 74 blade;</b>..</t
2160: 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 d></tr>..</table
2170: 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 63 65 ><br>..<table ce
2180: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 llspacing="4" ce
2190: 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a llpadding="4">..
21a0: 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 20 3c 62 <tr><td>..The <b
21b0: 3e 53 54 5f 53 70 6c 69 74 28 29 3c 2f 62 3e 20 >ST_Split()</b>
21c0: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c SQL function wil
21d0: 6c 20 73 69 6d 70 6c 79 20 72 65 74 75 72 6e 20 l simply return
21e0: 61 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f 6e 3c a <i>collection<
21f0: 2f 69 3e 20 61 67 67 72 65 67 61 74 69 6e 67 20 /i> aggregating
2200: 61 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 64 65 all fragments de
2210: 72 69 76 69 6e 67 20 66 72 6f 6d 20 74 68 65 20 riving from the
2220: 63 75 74 2e 3c 62 72 3e 0d 0a 45 78 65 63 74 6c cut.<br>..Exectl
2230: 79 20 61 73 20 77 65 20 68 61 76 65 20 61 6c 72 y as we have alr
2240: 65 61 64 79 20 70 72 65 76 69 6f 75 73 6c 79 20 eady previously
2250: 73 65 65 6e 20 6f 6e 20 74 68 65 20 4c 69 6e 65 seen on the Line
2260: 73 74 72 69 6e 67 20 63 61 73 65 2e 3c 62 72 3e string case.<br>
2270: 3c 62 72 3e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d <br>..</td><td>.
2280: 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 70 3a .<img src="http:
2290: 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 //www.gaia-gis.i
22a0: 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 t/gaia-sins/writ
22b0: 65 2d 76 69 65 77 2d 70 69 63 73 2f 73 70 6c 69 e-view-pics/spli
22c0: 74 2d 70 67 2e 70 6e 67 22 20 61 6c 74 3d 22 73 t-pg.png" alt="s
22d0: 70 6c 69 74 20 70 6f 6c 79 67 6f 6e 22 3e 0d 0a plit polygon">..
22e0: 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </td></tr>..<tr>
22f0: 3c 74 64 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f <td>..The <b>ST_
2300: 53 70 6c 69 74 4c 65 66 74 28 29 3c 2f 62 3e 20 SplitLeft()</b>
2310: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c SQL function wil
2320: 6c 20 72 65 74 75 72 6e 20 69 6e 73 74 65 61 64 l return instead
2330: 20 61 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f 6e a <i>collection
2340: 3c 2f 69 3e 20 61 67 67 72 65 67 61 74 69 6e 67 </i> aggregating
2350: 20 61 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 6c all fragments l
2360: 61 79 69 6e 67 20 6f 6e 20 74 68 65 20 3c 69 3e aying on the <i>
2370: 6c 65 66 74 3c 2f 69 3e 20 73 69 64 65 20 6f 66 left</i> side of
2380: 20 74 68 65 20 63 75 74 2e 3c 62 72 3e 0d 0a 46 the cut.<br>..F
2390: 6f 72 20 50 6f 6c 79 67 6f 6e 73 20 3c 69 3e 6c or Polygons <i>l
23a0: 65 66 74 3c 2f 69 3e 20 72 65 61 6c 6c 79 20 6d eft</i> really m
23b0: 65 61 6e 73 20 3c 69 3e 6c 65 66 74 20 73 69 64 eans <i>left sid
23c0: 65 3c 2f 69 3e 20 28 61 74 20 6c 65 61 73 74 2c e</i> (at least,
23d0: 20 74 68 69 73 20 69 73 20 74 72 75 65 20 77 68 this is true wh
23e0: 65 6e 20 74 68 65 20 62 6c 61 64 65 20 69 73 20 en the blade is
23f0: 61 6c 6d 6f 73 74 20 76 65 72 74 69 63 61 6c 6c almost verticall
2400: 79 20 6f 72 69 65 6e 74 65 64 29 2e 3c 62 72 3e y oriented).<br>
2410: 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 <br>..<u>Please
2420: 6e 6f 74 65 3c 2f 75 3e 3a 20 69 66 20 74 68 65 note</u>: if the
2430: 20 3c 69 3e 62 6c 61 64 65 3c 2f 69 3e 20 64 6f <i>blade</i> do
2440: 65 73 6e 27 74 20 69 6e 74 65 72 63 65 70 74 73 esn't intercepts
2450: 20 74 68 65 20 74 61 72 67 65 74 20 61 74 20 61 the target at a
2460: 6c 6c 2c 20 74 68 61 6e 20 6e 6f 20 63 75 74 20 ll, than no cut
2470: 77 6f 75 6c 64 20 62 65 20 6f 62 76 69 6f 75 73 would be obvious
2480: 6c 79 20 70 6f 73 73 69 62 6c 65 2e 20 49 6e 20 ly possible. In
2490: 74 68 69 73 20 73 70 65 63 69 61 6c 20 63 61 73 this special cas
24a0: 65 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 74 e the original t
24b0: 61 72 67 65 74 20 47 65 6f 6d 65 74 72 79 20 77 arget Geometry w
24c0: 69 6c 6c 20 62 65 20 61 6c 77 61 79 73 20 72 65 ill be always re
24d0: 74 75 72 6e 65 64 20 28 61 62 73 6f 6c 75 74 65 turned (absolute
24e0: 6c 79 20 75 6e 63 68 61 6e 67 65 64 29 20 6f 6e ly unchanged) on
24f0: 20 74 68 65 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e the <i>left</i>
2500: 20 73 69 64 65 20 63 6f 6c 6c 65 63 74 69 6f 6e side collection
2510: 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 ...</td><td>..<i
2520: 6d 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 mg src="http://w
2530: 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 ww.gaia-gis.it/g
2540: 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 aia-sins/write-v
2550: 69 65 77 2d 70 69 63 73 2f 73 70 6c 69 74 2d 70 iew-pics/split-p
2560: 67 2d 4c 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 g-L.png" alt="sp
2570: 6c 69 74 2d 6c 65 66 74 20 70 6f 6c 79 67 6f 6e lit-left polygon
2580: 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a ">..</td></tr>..
2590: 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 20 3c 62 <tr><td>..The <b
25a0: 3e 53 54 5f 53 70 6c 69 74 52 69 67 68 74 28 29 >ST_SplitRight()
25b0: 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f </b> SQL functio
25c0: 6e 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 n will return a
25d0: 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f 6e 3c 2f 69 <i>collection</i
25e0: 3e 20 61 67 67 72 65 67 61 74 69 6e 67 20 61 6c > aggregating al
25f0: 6c 20 66 72 61 67 6d 65 6e 74 73 20 6c 61 79 69 l fragments layi
2600: 6e 67 20 6f 6e 20 74 68 65 20 3c 69 3e 72 69 67 ng on the <i>rig
2610: 68 74 3c 2f 69 3e 20 73 69 64 65 20 6f 66 20 74 ht</i> side of t
2620: 68 65 20 63 75 74 2e 3c 62 72 3e 0d 0a 3c 75 3e he cut.<br>..<u>
2630: 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a Please note</u>:
2640: 20 69 66 20 74 68 65 20 3c 69 3e 62 6c 61 64 65 if the <i>blade
2650: 3c 2f 69 3e 20 64 6f 65 73 6e 27 74 20 69 6e 74 </i> doesn't int
2660: 65 72 63 65 70 74 73 20 74 68 65 20 74 61 72 67 ercepts the targ
2670: 65 74 20 61 74 20 61 6c 6c 2c 20 74 68 61 6e 20 et at all, than
2680: 6e 6f 20 63 75 74 20 77 6f 75 6c 64 20 62 65 20 no cut would be
2690: 6f 62 76 69 6f 75 73 6c 79 20 70 6f 73 73 69 62 obviously possib
26a0: 6c 65 2e 20 49 6e 20 74 68 69 73 20 73 70 65 63 le. In this spec
26b0: 69 61 6c 20 63 61 73 65 20 74 68 65 20 3c 69 3e ial case the <i>
26c0: 72 69 67 68 74 3c 2f 69 3e 20 73 69 64 65 20 63 right</i> side c
26d0: 6f 6c 6c 65 63 74 69 6f 6e 20 77 69 6c 6c 20 62 ollection will b
26e0: 65 20 4e 55 4c 4c 2e 0d 0a 3c 2f 74 64 3e 3c 74 e NULL...</td><t
26f0: 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 d>..<img src="ht
2700: 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 tp://www.gaia-gi
2710: 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 s.it/gaia-sins/w
2720: 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f 73 rite-view-pics/s
2730: 70 6c 69 74 2d 70 67 2d 52 2e 70 6e 67 22 20 61 plit-pg-R.png" a
2740: 6c 74 3d 22 73 70 6c 69 74 2d 72 69 67 68 74 20 lt="split-right
2750: 70 6f 6c 79 67 6f 6e 22 3e 0d 0a 3c 2f 74 64 3e polygon">..</td>
2760: 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d </tr>..</table>.
2770: 0a 3c 62 72 3e 3c 68 72 3e 0d 0a 3c 68 33 3e 53 .<br><hr>..<h3>S
2780: 65 67 6d 65 6e 74 69 7a 61 74 69 6f 6e 3c 2f 68 egmentization</h
2790: 33 3e 0d 0a 53 6f 6d 65 74 69 6d 65 73 20 69 74 3>..Sometimes it
27a0: 20 63 6f 75 6c 64 20 62 65 20 75 73 65 66 75 6c could be useful
27b0: 20 3c 69 3e 63 75 74 74 69 6e 67 3c 2f 69 3e 20 <i>cutting</i>
27c0: 61 20 76 65 72 79 20 6c 6f 6e 67 20 4c 69 6e 65 a very long Line
27d0: 73 74 72 69 6e 67 20 6f 72 20 50 6f 6c 79 67 6f string or Polygo
27e0: 6e 27 73 20 52 69 6e 67 20 69 6e 74 6f 20 6d 61 n's Ring into ma
27f0: 6e 79 20 73 6d 61 6c 6c 20 73 65 67 6d 65 6e 74 ny small segment
2800: 73 20 6f 66 20 74 68 65 20 73 61 6d 65 20 69 64 s of the same id
2810: 65 6e 74 69 63 61 6c 20 6c 65 6e 67 74 68 2e 0d entical length..
2820: 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d .<table bgcolor=
2830: 22 23 65 30 65 30 65 30 22 20 63 65 6c 6c 73 70 "#e0e0e0" cellsp
2840: 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 acing="4" cellpa
2850: 64 64 69 6e 67 3d 22 38 22 3e 0d 0a 3c 74 72 3e dding="8">..<tr>
2860: 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 <td>..<b>SELECT
2870: 67 65 6f 6d 65 74 72 79 2c 20 53 54 5f 53 65 67 geometry, ST_Seg
2880: 6d 65 6e 74 69 7a 65 28 67 65 6f 6d 65 74 72 79 mentize(geometry
2890: 2c 20 31 30 2e 30 29 3c 62 72 3e 0d 0a 46 52 4f , 10.0)<br>..FRO
28a0: 4d 20 63 6f 6d 32 30 31 31 3c 62 72 3e 0d 0a 57 M com2011<br>..W
28b0: 48 45 52 45 20 6e 6f 6d 65 5f 63 6f 6d 20 3d 20 HERE nome_com =
28c0: 27 42 72 6f 6e 74 65 27 3b 3c 2f 62 3e 0d 0a 3c 'Bronte';</b>..<
28d0: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 /td></tr></table
28e0: 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f ><br>..<table bo
28f0: 72 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 rder="1" cellspa
2900: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 cing="4" cellpad
2910: 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c ding="4">..<tr><
2920: 74 68 3e 6f 72 69 67 69 6e 61 6c 3c 2f 74 68 3e th>original</th>
2930: 3c 74 68 3e 73 65 67 6d 65 6e 74 69 7a 65 64 3c <th>segmentized<
2940: 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /th></tr>..<tr><
2950: 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 td>..<img src="h
2960: 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 ttp://www.gaia-g
2970: 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f is.it/gaia-sins/
2980: 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f write-view-pics/
2990: 62 72 6f 6e 74 65 2d 6f 72 69 67 69 6e 61 6c 2e bronte-original.
29a0: 70 6e 67 22 20 61 6c 74 3d 22 62 72 6f 6e 74 65 png" alt="bronte
29b0: 20 6f 72 69 67 69 6e 61 6c 22 3e 0d 0a 3c 2f 74 original">..</t
29c0: 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 d><td>..<img src
29d0: 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 ="http://www.gai
29e0: 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 a-gis.it/gaia-si
29f0: 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 ns/write-view-pi
2a00: 63 73 2f 62 72 6f 6e 74 65 2d 73 65 67 6d 65 6e cs/bronte-segmen
2a10: 74 69 7a 65 64 2e 70 6e 67 22 20 61 6c 74 3d 22 tized.png" alt="
2a20: 62 72 6f 6e 74 65 20 73 65 67 6d 65 6e 74 69 7a bronte segmentiz
2a30: 65 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e ed">..</td></tr>
2a40: 0d 0a 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61 ..<tr><td colspa
2a50: 6e 3d 22 32 22 3e 0d 0a 41 73 20 79 6f 75 20 63 n="2">..As you c
2a60: 61 6e 20 65 61 73 69 6c 79 20 6e 6f 74 69 63 65 an easily notice
2a70: 2c 20 74 68 65 72 65 20 61 72 65 20 6d 61 6e 79 , there are many
2a80: 20 6d 6f 72 65 20 76 65 72 74 69 63 65 73 20 69 more vertices i
2a90: 6e 20 74 68 65 20 73 65 67 6d 65 6e 74 69 7a 65 n the segmentize
2aa0: 64 20 47 65 6f 6d 65 74 72 79 2e 3c 62 72 3e 0d d Geometry.<br>.
2ab0: 0a 57 65 20 69 6d 70 6f 73 65 64 20 74 68 65 20 .We imposed the
2ac0: 63 6f 6e 73 74 72 61 69 6e 74 20 74 68 61 74 20 constraint that
2ad0: 6e 6f 20 73 65 67 6d 65 6e 74 20 63 6f 75 6c 64 no segment could
2ae0: 20 62 65 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 be longer than
2af0: 3c 62 3e 31 30 6d 3c 2f 62 3e 2c 20 74 68 75 73 <b>10m</b>, thus
2b00: 20 63 61 75 73 69 6e 67 20 6d 61 6e 79 20 6d 6f causing many mo
2b10: 72 65 20 76 65 72 74 69 63 65 73 20 74 6f 20 62 re vertices to b
2b20: 65 20 69 6e 74 65 72 70 6f 6c 61 74 65 64 2e 3c e interpolated.<
2b30: 62 72 3e 0d 0a 54 68 65 20 6f 76 65 72 61 6c 6c br>..The overall
2b40: 20 73 68 61 70 65 20 69 73 20 61 62 73 6f 6c 75 shape is absolu
2b50: 74 65 6c 79 20 75 6e 63 68 61 6e 67 65 64 2e 0d tely unchanged..
2b60: 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 .</td></tr>..</t
2b70: 61 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 72 3e 0d able>..<br><hr>.
2b80: 0a 3c 68 33 3e 41 7a 69 6d 75 74 68 3c 2f 68 33 .<h3>Azimuth</h3
2b90: 3e 0d 0a 50 72 6f 62 61 62 6c 79 20 6e 6f 74 20 >..Probably not
2ba0: 74 68 65 20 6d 6f 73 74 20 69 6e 74 65 72 65 73 the most interes
2bb0: 74 69 6e 67 20 66 75 6e 63 74 69 6f 6e 20 73 75 ting function su
2bc0: 70 70 6f 72 74 65 64 20 62 79 20 3c 69 3e 6c 69 pported by <i>li
2bd0: 62 6c 77 67 65 6f 6d 3c 2f 69 3e 3b 20 61 6e 79 blwgeom</i>; any
2be0: 77 61 79 20 69 74 27 73 20 74 68 65 72 65 2c 20 way it's there,
2bf0: 61 6e 64 20 69 73 20 77 6f 72 74 68 20 65 6e 6f and is worth eno
2c00: 75 67 68 20 74 6f 20 62 65 20 73 75 70 70 6f 72 ugh to be suppor
2c10: 74 65 64 20 62 79 20 53 70 61 74 69 61 4c 69 74 ted by SpatiaLit
2c20: 65 20 61 73 20 77 65 6c 6c 2e 3c 62 72 3e 0d 0a e as well.<br>..
2c30: 50 72 6f 62 61 62 6c 79 20 68 69 67 68 6c 79 20 Probably highly
2c40: 61 70 70 72 65 63 69 61 74 65 64 20 6f 6e 20 3c appreciated on <
2c50: 62 3e 47 50 53 20 64 65 76 69 63 65 73 3c 2f 62 b>GPS devices</b
2c60: 3e 20 73 6f 20 74 6f 20 64 65 74 65 72 6d 69 6e > so to determin
2c70: 65 20 74 68 65 20 63 75 72 72 65 6e 74 20 62 65 e the current be
2c80: 61 72 69 6e 67 2e 0d 0a 3c 74 61 62 6c 65 20 62 aring...<table b
2c90: 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 gcolor="#e0e0e0"
2ca0: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 cellspacing="4"
2cb0: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 cellpadding="8"
2cc0: 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e >..<tr><td>..<b>
2cd0: 53 45 4c 45 43 54 20 44 65 67 72 65 65 73 28 53 SELECT Degrees(S
2ce0: 54 5f 41 7a 69 6d 75 74 68 28 4d 61 6b 65 50 6f T_Azimuth(MakePo
2cf0: 69 6e 74 28 30 2c 20 30 29 2c 20 4d 61 6b 65 50 int(0, 0), MakeP
2d00: 6f 69 6e 74 28 30 2c 20 31 29 29 29 3b 3c 2f 62 oint(0, 1)));</b
2d10: 3e 0d 0a 3c 68 72 3e 0d 0a 30 2e 30 0d 0a 3c 2f >..<hr>..0.0..</
2d20: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 td></tr>..<tr><t
2d30: 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 44 65 d>..<b>SELECT De
2d40: 67 72 65 65 73 28 53 54 5f 41 7a 69 6d 75 74 68 grees(ST_Azimuth
2d50: 28 4d 61 6b 65 50 6f 69 6e 74 28 30 2c 20 30 29 (MakePoint(0, 0)
2d60: 2c 20 4d 61 6b 65 50 6f 69 6e 74 28 31 2c 20 31 , MakePoint(1, 1
2d70: 29 29 29 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a )));</b>..<hr>..
2d80: 34 35 2e 30 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 45.0..</td></tr>
2d90: 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 ..<tr><td>..<b>S
2da0: 45 4c 45 43 54 20 44 65 67 72 65 65 73 28 53 54 ELECT Degrees(ST
2db0: 5f 41 7a 69 6d 75 74 68 28 4d 61 6b 65 50 6f 69 _Azimuth(MakePoi
2dc0: 6e 74 28 30 2c 20 30 29 2c 20 4d 61 6b 65 50 6f nt(0, 0), MakePo
2dd0: 69 6e 74 28 31 2c 20 30 29 29 29 3b 3c 2f 62 3e int(1, 0)));</b>
2de0: 0d 0a 3c 68 72 3e 0d 0a 39 30 2e 30 0d 0a 3c 2f ..<hr>..90.0..</
2df0: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 td></tr>..<tr><t
2e00: 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 44 65 d>..<b>SELECT De
2e10: 67 72 65 65 73 28 53 54 5f 41 7a 69 6d 75 74 68 grees(ST_Azimuth
2e20: 28 4d 61 6b 65 50 6f 69 6e 74 28 30 2c 20 30 29 (MakePoint(0, 0)
2e30: 2c 20 4d 61 6b 65 50 6f 69 6e 74 28 30 2c 20 2d , MakePoint(0, -
2e40: 31 29 29 29 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 1)));</b>..<hr>.
2e50: 0a 31 38 30 2e 30 0d 0a 3c 2f 74 64 3e 3c 2f 74 .180.0..</td></t
2e60: 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e r>..</table><br>
2e70: 0d 0a 3c 62 72 3e 3c 68 72 3e 0d 0a 3c 68 33 3e ..<br><hr>..<h3>
2e80: 53 6e 61 70 70 69 6e 67 20 47 65 6f 6d 65 74 72 Snapping Geometr
2e90: 69 65 73 20 74 6f 20 61 20 70 72 65 64 65 66 69 ies to a predefi
2ea0: 6e 65 64 20 67 72 69 64 3c 2f 68 33 3e 0d 0a 54 ned grid</h3>..T
2eb0: 68 69 73 20 66 65 61 74 75 72 65 20 72 65 61 6c his feature real
2ec0: 6c 79 20 69 73 20 3c 69 3e 3c 75 3e 74 68 65 20 ly is <i><u>the
2ed0: 6d 6f 74 68 65 72 20 6f 66 20 74 6f 70 6f 6c 6f mother of topolo
2ee0: 67 69 63 61 6c 20 63 6f 6e 73 69 73 74 65 6e 63 gical consistenc
2ef0: 79 3c 2f 75 3e 3c 2f 69 3e 3b 20 69 6d 70 6f 73 y</u></i>; impos
2f00: 69 6e 67 20 74 68 61 74 20 61 6c 6c 20 70 6f 69 ing that all poi
2f10: 6e 74 73 20 2f 20 76 65 72 74 69 63 65 73 20 73 nts / vertices s
2f20: 68 6f 75 6c 64 20 62 65 20 73 74 72 69 63 74 6c hould be strictl
2f30: 79 20 61 6c 69 67 6e 65 64 20 74 6f 20 74 68 65 y aligned to the
2f40: 20 73 61 6d 65 20 67 72 69 64 20 77 69 6c 6c 20 same grid will
2f50: 73 75 72 65 6c 79 20 6d 61 6b 65 20 65 61 73 69 surely make easi
2f60: 65 72 20 65 6e 73 75 72 69 6e 67 20 61 20 73 74 er ensuring a st
2f70: 72 6f 6e 67 20 63 6f 6e 73 69 73 74 65 6e 63 79 rong consistency
2f80: 20 62 65 74 77 65 65 6e 20 64 69 66 66 65 72 65 between differe
2f90: 6e 74 20 47 65 6f 6d 65 74 72 69 65 73 2e 3c 62 nt Geometries.<b
2fa0: 72 3e 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 r><br>..<u>Pleas
2fb0: 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 64 75 65 20 e note</u>: due
2fc0: 74 6f 20 74 65 63 68 6e 69 63 61 6c 20 72 65 61 to technical rea
2fd0: 73 6f 6e 73 20 74 68 65 20 63 75 72 72 65 6e 74 sons the current
2fe0: 20 76 65 72 73 69 6f 6e 20 6f 66 20 3c 69 3e 6c version of <i>l
2ff0: 69 62 6c 77 67 65 6f 6d 3c 2f 69 3e 20 64 6f 65 iblwgeom</i> doe
3000: 73 6e 27 74 20 65 78 70 6f 73 65 73 20 74 6f 20 sn't exposes to
3010: 74 68 65 20 65 78 74 65 72 69 6f 72 20 74 68 65 the exterior the
3020: 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 6c corresponding l
3030: 69 6e 6b 20 73 79 6d 62 6f 6c 73 2e 3c 62 72 3e ink symbols.<br>
3040: 0d 0a 53 6f 20 74 68 65 20 63 75 72 72 65 6e 74 ..So the current
3050: 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 implementation
3060: 61 76 61 69 6c 61 62 6c 65 20 6f 6e 20 53 70 61 available on Spa
3070: 74 69 61 4c 69 74 65 20 69 73 20 61 6e 20 69 6e tiaLite is an in
3080: 64 65 70 65 6e 64 65 6e 74 20 6f 6e 65 20 28 61 dependent one (a
3090: 6c 74 68 6f 75 67 68 20 62 65 69 6e 67 20 64 69 lthough being di
30a0: 72 65 63 74 6c 79 20 69 6e 73 69 70 69 72 65 64 rectly insipired
30b0: 20 62 79 20 74 68 65 20 3c 69 3e 6c 69 62 6c 77 by the <i>liblw
30c0: 67 65 6f 6d 3c 2f 69 3e 20 6f 6e 65 29 2e 3c 62 geom</i> one).<b
30d0: 72 3e 20 20 0d 0a 3c 74 61 62 6c 65 20 62 67 63 r> ..<table bgc
30e0: 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 olor="#e0e0e0" c
30f0: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
3100: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e 0d ellpadding="8">.
3110: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 .<tr><td>..<b>SE
3120: 4c 45 43 54 20 53 54 5f 53 6e 61 70 54 6f 47 72 LECT ST_SnapToGr
3130: 69 64 28 67 65 6f 6d 65 74 72 79 2c 20 32 35 30 id(geometry, 250
3140: 2e 30 29 3c 62 72 3e 0d 0a 46 52 4f 4d 20 63 6f .0)<br>..FROM co
3150: 6d 32 30 31 31 3c 62 72 3e 0d 0a 57 48 45 52 45 m2011<br>..WHERE
3160: 20 6e 6f 6d 65 5f 63 6f 6d 20 3d 20 27 42 72 6f nome_com = 'Bro
3170: 6e 74 65 27 3b 3c 2f 62 3e 0d 0a 3c 2f 74 64 3e nte';</b>..</td>
3180: 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 </tr></table><br
3190: 3e 0d 0a 3c 74 61 62 6c 65 20 63 65 6c 6c 73 70 >..<table cellsp
31a0: 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 acing="4" cellpa
31b0: 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e dding="4">..<tr>
31c0: 3c 74 64 3e 0d 0a 59 61 74 20 61 67 61 69 6e 20 <td>..Yat again
31d0: 61 6e 6f 74 68 65 72 20 74 69 6d 65 20 74 68 65 another time the
31e0: 20 42 72 6f 6e 74 65 20 4c 6f 63 61 6c 20 43 6f Bronte Local Co
31f0: 75 6e 63 69 6c 20 62 6f 75 6e 64 61 72 79 2e 3c uncil boundary.<
3200: 62 72 3e 0d 0a 42 79 20 69 6e 76 6f 6b 69 6e 67 br>..By invoking
3210: 20 3c 62 3e 53 54 5f 53 6e 61 70 54 6f 47 72 69 <b>ST_SnapToGri
3220: 64 28 29 3c 2f 62 3e 20 74 68 69 73 20 74 69 6d d()</b> this tim
3230: 65 20 74 68 65 20 47 65 6f 6d 65 74 72 79 20 68 e the Geometry h
3240: 61 73 20 62 65 65 6e 20 73 74 72 6f 6e 67 6c 79 as been strongly
3250: 20 73 69 6d 70 6c 69 66 69 65 64 20 28 70 6c 65 simplified (ple
3260: 61 73 65 20 6e 6f 74 69 63 65 3b 20 6d 61 6e 79 ase notice; many
3270: 20 76 65 72 74 69 63 65 73 20 68 61 76 65 20 62 vertices have b
3280: 65 65 6e 20 73 75 70 70 72 65 73 73 65 64 29 2e een suppressed).
3290: 3c 62 72 3e 3c 62 72 3e 0d 0a 54 68 65 20 69 6d <br><br>..The im
32a0: 70 6f 73 65 64 20 3c 69 3e 67 72 69 64 20 73 69 posed <i>grid si
32b0: 7a 65 3c 2f 69 3e 20 28 3c 62 3e 32 35 30 6d 3c ze</i> (<b>250m<
32c0: 2f 62 3e 29 20 69 73 20 61 62 73 6f 6c 75 74 65 /b>) is absolute
32d0: 6c 79 20 75 6e 72 65 61 6c 69 73 74 69 63 20 61 ly unrealistic a
32e0: 6e 64 20 65 78 61 67 67 65 72 61 74 65 64 20 66 nd exaggerated f
32f0: 6f 72 20 61 6e 79 20 70 72 61 63 74 69 63 61 6c or any practical
3300: 20 70 75 72 70 6f 73 65 2e 3c 62 72 3e 0d 0a 41 purpose.<br>..A
3310: 6e 79 77 61 79 20 61 20 73 75 63 68 20 73 74 72 nyway a such str
3320: 6f 6e 67 20 66 61 63 74 6f 72 20 69 73 20 75 73 ong factor is us
3330: 65 66 75 6c 20 69 6e 20 6f 72 64 65 72 20 74 6f eful in order to
3340: 20 63 6c 65 61 72 6c 79 20 73 68 6f 77 20 77 68 clearly show wh
3350: 61 74 20 72 65 61 6c 6c 79 20 68 61 70 70 65 6e at really happen
3360: 73 3a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6c 6c 20 s:<ul>..<li>all
3370: 76 65 72 69 74 69 63 65 73 20 61 72 65 20 6e 6f veritices are no
3380: 77 20 73 74 72 69 63 74 6c 79 20 61 6c 69 67 6e w strictly align
3390: 65 64 20 74 6f 20 74 68 65 20 67 72 69 64 20 6e ed to the grid n
33a0: 6f 64 65 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e odes.</li>..<li>
33b0: 61 6c 6c 20 76 65 72 74 69 63 65 73 20 66 61 6c all vertices fal
33c0: 6c 69 6e 67 20 77 69 74 68 69 6e 20 74 68 65 20 ling within the
33d0: 73 61 6d 65 20 67 72 69 64 20 63 65 6c 6c 20 68 same grid cell h
33e0: 61 76 65 20 62 65 65 6e 20 73 75 70 70 72 65 73 ave been suppres
33f0: 73 65 6e 64 2c 20 73 74 69 6c 6c 20 70 72 65 73 send, still pres
3400: 65 72 76 69 6e 67 20 6f 6e 6c 79 20 6f 6e 65 20 erving only one
3410: 6f 66 20 74 68 65 6d 2e 3c 2f 6c 69 3e 0d 0a 3c of them.</li>..<
3420: 6c 69 3e 73 6f 20 74 68 65 20 6f 76 65 72 61 6c li>so the overal
3430: 6c 20 65 66 66 65 63 74 20 69 73 20 74 68 65 20 l effect is the
3440: 6f 6e 65 20 6c 65 61 64 69 6e 67 20 74 6f 20 61 one leading to a
3450: 20 72 69 67 6f 72 6f 75 73 6c 79 20 3c 69 3e 6e rigorously <i>n
3460: 6f 72 6d 61 6c 69 7a 65 64 3c 2f 69 3e 20 61 6e ormalized</i> an
3470: 64 20 28 6d 61 79 20 62 65 29 20 3c 69 3e 73 69 d (may be) <i>si
3480: 6d 70 6c 69 66 69 65 64 3c 2f 69 3e 20 47 65 6f mplified</i> Geo
3490: 6d 65 74 72 79 3b 20 61 6e 64 20 74 68 69 73 20 metry; and this
34a0: 77 69 6c 6c 20 73 75 72 65 6c 79 20 6d 61 6b 65 will surely make
34b0: 20 65 61 73 69 65 72 20 65 6e 73 75 72 69 6e 67 easier ensuring
34c0: 20 79 68 65 20 72 65 71 75 69 72 65 64 20 74 6f yhe required to
34d0: 70 6f 6c 6f 67 69 63 61 6c 20 63 6f 6e 73 69 73 pological consis
34e0: 74 65 6e 63 79 20 77 69 74 68 20 61 6e 79 20 6f tency with any o
34f0: 74 68 65 72 20 61 64 6a 61 63 65 6e 74 20 4c 6f ther adjacent Lo
3500: 63 61 6c 20 43 6f 75 6e 63 69 6c 2e 3c 2f 6c 69 cal Council.</li
3510: 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 3e 3c >..</ul>..</td><
3520: 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 td>..<img src="h
3530: 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 ttp://www.gaia-g
3540: 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f is.it/gaia-sins/
3550: 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f write-view-pics/
3560: 73 6e 61 70 2d 74 6f 2d 67 72 69 64 2e 70 6e 67 snap-to-grid.png
3570: 22 20 61 6c 74 3d 22 73 6e 61 70 20 74 6f 20 67 " alt="snap to g
3580: 72 69 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 rid">..</td></tr
3590: 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 >..</table>..<br
35a0: 3e 3c 68 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 ><hr>..<table bg
35b0: 63 6f 6c 6f 72 3d 22 23 64 37 66 66 66 66 22 20 color="#d7ffff"
35c0: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 36 22 20 cellspacing="6"
35d0: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 31 30 22 cellpadding="10"
35e0: 20 77 69 64 74 68 3d 22 31 30 30 25 22 3e 0d 0a width="100%">..
35f0: 3c 74 72 3e 3c 74 68 3e 43 72 65 64 69 74 73 3c <tr><th>Credits<
3600: 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c /th></tr>..<tr><
3610: 74 64 20 61 6c 69 67 6e 3d 22 63 65 6e 74 65 72 td align="center
3620: 22 3e 0d 0a 54 68 69 73 20 77 6f 72 6b 20 28 65 ">..This work (e
3630: 78 70 6f 73 69 6e 67 20 3c 69 3e 6c 69 62 6c 77 xposing <i>liblw
3640: 67 65 6f 6d 3c 2f 69 3e 20 41 50 49 73 20 61 73 geom</i> APIs as
3650: 20 53 70 61 74 69 61 4c 69 74 65 20 6f 77 6e 20 SpatiaLite own
3660: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 29 20 68 SQL functions) h
3670: 61 73 20 62 65 65 6e 20 65 6e 74 69 65 72 65 6c as been entierel
3680: 79 20 66 75 6e 64 65 64 20 62 79 3a 3c 62 72 3e y funded by:<br>
3690: 0d 0a 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a ..<a href="http:
36a0: 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61 2e 6f //en.wikipedia.o
36b0: 72 67 2f 77 69 6b 69 2f 54 75 73 63 61 6e 79 22 rg/wiki/Tuscany"
36c0: 3e 54 75 73 63 61 6e 79 20 52 65 67 69 6f 6e 3c >Tuscany Region<
36d0: 2f 61 3e 20 2d 20 54 65 72 72 69 74 6f 72 69 61 /a> - Territoria
36e0: 6c 20 61 6e 64 20 45 6e 76 69 72 6f 6e 6d 65 6e l and Environmen
36f0: 74 61 6c 20 49 6e 66 6f 72 6d 61 74 69 6f 6e 20 tal Information
3700: 53 79 73 74 65 6d 3c 62 72 3e 0d 0a 3c 61 20 68 System<br>..<a h
3710: 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e ref="http://www.
3720: 72 65 67 69 6f 6e 65 2e 74 6f 73 63 61 6e 61 2e regione.toscana.
3730: 69 74 2f 22 3e 52 65 67 69 6f 6e 65 20 54 6f 73 it/">Regione Tos
3740: 63 61 6e 61 3c 2f 61 3e 20 2d 20 53 65 74 74 6f cana</a> - Setto
3750: 72 65 20 53 69 73 74 65 6d 61 20 49 6e 66 6f 72 re Sistema Infor
3760: 6d 61 74 69 76 6f 20 54 65 72 72 69 74 6f 72 69 mativo Territori
3770: 61 6c 65 20 65 64 20 41 6d 62 69 65 6e 74 61 6c ale ed Ambiental
3780: 65 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a e...</td></tr>..
3790: 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 </table>..<br><h
37a0: 72 3e 0d 0a 42 61 63 6b 20 74 6f 20 3c 61 20 68 r>..Back to <a h
37b0: 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 ref="https://www
37c0: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 .gaia-gis.it/fos
37d0: 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 sil/libspatialit
37e0: 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 73 77 69 74 e/wiki?name=swit
37f0: 63 68 69 6e 67 2d 74 6f 2d 34 2e 30 23 6c 69 62 ching-to-4.0#lib
3800: 6c 77 67 65 6f 6d 22 3e 6d 61 69 6e 20 70 61 67 lwgeom">main pag
3810: 65 3c 2f 61 3e 0d 0a 0a 5a 20 39 32 34 33 38 65 e</a>...Z 92438e
3820: 63 35 61 35 39 62 38 30 64 63 37 65 31 37 34 31 c5a59b80dc7e1741
3830: 38 66 31 63 32 36 65 38 64 66 0a 8f1c26e8df.