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

org.opentripplanner.index.model.StopClusterDetail Maven / Gradle / Ivy

package org.opentripplanner.index.model;

import com.beust.jcommander.internal.Lists;
import org.opentripplanner.model.Stop;
import org.opentripplanner.profile.StopCluster;

import java.util.Collection;
import java.util.List;

/**
 * A representation of a stop cluster for use in an index API response.
 * Can contain references to stops for more detail.
 */
public class StopClusterDetail {

    public String id;
    public String name;
    public double lat;
    public double lon;
    public List stops; // filled in only if detail is requested

    public StopClusterDetail (StopCluster cluster, boolean detail) {
        id = cluster.id;
        lat = cluster.lat;
        lon = cluster.lon;
        name = cluster.name;
        if (detail) {
            stops = Lists.newArrayList();
            for (Stop stop : cluster.children) {
                stops.add(new StopShort(stop));
            }
        }
    }

    public static List list (Collection in, boolean detail) {
        List out = Lists.newArrayList();
        for (StopCluster cluster : in) out.add(new StopClusterDetail(cluster, detail));
        return out;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy