Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.MathTransform


        CoordinateReferenceSystem wsg84 = DefaultGeographicCRS.WGS84;
       
        double buffer = 0.01; // how much of the wgs84 world to see
        Envelope view = point.buffer( buffer ).getEnvelopeInternal();
       
        MathTransform transform;
        try {
            transform = CRS.findMathTransform( wsg84, world, true ); // relaxed
        } catch (FactoryException e) {
            return; // no go
        }
View Full Code Here


     */
    private static void verifyReferencingEpsg() throws Exception {
        CoordinateReferenceSystem WGS84 = CRS.decode("EPSG:4326"); // latlong //$NON-NLS-1$
        CoordinateReferenceSystem BC_ALBERS = CRS.decode("EPSG:3005"); //$NON-NLS-1$

        MathTransform transform = CRS.findMathTransform(BC_ALBERS, WGS84);
        DirectPosition here = new DirectPosition2D(BC_ALBERS, 1187128, 395268);
        DirectPosition there = new DirectPosition2D(WGS84, -123.47009173007372, 48.54326498732153);

        DirectPosition check = transform.transform(here, new GeneralDirectPosition(WGS84));
        double delta = Math.abs(check.getOrdinate(0) - there.getOrdinate(0))
                + Math.abs(check.getOrdinate(1) - there.getOrdinate(1));
        if (delta > 0.0001) {
            String msg = "Referencing failed to transformation with expected accuracy: Off by " + delta + "\n" + check + "\n" + there; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            System.out.println(msg);
View Full Code Here

     */
    private static void transform( CoordinateReferenceSystem coordCRS,
            CoordinateReferenceSystem destinationCRS, Coordinate[] coordinates ) throws Exception {
        if( coordCRS==null || destinationCRS==null)
            return;
        MathTransform mt = CRS.findMathTransform(coordCRS, destinationCRS, true );
        if (mt == null || mt.isIdentity())
            return;
        double[] coords = new double[coordinates.length * 2];
        for( int i = 0; i < coordinates.length; i++ ) {
            coords[i * 2] = coordinates[i].x;
            coords[i * 2 + 1] = coordinates[i].y;
        }
        mt.transform(coords, 0, coords, 0, coordinates.length);
        for( int i = 0; i < coordinates.length; i++ ) {
            coordinates[i].x = coords[i * 2];
            coordinates[i].y = coords[i * 2 + 1];
        }
    }
View Full Code Here

     * @return
     */
    public Coordinate getTransformedClick( Coordinate click, ILayer layer ) {
   
        try {
            MathTransform transform = layer.mapToLayerTransform();
            if (transform == null || transform.isIdentity())
                return click;
            return JTS.transform(click, new Coordinate(), transform);
        } catch (Exception e1) {
            // CorePlugin.log(ToolsPlugin.getDefault(), e1);
            return click;
View Full Code Here

            if (resource == null)
                return;

            CoordinateReferenceSystem dataCRS = layer.getCRS();
            CoordinateReferenceSystem worldCRS = context.getCRS();
            MathTransform dataToWorld = CRS.findMathTransform(dataCRS, worldCRS, false);

            ReferencedEnvelope bounds = getRenderBounds();
            monitor.subTask("connecting");
           
            CSV csv = resource.resolve(CSV.class, new SubProgressMonitor(monitor, 10) );
View Full Code Here

                getContext().setStatus(ILayer.DONE);
                getContext().setStatusMessage(THE_MAP_IS_OUTSIDE_OF_THE_VISIBLE_REGION);
                System.out.println(THE_MAP_IS_OUTSIDE_OF_THE_VISIBLE_REGION);
                return;
            }
            MathTransform transform = CRS.findMathTransform(destinationCRS, grassCrs, true);
            Coordinate pixelSize = getContext().getPixelSize();

            Coordinate c1 = new Coordinate(envelope.getMinX(), envelope.getMinY());
            Coordinate c2 = new Coordinate(envelope.getMinX() + pixelSize.x, envelope.getMinY() + pixelSize.y);
            Envelope envy = new Envelope(c1, c2);
View Full Code Here

   * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl()
   */
  protected void runImpl(IProgressMonitor monitor) {
    if (crs != null) {
      try {
        MathTransform mt = CRS.findMathTransform(crs, model.getCRS(),
            true);
        if (!mt.isIdentity()) {
          Envelope transformedBounds = JTS.transform(newbbox, null,
              mt, 5);
          crs = model.getCRS();
          newbbox = transformedBounds;
        }
View Full Code Here

        return toShape(new GeometryFactory().toGeometry(envelope), envelope.getCoordinateReferenceSystem());
    }

    public Shape toShape( Geometry geometry, CoordinateReferenceSystem crs ) {
        try {
            MathTransform transform = CRS.findMathTransform(crs, getCRS(), true);
            MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
            MathTransform toScreen = factory.createAffineTransform(new GeneralMatrix(
                    worldToScreenTransform()));
            transform = factory.createConcatenatedTransform(transform, toScreen);
            return new LiteShape2(geometry, transform, new Decimator(transform), false);
        } catch (FactoryException e) {
            return null;
View Full Code Here

            return;

        @SuppressWarnings("unchecked") List<Adapter> list = model.getMapInternal().getEditManagerInternal().eAdapters(); //$NON-NLS-1$
        if (!list.contains(editListener))
            list.add(editListener);
        MathTransform mt = null;
        mt = getMathTransform();

        Symbolizer[] symbs = null;
        if (feature.getDefaultGeometry() instanceof Point
                || feature.getDefaultGeometry() instanceof MultiPoint)
View Full Code Here

   
    private void renderInternal(){
        if( syms==null ) {
            syms = Drawing.getSymbolizers(((Geometry)feature.getDefaultGeometry()).getClass(), color,false);
        }
        MathTransform mt = getMathTransform(featureCRS);
        AffineTransform toScreen=getMap().getViewportModel().worldToScreenTransform();

        // calculate the size of the image and where it will be in the display
        Envelope envelope;
        try{
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.