Search in sources :

Example 1 with LogQuantifiable

use of org.opentripplanner.util.stats.DiscreteDistribution.LogQuantifiable in project OpenTripPlanner by opentripplanner.

the class GraphStatisticsModule method buildGraph.

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
    DiscreteDistribution<ConstantQuantifiable<String>> edgeTypeDistribution = new DiscreteDistribution<ConstantQuantifiable<String>>();
    DiscreteDistribution<NumberQuantifiable<Integer>> edgeNameDistribution = new DiscreteDistribution<NumberQuantifiable<Integer>>();
    DiscreteDistribution<NumberQuantifiable<Integer>> geomSizeDistribution = new DiscreteDistribution<NumberQuantifiable<Integer>>();
    DiscreteDistribution<LogQuantifiable<Double>> geomLenDistribution = new DiscreteDistribution<LogQuantifiable<Double>>();
    DiscreteDistribution<ConstantQuantifiable<String>> vertexTypeDistribution = new DiscreteDistribution<ConstantQuantifiable<String>>();
    DiscreteDistribution<NumberQuantifiable<Integer>> vertexNameDistribution = new DiscreteDistribution<NumberQuantifiable<Integer>>();
    DiscreteDistribution<NumberQuantifiable<Integer>> vertexLabelDistribution = new DiscreteDistribution<NumberQuantifiable<Integer>>();
    for (Edge e : graph.getEdges()) {
        edgeTypeDistribution.add(new ConstantQuantifiable<String>(e.getClass().toString()));
        edgeNameDistribution.add(new NumberQuantifiable<Integer>(e.getName() == null ? 0 : e.getName().length()), e.getName());
        if (e.getGeometry() != null) {
            LineString geometry = e.getGeometry();
            geomSizeDistribution.add(new NumberQuantifiable<Integer>(geometry.getNumPoints()));
            double lenMeters = SphericalDistanceLibrary.fastLength(geometry);
            geomLenDistribution.add(new LogQuantifiable<Double>(lenMeters, 5.0));
        }
    }
    for (Vertex v : graph.getVertices()) {
        vertexTypeDistribution.add(new ConstantQuantifiable<String>(v.getClass().toString()));
        vertexNameDistribution.add(new NumberQuantifiable<Integer>(v.getName() == null ? 0 : v.getName().length()), v.getName());
        vertexLabelDistribution.add(new NumberQuantifiable<Integer>(v.getLabel().length()), v.getLabel());
    }
    LOG.info("Geometry size distribution (linear scale, # points):\n" + geomSizeDistribution.toString());
    LOG.info("Geometry length distribution (log scale, meters):\n" + geomLenDistribution.toString());
    LOG.info("Edge type distribution:\n" + edgeTypeDistribution.toString());
    LOG.info("Edge name distribution:\n" + edgeNameDistribution.toString());
    LOG.info("Vertex type distribution:\n" + vertexTypeDistribution.toString());
    LOG.info("Vertex name distribution:\n" + vertexNameDistribution.toString());
    LOG.info("Vertex label distribution:\n" + vertexLabelDistribution.toString());
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) LineString(com.vividsolutions.jts.geom.LineString) LogQuantifiable(org.opentripplanner.util.stats.DiscreteDistribution.LogQuantifiable) NumberQuantifiable(org.opentripplanner.util.stats.DiscreteDistribution.NumberQuantifiable) LineString(com.vividsolutions.jts.geom.LineString) ConstantQuantifiable(org.opentripplanner.util.stats.DiscreteDistribution.ConstantQuantifiable) Edge(org.opentripplanner.routing.graph.Edge) DiscreteDistribution(org.opentripplanner.util.stats.DiscreteDistribution)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)1 Edge (org.opentripplanner.routing.graph.Edge)1 Vertex (org.opentripplanner.routing.graph.Vertex)1 DiscreteDistribution (org.opentripplanner.util.stats.DiscreteDistribution)1 ConstantQuantifiable (org.opentripplanner.util.stats.DiscreteDistribution.ConstantQuantifiable)1 LogQuantifiable (org.opentripplanner.util.stats.DiscreteDistribution.LogQuantifiable)1 NumberQuantifiable (org.opentripplanner.util.stats.DiscreteDistribution.NumberQuantifiable)1