Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer


   *
   * @return transformation to apply
   */
  private GeometryCoordinateSequenceTransformer getTransformer() {
    if (unitToPixel == null) {
      unitToPixel = new GeometryCoordinateSequenceTransformer();
      unitToPixel.setMathTransform(ProjectiveTransform.create(new AffineTransform(scale, 0, 0, -scale, -scale
          * panOrigin.x, scale * panOrigin.y)));
    }
    return unitToPixel;
  }
View Full Code Here


                    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);   
                        }
                        catch( Exception e ) {
                            String msg = "Failed to reproject geometry:" + e.getLocalizedMessage();
                            throw new WFSTransactionException( msg, e );
                        }
View Full Code Here

        if (source != null) {
            MathTransform2D tx = (MathTransform2D) ReferencingFactoryFinder
                    .getCoordinateOperationFactory(hints).createOperation(source, target)
                    .getMathTransform();

            GeometryCoordinateSequenceTransformer transformer = new GeometryCoordinateSequenceTransformer();
            transformer.setMathTransform(tx);
            transformers.put(source, transformer);
        } else {
            throw new RuntimeException("Source was null in trying to create a reprojected feature collection!");
        }
    }
View Full Code Here

                }

                if (crs != null) {
                    // if equal, nothing to do
                    if (!crs.equals(target)) {
                        GeometryCoordinateSequenceTransformer transformer = (GeometryCoordinateSequenceTransformer) transformers
                                .get(crs);

                        if (transformer == null) {
                            transformer = new GeometryCoordinateSequenceTransformer();

                            MathTransform2D tx;

                            try {
                                tx = (MathTransform2D) ReferencingFactoryFinder
                                        .getCoordinateOperationFactory(hints).createOperation(crs,
                                                target).getMathTransform();
                            } catch (Exception e) {
                                String msg = "Could not transform for crs: " + crs;
                                throw (IOException) new IOException(msg).initCause(e);
                            }

                            transformer.setMathTransform(tx);
                            transformers.put(crs, transformer);
                        }

                        // do the transformation
                        try {
                            object = transformer.transform(geometry);
                        } catch (TransformException e) {
                            String msg = "Error occured transforming " + geometry.toString();
                            throw (IOException) new IOException(msg).initCause(e);
                        }
                    }
View Full Code Here

    assert geomCrs != null;
    assert reprojectCrs != null;

    CoordinateSequenceFactory csFactory;
    CoordinateSequenceTransformer csTransformer;
    GeometryCoordinateSequenceTransformer transformer;

    csFactory = gFactory.getCoordinateSequenceFactory();
    csTransformer = new CoordSeqFactoryPreservingCoordinateSequenceTransformer(csFactory);
    transformer = new GeometryCoordinateSequenceTransformer(csTransformer);
    MathTransform mathTransform;
    try {
      mathTransform = CRS.findMathTransform(geomCrs, reprojectCrs, true);
    } catch (FactoryException e) {
      throw new OperationNotFoundException(e.getMessage());
    }

    transformer.setMathTransform(mathTransform);

    return transformer;
  }
View Full Code Here

      return geom;
    }

    GeometryFactory gFactory = geom.getFactory();

    GeometryCoordinateSequenceTransformer transformer;
    transformer = getTransformer(gFactory, geomCrs, reprojectCrs);
    Geometry geometry;
    try {
      geometry = transformer.transform(geom);
    } catch (TransformException e) {
      throw e;
    }
    return geometry;
  }
View Full Code Here

        } else if (projObj instanceof String) {
            toProj = new Projection(getParentScope(), (String) projObj);
        } else {
            throw new RuntimeException("Argument must be a Projection instance or string identifier.");
        }
        GeometryCoordinateSequenceTransformer gt = new GeometryCoordinateSequenceTransformer();
        try {
            gt.setMathTransform(CRS.findMathTransform(fromProj.unwrap(), toProj.unwrap()));
        } catch (FactoryException e) {
            throw new RuntimeException("Failed to find transform.", e);
        }
        com.vividsolutions.jts.geom.Geometry transGeom;
        try {
            transGeom = gt.transform((com.vividsolutions.jts.geom.Geometry) this.unwrap());
        } catch (TransformException e) {
            throw new RuntimeException("Failed to transform.", e);
        }
        Geometry transformed = (Geometry) GeometryWrapper.wrap(getParentScope(), transGeom);
        transformed.projection = toProj;
View Full Code Here

        target = CRS.decode("EPSG:3005");

        MathTransform2D tx = (MathTransform2D) ReferencingFactoryFinder
                .getCoordinateOperationFactory(null).createOperation(crs, target)
                .getMathTransform();
        transformer = new GeometryCoordinateSequenceTransformer();
        transformer.setMathTransform(tx);
    }
View Full Code Here

      "PROJCS[\"BC_Albers\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS_1980\",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"False_Easting\",1000000],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",-126],PARAMETER[\"Standard_Parallel_1\",50],PARAMETER[\"Standard_Parallel_2\",58.5],PARAMETER[\"Latitude_Of_Origin\",45],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"42102\"]]" 
    );
   
    MathTransform2D tx = (MathTransform2D) ReferencingFactoryFinder.getCoordinateOperationFactory(null)
    .createOperation(crs,target).getMathTransform();
    transformer = new GeometryCoordinateSequenceTransformer();
    transformer.setMathTransform( tx );
                transformer.setCoordinateReferenceSystem( target );
  }
View Full Code Here

        if ( target == null ) {
          throw new NullPointerException("destination crs");
        }
       
        this.transform = transform(source, target);
        transformer = new GeometryCoordinateSequenceTransformer();
    }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer

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.