Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
Activity
• Aug 01 2018 17:48
@jnh5y banned @matrixbot
Martin Davis
@dr-jts
yes, I put the new code in the old triangulate package. Maybe not ideal, but it will do for now.
TidalPoo
@TidalPoo
hi all!
I have been trying for several days to find instructions on how to make a multipolygon from several polygons.
And then how to determine to which polygon the coordinates in multipolygons belong.
I would be grateful for any help.
Jody Garnett
@jodygarnett
What have you figured out so far? MultiPolygon is created from a collection of polygons …
You can use getGeometryN to retrieve a specific geometry to check
I am not sure exactly what you mean by “belong” ?
TidalPoo
@TidalPoo
Perhaps I wrote the question incorrectly. I have a task. I need to make several polygons with names on the plane. A point will move randomly along these polygons. I need to get the name of the polygon where the point is.
Jody Garnett
@jodygarnett
Okay, that tends to be considered a feature (ie geometry with an attribute - in this case a name).
JTS provides one user data object which you could use to store a name. Or you could use a library that supports features such as GeoTools (which has a feature data type and a uses JTS for the geometry attribute(s) of each feature).
How many polygons are you working with? Hundreds, thousands, millions?
TidalPoo
@TidalPoo
thanks for your reply. Yes, I am considering working with geometry. i don't want to use GeoTools. It should be a very light project. I will have several planes (levels), each with its own set of polygons, no more than 50.
TidalPoo
@TidalPoo
The point will be moved by keyboard control. I need to understand which polygon the point is in now. I worked with jmonkey, but it is too heavy a library to perform such a simple function.
Can you show some example code? Do I need to create geometry, assign a name, and add it to multigeometry?
TidalPoo
@TidalPoo
is this ok, or are there any better ideas?
Martin Davis
@dr-jts
That looks fine. You can also just keep the polygons in a regular Java List. The only reason to keep them in a GeometryCollection would be if you want to perform other geometric operations on them.
James Hughes
@jnh5y
@dr-jts sorry for my confusion on that ZM issue;) I'm calling it a night now:)
Martin Davis
@dr-jts
np... get some sleep!
James Hughes
@jnh5y
indeed! I'm liking the suggestion of a single XYZM Test calling out to the operations
Martin Davis
@dr-jts
cool
Björn Harrtell
@bjornharrtell
I have a case where need to union sets of bboxes. It's done in PostGIS and AFAIK it converts bboxes to polygons and uses plain GEOS general polygon union on them which is expensive when the amount is large. Any ideas if this case could deserve an optimized path in JTS?
Martin Davis
@dr-jts
In general unioning rectangles can produce an arbitrarily complex output, so I'm not sure much optimization is possible. Are you aware of a fast algorithm?
Chris Hodgson
@cmhodgson
If you just want an enclosing bounding box for everything then you could use st_extent(), that will be fast but you'll only get the min of the mins and the max of the maxes, not a jagged-edged mass of unioned boxes
Björn Harrtell
@bjornharrtell
@dr-jts: I see you point and unfortunately not..
@cmhodgson: problem is I need to eliminate overlaps to calculate non overlapping area.
Martin Davis
@dr-jts
@jnh5y @jodygarnett any thoughts on #805 and#806? I'm not keen on introducing another dependency, and this is the only complaint about this change so far, so I"m -1 on this
James Hughes
@jnh5y
@dr-jts Neat! That is not adding a dependency to JTS. It is only adding a dependency to the JTS build.
The approach is to have the build generate backwards compatible bytecode
that's actually kinda cool
Martin Davis
@dr-jts
Just landed: locationtech/jts#810
James Hughes
@jnh5y
Very nice!
DonoG
@DonoG
I’ve got a series of line segments that I’m trying to polygonise. But I’ve got some lines that intersect other lines, but not at a start or end point of another line. To get all the lines to correctly polygonise, I was thinking I might need to test each line for intersections, find the intersection point and then split lines of there are intersections. Or is there an easier way to do this?
Chris Hodgson
@cmhodgson
@DonoG You will want to look at the noding package and noder class - this will do all the intersections for you.
DonoG
@DonoG
@cmhodgson Thanks. I've tried both SimplerNoder and MCIndexNoder - without any luck. I am trying to take a series of linestrings and then polygonise them. If I first compute the nodes, and then use Polygonizer polygonizer = new Polygonizer(false); I can get seven polygons out of the following linestrings. But visually, if I plot the lines, they form nine polygons. The linestrings are: [LINESTRING (450 466, 450 514), LINESTRING (450 562, 450 610), LINESTRING (450 658, 450 706), LINESTRING (228.29750061035156 530, 450 658), LINESTRING (450 562, 228.29750061035156 434), LINESTRING (228.29750061035156 338, 450 466), LINESTRING (671.7025146484375 530, 450 658), LINESTRING (450 562, 671.7025146484375 434), LINESTRING (671.7025146484375 338, 450 466), LINESTRING (228.29750061035156 338, 228.29750061035156 386), LINESTRING (228.29750061035156 434, 228.29750061035156 482), LINESTRING (228.29750061035156 530, 228.29750061035156 578), LINESTRING (671.7025146484375 578, 671.7025146484375 530), LINESTRING (671.7025146484375 482, 671.7025146484375 434), LINESTRING (671.7025146484375 386, 671.7025146484375 338), LINESTRING (450 706, 228.29750061035156 578), LINESTRING (228.29750061035156 482, 450 610), LINESTRING (450 514, 228.29750061035156 386), LINESTRING (630.13330078125 506, 671.7025146484375 530), LINESTRING (671.7025146484375 434, 630.13330078125 410), LINESTRING (450 210, 671.7025146484375 338), LINESTRING (671.7025146484375 578, 450 706), LINESTRING (450 610, 671.7025146484375 482), LINESTRING (671.7025146484375 386, 450 514), LINESTRING (228.29750061035156 530, 269.8667297363281 506), LINESTRING (269.8667297363281 410, 228.29750061035156 434), LINESTRING (228.29750061035156 338, 450 210)]
Martin Davis
@dr-jts
This is because your linework has a couple of places where the lines don't actually touch. This can be observed using the Magnify Topology mode in the JTS TestBuilder:
So running noding results in this output, where the gap are still present:
And thus Polygonize only forms polygons in the closed spaces:
That should be Reveal Topology mode... (I changed the name a while back!)
Martin Davis
@dr-jts
Coming soon: locationtech/jts#823
Concave Hulls...
James Hughes
@jnh5y
Awesome! Will that mean a minor release soonish?
Martin Davis
@dr-jts
Well, there is a fair bit of stuff stacked up. So probably a good idea, in early 2022
marko asplund
@marko-asplund
Hi! We're using jts-core in out backend service and while analysing our library dependencies with the jdeps tool I noticed jts-core-1.18.2.jar seems to depend on java.desktop as well as java.xml modules. java.desktop in particular seems a bit strange dependency to have in a backend service and this limits the ability to run jts-core services with trimmed down Java RT images.
Would it be possible in the future to modularise jts-core a bit further in the future and and place the code that requires e.g. font rendering capabilities or XML APIs in separate modules?
Jody Garnett
@jodygarnett
We have already taken that approach to some extent, not many of us are developing on java 11 or 14 and making use of the module system (day to day work for me is largely J2EE based on stuck on Java 8).
Martin Davis
@dr-jts
The reason for "java desktop" I think must be the awt package which converts to and from AWT Shapes.
XML is just for the GML code, I think