Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stops within bounding box fix #253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions app/datastore/AgencyTx.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,35 @@ public Collection<Stop> getStopsWithinBoundingBox (double north, double east, do
Tuple2<Double, Double> min = new Tuple2<Double, Double>(west, south);
Tuple2<Double, Double> max = new Tuple2<Double, Double>(east, north);

Set<Tuple2<Tuple2<Double, Double>, String>> matchedKeys =
stopsGix.subSet(new Tuple2(min, null), new Tuple2(max, Fun.HI));

Collection<Stop> matchedStops =
Collections2.transform(matchedKeys, new Function<Tuple2<Tuple2<Double, Double>, String>, Stop> () {

@Override
public Stop apply(
Tuple2<Tuple2<Double, Double>, String> input) {
return stops.get(input.b);
}
});
Set<Tuple2<Tuple2<Double, Double>, String>> matchedKeys
= stopsGix.subSet(new Tuple2(min, null), new Tuple2(max, Fun.HI));

List<Stop> matchedStops = new ArrayList<Stop>();

for (Tuple2<Tuple2<Double, Double>, String> value : matchedKeys) {
Tuple2<Double, Double> lonLat = value.a;
if (lonLat.a >= west &&
lonLat.a <= east &&
lonLat.b >= south &&
lonLat.b <= north
) {
Stop mStop = stops.get(value.b);
matchedStops.add(mStop);
}
}

/*
Collection<Stop> matchedStops
= Collections2.transform(matchedKeys, new Function<Tuple2<Tuple2<Double, Double>, String>, Stop>() {

@Override
public Stop apply(
Tuple2<Tuple2<Double, Double>, String> input) {
return stops.get(input.b);
}
});*/

return matchedStops;
return matchedStops;
}

public Collection<TripPattern> getTripPatternsByStop (String id) {
Expand Down Expand Up @@ -480,4 +495,4 @@ public Tuple2<String, ScheduleException> apply(Tuple2<String, ScheduleException>
throw new RuntimeException(e);
}
}
}
}