Changeset 16555 in osm for applications/editors
- Timestamp:
- 2009-07-17T14:19:35+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersAddLayerAction.java
r16549 r16555 27 27 public void actionPerformed(ActionEvent e) { 28 28 String wpid = JOptionPane.showInputDialog(Main.parent, 29 tr(" Image id from walking-papers.org(the bit after the ?id= in the URL)"),29 tr("Enter a walking-papers.org URL or ID (the bit after the ?id= in the URL)"), 30 30 Main.pref.get("walkingpapers.last-used-id")); 31 31 32 if (wpid == null || wpid.equals("")) return; 32 // Grab id= from the URL if we need to, otherwise get an ID 33 String mungedWpId = this.getWalkingPapersId(wpid); 34 35 if (mungedWpId == null || mungedWpId.equals("")) return; 33 36 34 37 // screen-scrape details about this id from walking-papers.org 35 String wpUrl = "http://walking-papers.org/scan.php?id=" + wpid;38 String wpUrl = "http://walking-papers.org/scan.php?id=" + mungedWpId; 36 39 37 40 Pattern spanPattern = Pattern.compile("<span class=\"(\\S+)\">(\\S+)</span>"); … … 67 70 } 68 71 69 Main.pref.put("walkingpapers.last-used-id", wpid);72 Main.pref.put("walkingpapers.last-used-id", mungedWpId); 70 73 71 74 Bounds b = new Bounds(new LatLon(south, west), new LatLon(north, east)); 72 75 73 WalkingPapersLayer wpl = new WalkingPapersLayer( wpid, tile, b, minz, maxz);76 WalkingPapersLayer wpl = new WalkingPapersLayer(mungedWpId, tile, b, minz, maxz); 74 77 Main.main.addLayer(wpl); 75 78 76 79 } 77 80 81 public static String getWalkingPapersId(String wpid) { 82 if (!wpid.contains("id=")) { 83 return wpid; 84 } else { 85 // To match e.g. http://walking-papers.org/scan.php?id=53h78bbx 86 final Pattern pattern = Pattern.compile("\\?id=(\\S+)"); 87 final Matcher matcher = pattern.matcher(wpid); 88 final boolean found = matcher.find(); 89 90 if (found) { 91 return matcher.group(1); 92 } 93 } 94 return null; 95 } 78 96 }
Note:
See TracChangeset
for help on using the changeset viewer.