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");
}
}
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);
}
}
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");
}
}
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;
}
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;
}
Aggregations