<div dir="ltr">Good that it's working for you too.<div><br></div><div>Glad you asked about scripting.  I was just going to post about a good option for doing this in a scripted way.  This uses the new JTS CLI [1][2].</div><div>(Note you will need to pull the latest overly-sr branch and rebuild, since the -explode option is newly added as of yesterday) <br></div><div><br></div><div>Here's a JtsOp command to run OverlayNG on the full dataset from a WKB file, saving the result to a file:</div><div><br></div><div><JTS HOME>/bin/jtsop.sh -a dbca_dump_116_35_117_34.wkb -b "POLYGON (EMPTY)" -f wkb -explode OverlayNG.union 100000000 > out.wkb<br></div><div><br></div><div>Alternatively the input could be sourced from a psql command-line query extracting the WKB from the DB.  That can be piped to the JtsOP command,</div><div>using the option "-a stdin".</div><div><br></div><div>And it may be possible to pipe the JtsOp WKB output back into the DB, perhaps by wrapping it with a SQL header and footer containing a COPY command?</div><div><br></div><div>If you get this working it would be nice to see the toolchain.</div><div><br></div><div>As for getting this into PostGIS, that is definitely the plan, and is being worked on right now.  Hopefully to ship by Q4 2020.</div><div></div><div><br></div><div>[1] <a href="https://github.com/locationtech/jts/blob/master/doc/JTSOp.md">https://github.com/locationtech/jts/blob/master/doc/JTSOp.md</a></div><div>[2] <a href="http://lin-ear-th-inking.blogspot.com/2019/08/a-cli-for-jts.html">http://lin-ear-th-inking.blogspot.com/2019/08/a-cli-for-jts.html</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 9, 2020 at 1:15 AM Jonathan Schultz <<a href="mailto:jonathan@schultz.la">jonathan@schultz.la</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It seems to work OK for me too. I managed to export the result using the 'Save as XML' function, which is a bit painful but does the job. Can you suggest how difficult it would be to script the procedure?<br>
<br>
Please let me know if there's anything can do to help move this along. It will be great to have this functionality in PostGIS.<br>
<br>
Cheers,<br>
Jonathan<br>
<br>
On 9/7/20 12:09 am, Martin Davis wrote:<br>
> Good news - overlaying the full dataset works using JTS OverlayNG in Snap-Rounding mode.  It completes in 195 s using a grid size of 1e-8 (which is quite fine).<br>
> <br>
> Interestingly it didn't complete when using OverlayNG with Snapping noding (which is  heuristic-based noding strategy intended to preserve more precision).  I'll have to look into that further.<br>
> <br>
> Here's some instructions on how to run this in JTS:<br>
> <br>
> - Clone the branch <a href="https://github.com/dr-jts/jts/tree/overlay-sr" rel="noreferrer" target="_blank">https://github.com/dr-jts/jts/tree/overlay-sr</a><br>
> - Build using maven clean install<br>
> - Run the TestBuilder (<a href="https://github.com/locationtech/jts/blob/master/doc/JTSTestBuilder.md" rel="noreferrer" target="_blank">https://github.com/locationtech/jts/blob/master/doc/JTSTestBuilder.md</a>)<br>
> - Convert the SQL file to a WKB file by removing the SQL header and footer, leaving only the WKB text<br>
> - Drop the WKB file onto the TestBuilder A input box to load it<br>
> - Run the geometry function OverlayNG/union with Grid Scale = 100000000<br>
> <br>
> <br>
> On Tue, Jul 7, 2020 at 10:49 PM Jonathan Schultz <<a href="mailto:jonathan@schultz.la" target="_blank">jonathan@schultz.la</a> <mailto:<a href="mailto:jonathan@schultz.la" target="_blank">jonathan@schultz.la</a>>> wrote:<br>
> <br>
>     Oh sorry about that. Here is a link to the file on my own VPS: <a href="http://barraqda.org/dbca_dump_116_35_117_34.zip" rel="noreferrer" target="_blank">http://barraqda.org/dbca_dump_116_35_117_34.zip</a><br>
> <br>
>     I've been playing with JTS but it's a bit of a steep learning curve. Getting stuck on Java NoClassDefFoundError messages, I presume related to incompatible versions and such-like. I'd very much appreciate advice on running OverlayNG.<br>
> <br>
>     Cheers,<br>
>     Jonathan<br>
> <br>
>     On 8/7/20 1:41 pm, Martin Davis wrote:<br>
>      > That's interesting that ST_SnapToGrid doesn't help for the full dataset - but not totally surprising, since it's a pretty blunt instrument.<br>
>      ><br>
>      > I'd like to try out the larger dataset.  That free download website seems to have a bunch of unpleasant strings attached though - is there any other way you can make the data available?<br>
>      ><br>
>      > If you are able to run Java, by all means try OverlayNG.  Happy to provide advice on how to run it if needed.<br>
>      ><br>
>      > cheers - Martin<br>
>      ><br>
>      > On Tue, Jul 7, 2020 at 8:10 PM Jonathan Schultz <<a href="mailto:jonathan@schultz.la" target="_blank">jonathan@schultz.la</a> <mailto:<a href="mailto:jonathan@schultz.la" target="_blank">jonathan@schultz.la</a>> <mailto:<a href="mailto:jonathan@schultz.la" target="_blank">jonathan@schultz.la</a> <mailto:<a href="mailto:jonathan@schultz.la" target="_blank">jonathan@schultz.la</a>>>> wrote:<br>
>      ><br>
>      >     Thank you for the prompt feedback.<br>
>      ><br>
>      >     As you suggested I tried using ST_SnapToGrid and that worked very well even with a very fine grid - st_snaptogrid(geometry,0.000000000001). However when it came to a collection of lines more useful for real work (13540 records compared with 6 in the minimal dataset) I found that snapping even to a grid so coarse as to render the data useless - st_snaptogrid(geometry,0.01) - still produced an incorrect result.<br>
>      ><br>
>      >     Here is the dump of my larger dataset: <a href="https://anonfiles.com/rdYcG1Edo2/dbca_dump_116_35_117_34_sql" rel="noreferrer" target="_blank">https://anonfiles.com/rdYcG1Edo2/dbca_dump_116_35_117_34_sql</a><br>
>      ><br>
>      >     I'll have a go myself with OverlayNG.<br>
>      ><br>
>      >     And I will file a PostGIS issue depending on the conclusions from this discussion.<br>
>      ><br>
>      ><br>
>      ><br>
> <br>
<br>
</blockquote></div>