openmove / odh-mentor-otp

https://mobility.meran.eu
1 stars 3 forks source link

Bikesharing regions #52

Closed zabuTNT closed 3 years ago

zabuTNT commented 3 years ago

In order to improve the bikesharing we have to modify otp to register the region of a bikesharing station. Because when you pickup a bike with an operator you cannot do a dropoff to another operator.

To do this we have to:

1) get the bike network from GBFS

2) set the bike network in GBFS mode, it seems that this is not done, otherwise this should work:

BikeRentalUpdater.java

if (station.networks == null) {
                    /* API did not provide a network list, use default */
                    station.networks = defaultNetworks;
                }

RentABikeAbstractEdge.java

/**
     * @param stationNetworks The station where we want to drop the bike off.
     * @param rentedNetworks The set of networks of the station we rented the bike from.
     * @return true if the bike can be dropped off here, false if not.
     */
    private boolean hasCompatibleNetworks(Set<String> stationNetworks, Set<String> rentedNetworks) {
        /*
         * Two stations are compatible if they share at least one network. Special case for "null"
         * networks ("catch-all" network defined).
         */
        if (stationNetworks == null || rentedNetworks == null)
            return true; // Always a match
        return !Sets.intersection(stationNetworks, rentedNetworks).isEmpty();
    }
zabuTNT commented 3 years ago

Find the issue, it seems that you have to use "network" in the updater, but they miss this in the documentation:

// Each updater can be assigned a unique network ID in the configuration to prevent returning bikes at
        // stations for another network. TODO shouldn't we give each updater a unique network ID by default?
String networkName = config.path("network").asText();
} else if (sourceType.equals("gbfs")) {
                source = new GbfsBikeRentalDataSource(networkName);
            }

and so networkName is alway GBFS:

if (networkName != null && !networkName.isEmpty()) {
            this.networkName = networkName;
        } else {
            this.networkName = "GBFS";
        }
zabuTNT commented 3 years ago

This is implemented with https://github.com/openmove/odh-mentor-otp/commit/b82c0dbd4f581586e4512a05ad93de9a36aea6fe#diff-07baf93f1d5a0aab605f2b645b2da983a76dbb8fff52d7c5dd479e9773d7a011