Class GrassLegacyUtilities


  • public class GrassLegacyUtilities
    extends Object

    A facade of often used methods by the JGrass engine

    Since:
    1.1.0
    Author:
    Andrea Antonello - www.hydrologis.com
    • Field Detail

      • COLORS

        public static final String[] COLORS
    • Constructor Detail

      • GrassLegacyUtilities

        public GrassLegacyUtilities()
    • Method Detail

      • numberOfAvailableColors

        public static int numberOfAvailableColors()
      • getColorTripletByIndex

        public static int[] getColorTripletByIndex​(int index)
      • checkRasterMapConsistence

        public static boolean checkRasterMapConsistence​(String mapsetPath,
                                                        String mapname)
        Returns the list of files involved in the raster map issues. If for example a map has to be deleted, then all these files have to.
        Parameters:
        mapsetPath - - the path of the mapset
        mapname - -the name of the map
        Returns:
        the array of strings containing the full path to the involved files
      • ByteBufferImage

        public static BufferedImage ByteBufferImage​(byte[] data,
                                                    int width,
                                                    int height)
        create a buffered image from a set of color triplets
        Parameters:
        data -
        width -
        height -
        Returns:
      • reprojectEnvelopeByEpsg

        public static org.locationtech.jts.geom.Envelope reprojectEnvelopeByEpsg​(int srcEpsg,
                                                                                 int destEpsg,
                                                                                 org.locationtech.jts.geom.Envelope srcEnvelope)
                                                                          throws org.opengis.referencing.FactoryException,
                                                                                 org.opengis.referencing.operation.TransformException
        Throws:
        org.opengis.referencing.FactoryException
        org.opengis.referencing.operation.TransformException
      • getRectangleAroundPoint

        public static Window getRectangleAroundPoint​(Window activeRegion,
                                                     double x,
                                                     double y)
        return the rectangle of the cell of the active region, that surrounds the given coordinates
        Parameters:
        activeRegion -
        x - the given easting coordinate
        y - given northing coordinate
        Returns:
        the rectangle localizing the cell inside which the x and y stay
      • rowColToCenterCoordinates

        public static org.locationtech.jts.geom.Coordinate rowColToCenterCoordinates​(Window active,
                                                                                     int row,
                                                                                     int col)

        Transforms row and column index of the active region into the regarding northing and easting coordinates. The center of the cell is taken.

        NOTE: basically the inverse of coordinateToNearestRowCol(Window, Coordinate)

        Parameters:
        active - - the active region (can be null)
        row - - row number of the point to transform
        col - - column number of the point to transform
        Returns:
        the point in N/E coordinates of the supplied row and column
      • coordinateToNearestRowCol

        public static int[] coordinateToNearestRowCol​(Window active,
                                                      org.locationtech.jts.geom.Coordinate coord)

        Return the row and column of the active region matrix for a give coordinate *

        NOTE: basically the inverse of rowColToCenterCoordinates(Window, int, int)

        Parameters:
        active - the active region
        coord -
        Returns:
        and int array containing row and col
      • rasterizePolygonGeometry

        public static void rasterizePolygonGeometry​(Window active,
                                                    org.locationtech.jts.geom.Geometry polygon,
                                                    RasterData raster,
                                                    RasterData rasterToMap,
                                                    double value,
                                                    IHMProgressMonitor monitor)
        Fill polygon areas mapping on a raster
        Parameters:
        active - the active region
        polygon - the jts polygon geometry
        raster - the empty raster data to be filled
        rasterToMap - the map from which the values to fill raster are taken (if null, the value parameter is used)
        value - the value to set if a second map is not given
        monitor -
      • removeGrassRasterMap

        public static boolean removeGrassRasterMap​(String mapsetPath,
                                                   String mapName)
                                            throws IOException
        Given the mapsetpath and the mapname, the map is removed with all its accessor files
        Parameters:
        mapsetPath -
        mapName -
        Throws:
        IOException
      • filesOfRasterMap

        public static String[] filesOfRasterMap​(String mapsetPath,
                                                String mapname)
        Returns the list of files involved in the raster map issues. If for example a map has to be deleted, then all these files have to.
        Parameters:
        mapsetPath - - the path of the mapset
        mapname - -the name of the map
        Returns:
        the array of strings containing the full path to the involved files
      • rowColToNodeboundCoordinates

        public static double[] rowColToNodeboundCoordinates​(Window active,
                                                            int row,
                                                            int col)
        Transforms row and column index of the active region into an array of the coordinates of the edgaes, i.e. n, s, e, w
        Parameters:
        active - - the active region (can be null)
        row - - row number of the point to transform
        col - - column number of the point to transform
        Returns:
        the array of north, south, east, west
      • factorial

        public static int factorial​(int n)
      • jgrassRegion2legacyWindow

        public static Window jgrassRegion2legacyWindow​(org.geotools.gce.grassraster.JGrassRegion region)