use of com.revolsys.geometry.cs.GeographicCoordinateSystem in project com.revolsys.open by revolsys.
the class Viewport2D method toDisplayValue.
public double toDisplayValue(final Quantity<Length> value) {
double convertedValue;
final Unit<Length> unit = value.getUnit();
if (unit.equals(CustomUnits.PIXEL)) {
convertedValue = QuantityType.doubleValue(value, CustomUnits.PIXEL);
} 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);
}
final double modelUnitsPerViewUnit = getModelUnitsPerViewUnit();
convertedValue = convertedValue / modelUnitsPerViewUnit;
}
return convertedValue;
}
use of com.revolsys.geometry.cs.GeographicCoordinateSystem in project com.revolsys.open by revolsys.
the class MapRulerBorder method setRulerGeometryFactory.
public void setRulerGeometryFactory(final GeometryFactory rulerGeometryFactory) {
this.rulerGeometryFactory = rulerGeometryFactory;
if (rulerGeometryFactory == null) {
this.rulerGeometryFactory = this.viewport.getGeometryFactory();
} else {
this.rulerGeometryFactory = rulerGeometryFactory;
}
this.rulerCoordinateSystem = this.rulerGeometryFactory.getCoordinateSystem();
this.baseUnit = this.rulerCoordinateSystem.getUnit();
if (this.rulerCoordinateSystem instanceof GeographicCoordinateSystem) {
this.areaMinX = -180;
this.areaMaxX = 180;
this.areaMinY = -90;
this.areaMaxY = 90;
} else {
final BoundingBox areaBoundingBox = this.rulerCoordinateSystem.getAreaBoundingBox();
this.areaMinX = areaBoundingBox.getMinX();
this.areaMaxX = areaBoundingBox.getMaxX();
this.areaMinY = areaBoundingBox.getMinY();
this.areaMaxY = areaBoundingBox.getMaxY();
}
}
use of com.revolsys.geometry.cs.GeographicCoordinateSystem in project com.revolsys.open by revolsys.
the class MapRulerBorder method paintBorder.
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
final Graphics2D graphics = (Graphics2D) g;
graphics.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
final FontMetrics fontMetrics = graphics.getFontMetrics();
this.labelHeight = fontMetrics.getHeight();
paintBackground(graphics, x, y, width, height);
final BoundingBox boundingBox = this.viewport.getBoundingBox();
if (this.rulerCoordinateSystem instanceof GeographicCoordinateSystem) {
final Unit<Angle> displayUnit = NonSI.DEGREE_ANGLE;
paintRuler(graphics, boundingBox, displayUnit, METRIC_GEOGRAPHICS_STEPS, true, x, y, width, height);
} else if (this.rulerCoordinateSystem instanceof ProjectedCoordinateSystem) {
if (this.baseUnit.equals(USCustomary.FOOT)) {
final Unit<Length> displayUnit = USCustomary.FOOT;
paintRuler(graphics, boundingBox, displayUnit, IMPERIAL_FOOT_STEPS, true, x, y, width, height);
} else {
final Unit<Length> displayUnit = Units.METRE;
paintRuler(graphics, boundingBox, displayUnit, METRIC_PROJECTED_STEPS, true, x, y, width, height);
}
}
graphics.setColor(Color.BLACK);
graphics.drawRect(this.rulerSize - 1, this.rulerSize - 1, width - 2 * this.rulerSize + 1, height - 2 * this.rulerSize + 1);
}
use of com.revolsys.geometry.cs.GeographicCoordinateSystem in project com.revolsys.open by revolsys.
the class Project method setViewBoundingBoxDo.
protected boolean setViewBoundingBoxDo(BoundingBox viewBoundingBox) {
if (Property.isEmpty(viewBoundingBox)) {
return false;
} else {
// TODO really should be min scale
double minDimension;
if (viewBoundingBox.getCoordinateSystem() instanceof GeographicCoordinateSystem) {
minDimension = 0.000005;
} else {
minDimension = 0.5;
}
final double width = viewBoundingBox.getWidth();
if (width < minDimension) {
viewBoundingBox = viewBoundingBox.expand((minDimension - width) / 2, 0);
}
final double height = viewBoundingBox.getHeight();
if (height < minDimension) {
viewBoundingBox = viewBoundingBox.expand(0, (minDimension - height) / 2);
}
final BoundingBox oldBoundingBox = this.viewBoundingBox;
this.viewBoundingBox = viewBoundingBox;
return !viewBoundingBox.equals(oldBoundingBox);
}
}
use of com.revolsys.geometry.cs.GeographicCoordinateSystem in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method validateEsri.
private void validateEsri() {
EsriCoordinateSystems.getCoordinateSystem(0);
for (final CoordinateSystem coordinateSytstem : EpsgCoordinateSystems.getCoordinateSystems()) {
if (coordinateSytstem instanceof GeographicCoordinateSystem) {
final GeographicCoordinateSystem geoCs = (GeographicCoordinateSystem) coordinateSytstem;
final int id = coordinateSytstem.getCoordinateSystemId();
final GeographicCoordinateSystem esri = EsriCoordinateSystems.getCoordinateSystem(id);
if (esri != null && !geoCs.equalsExact(esri)) {
// System.out.println(id + coordinateSytstem.getCoordinateSystemName());
}
} else if (coordinateSytstem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projectedCs = (ProjectedCoordinateSystem) coordinateSytstem;
final int id = coordinateSytstem.getCoordinateSystemId();
final String wkt = new UrlResource("http://spatialreference.org/ref/epsg/" + id + "/esriwkt/").contentsAsString();
final ProjectedCoordinateSystem esri = GeometryFactory.floating2d(wkt).getCoordinateSystem();
final CoordinateOperationMethod coordinateOperationMethod = esri.getCoordinateOperationMethod();
if (esri != null && !projectedCs.equals(esri) && coordinateOperationMethod != null && Property.hasValue(coordinateOperationMethod.getName()) && !projectedCs.isDeprecated()) {
final Map<ParameterName, Object> p1 = projectedCs.getParameters();
final Map<ParameterName, Object> p2 = esri.getParameters();
final Set<ParameterName> n1 = p1.keySet();
final Set<ParameterName> n2 = p2.keySet();
if (!n1.equals(n2)) {
final TreeSet<ParameterName> nm1 = new TreeSet<>(n1);
nm1.removeAll(n2);
final TreeSet<ParameterName> nm2 = new TreeSet<>(n2);
nm2.removeAll(n1);
final String m = id + "\t" + coordinateSytstem.getCoordinateSystemName() + "\t" + nm1 + "\t" + nm2;
// System.out.println(m);
}
}
}
}
}
Aggregations