use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method getGeographicCoordinateSystems.
public static List<GeographicCoordinateSystem> getGeographicCoordinateSystems() {
final List<GeographicCoordinateSystem> coordinateSystems = new ArrayList<>();
for (final CoordinateSystem coordinateSystem : coordinateSystemsByName.values()) {
if (coordinateSystem instanceof GeographicCoordinateSystem) {
final GeographicCoordinateSystem geographicCoordinateSystem = (GeographicCoordinateSystem) coordinateSystem;
coordinateSystems.add(geographicCoordinateSystem);
}
}
return coordinateSystems;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method addCoordinateSystem.
private static void addCoordinateSystem(final CoordinateSystem coordinateSystem) {
if (coordinateSystem != null) {
final Integer id = coordinateSystem.getCoordinateSystemId();
final String name = coordinateSystem.getCoordinateSystemName();
COORDINATE_SYSTEM_BY_ID.put(id, coordinateSystem);
coordinateSystemsById.put(id, coordinateSystem);
final int hashCode = coordinateSystem.hashCode();
List<CoordinateSystem> coordinateSystems = coordinateSystemsByCoordinateSystem.get(hashCode);
if (coordinateSystems == null) {
coordinateSystems = new ArrayList<>();
coordinateSystemsByCoordinateSystem.put(hashCode, coordinateSystems);
}
coordinateSystems.add(coordinateSystem);
coordinateSystemsByName.put(name, coordinateSystem);
}
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method getCodes.
@Override
public Map<Identifier, List<Object>> getCodes() {
if (this.codes == null) {
final Map<Identifier, List<Object>> codesById = new HashMap<>();
for (final CoordinateSystem coordinateSystem : coordinateSystems) {
final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
final Identifier id = Identifier.newIdentifier(coordinateSystemId);
final List<Object> code = Collections.singletonList(coordinateSystem);
codesById.put(id, code);
}
this.codes = codesById;
}
return this.codes;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method getIdentifiers.
@Override
public List<Identifier> getIdentifiers() {
if (this.identifiers == null) {
final List<Identifier> identifiers = new ArrayList<>();
for (final CoordinateSystem coordinateSystem : coordinateSystems) {
final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
final Identifier id = Identifier.newIdentifier(coordinateSystemId);
identifiers.add(id);
}
this.identifiers = Collections.unmodifiableList(identifiers);
}
return this.identifiers;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class LineString method getLength.
@Override
default double getLength(final Unit<Length> unit) {
double length = 0;
final CoordinateSystem coordinateSystem = getCoordinateSystem();
if (coordinateSystem instanceof GeographicCoordinateSystem) {
final int vertexCount = getVertexCount();
if (vertexCount > 1) {
double lon0 = getX(0);
double lat0 = getY(0);
for (int i = 1; i < vertexCount; i++) {
final double lon1 = getX(i);
final double lat1 = getY(i);
length += GeographicCoordinateSystem.distanceMetres(lon0, lat0, lon1, lat1);
lon0 = lon1;
lat0 = lat1;
}
}
final Quantity<Length> lengthMeasure = Quantities.getQuantity(length, Units.METRE);
length = QuantityType.doubleValue(lengthMeasure, unit);
} else if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projectedCoordinateSystem = (ProjectedCoordinateSystem) coordinateSystem;
final Unit<Length> lengthUnit = projectedCoordinateSystem.getLengthUnit();
length = getLength();
final Quantity<Length> lengthMeasure = Quantities.getQuantity(length, lengthUnit);
length = QuantityType.doubleValue(lengthMeasure, unit);
} else {
length = getLength();
}
return length;
}
Aggregations