Search in sources :

Example 16 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopPlugin method addBusRoutePolyline.

@NonNull
private Polyline addBusRoutePolyline(ArrayList<LatLng> points, int colorId) {
    Feature startPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(points.get(0).getLongitude(), points.get(0).getLatitude())));
    Feature endPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(points.get(points.size() - 1).getLongitude(), points.get(points.size() - 1).getLatitude())));
    busRouteStartFeature = FeatureCollection.fromFeatures(new Feature[] { startPoint });
    busRouteEndFeature = FeatureCollection.fromFeatures(new Feature[] { endPoint });
    refreshSourceWithFeatures(busRouteStartSource, busRouteStartFeature);
    refreshSourceWithFeatures(busRouteEndSource, busRouteEndFeature);
    return mapboxMap.addPolyline(new PolylineOptions().addAll(points).color(ContextCompat.getColor(getContext(), colorId)).width(4));
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature) PolylineOptions(com.mapbox.mapboxsdk.annotations.PolylineOptions) NonNull(android.support.annotation.NonNull)

Example 17 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopPlugin method updateBusStopSource.

private void updateBusStopSource(List<BusStop> busStops) {
    List<Feature> markerCoordinates = new ArrayList<>();
    boolean added = false;
    for (BusStop busStop : busStops) {
        if (selectedBusStop != null && selectedBusStop.getStringProperty(BusStopMarker.PROPERTY_ID).equals(busStop.getId())) {
            markerCoordinates.add(selectedBusStop);
            added = true;
        } else {
            markerCoordinates.add(new BusStopMarker(busStop));
        }
    }
    if (selectedBusStop != null && !added)
        markerCoordinates.add(selectedBusStop);
    busStopFeatures = FeatureCollection.fromFeatures(markerCoordinates);
    refreshBusStopSource();
}
Also used : 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 18 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopPlugin method updateSelectedBusStopIcons.

private void updateSelectedBusStopIcons() {
    ArrayList<IconBuilder> buildingList = new ArrayList<>();
    buildingList.add(new BusStopIconsBuilder(FeatureCollection.fromFeatures(new Feature[] { selectedBusStop })).toBuilder());
    final 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);
            }
            refreshBusStopSource();
        }
    }, viewMap, buildingList);
    task.execute();
}
Also used : GenerateViewIconTask(cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask) IconBuilder(cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder) ArrayList(java.util.ArrayList) Feature(com.mapbox.services.commons.geojson.Feature) View(android.view.View) Bitmap(android.graphics.Bitmap) BusStopIconsBuilder(cl.smartcities.isci.transportinspector.map.model.busStop.BusStopIconsBuilder)

Example 19 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopPlugin method deselectSelectedBusStop.

private void deselectSelectedBusStop(Feature newSelectedFeature) {
    if (newSelectedFeature != null && selectedBusStop != null && !newSelectedFeature.getId().equals(selectedBusStop.getId())) {
        Log.d(BusStopPlugin.class.getSimpleName(), "deselect previous selected bus stop");
        return;
    }
    listener.onFocusCleared();
    if (selectedBus != null) {
        deselectSelectedBusFeature();
    }
    if (selectedBusStop != null) {
        selectedBusStop.addBooleanProperty(BusStopMarker.PROPERTY_LOADING, false);
        selectedBusStop.addBooleanProperty(BusStopMarker.PROPERTY_SELECTED, false);
        mapboxMap.removeImage(selectedBusStop.getStringProperty(BusStopMarker.PROPERTY_ID) + "-max");
        mapboxMap.removeImage(selectedBusStop.getStringProperty(BusStopMarker.PROPERTY_ID) + "-min");
    }
    for (Feature busFeature : busesFeatures.getFeatures()) {
        mapboxMap.removeImage(busFeature.getStringProperty(BusMarker.PROPERTY_ID) + "-max");
        mapboxMap.removeImage(busFeature.getStringProperty(BusMarker.PROPERTY_ID) + "-min");
        mapboxMap.removeImage(busFeature.getStringProperty(BusMarker.PROPERTY_ID) + "-left");
        mapboxMap.removeImage(busFeature.getStringProperty(BusMarker.PROPERTY_ID) + "-right");
    }
    busesFeatures = FeatureCollection.fromFeatures(new Feature[] {});
    if (periodicRequestHandler != null) {
        periodicRequestHandler.stopPeriodicRequest();
        periodicRequestHandler = null;
    }
    Log.d(BusStopPlugin.class.getSimpleName(), "selectedBusStop unassign");
    selectedBusStop = null;
    refreshBusStopSource();
    refreshBusSource();
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature)

Example 20 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopIconsBuilder method setIconsAndViews.

public void setIconsAndViews(LayoutInflater inflater, HashMap<String, Bitmap> imagesMap, HashMap<String, View> viewMap) {
    for (Feature feature : featureCollection.getFeatures()) {
        String id = feature.getStringProperty(Marker.PROPERTY_ID);
        BusStopMarker marker = (BusStopMarker) feature;
        BusStop busStop = marker.getBusStop();
        View view = inflater.inflate(R.layout.bus_stop_bubble, null);
        TextView code = view.findViewById(R.id.bubble_bus_stop_code);
        TextView name = view.findViewById(R.id.bubble_bus_stop_name);
        code.setText(id);
        name.setText(busStop.getName());
        AppCompatImageView favIcon = view.findViewById(R.id.fav_icon);
        final FavoriteHelper helper = new FavoriteHelper(view.getContext());
        boolean isFavorite = helper.isFavorite(busStop.getId());
        if (isFavorite) {
            favIcon.setColorFilter(ContextCompat.getColor(view.getContext(), R.color.yellow_fav));
        }
        List<ServerSentBus> buses = Bus.filterDummyPlates(busStop.getIncomingBuses());
        buses = ServerSentBus.orderBusesByDistance(buses);
        if (!buses.isEmpty()) {
            view.findViewById(R.id.bus_layout).setVisibility(View.VISIBLE);
            view.findViewById(R.id.bus_empty_layout).setVisibility(View.GONE);
            setupNearBusLayout(view, getNearestVisibleBus(buses, busStop));
        } else {
            view.findViewById(R.id.bus_layout).setVisibility(View.GONE);
            view.findViewById(R.id.bus_empty_layout).setVisibility(View.VISIBLE);
        }
        setEventLayout(view, marker.getEvents());
        Bitmap bitmap = GenerateViewIconTask.SymbolGenerator.generate(view);
        imagesMap.put(id + "-max", bitmap);
        viewMap.put("busStop-max", view);
        View viewMin = inflater.inflate(R.layout.bus_stop_minimize_bubble, null);
        TextView nameMin = viewMin.findViewById(R.id.bubble_bus_stop_code);
        nameMin.setText(id);
        ((ImageView) viewMin.findViewById(R.id.maximize)).setImageDrawable(new GreenButtonUp(viewMin.getContext()));
        imagesMap.put(id + "-min", GenerateViewIconTask.SymbolGenerator.generate(viewMin));
        viewMap.put("busStop-min", viewMin);
    }
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature) AppCompatImageView(android.support.v7.widget.AppCompatImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AppCompatImageView(android.support.v7.widget.AppCompatImageView) GreenButtonUp(cl.smartcities.isci.transportinspector.drawables.greenButton.GreenButtonUp) ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus) FavoriteHelper(cl.smartcities.isci.transportinspector.database.FavoriteHelper) Bitmap(android.graphics.Bitmap) TextView(android.widget.TextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) ImageView(android.widget.ImageView) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop)

Aggregations

Feature (com.mapbox.services.commons.geojson.Feature)26 ArrayList (java.util.ArrayList)13 BusStop (cl.smartcities.isci.transportinspector.backend.BusStop)8 BusStopMarker (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopMarker)7 Bitmap (android.graphics.Bitmap)4 NonNull (android.support.annotation.NonNull)4 View (android.view.View)4 BusMarker (cl.smartcities.isci.transportinspector.map.model.bus.BusMarker)4 ServerSentBus (cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)4 BusStopIconsBuilder (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopIconsBuilder)3 IconBuilder (cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder)3 GenerateViewIconTask (cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask)3 PolylineOptions (com.mapbox.mapboxsdk.annotations.PolylineOptions)3 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)3 PointF (android.graphics.PointF)2 FavoriteHelper (cl.smartcities.isci.transportinspector.database.FavoriteHelper)2 BusClickHandler (cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler)2 BusStopClickHandler (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopClickHandler)2 MultiLayerOnMapClickListener (cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener)2 PeriodicRequestHandler (cl.smartcities.isci.transportinspector.periodicRequest.PeriodicRequestHandler)2