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

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

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.graph_builder.module.shapefile;

import org.opengis.feature.simple.SimpleFeature;
import org.opentripplanner.common.model.P2;
import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter;

/*
 * Read safety factors directly from shapefiles (contributed by Guillaume Barreau)
 */
public class DirectSafetyReader implements SimpleFeatureConverter> {
    private String safetyAttributeName;

    public static final P2 oneone = new P2(1.0, 1.0);

    @Override
    public P2 convert(SimpleFeature feature) {
        Double d = (Double) feature.getAttribute(safetyAttributeName);
        if (d == null) {
            return oneone;
        }
        return new P2(d, d);
    }

    public void setSafetyAttributeName(String safetyAttributeName) {
        this.safetyAttributeName = safetyAttributeName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy