From c812fdb677a828c5dd26d9a56f106f8db4386a6b Mon Sep 17 00:00:00 2001
From: Taylor Smock <tsmock@meta.com>
Date: Wed, 1 Feb 2023 06:52:17 -0700
Subject: [PATCH] Mapillary Layer: Fix issue with painting across tile borders

Signed-off-by: Taylor Smock <tsmock@meta.com>
---
 .../josm/plugins/mapillary/gui/layer/MapillaryLayer.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapillary/gui/layer/MapillaryLayer.java b/src/main/java/org/openstreetmap/josm/plugins/mapillary/gui/layer/MapillaryLayer.java
index c228dc0c7..5e7b53092 100644
--- a/src/main/java/org/openstreetmap/josm/plugins/mapillary/gui/layer/MapillaryLayer.java
+++ b/src/main/java/org/openstreetmap/josm/plugins/mapillary/gui/layer/MapillaryLayer.java
@@ -389,11 +389,13 @@ private void drawSequence(final Graphics2D g, final MapView mv, final IWay<?> se
         Point previousPoint = null;
         for (INode current : nodes) {
             final Point currentPoint = mv.getPoint(current);
-            g.setColor(forcedColor != null ? forcedColor : getColor(current));
+            if (MapillaryImageUtils.isImage(current)) {
+                g.setColor(forcedColor != null ? forcedColor : getColor(current));
+            }
             if (previous != null && (mv.contains(currentPoint) || mv.contains(previousPoint))) {
                 // FIXME get the right color for the line segment
+                final boolean visibleNode = zoom >= 14 && sequence.isVisible() && MapillaryImageUtils.isImage(previous);
                 g.drawLine(previousPoint.x, previousPoint.y, currentPoint.x, currentPoint.y);
-                final boolean visibleNode = zoom < 14 || sequence.isVisible() || MapillaryImageUtils.isImage(previous);
                 if (visibleNode) {
                     // FIXME draw the image here (avoid calculating the points twice)
                     drawImageMarker(originalTransform, selectedImage, g, previous, distPer100Pixel, false);
@@ -402,7 +404,7 @@ private void drawSequence(final Graphics2D g, final MapView mv, final IWay<?> se
             previous = current;
             previousPoint = currentPoint;
         }
-        final boolean visibleNode = zoom < 14 || sequence.isVisible() || MapillaryImageUtils.isImage(previous);
+        final boolean visibleNode = zoom >= 14 && sequence.isVisible() && MapillaryImageUtils.isImage(previous);
         if (visibleNode) {
             // FIXME draw the image here (avoid calculating the points twice)
             drawImageMarker(originalTransform, selectedImage, g, previous, distPer100Pixel, false);