Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.MathTransform


                coveragebounds.getMinY(), coveragebounds.getMaxY());

        // convert bounds to necessary viewport projection
        CoordinateReferenceSystem tileCrs = getContext().getCRS();
        if (!coverage.getCoordinateReferenceSystem().equals(tileCrs)) {
            MathTransform transform = CRS.findMathTransform(
                    coverage.getCoordinateReferenceSystem(), tileCrs);
            tilebBounds = JTS.transform(tilebBounds, transform);
        }

        // determine screen coordinates of tiles
View Full Code Here


        // get the bounds of the tile
        Envelope bnds = tile.getBounds();

        // convert bounds to necessary viewport projection
        if (!crs.equals(getContext().getCRS())) {
            MathTransform transform = CRS.findMathTransform(crs, getContext().getCRS());
            bnds = JTS.transform(bnds, transform);
        }

        // determine screen coordinates of tiles
        Point upperLeft = getContext().worldToPixel(new Coordinate(bnds.getMinX(), bnds.getMinY()));
View Full Code Here

               
                if (rs.equals(crs)) {
                    return true;
                }
               
                MathTransform transform = getMathTransform(crs, rs);
               
                if (transform != null) {
                    return true;
                }
            }
View Full Code Here

    return false; // we cannot handle crs
    }

    private synchronized MathTransform getMathTransform( CoordinateReferenceSystem from, CoordinateReferenceSystem to) throws FactoryException {
        Pair pair = new Pair(from,to);
        MathTransform result=this.transformCache.get(pair);
        if( result==null ){
            result=CRS.findMathTransform(from, to, true);
            transformCache.put(pair, result);
        }
        return result;
View Full Code Here

                    destinationEnvelopeInSourceCRS = destinationEnvelope;
                } else {
                    // otherwise we need to transform
                    final CoordinateReferenceSystem bboxCRS = CRS.decode(bbox.getCrs());
                    destinationEnvelope.setCoordinateReferenceSystem(bboxCRS);
                    final MathTransform bboxToNativeTx = CRS.findMathTransform(bboxCRS, nativeCRS,
                            true);
                    destinationEnvelopeInSourceCRS = CRS.transform(bboxToNativeTx,
                            destinationEnvelope);
                    destinationEnvelopeInSourceCRS.setCoordinateReferenceSystem(nativeCRS);
                }
            } else {
                destinationEnvelopeInSourceCRS = reader.getOriginalEnvelope();
                destinationEnvelope = destinationEnvelopeInSourceCRS;
            }

            final GridCrsType gridCRS = request.getOutput().getGridCRS();
            // TODO: handle time domain subset...

            // Compute the target crs, the crs that the final coverage will be
            // served into
            final CoordinateReferenceSystem targetCRS;
            if (gridCRS == null)
                targetCRS = reader.getOriginalEnvelope().getCoordinateReferenceSystem();
            else
                targetCRS = CRS.decode(gridCRS.getGridBaseCRS());

            // grab the grid to world transformation
            MathTransform gridToCRS = reader.getOriginalGridToWorld(PixelInCell.CELL_CORNER);
            if (gridCRS != null) {
                Double[] origin = (Double[]) gridCRS.getGridOrigin();
                Double[] offsets = (Double[]) gridCRS.getGridOffsets();

                // from the specification if grid origin is omitted and the crs
View Full Code Here

                    // the reprojection, otherwise just update the value as is
                    if ( source != null && target != null && !CRS.equalsIgnoreMetadata(source, target)) {
                        try {
                            //TODO: this code should be shared with the code
                            // from ReprojectingFeatureCollection --JD
                            MathTransform tx = CRS.findMathTransform(source, target, true);
                            GeometryCoordinateSequenceTransformer gtx =
                                new GeometryCoordinateSequenceTransformer();
                            gtx.setMathTransform(tx);
                           
                            values[j] = gtx.transform(geometry);   
View Full Code Here

            }

            fi = getSortedFeatures(geom, tile.getEnvelope(), nativeTileEnvelope, conn);

            // if the crs is not wgs84, we'll need to transform the point
            MathTransform tx = null;
            double[] coords = new double[2];

            // scan counting how many fids we've collected
            boolean first = true;
            while (fi.hasNext() && currFids.size() < featuresPerTile) {
                // grab the feature, skip it if it's already in a parent element
                SimpleFeature f = (SimpleFeature) fi.next();
                if (parentFids.contains(f.getID()))
                    continue;

                // check the need for a transformation
                if (first) {
                    first = false;
                    CoordinateReferenceSystem nativeCRS = f.getType()
                            .getCoordinateReferenceSystem();
                    featureType.getFeatureType().getCoordinateReferenceSystem();
                    if (nativeCRS != null
                            && !CRS.equalsIgnoreMetadata(nativeCRS, WGS84)) {
                        tx = CRS.findMathTransform(nativeCRS, WGS84);
                    }
                }

                // see if the features is to be included in this tile
                Point p = ((Geometry) f.getDefaultGeometry()).getCentroid();
                coords[0] = p.getX();
                coords[1] = p.getY();
                if (tx != null)
                    tx.transform(coords, 0, coords, 0, 1);
                if (tile.contains(coords[0], coords[1]))
                    currFids.add(f.getID());
            }
        } finally {
            if (fi != null)
View Full Code Here

      final CoordinateReferenceSystem sourceCRS = CRS.decode(requestCRS);
 
      // This is the CRS of the Coverage Envelope
      final CoordinateReferenceSystem cvCRS = ((GeneralEnvelope) coverageReader
          .getOriginalEnvelope()).getCoordinateReferenceSystem();
      final MathTransform GCCRSTodeviceCRSTransformdeviceCRSToGCCRSTransform = CRS
          .findMathTransform(cvCRS, sourceCRS, true);
      final MathTransform GCCRSTodeviceCRSTransform = CRS.findMathTransform(cvCRS, targetCRS, true);
      final MathTransform deviceCRSToGCCRSTransform = GCCRSTodeviceCRSTransformdeviceCRSToGCCRSTransform
          .inverse();
 
      com.vividsolutions.jts.geom.Envelope envelope = request.getBbox();
      GeneralEnvelope destinationEnvelope;
      final boolean lonFirst = sourceCRS.getCoordinateSystem().getAxis(0).getDirection().absolute()
                                        .equals(AxisDirection.EAST);
 
      // the envelope we are provided with is lon,lat always
      if (!lonFirst) {
          destinationEnvelope = new GeneralEnvelope(new double[] {
                      envelope.getMinY(), envelope.getMinX()
                  }, new double[] { envelope.getMaxY(), envelope.getMaxX() });
      } else {
          destinationEnvelope = new GeneralEnvelope(new double[] {
                      envelope.getMinX(), envelope.getMinY()
                  }, new double[] { envelope.getMaxX(), envelope.getMaxY() });
      }
 
      destinationEnvelope.setCoordinateReferenceSystem(sourceCRS);
 
      // this is the destination envelope in the coverage crs
      final GeneralEnvelope destinationEnvelopeInSourceCRS = (!deviceCRSToGCCRSTransform
          .isIdentity()) ? CRS.transform(deviceCRSToGCCRSTransform, destinationEnvelope)
                         : new GeneralEnvelope(destinationEnvelope);
      destinationEnvelopeInSourceCRS.setCoordinateReferenceSystem(cvCRS);
 
      /**
 
View Full Code Here

        // CoordinateReferenceSystem sourceCRS =
        // f.getFeatureType().getDefaultGeometry().getCoordinateSystem();
        if (!CRS.equalsIgnoreMetadata(sourceCrs, this.mapContext
                .getCoordinateReferenceSystem())) {
            try {
                MathTransform transform = CRS.findMathTransform(sourceCrs,
                        this.mapContext.getCoordinateReferenceSystem(), true);
                geom = JTS.transform(geom, transform);
            } catch (MismatchedDimensionException e) {
                LOGGER.severe(e.getLocalizedMessage());
            } catch (TransformException e) {
View Full Code Here

        final WMSMapContext map = new WMSMapContext();
       
        CoordinateReferenceSystem sourceCrs=CRS.decode("EPSG:3004");
        CoordinateReferenceSystem targetCrs=CRS.decode("EPSG:3003");
       
        MathTransform transform=CRS.findMathTransform(sourceCrs, targetCrs,true);
        Envelope projEnv=JTS.transform(env, transform);
        ReferencedEnvelope refEnv=new ReferencedEnvelope(projEnv,targetCrs);
       
        map.setAreaOfInterest(refEnv);
        map.setMapWidth(mapWidth);
View Full Code Here

TOP

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

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.