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

org.opentripplanner.graph_builder.module.shapefile.ShapefileStreetSchema Maven / Gradle / Ivy

package org.opentripplanner.graph_builder.module.shapefile;

import org.opentripplanner.common.model.P2;
import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter;
import org.opentripplanner.routing.edgetype.StreetTraversalPermission;

public class ShapefileStreetSchema {

    private SimpleFeatureConverter idConverter = new FeatureIdConverter();

    private SimpleFeatureConverter nameConverter;

    private SimpleFeatureConverter> permissionConverter = new CaseBasedTraversalPermissionConverter();

    private SimpleFeatureConverter> bicycleSafetyConverter = null;

    private SimpleFeatureConverter slopeOverrideConverter = new CaseBasedBooleanConverter();

    private SimpleFeatureConverter featureSelector = null;

    private SimpleFeatureConverter noteConverter = null;

    public SimpleFeatureConverter getIdConverter() {
        return idConverter;
    }

    /**
     * Sets the converter which gets IDs from features.
     * 
     * @see ShapefileStreetSchema#setIdAttribute
     */
    public void setIdConverter(SimpleFeatureConverter idConverter) {
        this.idConverter = idConverter;
    }

    /**
     * The ID attribute is used to uniquely identify street segments. This is useful if a given
     * street segment appears multiple times in a shapefile.
     */
    public void setIdAttribute(String attributeName) {
        this.idConverter = new AttributeFeatureConverter(attributeName);
    }

    public SimpleFeatureConverter getNameConverter() {
        return nameConverter;
    }

    public void setNameAttribute(String attributeName) {
        this.nameConverter = new AttributeFeatureConverter(attributeName);
    }

    /**
     * The name converter gets the street name from a feature.
     */
    public void setNameConverter(SimpleFeatureConverter nameConverter) {
        this.nameConverter = nameConverter;
    }

    /**
     * The permission converter gets the {@link StreetTraversalPermission} for a street segment and
     * its reverse.
     * 
     * @return
     */
    public SimpleFeatureConverter> getPermissionConverter() {
        return permissionConverter;
    }

    public void setPermissionConverter(
            SimpleFeatureConverter> permissionConverter) {
        this.permissionConverter = permissionConverter;
    }

    /**
     * The permission converter gets the bicycle safety factor for a street segment and its reverse.
     * The safety factor is 1.0 for an ordinary street. For streets which are more or less safe for
     * bicycles, the safety factor is the number of miles you would have to bike on an ordinary
     * street to have the same odds of dying as if you biked one mile on this street. For example,
     * if bike lanes reduce risk by a factor of 3, the safety factor would be 0.33...
     * 
     */
    public void setBicycleSafetyConverter(SimpleFeatureConverter> safetyConverter) {
        this.bicycleSafetyConverter = safetyConverter;
    }

    public SimpleFeatureConverter> getBicycleSafetyConverter() {
        return bicycleSafetyConverter;
    }

    /**
     * @see setSlopeOverrideConverter
     * @return
     */
    public SimpleFeatureConverter getSlopeOverrideConverter() {
        return slopeOverrideConverter;
    }

    /**
     * The slope override converter returns true if the slope found from NED is should be ignored
     * (for instance, on bridges and tunnels)
     * 
     * @param slopeOverrideConverter
     */
    public void setSlopeOverrideConverter(SimpleFeatureConverter slopeOverrideConverter) {
        this.slopeOverrideConverter = slopeOverrideConverter;
    }

    /**
     * @param featureSelector
     *            A featureSelector returns true if a feature is a street, and false otherwise.
     *            Useful for centerline files that also have non-streets, such as political
     *            boundaries or coastlines
     */
    public void setFeatureSelector(SimpleFeatureConverter featureSelector) {
        this.featureSelector = featureSelector;
    }

    /**
     * @see setFeatureSelector
     * @return the current feature selector
     */
    public SimpleFeatureConverter getFeatureSelector() {
        return featureSelector;
    }

	public void setNoteConverter(SimpleFeatureConverter noteConverter) {
		this.noteConverter = noteConverter;
	}

	public SimpleFeatureConverter getNoteConverter() {
		return noteConverter;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy