Quantcast

UnaryUnionOp and GeometryExtracter

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

UnaryUnionOp and GeometryExtracter

michaelm-2
Hi Martin,

I've got a bug in the OpenJUMP PlanarGraph plugin, and I'm not sure if
it comes from a JTS bug or if I have to find a workaround.

When I want to create a planar graph from an heterogeneous layer, I
union all the linear components of the layer (it is a simple way to get
a noded collection of linestrings).
The problem is that the linear components issued from polygons are
LinearRings, and UnaryUnion use a GeometryExtracter which test linear
components with a "o.getClass() == clz;" test, excluding all the linear
rings. At least, it is what I guessed after some investigation.

Is this behaviour intentional ? Why not testing if geometry instanceof
LineString ?
Do I have to transform LinearRings into LineString first ?

Thanks for your help

Michaël

_______________________________________________
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: UnaryUnionOp and GeometryExtracter

Martin Davis
You're right, Michael, that's a bug.

The fix is easy - use Class.isAssignableFrom instead of ==

The reason for not using instanceof is that the right operand has to be
a classname - it can't be a variable.

I'll make this fix in CVS now - hopefully you can build from there.

And yes, if you can convert your LinearRings to LineString that should
work too.  (But you can't just cast them, obviously - you have to make a
new LineString object)

Thanks for the bug report!

Michael Michaud wrote:

> Hi Martin,
>
> I've got a bug in the OpenJUMP PlanarGraph plugin, and I'm not sure if
> it comes from a JTS bug or if I have to find a workaround.
>
> When I want to create a planar graph from an heterogeneous layer, I
> union all the linear components of the layer (it is a simple way to
> get a noded collection of linestrings).
> The problem is that the linear components issued from polygons are
> LinearRings, and UnaryUnion use a GeometryExtracter which test linear
> components with a "o.getClass() == clz;" test, excluding all the
> linear rings. At least, it is what I guessed after some investigation.
>
> Is this behaviour intentional ? Why not testing if geometry instanceof
> LineString ?
> Do I have to transform LinearRings into LineString first ?
>
> Thanks for your help
>
> Michaël
>
> _______________________________________________
> 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...