Class GrassLegacyUtilities
- java.lang.Object
-
- org.hortonmachine.gears.io.grasslegacy.utils.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
-
-
Constructor Summary
Constructors Constructor Description GrassLegacyUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImageByteBufferImage(byte[] data, int width, int height)create a buffered image from a set of color tripletsstatic booleancheckRasterMapConsistence(String mapsetPath, String mapname)Returns the list of files involved in the raster map issues.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 *static intfactorial(int n)static String[]filesOfRasterMap(String mapsetPath, String mapname)Returns the list of files involved in the raster map issues.static ColorgetColor(String clr, Color defclr)static int[]getColorTripletByIndex(int index)static WindowgetRectangleAroundPoint(Window activeRegion, double x, double y)return the rectangle of the cell of the active region, that surrounds the given coordinatesstatic WindowjgrassRegion2legacyWindow(org.geotools.gce.grassraster.JGrassRegion region)static intnumberOfAvailableColors()static voidrasterizePolygonGeometry(Window active, org.locationtech.jts.geom.Geometry polygon, RasterData raster, RasterData rasterToMap, double value, IHMProgressMonitor monitor)Fill polygon areas mapping on a rasterstatic booleanremoveGrassRasterMap(String mapsetPath, String mapName)Given the mapsetpath and the mapname, the map is removed with all its accessor filesstatic org.locationtech.jts.geom.EnvelopereprojectEnvelopeByEpsg(int srcEpsg, int destEpsg, org.locationtech.jts.geom.Envelope srcEnvelope)static org.locationtech.jts.geom.CoordinaterowColToCenterCoordinates(Window active, int row, int col)Transforms row and column index of the active region into the regarding northing and easting coordinates.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.
-
-
-
Field Detail
-
COLORS
public static final String[] COLORS
-
-
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 mapsetmapname- -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.FactoryExceptionorg.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 coordinatey- 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 transformcol- - 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 regioncoord-- 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 regionpolygon- the jts polygon geometryraster- the empty raster data to be filledrasterToMap- 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 givenmonitor-
-
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 mapsetmapname- -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 transformcol- - 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)
-
-