use of org.geotools.coverage.grid.GridEnvelope2D in project sldeditor by robward-scisys.
the class RasterReader method createRGBImageSymbol.
/**
* Creates the rgb image symbol.
*
* @param sym the sym
* @param cov the cov
* @param raster the raster
*/
private void createRGBImageSymbol(RasterSymbolizer sym, GridCoverage2D cov, WritableRaster raster) {
double dest;
List<Double> valueList = new ArrayList<Double>();
GridEnvelope2D gridRange2D = cov.getGridGeometry().getGridRange2D();
for (int x = 0; x < gridRange2D.getWidth(); x++) {
for (int y = 0; y < gridRange2D.getHeight(); y++) {
try {
dest = raster.getSampleDouble(x, y, 0);
if (!valueList.contains(dest)) {
valueList.add(dest);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
ColorMapImpl colourMap = new ColorMapImpl();
// Sort the unique sample values in ascending order
Collections.sort(valueList);
// Create colour amp entries in the colour map for all the sample values
for (Double value : valueList) {
ColorMapEntry entry = new ColorMapEntryImpl();
Literal colourExpression = ff.literal(ColourUtils.fromColour(ColourUtils.createRandomColour()));
entry.setColor(colourExpression);
entry.setQuantity(ff.literal(value.doubleValue()));
colourMap.addColorMapEntry(entry);
}
colourMap.setType(ColorMap.TYPE_VALUES);
sym.setColorMap(colourMap);
}
use of org.geotools.coverage.grid.GridEnvelope2D in project OpenTripPlanner by opentripplanner.
the class SyntheticRasterPopulation method createIndividuals.
@Override
public void createIndividuals() {
try {
coverageCRS = CRS.decode(crsCode, true);
} catch (Exception e) {
LOG.error("error decoding coordinate reference system code.", e);
return;
}
if (boundsFromGraph) {
// autowire graph service or pass in
}
gridEnvelope = new GridEnvelope2D(0, 0, cols, rows);
refEnvelope = new ReferencedEnvelope(left, right, bottom, top, coverageCRS);
gridGeometry = new GridGeometry2D(gridEnvelope, refEnvelope);
super.createIndividuals0();
}
Aggregations