Skip to content

Commit

Permalink
rework raster API method #2066
Browse files Browse the repository at this point in the history
  • Loading branch information
abyrd committed Jul 31, 2015
1 parent 71f0b8c commit b9ed7ad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 77 deletions.
76 changes: 0 additions & 76 deletions src/main/java/org/opentripplanner/api/resource/Raster.java

This file was deleted.

Expand Up @@ -16,6 +16,8 @@
import org.opentripplanner.api.common.ParameterException; import org.opentripplanner.api.common.ParameterException;
import org.opentripplanner.api.common.RoutingResource; import org.opentripplanner.api.common.RoutingResource;
import org.opentripplanner.api.model.TimeSurfaceShort; import org.opentripplanner.api.model.TimeSurfaceShort;
import org.opentripplanner.api.parameter.CRSParameter;
import org.opentripplanner.api.parameter.IsoTimeParameter;
import org.opentripplanner.api.parameter.Layer; import org.opentripplanner.api.parameter.Layer;
import org.opentripplanner.api.parameter.MIMEImageFormat; import org.opentripplanner.api.parameter.MIMEImageFormat;
import org.opentripplanner.api.parameter.Style; import org.opentripplanner.api.parameter.Style;
Expand Down Expand Up @@ -262,4 +264,33 @@ public static List<IsochroneData> getIsochronesAccumulative(TimeSurface surf, in
return isochrones; return isochrones;
} }


/**
* Produce a single grayscale raster of travel time, like travel time tiles but not broken into tiles.
*/
@Path("/{surfaceId}/raster")
@GET @Produces("image/*")
public Response getRaster(
@PathParam("surfaceId") Integer surfaceId,
@QueryParam("width") @DefaultValue("1024") Integer width,
@QueryParam("height") @DefaultValue("768") Integer height,
@QueryParam("resolution") Double resolution,
@QueryParam("time") IsoTimeParameter time,
@QueryParam("format") @DefaultValue("image/geotiff") MIMEImageFormat format,
@QueryParam("crs") @DefaultValue("EPSG:4326") CRSParameter crs) throws Exception {

TimeSurface surface = otpServer.surfaceCache.get(surfaceId);
Router router = otpServer.getRouter(surface.routerId);
// BoundingBox is a subclass of Envelope, an Envelope2D constructor parameter
Envelope2D bbox = new Envelope2D(router.graph.getGeomIndex().getBoundingBox(crs.crs));
if (resolution != null) {
width = (int) Math.ceil(bbox.width / resolution);
height = (int) Math.ceil(bbox.height / resolution);
}

TileRequest tileRequest = new TileRequest(bbox, width, height);
RenderRequest renderRequest = new RenderRequest(format, Layer.TRAVELTIME, Style.GRAY, false, false);
return router.renderer.getResponse(tileRequest, surface, null, renderRequest);
}


} }
Expand Up @@ -83,7 +83,6 @@ public Set<Class<?>> getClasses() {
PlannerResource.class, PlannerResource.class,
SIsochrone.class, SIsochrone.class,
Routers.class, Routers.class,
Raster.class,
LegendResource.class, LegendResource.class,
ProfileResource.class, ProfileResource.class,
SimpleIsochrone.class, SimpleIsochrone.class,
Expand Down

0 comments on commit b9ed7ad

Please sign in to comment.