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

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

package org.opentripplanner.index.model;

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

import org.opentripplanner.model.FeedScopedId;
import org.opentripplanner.model.Stop;

import com.beust.jcommander.internal.Lists;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

public class StopShort {

    public FeedScopedId id;
    public String code;
    public String name;
    public double lat;
    public double lon;
    public String url;
    public String cluster;

    /** Distance to the stop when it is returned from a location-based query. */
    @JsonInclude(Include.NON_NULL) public Integer dist;
    
    public StopShort (Stop stop) {
        id = stop.getId();
        code = stop.getCode();
        name = stop.getName();
        lat = stop.getLat();
        lon = stop.getLon();
        url = stop.getUrl();
        cluster = stop.getParentStation(); // TODO harmonize these names, maybe use "station" everywhere
    }

    /** @param distance in integral meters, to avoid serializing a bunch of decimal places. */
    public StopShort(Stop stop, int distance) {
        this(stop);
        this.dist = distance;
    }

    public static List list (Collection in) {
        List out = Lists.newArrayList();
        for (Stop stop : in) out.add(new StopShort(stop));
        return out;
    }    

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy