If you only need to do this once, or speed is not really important, and your trace doesn't tend to loop back on itself so that detecting the closest two points could differ from detecting the line segment between them, then it's pretty easy. First, you need a distance squared...

I found it: the field definition needs the attribute spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory" or the system property SpatialContextFactory must be set to com.spatial4j.core.context.jts.JtsSpatialContextFactory.

One potential solution to this is extending the class to provide an additional function that either outputs the data you need in some convenient way: public Coordinate[] getReversedCoordinates(){ Coordinate[] original = this.getCoordinates(); Coordinate[] ret = new Coordinate[original.length]; for(int i =0; i<original.length; i++){ ret[i] = new Coordinate( original[i].x , original[i].y );...

This is not very nice solution, but it helps me to solve issue. So, issue is in Jackson way to serialize JTS Polygon and Point objects. This issue is solved by project jackson-datatype-jts. You can show this library sources on github - https://github.com/bedatadriven/jackson-datatype-jts All I need to run my test_point...

It turns out that I had a silly mistake in the backend. When I added the items to the tree I mixed up the x and y coords, so that the Lat Longs were reversed. After switching them, I can now set the size of the circle to around 0.1...