Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.MathTransform


                matrix[3] = tx.get( "shearY") != null ? tx.get( "shearY") : matrix[3];
                matrix[4] = tx.get( "scaleY") != null ? tx.get( "scaleY") : matrix[4];
                matrix[5] = tx.get( "translateY") != null ? tx.get( "translateY") : matrix[5];
                matrix[8] = 1.0;
               
                MathTransform gridToCRS = new DefaultMathTransformFactory()
                    .createAffineTransform( new GeneralMatrix(3,3,matrix));
                coverage.setGrid( new GridGeometry2D(range,gridToCRS,crs) );
            }
            else {
                coverage.setGrid( new GridGeometry2D( range, gridEnvelope ) );
View Full Code Here


            MismatchedDimensionException, TransformException {

        // reprojected geometries
        CoordinateReferenceSystem sourceCRS = (CoordinateReferenceSystem) CRS.decode(EPSG_4283);
        CoordinateReferenceSystem targetCRS = (CoordinateReferenceSystem) CRS.decode(EPSG_4326);
        MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
        GeometryFactory factory = new GeometryFactory();
        Polygon srcPolygon = factory.createPolygon(factory.createLinearRing(factory
                .getCoordinateSequenceFactory().create(
                        new Coordinate[] { new Coordinate(-1.2, 52.5), new Coordinate(-1.2, 52.6),
                                new Coordinate(-1.1, 52.6), new Coordinate(-1.1, 52.5),
View Full Code Here

    }
   
   
    public void testVersionedFeatureCollection10Reproject() throws Exception {
        // prepare the expected transformation results
        MathTransform tx = CRS.findMathTransform(CRS.decode("EPSG:26713"), CRS.decode("EPSG:900913"));
        double[] original = new double[] {604000,4930000};
        double[] expected = new double[2];
        tx.transform(original, 0, expected, 0, 1);
       
        // gather the results and extract the coordinates using xpath
        Document doc = getAsDOM(root() + "service=wfsv&version=1.0.0&request=GetVersionedFeature&srsName=EPSG:900913&typeName=topp:archsites&featureId=archsites.5");
        String transformed = xpath.evaluate("//topp:archsites[@fid=\"archsites.5\"]/topp:the_geom/gml:Point/gml:coordinates/text()", doc);
       
View Full Code Here

                "//topp:archsites[@gml:id=\"archsites.5\"]/topp:lastUpdateMessage", doc);
    }
   
    public void testVersionedFeatureCollection11Reproject() throws Exception {
        // prepare the expected transformation results
        MathTransform tx = CRS.findMathTransform(CRS.decode("EPSG:26713"), CRS.decode("EPSG:900913"));
        double[] original = new double[] {604000,4930000};
        double[] expected = new double[2];
        tx.transform(original, 0, expected, 0, 1);
       
        // gather the results and extract the coordinates using xpath
        Document doc = getAsDOM(root() + "service=WFSV&version=1.1.0&request=GetVersionedFeature&srsName=EPSG:900913&typeName=topp:archsites&featureId=archsites.5");
        print(doc);
        String transformed = xpath.evaluate("//topp:archsites[@gml:id=\"archsites.5\"]/topp:the_geom/gml:Point/gml:pos/text()", doc);
View Full Code Here

       
        //we have to be sure that we are working against a valid grid range.
        final GridEnvelope2D testRange= new GridEnvelope2D(minX,minY,maxX,maxY);
       
        //build the corresponding envelope
        final MathTransform gridToWorldCorner =  reader.getOriginalGridToWorld(PixelInCell.CELL_CORNER);
        final GeneralEnvelope testEnvelope =CRS.transform(gridToWorldCorner,new GeneralEnvelope(testRange.getBounds()));
        testEnvelope.setCoordinateReferenceSystem(nativeCRS);
       
        parameters.put(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString(),
            new GridGeometry2D(testRange, testEnvelope));
View Full Code Here

     */
    private void worldMapGraphic( MapGraphicContext context ) {
        GridStyle style = getStyle(context.getLayer());
        double[] gridSize=style.getGridSize();
        try{
            MathTransform mt = CRS.findMathTransform(DefaultGeographicCRS.WGS84, context.getCRS(), true);
       
            if( !mt.isIdentity() ){
                double x=gridSize[0]/2.0;
                double y=gridSize[1]/2.0;
                double[] toTransform=new double[]{-x,-y,x,y};
                double[] dest=new double[4];
                mt.transform(toTransform,0,dest,0,2);
                gridSize=new double[]{Math.abs(dest[2]-dest[0]), Math.abs(dest[3]-dest[1])};
            }
        }catch (Exception e) {
            MapGraphicPlugin.log("",e); //$NON-NLS-1$
        }
View Full Code Here

        GridStyle style = getStyle(context.getLayer());
        double[] gridSize=style.getGridSize();
    

        try{
            MathTransform mt = CRS.findMathTransform(DefaultGeographicCRS.WGS84, context.getCRS(), true);
       
            if( !mt.isIdentity() ){
                double x=gridSize[0]/2.0;
                double y=gridSize[1]/2.0;
                double[] toTransform=new double[]{-x,-y,x,y};
                double[] dest=new double[4];
                mt.transform(toTransform,0,dest,0,2);
                gridSize=new double[]{Math.abs(dest[2]-dest[0]), Math.abs(dest[3]-dest[1])};
            }
        }catch (Exception e) {
            MapGraphicPlugin.log("",e); //$NON-NLS-1$
        }
View Full Code Here

    }

    private double[] worldClosest( int x1, int y1, ILayer layer ) throws FactoryException {
        Coordinate coord = layer.getMap().getViewportModel().pixelToWorld(x1, y1);
        CoordinateReferenceSystem crs = layer.getMap().getViewportModel().getCRS();
        MathTransform mt = CRS.findMathTransform(DefaultGeographicCRS.WGS84, crs);

        double[] gridSize = getStyle(layer).getGridSize();
        try{
       
            if( !mt.isIdentity() ){
                double tx=gridSize[0]/2.0;
                double ty=gridSize[1]/2.0;
                double[] toTransform=new double[]{-tx,-ty,tx,ty};
                double[] dest=new double[4];
                mt.transform(toTransform,0,dest,0,2);
                gridSize=new double[]{Math.abs(dest[2]-dest[0]), Math.abs(dest[3]-dest[1])};
            }
        }catch (Exception e) {
            MapGraphicPlugin.log("",e); //$NON-NLS-1$
        }
View Full Code Here

    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());
    }
View Full Code Here

    }
    if (CRS.equalsIgnoreMetadata(segmentCrs, reprojectCrs)) {
      return segment;
    }

    MathTransform mathTransform;
    try {
      mathTransform = CRS.findMathTransform(segmentCrs, reprojectCrs, true);
    } catch (FactoryException e) {
      throw new RuntimeException(e.getMessage());
    }
    double[] src = { segment.p0.x, segment.p0.y, segment.p1.x, segment.p1.y };
    double[] dst = new double[4];
    try {
      mathTransform.transform(src, 0, dst, 0, 2);
    } catch (TransformException e) {
      throw new RuntimeException(e.getMessage());
    }
    Coordinate p0 = new Coordinate(dst[0], dst[1]);
    Coordinate p1 = new Coordinate(dst[2], dst[3]);
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.