use of org.opengis.geometry.coordinate.Position in project collect by openforis.
the class GeoToolsCoordinateOperations method validate.
public boolean validate(Coordinate coordinate) {
try {
double x = coordinate.getX();
double y = coordinate.getY();
String srsId = coordinate.getSrsId();
Position position = toLatLonPosition(x, y, srsId);
GeodeticCalculator calculator = new GeodeticCalculator();
// this will call methods checkLatidude and checkLongitude inside of GeodeticCalculator
calculator.setStartingPosition(position);
return true;
} catch (Exception e) {
return false;
}
}
use of org.opengis.geometry.coordinate.Position in project collect by openforis.
the class GeoToolsCoordinateOperations method orthodromicDistance.
public double orthodromicDistance(double startX, double startY, String startSRSId, double destX, double destY, String destSRSId) throws CoordinateOperationException {
Position startingPosition = toLatLonPosition(startX, startY, startSRSId);
Position destinationPosition = toLatLonPosition(destX, destY, destSRSId);
return orthodromicDistance(startingPosition, destinationPosition);
}
use of org.opengis.geometry.coordinate.Position in project collect by openforis.
the class GeoToolsCoordinateOperations method convertTo.
public Coordinate convertTo(Coordinate coordinate, String toSrsId) {
if (toSrsId.equals(coordinate.getSrsId())) {
return coordinate;
} else {
Position position = toPosition(coordinate.getX(), coordinate.getY(), coordinate.getSrsId(), toSrsId);
DirectPosition directPosition = position.getDirectPosition();
return new Coordinate(directPosition.getOrdinate(0), directPosition.getOrdinate(1), toSrsId);
}
}
Aggregations