<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html;">
<title>Scalix message content</title>
<style type="text/css">
<!--
.Normal { text-align: left; text-indent:0pt; margin-top:0pt; margin-bottom:0pt; font-family: Arial; font-size: 12pt; }
.Default_Paragraph_Font {font-family: Arial; color: Black; background-color: white ; font-size: 12pt; font-weight: normal; font-style: normal; font-variant: normal; vertical-align: normal; text-decoration: none;}
div.ltTOCtitle { font-family: Verdana; font-size: 8pt; font-weight: bold; text-align: center;}
div.ltTOCl1 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:32pt; text-indent:-32pt;}
div.ltTOCl2 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:40pt; text-indent:-32pt;}
div.ltTOCl3 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:48pt; text-indent:-32pt;}
div.ltTOCl4 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:56pt; text-indent:-32pt;}
div.ltTOCl5 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:64pt; text-indent:-32pt;}
div.ltTOCl6 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:72pt; text-indent:-32pt;}
-->
</style>
</head>
<body>
<div class="Normal"><span style='font-size: 10pt; '>Hi</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Try to use the cleanGeometry
function published on:</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>http://www.sogis1.so.ch/sogis/dl/postgis/cleanGeometry.sql</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>for cleaning your
geometries.</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Regards</span><br><span style='font-size: 10pt; '>Horst</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>------------------------------------------------</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Dr. Horst
Düster</span><br><span style='font-size: 10pt; '>Stv. Amtschef /
GIS-Koordinator </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Kanton
Solothurn</span><br><span style='font-size: 10pt; '>Bau- und
Justizdepartement</span><br><span style='font-size: 10pt; '>Amt für
Geoinformation</span><br><span style='font-size: 10pt; '>SO!GIS
Koordination</span><br><span style='font-size: 10pt; '>Rötistrasse
4</span><br><span style='font-size: 10pt; '>CH-4501 Solothurn</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Telefon ++41(0)32 627 25
32</span><br><span style='font-size: 10pt; '>Telefax ++41(0)32 627 22
14</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>mailto:horst.duester@bd.so.ch</span><br><span style='font-size: 10pt; '>http://www.agi.so.ch</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>-----Ursprüngliche
Nachricht-----</span><br><span style='font-size: 10pt; '>Von: Simon Greener
[mailto:simon@spatialdbadvisor.com]</span><br><span style='font-size: 10pt; '>Gesendet
am: Dienstag, 3. Februar 2009
07:20</span><br><span style='font-size: 10pt; '>An: PostGIS Users
Discussion</span><br><span style='font-size: 10pt; '>Betreff: Re:
[postgis-users] Cleaning non valid multipolygon</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Yves,</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>I don't know if this helps.
In Oracle, to fix self-intersecting polygons one can do a "self-union".
</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>I looked to see if this
would work for PostGIS and, from what I can tell from my simple testing, it
does:</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>drop table
crap;</span><br><span style='font-size: 10pt; '>create table crap (oid
serial);</span><br><span style='font-size: 10pt; '>SELECT
AddGeometryColumn('public', 'crap', 'geom', -1, 'MULTIPOLYGON',
2);</span><br><span style='font-size: 10pt; '>alter TABLE crap DROP CONSTRAINT
enforce_geotype_geom;</span><br><span style='font-size: 10pt; '>alter TABLE crap
ADD CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) IN
('MULTIPOLYGON'::text,'POLYGON'::text) OR geom IS
NULL);</span><br><span style='font-size: 10pt; '>insert into crap (geom)
values(st_geomfromtext('MULTIPOLYGON(((</span><br><span style='font-size: 10pt; '>376249.7830234
8717655.6050357,</span><br><span style='font-size: 10pt; '>376268.0818048
8717666.0116082,</span><br><span style='font-size: 10pt; '>376265.2666038
8717670.5117466,</span><br><span style='font-size: 10pt; '>376247.812391
8717660.3864341,</span><br><span style='font-size: 10pt; '>376249.7830234
8717655.6050357,</span><br><span style='font-size: 10pt; '>376247.812391
8717660.3864341,</span><br><span style='font-size: 10pt; '>376265.2666038
8717670.5117466,</span><br><span style='font-size: 10pt; '>376268.0818048
8717666.0116082,</span><br><span style='font-size: 10pt; '>376249.7830234
8717655.6050357)))'));</span><br><span style='font-size: 10pt; '>insert into
crap (geom)</span><br><span style='font-size: 10pt; '>select
ST_AsText(st_makepolygon(st_linemerge(st_union(geom,geom))))</span><br><span style='font-size: 10pt; '>from
(select
st_geomfromtext('MULTIPOLYGON(((</span><br><span style='font-size: 10pt; '>376249.7830234
8717655.6050357,</span><br><span style='font-size: 10pt; '>376268.0818048
8717666.0116082,</span><br><span style='font-size: 10pt; '>376265.2666038
8717670.5117466,</span><br><span style='font-size: 10pt; '>376247.812391
8717660.3864341,</span><br><span style='font-size: 10pt; '>376249.7830234
8717655.6050357,</span><br><span style='font-size: 10pt; '>376247.812391
8717660.3864341,</span><br><span style='font-size: 10pt; '>376265.2666038
8717670.5117466,</span><br><span style='font-size: 10pt; '>376268.0818048
8717666.0116082,</span><br><span style='font-size: 10pt; '>376249.7830234
8717655.6050357)))') as geom) as a;</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>This may help. But I am sure
more experienced experts have a better solution.</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>S</span><br><span style='font-size: 10pt; '>On
Tue, 03 Feb 2009 06:00:18 +1100, Yves Moisan <yves.moisan@boreal-is.com>
wrote:</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>> Hi
All,</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
I have some data from an AutoCAD file (dwg) for which some of
the</span><br><span style='font-size: 10pt; '>> multipolygon elements are not
valid geometries. The pattern is
pretty</span><br><span style='font-size: 10pt; '>> simple : some polygons
display the origin vertex 3 times as though
one</span><br><span style='font-size: 10pt; '>> started digitizing going
clockwise to close the polygon and then
came</span><br><span style='font-size: 10pt; '>> back counterclockwise not
necessarily exactly on the same vertices
and</span><br><span style='font-size: 10pt; '>> closed again. An example
:</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
"MULTIPOLYGON(((</span><br><span style='font-size: 10pt; '>> 376249.7830234
8717655.6050357,</span><br><span style='font-size: 10pt; '>> 376268.0818048
8717666.0116082,</span><br><span style='font-size: 10pt; '>> 376265.2666038
8717670.5117466,</span><br><span style='font-size: 10pt; '>> 376247.812391
8717660.3864341,</span><br><span style='font-size: 10pt; '>> 376249.7830234
8717655.6050357,</span><br><span style='font-size: 10pt; '>> 376247.812391
8717660.3864341,</span><br><span style='font-size: 10pt; '>> 376265.2666038
8717670.5117466,</span><br><span style='font-size: 10pt; '>> 376268.0818048
8717666.0116082,</span><br><span style='font-size: 10pt; '>> 376249.7830234
8717655.6050357)))"</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Deleting the last 4 lines on that geometry and shoving it back in
does</span><br><span style='font-size: 10pt; '>> the job. I tried to find an
automated way of doing this
(buffer,</span><br><span style='font-size: 10pt; '>> st_geometry ...) and but
didn't find anything. Any pointer to
an</span><br><span style='font-size: 10pt; '>> automated way of doing that,
short of writing my own function, which
I</span><br><span style='font-size: 10pt; '>> would need pointers for
examples too
:-),</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
TIA,</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Yves
Moisan</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
_______________________________________________</span><br><span style='font-size: 10pt; '>>
postgis-users mailing list</span><br><span style='font-size: 10pt; '>>
postgis-users@postgis.refractions.net</span><br><span style='font-size: 10pt; '>>
http://postgis.refractions.net/mailman/listinfo/postgis-users</span><br><span style='font-size: 10pt; '>>
</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>--
</span><br><span style='font-size: 10pt; '>SpatialDB Advice and Design,
Solutions Architecture and
Programming,</span><br><span style='font-size: 10pt; '>Oracle Database 10g
Administrator Certified Associate; Oracle Database 10g SQL Certified
Professional</span><br><span style='font-size: 10pt; '>Oracle Spatial, SQL
Server, PostGIS, MySQL, ArcSDE, Manifold GIS, Radius Topology and Studio
Specialist.</span><br><span style='font-size: 10pt; '>39 Cliff View Drive,
Allens Rivulet, 7150, Tasmania,
Australia.</span><br><span style='font-size: 10pt; '>Website:
www.spatialdbadvisor.com</span><br><span style='font-size: 10pt; '> Email:
simon@spatialdbadvisor.com</span><br><span style='font-size: 10pt; '> Voice:
+613 9016 3910</span><br><span style='font-size: 10pt; '>Mobile: +61 418
396391</span><br><span style='font-size: 10pt; '>Skype:
sggreener</span><br><span style='font-size: 10pt; '>Longitude: 147.20515
(147° 12' 18" E)</span><br><span style='font-size: 10pt; '>Latitude:
-43.01530 (43° 00' 55"
S)</span><br><span style='font-size: 10pt; '>NAC:W80CK
7SWP3</span><br><span style='font-size: 10pt; '>_______________________________________________</span><br><span style='font-size: 10pt; '>postgis-users
mailing
list</span><br><span style='font-size: 10pt; '>postgis-users@postgis.refractions.net</span><br><span style='font-size: 10pt; '>http://postgis.refractions.net/mailman/listinfo/postgis-users</span></div>
</body>
</html>