jts-topo-suite-user

 [Jts-topo-suite-user] Polygon difference problem From: Brian Sanjeewa Rupasinghe - 2013-03-21 05:50:50 Attachments: Message as HTML ```Hi, I have two polygons as follows: Geometry poly1 = POLYGON ((401034.9795410591 488331.76811906695, 401034.9795410591 488381.205619067, 401064.8857910591 488381.205619067, 401064.8857910591 488331.76811906695, 401034.9795410591 488331.76811906695)) Geometry poly2 = POLYGON ((401055.6045410591 488331.83061906317, 401037.36553711747 488331.8306190668, 401036.0107910591 488331.830619067, 401035.6826660591 488331.83061906707, 401035.3857910591 488331.8306190671, 401034.9795410591 488331.8306190672, 401034.9795410591 488345.330619067, 401034.9795410591 488350.143119067, 401034.9795410591 488351.893119067, 401034.9795410591 488381.205619067, 401040.3545410591 488381.20561906695, 401040.6826660591 488381.20561906695, 401047.2920410591 488381.2056190669, 401050.9170410591 488381.20561906684, 401050.9170410591 488368.361869067, 401050.9170410591 488358.86186906707, 401060.3545410591 488358.861869067, 401060.7295410591 488358.861869067, 401064.8857910591 488358.861869067, 401064.8857910591 488355.143119067, 401064.8857910591 488353.393119067, 401064.8857910591 488336.924369067, 401064.8857910591 488336.611869067, 401064.8857910591 488331.76811906695, 401060.6045410591 488331.76811906695, 401060.4482910591 488331.76811906695, 401055.7607910591 488331.76811906695, 401055.6045410591 488331.768119067, 401055.6045410591 488331.83061906317)) When i get the difference of these two with the following code, the resulting polygons is invalid although rslt.isValid() becomes TRUE. Any solution for this? Geometry rslt = poly1.difference(poly2); Geometry rslt = (((401034.9795410591 488331.76811906695, 401034.9795410591 488331.8306190672, 401035.3857910591 488331.8306190671, 401035.6826660591 488331.83061906707, 401036.0107910591 488331.830619067, 401037.36553711747 488331.8306190668, 401055.6045410591 488331.83061906317, 401055.6045410591 488331.768119067, 401055.7607910591 488331.76811906695, 401034.9795410591 488331.76811906695)), ((401034.9795410591 488381.205619067, 401064.8857910591 488381.205619067, 401064.8857910591 488358.861869067, 401060.7295410591 488358.861869067, 401060.3545410591 488358.861869067, 401050.9170410591 488358.86186906707, 401050.9170410591 488368.361869067, 401050.9170410591 488381.20561906684, 401047.2920410591 488381.2056190669, 401040.6826660591 488381.20561906695, 401040.3545410591 488381.20561906695, 401034.9795410591 488381.205619067))) Best, Brian. ```
 Re: [Jts-topo-suite-user] Polygon difference problem From: Martin Davis - 2013-03-21 14:55:28 Attachments: Message as HTML ```I don't follow. The result of computing the difference is a valid MultiPolygon. Granted, it does have some slivers and spikes, due to slight discrepancies between the vertices of the inputs. Is this not what you expect? On 3/20/2013 10:50 PM, Brian Sanjeewa Rupasinghe wrote: > Hi, > > I have two polygons as follows: > > Geometry poly1 = POLYGON ((401034.9795410591 488331.76811906695, > 401034.9795410591 488381.205619067, 401064.8857910591 > 488381.205619067, 401064.8857910591 488331.76811906695, > 401034.9795410591 488331.76811906695)) > > Geometry poly2 = POLYGON ((401055.6045410591 488331.83061906317, > 401037.36553711747 488331.8306190668, 401036.0107910591 > 488331.830619067, 401035.6826660591 488331.83061906707, > 401035.3857910591 488331.8306190671, 401034.9795410591 > 488331.8306190672, 401034.9795410591 488345.330619067, > 401034.9795410591 488350.143119067, 401034.9795410591 > 488351.893119067, 401034.9795410591 488381.205619067, > 401040.3545410591 488381.20561906695, 401040.6826660591 > 488381.20561906695, 401047.2920410591 488381.2056190669, > 401050.9170410591 488381.20561906684, 401050.9170410591 > 488368.361869067, 401050.9170410591 488358.86186906707, > 401060.3545410591 488358.861869067, 401060.7295410591 > 488358.861869067, 401064.8857910591 488358.861869067, > 401064.8857910591 488355.143119067, 401064.8857910591 > 488353.393119067, 401064.8857910591 488336.924369067, > 401064.8857910591 488336.611869067, 401064.8857910591 > 488331.76811906695, 401060.6045410591 488331.76811906695, > 401060.4482910591 488331.76811906695, 401055.7607910591 > 488331.76811906695, 401055.6045410591 488331.768119067, > 401055.6045410591 488331.83061906317)) > > When i get the difference of these two with the following code, the > resulting polygons is invalid although rslt.isValid() becomes TRUE. > Any solution for this? > > Geometry rslt = poly1.difference(poly2); > > Geometry rslt = (((401034.9795410591 488331.76811906695, > 401034.9795410591 488331.8306190672, 401035.3857910591 > 488331.8306190671, 401035.6826660591 488331.83061906707, > 401036.0107910591 488331.830619067, 401037.36553711747 > 488331.8306190668, 401055.6045410591 488331.83061906317, > 401055.6045410591 488331.768119067, 401055.7607910591 > 488331.76811906695, 401034.9795410591 488331.76811906695)), > ((401034.9795410591 488381.205619067, 401064.8857910591 > 488381.205619067, 401064.8857910591 488358.861869067, > 401060.7295410591 488358.861869067, 401060.3545410591 > 488358.861869067, 401050.9170410591 488358.86186906707, > 401050.9170410591 488368.361869067, 401050.9170410591 > 488381.20561906684, 401047.2920410591 488381.2056190669, > 401040.6826660591 488381.20561906695, 401040.3545410591 > 488381.20561906695, 401034.9795410591 488381.205619067))) > > Best, Brian. > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar > > > _______________________________________________ > Jts-topo-suite-user mailing list > Jts-topo-suite-user@... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user ```
 Re: [Jts-topo-suite-user] Polygon difference problem From: Brian Sanjeewa Rupasinghe - 2013-03-22 04:35:11 Attachments: Message as HTML ```Hi Martin, Thanks, I got it form your point. The two inputs i used are rectangles where poly1 has some intermediate vertices between the four edges with some minute discrepancies. Therefore, i do not get the expected outcome which has to be another two smaller rectangles after applying difference. Any solution for this? I tried using GeometrySnapper class but it did not work. Cheers, Brian On Thu, Mar 21, 2013 at 11:20 AM, Brian Sanjeewa Rupasinghe < jinkabs@...> wrote: > Hi, > > I have two polygons as follows: > > Geometry poly1 = POLYGON ((401034.9795410591 488331.76811906695, > 401034.9795410591 488381.205619067, 401064.8857910591 488381.205619067, > 401064.8857910591 488331.76811906695, 401034.9795410591 488331.76811906695)) > > Geometry poly2 = POLYGON ((401055.6045410591 488331.83061906317, > 401037.36553711747 488331.8306190668, 401036.0107910591 488331.830619067, > 401035.6826660591 488331.83061906707, 401035.3857910591 488331.8306190671, > 401034.9795410591 488331.8306190672, 401034.9795410591 488345.330619067, > 401034.9795410591 488350.143119067, 401034.9795410591 488351.893119067, > 401034.9795410591 488381.205619067, 401040.3545410591 488381.20561906695, > 401040.6826660591 488381.20561906695, 401047.2920410591 488381.2056190669, > 401050.9170410591 488381.20561906684, 401050.9170410591 488368.361869067, > 401050.9170410591 488358.86186906707, 401060.3545410591 488358.861869067, > 401060.7295410591 488358.861869067, 401064.8857910591 488358.861869067, > 401064.8857910591 488355.143119067, 401064.8857910591 488353.393119067, > 401064.8857910591 488336.924369067, 401064.8857910591 488336.611869067, > 401064.8857910591 488331.76811906695, 401060.6045410591 488331.76811906695, > 401060.4482910591 488331.76811906695, 401055.7607910591 488331.76811906695, > 401055.6045410591 488331.768119067, 401055.6045410591 488331.83061906317)) > > When i get the difference of these two with the following code, the > resulting polygons is invalid although rslt.isValid() becomes TRUE. Any > solution for this? > > Geometry rslt = poly1.difference(poly2); > > Geometry rslt = (((401034.9795410591 488331.76811906695, 401034.9795410591 > 488331.8306190672, 401035.3857910591 488331.8306190671, 401035.6826660591 > 488331.83061906707, 401036.0107910591 488331.830619067, 401037.36553711747 > 488331.8306190668, 401055.6045410591 488331.83061906317, 401055.6045410591 > 488331.768119067, 401055.7607910591 488331.76811906695, 401034.9795410591 > 488331.76811906695)), ((401034.9795410591 488381.205619067, > 401064.8857910591 488381.205619067, 401064.8857910591 488358.861869067, > 401060.7295410591 488358.861869067, 401060.3545410591 488358.861869067, > 401050.9170410591 488358.86186906707, 401050.9170410591 488368.361869067, > 401050.9170410591 488381.20561906684, 401047.2920410591 488381.2056190669, > 401040.6826660591 488381.20561906695, 401040.3545410591 488381.20561906695, > 401034.9795410591 488381.205619067))) > > Best, Brian. > ```
 Re: [Jts-topo-suite-user] Polygon difference problem From: Martin Davis - 2013-03-22 05:13:58 Attachments: Message as HTML ```In my testing GeometrySnapper *almost* works, apart from the two points along the top of the rectangle. Perhaps you could run GeometrySnapper, and then write some code to snap discrepant intermediate points to the target rectangle? On 3/21/2013 9:35 PM, Brian Sanjeewa Rupasinghe wrote: > Hi Martin, > > Thanks, I got it form your point. The two inputs i used are rectangles > where poly1 has some intermediate vertices between the four edges with > some minute discrepancies. Therefore, i do not get the expected > outcome which has to be another two smaller rectangles after applying > difference. Any solution for this? I tried using GeometrySnapper class > but it did not work. > > Cheers, Brian > > On Thu, Mar 21, 2013 at 11:20 AM, Brian Sanjeewa Rupasinghe > > wrote: > > Hi, > > I have two polygons as follows: > > Geometry poly1 = POLYGON ((401034.9795410591 488331.76811906695, > 401034.9795410591 488381.205619067, 401064.8857910591 > 488381.205619067, 401064.8857910591 488331.76811906695, > 401034.9795410591 488331.76811906695)) > > Geometry poly2 = POLYGON ((401055.6045410591 488331.83061906317, > 401037.36553711747 488331.8306190668, 401036.0107910591 > 488331.830619067, 401035.6826660591 488331.83061906707, > 401035.3857910591 488331.8306190671, 401034.9795410591 > 488331.8306190672, 401034.9795410591 488345.330619067, > 401034.9795410591 488350.143119067, 401034.9795410591 > 488351.893119067, 401034.9795410591 488381.205619067, > 401040.3545410591 488381.20561906695, 401040.6826660591 > 488381.20561906695, 401047.2920410591 488381.2056190669, > 401050.9170410591 488381.20561906684, 401050.9170410591 > 488368.361869067, 401050.9170410591 488358.86186906707, > 401060.3545410591 488358.861869067, 401060.7295410591 > 488358.861869067, 401064.8857910591 488358.861869067, > 401064.8857910591 488355.143119067, 401064.8857910591 > 488353.393119067, 401064.8857910591 488336.924369067, > 401064.8857910591 488336.611869067, 401064.8857910591 > 488331.76811906695, 401060.6045410591 488331.76811906695, > 401060.4482910591 488331.76811906695, 401055.7607910591 > 488331.76811906695, 401055.6045410591 488331.768119067, > 401055.6045410591 488331.83061906317)) > > When i get the difference of these two with the following code, > the resulting polygons is invalid although rslt.isValid() becomes > TRUE. Any solution for this? > > Geometry rslt = poly1.difference(poly2); > > Geometry rslt = (((401034.9795410591 488331.76811906695, > 401034.9795410591 488331.8306190672, 401035.3857910591 > 488331.8306190671, 401035.6826660591 488331.83061906707, > 401036.0107910591 488331.830619067, 401037.36553711747 > 488331.8306190668, 401055.6045410591 488331.83061906317, > 401055.6045410591 488331.768119067, 401055.7607910591 > 488331.76811906695, 401034.9795410591 488331.76811906695)), > ((401034.9795410591 488381.205619067, 401064.8857910591 > 488381.205619067, 401064.8857910591 488358.861869067, > 401060.7295410591 488358.861869067, 401060.3545410591 > 488358.861869067, 401050.9170410591 488358.86186906707, > 401050.9170410591 488368.361869067, 401050.9170410591 > 488381.20561906684, 401047.2920410591 488381.2056190669, > 401040.6826660591 488381.20561906695, 401040.3545410591 > 488381.20561906695, 401034.9795410591 488381.205619067))) > > Best, Brian. > > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar > > > _______________________________________________ > Jts-topo-suite-user mailing list > Jts-topo-suite-user@... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user ```