Package org.gdal.osr

Examples of org.gdal.osr.CoordinateTransformation


      System.out.println( "DEST IsGeographic:" + dst.IsGeographic() + " IsProjected:" + dst.IsProjected() );
      /* -------------------------------------------------------------------- */
      /*      making the transform                                            */
      /* -------------------------------------------------------------------- */
            /* New in GDAL 1.10. Before was "new CoordinateTransformation(srs,dst)". */
      CoordinateTransformation ct = CoordinateTransformation.CreateCoordinateTransformation(src, dst);
      double[] p = new double[3];
      p[0] = 19; p[1] = 47; p[2] = 0;
      ct.TransformPoint(p);
      System.out.println("x:" + p[0] + " y:" + p[1] + " z:" + p[2]);
      ct.TransformPoint(p, 19.2, 47.5, 0);
      System.out.println("x:" + p[0] + " y:" + p[1] + " z:" + p[2]);
    }
    catch (Exception e)
    {
      System.out.println("Error occurred: " + e.getMessage());
View Full Code Here


  {
    double dfGeoX, dfGeoY;
    String pszProjection;
    double[] adfGeoTransform = new double[6];
    CoordinateTransformation hTransform = null;

    System.out.print(corner_name + " ");

    /* -------------------------------------------------------------------- */
    /*      Transform the point into georeferenced coordinates.             */
    /* -------------------------------------------------------------------- */
    hDataset.GetGeoTransform(adfGeoTransform);
    {
      pszProjection = hDataset.GetProjectionRef();

      dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
          + adfGeoTransform[2] * y;
      dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x
          + adfGeoTransform[5] * y;
    }

    if (adfGeoTransform[0] == 0 && adfGeoTransform[1] == 0
        && adfGeoTransform[2] == 0 && adfGeoTransform[3] == 0
        && adfGeoTransform[4] == 0 && adfGeoTransform[5] == 0) {
      System.out.println("(" + x + "," + y + ")");
      return false;
    }

    /* -------------------------------------------------------------------- */
    /*      Report the georeferenced coordinates.                           */
    /* -------------------------------------------------------------------- */
    System.out.print("(" + dfGeoX + "," + dfGeoY + ") ");

    /* -------------------------------------------------------------------- */
    /*      Setup transformation to lat/long.                               */
    /* -------------------------------------------------------------------- */
    if (pszProjection != null && pszProjection.length() > 0) {
      SpatialReference hProj, hLatLong = null;

      hProj = new SpatialReference(pszProjection);
      if (hProj != null)
        hLatLong = hProj.CloneGeogCS();

      if (hLatLong != null) {
        /* New in GDAL 1.10. Before was "new CoordinateTransformation(srs,dst)". */
        hTransform = CoordinateTransformation.CreateCoordinateTransformation(hProj, hLatLong);
            }

      if (hProj != null)
        hProj.delete();
    }

    /* -------------------------------------------------------------------- */
    /*      Transform to latlong and report.                                */
    /* -------------------------------------------------------------------- */
    if (hTransform != null) {
      double[] transPoint = new double[3];
      hTransform.TransformPoint(transPoint, dfGeoX, dfGeoY, 0);
      System.out.print("(" + gdal.DecToDMS(transPoint[0], "Long", 2));
      System.out
          .print("," + gdal.DecToDMS(transPoint[1], "Lat", 2) + ")");
    }

    if (hTransform != null)
      hTransform.delete();

    System.out.println("");

    return true;
  }
View Full Code Here

            bForceToMultiLineString = true;
   
    /* -------------------------------------------------------------------- */
    /*      Setup coordinate transformation if we need it.                  */
    /* -------------------------------------------------------------------- */
        CoordinateTransformation poCT = null;
   
        if( bTransform )
        {
            if( poSourceSRS == null )
                poSourceSRS = poSrcLayer.GetSpatialRef();
View Full Code Here

TOP

Related Classes of org.gdal.osr.CoordinateTransformation

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.