Ticket #18123: 0001-Add-Yandex-as-a-possible-imagery-source.patch

File 0001-Add-Yandex-as-a-possible-imagery-source.patch, 13.3 KB (added by taylor.smock, 6 years ago)

Add Yandex as imagery source, refactor some code for deduplication

  • new file images/dialogs/yandex.svg

    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
    - +  
     1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
     2<!-- Created with Inkscape (http://www.inkscape.org/) -->
     3
     4<svg
     5   xmlns:dc="http://purl.org/dc/elements/1.1/"
     6   xmlns:cc="http://creativecommons.org/ns#"
     7   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     8   xmlns:svg="http://www.w3.org/2000/svg"
     9   xmlns="http://www.w3.org/2000/svg"
     10   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
     11   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
     12   width="6.5060625mm"
     13   height="7.715291mm"
     14   viewBox="0 0 6.5060625 7.715291"
     15   version="1.1"
     16   id="svg8"
     17   inkscape:version="0.92.2 5c3e80d, 2017-08-06"
     18   sodipodi:docname="yandex.svg">
     19  <defs
     20     id="defs2" />
     21  <sodipodi:namedview
     22     id="base"
     23     pagecolor="#ffffff"
     24     bordercolor="#666666"
     25     borderopacity="1.0"
     26     inkscape:pageopacity="0.0"
     27     inkscape:pageshadow="2"
     28     inkscape:zoom="5.5546296"
     29     inkscape:cx="-4.2959195"
     30     inkscape:cy="5.7142445"
     31     inkscape:document-units="mm"
     32     inkscape:current-layer="layer1"
     33     showgrid="false"
     34     inkscape:snap-text-baseline="true"
     35     inkscape:window-width="1965"
     36     inkscape:window-height="1034"
     37     inkscape:window-x="1923"
     38     inkscape:window-y="0"
     39     inkscape:window-maximized="0" />
     40  <metadata
     41     id="metadata5">
     42    <rdf:RDF>
     43      <cc:Work
     44         rdf:about="">
     45        <dc:format>image/svg+xml</dc:format>
     46        <dc:type
     47           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
     48        <dc:title></dc:title>
     49      </cc:Work>
     50    </rdf:RDF>
     51  </metadata>
     52  <g
     53     inkscape:label="Layer 1"
     54     inkscape:groupmode="layer"
     55     id="layer1"
     56     transform="translate(-61.96742,-144.14184)">
     57    <text
     58       xml:space="preserve"
     59       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"
     60       x="61.988091"
     61       y="151.85713"
     62       id="text3701"><tspan
     63         sodipodi:role="line"
     64         id="tspan3699"
     65         x="61.988091"
     66         y="151.85713"
     67         style="fill:#d40000;stroke-width:0.26458332">Y</tspan></text>
     68  </g>
     69</svg>
     70<?xml version="1.0" encoding="UTF-8" standalone="no"?>
     71<!-- Created with Inkscape (http://www.inkscape.org/) -->
     72
     73<svg
     74   xmlns:dc="http://purl.org/dc/elements/1.1/"
     75   xmlns:cc="http://creativecommons.org/ns#"
     76   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     77   xmlns:svg="http://www.w3.org/2000/svg"
     78   xmlns="http://www.w3.org/2000/svg"
     79   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
     80   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
     81   width="6.5060625mm"
     82   height="7.715291mm"
     83   viewBox="0 0 6.5060625 7.715291"
     84   version="1.1"
     85   id="svg8"
     86   inkscape:version="0.92.2 5c3e80d, 2017-08-06"
     87   sodipodi:docname="yandex.svg">
     88  <defs
     89     id="defs2" />
     90  <sodipodi:namedview
     91     id="base"
     92     pagecolor="#ffffff"
     93     bordercolor="#666666"
     94     borderopacity="1.0"
     95     inkscape:pageopacity="0.0"
     96     inkscape:pageshadow="2"
     97     inkscape:zoom="5.5546296"
     98     inkscape:cx="-4.2959195"
     99     inkscape:cy="5.7142445"
     100     inkscape:document-units="mm"
     101     inkscape:current-layer="layer1"
     102     showgrid="false"
     103     inkscape:snap-text-baseline="true"
     104     inkscape:window-width="1965"
     105     inkscape:window-height="1034"
     106     inkscape:window-x="1923"
     107     inkscape:window-y="0"
     108     inkscape:window-maximized="0" />
     109  <metadata
     110     id="metadata5">
     111    <rdf:RDF>
     112      <cc:Work
     113         rdf:about="">
     114        <dc:format>image/svg+xml</dc:format>
     115        <dc:type
     116           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
     117        <dc:title></dc:title>
     118      </cc:Work>
     119    </rdf:RDF>
     120  </metadata>
     121  <g
     122     inkscape:label="Layer 1"
     123     inkscape:groupmode="layer"
     124     id="layer1"
     125     transform="translate(-61.96742,-144.14184)">
     126    <text
     127       xml:space="preserve"
     128       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"
     129       x="61.988091"
     130       y="151.85713"
     131       id="text3701"><tspan
     132         sodipodi:role="line"
     133         id="tspan3699"
     134         x="61.988091"
     135         y="151.85713"
     136         style="fill:#d40000;stroke-width:0.26458332">Y</tspan></text>
     137  </g>
     138</svg>
  • src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfoActions.java

    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 b public class OSMObjInfoActions {  
    2626
    2727    public static void openinBrowserUser(String user) {
    2828        if (!user.isEmpty()) {
    29             String url = "http://www.openstreetmap.org/user/" + user;
    30             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    31             OpenBrowser.displayUrl(url);
     29            openInBrowser("http://www.openstreetmap.org/user/".concat(user));
    3230        }
    3331
    3432    }
    3533
    3634    public static void openinBrowserUserNeis(String user) {
    3735        if (!user.isEmpty()) {
    38             String url = "http://hdyc.neis-one.org/?" + user;
    39             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    40             OpenBrowser.displayUrl(url);
     36            openInBrowser("http://hdyc.neis-one.org/?".concat(user));
    4137        }
    4238    }
    4339
    4440    static void openinBrowserUserOsmComments(String user) {
    4541        if (!user.isEmpty()) {
    46             String url = "https://www.mapbox.com/osm-comments/#/changesets/?q=users:" + user;
    47             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    48             OpenBrowser.displayUrl(url);
     42            openInBrowser( "https://www.mapbox.com/osm-comments/#/changesets/?q=users:".concat(user));
    4943        }
    5044    }
    5145
    public class OSMObjInfoActions {  
    6155
    6256    public static void openinBrowserChangeset(String idChangeset) {
    6357        if (!idChangeset.isEmpty()) {
    64             String url = "https://www.openstreetmap.org/changeset/" + idChangeset;
    65             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    66             OpenBrowser.displayUrl(url);
     58            openInBrowser("https://www.openstreetmap.org/changeset/".concat(idChangeset));
    6759        }
    6860    }
    6961
    7062    public static void openinBrowserChangesetMap(String idChangeset) {
    7163        if (!idChangeset.isEmpty()) {
    72             String url = "https://osmcha.mapbox.com/" + idChangeset;
    73             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    74             OpenBrowser.displayUrl(url);
     64            openInBrowser("https://osmcha.mapbox.com/".concat(idChangeset));
    7565        }
    7666    }
    7767
    public class OSMObjInfoActions {  
    8777
    8878    public static void openinBrowserIdobj(String typeObj, String idobj) {
    8979        if (typeObj != null && !idobj.isEmpty()) {
    90             String url = "https://www.openstreetmap.org/" + typeObj + "/" + idobj;
    91             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    92             OpenBrowser.displayUrl(url);
     80            openInBrowser("https://www.openstreetmap.org/" + typeObj + "/" + idobj);
    9381        }
    9482    }
    9583
    9684    public static void openinBrowserIdobjOsmDeepHistory(String typeObj, String idobj) {
    9785        if (typeObj != null && !idobj.isEmpty()) {
    98             String url = "http://osmlab.github.io/osm-deep-history/#/" + typeObj + "/" + idobj;
    99             new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    100             OpenBrowser.displayUrl(url);
     86            openInBrowser("http://osmlab.github.io/osm-deep-history/#/" + typeObj + "/" + idobj);
    10187        }
    10288    }
    10389
    10490    public static void openinBrowserMapillary(String coords) {
    10591        if (coords == null || coords.isEmpty()) return;
    10692        String[] arrCoords = coords.split(",");
    107         String url = "https://www.mapillary.com/app/?lat=" + arrCoords[0] + "&lng=" + arrCoords[1] + "&z=20&focus=map&dateFrom=2017-01-01";
    108         new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    109         OpenBrowser.displayUrl(url);
    110 
     93        openInBrowser("https://www.mapillary.com/app/?lat=" + arrCoords[0] + "&lng=" + arrCoords[1] + "&z=20&focus=map&dateFrom=2017-01-01");
    11194    }
    11295
    11396    public static void openinBrowserOpenstreetcam(String coords) {
    11497        if (coords == null || coords.isEmpty()) return;
    11598        String[] arrCoords = coords.split(",");
    116         String url = "http://openstreetcam.org/map/@" + arrCoords[0] + "," + arrCoords[1] + ",18z";
    117         new Notification(tr("Open in browser " + url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
    118         OpenBrowser.displayUrl(url);
     99        openInBrowser("http://openstreetcam.org/map/@" + arrCoords[0] + "," + arrCoords[1] + ",18z");
    119100    }
    120101
     102    public static void openInBrowserYandex(String coords) {
     103        if (coords == null || coords.isEmpty()) return;
     104        String[] arrCoords = coords.split(",");
     105        openInBrowser("https://yandex.com/maps/?l=stv,sta&ll=" + arrCoords[1] + "," + arrCoords[0] + "&z=18");
     106    }
     107
     108    private static void openInBrowser(String url) {
     109        new Notification(tr("Open in browser {0}", url)).setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show();
     110        OpenBrowser.displayUrl(url);
     111    }
    121112}
  • src/org/openstreetmap/josm/plugins/osmobjinfo/OSMObjInfotDialog.java

    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 b public class OSMObjInfotDialog extends ToggleDialog {  
    4444    protected JLabel lbLinnkIdobj;
    4545    protected JLabel lbLinkMapillary;
    4646    protected JLabel lbLinkOSMcamp;
     47    protected JLabel lbLinkYandex;
    4748    protected JLabel lbLinkIdChangeset;
    4849    protected JLabel lbCopyUser;
    4950    protected JLabel lbCopyIdobj;
    public class OSMObjInfotDialog extends ToggleDialog {  
    346347    private JPanel MapillaryImages() {
    347348        JPanel jpIMapillary = new JPanel(new BorderLayout());
    348349        lbMapillary = new JLabel();
    349         lbLinkMapillary = new JLabel(ImageProvider.get("dialogs", "mapillary.png"));
    350         lbLinkOSMcamp = new JLabel(ImageProvider.get("dialogs", "openstreetcam.png"));
     350        lbLinkMapillary = new JLabel(ImageProvider.get("dialogs", "mapillary"));
     351        lbLinkOSMcamp = new JLabel(ImageProvider.get("dialogs", "openstreetcam"));
     352        // TODO replace with real image
     353        lbLinkYandex = new JLabel(ImageProvider.get("dialogs", "yandex"));
    351354        lbLinkMapillary.setCursor(new Cursor(Cursor.HAND_CURSOR));
    352355        lbLinkOSMcamp.setCursor(new Cursor(Cursor.HAND_CURSOR));
     356        lbLinkYandex.setCursor(new Cursor(Cursor.HAND_CURSOR));
    353357        JPanel jpIMapillaryOptions = new JPanel(new GridLayout(1, 2, 5, 5));
    354358        jpIMapillaryOptions.add(lbLinkMapillary);
    355359        jpIMapillaryOptions.add(lbLinkOSMcamp);
     360        jpIMapillaryOptions.add(lbLinkYandex);
    356361        //add
    357362        jpIMapillary.add(lbMapillary, BorderLayout.LINE_START);
    358363        jpIMapillary.add(jpIMapillaryOptions, BorderLayout.LINE_END);
    359         //id obj actions 
     364        //id obj actions
    360365        lbLinkMapillary.addMouseListener(new MouseAdapter() {
    361366            @Override
    362367            public void mouseClicked(MouseEvent e) {
    public class OSMObjInfotDialog extends ToggleDialog {  
    369374                OSMObjInfoActions.openinBrowserOpenstreetcam(lbMapillary.getText());
    370375            }
    371376        });
     377        lbLinkYandex.addMouseListener(new MouseAdapter() {
     378            @Override
     379            public void mouseClicked(MouseEvent e) {
     380                OSMObjInfoActions.openInBrowserYandex(lbMapillary.getText());
     381            }
     382        });
    372383        return jpIMapillary;
    373384    }
    374385}