Search in sources :

Example 21 with GeographicCoordinateSystem

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;
}
Also used : Length(javax.measure.quantity.Length) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

Example 22 with GeographicCoordinateSystem

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();
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

Example 23 with GeographicCoordinateSystem

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);
}
Also used : Angle(javax.measure.quantity.Angle) FontMetrics(java.awt.FontMetrics) BoundingBox(com.revolsys.geometry.model.BoundingBox) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) Unit(javax.measure.Unit) Font(java.awt.Font) Graphics2D(java.awt.Graphics2D)

Example 24 with GeographicCoordinateSystem

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);
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

Example 25 with GeographicCoordinateSystem

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);
                }
            }
        }
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) UrlResource(com.revolsys.spring.resource.UrlResource) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) TreeSet(java.util.TreeSet) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)28 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)19 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)13 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)9 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)8 Map (java.util.Map)7 ParameterName (com.revolsys.geometry.cs.ParameterName)5 BoundingBox (com.revolsys.geometry.model.BoundingBox)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)5 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 Authority (com.revolsys.geometry.cs.Authority)4 ParameterValue (com.revolsys.geometry.cs.ParameterValue)4 VerticalCoordinateSystem (com.revolsys.geometry.cs.VerticalCoordinateSystem)4 GeodeticDatum (com.revolsys.geometry.cs.datum.GeodeticDatum)4 IOException (java.io.IOException)4 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)3 EngineeringCoordinateSystem (com.revolsys.geometry.cs.EngineeringCoordinateSystem)3 GeocentricCoordinateSystem (com.revolsys.geometry.cs.GeocentricCoordinateSystem)3 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)3