Class LayerableUtil

java.lang.Object
org.openjump.core.ui.util.LayerableUtil

public abstract class LayerableUtil extends Object
  • Field Details

    • filetype

      public static String filetype
  • Constructor Details

    • LayerableUtil

      public LayerableUtil()
  • Method Details

    • isSpatiallyEqualTo

      public static boolean isSpatiallyEqualTo(RasterImageLayer rLayer1, RasterImageLayer rLayer2) throws IOException
      Boolean to verify if a <RasterImageLayer> rLayer1 is spatially equivalent to another <RasterImageLayer> rLayer2
      Parameters:
      rLayer1 - first layer
      rLayer2 - second layer
      Returns:
      true if they are equivalent. False if they are not equivalent
      Throws:
      IOException - if an IOException occurs during layer reading
    • isTemporary

      public static boolean isTemporary(RasterImageLayer layer)
      RasterImageLayer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if selected sextante raster (RasterImageLayer.class) is Temporary layer (layer stored into TEMP folder)
    • isModified

      public static boolean isModified(RasterImageLayer layer)
      RasterImageLayer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if selected sextante raster (RasterImageLayer.class) has been modified
    • isMonoband

      public static boolean isMonoband(RasterImageLayer layer)
      RasterImageLayer.class
      Parameters:
      layer - the RasterImageLayer to test
      Returns:
      true if selected sextante raster layer is monoband layer
    • getFilePath

      public static String getFilePath(RasterImageLayer layer)
      RasterImageLayer.class
      Parameters:
      layer - the layer to query
      Returns:
      the File path of a sextante raster (RasterImageLayer.class) eg. C/File/imagename.tif
    • isTemporary

      public static boolean isTemporary(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if the layer (Layer.class) is a temporary layer Both layers in memory and layers stored into TEMP folder are considered as "Temporary layers"
    • isModified

      public static boolean isModified(Layer layer)
      Parameters:
      layer - the layer to test
      Returns:
      true if the layer (Layer.class) has been modified
    • isVector

      public boolean isVector(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if the layer (Layer,class) is a vector layer Eg. layer with datastore belonging to Shapefile, JML or GML file). This method excludes Datastores and Image file loaded by Layer,class
    • isImage

      public static boolean isImage(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if the layer (Layer.class) belongs form an image file (eg. JPG, TIF, ECW)
    • isMultipleImages

      public static boolean isMultipleImages(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if the Layer (Layer.class) is a collection of Image layers (eg. JPG, TIF, ECW)
    • isDataStore

      public static boolean isDataStore(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if the layer (Layer.class) is a datastore layer (eg. Oracle, SpatiaLite, MySQL)
    • isCad

      public static boolean isCad(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true Check if the layer is a cad Layer following DXF PlugIn schema it defines Cad layer with the presence of COLOR and TEXT attributes
    • isEmpty

      public static boolean isEmpty(Layer layer)
      Layer.class
      Parameters:
      layer - the layer to test
      Returns:
      true if the layer is empty
    • isPolygonalLayer

      public static boolean isPolygonalLayer(Layer layer)
      check if selected layer has only polygons and/or multipolygons
      Parameters:
      layer - the layer to test
      Returns:
      boolean - true if the vector layer has only polygon/multipolygon geometries (Shapefile model)
    • isPolygonalLayer

      public static boolean isPolygonalLayer(FeatureCollection featureCollection)
      check if selected featureCollection has only polygons and/or multipolygons
      Parameters:
      featureCollection - the feature collection to test
      Returns:
      boolean - true if the vector layer has only polygon/multipolygon geometries (Shapefile model)
    • isPointLayer

      public static boolean isPointLayer(Layer layer)
      Check if selected layer has only points and/or multipoints
      Parameters:
      layer - the layer to test
      Returns:
      boolean - true if the vector layer has only point/multipoint geometries (Shapefile model)
    • isPointLayer

      public static boolean isPointLayer(FeatureCollection featureCollection)
      Check if selected featureCollection has only points and/or multipoints
      Parameters:
      featureCollection - the feature collection to test
      Returns:
      boolean - true if the vector layer has only point/multipoint geometries (Shapefile model)
    • isLinealLayer

      public static boolean isLinealLayer(Layer layer)
      Check if selected layer has only linestring and/or multilinestring and/or multilinearings
      Parameters:
      layer - the layer to test
      Returns:
      boolean - true if the vector layer has only LineString/MultiLineString geometries (Shapefile model)
    • isLinealLayer

      public static boolean isLinealLayer(FeatureCollection featureCollection)
      Check if selected FeatureCollection has only linestring and/or multilinestring and/or multilinearings (Shapefile model)
      Parameters:
      featureCollection - the feature collection to test
      Returns:
      boolean - true if the vector layer has only LineString/MultiLineString geometries (Shapefile model)
    • isMixedGeometryType

      public static boolean isMixedGeometryType(Layer layer)
      Check if selected layer has geoemtries of different types
      Parameters:
      layer - the layer to test
      Returns:
      true if the selected layer has features of different geometries types (Shapefile model) (Shapefile model)
    • isMixedGeometryType

      public static boolean isMixedGeometryType(FeatureCollection featureCollection)
      Check if selected FeatureCollection has geoemtries of different types
      Parameters:
      featureCollection - the feature collection to test
      Returns:
      true if the selected layer has features of different geometries types (Shapefile model)
    • getGeometryType

      public static String getGeometryType(Layer layer)
    • getFilePath

      public static String getFilePath(Layer layer)
      Parameters:
      layer - the layer from which to get the file path
      Returns:
      the File path of a Layer.class eg. C/File/vectorname.shp
    • getLayerSourceClass

      public static String getLayerSourceClass(Layer layer)
      Parameters:
      layer - the Layer from which to get the DataSource class
      Returns:
      the source class of a Layer.class eg. C/File/vectorname.shp
    • getFileType

      public static String getFileType(File file)
      input file
      Parameters:
      file - the file whose type we want to know
      Returns:
      the type of the file as string
    • getVectorImageFileDescription

      public static String getVectorImageFileDescription(Layer layer)
      Parameters:
      layer - the Layer whose description we want to know
      Returns:
      a description of the vector file ex. "SHP - ESRI Shapefile" if the file extension is not into the enum list it returns the extension (eg. "DWG")
    • getRasterFileDescription

      public static String getRasterFileDescription(RasterImageLayer layer)
      Parameters:
      layer - the Raster image layer
      Returns:
      a description of raster image layer ex. "GEOTIF/TIFF - Tagged Image File Format" if the file extension is not into the enum list it returns only the extension (eg. "MAP")
    • ExportVector

      public static void ExportVector(PlugInContext context, Layer layer, String path)
      Export vector layer as SHP or JML depending on the geometries
      Parameters:
      context - the plugin context
      layer - a layer
      path - the path to export to
    • ExportSextanteRaster

      public static void ExportSextanteRaster(PlugInContext context, RasterImageLayer layer, String path)
      Export Sextante Raster layerable to TIF
      Parameters:
      context - plugin context
      layer - the RasterImageLayer to export
      path - the path to export to
    • ExportImage

      public static void ExportImage(PlugInContext context, Layer layer, String path) throws IOException
      Export Image: simple method to save an image file, loaded to a folde by Layer.class, with corresponding worldfile, if exists
      Parameters:
      context - the plugin context
      layer - the image layer to export
      path - the path to export the image to
      Throws:
      IOException - if an IOException occurs during export
    • ExportVectorStyleToSLD

      public static void ExportVectorStyleToSLD(PlugInContext context, Layer layer, String path) throws Exception
      Export Vector layer styles as SLD This part of the code derives from de.latlon.deejump.plugin.style.LayerStyle2SLDPlugIn.class and it has been modified to automatically export SLD files for vectors
      Parameters:
      context - the plugin context
      layer - the layer whose style to export
      path - the path to export to
      Throws:
      IOException - if an IOException occurs during SLD writing
      Exception
    • ExportRasterStyleToSLD

      public static void ExportRasterStyleToSLD(PlugInContext context, RasterImageLayer rLayer, String path)
      Export RasterImage layer styles as SLD
      Parameters:
      context - the plugin context
      rLayer - the RasterImageLayer to export
      path - the path to export to
    • ExportVectorProjection

      public static void ExportVectorProjection(PlugInContext context, Layer layer, String proj, String path) throws IOException
      Export .prj projection auxiliary file for vector/image layer
      Parameters:
      context - the plugin context
      layer - the layer to export
      proj - OGC wkt projection code
      path - the path to export to
      Throws:
      IOException - if an IOException occurs during export
    • ExportRasterProjection

      public static void ExportRasterProjection(PlugInContext context, RasterImageLayer layer, String proj, String path) throws IOException
      Export .prj projection auxiliary file for sextante raster image
      Parameters:
      context - the plugin context
      layer - the rasterImageLayer
      proj - OGC wkt projection code
      path - the path to export to
      Throws:
      IOException - if an IOException occurs during export
    • copyWorldFile

      public static void copyWorldFile(Layer layer, String path) throws IOException
      Simple method to copy a file (as worldfile)
      Parameters:
      layer - the image layer whose worldfile we want to copy
      path - the path to copy to
      Throws:
      IOException - if an IOException occurs during world file writing
    • filepath

      public static String filepath(Layer layer)
      Return the path of the file associated to a ReferencedImage layer /* EX. c:\folder\image.tif
      Parameters:
      layer - the Layer whose file path we want to know
      Returns:
      file path of the Layer
    • worldFilepath

      public static String worldFilepath(Layer layer)
      Return path/name of a worldfile associated to a ReferencedImage layer /* Ex. if c:\folder\image.tif exists, it returns c:\folder\image.tfw
      Parameters:
      layer - the layer whose worldfile path we want to know
      Returns:
      the path of the worldfile associated to the layer
    • getValidArea

      public static double getValidArea(Layer layer)
      Returns the area of feature collection (only Polygons or MultiPolygons) in the selected Vector Layer.class. This method exclude area of the layer which are not covered by feature
      Parameters:
      layer - a Layer
      Returns:
      area as a double
    • getValidArea

      public static double getValidArea(RasterImageLayer layer) throws IOException
      Returns the area of selected RasterImageLayer.class. This method excludes cells with no data value
      Parameters:
      layer - RasterImageLayer
      Returns:
      area as a double
      Throws:
      IOException
    • main

      public static void main(String[] args)