Search in sources :

Example 16 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class LinearRing method getPolygonArea.

default double getPolygonArea(final Unit<Area> unit) {
    double area = 0;
    final CoordinateSystem coordinateSystem = getCoordinateSystem();
    if (coordinateSystem instanceof GeographicCoordinateSystem) {
        // TODO better algorithm than converting to world mercator
        final GeometryFactory geometryFactory = GeometryFactory.worldMercator();
        final LinearRing ring = as2d(geometryFactory);
        return ring.getPolygonArea(unit);
    } else if (coordinateSystem instanceof ProjectedCoordinateSystem) {
        final ProjectedCoordinateSystem projectedCoordinateSystem = (ProjectedCoordinateSystem) coordinateSystem;
        final Unit<Length> lengthUnit = projectedCoordinateSystem.getLengthUnit();
        @SuppressWarnings("unchecked") final Unit<Area> areaUnit = (Unit<Area>) lengthUnit.multiply(lengthUnit);
        area = getPolygonArea();
        final Quantity<Area> areaMeasure = Quantities.getQuantity(area, areaUnit);
        area = QuantityType.doubleValue(areaMeasure, unit);
    } else {
        area = getPolygonArea();
    }
    return area;
}
Also used : Area(javax.measure.quantity.Area) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) Quantity(javax.measure.Quantity) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) PreparedLinearRing(com.revolsys.geometry.model.prep.PreparedLinearRing) Unit(javax.measure.Unit)

Example 17 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class GeometryFactory method hasSameCoordinateSystem.

public boolean hasSameCoordinateSystem(final GeometryFactory geometryFactory) {
    if (geometryFactory == null) {
        return false;
    } else {
        final int coordinateSystemId1 = getCoordinateSystemId();
        final int coordinateSystemId2 = geometryFactory.getCoordinateSystemId();
        if (coordinateSystemId1 == coordinateSystemId2) {
            if (coordinateSystemId1 >= 0) {
                return true;
            }
        }
        final CoordinateSystem coordinateSystem1 = getCoordinateSystem();
        final CoordinateSystem coordinateSystem2 = geometryFactory.getCoordinateSystem();
        if (coordinateSystem1 == coordinateSystem2) {
            return true;
        } else if (coordinateSystem1 == null || coordinateSystem2 == null) {
            return false;
        } else if (coordinateSystem1.equals(coordinateSystem2)) {
            return true;
        } else {
            return false;
        }
    }
}
Also used : ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) AbstractPoint(com.revolsys.geometry.model.impl.AbstractPoint)

Example 18 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class GeometryFactory method isSameCoordinateSystem.

@Override
public boolean isSameCoordinateSystem(final GeometryFactory geometryFactory) {
    if (geometryFactory == null) {
        return false;
    } else {
        final int coordinateSystemId = getCoordinateSystemId();
        final int coordinateSystemId2 = geometryFactory.getCoordinateSystemId();
        if (coordinateSystemId == coordinateSystemId2) {
            return true;
        } else {
            final CoordinateSystem coordinateSystem = getCoordinateSystem();
            final CoordinateSystem coordinateSystem2 = geometryFactory.getCoordinateSystem();
            if (coordinateSystem == null) {
                if (coordinateSystemId <= 0) {
                    return true;
                } else if (coordinateSystem2 == null && coordinateSystemId2 <= 0) {
                    return true;
                } else {
                    return false;
                }
            } else if (coordinateSystem2 == null) {
                if (coordinateSystemId2 <= 0) {
                    return true;
                } else if (coordinateSystemId <= 0) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return coordinateSystem.equals(coordinateSystem2);
            }
        }
    }
}
Also used : ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) AbstractPoint(com.revolsys.geometry.model.impl.AbstractPoint)

Example 19 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class BoundingBox method getWidthLength.

default Quantity<Length> getWidthLength() {
    final double width = getWidth();
    final CoordinateSystem coordinateSystem = getCoordinateSystem();
    if (coordinateSystem == null) {
        return Quantities.getQuantity(width, Units.METRE);
    } else {
        return Quantities.getQuantity(width, coordinateSystem.getLengthUnit());
    }
}
Also used : CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

Example 20 with CoordinateSystem

use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.

the class BoundingBox method getHeightLength.

default Quantity<Length> getHeightLength() {
    final double height = getHeight();
    final CoordinateSystem coordinateSystem = getCoordinateSystem();
    if (coordinateSystem == null) {
        return Quantities.getQuantity(height, Units.METRE);
    } else {
        return Quantities.getQuantity(height, coordinateSystem.getLengthUnit());
    }
}
Also used : CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

Aggregations

CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)51 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)28 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)25 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 BoundingBox (com.revolsys.geometry.model.BoundingBox)11 Point (com.revolsys.geometry.model.Point)8 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)7 EngineeringCoordinateSystem (com.revolsys.geometry.cs.EngineeringCoordinateSystem)7 GeocentricCoordinateSystem (com.revolsys.geometry.cs.GeocentricCoordinateSystem)7 VerticalCoordinateSystem (com.revolsys.geometry.cs.VerticalCoordinateSystem)7 ArrayList (java.util.ArrayList)6 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)5 Map (java.util.Map)5 DataType (com.revolsys.datatype.DataType)4 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)4 Record (com.revolsys.record.Record)4 FieldDefinition (com.revolsys.record.schema.FieldDefinition)4 PrintWriter (java.io.PrintWriter)4 IntHashMap (com.revolsys.collection.map.IntHashMap)3 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)3