Package org.apache.sis.measure

Examples of org.apache.sis.measure.Angle


     * Tests conversions to {@link Angle}.
     */
    @Test
    public void testAngle() {
        final ObjectConverter<String,Angle> c = new StringConverter.Angle();
        runInvertibleConversion(c, "42°30′00″", new Angle(42.5));
        tryUnconvertibleValue(c);
        assertSerializedEquals(c);
    }
View Full Code Here


            return bijective();
        }

        /** Converts the given angle. */
        @Override public Angle apply(final Double object) {
            return new Angle(object);
        }
View Full Code Here

        super(true);
        this.westBoundLongitude = westBoundLongitude;
        this.eastBoundLongitude = eastBoundLongitude;
        this.southBoundLatitude = southBoundLatitude;
        this.northBoundLatitude = northBoundLatitude;
        final Angle min, max;
        if (westBoundLongitude > eastBoundLongitude) {
            min = new Longitude(westBoundLongitude);
            max = new Longitude(eastBoundLongitude);
        } else if (southBoundLatitude > northBoundLatitude) {
            min = new Latitude(southBoundLatitude);
View Full Code Here

                          final double southBoundLatitude,
                          final double northBoundLatitude)
            throws IllegalArgumentException
    {
        checkWritePermission();
        final Angle min, max;
        if (westBoundLongitude > eastBoundLongitude) {
            min = new Longitude(westBoundLongitude);
            max = new Longitude(eastBoundLongitude);
            // Exception will be thrown below.
        } else if (southBoundLatitude > northBoundLatitude) {
View Full Code Here

         * Check for NORTH, SOUTH, EAST, EAST-NORTH-EAST, etc.
         * Checked first because this is the most common case.
         */
        int c = AxisDirections.angleForCompass(source, target);
        if (c != Integer.MIN_VALUE) {
            return new Angle(c * (360.0 / AxisDirections.COMPASS_COUNT));
        }
        /*
         * Check for GEOCENTRIC_X, GEOCENTRIC_Y, GEOCENTRIC_Z.
         */
        c = AxisDirections.angleForGeocentric(source, target);
        if (c != Integer.MIN_VALUE) {
            return new Angle(c * 90);
        }
        /*
         * Check for DISPLAY_UP, DISPLAY_DOWN, etc. assuming a flat screen.
         * Note that we do not check for grid directions (COLUMN_POSITIVE,
         * ROW_POSITIVE, etc.) because the grid geometry may be anything.
         */
        c = AxisDirections.angleForDisplay(source, target);
        if (c != Integer.MIN_VALUE) {
            return new Angle(c * (360 / AxisDirections.DISPLAY_COUNT));
        }
        /*
         * Check for "South along 90° East", etc. directions. Note that this
         * check may perform a relatively costly parsing of axis direction name.
         * (NOTE: the check for 'isUserDefined' is performed outside DirectionAlongMeridian for
         * avoiding class initialization of the later in the common case where we do not need it).
         */
        final DirectionAlongMeridian srcMeridian, tgtMeridian;
        srcMeridian = AxisDirections.isUserDefined(source) ? DirectionAlongMeridian.parse(source) : null;
        tgtMeridian = AxisDirections.isUserDefined(target) ? DirectionAlongMeridian.parse(target) : null;
        if (srcMeridian != null && tgtMeridian != null) {
            return new Angle(srcMeridian.angle(tgtMeridian));
        }
        /*
         * Check for UP and DOWN, with special case if one of the direction is horizontal
         * (either a compass direction of a direction along a meridian).
         */
        final boolean srcVrt = AxisDirections.isVertical(source);
        final boolean tgtVrt = AxisDirections.isVertical(target);
        if (tgtVrt) {
            if (srcVrt) {
                return new Angle(source.equals(target) ? 0 : target.equals(AxisDirection.UP) ? 180 : -180);
            } else if (AxisDirections.isCompass(source) || srcMeridian != null) {
                return target.equals(AxisDirection.UP) ? ElevationAngle.ZENITH : ElevationAngle.NADIR;
            }
        } else if (srcVrt) {
            if (AxisDirections.isCompass(target) || tgtMeridian != null) {
View Full Code Here

     */
    @Test
    public void testDouble() {
        final ObjectConverter<Angle,Double> c1 = AngleConverter.INSTANCE;
        final ObjectConverter<Double,Angle> c2 = AngleConverter.Inverse.INSTANCE;
        final Angle  v1 = new Angle (30.25);
        final Double v2 = new Double(30.25);
        assertEquals(v2, c1.apply(v1));
        assertEquals(v1, c2.apply(v2));
        assertSame(c2, c1.inverse());
        assertSame(c1, c2.inverse());
View Full Code Here

     * Tests conversions to {@link Angle}.
     */
    @Test
    public void testAngle() {
        final ObjectConverter<String,Angle> c = new StringConverter.Angle();
        runInvertibleConversion(c, "42°30′",       new Angle(42.5));
        runInvertibleConversion(c, "42°30′56.25″", new Angle(42.515625));
        tryUnconvertibleValue(c);
        assertSerializedEquals(c);
    }
View Full Code Here

        final int dimension = getDimension();
        for (int i=0; i<dimension; i++) {
            final AxisDirection axis0 = getAxis(i).getDirection();
            for (int j=i; ++j<dimension;) {
                final AxisDirection axis1 = getAxis(j).getDirection();
                final Angle angle = CoordinateSystems.angle(axis0, axis1);
                /*
                 * The angle may be null for grid directions (COLUMN_POSITIVE, COLUMN_NEGATIVE,
                 * ROW_POSITIVE, ROW_NEGATIVE). We conservatively accept those directions even if
                 * they are not really for Cartesian CS because we do not know the grid geometry.
                 */
                if (angle != null && Math.abs(angle.degrees()) != 90) {
                    throw new IllegalArgumentException(Errors.format(
                            Errors.Keys.NonPerpendicularDirections_2, axis0, axis1));
                }
            }
        }
View Full Code Here

            return bijective();
        }

        /** Converts the given angle. */
        @Override public Angle apply(final Double object) {
            return new Angle(object);
        }
View Full Code Here

     * This method tests also the angle by interchanging the given directions.
     */
    private static void assertAngleEquals(final boolean isElevation, final double expected,
            final AxisDirection source, final AxisDirection target)
    {
        final Angle forward = angle(source, target);
        final Angle inverse = angle(target, source);
        assertEquals(isElevation, forward instanceof ElevationAngle);
        assertEquals(isElevation, inverse instanceof ElevationAngle);
        assertEquals(+expected, (forward != null) ? forward.degrees() : Double.NaN, STRICT);
        assertEquals(-expected, (inverse != null) ? inverse.degrees() : Double.NaN, STRICT);
    }
View Full Code Here

TOP

Related Classes of org.apache.sis.measure.Angle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.