Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pass sampleSource into sampleList constructors

maybe replace eventually with a factory class or setter methods
  • Loading branch information...
commit a011ca28a645b6483673b478060e742b31aaf583 1 parent 5b40b12
@abyrd abyrd authored
View
8 opentripplanner-analyst/src/main/java/org/opentripplanner/analyst/batch/AbstractPopulation.java
@@ -1,5 +1,7 @@
package org.opentripplanner.analyst.batch;
+import org.opentripplanner.analyst.core.SampleSource;
+
import lombok.Getter;
public abstract class AbstractPopulation implements Population {
@@ -20,11 +22,11 @@ public AbstractPopulation (IndividualList il, SampleList sl) {
}
public AbstractPopulation (SampleList sl) {
- this(null,sl);
+ this(null, sl);
}
- public AbstractPopulation (IndividualList il) {
- this(il, new IndividualBackedSampleList(il));
+ public AbstractPopulation (IndividualList il, SampleSource ss) {
+ this(il, new IndividualBackedSampleList(il, ss));
}
@Override
View
6 opentripplanner-analyst/src/main/java/org/opentripplanner/analyst/batch/IndividualBackedSampleList.java
@@ -4,7 +4,6 @@
import org.opentripplanner.analyst.core.Sample;
import org.opentripplanner.analyst.core.SampleSource;
-import org.springframework.beans.factory.annotation.Autowired;
/**
* A dynamic SampleList which builds samples based on an IndividualList.
@@ -12,16 +11,17 @@
public class IndividualBackedSampleList implements SampleList {
IndividualList individualList;
+ SampleSource ss;
- public IndividualBackedSampleList(IndividualList individualList) {
+ public IndividualBackedSampleList(IndividualList individualList, SampleSource ss) {
this.individualList = individualList;
+ this.ss = ss;
}
@Override
public Iterator<Sample> iterator() {
return new Iterator<Sample>() {
- @Autowired SampleSource ss;
Iterator<Individual> ii = individualList.iterator();
@Override
View
12 opentripplanner-analyst/src/main/java/org/opentripplanner/analyst/core/RasterPopulation.java
@@ -40,19 +40,19 @@
*/
final GridGeometry2D gg; // maps grid coordinates to CRS coordinates
- public RasterPopulation(GridGeometry2D gg) {
- super(new RasterSampleList(gg));
+ public RasterPopulation(GridGeometry2D gg, SampleSource ss) {
+ super(new RasterSampleList(gg, ss));
this.gg = gg;
LOG.debug("tile for {}", gg);
}
- public RasterPopulation(Envelope2D bbox, int width, int height) {
+ public RasterPopulation(Envelope2D bbox, int width, int height, SampleSource ss) {
this( new GridGeometry2D( new GridEnvelope2D(0, 0, width, height),
- (org.opengis.geometry.Envelope)(bbox)));
+ (org.opengis.geometry.Envelope)(bbox)), ss);
}
- public RasterPopulation(GridCoverage2D coverage) {
- super(new GridCoverageIndividualList(coverage));
+ public RasterPopulation(GridCoverage2D coverage, SampleSource ss) {
+ super(new GridCoverageIndividualList(coverage), ss);
this.gg = coverage.getGridGeometry();
}
View
8 opentripplanner-analyst/src/main/java/org/opentripplanner/analyst/core/RasterSampleList.java
@@ -15,6 +15,9 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import com.sun.jersey.api.spring.Autowire;
+import com.sun.jersey.spi.inject.Inject;
+
/**
* Produces samples from a regular grid of the given size in the given spatial reference system,
* Samples are produced in row-major order.
@@ -31,12 +34,13 @@
int width;
int height;
MathTransform tr = null;
- @Autowired SampleSource ss;
+ SampleSource ss;
- public RasterSampleList (GridGeometry2D gg) {
+ public RasterSampleList (GridGeometry2D gg, SampleSource ss) {
this.gg = gg;
this.width = gg.getGridRange2D().width;
this.height = gg.getGridRange2D().height;
+ this.ss = ss;
crs = gg.getCoordinateReferenceSystem2D();
try {
tr = CRS.findMathTransform(crs, DefaultGeographicCRS.WGS84);
View
4 opentripplanner-analyst/src/main/java/org/opentripplanner/analyst/core/SlippyTile.java
@@ -8,8 +8,8 @@
final int x, y, z;
- public SlippyTile(int x, int y, int z) {
- super(tile2Envelope(x, y, z), 256, 256);
+ public SlippyTile(int x, int y, int z, SampleSource ss) {
+ super(tile2Envelope(x, y, z), 256, 256, ss);
this.x = x;
this.y = y;
this.z = z;
View
8 opentripplanner-api-webapp/src/main/java/org/opentripplanner/api/ws/analyst/TileService.java
@@ -8,6 +8,7 @@
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
+import org.opentripplanner.analyst.core.SampleSource;
import org.opentripplanner.analyst.core.SlippyTile;
import org.opentripplanner.analyst.core.RasterPopulation;
import org.opentripplanner.analyst.parameter.Layer;
@@ -21,6 +22,7 @@
import org.opentripplanner.routing.core.RoutingRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import com.sun.jersey.api.core.InjectParam;
import com.sun.jersey.api.spring.Autowire;
@@ -35,6 +37,9 @@
@InjectParam
private Renderer renderer;
+ @Autowired
+ private SampleSource ss;
+
@PathParam("x") int x;
@PathParam("y") int y;
@PathParam("z") int z;
@@ -43,10 +48,11 @@
@QueryParam("styles") @DefaultValue("color30") StyleList styles;
@QueryParam("format") @DefaultValue("image/png") MIMEImageFormat format;
+
@GET @Produces("image/*")
public Response tileGet() throws Exception {
- RasterPopulation tileRequest = new SlippyTile(x, y, z);
+ RasterPopulation tileRequest = new SlippyTile(x, y, z, ss);
RoutingRequest sptRequestA = buildRequest(0);
RoutingRequest sptRequestB = buildRequest(1);
Please sign in to comment.
Something went wrong with that request. Please try again.