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;
}
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;
}
}
}
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);
}
}
}
}
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());
}
}
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());
}
}
Aggregations