Examples of DirectPosition


Examples of org.opengis.geometry.DirectPosition

        ensureNonNull("envelope", envelope);
        final int dimension = getDimension();
        ensureDimensionMatches("envelope", dimension, envelope);
        assert equalsIgnoreMetadata(getCoordinateReferenceSystem(),
                envelope.getCoordinateReferenceSystem(), true) : envelope;
        final DirectPosition lowerCorner = envelope.getLowerCorner();
        final DirectPosition upperCorner = envelope.getUpperCorner();
        for (int i=0; i<dimension; i++) {
            final double lower0 = getLower(i);
            final double upper0 = getUpper(i);
            final double lower1 = lowerCorner.getOrdinate(i);
            final double upper1 = upperCorner.getOrdinate(i);
            final boolean lowerCondition, upperCondition;
            if (edgesInclusive) {
                lowerCondition = (lower1 <= upper0);
                upperCondition = (upper1 >= lower0);
            } else {
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

        if (other.getDimension() != dimension || !equalsIgnoreMetadata(
                getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem(), false))
        {
            return false;
        }
        final DirectPosition lowerCorner = other.getLowerCorner();
        final DirectPosition upperCorner = other.getUpperCorner();
        for (int i=0; i<dimension; i++) {
            double ε = eps;
            if (epsIsRelative) {
                final double span = Math.max(getSpan(i), other.getSpan(i));
                if (span > 0 && span < Double.POSITIVE_INFINITY) {
                    ε *= span;
                }
            }
            if (!epsilonEqual(getLower(i), lowerCorner.getOrdinate(i), ε) ||
                !epsilonEqual(getUpper(i), upperCorner.getOrdinate(i), ε))
            {
                return false;
            }
        }
        return true;
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

            buffer.append(dimension).append('D');
        }
        if (dimension == 0) {
            buffer.append("()");
        } else {
            final DirectPosition lowerCorner = envelope.getLowerCorner();
            final DirectPosition upperCorner = envelope.getUpperCorner();
            boolean isUpper = false;
            do { // Executed exactly twice.
                for (int i=0; i<dimension; i++) {
                    buffer.append(i == 0 && !isUpper ? '(' : ' ');
                    final double ordinate = (isUpper ? upperCorner : lowerCorner).getOrdinate(i);
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

     */
    @Test
    public void testDecode() throws ParseException {
        final GeoHashCoder coder = new GeoHashCoder();
        for (final Place place : PLACES) {
            final DirectPosition result = coder.decode(place.geohash);
            assertEquals(place.name, place.longitude, result.getOrdinate(0), TOLERANCE);
            assertEquals(place.name, place.latitude,  result.getOrdinate(1), TOLERANCE);
        }
    }
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

     */
    private static MatrixSIS createTransform(final Envelope srcEnvelope, final AxisDirection[] srcAxes,
                                             final Envelope dstEnvelope, final AxisDirection[] dstAxes,
                                             final boolean useEnvelopes)
    {
        final DirectPosition dstCorner, srcCorner, srcOppositeCorner;
        if (useEnvelopes) {
            dstCorner         = dstEnvelope.getLowerCorner();
            srcCorner         = srcEnvelope.getLowerCorner();
            srcOppositeCorner = srcEnvelope.getUpperCorner();
        } else {
            dstCorner = srcCorner = srcOppositeCorner = null;
        }
        final MatrixSIS matrix = createZero(dstAxes.length+1, srcAxes.length+1);
        /*
         * Maps source axes to destination axes. If no axis is moved (for example if the user
         * want to transform (NORTH,EAST) to (SOUTH,EAST)), then source and destination index
         * will be equal.   If some axes are moved (for example if the user want to transform
         * (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.
                        translate  = dstCorner.getOrdinate(dstIndex);
                        scale     *= dstEnvelope.getSpan(dstIndex) /
                                     srcEnvelope.getSpan(srcIndex);
                        translate -= scale * (same ? srcCorner : srcOppositeCorner).getOrdinate(srcIndex);
                    }
                    matrix.setElement(dstIndex, srcIndex,       scale);
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

         * Following code is a simplified version of above createTransform(Envelope, AxisDirection[], ...) method.
         * We need to make sure that those two methods are consistent and compute the matrix values in the same way.
         */
        final int srcDim = srcEnvelope.getDimension();
        final int dstDim = dstEnvelope.getDimension();
        final DirectPosition srcCorner = srcEnvelope.getLowerCorner();
        final DirectPosition dstCorner = dstEnvelope.getLowerCorner();
        final MatrixSIS matrix = createZero(dstDim+1, srcDim+1);
        for (int i = Math.min(srcDim, dstDim); --i >= 0;) {
            /*
             * Note on envelope spanning over the anti-meridian: the GeoAPI javadoc does not mandate the
             * precise behavior of getSpan(int) in such situation.  In the particular case of Apache SIS
             * implementations, the envelope will compute the span correctly (taking in account the wrap
             * around behavior). For non-SIS implementations, we can not know.
             *
             * For the translation term, we really need the lower corner, NOT envelope.getMinimum(i),
             * because we need the starting point, which is not the minimal value when spanning over
             * the anti-meridian.
             */
            final double scale     = dstEnvelope.getSpan(i)   / srcEnvelope.getSpan(i);
            final double translate = dstCorner.getOrdinate(i) - srcCorner.getOrdinate(i)*scale;
            matrix.setElement(i, i,      scale);
            matrix.setElement(i, srcDim, translate);
        }
        matrix.setElement(dstDim, srcDim, 1);
        return matrix;
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

    @Test
    public void testEquals() {
        assertTrue(DirectPosition2D     .class.desiredAssertionStatus());
        assertTrue(GeneralDirectPosition.class.desiredAssertionStatus());

        DirectPosition p1 = new DirectPosition2D     (48.543261561072285, -123.47009555832284);
        DirectPosition p2 = new GeneralDirectPosition(48.543261561072285, -123.47009555832284);
        assertTrue(p1.equals(p2));
        assertTrue(p2.equals(p1));
        assertEquals(p2.hashCode(), p1.hashCode());

        p1.setOrdinate(0, p1.getOrdinate(0) + 1);
        assertFalse(p1.equals(p2));
        assertFalse(p2.equals(p1));
        assertFalse(p2.hashCode() == p1.hashCode());
    }
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

    @Test
    public void testEquals() {
        assertTrue(DirectPosition1D     .class.desiredAssertionStatus());
        assertTrue(GeneralDirectPosition.class.desiredAssertionStatus());

        DirectPosition p1 = new DirectPosition1D     (48.543261561072285);
        DirectPosition p2 = new GeneralDirectPosition(48.543261561072285);
        assertTrue(p1.equals(p2));
        assertTrue(p2.equals(p1));
        assertEquals(p2.hashCode(), p1.hashCode());

        p1.setOrdinate(0, p1.getOrdinate(0) + 1);
        assertFalse(p1.equals(p2));
        assertFalse(p2.equals(p1));
        assertFalse(p2.hashCode() == p1.hashCode());
    }
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

            xmax = +180;
        } else {
            xmin = xLower;
            xmax = xUpper;
        }
        final DirectPosition lower = test.getLowerCorner();
        final DirectPosition upper = test.getUpperCorner();
        assertEquals("lower", xLower, lower.getOrdinate(0), STRICT);
        assertEquals("upper", xUpper, upper.getOrdinate(0), STRICT);
        assertEquals("xmin",  xmin,   test .getMinimum (0), STRICT);
        assertEquals("xmax",  xmax,   test .getMaximum (0), STRICT);
        assertEquals("ymin",  ymin,   test .getMinimum (1), STRICT);
        assertEquals("ymax",  ymax,   test .getMaximum (1), STRICT);
        assertEquals("ymin",  ymin,   lower.getOrdinate(1), STRICT);
        assertEquals("ymax",  ymax,   upper.getOrdinate(1), STRICT);
        if (test instanceof Envelope2D) {
            final Envelope2D ri = (Envelope2D) test;
            assertEquals("xmin", xmin, ri.getMinX(), STRICT);
            assertEquals("xmax", xmax, ri.getMaxX(), STRICT);
            assertEquals("ymin", ymin, ri.getMinY(), STRICT);
View Full Code Here

Examples of org.opengis.geometry.DirectPosition

        final Envelope2D disjoint   = (Envelope2D) create(RECTANGLE, -2, 10, 35, 40);
        final Envelope2D spanning   = (Envelope2D) create(RECTANGLE, 16, -8, 35, 40);
        for (int type=0; type<LAST; type++) {
            final String label = "Type " + type;
            final Envelope envelope = create(type, 12, -4, 30, 50);
            final DirectPosition lower = envelope.getLowerCorner();
            final DirectPosition upper = envelope.getUpperCorner();
            assertEquals(label,   30, envelope.getMinimum (1), STRICT);
            assertEquals(label,   50, envelope.getMaximum (1), STRICT);
            assertEquals(label,   40, envelope.getMedian  (1), STRICT);
            assertEquals(label,   20, envelope.getSpan    (1), STRICT);
            assertEquals(label,   12, lower   .getOrdinate(0), STRICT);
            assertEquals(label, -180, envelope.getMinimum (0), STRICT);
            assertEquals(label,   -4, upper   .getOrdinate(0), STRICT);
            assertEquals(label, +180, envelope.getMaximum (0), STRICT);
            assertEquals(label, -176, envelope.getMedian  (0), STRICT);
            assertEquals(label,  344, envelope.getSpan    (0), STRICT); // 360° - testSimpleEnvelope()
            switch (type) {
                default: {
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.