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);
}
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);
}
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);
}
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);
}
Aggregations