I am working on my university project, and I use GeoTools library. My task is to implement AGNES (agglomerative nesting) algorithm that considers spatial data. To do this I need to calculate distances between spatial objects e.g. points, curves, polygons.
LineString which can be converted to Curve is a GeoTools class that inherits Geometry methods including distance(). My question is how is the distance between two LineString objects calculated? Is it the shortest line segment connecting both curves? Also, I am curious how similar is done with polygons.