use of com.revolsys.geometry.cs.Authority in project com.revolsys.open by revolsys.
the class EsriCoordinateSystems method getVerticalCoordinateSystem.
public static VerticalCoordinateSystem getVerticalCoordinateSystem(final int id) {
VerticalCoordinateSystem coordinateSystem = (VerticalCoordinateSystem) COORDINATE_SYSTEM_BY_ID.get(id);
if (coordinateSystem == null) {
try (final ChannelReader reader = ChannelReader.newChannelReader("classpath:CoordinateSystems/esri/Vertical.cs")) {
while (true) {
final int coordinateSystemId = reader.getInt();
final String csName = reader.getStringUtf8ByteCount();
final String datumName = reader.getStringUtf8ByteCount();
final Map<ParameterName, ParameterValue> parameters = readParameters(reader);
final String linearUnitName = reader.getStringUtf8ByteCount();
final double conversionFactor = reader.getDouble();
if (id == coordinateSystemId) {
final VerticalDatum verticalDatum = new VerticalDatum(null, datumName, 0);
LinearUnit linearUnit = LINEAR_UNITS_BY_NAME.get(linearUnitName);
if (linearUnit == null) {
linearUnit = new LinearUnit(linearUnitName, conversionFactor, null);
LINEAR_UNITS_BY_NAME.put(linearUnitName, linearUnit);
}
final Authority authority = new BaseAuthority("ESRI", coordinateSystemId);
coordinateSystem = new VerticalCoordinateSystem(authority, csName, verticalDatum, parameters, linearUnit, Collections.emptyList());
COORDINATE_SYSTEM_BY_ID.put(id, coordinateSystem);
return coordinateSystem;
}
}
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
return null;
} else {
Logs.error("Cannot load coordinate system=" + id, e);
throw e;
}
}
}
return coordinateSystem;
}
use of com.revolsys.geometry.cs.Authority in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method getCoordinateSystem.
public static synchronized CoordinateSystem getCoordinateSystem(final CoordinateSystem coordinateSystem) {
initialize();
if (coordinateSystem == null) {
return null;
} else {
int srid = coordinateSystem.getCoordinateSystemId();
CoordinateSystem matchedCoordinateSystem = coordinateSystemsById.get(srid);
if (matchedCoordinateSystem == null) {
matchedCoordinateSystem = coordinateSystemsByName.get(coordinateSystem.getCoordinateSystemName());
if (matchedCoordinateSystem == null) {
final int hashCode = coordinateSystem.hashCode();
int matchCoordinateSystemId = 0;
final List<CoordinateSystem> coordinateSystems = coordinateSystemsByCoordinateSystem.get(hashCode);
if (coordinateSystems != null) {
for (final CoordinateSystem coordinateSystem3 : coordinateSystems) {
if (coordinateSystem3.equals(coordinateSystem)) {
final int srid3 = coordinateSystem3.getCoordinateSystemId();
if (matchedCoordinateSystem == null) {
matchedCoordinateSystem = coordinateSystem3;
matchCoordinateSystemId = srid3;
} else if (srid3 < matchCoordinateSystemId) {
if (!coordinateSystem3.isDeprecated() || matchedCoordinateSystem.isDeprecated()) {
matchedCoordinateSystem = coordinateSystem3;
matchCoordinateSystemId = srid3;
}
}
}
}
}
if (matchedCoordinateSystem == null) {
if (srid <= 0) {
srid = nextSrid++;
}
final String name = coordinateSystem.getCoordinateSystemName();
final List<Axis> axis = coordinateSystem.getAxis();
final Area area = coordinateSystem.getArea();
final Authority authority = coordinateSystem.getAuthority();
final boolean deprecated = coordinateSystem.isDeprecated();
if (coordinateSystem instanceof GeographicCoordinateSystem) {
final GeographicCoordinateSystem geographicCs = (GeographicCoordinateSystem) coordinateSystem;
final GeodeticDatum geodeticDatum = geographicCs.getDatum();
final PrimeMeridian primeMeridian = geographicCs.getPrimeMeridian();
final CoordinateSystem sourceCoordinateSystem = geographicCs.getSourceCoordinateSystem();
final CoordinateOperation coordinateOperation = geographicCs.getCoordinateOperation();
final GeographicCoordinateSystem newCs = new GeographicCoordinateSystem(srid, name, geodeticDatum, primeMeridian, axis, area, sourceCoordinateSystem, coordinateOperation, deprecated);
addCoordinateSystem(newCs);
return newCs;
} else if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projectedCs = (ProjectedCoordinateSystem) coordinateSystem;
GeographicCoordinateSystem geographicCs = projectedCs.getGeographicCoordinateSystem();
geographicCs = (GeographicCoordinateSystem) getCoordinateSystem(geographicCs);
final CoordinateOperationMethod coordinateOperationMethod = projectedCs.getCoordinateOperationMethod();
final Map<ParameterName, ParameterValue> parameters = projectedCs.getParameterValues();
final LinearUnit linearUnit = projectedCs.getLinearUnit();
final ProjectedCoordinateSystem newCs = new ProjectedCoordinateSystem(srid, name, geographicCs, area, coordinateOperationMethod, parameters, linearUnit, axis, authority, deprecated);
addCoordinateSystem(newCs);
return newCs;
}
return coordinateSystem;
}
}
}
return matchedCoordinateSystem;
}
}
use of com.revolsys.geometry.cs.Authority in project com.revolsys.open by revolsys.
the class EpsgCsWktWriter method write.
public static void write(final PrintWriter out, final AngularUnit unit) {
if (unit != null) {
out.print(",UNIT[");
write(out, unit.getName());
out.write(',');
out.print(unit.getConversionFactor());
final Authority authority = unit.getAuthority();
write(out, authority);
out.write(']');
}
}
use of com.revolsys.geometry.cs.Authority in project com.revolsys.open by revolsys.
the class EpsgCsWktWriter method write.
public static void write(final PrintWriter out, final LinearUnit unit) {
if (unit != null) {
out.print(",UNIT[");
write(out, unit.getName());
out.write(',');
write(out, unit.getConversionFactor());
final Authority authority = unit.getAuthority();
write(out, authority);
out.write(']');
}
}
use of com.revolsys.geometry.cs.Authority in project com.revolsys.open by revolsys.
the class EpsgCsWktWriter method write.
public static void write(final PrintWriter out, final ProjectedCoordinateSystem coordinateSystem) {
if (coordinateSystem != null) {
out.print("PROJCS[");
write(out, coordinateSystem.getCoordinateSystemName());
final GeographicCoordinateSystem geoCs = coordinateSystem.getGeographicCoordinateSystem();
out.print(",");
write(out, geoCs);
final CoordinateOperationMethod coordinateOperationMethod = coordinateSystem.getCoordinateOperationMethod();
write(out, coordinateOperationMethod);
for (final Entry<ParameterName, Object> parameter : coordinateSystem.getParameters().entrySet()) {
final ParameterName name = parameter.getKey();
final Object value = parameter.getValue();
write(out, name, value);
}
final LinearUnit unit = coordinateSystem.getLinearUnit();
if (unit != null) {
write(out, unit);
}
final Authority authority = coordinateSystem.getAuthority();
write(out, authority);
out.write(']');
}
}
Aggregations