<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Good description of &nbsp;a reasonable approach Brent! &nbsp;At one point, for a certain dataset, I was able to calculate a pretty reliable (e.g. still made valid features) &nbsp;ratio of simplification threshold based on map scale. &nbsp;I don't have the data anymore, but it was almost like an LOD level of detail approach. &nbsp;<div><br></div><div>With that in mind, I'd like to see what one could do with LOD approach in OpenGL with map data - probably blows away our best little hacks ;-) &nbsp;Never got to that yet :)<div><br><div><div>On 2012-05-25, at 4:26 PM, <a href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font: inherit;">My 02c...<br><br>If you have a table with a geometry column, you can add a second geometry column for the simplified ones. As in the script below, for a national coastline with about 10,000 polygons<br><br>You can generate the simplified ones using a series of update SQL statements, based on a variety of criteria, including neighbouring (or not) via a ST_Distance() in the where clause.<br><br>If you hand craft the update SQL's, you can just copy rather than simplify smaller polygons (ST_Area in the where clause), etc.<br><br>A slowish way, but viable for a 1-off is to have a where clause with an ST_IsValid in the where clause testing the result of the simplification. If the where clause includes a test for the target geometry being not-null, the series can apply a large simplification initially, then progressively apply a decreasing simplifcation buffer to
 features that failed previous iterations, until the last statement copies any remaining features with zero simplification.<br><br>I prefer a script with a set of SQL's rather than a function, as it is easier to tweak case requirements. <br><br>The advantage of this approach over the preserving topology simplify function is the degree of control the hand crafted SQL's provide over exactly how to simplify the dataset.<br><br>But, as always, your mileage may vary :-)<br><br>&nbsp; Cheers,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Brent Wood<br><br><br>#! /bin/bash<br>#<br># script to simplify NZ coastline for zoom layer<br><br>DB=nzcoast<br>TAB=nz_all<br><br><br># add new geometry column<br>psql -d $DB -c "alter table nz_all drop column simple_geom;"<br><br>psql -d $DB -c "alter table nz_all add column simple_geom geometry(multipolygon,4326);"<br><br><br># populate<br># do small islands with no simplification<br>psql -d $DB -qc "update
 nz_all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set simple_geom=geom <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where ST_Area(geom) &lt; 0.0000000001;"<br>psql -d $DB -qc "update nz_all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set simple_geom=ST_Simplify(geom, 0.001) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where simple_geom isnull<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and ST_IsValid(ST_Simplify(geom, 0.001));"<br>psql -d $DB -qc "update nz_all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set simple_geom=ST_Simplify(geom, 0.0001) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where
 simple_geom isnull<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and ST_IsValid(ST_Simplify(geom, 0.0001));"<br>psql -d $DB -qc "update nz_all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set simple_geom=ST_Simplify(geom, 0.00001) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where simple_geom isnull<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and ST_IsValid(ST_Simplify(geom, 0.00001));"<br>psql -d $DB -qc "update nz_all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set simple_geom=geom <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where simple_geom isnull;"<br><br><br><br><br>--- On <b>Sat, 5/26/12, Carson Farmer
 <i>&lt;<a href="mailto:carson.farmer@gmail.com">carson.farmer@gmail.com</a>&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Carson Farmer &lt;<a href="mailto:carson.farmer@gmail.com">carson.farmer@gmail.com</a>&gt;<br>Subject: Re: [Qgis-developer] Vector Layer Generalization<br>To: "Evgeniy Pashentsev" &lt;<a href="mailto:ugnpaul@gmail.com">ugnpaul@gmail.com</a>&gt;<br>Cc: <a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a><br>Date: Saturday, May 26, 2012, 10:11 AM<br><br><div class="plainMail">Excellent! Topology preserving simplification is something I've been<br>looking for!<br>&gt; But I want to ask your advice on one thing. Is it normal for user<br>&gt; to&nbsp;simplify all the features on a layer at once? I'm just not sure<br>&gt; which way&nbsp;is more suitable for a regular user:<br>&gt; - simplify all the features at once as it is now in my current prototype;<br>&gt; - simplify selected feature and all the corresponding vertexes of<br>&gt; the&nbsp;neighboring features;<br>&gt; - or simplify only selected
 features;<br>&gt; - or even something else.<br>&gt; Although it is not very important for current work, I want to make sure<br>&gt; I don't implement useless functionality.<br>Personally, I normally simplify an entire layer at once... for mapping<br>purposes, or simply to reduce drawing time or for computational/space<br>efficiency. It might be nice to also have the option to simplify<br>selected features only, but if this was an option, then I would expect<br>*only* those selected features to be simplified... and *not* their<br>neighbouring features...<br><br>That's my two cents anyway, looking forward to trying it out!<br><br>Carson<br><br><br>-- <br>Dr. Carson J. Q. Farmer<br>Centre for GeoInformatics (CGI)<br>School of Geography and Geosciences<br>Irvine Building, University of St Andrews<br>St Andrews, Fife, KY16 9AL<br>Scotland, UK<br>_______________________________________________<br>Qgis-developer mailing list<br><a ymailto="mailto:Qgis-developer@lists.osgeo.org" href="x-msg://1873/mc/compose?to=Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></div></blockquote></td></tr></tbody></table>_______________________________________________<br>Qgis-developer mailing list<br><a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br class="Apple-interchange-newline">-----</div><div>Tyler Mitchell, Publisher</div><div>Locate Press,&nbsp;<a href="mailto:info@locatepress.com">info@locatepress.com</a></div><div>Open Source "geo" Books</div><div><a href="http://www.locatepress.com">http://www.locatepress.com</a></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></div></div></body></html>