use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class MapPointerLocation method setGeometryFactory.
public void setGeometryFactory(GeometryFactory geometryFactory) {
if (this.geographics && geometryFactory.isGeographics()) {
setVisible(false);
} else {
setVisible(true);
}
geometryFactory = geometryFactory.convertAxisCount(2);
if (geometryFactory.isGeographics()) {
geometryFactory = geometryFactory.convertScales(10000000.0, 10000000.0);
} else if (this.geographics) {
geometryFactory = geometryFactory.getGeographicGeometryFactory();
geometryFactory = geometryFactory.convertScales(10000000.0, 10000000.0);
} else {
geometryFactory = geometryFactory.convertScales(1000.0, 1000.0);
}
if (geometryFactory != this.geometryFactory) {
final int srid = geometryFactory.getCoordinateSystemId();
this.geometryFactory = geometryFactory;
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
this.setToolTipText(coordinateSystem.getCoordinateSystemName());
this.title = String.valueOf(srid);
final Point mapLocation = geometryFactory.point(this.mapLocation);
setMapLocation(mapLocation);
}
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class GeoNamesBoundingBoxLayerWorker method handleBackground.
@Override
protected List<LayerRecord> handleBackground() {
BoundingBox boundingBox = this.boundingBox;
GeometryFactory geometryFactory = this.geometryFactory;
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projCs = (ProjectedCoordinateSystem) coordinateSystem;
final GeographicCoordinateSystem geoCs = projCs.getGeographicCoordinateSystem();
geometryFactory = geoCs.getGeometryFactory();
boundingBox = boundingBox.convert(geometryFactory);
}
final List<LayerRecord> results = (List) this.geoNamesService.getNames(boundingBox);
for (final Record record : results) {
final String name = record.getValue("name");
final Point point = record.getGeometry();
final String text = "<html><b>" + name + "</b><br /></html>";
// if (viewport instanceof ComponentViewport2D) {
// final ComponentViewport2D componentViewport =
// (ComponentViewport2D)viewport;
// componentViewport.addHotSpot(geometryFactory, point, text, null);
// }
}
return results;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class Viewport2D method toModelValue.
public double toModelValue(final Quantity<Length> value) {
double convertedValue;
final Unit<Length> unit = value.getUnit();
if (unit.equals(CustomUnits.PIXEL)) {
convertedValue = QuantityType.doubleValue(value, CustomUnits.PIXEL);
final double modelUnitsPerViewUnit = getModelUnitsPerViewUnit();
convertedValue *= modelUnitsPerViewUnit;
} else {
convertedValue = QuantityType.doubleValue(value, Units.METRE);
final CoordinateSystem coordinateSystem = this.geometryFactory2d.getCoordinateSystem();
if (coordinateSystem instanceof GeographicCoordinateSystem) {
final GeographicCoordinateSystem geoCs = (GeographicCoordinateSystem) coordinateSystem;
final double radius = geoCs.getDatum().getEllipsoid().getSemiMajorAxis();
convertedValue = Math.toDegrees(convertedValue / radius);
}
}
return convertedValue;
}
use of com.revolsys.geometry.cs.CoordinateSystem 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.CoordinateSystem in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method loadCoordinateReferenceSystem.
private static void loadCoordinateReferenceSystem(final IntHashMap<List<Axis>> axisMap) {
try (ChannelReader reader = newChannelReader("coordinateReferenceSystem")) {
while (true) {
final int id = reader.getInt();
final String name = reader.getStringUtf8ByteCount();
final Area area = readCode(reader, AREA_BY_ID);
final int type = reader.getByte();
final CoordinateSystemType coordinateSystemType = readCode(reader, COORDINATE_SYSTEM_TYPE_BY_ID);
final Datum datum = readCode(reader, DATUM_BY_ID);
final CoordinateSystem sourceCoordinateSystem = readCode(reader, COORDINATE_SYSTEM_BY_ID);
final CoordinateOperation operation = readCode(reader, OPERATION_BY_ID);
final CoordinateSystem horizontalCoordinateSystem = readCode(reader, COORDINATE_SYSTEM_BY_ID);
final VerticalCoordinateSystem verticalCoordinateSystem = (VerticalCoordinateSystem) readCode(reader, COORDINATE_SYSTEM_BY_ID);
final boolean deprecated = readBoolean(reader);
final List<Axis> axis;
if (coordinateSystemType == null) {
axis = null;
} else {
axis = axisMap.get(coordinateSystemType.getId());
}
CoordinateSystem coordinateSystem = null;
if (type == 0) {
// geocentric
coordinateSystem = newCoordinateSystemGeocentric(id, name, datum, axis, area, deprecated);
} else if (type == 1) {
// geographic 3D
coordinateSystem = new GeographicCoordinateSystem(id, name, (GeodeticDatum) datum, axis, area, sourceCoordinateSystem, operation, deprecated);
} else if (type == 2) {
// geographic 2D
coordinateSystem = new GeographicCoordinateSystem(id, name, (GeodeticDatum) datum, axis, area, sourceCoordinateSystem, operation, deprecated);
} else if (type == 3) {
// projected
coordinateSystem = newCoordinateSystemProjected(id, name, area, sourceCoordinateSystem, operation, axis, deprecated);
} else if (type == 4) {
// engineering
coordinateSystem = new EngineeringCoordinateSystem(id, name, (EngineeringDatum) datum, axis, area, deprecated);
} else if (type == 5) {
// vertical
coordinateSystem = new VerticalCoordinateSystem(id, name, (VerticalDatum) datum, axis, area, deprecated);
} else if (type == 6) {
coordinateSystem = new CompoundCoordinateSystem(id, name, horizontalCoordinateSystem, verticalCoordinateSystem, area, deprecated);
} else {
coordinateSystem = null;
}
addCoordinateSystem(coordinateSystem);
}
} catch (final NoSuchResourceException e) {
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
} else {
throw e;
}
}
}
Aggregations