Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
MapillaryLayer: Avoid allocations of Instant during painting
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Feb 2, 2023
1 parent 7a78e98 commit b92f8ff
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ public final class MapillaryLayer extends MVTLayer implements ActiveLayerChangeL
/** The color scale used when drawing using velocity */
private final ColorScale velocityScale = ColorScale.createHSBScale(256);
/** The color scale used when drawing using date */
private final ColorScale dateScale = ColorScale.createFixedScale(new Color[] { ColorHelper.html2color("e17155"), // Really
// old
// color
ColorHelper.html2color("fbc01b"), // Old color
MapillaryColorScheme.SEQ_UNSELECTED // New color
private final ColorScale dateScale = ColorScale.createFixedScale(
// Really old color
new Color[] { ColorHelper.html2color("e17155"),
// Old color
ColorHelper.html2color("fbc01b"),
// New color
MapillaryColorScheme.SEQ_UNSELECTED
}).addTitle(tr("Time"));

/** The color scale used when drawing using direction */
Expand Down Expand Up @@ -189,8 +191,8 @@ private MapillaryLayer() {
private void setupColorScales() {
this.dateScale.setNoDataColor(MapillaryColorScheme.SEQ_UNSELECTED);
// ChronoUnit.YEARS isn't supported since a year can be either 365 or 366.
this.dateScale.setRange(Instant.now().minus(4 * 365L, ChronoUnit.DAYS).toEpochMilli(),
Instant.now().toEpochMilli());
this.dateScale.setRange(Instant.now().minus(4 * 365L, ChronoUnit.DAYS).getEpochSecond(),
Instant.now().getEpochSecond());
this.directionScale.setNoDataColor(MapillaryColorScheme.SEQ_UNSELECTED);
this.velocityScale.setNoDataColor(MapillaryColorScheme.SEQ_UNSELECTED);
}
Expand Down Expand Up @@ -414,7 +416,10 @@ private void drawSequence(final Graphics2D g, final MapView mv, final IWay<?> se
private Color getColor(final INode node) {
switch (this.drawType) {
case DATE:
return this.dateScale.getColor(MapillaryImageUtils.getDate(node).toEpochMilli());
if (node.isTimestampEmpty()) {
MapillaryImageUtils.getDate(node);
}
return this.dateScale.getColor(node.getRawTimestamp());
case VELOCITY_FOOT:
case VELOCITY_BIKE:
case VELOCITY_CAR:
Expand Down

0 comments on commit b92f8ff

Please sign in to comment.