Search in sources :

Example 1 with UserBusIconsBuilder

use of cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder 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)

Example 2 with UserBusIconsBuilder

use of cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder in project androidApp by InspectorIncognito.

the class BusUserPlugin method setBusAvatarId.

public void setBusAvatarId(int busAvatarId) {
    if (currentUserBus == null) {
        return;
    }
    currentUserBus.setAvatarId(busAvatarId);
    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;
            }
            GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
            if (locationGeoJsonSource != null) {
                locationGeoJsonSource.setGeoJson(userLocationFeature);
            }
        }
    }, viewMap, buildingList);
    task.execute();
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) GenerateViewIconTask(cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask) 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)

Example 3 with UserBusIconsBuilder

use of cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder in project androidApp by InspectorIncognito.

the class BusUserPlugin method updateUserEvents.

public void updateUserEvents(ArrayList<ServerSentEvent> newEvents, String reporterId) {
    if (currentUserBus != null && reporterId.equals(currentUserBus.getId())) {
        currentUserBus.setEvents(newEvents);
        final GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
        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) {
                mapboxMap.addImages(bitmapHashMap);
                if (locationGeoJsonSource != null) {
                    locationGeoJsonSource.setGeoJson(userLocationFeature);
                }
            }
        }, viewMap, buildingList);
        task.execute();
    }
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) GenerateViewIconTask(cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask) 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)

Aggregations

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