Class ProjUtils

java.lang.Object
org.openjump.core.ccordsys.utils.ProjUtils

public class ProjUtils extends Object
Giuseppe Aruta [23_3_2016] This class is used to recognize file projection. There are different methods A) a method to decode projection information from GeoTIFF metadata. B) a method to decode projection info from auxiliary files (.proj and .aux.xml). http://landsathandbook.gsfc.nasa.gov/pdfs/geotiff_spec.pdf http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/GeoTiff.html http://www.remotesensing.org/geotiff/spec/geotiff6.html the following datasets have been used to test this library: QGIS (http://qgis.org/downloads/data/) OSGEO data samples ( http://download.osgeo.org/geotiff/samples/)
  • Constructor Details

    • ProjUtils

      public ProjUtils()
  • Method Details

    • getSRSInfoFromGeoTiff

      public static SRSInfo getSRSInfoFromGeoTiff(String fileSourcePath) throws IOException, TiffTags.TiffReadingException
      - Read SRS from GeoTIFF tag - This method gets projection srid code and projection info from a geotiff file. It first scans GeoKeyDirectoryTag to get either geographic/geocentric (2048 - GeographicTypeGeoKey), projected (3072 - ProjectedCSTypeGeoKey) or vertical (4096 - VerticalCSTypeGeoKey) info. If no key ID is identified, it scans for GeoAsciiParamsTag projection definition. Last choice, it search for an auxiliary file
      Parameters:
      fileSourcePath - . eg. "c\documents\folder\image.tif"
      Returns:
      the projection srid as a string. eg "32632"
      Throws:
      IOException - if an IOException occurs
      TiffTags.TiffReadingException
    • getSRSInfoFromAuxiliaryFile

      public static SRSInfo getSRSInfoFromAuxiliaryFile(String fileSourcePath) throws URISyntaxException, IOException
      - Read SRS from auxiliary file - Method to get a SRS (SRID code + SRID definition) scanning the aux projection file (AUX.XML or PRJ file) for a search string (SRID code or SRID definition). It scans into the registry file (srid.txt) to find a correspondence between the search string and lines of the srid.txt. If the source string corresponds as substring to a line, it returns the complete line as string. For instance, search strings like "NAD83 UTM zone 10N" or "26910" both return "SRID:26910 - NAD83 UTM zone 10N".
      Parameters:
      fileSourcePath - auxiliary file path
      Returns:
      SRSInfo and Projection definition
      Throws:
      IOException - if an IOException occurs
      URISyntaxException - if an URISyntaxException occurs
    • readableFormatWKTCode

      public static String readableFormatWKTCode(String WKT)
      Method to show an OGC WKT string in a more readable style
      Parameters:
      WKT - OGC WKT from auxiliary proj file
      Returns:
      Readable string
    • getSRSInfoFromLayerStyleOrSource

      public static SRSInfo getSRSInfoFromLayerStyleOrSource(Layer layer) throws Exception
      Method to get SRID from a layer from Style or from auxiliary file. It tries to check all possibilities: a) SRID is recorded from layer auxiliary file b) SRID is recorded from data source c) No SRID is available d) Layer SRID doesn't match auxilary file/datasource SRID
      Parameters:
      layer - a Layer
      Returns:
      the SRID srid associated to the Layer
      Throws:
      Exception - if an Exception occurs
    • getSRSInfoFromLayerStyleOrSource_old

      public static SRSInfo getSRSInfoFromLayerStyleOrSource_old(Layer layer) throws Exception
      Method to get SRID from a layer from Style or from auxiliary file. First scans SRIDStyle, than auxiliary file or GeoTIFF tag. If SRID does not exist, it returns 0.
      Parameters:
      layer - a Layer
      Returns:
      the SRID associated to the Layer
      Throws:
      Exception - if an Exception occurs
    • getSRSInfoFromLayerSource

      public static SRSInfo getSRSInfoFromLayerSource(Layer layer) throws Exception
      Method to get SRID from a layer file from auxiliary files (.prj or .aux) or GeoTIFFed tag. If the auxiliary file SRID does not exist, it returns 0.
      Parameters:
      layer - a Layer
      Returns:
      the SRID associated to this Layer
      Throws:
      Exception - if an Exception occurs
    • isImageGeoTIFFLayer

      public static boolean isImageGeoTIFFLayer(Layer layer)
    • getSRSInfoFromLayerSource

      public static SRSInfo getSRSInfoFromLayerSource(RasterImageLayer layer) throws Exception, URISyntaxException
      Throws:
      Exception
      URISyntaxException