Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCircle.getGeometry() returns point, should return polygon? #163

Open
basisbit opened this issue Sep 26, 2017 · 4 comments
Open

LCircle.getGeometry() returns point, should return polygon? #163

basisbit opened this issue Sep 26, 2017 · 4 comments

Comments

@basisbit
Copy link
Contributor

Currently LCircle.getGeometry() returns a JTS point.

return JTSUtil.toPoint(getPoint());

If a developer uses for example a LDraw.FeatureDrawnListener, then stores the JTS geometry ( FeatureDrawnEvent.getDrawnFeature().getGeometry() ) somewhere and later on recreates the object using LFeatureGroup.addComponent(JTSUtil.toLayer(geometry)), the result will be only a single LMarker for that point on the map.

How about changing this function to returning a polygon (buffer of size radius around the point)? JTS provides the necessary functions to calculate that: https://locationtech.github.io/jts/javadoc/org/locationtech/jts/geom/Geometry.html#buffer(double)

@mstahv
Copy link
Owner

mstahv commented Oct 18, 2017

Sounds reasonable to me. Will you create a pull request?

@basisbit
Copy link
Contributor Author

basisbit commented Nov 2, 2017

After testing some different ways to fix/change this behaviour, I am not sure any more what actually is the best solution for storing, displaying and calculating of "circles" would be. There was a huge discussion on the jts mailing list ~5 years ago and they didn't come up with a solution that works good for all use cases.

Calculating a buffer with X points per circle-quarter as done by geotools is quite CPU expensive and makes it difficult to edit these geometries later on.

Maybe extending the LCircle.getGeometry() JTSUtil.toPoint(getPoint()) to also do (jts)Geometry.setUserData(getRadius) and add a note in the code documentation about where to find the radius would be a better solution. Then, a developer would at least be able to get the radius value from a generic FeatureDrawnEvent.getDrawnFeature().getGeometry().

@TorstenBMR
Copy link

sounds reasonable - any proceedings on this issue?
Currently we have the strange result, that drawing a circle on a map is fine, but it's not possible to automatically zoom to the right level:

LCircle circle = new LCircle(50, 10, 5000);
map.addComponent(circle);
map.zoomToContent(); // does nothing

@mstahv
Copy link
Owner

mstahv commented Aug 31, 2018

I think there is a change in the latest version that takes the center point into account in zoomToContent, but still no improvements to really obey the whole geometry.

There is a lot of things in queue for me to do in this project, this would really be a good place for contribution ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants