Examples of AxisDirection


Examples of org.opengis.referencing.cs.AxisDirection

     * Compares two axis for an order that try to favor right-handed coordinate systems.
     * Compass directions like North and East are first. Vertical directions like Up or Down are next.
     */
    @Override
    public int compareTo(final Normalizer that) {
        final AxisDirection d1 = this.axis.getDirection();
        final AxisDirection d2 = that.axis.getDirection();
        final int compass = AxisDirections.angleForCompass(d2, d1);
        if (compass != Integer.MIN_VALUE) {
            return compass;
        }
        if (meridian != null) {
            if (that.meridian != null) {
                return meridian.compareTo(that.meridian);
            }
            return -1;
        } else if (that.meridian != null) {
            return +1;
        }
        return d1.ordinal() - d2.ordinal();
    }
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

    static CoordinateSystemAxis normalize(final CoordinateSystemAxis axis) {
        /*
         * Normalize the axis direction. For now we do not touch to inter-cardinal directions (e.g. "North-East")
         * because it is not clear which normalization policy would match common usage.
         */
        final AxisDirection direction = axis.getDirection();
        AxisDirection newDir = direction;
        if (!AxisDirections.isIntercardinal(direction)) {
            newDir = AxisDirections.absolute(direction);
        }
        final boolean sameDirection = newDir.equals(direction);
        /*
         * Normalize unit of measurement.
         */
        final Unit<?> unit = axis.getUnit(), newUnit;
        if (Units.isLinear(unit)) {
            newUnit = SI.METRE;
        } else if (Units.isAngular(unit)) {
            newUnit = NonSI.DEGREE_ANGLE;
        } else if (Units.isTemporal(unit)) {
            newUnit = NonSI.DAY;
        } else {
            newUnit = unit;
        }
        /*
         * Reuse some properties (name, remarks, etc.) from the existing axis. If the direction changed,
         * then the axis name may need change too (e.g. "Westing" → "Easting"). The new axis name may be
         * set to "Unnamed", but the caller will hopefully be able to replace the returned instance by
         * an instance from the EPSG database with appropriate name.
         */
        if (sameDirection && newUnit.equals(unit)) {
            return axis;
        }
        final String abbreviation = axis.getAbbreviation();
        String newAbbr = abbreviation;
        if (!sameDirection) {
            if (AxisDirections.isCompass(direction)) {
                if (CharSequences.isAcronymForWords(abbreviation, direction.name())) {
                    if (newDir.equals(AxisDirection.EAST)) {
                        newAbbr = "E";
                    } else if (newDir.equals(AxisDirection.NORTH)) {
                        newAbbr = "N";
                    }
                }
            } else if (newDir.equals(AxisDirection.UP)) {
                newAbbr = "z";
            } else if (newDir.equals(AxisDirection.FUTURE)) {
                newAbbr = "t";
            }
        }
        final Map<String,Object> properties = new HashMap<String,Object>();
        if (newAbbr.equals(abbreviation)) {
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

         * (NORTH,EAST) to (EAST,NORTH)), then ordinates at index {@code srcIndex} will have
         * to be moved at index {@code dstIndex}.
         */
        for (int dstIndex = 0; dstIndex < dstAxes.length; dstIndex++) {
            boolean hasFound = false;
            final AxisDirection dstDir = dstAxes[dstIndex];
            final AxisDirection search = AxisDirections.absolute(dstDir);
            for (int srcIndex = 0; srcIndex < srcAxes.length; srcIndex++) {
                final AxisDirection srcDir = srcAxes[srcIndex];
                if (search.equals(AxisDirections.absolute(srcDir))) {
                    if (hasFound) {
                        throw new IllegalArgumentException(Errors.format(
                                Errors.Keys.ColinearAxisDirections_2, srcDir, dstDir));
                    }
                    hasFound = true;
                    /*
                     * Set the matrix elements. Some matrix elements will never be set.
                     * They will be left to zero, which is their desired value.
                     */
                    final boolean same = srcDir.equals(dstDir);
                    double scale = same ? +1 : -1;
                    double translate = 0;
                    if (useEnvelopes) {
                        // See the comment in transform(Envelope, Envelope) for an explanation about why
                        // we use the lower/upper corners instead than getMinimum()/getMaximum() methods.
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

     * Creates an axis for the specified direction.
     *
     * @param direction The name of an {@link AxisDirection} value.
     */
    private static DefaultCoordinateSystemAxis createAxis(final String direction) {
        final AxisDirection c = CoordinateSystems.parseAxisDirection(direction);
        if (c.equals(AxisDirection.NORTH)) return HardCodedAxes.NORTHING;
        if (c.equals(AxisDirection.EAST))  return HardCodedAxes.EASTING;
        if (c.equals(AxisDirection.SOUTH)) return HardCodedAxes.SOUTHING;
        if (c.equals(AxisDirection.WEST))  return HardCodedAxes.WESTING;
        return new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, c.name()), "?", c, SI.METRE);
    }
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

     * This method tests also the angle by interchanging the axis directions.
     */
    private static void assertAngleEquals(final boolean isElevation, final double expected,
            final String source, final String target)
    {
        final AxisDirection dir1 = parseAxisDirection(source);
        final AxisDirection dir2 = parseAxisDirection(target);
        assertNotNull(source, dir1);
        assertNotNull(target, dir2);
        assertAngleEquals(isElevation, expected, dir1, dir2);
    }
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

        // probably the upward axis.
        //

        for (int i = 0; i < numDimensions; i++) {
            CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(i);
            AxisDirection axisDirection = axis.getDirection();

            if (axisDirection.equals(AxisDirection.DISPLAY_UP)
                    || axisDirection.equals(AxisDirection.EAST_NORTH_EAST)
                    || axisDirection.equals(AxisDirection.NORTH)
                    || axisDirection.equals(AxisDirection.NORTH_EAST)
                    || axisDirection.equals(AxisDirection.NORTH_NORTH_EAST)
                    || axisDirection.equals(AxisDirection.NORTH_NORTH_WEST)
                    || axisDirection.equals(AxisDirection.NORTH_WEST)
                    || axisDirection.equals(AxisDirection.ROW_POSITIVE)
                    || axisDirection.equals(AxisDirection.UP)
                    || axisDirection.equals(AxisDirection.WEST_NORTH_WEST)) {
                return i;
            }
        }

        //
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

        assertEquals(compass.length, COMPASS_DIRECTION_COUNT);
        final int base = AxisDirection.NORTH.ordinal();
        final int h = compass.length / 2;
        for (int i=0; i<compass.length; i++) {
            final String index = "compass[" + i +']';
            final AxisDirection c = compass[i];
            double angle = i * (360.0/compass.length);
            if (angle > 180) {
                angle -= 360;
            }
            assertEquals(index, base + i, c.ordinal());
            assertEquals(index, base + i + (i<h ? h : -h), c.opposite().ordinal());
            assertEquals(index, 0, getAngle(c, c), EPS);
            assertEquals(index, 180, Math.abs(getAngle(c, c.opposite())), EPS);
            assertEquals(index, angle, getAngle(c, AxisDirection.NORTH), EPS);
        }
    }
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

    /**
     * Compare the angle between the specified directions.
     */
    private static void compareAngle(final double expected, final String source, final String target) {
        final AxisDirection dir1 = getDirection(source);
        final AxisDirection dir2 = getDirection(target);
        assertNotNull(dir1);
        assertNotNull(dir2);
        assertEquals(expected, getAngle(dir1, dir2), EPS);
    }
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

        int dimension = cs.getDimension();
        int longitudeDim = -1;
        int latitudeDim = -1;

        for (int i = 0; i < dimension; i++) {
            AxisDirection dir = cs.getAxis(i).getDirection().absolute();

            if (dir.equals(AxisDirection.EAST)) {
                longitudeDim = i;
            }

            if (dir.equals(AxisDirection.NORTH)) {
                latitudeDim = i;
            }
        }

        if ((longitudeDim >= 0) && (latitudeDim >= 0)) {
View Full Code Here

Examples of org.opengis.referencing.cs.AxisDirection

        super(properties);
        ensureNonNull("axis", axis);
        this.axis = axis.clone();
        for (int i=0; i<axis.length; i++) {
            ensureNonNull("axis", axis, i);
            final AxisDirection direction = axis[i].getDirection();
            ensureNonNull("direction", direction);
            /*
             * Ensures that axis direction and units are compatible with the
             * coordinate system to be created. For example CartesianCS will
             * accepts only linear or dimensionless units.
             */
            if (!isCompatibleDirection(direction)) {
                // TOOD: localize name()
                throw new IllegalArgumentException(Errors.format(
                        ErrorKeys.ILLEGAL_AXIS_ORIENTATION_$2, direction.name(), getClass()));
            }
            final Unit<?> unit = axis[i].getUnit();
            ensureNonNull("unit", unit);
            if (!isCompatibleUnit(direction, unit)) {
                throw new IllegalArgumentException(Errors.format(
                            ErrorKeys.INCOMPATIBLE_UNIT_$1, unit));
            }
            /*
             * Ensures there is no axis along the same direction
             * (e.g. two North axis, or an East and a West axis).
             */
            final AxisDirection check = direction.absolute();
            if (!check.equals(AxisDirection.OTHER)) {
                for (int j=i; --j>=0;) {
                    if (check.equals(axis[j].getDirection().absolute())) {
                        // TODO: localize name()
                        final String nameI = axis[i].getDirection().name();
                        final String nameJ = axis[j].getDirection().name();
                        throw new IllegalArgumentException(Errors.format(
                                    ErrorKeys.COLINEAR_AXIS_$2, nameI, nameJ));
                    }
                }
            }
            /*
             * Checks for some inconsistency in naming and direction. For example if the axis
             * is named "Northing", then the direction must be North. Exceptions to this rule
             * are the directions along a meridian from a pole. For example a "Northing" axis
             * may have a "South along 180 deg" direction.
             */
            final String name = axis[i].getName().getCode();
            for (int j=0; j<DIRECTION_CHECKS.length; j++) {
                final DefaultCoordinateSystemAxis candidate = DIRECTION_CHECKS[j];
                if (candidate.nameMatches(name)) {
                    final AxisDirection expected = candidate.getDirection();
                    if (!direction.equals(expected)) {
                        DirectionAlongMeridian m = DirectionAlongMeridian.parse(direction);
                        /*
                         * Note: for the check below, maybe it would have be nice to use:
                         *
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.