<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi again</p>
<p><br>
</p>
<p style="margin-bottom: 0in">I am not sure if this problem with drifting points are solvable by using fussy tolerance and simple feature in a easy way.</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">The main problem by using simple feature is that if a user are moving 2 points in a line with 100 points. Simple feature spec does not include any spec to mark this2 points as moved and mark the rest as unmoved. This means that
 the applications has to send all 100 points back to the server which in most causes means the system moves more 90% of the points. Maps are also analog data that makes complicated to preserve exact value, the only format that seems to preserve the value are
 WKB  and no map projections.</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">In stead of solving the problem with drifting point maybe it's easier just to walk around the problem, by only sending the part of line that has changed back to server. This is how we have done in the https://github.com/NibioOpenSource/pgtopo_update_sql
 that depends Postgis Topology. By doing it this way we remove the possibility of drifting points and we send less data back to the server from the client.
</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">But before you can start to update the data you need fix your exiting data the way to that is by using Postgis Topology and then you can use a snap tolerance to ensure that you get no small slices or gaps. Here is some guide lines
 on way to this by.</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">Here we have two lines that almost touch each other and that we want them to be one single line. By using Postgis Topology this lines are melted together. The basic idea is that you first add the lines that are ok, then you add
 the rest. </p>
<p style="margin-bottom: 0in"><br>
</p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000">#
</font><font color="#7f0055"><b>create</b></font><font color="#000000"> test </font>
<font color="#7f0055"><b>schema</b></font><font color="#000000"> if </font><font color="#7f0055"><b>not</b></font><font color="#000000"> exist</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000">psql sl -c</font><font color="#0000ff">'CREATE SCHEMA IF NOT EXISTS test2;'</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><br>
</p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000"># copy file muni_buffer_out that contains
</font><font color="#7f0055"><b>not</b></font><font color="#000000"> ok buffered out municipalitie border
</font><font color="#008000">"where komid not in (125)"</font><font color="#000000">
</font><font color="#7f0055"><b>into</b></font><font color="#000000"> </font><font color="#7f0055"><b>table</b></font><font color="#000000"> test2.sf_in (</font><font color="#7f0055"><b>drop</b></font><font color="#000000">
</font><font color="#7f0055"><b>and</b></font><font color="#000000"> </font><font color="#7f0055"><b>create</b></font><font color="#000000"> if exits)
</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000">shp2pgsql -W ISO-8859-1 -d -D -s 4258 data3/edge_1219 test2.sf_in | psql sl; psql sl -c
</font><font color="#008000">"SELECT topo_help_sf_to_topology_case_1('test2.sf_in','topo_3.muni_surface');"</font><font color="#000000">
</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000"># copy data
</font><font color="#7f0055"><b>from</b></font><font color="#000000"> test2.sf_in
</font><font color="#7f0055"><b>into</b></font><font color="#000000"> </font><font color="#7f0055"><b>table</b></font><font color="#000000"> topo_3.muni_surface (append data to topo_3.muni_edge)</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000">psql sl -c
</font><font color="#008000">"SELECT topo_help_sf_to_topology_case_1('test2.sf_in','topo_3.muni_edge',0.00001);"</font><font color="#000000">
</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><br>
</p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000"># copy file muni_buffer_in that contains
</font><font color="#7f0055"><b>not</b></font><font color="#000000"> ok buffered </font>
<font color="#7f0055"><b>in</b></font><font color="#000000"> municipalitie border
</font><font color="#008000">"where komid not in (214)"</font><font color="#000000">
</font><font color="#7f0055"><b>into</b></font><font color="#000000"> </font><font color="#7f0055"><b>table</b></font><font color="#000000"> test2.sf_in (</font><font color="#7f0055"><b>drop</b></font><font color="#000000">
</font><font color="#7f0055"><b>and</b></font><font color="#000000"> </font><font color="#7f0055"><b>create</b></font><font color="#000000"> if exits)
</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000">shp2pgsql -W ISO-8859-1 -d -D -s 4258 data3/edge_1521 test2.sf_in | psql sl; psql sl -c
</font><font color="#008000">"SELECT topo_help_sf_to_topology_case_1('test2.sf_in','topo_3.muni_surface');"</font><font color="#000000">
</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000"># copy data
</font><font color="#7f0055"><b>from</b></font><font color="#000000"> test2.sf_in
</font><font color="#7f0055"><b>into</b></font><font color="#000000"> </font><font color="#7f0055"><b>table</b></font><font color="#000000"> topo_3.muni_surface (append data to topo_3.muni_edge)</font></font></font></p>
<p align="LEFT" style="margin-bottom: 0in"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt"><font color="#000000">psql sl -c
</font><font color="#008000">"SELECT topo_help_sf_to_topology_case_1('test2.sf_in','topo_3.muni_edge',0.00001);"</font><font color="#000000">
</font></font></font></p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">The scripts and data can found at <a href="https://github.com/NibioOpenSource/pgtopo_update_sql/tree/develop/src/test/sql/import">
https://github.com/NibioOpenSource/pgtopo_update_sql/tree/develop/src/test/sql/import</a></p>
<p style="margin-bottom: 0in">if somebody whats to test it. </p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in"><font size="3"><span style="font-weight: normal">At
<a href="https://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology" title="https://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology
Cmd+ Klikk eller trykk for å følge koblingen">
https://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology</a> I have added section
</span></font></p>
<p style="margin-bottom: 0in"><font size="3"><span style="font-weight: normal">called “</span></font><font color="#000000"><font face="ArialMT, sans-serif"><font size="3"><span style="font-weight: normal">Convert shape file and simple feature data to Postgis
 Topology” that has some more info</span></font></font></font>.</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">When all the lines are added you have build the surfaces by using
<font color="#000000"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt">topology.CreateTopoGeom</font></font></font></p>
<p style="margin-bottom: 0in">and using the edges added. The code for this is also found in pgtopo_update_sql but wrapped into different part so it takes some work to extract this code into single function like
<font color="#008000"><font face="Monaco, monospace"><font size="2" style="font-size: 11pt">topo_help_sf_to_topology_case_1
</font></font></font>. Hopefully I will get the time to fix this later.</p>
<p style="margin-bottom: 0in"><br>
</p>
<p style="margin-bottom: 0in">Lars</p>
<p></p>
<p style="margin-bottom: 0in"><br>
</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Fra:</b> Willy-Bas Loos <willybas@gmail.com><br>
<b>Sendt:</b> 16. september 2016 17:20<br>
<b>Til:</b> PostGIS Users Discussion; Daniel Baston; Lars Aksel Opsahl<br>
<b>Emne:</b> Re: [postgis-users] fuzzy tolerance</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>
<div>
<div class="gmail_extra">
<div class="gmail_quote">On Thu, Sep 15, 2016 at 1:58 PM, Daniel Baston <span dir="ltr">
<<a target="_blank" href="mailto:dbaston@gmail.com">dbaston@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<span class="gmail-">> Any words of warning about using a trigger and storing the data on a 10 cm<br>
> grid like i suggest?</span><br>
</blockquote>
</div>
<br clear="all">
</div>
<div class="gmail_extra">Wow, thanks for the great responses. Lars Opsahl, nice to see you in the mailing list :D<br>
</div>
<div class="gmail_extra">So what i gather from this is that it is not ideal to use st_snaptogrid. It solves some problems, but it creates some new ones too.<br>
</div>
<div class="gmail_extra">Maybe a second geometry column would be a better idea, so that the original is still there (and will consume your server's memory &hdd space :/ )<br>
</div>
<div class="gmail_extra">Anyway, there is no automatic way to solve the problem right now.<br>
</div>
<div class="gmail_extra"><br>
</div>
So how big are the problems that arise from this?<br>
</div>
<div>For me i have to say that we often have problems with errors in overlays, and we have to keep using st_makevalid after every step of a process. Decreasing the supersmall artifacts in the geometries would probably help with that.
<br>
</div>
<div>@Lars Opsahl, you describe a lot of problems or very reasonable wishes in your presentation (link to abstract in previous mail). Do you think those could be solved with a concept similar to fuzzy tolerance?<br>
</div>
<div>@Daniel Baston could you describe some of the problems that the hyperprecise coordinates cause for you?<br>
<br>
</div>
<div>Cheers,<br>
</div>
</div>
<div>
<div>
<div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">-- <br>
<div class="gmail_signature">
<div dir="ltr">Willy-Bas Loos<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>