Search in sources :

Example 6 with Lobby

use of im.tny.segvault.subway.Lobby in project underlx by underlx.

the class StationPickerView method selectNearestStation.

public void selectNearestStation(Location location) {
    float minDistance = Float.MAX_VALUE;
    Station minStation = null;
    if (adapter == null) {
        return;
    }
    for (Station station : adapter.stations) {
        if (station.isAlwaysClosed()) {
            continue;
        }
        for (Lobby lobby : station.getLobbies()) {
            for (Lobby.Exit exit : lobby.getExits()) {
                Location exitLocation = new Location("");
                exitLocation.setLatitude(exit.worldCoord[0]);
                exitLocation.setLongitude(exit.worldCoord[1]);
                float distance = location.distanceTo(exitLocation);
                if (distance < minDistance || minStation == null) {
                    minDistance = distance;
                    minStation = station;
                }
            }
        }
    }
    setSelection(minStation);
}
Also used : Station(im.tny.segvault.subway.Station) Lobby(im.tny.segvault.subway.Lobby) Location(android.location.Location)

Aggregations

Lobby (im.tny.segvault.subway.Lobby)6 Line (im.tny.segvault.subway.Line)4 Station (im.tny.segvault.subway.Station)4 Marker (com.google.android.gms.maps.model.Marker)3 POI (im.tny.segvault.subway.POI)3 WorldPath (im.tny.segvault.subway.WorldPath)3 CameraUpdate (com.google.android.gms.maps.CameraUpdate)2 LatLng (com.google.android.gms.maps.model.LatLng)2 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)2 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)2 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)2 Network (im.tny.segvault.subway.Network)2 MatrixCursor (android.database.MatrixCursor)1 Location (android.location.Location)1 ViewTreeObserver (android.view.ViewTreeObserver)1 GoogleMap (com.google.android.gms.maps.GoogleMap)1 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)1 MainService (im.tny.segvault.disturbances.MainService)1 CacheException (im.tny.segvault.disturbances.exception.CacheException)1 LobbyView (im.tny.segvault.disturbances.ui.widget.LobbyView)1