Improve usability and consistency of spatial API

Description

SpatialContext has two methods: onDefaultCoordinates() and onCoordinates(String), the first one makes it easy for simple cases, but DistanceSortField constructors must know the spatial field name (you can't create one for the default coordinates). I suggest to add DistanceSortField(Point) and DistanceSortField(double, double) which act on default coordinates.

Same for FullTextQuery.setSpatialParameters(Point, String) and FullTextQuery.setSpatialParameters(double, double, String). There should be FullTextQuery.setSpatialParameters(Point) and FullTextQuery.setSpatialParameters(double, double).

I would like to reuse distance computation in my own code: if my entity implements Coordinates and I have a Point origin, I would like to be able to call origin.getDistanceTo(myEntity) but Point.getDistanceTo() takes a Point, not a Coordinates. I suggest to change Point.getDistanceTo(Point other) to Point.getDistanceTo(Coordinates other).

Environment

None

Status

Assignee

Hardy Ferentschik

Reporter

Xavier Dury

Labels

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Affects versions

4.2.0.Final

Priority

Trivial