Search in sources :

Example 1 with BearingEngine

use of cl.smartcities.isci.transportinspector.map.engine.BearingEngine in project androidApp by InspectorIncognito.

the class BusUserPlugin method setOnBus.

private void setOnBus() {
    final GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
    if (locationGeoJsonSource == null) {
        return;
    }
    this.directionDetectionEngine = new DirectionEngine(10, currentUserBus.getService());
    ArrayList<IconBuilder> buildingList = new ArrayList<>();
    buildingList.add(new UserBusIconsBuilder(currentUserBus).toBuilder());
    GenerateViewIconTask task = new GenerateViewIconTask(new GenerateViewIconTask.ImageLoaderListener() {

        @Override
        public void onImageGenResult(HashMap<String, View> viewMap, HashMap<String, Bitmap> bitmapHashMap) {
            if (mapboxMap != null) {
                mapboxMap.addImages(bitmapHashMap);
            } else {
                return;
            }
            BearingEngine.Orientation orientation;
            if (currentUserBus.isFlipped()) {
                userLocationFeature.addStringProperty(LocationLayerConstants.PROPERTY_ORIENTATION, "LEFT");
                orientation = BearingEngine.Orientation.Left;
            } else {
                userLocationFeature.addStringProperty(LocationLayerConstants.PROPERTY_ORIENTATION, "RIGHT");
                orientation = BearingEngine.Orientation.Right;
            }
            userLocationFeature.addBooleanProperty(LocationLayerConstants.PROPERTY_ON_BUS, true);
            bearingEngine = new BearingEngine(mapboxMap, previousPoint, orientation);
            if (currentUserBus.getDirection() != null && !currentUserBus.getDirection().isEmpty()) {
                onBusEngine.setOnBus(currentUserBus);
            }
            locationGeoJsonSource.setGeoJson(userLocationFeature);
            mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(MapboxUtil.convertToLatLng(userLocationFeature)));
        }
    }, viewMap, buildingList);
    task.execute();
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) GenerateViewIconTask(cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask) DirectionEngine(cl.smartcities.isci.transportinspector.map.engine.DirectionEngine) IconBuilder(cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder) ArrayList(java.util.ArrayList) UserBusIconsBuilder(cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder) MapView(com.mapbox.mapboxsdk.maps.MapView) View(android.view.View) Bitmap(android.graphics.Bitmap) BearingEngine(cl.smartcities.isci.transportinspector.map.engine.BearingEngine)

Aggregations

Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 BearingEngine (cl.smartcities.isci.transportinspector.map.engine.BearingEngine)1 DirectionEngine (cl.smartcities.isci.transportinspector.map.engine.DirectionEngine)1 UserBusIconsBuilder (cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder)1 IconBuilder (cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder)1 GenerateViewIconTask (cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask)1 MapView (com.mapbox.mapboxsdk.maps.MapView)1 GeoJsonSource (com.mapbox.mapboxsdk.style.sources.GeoJsonSource)1 ArrayList (java.util.ArrayList)1