Search in sources :

Example 16 with Angle

use of javax.measure.quantity.Angle in project sis by apache.

the class CRSBuilder method verify.

/**
 * Verifies if the user-defined CRS created from GeoTIFF values
 * matches the given CRS created from the EPSG geodetic dataset.
 * This method does not verify the EPSG code of the given CRS.
 *
 * @param  crs  the CRS created from the EPSG geodetic dataset.
 */
private void verify(final ProjectedCRS crs) throws FactoryException {
    final Unit<Length> linearUnit = createUnit(GeoKeys.LinearUnits, GeoKeys.LinearUnitSize, Length.class, Units.METRE);
    final Unit<Angle> angularUnit = createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize, Angle.class, Units.DEGREE);
    final GeographicCRS baseCRS = crs.getBaseCRS();
    verifyIdentifier(crs, baseCRS, GeoKeys.GeographicType);
    verify(baseCRS, angularUnit);
    final Conversion projection = crs.getConversionFromBase();
    verifyIdentifier(crs, projection, GeoKeys.Projection);
    verify(projection, angularUnit, linearUnit);
}
Also used : Angle(javax.measure.quantity.Angle) Length(javax.measure.quantity.Length) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) Conversion(org.opengis.referencing.operation.Conversion)

Example 17 with Angle

use of javax.measure.quantity.Angle in project sis by apache.

the class CRSBuilder method verify.

/**
 * Verifies if the user-defined CRS created from GeoTIFF values
 * matches the given CRS created from the EPSG geodetic dataset.
 * This method does not verify the EPSG code of the given CRS.
 *
 * @param  crs  the CRS created from the EPSG geodetic dataset.
 */
private void verify(final GeocentricCRS crs) throws FactoryException {
    /*
         * Note: current createUnit(…) implementation does not allow us to distinguish whether METRE ou DEGREE units
         * were specified in the GeoTIFF file or if we got the default values. We do not compare units of that reason.
         */
    final Unit<Length> linearUnit = createUnit(GeoKeys.GeogLinearUnits, GeoKeys.GeogLinearUnitSize, Length.class, Units.METRE);
    final Unit<Angle> angularUnit = createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize, Angle.class, Units.DEGREE);
    final GeodeticDatum datum = crs.getDatum();
    verifyIdentifier(crs, datum, GeoKeys.GeodeticDatum);
    verify(datum, angularUnit, linearUnit);
}
Also used : Angle(javax.measure.quantity.Angle) Length(javax.measure.quantity.Length) GeodeticDatum(org.opengis.referencing.datum.GeodeticDatum)

Example 18 with Angle

use of javax.measure.quantity.Angle in project com.revolsys.open by revolsys.

the class GeographicCoordinateSystem method getLengthUnit.

@Override
public Unit<Length> getLengthUnit() {
    final Unit<Angle> unit = this.angularUnit.getUnit();
    final UnitConverter radianConverter = unit.getConverterTo(Units.RADIAN);
    final Ellipsoid ellipsoid = this.geodeticDatum.getEllipsoid();
    final double radius = ellipsoid.getSemiMajorAxis();
    final double radianFactor = radianConverter.convert(1);
    return Units.METRE.multiply(radius).multiply(radianFactor);
}
Also used : Angle(javax.measure.quantity.Angle) UnitConverter(javax.measure.UnitConverter)

Example 19 with Angle

use of javax.measure.quantity.Angle 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)

Aggregations

Angle (javax.measure.quantity.Angle)19 Length (javax.measure.quantity.Length)7 Path (java.nio.file.Path)3 Unit (javax.measure.Unit)3 Convention (org.apache.sis.io.wkt.Convention)3 CartesianCS (org.opengis.referencing.cs.CartesianCS)3 GeodeticDatum (org.opengis.referencing.datum.GeodeticDatum)3 FactoryException (org.opengis.util.FactoryException)3 BufferedReader (java.io.BufferedReader)2 BigDecimal (java.math.BigDecimal)2 Matrix3 (org.apache.sis.referencing.operation.matrix.Matrix3)2 Test (org.junit.Test)2 Envelope (org.opengis.geometry.Envelope)2 Identifier (org.opengis.metadata.Identifier)2 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)2 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)2 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)2 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)2 NoninvertibleTransformException (org.opengis.referencing.operation.NoninvertibleTransformException)2 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)1