public boolean fulfillDemands(TransitStop ts, Graph graph) {
if (graph.streetIndex == null) {
graph.streetIndex = new StreetVertexIndexServiceImpl(graph);
LOG.debug("street index built.");
}
StreetVertexIndexService streetIndexService = graph.streetIndex;
DistanceLibrary distanceLibrary;
if (streetIndexService instanceof StreetVertexIndexServiceImpl) {
distanceLibrary = ((StreetVertexIndexServiceImpl) streetIndexService).distanceLibrary;
} else {
distanceLibrary = SphericalDistanceLibrary.getInstance();
}
Envelope env = new Envelope(ts.getCoordinate());
double rInMeters;
if (distanceLibrary instanceof SphericalDistanceLibrary) {
rInMeters = SphericalDistanceLibrary.RADIUS_OF_EARTH_IN_M;
} else {
rInMeters = 6371.01 * 1000;
}
double degForOneMeter = (Math.PI / (180 * rInMeters));
double disInDeg = degForOneMeter * distance;
env.expandBy(disInDeg);
Collection<Edge> edges = streetIndexService.getEdgesForEnvelope(env);
int counter = 0;
for (Edge edge : edges) {
if (edge instanceof StreetEdge) {
StreetEdge streetEdge = (StreetEdge) edge;