use of org.geotools.geometry.GeneralEnvelope in project polymap4-core by Polymap4.
the class RasterRenderProcessor method getBoundsRequest.
@Override
public void getBoundsRequest(GetBoundsRequest request, ProcessorContext context) throws Exception {
GeneralEnvelope envelope = reader.getOriginalEnvelope();
if (envelope != null) {
context.sendResponse(new GetBoundsResponse(new ReferencedEnvelope(envelope)));
return;
}
CoordinateReferenceSystem crs = reader.getCoordinateReferenceSystem();
if (crs != null) {
context.sendResponse(new GetBoundsResponse(new ReferencedEnvelope(crs)));
return;
}
throw new IllegalStateException("No bounds founds.");
}
use of org.geotools.geometry.GeneralEnvelope 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