Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.CoordinateOperation


              + "a nonexistent operation. Instead, a NoSuchAuthorityCodeException was expected.");
        }

        try {
            // Test CoordinateOperation
            CoordinateOperation co = factory.createCoordinateOperation(CRS_PAIR);
            assertNotNull(co);

            // Test CRSs
            CoordinateReferenceSystem crs = CRS.decode(SOURCE_CRS);
            assertSame(crs, co.getSourceCRS());
            crs = CRS.decode(TARGET_CRS);
            assertSame(crs, co.getTargetCRS());
           
            // Test MathTransform
            assertTrue(co.getMathTransform() instanceof MathTransform);
            double[] p = new double[2];
            co.getMathTransform().transform(SRC_TEST_POINT, 0, p, 0, 1);
            assertEquals(p[0], DST_TEST_POINT[0], 1e-8);
            assertEquals(p[1], DST_TEST_POINT[1], 1e-8);
        } catch (FactoryException e) {
            fail(factory.getClass().getSimpleName() + " threw a FactoryException when creating" +
                    " coordinate operation from an existing code.");           
View Full Code Here


       
        try {
            // Test CoordinateOperation
            Set<CoordinateOperation> cos = factory.createFromCoordinateReferenceSystemCodes(SOURCE_CRS, TARGET_CRS);
            assertTrue(cos.size() == 1);
            CoordinateOperation co = cos.iterator().next();
            assertNotNull(co);

            // Test CRSs
            CoordinateReferenceSystem crs = CRS.decode(SOURCE_CRS);
            assertSame(crs, co.getSourceCRS());
            crs = CRS.decode(TARGET_CRS);
            assertSame(crs, co.getTargetCRS());
           
            // Test MathTransform
            assertTrue(co.getMathTransform() instanceof MathTransform);
            double[] p = new double[2];
            co.getMathTransform().transform(SRC_TEST_POINT, 0, p, 0, 1);
            assertEquals(p[0], DST_TEST_POINT[0], 1e-8);
            assertEquals(p[1], DST_TEST_POINT[1], 1e-8);
        } catch (FactoryException e) {
            fail(factory.getClass().getSimpleName() + " threw a FactoryException when creating" +
                    " coordinate operation from an existing code.");           
View Full Code Here

     */
    @Test
    public void testTransformationOverPole() throws FactoryException, TransformException {
        final CoordinateReferenceSystem mapCRS = CRS.parseWKT(WKT.POLAR_STEREOGRAPHIC);
        final CoordinateReferenceSystem WGS84  = DefaultGeographicCRS.WGS84;
        final CoordinateOperation operation =
                CRS.getCoordinateOperationFactory(false).createOperation(mapCRS, WGS84);
        final MathTransform transform = operation.getMathTransform();
        assertTrue(transform instanceof MathTransform2D);
        /*
         * The rectangle to test, which contains the South pole.
         */
        Rectangle2D envelope = XRectangle2D.createFromExtremums(
View Full Code Here

            throws OperationNotFoundException, FactoryException
    {
        ensureNonNull("sourceCRS", sourceCRS);
        ensureNonNull("targetCRS", targetCRS);
        final CRSPair key = new CRSPair(sourceCRS, targetCRS);
        CoordinateOperation op;
        synchronized (hints) { // This lock is indirectly required by getBackingFactory().
            op = pool.get(key);
            if (op == null) {
                op = getBackingFactory().createOperation(sourceCRS, targetCRS);
                pool.put(key, op);
View Full Code Here

        char[] separator = null;
        for (int i=0; i<args.length; i++) {
            final CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem(args[i]);
            for (int j=i+1; j<args.length; j++) {
                final CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem(args[j]);
                final CoordinateOperation op;
                try {
                    op = opFactory.createOperation(crs1, crs2);
                } catch (OperationNotFoundException exception) {
                    out.println(exception.getLocalizedMessage());
                    continue;
                }
                if (separator == null) {
                    separator = getSeparator();
                } else {
                    out.println(separator);
                }
                out.println(formatter.format(op.getMathTransform()));
            }
        }
    }
View Full Code Here

    {
        MathTransform transform = null;
        ensureNonNull("operations", operations);
        for (int i=0; i<operations.length; i++) {
            ensureNonNull("operations", operations, i);
            final CoordinateOperation op = operations[i];
            if (op instanceof SingleOperation) {
                target.add((SingleOperation) op);
            } else if (op instanceof ConcatenatedOperation) {
                final ConcatenatedOperation cop = (ConcatenatedOperation) op;
                final List<SingleOperation> cops = cop.getOperations();
                expand(cops.toArray(new CoordinateOperation[cops.size()]), target, factory, false);
            } else {
                throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_CLASS_$2,
                        Classes.getClass(op), SingleOperation.class));
            }
            /*
             * Check the CRS dimensions.
             */
            if (i != 0) {
                final CoordinateReferenceSystem previous = operations[i-1].getTargetCRS();
                final CoordinateReferenceSystem next     = op             .getSourceCRS();
                if (previous!=null && next!=null) {
                    final int dim1 = previous.getCoordinateSystem().getDimension();
                    final int dim2 =     next.getCoordinateSystem().getDimension();
                    if (dim1 != dim2) {
                        throw new IllegalArgumentException(Errors.format(
                                  ErrorKeys.MISMATCHED_DIMENSION_$2, dim1, dim2));
                    }
                }
            }
            /*
             * Concatenates the math transform.
             */
            if (wantTransform) {
                final MathTransform step = op.getMathTransform();
                if (transform == null) {
                    transform = step;
                } else if (factory != null) {
                    transform = factory.createConcatenatedTransform(transform, step);
                } else {
View Full Code Here

        if (envelope != null && targetCRS != null) {
            final CoordinateReferenceSystem sourceCRS = envelope.getCoordinateReferenceSystem();
            if (sourceCRS != null) {
                if (!equalsIgnoreMetadata(sourceCRS, targetCRS)) {
                    final CoordinateOperationFactory factory = getCoordinateOperationFactory(true);
                    final CoordinateOperation operation;
                    try {
                        operation = factory.createOperation(sourceCRS, targetCRS);
                    } catch (FactoryException exception) {
                        throw new TransformException(Errors.format(
                                ErrorKeys.CANT_TRANSFORM_ENVELOPE), exception);
                    }
                    if (!operation.getMathTransform().isIdentity()) {
                        envelope = transform(operation, envelope);
                    } else if(!equalsIgnoreMetadata(envelope.getCoordinateReferenceSystem(), targetCRS)) {
                        GeneralEnvelope tx = new GeneralEnvelope(envelope);
                        tx.setCoordinateReferenceSystem(targetCRS);
                        envelope = tx;
View Full Code Here

            String sourceCRS, String targetCRS)
                    throws NoSuchAuthorityCodeException, FactoryException {

        Set<CoordinateOperation> coordops = new HashSet<CoordinateOperation>(1);

        CoordinateOperation coordop = createFromCoordinateReferenceSystemCodes(sourceCRS,
                targetCRS, false);
        if (coordop == null) {
            // Not found. Try to create from the inverse.
            coordop = createFromCoordinateReferenceSystemCodes(targetCRS, sourceCRS, true);
        }
View Full Code Here

        // Create the OperationMethod
        OperationMethod method = new DefaultOperationMethod(props,
                mt2.getSourceDimensions(), mt2.getTargetDimensions(), null);
       
        // Finally create CoordinateOperation
        CoordinateOperation coordop = null;
        if (!inverse) { // Direct operation
            props.put("name", sourceCRS + " \u21E8 " + targetCRS);
            coordop = DefaultOperation.create(props, source, target,
                    mt2, method, CoordinateOperation.class);
        } else { // Inverse operation
View Full Code Here

  }

  public CoordinateOperation createCoordinateOperation(String code)
      throws FactoryException {
    final String key = toKey(code);
    CoordinateOperation operation = (CoordinateOperation) cache.get(key);
    if (operation == null) {
      try {
        cache.writeLock(key);
        operation = (CoordinateOperation) cache.peek(key);
        if (operation == null) {
View Full Code Here

TOP

Related Classes of org.opengis.referencing.operation.CoordinateOperation

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.