use of cl.smartcities.isci.transportinspector.database.GridHelper in project androidApp by InspectorIncognito.
the class BusStopPlugin method setupData.
private void setupData() {
if (mapboxMap == null) {
return;
}
GridHelper helper = new GridHelper(getContext());
List<BusStop> busStops = helper.getNearBusStops(mapboxMap.getCameraPosition().target.getLatitude(), mapboxMap.getCameraPosition().target.getLongitude());
helper.close();
onBusEngine.setBusStops(busStops);
List<Feature> markerCoordinates = new ArrayList<>();
for (BusStop busStop : busStops) {
markerCoordinates.add(new BusStopMarker(busStop));
}
busStopFeatures = FeatureCollection.fromFeatures(markerCoordinates);
busesFeatures = FeatureCollection.fromFeatures(new Feature[] {});
busRouteStartFeature = FeatureCollection.fromFeatures(new Feature[] {});
busRouteEndFeature = FeatureCollection.fromFeatures(new Feature[] {});
setupBusRouteSource();
setupBusRouteLayer();
setupBusStopSource();
setupBusStopLayer();
setupBusSource();
setupBusLayer();
}
use of cl.smartcities.isci.transportinspector.database.GridHelper in project androidApp by InspectorIncognito.
the class DirectionEngine method getDetectedDirection.
public String getDetectedDirection(Location newLocation) {
GridHelper helper = new GridHelper(TranSappApplication.getAppContext());
if (previousLocation == null) {
Pair<List<RouteSegment>, List<RouteSegment>> segments = helper.getRouteSegmentInGrid(service, newLocation);
previousISegment = getNearestRouteSegment(newLocation, segments.first);
previousRSegment = getNearestRouteSegment(newLocation, segments.second);
previousLocation = newLocation;
return null;
}
Pair<List<RouteSegment>, List<RouteSegment>> segments = helper.getRouteSegmentInGrid(service, newLocation);
RouteSegment routeISegment = getNearestRouteSegment(newLocation, segments.first);
RouteSegment routeRSegment = getNearestRouteSegment(newLocation, segments.second);
iScores.add(getSegmentScore(previousISegment, routeISegment, previousLocation, newLocation));
rScores.add(getSegmentScore(previousRSegment, routeRSegment, previousLocation, newLocation));
Log.d("DirectionEngine", "i score: " + sumScore(iScores));
Log.d("DirectionEngine", "r score: " + sumScore(rScores));
Log.d("DirectionEngine", "--");
if (iScores.size() > neededScores) {
double iScore = (sumScore(iScores) * 1.0) / neededScores;
double rScore = (sumScore(rScores) * 1.0) / neededScores;
if (iScore >= 0.7 && rScore <= 0.3) {
return "I";
}
if (rScore >= 0.7 && iScore <= 0.3) {
return "R";
}
rScores.removeFirst();
iScores.removeFirst();
}
previousISegment = routeISegment;
previousRSegment = routeRSegment;
previousLocation = newLocation;
return null;
}
use of cl.smartcities.isci.transportinspector.database.GridHelper in project androidApp by InspectorIncognito.
the class CameraMoveHandler method getNearBusStops.
private List<BusStop> getNearBusStops(double latitude, double longitude) {
Context context = this.context.get();
if (context == null)
return null;
GridHelper helper = new GridHelper(context);
List<BusStop> busStops = helper.getNearBusStops(latitude, longitude);
helper.close();
return busStops;
}
Aggregations