use of javax.media.jai.InterpolationBilinear in project OpenTripPlanner by opentripplanner.
the class ElevationModule method buildGraph.
@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
gridCoverageFactory.setGraph(graph);
Coverage gridCov = gridCoverageFactory.getGridCoverage();
// If gridCov is a GridCoverage2D, apply a bilinear interpolator. Otherwise, just use the
// coverage as is (note: UnifiedGridCoverages created by NEDGridCoverageFactoryImpl handle
// interpolation internally)
coverage = (gridCov instanceof GridCoverage2D) ? Interpolator2D.create((GridCoverage2D) gridCov, new InterpolationBilinear()) : gridCov;
log.info("Setting street elevation profiles from digital elevation model...");
List<StreetEdge> edgesWithElevation = new ArrayList<StreetEdge>();
int nProcessed = 0;
int nTotal = graph.countEdges();
for (Vertex gv : graph.getVertices()) {
for (Edge ee : gv.getOutgoing()) {
if (ee instanceof StreetWithElevationEdge) {
StreetWithElevationEdge edgeWithElevation = (StreetWithElevationEdge) ee;
processEdge(graph, edgeWithElevation);
if (edgeWithElevation.getElevationProfile() != null && !edgeWithElevation.isElevationFlattened()) {
edgesWithElevation.add(edgeWithElevation);
}
nProcessed += 1;
if (nProcessed % 50000 == 0) {
log.info("set elevation on {}/{} edges", nProcessed, nTotal);
double failurePercentage = nPointsOutsideDEM / nPointsEvaluated * 100;
if (failurePercentage > 50) {
log.warn("Fetching elevation failed at {}/{} points ({}%)", nPointsOutsideDEM, nPointsEvaluated, failurePercentage);
log.warn("Elevation is missing at a large number of points. DEM may be for the wrong region. " + "If it is unprojected, perhaps the axes are not in (longitude, latitude) order.");
}
}
}
}
}
@SuppressWarnings("unchecked") HashMap<Vertex, Double> extraElevation = (HashMap<Vertex, Double>) extra.get(ElevationPoint.class);
assignMissingElevations(graph, edgesWithElevation, extraElevation);
}
use of javax.media.jai.InterpolationBilinear in project sldeditor by robward-scisys.
the class InterpolationValues method setValue.
/*
* (non-Javadoc)
*
* @see
* com.sldeditor.rendertransformation.types.RenderTransformValueInterface#setValue(java.lang.
* Object)
*/
@Override
public void setValue(Object aValue) {
this.value = null;
this.expression = null;
if (aValue instanceof LiteralExpressionImpl) {
String displayName = ((Expression) aValue).toString();
if (InterpolationNearest.class.getSimpleName().compareTo(displayName) == 0) {
value = new InterpolationNearest();
} else if (InterpolationBilinear.class.getSimpleName().compareTo(displayName) == 0) {
value = new InterpolationBilinear();
} else if (displayName.startsWith(InterpolationBicubic2.class.getSimpleName())) {
sampleBits = extractSampleBits(INTERPOLATION_BICUBIC2_PATTERN_MATCH, displayName);
value = new InterpolationBicubic2(sampleBits);
} else if (displayName.startsWith(InterpolationBicubic.class.getSimpleName())) {
sampleBits = extractSampleBits(INTERPOLATION_BICUBIC_PATTERN_MATCH, displayName);
value = new InterpolationBicubic(sampleBits);
}
} else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
this.expression = (Expression) aValue;
}
}
use of javax.media.jai.InterpolationBilinear in project OpenTripPlanner by opentripplanner.
the class NEDGridCoverageFactoryImpl method getGridCoverage.
/**
* @return a GeoTools grid coverage for the entire area of interest, lazy-creating it on the first call.
*/
public Coverage getGridCoverage() {
if (unifiedCoverage == null) {
loadVerticalDatum();
tileSource.setGraph(graph);
tileSource.setCacheDirectory(cacheDirectory);
List<File> paths = tileSource.getNEDTiles();
// Make one grid coverage for each NED tile, adding them all to a single UnifiedGridCoverage.
for (File path : paths) {
GeotiffGridCoverageFactoryImpl factory = new GeotiffGridCoverageFactoryImpl(path);
// TODO might bicubic interpolation give better results?
GridCoverage2D regionCoverage = Interpolator2D.create(factory.getGridCoverage(), new InterpolationBilinear());
if (unifiedCoverage == null) {
unifiedCoverage = new UnifiedGridCoverage("unified", regionCoverage, datums);
} else {
unifiedCoverage.add(regionCoverage);
}
}
}
return unifiedCoverage;
}
Aggregations