Search in sources :

Example 1 with GridHelper

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();
}
Also used : GridHelper(cl.smartcities.isci.transportinspector.database.GridHelper) ArrayList(java.util.ArrayList) BusStopMarker(cl.smartcities.isci.transportinspector.map.model.busStop.BusStopMarker) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop) Feature(com.mapbox.services.commons.geojson.Feature)

Example 2 with GridHelper

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;
}
Also used : GridHelper(cl.smartcities.isci.transportinspector.database.GridHelper) List(java.util.List) LinkedList(java.util.LinkedList) RouteSegment(cl.smartcities.isci.transportinspector.map.model.RouteSegment)

Example 3 with GridHelper

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;
}
Also used : Context(android.content.Context) GridHelper(cl.smartcities.isci.transportinspector.database.GridHelper) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop)

Aggregations

GridHelper (cl.smartcities.isci.transportinspector.database.GridHelper)3 BusStop (cl.smartcities.isci.transportinspector.backend.BusStop)2 Context (android.content.Context)1 RouteSegment (cl.smartcities.isci.transportinspector.map.model.RouteSegment)1 BusStopMarker (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopMarker)1 Feature (com.mapbox.services.commons.geojson.Feature)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1