Quantcast

Union problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Union problem

Swan Jerry

Dear list members,

Given geometries g1 and g2, they don't appear to be contained in their union. The code that exhibits this behaviour is below. Can someone kindly point me to the likely cause?

Regards,

Jerry.

////////////////////////////////////////////////////////////////////////////////////////////

Geometry amalgGeom = geom1.union( geom2 );

MultiPolygon mp;

if( amalgGeom instanceof Polygon )

    mp = gf.createMultiPolygon( new Polygon [] { (Polygon)amalgGeom } );

else

    mp = (MultiPolygon)amalgGeom;

assert mp.contains( geom1 );

assert mp.contains( geom2 );

////////////////////////////////////////////////////////////////////////////////////////////


This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.


_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Union problem

Martin Davis
This is expected behaviour.

There's an explanation in the FAQ here:
http://tsusiatsoftware.net/jts/jts-faq/jts-faq.html

under the heading "Why do overlay operations not obey the axioms of set
theory?"

Swan Jerry wrote:

>
> Dear list members,
>
> Given geometries g1 and g2, they don't appear to be contained in their
> union. The code that exhibits this behaviour is below. Can someone
> kindly point me to the likely cause?
>
> Regards,
>
> Jerry.
>
> ////////////////////////////////////////////////////////////////////////////////////////////
>
> Geometry amalgGeom = geom1.union( geom2 );
>
> MultiPolygon mp;
>
> *if*( amalgGeom *instanceof* Polygon )
>
>     mp = gf.createMultiPolygon( *new* Polygon [] { (Polygon)amalgGeom } );
>
> *else*
>
>     mp = (MultiPolygon)amalgGeom;
>
> assert mp.contains( geom1 );
>
> assert mp.contains( geom2 );
>
> ////////////////////////////////////////////////////////////////////////////////////////////
>
>
> This message has been checked for viruses but the contents of an
> attachment may still contain software viruses, which could damage your
> computer system: you are advised to perform your own checks. Email
> communications with the University of Nottingham may be monitored as
> permitted by UK legislation.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Loading...