From af530b015aabd58fb937d2d55338e4f0f22e5400 Mon Sep 17 00:00:00 2001
From: Taylor Smock <taylor.smock@kaartgroup.com>
Date: Thu, 5 Sep 2019 14:25:22 -0600
Subject: [PATCH] Add Yandex as a possible imagery source

	* See https://wiki.openstreetmap.org/wiki/Contributors#Yandex.Panoramas

Signed-off-by: Taylor Smock <taylor.smock@kaartgroup.com>
---
 images/dialogs/yandex.svg                     | 138 ++++++++++++++++++
 .../plugins/osmobjinfo/OSMObjInfoActions.java |  47 +++---
 .../plugins/osmobjinfo/OSMObjInfotDialog.java |  17 ++-
 3 files changed, 171 insertions(+), 31 deletions(-)
 create mode 100644 images/dialogs/yandex.svg

diff --git a/images/dialogs/yandex.svg b/images/dialogs/yandex.svg
new file mode 100644
index 0000000..97e9437
--- /dev/null
+++ b/images/dialogs/yandex.svg
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="6.5060625mm"
+   height="7.715291mm"
+   viewBox="0 0 6.5060625 7.715291"
+   version="1.1"
+   id="svg8"
+   inkscape:version="0.92.2 5c3e80d, 2017-08-06"
+   sodipodi:docname="yandex.svg">
+  <defs
+     id="defs2" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="5.5546296"
+     inkscape:cx="-4.2959195"
+     inkscape:cy="5.7142445"
+     inkscape:document-units="mm"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:snap-text-baseline="true"
+     inkscape:window-width="1965"
+     inkscape:window-height="1034"
+     inkscape:window-x="1923"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0" />
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-61.96742,-144.14184)">
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#d40000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
+       x="61.988091"
+       y="151.85713"
+       id="text3701"><tspan
+         sodipodi:role="line"
+         id="tspan3699"
+         x="61.988091"
+         y="151.85713"
+         style="fill:#d40000;stroke-width:0.26458332">Y</tspan></text>
+  </g>
+</svg>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="6.5060625mm"
+   height="7.715291mm"
+   viewBox="0 0 6.5060625 7.715291"
+   version="1.1"
+   id="svg8"
+   inkscape:version="0.92.2 5c3e80d, 2017-08-06"
+   sodipodi:docname="yandex.svg">
+  <defs
+     id="defs2" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="5.5546296"
+     inkscape:cx="-4.2959195"
+     inkscape:cy="5.7142445"
+     inkscape:document-units="mm"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:snap-text-baseline="true"
+     inkscape:window-width="1965"
+     inkscape:window-height="1034"
+     inkscape:window-x="1923"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0" />
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-61.96742,-144.14184)">
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#d40000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
+       x="61.988091"
+       y="151.85713"
+       id="text3701"><tspan
+         sodipodi:role="line"
+         id="tspan3699"
+         x="61.988091"
+         y="151.85713"
+         style="fill:#d40000;stroke-width:0.26458332">Y</tspan></text>
+  </g>
+</svg>
diff --git a/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfoActions.java b/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfoActions.java
index 89020d4..4bbe239 100644
--- a/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfoActions.java
+++ b/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfoActions.java
@@ -26,26 +26,20 @@ public class OSMObjInfoActions {
 
     public static void openinBrowserUser(String user) {
         if (!user.isEmpty()) {
-            String url = "http://www.openstreetmap.org/user/" + user;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser("http://www.openstreetmap.org/user/".concat(user));
         }
 
     }
 
     public static void openinBrowserUserNeis(String user) {
         if (!user.isEmpty()) {
-            String url = "http://hdyc.neis-one.org/?" + user;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser("http://hdyc.neis-one.org/?".concat(user));
         }
     }
 
     static void openinBrowserUserOsmComments(String user) {
         if (!user.isEmpty()) {
-            String url = "https://www.mapbox.com/osm-comments/#/changesets/?q=users:" + user;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser( "https://www.mapbox.com/osm-comments/#/changesets/?q=users:".concat(user));
         }
     }
 
@@ -61,17 +55,13 @@ public class OSMObjInfoActions {
 
     public static void openinBrowserChangeset(String idChangeset) {
         if (!idChangeset.isEmpty()) {
-            String url = "https://www.openstreetmap.org/changeset/" + idChangeset;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser("https://www.openstreetmap.org/changeset/".concat(idChangeset));
         }
     }
 
     public static void openinBrowserChangesetMap(String idChangeset) {
         if (!idChangeset.isEmpty()) {
-            String url = "https://osmcha.mapbox.com/" + idChangeset;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser("https://osmcha.mapbox.com/".concat(idChangeset));
         }
     }
 
@@ -87,35 +77,36 @@ public class OSMObjInfoActions {
 
     public static void openinBrowserIdobj(String typeObj, String idobj) {
         if (typeObj != null && !idobj.isEmpty()) {
-            String url = "https://www.openstreetmap.org/" + typeObj + "/" + idobj;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser("https://www.openstreetmap.org/" + typeObj + "/" + idobj);
         }
     }
 
     public static void openinBrowserIdobjOsmDeepHistory(String typeObj, String idobj) {
         if (typeObj != null && !idobj.isEmpty()) {
-            String url = "http://osmlab.github.io/osm-deep-history/#/" + typeObj + "/" + idobj;
-            new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-            OpenBrowser.displayUrl(url);
+            openInBrowser("http://osmlab.github.io/osm-deep-history/#/" + typeObj + "/" + idobj);
         }
     }
 
     public static void openinBrowserMapillary(String coords) {
         if (coords == null || coords.isEmpty()) return;
         String[] arrCoords = coords.split(",");
-        String url = "https://www.mapillary.com/app/?lat=" + arrCoords[0] + "&lng=" + arrCoords[1] + "&z=20&focus=map&dateFrom=2017-01-01";
-        new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-        OpenBrowser.displayUrl(url);
-
+        openInBrowser("https://www.mapillary.com/app/?lat=" + arrCoords[0] + "&lng=" + arrCoords[1] + "&z=20&focus=map&dateFrom=2017-01-01");
     }
 
     public static void openinBrowserOpenstreetcam(String coords) {
         if (coords == null || coords.isEmpty()) return;
         String[] arrCoords = coords.split(",");
-        String url = "http://openstreetcam.org/map/@" + arrCoords[0] + "," + arrCoords[1] + ",18z";
-        new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
-        OpenBrowser.displayUrl(url);
+        openInBrowser("http://openstreetcam.org/map/@" + arrCoords[0] + "," + arrCoords[1] + ",18z");
     }
 
+    public static void openInBrowserYandex(String coords) {
+        if (coords == null || coords.isEmpty()) return;
+        String[] arrCoords = coords.split(",");
+        openInBrowser("https://yandex.com/maps/?l=stv,sta&ll=" + arrCoords[1] + "," + arrCoords[0] + "&z=18");
+    }
+
+    private static void openInBrowser(String url) {
+        new Notification(tr("Open in browser {0}", url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
+        OpenBrowser.displayUrl(url);
+    }
 }
diff --git a/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfotDialog.java b/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfotDialog.java
index 8da1d88..67395bc 100644
--- a/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfotDialog.java
+++ b/src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfotDialog.java
@@ -44,6 +44,7 @@ public class OSMObjInfotDialog extends ToggleDialog {
     protected JLabel lbLinnkIdobj;
     protected JLabel lbLinkMapillary;
     protected JLabel lbLinkOSMcamp;
+    protected JLabel lbLinkYandex;
     protected JLabel lbLinkIdChangeset;
     protected JLabel lbCopyUser;
     protected JLabel lbCopyIdobj;
@@ -346,17 +347,21 @@ public class OSMObjInfotDialog extends ToggleDialog {
     private JPanel MapillaryImages() {
         JPanel jpIMapillary = new JPanel(new BorderLayout());
         lbMapillary = new JLabel();
-        lbLinkMapillary = new JLabel(ImageProvider.get("dialogs", "mapillary.png"));
-        lbLinkOSMcamp = new JLabel(ImageProvider.get("dialogs", "openstreetcam.png"));
+        lbLinkMapillary = new JLabel(ImageProvider.get("dialogs", "mapillary"));
+        lbLinkOSMcamp = new JLabel(ImageProvider.get("dialogs", "openstreetcam"));
+        // TODO replace with real image
+        lbLinkYandex = new JLabel(ImageProvider.get("dialogs", "yandex"));
         lbLinkMapillary.setCursor(new Cursor(Cursor.HAND_CURSOR));
         lbLinkOSMcamp.setCursor(new Cursor(Cursor.HAND_CURSOR));
+        lbLinkYandex.setCursor(new Cursor(Cursor.HAND_CURSOR));
         JPanel jpIMapillaryOptions = new JPanel(new GridLayout(1, 2, 5, 5));
         jpIMapillaryOptions.add(lbLinkMapillary);
         jpIMapillaryOptions.add(lbLinkOSMcamp);
+        jpIMapillaryOptions.add(lbLinkYandex);
         //add
         jpIMapillary.add(lbMapillary, BorderLayout.LINE_START);
         jpIMapillary.add(jpIMapillaryOptions, BorderLayout.LINE_END);
-        //id obj actions 
+        //id obj actions
         lbLinkMapillary.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseClicked(MouseEvent e) {
@@ -369,6 +374,12 @@ public class OSMObjInfotDialog extends ToggleDialog {
                 OSMObjInfoActions.openinBrowserOpenstreetcam(lbMapillary.getText());
             }
         });
+        lbLinkYandex.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                OSMObjInfoActions.openInBrowserYandex(lbMapillary.getText());
+            }
+        });
         return jpIMapillary;
     }
 }
-- 
2.20.1 (Apple Git-117)

