[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Corrupted topology when using totopogeom in 3D topology
From:       "Regina Obe" <lr () pcorp ! us>
Date:       2022-08-29 21:29:14
Message-ID: 002a01d8bbee$634ed170$29ec7450$ () pcorp ! us
[Download RAW message or body]

This is a multipart message in MIME format.

[Attachment #2 (multipart/alternative)]
This is a multipart message in MIME format.


I think the issue is that postgis topology only works with 2D and simply just carries \
the Z.  So all its assumptions about closedness and intersection are based on the 2D \
plane.

 

Thanks,

Regina

 

From: postgis-users [mailto:postgis-users-bounces@lists.osgeo.org] On Behalf Of \
                Alexandre Silva
Sent: Friday, August 26, 2022 7:14 AM
To: postgis-users@lists.osgeo.org
Subject: [postgis-users] Corrupted topology when using totopogeom in 3D topology

 

Hello,

 

I'm having some trouble creating a 3D topology using totopogeom method, I don't know \
if I'm not using the functions correctly or if there's indeed a bug, so any help \
would be appreciated.

 

I reduced the problem to an example with two lines.

The first line is added with no errors to the topology but the second one throws this \
error "Corrupted topology: ring of edge -3 is geometrically not-closed".

The second line intersects with the first one, but there's no vertex on the \
intersection.

I found two workarounds but both of them have some disadvantages in my point of view.

The first one was to add manually a vertex on the intersection (this involves someone \
doing that work manually).

The other one was to add the start and end point of every line using topogeo_addpoint \
before calling totopogeom (this involves remembering to do this every time that I \
create a topology and I think it's redundant and overhead for most cases).

 

https://imgur.com/a/FgIVyMO - here is the visual of the data for the error and \
non-error approach 

https://pastebin.com/CR5dNYSZ - here is a script to emulate the error, with the two \
workarounds commented

 

Not having much knowledge of the c code base, just looking at the code surrounding \
the error (https://www.postgis.net/docs/doxygen/3.0/d6/d03/lwgeom__topo_8c_source.html), \
my wild guess is that when it creates the ring of the newly closed area, and as there \
is no vertex on the intersection so no snap made, the ring is closed on 2D dimension \
but there is a 3D gap that makes the ring not geometrically closed. My reasoning for \
this is that the same data with a 2D topology has no errors and if I reverse the \
insertion order (there would be a node on the intersection), it also works. I can \
also be completely wrong.

 

This error was tested on docker image postgis/postgis:14-3.2-alpine with postgis \
version:

POSTGIS="3.2.1 0" [EXTENSION] PGSQL="140" GEOS="3.10.2-CAPI-1.16.0" PROJ="8.2.0" \
LIBXML="2.9.13" LIBJSON="0.15" LIBPROTOBUF="1.4.0" WAGYU="0.5.0 (Internal)" TOPOLOGY

 

There's no error in this version (also running in docker):

POSTGIS="3.0.1 ec2a9aa" [EXTENSION] PGSQL="120" GEOS="3.7.1-CAPI-1.11.1 27a5e771" \
SFCGAL="1.3.6" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.4.0, released \
2018/12/14" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.3.1" WAGYU="0.4.3 \
(Internal)" TOPOLOGY RASTER

 

Thanks,

Alexandre Silva

​​​

  <http://newsletter.impresapublishing.pt/i/barra_ip.jpg> 


[Attachment #5 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type \
content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 \
(filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);} o\:* \
{behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p
	{mso-style-priority:99;
	margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>I think the \
issue is that postgis topology only works with 2D and simply just carries the Z.   So \
all its assumptions about closedness and intersection are based on the 2D \
plane.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Thanks,<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Regina<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p>&nbsp;</o:p></span></p><div \
style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div \
style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p \
class=MsoNormal><b><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span \
style='font-size:11.0pt;font-family:"Calibri",sans-serif'> postgis-users \
[mailto:postgis-users-bounces@lists.osgeo.org] <b>On Behalf Of </b>Alexandre \
Silva<br><b>Sent:</b> Friday, August 26, 2022 7:14 AM<br><b>To:</b> \
postgis-users@lists.osgeo.org<br><b>Subject:</b> [postgis-users] Corrupted topology \
when using totopogeom in 3D topology<o:p></o:p></span></p></div></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>Hello,<o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>I'm having some trouble creating \
a 3D topology using totopogeom method, I don't know if I'm not using the functions \
correctly or if there's indeed a bug, so any help would be \
appreciated.<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>I reduced the problem to an \
example with two lines.<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>The first line is added with no \
errors to the topology but the second one throws this error &quot;Corrupted topology: \
ring of edge -3 is geometrically not-closed&quot;.<o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>The second line intersects with \
the first one, but there's no vertex on the \
intersection.<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span style='font-family:"Calibri",sans-serif;color:black'>I \
found two workarounds but both of them have some disadvantages in my point of \
view.<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>The first one was to add \
manually a vertex on the intersection (this involves someone doing that work \
manually).<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>The other one was to add the \
start and end point of every line using topogeo_addpoint before calling totopogeom \
(this involves remembering to do this every time that I create a topology and I think \
it's redundant and overhead for most cases).<o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><a \
href="https://imgur.com/a/FgIVyMO" \
id=LPNoLPOWALinkPreview>https://imgur.com/a/FgIVyMO</a> - here is the visual of the \
data for the error and non-error approach <o:p></o:p></span></p></div><div><p \
class=MsoNormal><a href="https://pastebin.com/CR5dNYSZ" \
id="LPNoLPOWALinkPreview_2">https://pastebin.com/CR5dNYSZ</a> - here is a script to \
emulate the error, with the two workarounds commented<o:p></o:p></p></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>Not having much knowledge of the \
c code base, just looking at the code surrounding the error (<a \
href="https://www.postgis.net/docs/doxygen/3.0/d6/d03/lwgeom__topo_8c_source.html" \
id=LPlnk119426>https://www.postgis.net/docs/doxygen/3.0/d6/d03/lwgeom__topo_8c_source.html</a>), \
my wild guess is that when it creates the ring of the newly closed area, and as there \
is no vertex on the intersection so no snap made, the ring is closed on 2D dimension \
but there is a 3D gap that makes the ring not geometrically closed. My reasoning for \
this is that the same data with a 2D topology has no errors and if I reverse the \
insertion order (there would be a node on the intersection), it also works. I can \
also be completely wrong.<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>This error was tested on docker \
image&nbsp;postgis/postgis:14-3.2-alpine with postgis \
version:<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>POSTGIS=&quot;3.2.1 0&quot; \
[EXTENSION] PGSQL=&quot;140&quot; GEOS=&quot;3.10.2-CAPI-1.16.0&quot; \
PROJ=&quot;8.2.0&quot; LIBXML=&quot;2.9.13&quot; LIBJSON=&quot;0.15&quot; \
LIBPROTOBUF=&quot;1.4.0&quot; WAGYU=&quot;0.5.0 (Internal)&quot; \
TOPOLOGY<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>There's no error in this version \
(also running in docker):<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>POSTGIS=&quot;3.0.1 \
ec2a9aa&quot; [EXTENSION] PGSQL=&quot;120&quot; GEOS=&quot;3.7.1-CAPI-1.11.1 \
27a5e771&quot; SFCGAL=&quot;1.3.6&quot; PROJ=&quot;Rel. 5.2.0, September 15th, \
2018&quot; GDAL=&quot;GDAL 2.4.0, released 2018/12/14&quot; LIBXML=&quot;2.9.4&quot; \
LIBJSON=&quot;0.12.1&quot; LIBPROTOBUF=&quot;1.3.1&quot; WAGYU=&quot;0.4.3 \
(Internal)&quot; TOPOLOGY RASTER<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>Thanks,<o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-family:"Calibri",sans-serif;color:black'>Alexandre \
Silva<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span style='color:black'>​​</span><span \
style='font-family:"Calibri",sans-serif;color:black;background:white'>​</span><span \
style='color:black'><o:p></o:p></span></p></div><p class=MsoNormal><img border=0 \
id="_x0000_i1025" src="http://newsletter.impresapublishing.pt/i/barra_ip.jpg"><o:p></o:p></p></div></div></body></html>




_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic