use of cl.smartcities.isci.transportinspector.database.BusStopHelper in project androidApp by InspectorIncognito.
the class StepJsonBuilder method getBusStop.
/*
If this method return null the given BusStop is not in TranSapp database and there is
nothing to do to recover this route
*/
@Nullable
private BusStop getBusStop(String departureCode, Context context, Location point) {
String[] split = departureCode.split("-");
String code = split[0];
BusStopHelper helper = new BusStopHelper(context);
BusStop busStop = helper.getBusStopById(code);
if (busStop == null) {
if (split.length != 1) {
Map<String, String> map = new HashMap<>();
map.put("code", code);
TranSappApplication.addLog("OutDated GTFS!", map);
return new BusStop(code, split[1], point.getLatitude(), point.getLongitude(), "");
} else {
List<BusStop> nearest = helper.getNearestBusStops(point.getLatitude(), point.getLongitude(), 10);
for (BusStop stop : nearest) {
String truncName = stop.getName().replaceAll(" |/", "");
String truncData = departureCode.replaceAll(" |/", "");
if (truncData.equals(truncName)) {
return stop;
}
}
Map<String, String> map = new HashMap<>();
map.put("data", departureCode);
TranSappApplication.addLog("Wrong bus stop code/name", map);
}
}
return busStop;
}
use of cl.smartcities.isci.transportinspector.database.BusStopHelper in project androidApp by InspectorIncognito.
the class SuggestionsSearchTask method doInBackground.
@Override
protected List<Suggestion> doInBackground(Void... params) {
BusStopHelper stopHelper = new BusStopHelper(context);
ServiceHelper serviceHelper = new ServiceHelper(context);
List<Suggestion> suggestions = new ArrayList<>();
if (query.toUpperCase().startsWith("L")) {
return suggestions;
}
for (BusStop busStop : stopHelper.getBusStopsSuggestionsById(query.toUpperCase())) {
suggestions.add(busStop);
}
for (Service service : serviceHelper.getServiceSuggestionsById(query.toLowerCase())) {
suggestions.add(service);
}
return suggestions;
}
use of cl.smartcities.isci.transportinspector.database.BusStopHelper in project androidApp by InspectorIncognito.
the class FavouritesManger method getFavouriteBusStops.
static List<BusStop> getFavouriteBusStops(Context context) {
FavoriteHelper helper = new FavoriteHelper(context);
BusStopHelper busStopHelper = new BusStopHelper(context);
List<String> busStops = helper.getFavoriteBusStops();
List<BusStop> favouriteBusStops = new ArrayList<>();
if (!busStops.isEmpty()) {
List<BusStop> favourites = busStopHelper.getAllBusStopsIn(busStops.toArray(new String[busStops.size()]));
favouriteBusStops.addAll(favourites);
}
return favouriteBusStops;
}
use of cl.smartcities.isci.transportinspector.database.BusStopHelper in project androidApp by InspectorIncognito.
the class BusStopPlugin method moveCenterInAndOpen.
public void moveCenterInAndOpen(String id) {
if (selectedBusStop != null) {
if (selectedBusStop.getStringProperty(Marker.PROPERTY_ID).equals(id)) {
MapboxUtil.animateCameraToSelection(selectedBusStop, animatorSet, mapboxMap);
return;
} else {
deselectSelectedBusStop();
}
}
Feature busStopFeature = getFeature(id, busStopFeatures, BusStopMarker.PROPERTY_ID);
BusStopClickHandler handler = new BusStopClickHandler(getContext().getResources(), periodicRequestHandler, BusStopPlugin.this);
if (busStopFeature == null) {
BusStopHelper helper = new BusStopHelper(getContext());
ArrayList<BusStop> busStops = new ArrayList<>();
busStops.add(helper.getBusStopById(id));
updateBusStopSource(busStops);
busStopFeature = busStopFeatures.getFeatures().get(0);
}
busStopFeatureClick(busStopFeature, handler);
}
use of cl.smartcities.isci.transportinspector.database.BusStopHelper in project androidApp by InspectorIncognito.
the class BusStep method getNearestBusStop.
@Nullable
private BusStop getNearestBusStop(Location point) {
BusStopHelper helper = new BusStopHelper(TranSappApplication.getAppContext());
List<BusStop> buses = helper.getNearestBusStops(point.getLatitude(), point.getLongitude(), 1);
if (buses.isEmpty()) {
return null;
}
return buses.get(0);
}
Aggregations