Search in sources :

Example 1 with TDoubleList

use of gnu.trove.list.TDoubleList in project Terasology by MovingBlocks.

the class TimeMetricsMode method displayMetrics.

private void displayMetrics(TObjectDoubleMap<String> metrics, StringBuilder builder) {
    final List<String> activities = Lists.newArrayList();
    final TDoubleList values = new TDoubleArrayList();
    sortMetrics(metrics, activities, values);
    for (int i = 0; i < limit && i < activities.size(); ++i) {
        builder.append(activities.get(i));
        builder.append(": ");
        builder.append(format.format(values.get(i)));
        builder.append(unit);
        builder.append("\n");
    }
}
Also used : TDoubleList(gnu.trove.list.TDoubleList) TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Example 2 with TDoubleList

use of gnu.trove.list.TDoubleList in project OpenTripPlanner by opentripplanner.

the class Graph method calculateTransitCenter.

/**
 * Calculates Transit center from median of coordinates of all transitStops if graph
 * has transit. If it doesn't it isn't calculated. (mean walue of min, max latitude and longitudes are used)
 *
 * Transit center is saved in center variable
 *
 * This speeds up calculation, but problem is that median needs to have all of latitudes/longitudes
 * in memory, this can become problematic in large installations. It works without a problem on New York State.
 * @see GraphEnvelope
 */
public void calculateTransitCenter() {
    if (hasTransit) {
        TDoubleList latitudes = new TDoubleLinkedList();
        TDoubleList longitudes = new TDoubleLinkedList();
        Median median = new Median();
        getVertices().stream().filter(v -> v instanceof TransitStop).forEach(v -> {
            latitudes.add(v.getLat());
            longitudes.add(v.getLon());
        });
        median.setData(latitudes.toArray());
        double medianLatitude = median.evaluate();
        median = new Median();
        median.setData(longitudes.toArray());
        double medianLongitude = median.evaluate();
        this.center = new Coordinate(medianLongitude, medianLatitude);
    }
}
Also used : TDoubleList(gnu.trove.list.TDoubleList) TurnRestriction(org.opentripplanner.common.TurnRestriction) LoggerFactory(org.slf4j.LoggerFactory) TransitStop(org.opentripplanner.routing.vertextype.TransitStop) CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) StreetSpeedSnapshotSource(org.opentripplanner.traffic.StreetSpeedSnapshotSource) GraphUtils(org.opentripplanner.common.geometry.GraphUtils) StreetVertexIndexService(org.opentripplanner.routing.services.StreetVertexIndexService) Median(org.apache.commons.math3.stat.descriptive.rank.Median) DefaultStreetVertexIndexFactory(org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory) Geometry(com.vividsolutions.jts.geom.Geometry) TraverseMode(org.opentripplanner.routing.core.TraverseMode) com.google.common.collect(com.google.common.collect) FeedInfo(org.onebusaway.gtfs.model.FeedInfo) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) MavenVersion(org.opentripplanner.common.MavenVersion) TransferTable(org.opentripplanner.routing.core.TransferTable) StreetNotesService(org.opentripplanner.routing.services.notes.StreetNotesService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SampleFactory(org.opentripplanner.analyst.request.SampleFactory) CalendarService(org.onebusaway.gtfs.services.calendar.CalendarService) TripPattern(org.opentripplanner.routing.edgetype.TripPattern) Stop(org.onebusaway.gtfs.model.Stop) Agency(org.onebusaway.gtfs.model.Agency) GraphUpdaterManager(org.opentripplanner.updater.GraphUpdaterManager) TimetableSnapshotSource(org.opentripplanner.updater.stoptime.TimetableSnapshotSource) StreetVertexIndexFactory(org.opentripplanner.routing.services.StreetVertexIndexFactory) java.util(java.util) AlertPatch(org.opentripplanner.routing.alertpatch.AlertPatch) WorldEnvelope(org.opentripplanner.util.WorldEnvelope) TDoubleList(gnu.trove.list.TDoubleList) TDoubleLinkedList(gnu.trove.list.linked.TDoubleLinkedList) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) NoFutureDates(org.opentripplanner.graph_builder.annotation.NoFutureDates) GraphUpdaterConfigurator(org.opentripplanner.updater.GraphUpdaterConfigurator) GraphBuilderAnnotation(org.opentripplanner.graph_builder.annotation.GraphBuilderAnnotation) GeometryIndex(org.opentripplanner.analyst.core.GeometryIndex) MortonVertexComparatorFactory(org.opentripplanner.routing.core.MortonVertexComparatorFactory) EdgeWithCleanup(org.opentripplanner.routing.edgetype.EdgeWithCleanup) Coordinate(com.vividsolutions.jts.geom.Coordinate) Logger(org.slf4j.Logger) Envelope(com.vividsolutions.jts.geom.Envelope) CalendarServiceImpl(org.onebusaway.gtfs.impl.calendar.CalendarServiceImpl) GraphBundle(org.opentripplanner.model.GraphBundle) DateTime(org.joda.time.DateTime) TransitStation(org.opentripplanner.routing.vertextype.TransitStation) Preferences(java.util.prefs.Preferences) java.io(java.io) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) PatternArriveVertex(org.opentripplanner.routing.vertextype.PatternArriveVertex) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TransitStop(org.opentripplanner.routing.vertextype.TransitStop) Coordinate(com.vividsolutions.jts.geom.Coordinate) TDoubleLinkedList(gnu.trove.list.linked.TDoubleLinkedList) Median(org.apache.commons.math3.stat.descriptive.rank.Median)

Example 3 with TDoubleList

use of gnu.trove.list.TDoubleList in project Terasology by MovingBlocks.

the class TimeMetricsMode method displayMetrics.

private void displayMetrics(TObjectDoubleMap<String> metrics, StringBuilder builder) {
    final List<String> activities = Lists.newArrayList();
    final TDoubleList values = new TDoubleArrayList();
    sortMetrics(metrics, activities, values);
    for (int i = 0; i < limit && i < activities.size(); ++i) {
        builder.append(activities.get(i));
        builder.append(": ");
        builder.append(format.format(values.get(i)));
        builder.append(unit);
        builder.append("\n");
    }
}
Also used : TDoubleList(gnu.trove.list.TDoubleList) TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Example 4 with TDoubleList

use of gnu.trove.list.TDoubleList in project Terasology by MovingBlocks.

the class TroveUtils method floatToDouble.

public static TDoubleList floatToDouble(TFloatList list) {
    TDoubleList result = new TDoubleArrayList(list.size());
    TFloatIterator iterator = list.iterator();
    while (iterator.hasNext()) {
        float i = iterator.next();
        result.add(i);
    }
    return result;
}
Also used : TDoubleList(gnu.trove.list.TDoubleList) TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList) TFloatIterator(gnu.trove.iterator.TFloatIterator)

Example 5 with TDoubleList

use of gnu.trove.list.TDoubleList in project Terasology by MovingBlocks.

the class TroveUtils method longToDouble.

public static TDoubleList longToDouble(TLongList list) {
    TDoubleList result = new TDoubleArrayList(list.size());
    TLongIterator iterator = list.iterator();
    while (iterator.hasNext()) {
        long i = iterator.next();
        result.add(i);
    }
    return result;
}
Also used : TDoubleList(gnu.trove.list.TDoubleList) TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList) TLongIterator(gnu.trove.iterator.TLongIterator)

Aggregations

TDoubleList (gnu.trove.list.TDoubleList)6 TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 com.google.common.collect (com.google.common.collect)1 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 TFloatIterator (gnu.trove.iterator.TFloatIterator)1 TIntIterator (gnu.trove.iterator.TIntIterator)1 TLongIterator (gnu.trove.iterator.TLongIterator)1 TDoubleLinkedList (gnu.trove.list.linked.TDoubleLinkedList)1 java.io (java.io)1 java.util (java.util)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Preferences (java.util.prefs.Preferences)1 Median (org.apache.commons.math3.stat.descriptive.rank.Median)1 DateTime (org.joda.time.DateTime)1 CalendarServiceImpl (org.onebusaway.gtfs.impl.calendar.CalendarServiceImpl)1 Agency (org.onebusaway.gtfs.model.Agency)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1