Wiki page
[liblwgeom-4.0] by
sandro
2012-08-31 10:50:08.
0000: 44 20 32 30 31 32 2d 30 38 2d 33 31 54 31 30 3a D 2012-08-31T10:
0010: 35 30 3a 30 38 2e 37 33 31 0a 4c 20 6c 69 62 6c 50:08.731.L libl
0020: 77 67 65 6f 6d 2d 34 2e 30 0a 50 20 65 65 34 31 wgeom-4.0.P ee41
0030: 35 38 32 35 62 34 64 63 62 64 62 32 62 62 37 33 5825b4dcbdb2bb73
0040: 61 39 37 31 65 32 33 31 37 33 66 64 37 61 37 64 a971e23173fd7a7d
0050: 37 30 33 61 0a 55 20 73 61 6e 64 72 6f 0a 57 20 703a.U sandro.W
0060: 31 34 33 35 33 0a 3c 68 32 3e 53 51 4c 20 66 75 14353.<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 66 6f 72 6d 61 6c 20 72 re many formal r
01f0: 75 6c 65 73 20 74 6f 20 62 65 20 63 61 72 65 66 ules to be caref
0200: 75 6c 6c 79 20 72 65 73 70 65 63 74 65 64 2e 0d ully respected..
0210: 0a 49 6e 66 72 69 6e 67 69 6e 67 20 6f 6e 65 20 .Infringing one
0220: 6f 66 20 73 75 63 68 20 72 75 6c 65 73 20 64 69 of such rules di
0230: 72 65 63 74 6c 79 20 6c 65 61 64 73 20 74 6f 20 rectly leads to
0240: 73 6f 6d 65 20 69 6e 76 61 6c 69 64 20 47 65 6f some invalid Geo
0250: 6d 65 74 72 79 3a 20 61 6e 64 20 61 6e 20 69 6e metry: and an in
0260: 76 61 6c 69 64 20 47 65 6f 6d 65 74 72 79 20 63 valid Geometry c
0270: 6f 75 6c 64 20 63 61 75 73 65 20 69 6e 76 61 6c ould cause inval
0280: 69 64 20 72 65 73 75 6c 74 73 20 74 6f 20 62 65 id results to be
0290: 20 72 65 74 75 72 6e 65 64 2c 20 6f 72 20 63 6f returned, or co
02a0: 75 6c 64 20 65 76 65 6e 74 75 61 6c 6c 79 20 63 uld eventually c
02b0: 61 75 73 65 20 73 6f 6d 65 20 75 6e 65 78 70 65 ause some unexpe
02c0: 63 74 65 64 20 6e 61 73 74 79 20 63 72 61 73 68 cted nasty crash
02d0: 20 69 6e 20 74 68 65 20 77 6f 72 73 74 20 63 61 in the worst ca
02e0: 73 65 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 47 45 4f se.<br><br>..GEO
02f0: 53 20 28 61 6e 64 20 74 68 75 73 20 53 70 61 74 S (and thus Spat
0300: 69 61 4c 69 74 65 29 20 61 6c 72 65 61 64 79 20 iaLite) already
0310: 73 75 70 70 6f 72 74 73 20 74 68 65 20 3c 62 3e supports the <b>
0320: 53 54 5f 49 73 56 61 6c 69 64 28 29 3c 2f 62 3e ST_IsValid()</b>
0330: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 3b 20 62 SQL function; b
0340: 79 20 69 6e 76 6f 6b 69 6e 67 20 74 68 69 73 20 y invoking this
0350: 66 75 6e 63 74 69 6f 6e 20 79 6f 75 20 63 61 6e function you can
0360: 20 65 61 73 69 6c 79 20 69 64 65 6e 74 69 66 79 easily identify
0370: 20 61 6c 6c 20 6f 66 66 65 6e 64 69 6e 67 20 47 all offending G
0380: 65 6f 6d 65 74 72 69 65 73 20 65 76 65 6e 74 75 eometries eventu
0390: 61 6c 6c 79 20 63 6f 6e 74 61 69 6e 65 64 20 77 ally contained w
03a0: 69 74 68 69 6e 20 79 6f 75 72 20 74 61 62 6c 65 ithin your table
03b0: 73 3b 20 61 6e 79 77 61 79 20 79 6f 75 20 63 61 s; anyway you ca
03c0: 6e 6e 6f 74 20 61 74 74 65 6d 70 74 20 74 6f 20 nnot attempt to
03d0: 3c 69 3e 73 61 6e 69 74 69 7a 65 3c 2f 69 3e 20 <i>sanitize</i>
03e0: 74 68 65 6d 2e 3c 62 72 3e 0d 0a 53 70 61 74 69 them.<br>..Spati
03f0: 61 4c 69 74 65 20 61 6c 72 65 61 64 79 20 73 75 aLite already su
0400: 70 70 6f 72 74 65 64 20 61 20 3c 62 3e 53 54 5f pported a <b>ST_
0410: 53 61 6e 69 74 69 7a 65 47 65 6f 6d 65 74 72 79 SanitizeGeometry
0420: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 ()</b> SQL funct
0430: 69 6f 6e 3b 20 62 75 74 20 74 68 69 73 20 77 61 ion; but this wa
0440: 73 20 73 69 6d 70 6c 79 20 63 61 70 61 62 6c 65 s simply capable
0450: 20 74 6f 20 65 66 66 65 63 74 69 76 65 6c 79 20 to effectively
0460: 72 65 73 6f 6c 76 65 20 6a 75 73 74 20 66 65 77 resolve just few
0470: 20 69 6e 76 61 6c 69 64 69 74 79 20 63 61 75 73 invalidity caus
0480: 65 73 2c 20 61 6e 64 20 77 61 73 6e 27 74 20 61 es, and wasn't a
0490: 74 20 61 6c 6c 20 61 20 67 65 6e 65 72 61 6c 20 t all a general
04a0: 73 6f 6c 75 74 69 6f 6e 20 66 6f 72 20 74 68 69 solution for thi
04b0: 73 20 70 72 6f 62 6c 65 6d 2e 3c 62 72 3e 3c 62 s problem.<br><b
04c0: 72 3e 0d 0a 4e 6f 77 2c 20 74 68 61 6e 6b 73 20 r>..Now, thanks
04d0: 74 6f 20 3c 69 3e 6c 69 62 6c 77 67 65 6f 6d 3c to <i>liblwgeom<
04e0: 2f 69 3e 2c 20 53 70 61 74 69 61 4c 69 74 65 20 /i>, SpatiaLite
04f0: 63 61 6e 20 73 75 70 70 6f 72 74 20 74 68 65 20 can support the
0500: 73 61 6d 65 20 69 64 65 6e 74 69 63 61 6c 20 3c same identical <
0510: 62 3e 53 54 5f 4d 61 6b 65 56 61 6c 69 64 28 29 b>ST_MakeValid()
0520: 3c 2f 62 3e 20 61 6c 72 65 61 64 79 20 73 75 70 </b> already sup
0530: 70 6f 72 74 65 64 20 62 79 20 50 6f 73 74 47 49 ported by PostGI
0540: 53 3b 20 66 65 77 20 73 6d 61 6c 6c 20 69 6d 70 S; few small imp
0550: 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 64 65 74 61 lementation deta
0560: 69 6c 73 20 64 69 66 66 65 72 20 28 64 75 65 20 ils differ (due
0570: 74 6f 20 74 68 65 20 68 75 67 65 20 61 72 63 68 to the huge arch
0580: 69 74 65 63 74 75 72 61 6c 20 64 69 66 66 65 72 itectural differ
0590: 65 6e 63 65 73 20 64 69 73 74 69 6e 67 75 69 73 ences distinguis
05a0: 68 69 6e 67 20 50 6f 73 74 47 49 53 20 61 6e 64 hing PostGIS and
05b0: 20 53 70 61 74 69 61 4c 69 74 65 29 2c 20 62 75 SpatiaLite), bu
05c0: 74 20 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 t the underlying
05d0: 20 63 6f 64 65 20 69 73 20 65 78 61 63 74 6c 79 code is exactly
05e0: 20 6f 6e 65 20 61 6e 64 20 74 68 65 20 73 61 6d one and the sam
05f0: 65 20 66 6f 72 20 62 6f 74 68 2e 0d 0a 3c 68 34 e for both...<h4
0600: 3e 61 20 66 69 72 73 74 20 62 61 73 69 63 20 65 >a first basic e
0610: 78 61 6d 70 6c 65 3c 2f 68 34 3e 0d 0a 57 65 27 xample</h4>..We'
0620: 6c 6c 20 73 74 61 72 74 20 6c 6f 61 64 69 6e 67 ll start loading
0630: 20 74 68 65 20 4c 6f 63 61 6c 20 43 6f 75 6e 63 the Local Counc
0640: 69 6c 73 20 61 64 6d 69 6e 69 73 74 72 61 74 69 ils administrati
0650: 76 65 20 62 6f 75 6e 64 61 72 69 65 73 20 73 75 ve boundaries su
0660: 70 70 6c 69 65 64 20 62 79 20 49 53 54 41 54 20 pplied by ISTAT
0670: 28 74 68 65 20 49 74 61 6c 69 61 6e 20 4e 61 74 (the Italian Nat
0680: 69 6f 6e 61 6c 20 53 74 61 74 69 63 73 20 41 67 ional Statics Ag
0690: 65 6e 63 79 29 3a 20 74 68 69 73 20 64 61 74 61 ency): this data
06a0: 73 65 74 20 69 73 20 66 72 65 65 6c 79 20 61 76 set is freely av
06b0: 61 69 6c 61 62 6c 65 20 66 6f 72 20 3c 61 20 68 ailable for <a h
06c0: 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e ref="http://www.
06d0: 69 73 74 61 74 2e 69 74 2f 75 70 6c 6f 61 64 73 istat.it/uploads
06e0: 2f 63 6f 6d 32 30 31 31 2e 7a 69 70 22 3e 64 6f /com2011.zip">do
06f0: 77 6e 6c 6f 61 64 3c 2f 61 3e 20 75 6e 64 65 72 wnload</a> under
0700: 20 61 20 43 43 2d 42 59 20 6c 69 63 65 6e 73 65 a CC-BY license
0710: 2e 0d 0a 4a 75 73 74 20 61 20 71 75 69 63 6b 20 ...Just a quick
0720: 63 68 65 63 6b 2c 20 61 6e 64 20 77 65 27 6c 6c check, and we'll
0730: 20 73 6f 6f 6e 20 64 69 73 63 6f 76 65 72 20 74 soon discover t
0740: 68 61 74 20 74 68 69 73 20 64 61 74 61 73 65 74 hat this dataset
0750: 20 61 63 74 75 61 6c 6c 79 20 63 6f 6e 74 61 69 actually contai
0760: 6e 73 20 73 65 76 65 72 61 6c 20 6d 61 6c 66 6f ns several malfo
0770: 72 6d 65 64 20 50 6f 6c 79 67 6f 6e 73 3a 0d 0a rmed Polygons:..
0780: 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 <table bgcolor="
0790: 23 65 30 65 30 65 30 22 20 63 65 6c 6c 73 70 61 #e0e0e0" cellspa
07a0: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 cing="4" cellpad
07b0: 64 69 6e 67 3d 22 38 22 3e 0d 0a 3c 74 72 3e 3c ding="8">..<tr><
07c0: 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 54 20 43 td>..<b>SELECT C
07d0: 6f 75 6e 74 28 2a 29 3c 62 72 3e 0d 0a 46 52 4f ount(*)<br>..FRO
07e0: 4d 20 63 6f 6d 32 30 31 31 3c 62 72 3e 0d 0a 57 M com2011<br>..W
07f0: 48 45 52 45 20 53 54 5f 49 73 56 61 6c 69 64 28 HERE ST_IsValid(
0800: 67 65 6f 6d 65 74 72 79 29 20 3d 20 30 3b 3c 2f geometry) = 0;</
0810: 62 3e 0d 0a 3c 68 72 3e 0d 0a 31 39 0d 0a 3c 2f b>..<hr>..19..</
0820: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c td></tr>..</tabl
0830: 65 3e 3c 62 72 3e 0d 0a 52 65 63 6f 76 65 72 69 e><br>..Recoveri
0840: 6e 67 20 61 6c 6c 20 6d 61 6c 66 6f 72 6d 65 64 ng all malformed
0850: 20 47 65 6f 6d 65 74 72 69 65 73 20 69 73 20 6e Geometries is n
0860: 6f 77 20 61 62 73 6f 6c 75 74 65 6c 79 20 73 69 ow absolutely si
0870: 6d 70 6c 65 20 61 6e 64 20 65 61 73 79 3a 0d 0a mple and easy:..
0880: 3c 74 61 62 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 <table bgcolor="
0890: 23 65 30 65 30 65 30 22 20 63 65 6c 6c 73 70 61 #e0e0e0" cellspa
08a0: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 cing="4" cellpad
08b0: 64 69 6e 67 3d 22 38 22 3e 3c 74 72 3e 3c 74 64 ding="8"><tr><td
08c0: 3e 0d 0a 3c 62 3e 55 50 44 41 54 45 20 63 6f 6d >..<b>UPDATE com
08d0: 32 30 31 31 20 53 45 54 20 67 65 6f 6d 65 74 72 2011 SET geometr
08e0: 79 20 3d 20 53 54 5f 4d 61 6b 65 56 61 6c 69 64 y = ST_MakeValid
08f0: 28 67 65 6f 6d 65 74 72 79 29 3c 62 72 3e 0d 0a (geometry)<br>..
0900: 57 48 45 52 45 20 53 54 5f 49 73 56 61 6c 69 64 WHERE ST_IsValid
0910: 28 67 65 6f 6d 65 74 72 79 29 20 3d 20 30 3b 3c (geometry) = 0;<
0920: 2f 62 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d /b>..</td></tr>.
0930: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 .<tr><td>..<b>SE
0940: 4c 45 43 54 20 43 6f 75 6e 74 28 2a 29 3c 62 72 LECT Count(*)<br
0950: 3e 0d 0a 46 52 4f 4d 20 63 6f 6d 32 30 31 31 3c >..FROM com2011<
0960: 62 72 3e 0d 0a 57 48 45 52 45 20 53 54 5f 49 73 br>..WHERE ST_Is
0970: 56 61 6c 69 64 28 67 65 6f 6d 65 74 72 79 29 20 Valid(geometry)
0980: 3d 20 30 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a = 0;</b>..<hr>..
0990: 30 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 0..</td></tr>..<
09a0: 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 61 /table><br>..<ta
09b0: 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 ble border="1" c
09c0: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
09d0: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d ellpadding="4">.
09e0: 0a 3c 74 72 3e 3c 74 68 20 63 6f 6c 73 70 61 6e .<tr><th colspan
09f0: 3d 22 32 22 3e 57 68 79 20 74 68 65 20 42 72 6f ="2">Why the Bro
0a00: 6e 74 65 20 4c 6f 63 61 6c 20 43 6f 75 6e 63 69 nte Local Counci
0a10: 6c 20 62 6f 75 6e 64 61 72 79 20 77 61 73 20 6d l boundary was m
0a20: 61 6c 66 6f 72 6d 65 64 20 3f 3c 62 72 3e 0d 0a alformed ?<br>..
0a30: 61 20 71 75 69 63 6b 20 61 6e 61 6c 79 73 69 73 a quick analysis
0a40: 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </th></tr>..<tr>
0a50: 3c 74 68 3e 6d 61 6c 66 6f 72 6d 65 64 20 2f 20 <th>malformed /
0a60: 69 6e 76 61 6c 69 64 3c 2f 74 68 3e 3c 74 68 3e invalid</th><th>
0a70: 76 61 6c 69 64 3c 2f 74 68 3e 3c 2f 74 72 3e 0d valid</th></tr>.
0a80: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 .<tr><td>..<img
0a90: 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e src="http://www.
0aa0: 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 gaia-gis.it/gaia
0ab0: 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 -sins/write-view
0ac0: 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d 69 6e 76 -pics/bronte-inv
0ad0: 61 6c 69 64 2e 70 6e 67 22 20 61 6c 74 3d 22 62 alid.png" alt="b
0ae0: 72 6f 6e 74 65 20 69 6e 76 61 6c 69 64 22 3e 0d ronte invalid">.
0af0: 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 .</td><td>..<img
0b00: 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 src="http://www
0b10: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 .gaia-gis.it/gai
0b20: 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 a-sins/write-vie
0b30: 77 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d 76 61 w-pics/bronte-va
0b40: 6c 69 64 2e 70 6e 67 22 20 61 6c 74 3d 22 62 72 lid.png" alt="br
0b50: 6f 6e 74 65 20 76 61 6c 69 64 22 3e 0d 0a 3c 2f onte valid">..</
0b60: 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 td></tr>..<tr><t
0b70: 64 20 63 6f 6c 73 70 61 6e 3d 22 32 22 3e 0d 0a d colspan="2">..
0b80: 41 73 20 79 6f 75 20 63 61 6e 20 65 61 73 69 6c As you can easil
0b90: 79 20 6e 6f 74 69 63 65 2c 20 74 68 65 20 3c 69 y notice, the <i
0ba0: 3e 69 6e 76 61 6c 69 64 3c 2f 69 3e 20 70 6f 6c >invalid</i> pol
0bb0: 79 67 6f 6e 20 77 61 73 20 73 69 6d 70 6c 79 20 ygon was simply
0bc0: 72 65 70 72 65 73 65 6e 74 20 62 79 20 74 68 65 represent by the
0bd0: 20 3c 69 3e 65 78 74 65 72 69 6f 72 20 72 69 6e <i>exterior rin
0be0: 67 3c 2f 69 3e 3a 20 62 75 74 20 74 68 65 72 65 g</i>: but there
0bf0: 20 69 73 20 61 20 68 75 67 65 20 69 6e 74 65 72 is a huge inter
0c00: 6e 61 6c 20 68 6f 6c 65 20 69 6e 20 74 68 69 73 nal hole in this
0c10: 20 50 6f 6c 79 67 6f 6e 2e 0d 0a 54 68 69 73 20 Polygon...This
0c20: 6f 64 64 20 63 6f 6e 64 69 74 69 6f 6e 20 69 73 odd condition is
0c30: 20 72 65 70 75 74 65 64 20 70 65 72 66 65 63 74 reputed perfect
0c40: 6c 79 20 76 61 6c 69 64 20 62 79 20 73 6f 6d 65 ly valid by some
0c50: 20 6d 61 69 6e 73 74 72 65 61 6d 20 70 72 6f 70 mainstream prop
0c60: 72 69 65 74 61 72 79 20 73 6f 66 74 77 61 72 65 rietary software
0c70: 3b 20 61 6e 79 77 61 79 2c 20 69 73 20 61 63 74 ; anyway, is act
0c80: 75 61 6c 6c 79 20 3c 69 3e 69 6e 76 61 6c 69 64 ually <i>invalid
0c90: 3c 2f 69 3e 20 61 63 63 6f 72 64 69 6e 67 6c 79 </i> accordingly
0ca0: 20 74 6f 20 73 74 61 6e 64 61 72 64 20 72 75 6c to standard rul
0cb0: 65 73 2e 3c 62 72 3e 0d 0a 53 6f 20 74 68 65 20 es.<br>..So the
0cc0: 63 6f 72 72 65 63 74 20 72 65 70 72 65 73 65 6e correct represen
0cd0: 74 61 74 69 6f 6e 20 66 6f 72 20 74 68 69 73 20 tation for this
0ce0: 50 6f 6c 79 67 6f 6e 20 72 65 71 75 69 72 65 73 Polygon requires
0cf0: 20 61 6e 20 3c 69 3e 65 78 74 65 72 69 6f 72 20 an <i>exterior
0d00: 72 69 6e 67 3c 2f 69 3e 20 61 6e 64 20 61 20 73 ring</i> and a s
0d10: 65 70 61 72 61 74 65 20 3c 69 3e 69 6e 74 65 72 eparate <i>inter
0d20: 69 6f 72 20 72 69 6e 67 3c 2f 69 3e 3b 20 53 54 ior ring</i>; ST
0d30: 5f 4d 61 6b 65 56 61 6c 69 64 28 29 20 64 6f 65 _MakeValid() doe
0d40: 73 20 74 68 65 20 6d 61 67 69 63 2c 20 74 68 75 s the magic, thu
0d50: 73 20 72 65 63 6f 76 65 72 69 6e 67 20 61 20 66 s recovering a f
0d60: 75 6c 6c 20 76 61 6c 69 64 20 50 6f 6c 79 67 6f ull valid Polygo
0d70: 6e 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a n...</td></tr>..
0d80: 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 68 34 3e 61 20 </table>..<h4>a
0d90: 73 65 63 6f 6e 64 20 6d 6f 72 65 20 65 6c 61 62 second more elab
0da0: 6f 72 61 74 65 20 65 78 61 6d 70 6c 65 3c 2f 68 orate example</h
0db0: 34 3e 0d 0a 54 68 69 73 20 74 69 6d 65 20 77 65 4>..This time we
0dc0: 27 6c 6c 20 70 75 72 70 6f 73 65 6c 79 20 63 72 'll purposely cr
0dd0: 65 61 74 65 20 61 20 73 65 76 65 72 65 6c 79 20 eate a severely
0de0: 6d 61 6c 66 6f 72 6d 65 64 20 50 6f 6c 79 67 6f malformed Polygo
0df0: 6e 3a 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f 6c n:..<table bgcol
0e00: 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 65 6c or="#e0e0e0" cel
0e10: 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c lspacing="4" cel
0e20: 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e 0d 0a 3c lpadding="8">..<
0e30: 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 tr><td>..<b>SELE
0e40: 43 54 20 67 2c 20 53 54 5f 4d 61 6b 65 56 61 6c CT g, ST_MakeVal
0e50: 69 64 28 67 29 2c 20 53 54 5f 4d 61 6b 65 56 61 id(g), ST_MakeVa
0e60: 6c 69 64 44 69 73 63 61 72 64 65 64 28 67 29 3c lidDiscarded(g)<
0e70: 62 72 3e 0d 0a 46 52 4f 4d 20 28 3c 62 72 3e 0d br>..FROM (<br>.
0e80: 0a 53 45 4c 45 43 54 20 53 54 5f 47 65 6f 6d 46 .SELECT ST_GeomF
0e90: 72 6f 6d 54 65 78 74 28 27 50 4f 4c 59 47 4f 4e romText('POLYGON
0ea0: 28 28 30 20 30 2c 20 30 20 31 30 2c 20 31 31 20 ((0 0, 0 10, 11
0eb0: 31 30 2c 20 31 30 20 31 30 2c 20 31 30 20 31 2c 10, 10 10, 10 1,
0ec0: 20 35 20 31 2c 20 35 20 39 2c 20 35 20 31 2c 20 5 1, 5 9, 5 1,
0ed0: 30 20 31 2c 20 30 20 30 29 29 27 29 20 41 53 20 0 1, 0 0))') AS
0ee0: 67 3c 62 72 3e 0d 0a 29 3b 3c 2f 62 3e 0d 0a 3c g<br>..);</b>..<
0ef0: 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 /td></tr>..</tab
0f00: 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 le><br>..<table
0f10: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 cellspacing="4"
0f20: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e cellpadding="4">
0f30: 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 69 73 ..<tr><td>..This
0f40: 20 66 69 67 75 72 65 20 72 65 70 72 65 73 65 6e figure represen
0f50: 74 73 20 74 68 65 20 3c 69 3e 69 6e 76 61 6c 69 ts the <i>invali
0f60: 64 3c 2f 69 3e 20 50 6f 6c 79 67 6f 6e 20 72 65 d</i> Polygon re
0f70: 74 75 72 6e 65 64 20 62 79 20 3c 62 3e 53 54 5f turned by <b>ST_
0f80: 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 29 3c 2f GeomFromText()</
0f90: 62 3e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 54 68 65 b>.<br><br>..The
0fa0: 72 65 20 61 72 65 20 74 68 72 65 65 20 3c 69 3e re are three <i>
0fb0: 73 70 69 6b 65 73 3c 2f 69 3e 20 69 6e 20 74 68 spikes</i> in th
0fc0: 65 20 3c 69 3e 65 78 74 65 72 69 6f 72 20 72 69 e <i>exterior ri
0fd0: 6e 67 3c 2f 69 3e 2c 20 61 6e 64 20 74 68 69 73 ng</i>, and this
0fe0: 20 6f 6e 65 20 73 75 72 65 6c 79 20 69 73 20 61 one surely is a
0ff0: 20 73 65 76 65 72 65 20 69 6e 76 61 6c 69 64 69 severe invalidi
1000: 74 79 20 63 61 75 73 65 2e 0d 0a 3c 2f 74 64 3e ty cause...</td>
1010: 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 <td>..<img src="
1020: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d http://www.gaia-
1030: 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 gis.it/gaia-sins
1040: 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 /write-view-pics
1050: 2f 73 70 69 6b 65 2d 69 6e 76 61 6c 69 64 2e 70 /spike-invalid.p
1060: 6e 67 22 20 61 6c 74 3d 22 73 70 69 6b 65 20 69 ng" alt="spike i
1070: 6e 76 61 6c 69 64 22 3e 0d 0a 3c 2f 74 64 3e 3c nvalid">..</td><
1080: 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a /tr>..<tr><td>..
1090: 54 68 69 73 20 66 69 67 75 72 65 20 72 65 70 72 This figure repr
10a0: 65 73 65 6e 74 73 20 74 68 65 20 3c 69 3e 76 61 esents the <i>va
10b0: 6c 69 64 3c 2f 69 3e 20 50 6f 6c 79 67 6f 6e 20 lid</i> Polygon
10c0: 72 65 74 75 72 6e 65 64 20 62 79 20 3c 62 3e 53 returned by <b>S
10d0: 54 5f 4d 61 6b 65 56 61 6c 69 64 28 29 3c 2f 62 T_MakeValid()</b
10e0: 3e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 4e 6f 77 20 >.<br><br>..Now
10f0: 77 65 20 68 61 76 65 20 61 20 6e 69 63 65 20 72 we have a nice r
1100: 65 67 75 6c 61 72 20 72 65 63 74 61 6e 67 6c 65 egular rectangle
1110: 2c 20 61 6c 6c 20 3c 69 3e 73 70 69 6b 65 73 3c , all <i>spikes<
1120: 2f 69 3e 20 68 61 76 65 20 62 65 65 6e 20 72 65 /i> have been re
1130: 6d 6f 76 65 64 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 moved...</td><td
1140: 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 >..<img src="htt
1150: 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 p://www.gaia-gis
1160: 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 72 .it/gaia-sins/wr
1170: 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f 73 70 ite-view-pics/sp
1180: 69 6b 65 2d 76 61 6c 69 64 2e 70 6e 67 22 20 61 ike-valid.png" a
1190: 6c 74 3d 22 73 70 69 6b 65 20 76 61 6c 69 64 22 lt="spike valid"
11a0: 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c >..</td></tr>..<
11b0: 74 72 3e 3c 74 64 3e 0d 0a 41 6e 79 77 61 79 20 tr><td>..Anyway
11c0: 74 68 65 20 72 65 6d 6f 76 65 64 20 3c 69 3e 73 the removed <i>s
11d0: 70 69 6b 65 73 3c 2f 69 3e 20 61 72 65 6e 27 74 pikes</i> aren't
11e0: 20 73 69 6d 70 6c 79 20 76 61 6e 69 73 68 65 64 simply vanished
11f0: 20 69 6e 74 6f 20 6e 6f 74 68 69 6e 67 2e 0d 0a into nothing...
1200: 59 6f 75 20 63 6f 75 6c 64 20 65 76 65 6e 74 75 You could eventu
1210: 61 6c 6c 79 20 72 65 74 72 69 65 76 65 20 28 61 ally retrieve (a
1220: 6e 64 20 6d 61 79 20 62 65 2c 20 73 61 76 69 6e nd may be, savin
1230: 67 20 73 6f 6d 65 77 68 65 72 65 20 66 6f 72 20 g somewhere for
1240: 66 75 72 74 68 65 72 20 70 72 6f 63 65 73 73 69 further processi
1250: 6e 67 20 2f 20 65 64 69 74 69 6e 67 29 20 61 6c ng / editing) al
1260: 6c 20 6f 66 66 65 6e 64 69 6e 67 20 65 6c 65 6d l offending elem
1270: 65 6e 74 73 20 62 65 69 6e 67 20 64 69 73 63 61 ents being disca
1280: 72 64 65 64 20 64 75 72 69 6e 67 20 74 68 65 20 rded during the
1290: 76 61 6c 69 64 61 74 69 6f 6e 20 70 72 6f 63 65 validation proce
12a0: 73 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 59 6f 75 ss.<br><br>..You
12b0: 20 73 69 6d 70 6c 79 20 68 61 76 65 20 74 6f 20 simply have to
12c0: 69 6e 76 6f 6b 65 20 3c 62 3e 53 54 5f 4d 61 6b invoke <b>ST_Mak
12d0: 65 56 61 6c 69 64 44 69 73 63 61 72 64 65 64 28 eValidDiscarded(
12e0: 29 3c 2f 62 3e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c )</b><br><br>..<
12f0: 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 u>Please note</u
1300: 3e 3a 20 74 68 69 73 20 69 73 20 73 74 72 6f 6e >: this is stron
1310: 67 6c 79 20 64 69 66 66 65 72 65 6e 74 20 66 72 gly different fr
1320: 6f 6d 20 74 68 65 20 50 6f 73 74 47 49 53 20 6f om the PostGIS o
1330: 77 6e 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f wn implementatio
1340: 6e 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c n...</td><td>..<
1350: 69 6d 67 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f img src="http://
1360: 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f www.gaia-gis.it/
1370: 67 61 69 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d gaia-sins/write-
1380: 76 69 65 77 2d 70 69 63 73 2f 73 70 69 6b 65 2d view-pics/spike-
1390: 64 69 73 63 61 72 64 65 64 2e 70 6e 67 22 20 61 discarded.png" a
13a0: 6c 74 3d 22 73 70 69 6b 65 20 64 69 73 63 61 72 lt="spike discar
13b0: 64 65 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 ded">..</td></tr
13c0: 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 >..</table>..<br
13d0: 3e 3c 68 72 3e 0d 0a 3c 68 33 3e 53 70 6c 69 74 ><hr>..<h3>Split
13e0: 74 69 6e 67 20 67 65 6f 6d 65 74 72 69 65 73 20 ting geometries
13f0: 69 6e 20 74 77 6f 20 68 61 6c 76 65 73 3c 2f 68 in two halves</h
1400: 33 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 70 3>..The <b>ST_Sp
1410: 6c 69 74 28 29 3c 2f 62 3e 20 53 70 61 74 69 61 lit()</b> Spatia
1420: 6c 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 69 l SQL function i
1430: 73 20 69 6e 74 65 6e 64 65 64 20 74 6f 20 3c 69 s intended to <i
1440: 3e 63 75 74 3c 2f 69 3e 20 61 20 47 65 6f 6d 65 >cut</i> a Geome
1450: 74 72 79 2e 3c 62 72 3e 0d 0a 54 68 69 73 20 66 try.<br>..This f
1460: 75 6e 63 74 69 6f 6e 20 61 6c 77 61 79 73 20 72 unction always r
1470: 65 71 75 69 72 65 73 20 74 6f 20 70 61 73 73 20 equires to pass
1480: 74 77 6f 20 64 69 66 66 65 72 65 6e 74 20 47 65 two different Ge
1490: 6f 6d 65 74 72 69 65 73 3a 3c 75 6c 3e 0d 0a 3c ometries:<ul>..<
14a0: 6c 69 3e 74 68 65 20 66 69 72 73 74 20 47 65 6f li>the first Geo
14b0: 6d 65 74 72 79 20 69 73 20 61 73 73 75 6d 65 64 metry is assumed
14c0: 20 74 6f 20 72 65 70 72 65 73 65 6e 74 20 74 68 to represent th
14d0: 65 20 3c 62 3e 69 6e 70 75 74 3c 2f 62 3e 20 61 e <b>input</b> a
14e0: 6b 61 20 3c 62 3e 74 61 72 67 65 74 3c 2f 62 3e ka <b>target</b>
14f0: 20 74 6f 20 62 65 20 73 70 6c 69 74 2e 3c 2f 6c to be split.</l
1500: 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20 73 65 63 6f i>..<li>the seco
1510: 6e 64 20 47 65 6f 6d 65 74 72 79 20 69 73 20 61 nd Geometry is a
1520: 73 73 75 6d 65 64 20 74 6f 20 72 65 70 72 65 73 ssumed to repres
1530: 65 6e 74 20 74 68 65 20 3c 62 3e 62 6c 61 64 65 ent the <b>blade
1540: 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c </b>.</li>..</ul
1550: 3e 0d 0a 4f 6e 6c 79 20 74 68 65 20 66 6f 6c 6c >..Only the foll
1560: 6f 77 69 6e 67 20 63 6f 6e 66 69 67 75 72 61 74 owing configurat
1570: 69 6f 6e 73 20 61 72 65 20 61 73 73 75 6d 65 64 ions are assumed
1580: 20 74 6f 20 62 65 20 76 61 6c 69 64 3a 3c 75 6c to be valid:<ul
1590: 3e 0d 0a 3c 6c 69 3e 4c 69 6e 65 73 74 72 69 6e >..<li>Linestrin
15a0: 67 20 74 61 72 67 65 74 20 2f 20 50 6f 69 6e 74 g target / Point
15b0: 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c blade.</li>..<l
15c0: 69 3e 4d 75 6c 74 69 4c 69 6e 65 73 74 72 69 6e i>MultiLinestrin
15d0: 67 20 74 61 72 67 65 74 20 2f 20 50 6f 69 6e 74 g target / Point
15e0: 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c blade.</li>..<l
15f0: 69 3e 47 65 6f 6d 65 74 72 79 43 6f 6c 6c 65 63 i>GeometryCollec
1600: 74 69 6f 6e 20 28 63 6f 6e 74 61 69 6e 69 6e 67 tion (containing
1610: 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 4c 69 at least one Li
1620: 6e 65 73 74 72 69 6e 67 29 20 2f 20 50 6f 69 6e nestring) / Poin
1630: 74 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c t blade.</li>..<
1640: 6c 69 3e 4c 69 6e 65 73 74 72 69 6e 67 20 74 61 li>Linestring ta
1650: 72 67 65 74 20 2f 20 4c 69 6e 65 73 74 72 69 6e rget / Linestrin
1660: 67 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d 0a 3c g blade.</li>..<
1670: 6c 69 3e 4d 75 6c 74 69 4c 69 6e 65 73 74 72 69 li>MultiLinestri
1680: 6e 67 20 74 61 72 67 65 74 20 2f 20 4c 69 6e 65 ng target / Line
1690: 73 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c 2f 6c string blade.</l
16a0: 69 3e 0d 0a 3c 6c 69 3e 50 6f 6c 79 67 6f 6e 20 i>..<li>Polygon
16b0: 74 61 72 67 65 74 20 2f 20 4c 69 6e 65 73 74 72 target / Linestr
16c0: 69 6e 67 20 62 6c 61 64 65 2e 3c 2f 6c 69 3e 0d ing blade.</li>.
16d0: 0a 3c 6c 69 3e 4d 75 6c 74 69 50 6f 6c 79 67 6f .<li>MultiPolygo
16e0: 6e 20 74 61 72 67 65 74 20 2f 20 4c 69 6e 65 73 n target / Lines
16f0: 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c 2f 6c 69 tring blade.</li
1700: 3e 0d 0a 3c 6c 69 3e 47 65 6f 6d 65 74 72 79 43 >..<li>GeometryC
1710: 6f 6c 6c 65 63 74 69 6f 6e 20 2f 20 4c 69 6e 65 ollection / Line
1720: 73 74 72 69 6e 67 20 62 6c 61 64 65 2e 3c 2f 6c string blade.</l
1730: 69 3e 0d 0a 3c 6c 69 3e 50 6c 65 61 73 65 20 6e i>..<li>Please n
1740: 6f 74 69 63 65 3a 20 74 68 65 20 74 61 72 67 65 otice: the targe
1750: 74 20 47 65 6f 6d 65 74 72 79 20 73 68 6f 75 6c t Geometry shoul
1760: 64 20 6e 65 76 65 72 20 63 6f 6e 74 61 69 6e 20 d never contain
1770: 61 20 50 6f 69 6e 74 2e 3c 2f 6c 69 3e 0d 0a 3c a Point.</li>..<
1780: 2f 75 6c 3e 0d 0a 3c 68 34 3e 45 78 61 6d 70 6c /ul>..<h4>Exampl
1790: 65 20 23 31 20 2d 20 73 70 6c 69 74 74 69 6e 67 e #1 - splitting
17a0: 20 61 20 4c 69 6e 65 73 74 72 69 6e 67 20 62 79 a Linestring by
17b0: 20 61 20 50 6f 69 6e 74 20 62 6c 61 64 65 3c 2f a Point blade</
17c0: 68 34 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f h4>..<table bgco
17d0: 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 65 lor="#e0e0e0" ce
17e0: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 llspacing="4" ce
17f0: 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e 0d 0a llpadding="8">..
1800: 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c <tr><td>..<b>SEL
1810: 45 43 54 20 53 54 5f 53 70 6c 69 74 28 69 6e 70 ECT ST_Split(inp
1820: 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 2c 20 ut.g, blade.g),
1830: 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 69 6e 70 ST_SplitLeft(inp
1840: 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 2c 20 ut.g, blade.g),
1850: 53 54 5f 53 70 6c 69 74 52 69 67 68 74 28 69 6e ST_SplitRight(in
1860: 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 3c put.g, blade.g)<
1870: 62 72 3e 0d 0a 46 52 4f 4d 3c 62 72 3e 20 0d 0a br>..FROM<br> ..
1880: 28 53 45 4c 45 43 54 20 47 65 6f 6d 46 72 6f 6d (SELECT GeomFrom
1890: 54 65 78 74 28 27 4c 49 4e 45 53 54 52 49 4e 47 Text('LINESTRING
18a0: 28 30 20 31 30 2c 20 32 20 30 2c 20 34 20 34 2c (0 10, 2 0, 4 4,
18b0: 20 36 20 30 2c 20 31 30 20 31 30 29 27 29 20 41 6 0, 10 10)') A
18c0: 53 20 67 29 20 41 53 20 69 6e 70 75 74 2c 3c 62 S g) AS input,<b
18d0: 72 3e 0d 0a 28 53 45 4c 45 43 54 20 47 65 6f 6d r>..(SELECT Geom
18e0: 46 72 6f 6d 54 65 78 74 28 27 50 4f 49 4e 54 28 FromText('POINT(
18f0: 33 20 32 29 27 29 20 41 53 20 67 29 20 41 53 20 3 2)') AS g) AS
1900: 62 6c 61 64 65 3b 3c 2f 62 3e 0d 0a 3c 2f 74 64 blade;</b>..</td
1910: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 0d 0a ></tr></table>..
1920: 3c 74 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 <table cellspaci
1930: 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 ng="4" cellpaddi
1940: 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 64 ng="4">..<tr><td
1950: 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 70 6c >..The <b>ST_Spl
1960: 69 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e it()</b> SQL fun
1970: 63 74 69 6f 6e 20 77 69 6c 6c 20 73 69 6d 70 6c ction will simpl
1980: 79 20 72 65 74 75 72 6e 20 61 20 3c 69 3e 63 6f y return a <i>co
1990: 6c 6c 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 llection</i> agg
19a0: 72 65 67 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 regating all fra
19b0: 67 6d 65 6e 74 73 20 64 65 72 69 76 69 6e 67 20 gments deriving
19c0: 66 72 6f 6d 20 74 68 65 20 63 75 74 2e 0d 0a 54 from the cut...T
19d0: 68 69 73 20 69 73 6e 27 74 20 72 65 61 6c 6c 79 his isn't really
19e0: 20 75 73 65 66 75 6c 20 6f 6e 20 6d 61 6e 79 20 useful on many
19f0: 63 61 73 65 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a cases.<br><br>..
1a00: 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f <u>Please note</
1a10: 75 3e 3a 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 6f u>: <i>collectio
1a20: 6e 73 3c 2f 69 3e 20 69 6e 20 53 70 61 74 69 61 ns</i> in Spatia
1a30: 4c 69 74 65 20 62 65 68 61 76 65 20 71 75 69 74 Lite behave quit
1a40: 65 20 64 69 66 66 65 72 65 6e 74 6c 79 20 66 72 e differently fr
1a50: 6f 6d 20 50 6f 73 74 47 69 73 2e 0d 0a 3c 2f 74 om PostGis...</t
1a60: 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 d><td>..<img src
1a70: 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 ="http://www.gai
1a80: 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 a-gis.it/gaia-si
1a90: 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 ns/write-view-pi
1aa0: 63 73 2f 73 70 6c 69 74 2d 6c 6e 2e 70 6e 67 22 cs/split-ln.png"
1ab0: 20 61 6c 74 3d 22 73 70 6c 69 74 20 6c 69 6e 65 alt="split line
1ac0: 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a ">..</td></tr>..
1ad0: 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 20 3c 62 <tr><td>..The <b
1ae0: 3e 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 29 3c >ST_SplitLeft()<
1af0: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e /b> SQL function
1b00: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 69 6e 73 will return ins
1b10: 74 65 61 64 20 61 20 3c 69 3e 63 6f 6c 6c 65 63 tead a <i>collec
1b20: 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 67 61 tion</i> aggrega
1b30: 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d 65 6e ting all fragmen
1b40: 74 73 20 6c 61 79 69 6e 67 20 6f 6e 20 74 68 65 ts laying on the
1b50: 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 73 69 64 <i>left</i> sid
1b60: 65 20 6f 66 20 74 68 65 20 63 75 74 2e 3c 62 72 e of the cut.<br
1b70: 3e 0d 0a 46 6f 72 20 4c 69 6e 65 73 74 72 69 6e >..For Linestrin
1b80: 67 73 20 79 6f 75 20 63 61 6e 6e 6f 74 20 69 6e gs you cannot in
1b90: 74 65 6e 64 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e tend <i>left</i>
1ba0: 20 69 6e 20 74 68 65 20 76 65 72 79 20 6c 69 74 in the very lit
1bb0: 65 72 61 6c 20 73 65 6e 73 65 3b 20 74 68 69 73 eral sense; this
1bc0: 20 72 65 61 6c 6c 79 20 6d 65 61 6e 73 20 3c 69 really means <i
1bd0: 3e 74 68 65 20 73 69 64 65 20 77 68 65 72 65 20 >the side where
1be0: 74 68 65 20 73 74 61 72 74 2d 70 6f 69 6e 74 20 the start-point
1bf0: 6c 61 79 3c 2f 69 3e 2e 3c 62 72 3e 3c 62 72 3e lay</i>.<br><br>
1c00: 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 ..<u>Please note
1c10: 3c 2f 75 3e 3a 20 69 66 20 74 68 65 20 3c 69 3e </u>: if the <i>
1c20: 62 6c 61 64 65 3c 2f 69 3e 20 64 6f 65 73 6e 27 blade</i> doesn'
1c30: 74 20 69 6e 74 65 72 63 65 70 74 73 20 74 68 65 t intercepts the
1c40: 20 74 61 72 67 65 74 20 61 74 20 61 6c 6c 2c 20 target at all,
1c50: 74 68 61 6e 20 6e 6f 20 63 75 74 20 77 6f 75 6c than no cut woul
1c60: 64 20 62 65 20 6f 62 76 69 6f 75 73 6c 79 20 70 d be obviously p
1c70: 6f 73 73 69 62 6c 65 2e 20 49 6e 20 74 68 69 73 ossible. In this
1c80: 20 73 70 65 63 69 61 6c 20 63 61 73 65 20 74 68 special case th
1c90: 65 20 6f 72 69 67 69 6e 61 6c 20 74 61 72 67 65 e original targe
1ca0: 74 20 47 65 6f 6d 65 74 72 79 20 77 69 6c 6c 20 t Geometry will
1cb0: 62 65 20 61 6c 77 61 79 73 20 72 65 74 75 72 6e be always return
1cc0: 65 64 20 28 61 62 73 6f 6c 75 74 65 6c 79 20 75 ed (absolutely u
1cd0: 6e 63 68 61 6e 67 65 64 29 20 6f 6e 20 74 68 65 nchanged) on the
1ce0: 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 73 69 64 <i>left</i> sid
1cf0: 65 20 63 6f 6c 6c 65 63 74 69 6f 6e 2e 0d 0a 3c e collection...<
1d00: 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 /td><td>..<img s
1d10: 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 rc="http://www.g
1d20: 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d aia-gis.it/gaia-
1d30: 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d sins/write-view-
1d40: 70 69 63 73 2f 73 70 6c 69 74 2d 6c 6e 2d 4c 2e pics/split-ln-L.
1d50: 70 6e 67 22 20 61 6c 74 3d 22 73 70 6c 69 74 2d png" alt="split-
1d60: 6c 65 66 74 20 6c 69 6e 65 22 3e 0d 0a 3c 2f 74 left line">..</t
1d70: 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 d></tr>..<tr><td
1d80: 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 70 6c >..The <b>ST_Spl
1d90: 69 74 52 69 67 68 74 28 29 3c 2f 62 3e 20 53 51 itRight()</b> SQ
1da0: 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 L function will
1db0: 72 65 74 75 72 6e 20 61 20 3c 69 3e 63 6f 6c 6c return a <i>coll
1dc0: 65 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 ection</i> aggre
1dd0: 67 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d gating all fragm
1de0: 65 6e 74 73 20 6c 61 79 69 6e 67 20 6f 6e 20 74 ents laying on t
1df0: 68 65 20 3c 69 3e 72 69 67 68 74 3c 2f 69 3e 20 he <i>right</i>
1e00: 73 69 64 65 20 6f 66 20 74 68 65 20 63 75 74 2e side of the cut.
1e10: 3c 62 72 3e 0d 0a 46 6f 72 20 4c 69 6e 65 73 74 <br>..For Linest
1e20: 72 69 6e 67 73 20 79 6f 75 20 63 61 6e 6e 6f 74 rings you cannot
1e30: 20 69 6e 74 65 6e 64 20 3c 69 3e 72 69 67 68 74 intend <i>right
1e40: 3c 2f 69 3e 20 69 6e 20 74 68 65 20 76 65 72 79 </i> in the very
1e50: 20 6c 69 74 65 72 61 6c 20 73 65 6e 73 65 3b 20 literal sense;
1e60: 74 68 69 73 20 72 65 61 6c 6c 79 20 6d 65 61 6e this really mean
1e70: 73 20 3c 69 3e 74 68 65 20 73 69 64 65 20 77 68 s <i>the side wh
1e80: 65 72 65 20 74 68 65 20 65 6e 64 2d 70 6f 69 6e ere the end-poin
1e90: 74 20 6c 61 79 3c 2f 69 3e 2e 3c 62 72 3e 3c 62 t lay</i>.<br><b
1ea0: 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f r>..<u>Please no
1eb0: 74 65 3c 2f 75 3e 3a 20 69 66 20 74 68 65 20 3c te</u>: if the <
1ec0: 69 3e 62 6c 61 64 65 3c 2f 69 3e 20 64 6f 65 73 i>blade</i> does
1ed0: 6e 27 74 20 69 6e 74 65 72 63 65 70 74 73 20 74 n't intercepts t
1ee0: 68 65 20 74 61 72 67 65 74 20 61 74 20 61 6c 6c he target at all
1ef0: 2c 20 74 68 61 6e 20 6e 6f 20 63 75 74 20 77 6f , than no cut wo
1f00: 75 6c 64 20 62 65 20 6f 62 76 69 6f 75 73 6c 79 uld be obviously
1f10: 20 70 6f 73 73 69 62 6c 65 2e 20 49 6e 20 74 68 possible. In th
1f20: 69 73 20 73 70 65 63 69 61 6c 20 63 61 73 65 20 is special case
1f30: 74 68 65 20 3c 69 3e 72 69 67 68 74 3c 2f 69 3e the <i>right</i>
1f40: 20 73 69 64 65 20 63 6f 6c 6c 65 63 74 69 6f 6e side collection
1f50: 20 77 69 6c 6c 20 62 65 20 4e 55 4c 4c 2e 0d 0a will be NULL...
1f60: 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 </td><td>..<img
1f70: 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e src="http://www.
1f80: 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 gaia-gis.it/gaia
1f90: 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 -sins/write-view
1fa0: 2d 70 69 63 73 2f 73 70 6c 69 74 2d 6c 6e 2d 52 -pics/split-ln-R
1fb0: 2e 70 6e 67 22 20 61 6c 74 3d 22 73 70 6c 69 74 .png" alt="split
1fc0: 2d 72 69 67 68 74 20 6c 69 6e 65 22 3e 0d 0a 3c -right line">..<
1fd0: 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 /td></tr>..</tab
1fe0: 6c 65 3e 0d 0a 3c 68 34 3e 45 78 61 6d 70 6c 65 le>..<h4>Example
1ff0: 20 23 32 20 2d 20 73 70 6c 69 74 74 69 6e 67 20 #2 - splitting
2000: 61 20 50 6f 6c 79 67 6f 6e 20 62 79 20 61 20 4c a Polygon by a L
2010: 69 6e 65 73 74 72 69 6e 67 20 62 6c 61 64 65 3c inestring blade<
2020: 2f 68 34 3e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 /h4>..<table bgc
2030: 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 olor="#e0e0e0" c
2040: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 ellspacing="4" c
2050: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e 0d ellpadding="8">.
2060: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 .<tr><td>..<b>SE
2070: 4c 45 43 54 20 53 54 5f 53 70 6c 69 74 28 69 6e LECT ST_Split(in
2080: 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 2c put.g, blade.g),
2090: 20 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 69 6e ST_SplitLeft(in
20a0: 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 2c put.g, blade.g),
20b0: 20 53 54 5f 53 70 6c 69 74 52 69 67 68 74 28 69 ST_SplitRight(i
20c0: 6e 70 75 74 2e 67 2c 20 62 6c 61 64 65 2e 67 29 nput.g, blade.g)
20d0: 3c 62 72 3e 0d 0a 46 52 4f 4d 3c 62 72 3e 20 0d <br>..FROM<br> .
20e0: 0a 28 53 45 4c 45 43 54 20 47 65 6f 6d 46 72 6f .(SELECT GeomFro
20f0: 6d 54 65 78 74 28 27 50 4f 4c 59 47 4f 4e 28 28 mText('POLYGON((
2100: 30 20 31 2c 20 31 30 20 31 2c 20 31 30 20 39 2c 0 1, 10 1, 10 9,
2110: 20 30 20 39 2c 20 30 20 31 29 2c 20 28 32 20 32 0 9, 0 1), (2 2
2120: 2c 20 37 20 32 2c 20 37 20 36 2c 20 32 20 36 2c , 7 2, 7 6, 2 6,
2130: 20 32 20 32 29 29 27 29 20 41 53 20 67 29 20 41 2 2))') AS g) A
2140: 53 20 69 6e 70 75 74 2c 3c 62 72 3e 20 0d 0a 28 S input,<br> ..(
2150: 53 45 4c 45 43 54 20 47 65 6f 6d 46 72 6f 6d 54 SELECT GeomFromT
2160: 65 78 74 28 27 4c 49 4e 45 53 54 52 49 4e 47 28 ext('LINESTRING(
2170: 32 20 30 2c 20 36 20 31 30 29 27 29 20 41 53 20 2 0, 6 10)') AS
2180: 67 29 20 41 53 20 62 6c 61 64 65 3b 3c 2f 62 3e g) AS blade;</b>
2190: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f ..</td></tr>..</
21a0: 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 61 62 table><br>..<tab
21b0: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 le cellspacing="
21c0: 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 4" cellpadding="
21d0: 34 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 4">..<tr><td>..T
21e0: 68 65 20 3c 62 3e 53 54 5f 53 70 6c 69 74 28 29 he <b>ST_Split()
21f0: 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f </b> SQL functio
2200: 6e 20 77 69 6c 6c 20 73 69 6d 70 6c 79 20 72 65 n will simply re
2210: 74 75 72 6e 20 61 20 3c 69 3e 63 6f 6c 6c 65 63 turn a <i>collec
2220: 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 67 61 tion</i> aggrega
2230: 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d 65 6e ting all fragmen
2240: 74 73 20 64 65 72 69 76 69 6e 67 20 66 72 6f 6d ts deriving from
2250: 20 74 68 65 20 63 75 74 2e 3c 62 72 3e 0d 0a 45 the cut.<br>..E
2260: 78 61 63 74 6c 79 20 61 73 20 77 65 20 68 61 76 xactly as we hav
2270: 65 20 61 6c 72 65 61 64 79 20 70 72 65 76 69 6f e already previo
2280: 75 73 6c 79 20 73 65 65 6e 20 6f 6e 20 74 68 65 usly seen on the
2290: 20 4c 69 6e 65 73 74 72 69 6e 67 20 63 61 73 65 Linestring case
22a0: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 2f 74 64 3e .<br><br>..</td>
22b0: 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 <td>..<img src="
22c0: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d http://www.gaia-
22d0: 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 gis.it/gaia-sins
22e0: 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 /write-view-pics
22f0: 2f 73 70 6c 69 74 2d 70 67 2e 70 6e 67 22 20 61 /split-pg.png" a
2300: 6c 74 3d 22 73 70 6c 69 74 20 70 6f 6c 79 67 6f lt="split polygo
2310: 6e 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d n">..</td></tr>.
2320: 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 68 65 20 3c .<tr><td>..The <
2330: 62 3e 53 54 5f 53 70 6c 69 74 4c 65 66 74 28 29 b>ST_SplitLeft()
2340: 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f </b> SQL functio
2350: 6e 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 69 6e n will return in
2360: 73 74 65 61 64 20 61 20 3c 69 3e 63 6f 6c 6c 65 stead a <i>colle
2370: 63 74 69 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 67 ction</i> aggreg
2380: 61 74 69 6e 67 20 61 6c 6c 20 66 72 61 67 6d 65 ating all fragme
2390: 6e 74 73 20 6c 61 79 69 6e 67 20 6f 6e 20 74 68 nts laying on th
23a0: 65 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 73 69 e <i>left</i> si
23b0: 64 65 20 6f 66 20 74 68 65 20 63 75 74 2e 3c 62 de of the cut.<b
23c0: 72 3e 0d 0a 46 6f 72 20 50 6f 6c 79 67 6f 6e 73 r>..For Polygons
23d0: 20 3c 69 3e 6c 65 66 74 3c 2f 69 3e 20 72 65 61 <i>left</i> rea
23e0: 6c 6c 79 20 6d 65 61 6e 73 20 3c 69 3e 6c 65 66 lly means <i>lef
23f0: 74 20 73 69 64 65 3c 2f 69 3e 20 28 61 74 20 6c t side</i> (at l
2400: 65 61 73 74 2c 20 74 68 69 73 20 69 73 20 74 72 east, this is tr
2410: 75 65 20 77 68 65 6e 20 74 68 65 20 62 6c 61 64 ue when the blad
2420: 65 20 69 73 20 61 6c 6d 6f 73 74 20 76 65 72 74 e is almost vert
2430: 69 63 61 6c 6c 79 20 6f 72 69 65 6e 74 65 64 29 ically oriented)
2440: 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 3e 50 6c .<br><br>..<u>Pl
2450: 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 69 ease note</u>: i
2460: 66 20 74 68 65 20 3c 69 3e 62 6c 61 64 65 3c 2f f the <i>blade</
2470: 69 3e 20 64 6f 65 73 6e 27 74 20 69 6e 74 65 72 i> doesn't inter
2480: 63 65 70 74 73 20 74 68 65 20 74 61 72 67 65 74 cepts the target
2490: 20 61 74 20 61 6c 6c 2c 20 74 68 61 6e 20 6e 6f at all, than no
24a0: 20 63 75 74 20 77 6f 75 6c 64 20 62 65 20 6f 62 cut would be ob
24b0: 76 69 6f 75 73 6c 79 20 70 6f 73 73 69 62 6c 65 viously possible
24c0: 2e 20 49 6e 20 74 68 69 73 20 73 70 65 63 69 61 . In this specia
24d0: 6c 20 63 61 73 65 20 74 68 65 20 6f 72 69 67 69 l case the origi
24e0: 6e 61 6c 20 74 61 72 67 65 74 20 47 65 6f 6d 65 nal target Geome
24f0: 74 72 79 20 77 69 6c 6c 20 62 65 20 61 6c 77 61 try will be alwa
2500: 79 73 20 72 65 74 75 72 6e 65 64 20 28 61 62 73 ys returned (abs
2510: 6f 6c 75 74 65 6c 79 20 75 6e 63 68 61 6e 67 65 olutely unchange
2520: 64 29 20 6f 6e 20 74 68 65 20 3c 69 3e 6c 65 66 d) on the <i>lef
2530: 74 3c 2f 69 3e 20 73 69 64 65 20 63 6f 6c 6c 65 t</i> side colle
2540: 63 74 69 6f 6e 2e 0d 0a 3c 2f 74 64 3e 3c 74 64 ction...</td><td
2550: 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 >..<img src="htt
2560: 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 p://www.gaia-gis
2570: 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 77 72 .it/gaia-sins/wr
2580: 69 74 65 2d 76 69 65 77 2d 70 69 63 73 2f 73 70 ite-view-pics/sp
2590: 6c 69 74 2d 70 67 2d 4c 2e 70 6e 67 22 20 61 6c lit-pg-L.png" al
25a0: 74 3d 22 73 70 6c 69 74 2d 6c 65 66 74 20 70 6f t="split-left po
25b0: 6c 79 67 6f 6e 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f lygon">..</td></
25c0: 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 54 tr>..<tr><td>..T
25d0: 68 65 20 3c 62 3e 53 54 5f 53 70 6c 69 74 52 69 he <b>ST_SplitRi
25e0: 67 68 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 ght()</b> SQL fu
25f0: 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 74 75 nction will retu
2600: 72 6e 20 61 20 3c 69 3e 63 6f 6c 6c 65 63 74 69 rn a <i>collecti
2610: 6f 6e 3c 2f 69 3e 20 61 67 67 72 65 67 61 74 69 on</i> aggregati
2620: 6e 67 20 61 6c 6c 20 66 72 61 67 6d 65 6e 74 73 ng all fragments
2630: 20 6c 61 79 69 6e 67 20 6f 6e 20 74 68 65 20 3c laying on the <
2640: 69 3e 72 69 67 68 74 3c 2f 69 3e 20 73 69 64 65 i>right</i> side
2650: 20 6f 66 20 74 68 65 20 63 75 74 2e 3c 62 72 3e of the cut.<br>
2660: 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 ..<u>Please note
2670: 3c 2f 75 3e 3a 20 69 66 20 74 68 65 20 3c 69 3e </u>: if the <i>
2680: 62 6c 61 64 65 3c 2f 69 3e 20 64 6f 65 73 6e 27 blade</i> doesn'
2690: 74 20 69 6e 74 65 72 63 65 70 74 73 20 74 68 65 t intercepts the
26a0: 20 74 61 72 67 65 74 20 61 74 20 61 6c 6c 2c 20 target at all,
26b0: 74 68 61 6e 20 6e 6f 20 63 75 74 20 77 6f 75 6c than no cut woul
26c0: 64 20 62 65 20 6f 62 76 69 6f 75 73 6c 79 20 70 d be obviously p
26d0: 6f 73 73 69 62 6c 65 2e 20 49 6e 20 74 68 69 73 ossible. In this
26e0: 20 73 70 65 63 69 61 6c 20 63 61 73 65 20 74 68 special case th
26f0: 65 20 3c 69 3e 72 69 67 68 74 3c 2f 69 3e 20 73 e <i>right</i> s
2700: 69 64 65 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 77 ide collection w
2710: 69 6c 6c 20 62 65 20 4e 55 4c 4c 2e 0d 0a 3c 2f ill be NULL...</
2720: 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 td><td>..<img sr
2730: 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 c="http://www.ga
2740: 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 ia-gis.it/gaia-s
2750: 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 ins/write-view-p
2760: 69 63 73 2f 73 70 6c 69 74 2d 70 67 2d 52 2e 70 ics/split-pg-R.p
2770: 6e 67 22 20 61 6c 74 3d 22 73 70 6c 69 74 2d 72 ng" alt="split-r
2780: 69 67 68 74 20 70 6f 6c 79 67 6f 6e 22 3e 0d 0a ight polygon">..
2790: 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 </td></tr>..</ta
27a0: 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 72 3e 0d 0a ble>..<br><hr>..
27b0: 3c 68 33 3e 53 65 67 6d 65 6e 74 69 7a 61 74 69 <h3>Segmentizati
27c0: 6f 6e 3c 2f 68 33 3e 0d 0a 53 6f 6d 65 74 69 6d on</h3>..Sometim
27d0: 65 73 20 69 74 20 63 6f 75 6c 64 20 62 65 20 75 es it could be u
27e0: 73 65 66 75 6c 20 3c 69 3e 69 6e 74 65 72 70 6f seful <i>interpo
27f0: 6c 61 74 69 6e 67 3c 2f 69 3e 20 6d 61 6e 79 20 lating</i> many
2800: 66 75 72 74 68 65 72 20 76 65 72 74 69 63 65 73 further vertices
2810: 20 69 6e 74 6f 20 73 6f 6d 65 20 76 65 72 79 20 into some very
2820: 6c 6f 6e 67 20 4c 69 6e 65 73 74 72 69 6e 67 20 long Linestring
2830: 6f 72 20 50 6f 6c 79 67 6f 6e 27 73 20 52 69 6e or Polygon's Rin
2840: 67 2c 20 73 6f 20 74 6f 20 6f 62 74 61 69 6e 20 g, so to obtain
2850: 6d 61 6e 79 20 73 6d 61 6c 6c 65 72 20 73 65 67 many smaller seg
2860: 6d 65 6e 74 73 20 6f 66 20 74 68 65 20 73 61 6d ments of the sam
2870: 65 20 69 64 65 6e 74 69 63 61 6c 20 6c 65 6e 67 e identical leng
2880: 74 68 2e 0d 0a 3c 74 61 62 6c 65 20 62 67 63 6f th...<table bgco
2890: 6c 6f 72 3d 22 23 65 30 65 30 65 30 22 20 63 65 lor="#e0e0e0" ce
28a0: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 llspacing="4" ce
28b0: 6c 6c 70 61 64 64 69 6e 67 3d 22 38 22 3e 0d 0a llpadding="8">..
28c0: 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c <tr><td>..<b>SEL
28d0: 45 43 54 20 67 65 6f 6d 65 74 72 79 2c 20 53 54 ECT geometry, ST
28e0: 5f 53 65 67 6d 65 6e 74 69 7a 65 28 67 65 6f 6d _Segmentize(geom
28f0: 65 74 72 79 2c 20 31 30 2e 30 29 3c 62 72 3e 0d etry, 10.0)<br>.
2900: 0a 46 52 4f 4d 20 63 6f 6d 32 30 31 31 3c 62 72 .FROM com2011<br
2910: 3e 0d 0a 57 48 45 52 45 20 6e 6f 6d 65 5f 63 6f >..WHERE nome_co
2920: 6d 20 3d 20 27 42 72 6f 6e 74 65 27 3b 3c 2f 62 m = 'Bronte';</b
2930: 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 >..</td></tr></t
2940: 61 62 6c 65 3e 3c 62 72 3e 0d 0a 3c 74 61 62 6c able><br>..<tabl
2950: 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c e border="1" cel
2960: 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c lspacing="4" cel
2970: 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c lpadding="4">..<
2980: 74 72 3e 3c 74 68 3e 6f 72 69 67 69 6e 61 6c 3c tr><th>original<
2990: 2f 74 68 3e 3c 74 68 3e 73 65 67 6d 65 6e 74 69 /th><th>segmenti
29a0: 7a 65 64 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c zed</th></tr>..<
29b0: 74 72 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 tr><td>..<img sr
29c0: 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 c="http://www.ga
29d0: 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 ia-gis.it/gaia-s
29e0: 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 ins/write-view-p
29f0: 69 63 73 2f 62 72 6f 6e 74 65 2d 6f 72 69 67 69 ics/bronte-origi
2a00: 6e 61 6c 2e 70 6e 67 22 20 61 6c 74 3d 22 62 72 nal.png" alt="br
2a10: 6f 6e 74 65 20 6f 72 69 67 69 6e 61 6c 22 3e 0d onte original">.
2a20: 0a 3c 2f 74 64 3e 3c 74 64 3e 0d 0a 3c 69 6d 67 .</td><td>..<img
2a30: 20 73 72 63 3d 22 68 74 74 70 3a 2f 2f 77 77 77 src="http://www
2a40: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 .gaia-gis.it/gai
2a50: 61 2d 73 69 6e 73 2f 77 72 69 74 65 2d 76 69 65 a-sins/write-vie
2a60: 77 2d 70 69 63 73 2f 62 72 6f 6e 74 65 2d 73 65 w-pics/bronte-se
2a70: 67 6d 65 6e 74 69 7a 65 64 2e 70 6e 67 22 20 61 gmentized.png" a
2a80: 6c 74 3d 22 62 72 6f 6e 74 65 20 73 65 67 6d 65 lt="bronte segme
2a90: 6e 74 69 7a 65 64 22 3e 0d 0a 3c 2f 74 64 3e 3c ntized">..</td><
2aa0: 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 20 63 6f /tr>..<tr><td co
2ab0: 6c 73 70 61 6e 3d 22 32 22 3e 0d 0a 41 73 20 79 lspan="2">..As y
2ac0: 6f 75 20 63 61 6e 20 65 61 73 69 6c 79 20 6e 6f ou can easily no
2ad0: 74 69 63 65 2c 20 74 68 65 72 65 20 61 72 65 20 tice, there are
2ae0: 6d 61 6e 79 20 6d 6f 72 65 20 76 65 72 74 69 63 many more vertic
2af0: 65 73 20 69 6e 20 74 68 65 20 73 65 67 6d 65 6e es in the segmen
2b00: 74 69 7a 65 64 20 47 65 6f 6d 65 74 72 79 2e 3c tized Geometry.<
2b10: 62 72 3e 0d 0a 57 65 20 69 6d 70 6f 73 65 64 20 br>..We imposed
2b20: 74 68 65 20 63 6f 6e 73 74 72 61 69 6e 74 20 74 the constraint t
2b30: 68 61 74 20 6e 6f 20 73 65 67 6d 65 6e 74 20 63 hat no segment c
2b40: 6f 75 6c 64 20 62 65 20 6c 6f 6e 67 65 72 20 74 ould be longer t
2b50: 68 61 6e 20 3c 62 3e 31 30 6d 3c 2f 62 3e 2c 20 han <b>10m</b>,
2b60: 74 68 75 73 20 63 61 75 73 69 6e 67 20 6d 61 6e thus causing man
2b70: 79 20 6d 6f 72 65 20 76 65 72 74 69 63 65 73 20 y more vertices
2b80: 74 6f 20 62 65 20 69 6e 74 65 72 70 6f 6c 61 74 to be interpolat
2b90: 65 64 2e 3c 62 72 3e 0d 0a 54 68 65 20 6f 76 65 ed.<br>..The ove
2ba0: 72 61 6c 6c 20 73 68 61 70 65 20 69 73 20 61 62 rall shape is ab
2bb0: 73 6f 6c 75 74 65 6c 79 20 75 6e 63 68 61 6e 67 solutely unchang
2bc0: 65 64 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d ed...</td></tr>.
2bd0: 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 3c .</table>..<br><
2be0: 68 72 3e 0d 0a 3c 68 33 3e 41 7a 69 6d 75 74 68 hr>..<h3>Azimuth
2bf0: 3c 2f 68 33 3e 0d 0a 50 72 6f 62 61 62 6c 79 20 </h3>..Probably
2c00: 6e 6f 74 20 74 68 65 20 6d 6f 73 74 20 69 6e 74 not the most int
2c10: 65 72 65 73 74 69 6e 67 20 66 75 6e 63 74 69 6f eresting functio
2c20: 6e 20 73 75 70 70 6f 72 74 65 64 20 62 79 20 3c n supported by <
2c30: 69 3e 6c 69 62 6c 77 67 65 6f 6d 3c 2f 69 3e 3b i>liblwgeom</i>;
2c40: 20 61 6e 79 77 61 79 20 69 74 27 73 20 74 68 65 anyway it's the
2c50: 72 65 2c 20 61 6e 64 20 69 73 20 77 6f 72 74 68 re, and is worth
2c60: 20 65 6e 6f 75 67 68 20 74 6f 20 62 65 20 73 75 enough to be su
2c70: 70 70 6f 72 74 65 64 20 62 79 20 53 70 61 74 69 pported by Spati
2c80: 61 4c 69 74 65 20 61 73 20 77 65 6c 6c 2e 3c 62 aLite as well.<b
2c90: 72 3e 0d 0a 50 72 6f 62 61 62 6c 79 20 68 69 67 r>..Probably hig
2ca0: 68 6c 79 20 61 70 70 72 65 63 69 61 74 65 64 20 hly appreciated
2cb0: 6f 6e 20 3c 62 3e 47 50 53 20 64 65 76 69 63 65 on <b>GPS device
2cc0: 73 3c 2f 62 3e 20 73 6f 20 74 6f 20 64 65 74 65 s</b> so to dete
2cd0: 72 6d 69 6e 65 20 74 68 65 20 63 75 72 72 65 6e rmine the curren
2ce0: 74 20 62 65 61 72 69 6e 67 2e 0d 0a 3c 74 61 62 t bearing...<tab
2cf0: 6c 65 20 62 67 63 6f 6c 6f 72 3d 22 23 65 30 65 le bgcolor="#e0e
2d00: 30 65 30 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 0e0" cellspacing
2d10: 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 ="4" cellpadding
2d20: 3d 22 38 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d ="8">..<tr><td>.
2d30: 0a 3c 62 3e 53 45 4c 45 43 54 20 44 65 67 72 65 .<b>SELECT Degre
2d40: 65 73 28 53 54 5f 41 7a 69 6d 75 74 68 28 4d 61 es(ST_Azimuth(Ma
2d50: 6b 65 50 6f 69 6e 74 28 30 2c 20 30 29 2c 20 4d kePoint(0, 0), M
2d60: 61 6b 65 50 6f 69 6e 74 28 30 2c 20 31 29 29 29 akePoint(0, 1)))
2d70: 3b 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a 30 2e 30 ;</b>..<hr>..0.0
2d80: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 ..</td></tr>..<t
2d90: 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 r><td>..<b>SELEC
2da0: 54 20 44 65 67 72 65 65 73 28 53 54 5f 41 7a 69 T Degrees(ST_Azi
2db0: 6d 75 74 68 28 4d 61 6b 65 50 6f 69 6e 74 28 30 muth(MakePoint(0
2dc0: 2c 20 30 29 2c 20 4d 61 6b 65 50 6f 69 6e 74 28 , 0), MakePoint(
2dd0: 31 2c 20 31 29 29 29 3b 3c 2f 62 3e 0d 0a 3c 68 1, 1)));</b>..<h
2de0: 72 3e 0d 0a 34 35 2e 30 0d 0a 3c 2f 74 64 3e 3c r>..45.0..</td><
2df0: 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a /tr>..<tr><td>..
2e00: 3c 62 3e 53 45 4c 45 43 54 20 44 65 67 72 65 65 <b>SELECT Degree
2e10: 73 28 53 54 5f 41 7a 69 6d 75 74 68 28 4d 61 6b s(ST_Azimuth(Mak
2e20: 65 50 6f 69 6e 74 28 30 2c 20 30 29 2c 20 4d 61 ePoint(0, 0), Ma
2e30: 6b 65 50 6f 69 6e 74 28 31 2c 20 30 29 29 29 3b kePoint(1, 0)));
2e40: 3c 2f 62 3e 0d 0a 3c 68 72 3e 0d 0a 39 30 2e 30 </b>..<hr>..90.0
2e50: 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 ..</td></tr>..<t
2e60: 72 3e 3c 74 64 3e 0d 0a 3c 62 3e 53 45 4c 45 43 r><td>..<b>SELEC
2e70: 54 20 44 65 67 72 65 65 73 28 53 54 5f 41 7a 69 T Degrees(ST_Azi
2e80: 6d 75 74 68 28 4d 61 6b 65 50 6f 69 6e 74 28 30 muth(MakePoint(0
2e90: 2c 20 30 29 2c 20 4d 61 6b 65 50 6f 69 6e 74 28 , 0), MakePoint(
2ea0: 30 2c 20 2d 31 29 29 29 3b 3c 2f 62 3e 0d 0a 3c 0, -1)));</b>..<
2eb0: 68 72 3e 0d 0a 31 38 30 2e 30 0d 0a 3c 2f 74 64 hr>..180.0..</td
2ec0: 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e ></tr>..</table>
2ed0: 3c 62 72 3e 0d 0a 3c 62 72 3e 3c 68 72 3e 0d 0a <br>..<br><hr>..
2ee0: 3c 68 33 3e 53 6e 61 70 70 69 6e 67 20 47 65 6f <h3>Snapping Geo
2ef0: 6d 65 74 72 69 65 73 20 74 6f 20 61 20 70 72 65 metries to a pre
2f00: 64 65 66 69 6e 65 64 20 67 72 69 64 3c 2f 68 33 defined grid</h3
2f10: 3e 0d 0a 54 68 69 73 20 66 65 61 74 75 72 65 20 >..This feature
2f20: 72 65 61 6c 6c 79 20 69 73 20 3c 69 3e 3c 75 3e really is <i><u>
2f30: 74 68 65 20 6d 6f 74 68 65 72 20 6f 66 20 74 6f the mother of to
2f40: 70 6f 6c 6f 67 69 63 61 6c 20 63 6f 6e 73 69 73 pological consis
2f50: 74 65 6e 63 79 3c 2f 75 3e 3c 2f 69 3e 3b 20 69 tency</u></i>; i
2f60: 6d 70 6f 73 69 6e 67 20 74 68 61 74 20 61 6c 6c mposing that all
2f70: 20 70 6f 69 6e 74 73 20 2f 20 76 65 72 74 69 63 points / vertic
2f80: 65 73 20 73 68 6f 75 6c 64 20 62 65 20 73 74 72 es should be str
2f90: 69 63 74 6c 79 20 61 6c 69 67 6e 65 64 20 74 6f ictly aligned to
2fa0: 20 74 68 65 20 73 61 6d 65 20 67 72 69 64 20 77 the same grid w
2fb0: 69 6c 6c 20 73 75 72 65 6c 79 20 6d 61 6b 65 20 ill surely make
2fc0: 65 61 73 69 65 72 20 65 6e 73 75 72 69 6e 67 20 easier ensuring
2fd0: 61 20 73 74 72 6f 6e 67 20 63 6f 6e 73 69 73 74 a strong consist
2fe0: 65 6e 63 79 20 62 65 74 77 65 65 6e 20 64 69 66 ency between dif
2ff0: 66 65 72 65 6e 74 20 47 65 6f 6d 65 74 72 69 65 ferent Geometrie
3000: 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 75 3e 50 s.<br><br>..<u>P
3010: 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 lease note</u>:
3020: 64 75 65 20 74 6f 20 74 65 63 68 6e 69 63 61 6c due to technical
3030: 20 72 65 61 73 6f 6e 73 20 74 68 65 20 63 75 72 reasons the cur
3040: 72 65 6e 74 20 76 65 72 73 69 6f 6e 20 6f 66 20 rent version of
3050: 3c 69 3e 6c 69 62 6c 77 67 65 6f 6d 3c 2f 69 3e <i>liblwgeom</i>
3060: 20 64 6f 65 73 6e 27 74 20 65 78 70 6f 73 65 73 doesn't exposes
3070: 20 74 6f 20 74 68 65 20 65 78 74 65 72 69 6f 72 to the exterior
3080: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 the correspondi
3090: 6e 67 20 6c 69 6e 6b 20 73 79 6d 62 6f 6c 73 2e ng link symbols.
30a0: 3c 62 72 3e 0d 0a 53 6f 20 74 68 65 20 63 75 72 <br>..So the cur
30b0: 72 65 6e 74 20 69 6d 70 6c 65 6d 65 6e 74 61 74 rent implementat
30c0: 69 6f 6e 20 61 76 61 69 6c 61 62 6c 65 20 6f 6e ion available on
30d0: 20 53 70 61 74 69 61 4c 69 74 65 20 69 73 20 61 SpatiaLite is a
30e0: 6e 20 69 6e 64 65 70 65 6e 64 65 6e 74 20 6f 6e n independent on
30f0: 65 20 28 61 6c 74 68 6f 75 67 68 20 62 65 69 6e e (although bein
3100: 67 20 64 69 72 65 63 74 6c 79 20 69 6e 73 70 69 g directly inspi
3110: 72 65 64 20 62 79 20 74 68 65 20 3c 69 3e 6c 69 red by the <i>li
3120: 62 6c 77 67 65 6f 6d 3c 2f 69 3e 20 6f 6e 65 29 blwgeom</i> one)
3130: 2e 3c 62 72 3e 20 20 0d 0a 3c 74 61 62 6c 65 20 .<br> ..<table
3140: 62 67 63 6f 6c 6f 72 3d 22 23 65 30 65 30 65 30 bgcolor="#e0e0e0
3150: 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 " cellspacing="4
3160: 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 38 " cellpadding="8
3170: 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 0d 0a 3c 62 ">..<tr><td>..<b
3180: 3e 53 45 4c 45 43 54 20 53 54 5f 53 6e 61 70 54 >SELECT ST_SnapT
3190: 6f 47 72 69 64 28 67 65 6f 6d 65 74 72 79 2c 20 oGrid(geometry,
31a0: 32 35 30 2e 30 29 3c 62 72 3e 0d 0a 46 52 4f 4d 250.0)<br>..FROM
31b0: 20 63 6f 6d 32 30 31 31 3c 62 72 3e 0d 0a 57 48 com2011<br>..WH
31c0: 45 52 45 20 6e 6f 6d 65 5f 63 6f 6d 20 3d 20 27 ERE nome_com = '
31d0: 42 72 6f 6e 74 65 27 3b 3c 2f 62 3e 0d 0a 3c 2f Bronte';</b>..</
31e0: 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e td></tr></table>
31f0: 3c 62 72 3e 0d 0a 3c 74 61 62 6c 65 20 63 65 6c <br>..<table cel
3200: 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c lspacing="4" cel
3210: 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c lpadding="4">..<
3220: 74 72 3e 3c 74 64 3e 0d 0a 59 65 74 20 61 67 61 tr><td>..Yet aga
3230: 69 6e 20 61 6e 6f 74 68 65 72 20 74 69 6d 65 20 in another time
3240: 74 68 65 20 42 72 6f 6e 74 65 20 4c 6f 63 61 6c the Bronte Local
3250: 20 43 6f 75 6e 63 69 6c 20 62 6f 75 6e 64 61 72 Council boundar
3260: 79 2e 3c 62 72 3e 0d 0a 42 79 20 69 6e 76 6f 6b y.<br>..By invok
3270: 69 6e 67 20 3c 62 3e 53 54 5f 53 6e 61 70 54 6f ing <b>ST_SnapTo
3280: 47 72 69 64 28 29 3c 2f 62 3e 20 74 68 69 73 20 Grid()</b> this
3290: 74 69 6d 65 20 74 68 65 20 47 65 6f 6d 65 74 72 time the Geometr
32a0: 79 20 68 61 73 20 62 65 65 6e 20 73 74 72 6f 6e y has been stron
32b0: 67 6c 79 20 73 69 6d 70 6c 69 66 69 65 64 20 28 gly simplified (
32c0: 70 6c 65 61 73 65 20 6e 6f 74 69 63 65 3b 20 6d please notice; m
32d0: 61 6e 79 20 76 65 72 74 69 63 65 73 20 68 61 76 any vertices hav
32e0: 65 20 62 65 65 6e 20 73 75 70 70 72 65 73 73 65 e been suppresse
32f0: 64 29 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 54 68 65 d).<br><br>..The
3300: 20 69 6d 70 6f 73 65 64 20 3c 69 3e 67 72 69 64 imposed <i>grid
3310: 20 73 69 7a 65 3c 2f 69 3e 20 28 3c 62 3e 32 35 size</i> (<b>25
3320: 30 6d 3c 2f 62 3e 29 20 69 73 20 61 62 73 6f 6c 0m</b>) is absol
3330: 75 74 65 6c 79 20 75 6e 72 65 61 6c 69 73 74 69 utely unrealisti
3340: 63 20 61 6e 64 20 65 78 61 67 67 65 72 61 74 65 c and exaggerate
3350: 64 20 66 6f 72 20 61 6e 79 20 70 72 61 63 74 69 d for any practi
3360: 63 61 6c 20 70 75 72 70 6f 73 65 2e 3c 62 72 3e cal purpose.<br>
3370: 0d 0a 41 6e 79 77 61 79 20 61 20 73 75 63 68 20 ..Anyway a such
3380: 73 74 72 6f 6e 67 20 66 61 63 74 6f 72 20 69 73 strong factor is
3390: 20 75 73 65 66 75 6c 20 69 6e 20 6f 72 64 65 72 useful in order
33a0: 20 74 6f 20 63 6c 65 61 72 6c 79 20 73 68 6f 77 to clearly show
33b0: 20 77 68 61 74 20 72 65 61 6c 6c 79 20 68 61 70 what really hap
33c0: 70 65 6e 73 3a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 pens:<ul>..<li>a
33d0: 6c 6c 20 76 65 72 74 69 63 65 73 20 61 72 65 20 ll vertices are
33e0: 6e 6f 77 20 73 74 72 69 63 74 6c 79 20 61 6c 69 now strictly ali
33f0: 67 6e 65 64 20 74 6f 20 74 68 65 20 67 72 69 64 gned to the grid
3400: 20 6e 6f 64 65 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c nodes.</li>..<l
3410: 69 3e 61 6c 6c 20 76 65 72 74 69 63 65 73 20 66 i>all vertices f
3420: 61 6c 6c 69 6e 67 20 77 69 74 68 69 6e 20 74 68 alling within th
3430: 65 20 73 61 6d 65 20 67 72 69 64 20 63 65 6c 6c e same grid cell
3440: 20 68 61 76 65 20 62 65 65 6e 20 73 75 70 70 72 have been suppr
3450: 65 73 73 65 64 2c 20 73 74 69 6c 6c 20 70 72 65 essed, still pre
3460: 73 65 72 76 69 6e 67 20 6f 6e 6c 79 20 6f 6e 65 serving only one
3470: 20 6f 66 20 74 68 65 6d 2e 3c 2f 6c 69 3e 0d 0a of them.</li>..
3480: 3c 6c 69 3e 73 6f 20 74 68 65 20 6f 76 65 72 61 <li>so the overa
3490: 6c 6c 20 65 66 66 65 63 74 20 69 73 20 74 68 65 ll effect is the
34a0: 20 6f 6e 65 20 6c 65 61 64 69 6e 67 20 74 6f 20 one leading to
34b0: 61 20 72 69 67 6f 72 6f 75 73 6c 79 20 3c 69 3e a rigorously <i>
34c0: 6e 6f 72 6d 61 6c 69 7a 65 64 3c 2f 69 3e 20 61 normalized</i> a
34d0: 6e 64 20 28 6d 61 79 20 62 65 29 20 3c 69 3e 73 nd (may be) <i>s
34e0: 69 6d 70 6c 69 66 69 65 64 3c 2f 69 3e 20 47 65 implified</i> Ge
34f0: 6f 6d 65 74 72 79 3b 20 61 6e 64 20 74 68 69 73 ometry; and this
3500: 20 77 69 6c 6c 20 73 75 72 65 6c 79 20 6d 61 6b will surely mak
3510: 65 20 65 61 73 69 65 72 20 65 6e 73 75 72 69 6e e easier ensurin
3520: 67 20 74 68 65 20 72 65 71 75 69 72 65 64 20 74 g the required t
3530: 6f 70 6f 6c 6f 67 69 63 61 6c 20 63 6f 6e 73 69 opological consi
3540: 73 74 65 6e 63 79 20 77 69 74 68 20 61 6e 79 20 stency with any
3550: 6f 74 68 65 72 20 61 64 6a 61 63 65 6e 74 20 4c other adjacent L
3560: 6f 63 61 6c 20 43 6f 75 6e 63 69 6c 2e 3c 2f 6c ocal Council.</l
3570: 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 3e i>..</ul>..</td>
3580: 3c 74 64 3e 0d 0a 3c 69 6d 67 20 73 72 63 3d 22 <td>..<img src="
3590: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d http://www.gaia-
35a0: 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 gis.it/gaia-sins
35b0: 2f 77 72 69 74 65 2d 76 69 65 77 2d 70 69 63 73 /write-view-pics
35c0: 2f 73 6e 61 70 2d 74 6f 2d 67 72 69 64 2e 70 6e /snap-to-grid.pn
35d0: 67 22 20 61 6c 74 3d 22 73 6e 61 70 20 74 6f 20 g" alt="snap to
35e0: 67 72 69 64 22 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 grid">..</td></t
35f0: 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 r>..</table>..<b
3600: 72 3e 3c 68 72 3e 0d 0a 3c 74 61 62 6c 65 20 62 r><hr>..<table b
3610: 67 63 6f 6c 6f 72 3d 22 23 64 37 66 66 66 66 22 gcolor="#d7ffff"
3620: 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 36 22 cellspacing="6"
3630: 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 31 30 cellpadding="10
3640: 22 20 77 69 64 74 68 3d 22 31 30 30 25 22 3e 0d " width="100%">.
3650: 0a 3c 74 72 3e 3c 74 68 3e 43 72 65 64 69 74 73 .<tr><th>Credits
3660: 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e </th></tr>..<tr>
3670: 3c 74 64 20 61 6c 69 67 6e 3d 22 63 65 6e 74 65 <td align="cente
3680: 72 22 3e 0d 0a 54 68 69 73 20 77 6f 72 6b 20 28 r">..This work (
3690: 65 78 70 6f 73 69 6e 67 20 3c 69 3e 6c 69 62 6c exposing <i>libl
36a0: 77 67 65 6f 6d 3c 2f 69 3e 20 41 50 49 73 20 61 wgeom</i> APIs a
36b0: 73 20 53 70 61 74 69 61 4c 69 74 65 20 6f 77 6e s SpatiaLite own
36c0: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 29 20 SQL functions)
36d0: 68 61 73 20 62 65 65 6e 20 65 6e 74 69 72 65 6c has been entirel
36e0: 79 20 66 75 6e 64 65 64 20 62 79 3a 3c 62 72 3e y funded by:<br>
36f0: 0d 0a 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a ..<a href="http:
3700: 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61 2e 6f //en.wikipedia.o
3710: 72 67 2f 77 69 6b 69 2f 54 75 73 63 61 6e 79 22 rg/wiki/Tuscany"
3720: 3e 54 75 73 63 61 6e 79 20 52 65 67 69 6f 6e 3c >Tuscany Region<
3730: 2f 61 3e 20 2d 20 54 65 72 72 69 74 6f 72 69 61 /a> - Territoria
3740: 6c 20 61 6e 64 20 45 6e 76 69 72 6f 6e 6d 65 6e l and Environmen
3750: 74 61 6c 20 49 6e 66 6f 72 6d 61 74 69 6f 6e 20 tal Information
3760: 53 79 73 74 65 6d 3c 62 72 3e 0d 0a 3c 61 20 68 System<br>..<a h
3770: 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e ref="http://www.
3780: 72 65 67 69 6f 6e 65 2e 74 6f 73 63 61 6e 61 2e regione.toscana.
3790: 69 74 2f 22 3e 52 65 67 69 6f 6e 65 20 54 6f 73 it/">Regione Tos
37a0: 63 61 6e 61 3c 2f 61 3e 20 2d 20 53 65 74 74 6f cana</a> - Setto
37b0: 72 65 20 53 69 73 74 65 6d 61 20 49 6e 66 6f 72 re Sistema Infor
37c0: 6d 61 74 69 76 6f 20 54 65 72 72 69 74 6f 72 69 mativo Territori
37d0: 61 6c 65 20 65 64 20 41 6d 62 69 65 6e 74 61 6c ale ed Ambiental
37e0: 65 2e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a e...</td></tr>..
37f0: 3c 2f 74 61 62 6c 65 3e 0d 0a 3c 62 72 3e 3c 68 </table>..<br><h
3800: 72 3e 0d 0a 42 61 63 6b 20 74 6f 20 3c 61 20 68 r>..Back to <a h
3810: 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 ref="https://www
3820: 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 .gaia-gis.it/fos
3830: 73 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 sil/libspatialit
3840: 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 73 77 69 74 e/wiki?name=swit
3850: 63 68 69 6e 67 2d 74 6f 2d 34 2e 30 23 6c 69 62 ching-to-4.0#lib
3860: 6c 77 67 65 6f 6d 22 3e 6d 61 69 6e 20 70 61 67 lwgeom">main pag
3870: 65 3c 2f 61 3e 0d 0a 0a 5a 20 39 36 36 62 62 37 e</a>...Z 966bb7
3880: 66 37 38 31 36 30 34 33 65 65 66 65 31 63 39 32 f7816043eefe1c92
3890: 38 36 65 30 37 35 66 33 63 65 0a 86e075f3ce.