use of org.opengis.coverage.PointOutsideCoverageException in project OpenTripPlanner by opentripplanner.
the class UnifiedGridCoverage method evaluate.
public double[] evaluate(DirectPosition point, double[] values) throws PointOutsideCoverageException, CannotEvaluateException {
for (Coverage region : regions) {
// GeneralEnvelope has a contains method, OpenGIS Envelope does not
GeneralEnvelope env = ((GeneralEnvelope) region.getEnvelope());
// especially important when there are many regions.
if (env.contains(point)) {
double[] result;
double x = point.getOrdinate(0);
double y = point.getOrdinate(1);
try {
result = region.evaluate(point, values);
// TODO It might be faster to put all the datums and Coverage regions into a spatial index instead of iterating.
for (VerticalDatum datum : datums) {
if (datum.covers(x, y)) {
result[0] += datum.interpolatedHeight(x, y);
return result;
}
}
// if we get here, all vdatums failed.
log.error("Failed to convert elevation at " + y + ", " + x + " from NAVD88 to NAD83");
} catch (PointOutsideCoverageException e) {
continue;
}
return result;
}
}
/* not found */
log.warn("Point not found: " + point);
return null;
}
Aggregations