All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.gtfs.mapping.AreaMapper Maven / Gradle / Ivy

package org.opentripplanner.gtfs.mapping;

import org.opentripplanner.model.FlexArea;
import org.opentripplanner.util.MapUtils;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/** Map from the OBA model of GTFS-flex areas to the OTP internal model of areas. */
class AreaMapper {

    private final Map mappedAreas = new HashMap<>();

    Collection map(Collection agencies) {
        return MapUtils.mapToList(agencies, this::map);
    }

    /** Map from the OBA model of GTFS-flex areas to the OTP internal model of areas.  */
    FlexArea map(org.onebusaway.gtfs.model.Area orginal) {
        return orginal == null ? null : mappedAreas.computeIfAbsent(orginal, this::doMap);
    }

    private FlexArea doMap(org.onebusaway.gtfs.model.Area rhs) {
        FlexArea lhs = new FlexArea();

        lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId()));
        lhs.setWkt(rhs.getWkt());

        return lhs;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy