Search in sources :

Example 1 with Position

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;
    }
}
Also used : Position(org.opengis.geometry.coordinate.Position) DirectPosition(org.opengis.geometry.DirectPosition) InternationalString(org.opengis.util.InternationalString) FactoryException(org.opengis.referencing.FactoryException) CoordinateOperationException(org.openforis.idm.geospatial.CoordinateOperationException) TransformException(org.opengis.referencing.operation.TransformException) GeodeticCalculator(org.geotools.referencing.GeodeticCalculator)

Example 2 with Position

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);
}
Also used : Position(org.opengis.geometry.coordinate.Position) DirectPosition(org.opengis.geometry.DirectPosition)

Example 3 with Position

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);
    }
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) Position(org.opengis.geometry.coordinate.Position) DirectPosition(org.opengis.geometry.DirectPosition) Coordinate(org.openforis.idm.model.Coordinate)

Aggregations

DirectPosition (org.opengis.geometry.DirectPosition)3 Position (org.opengis.geometry.coordinate.Position)3 GeodeticCalculator (org.geotools.referencing.GeodeticCalculator)1 CoordinateOperationException (org.openforis.idm.geospatial.CoordinateOperationException)1 Coordinate (org.openforis.idm.model.Coordinate)1 FactoryException (org.opengis.referencing.FactoryException)1 TransformException (org.opengis.referencing.operation.TransformException)1 InternationalString (org.opengis.util.InternationalString)1