Changeset 5345 in josm for trunk/src/org
- Timestamp:
- 2012-07-15T16:34:27+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmBzip2Task.java
r5317 r5345 3 3 4 4 import java.util.concurrent.Future; 5 import java.util.regex.Matcher;6 import java.util.regex.Pattern;7 5 8 6 import org.openstreetmap.josm.Main; … … 49 47 currentBounds = null; 50 48 // Extract .osm.bz/bz2 filename from URL to set the new layer name 51 Matcher matcher = Pattern.compile("http://.*/(.*\\.osm.bz2?)").matcher(url); 52 newLayerName = matcher.matches() ? matcher.group(1) : null; 49 extractOsmFilename("http://.*/(.*\\.osm.bz2?)", url); 53 50 return Main.worker.submit(downloadTask); 54 51 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java
r5171 r5345 36 36 @Override 37 37 public boolean acceptsUrl(String url) { 38 return url != null && url.matches("http://.*/api/0.6/changeset/\\p{Digit}+/download"); 38 return url != null && ( 39 url.matches("http://.*/api/0.6/changeset/\\p{Digit}+/download") // OSM API 0.6 changesets 40 || url.matches("http://.*/.*\\.osc") // Remote .osc files 41 ); 39 42 } 40 43 … … 57 60 new OsmServerLocationReader(url), 58 61 progressMonitor); 62 // Extract .osc filename from URL to set the new layer name 63 extractOsmFilename("http://.*/(.*\\.osc)", url); 59 64 return Main.worker.submit(downloadTask); 60 65 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r5097 r5345 76 76 currentBounds = null; 77 77 // Extract .osm filename from URL to set the new layer name 78 Matcher matcher = Pattern.compile("http://.*/(.*\\.osm)").matcher(url); 78 extractOsmFilename("http://.*/(.*\\.osm)", url); 79 return Main.worker.submit(downloadTask); 80 } 81 82 protected final void extractOsmFilename(String pattern, String url) { 83 Matcher matcher = Pattern.compile(pattern).matcher(url); 79 84 newLayerName = matcher.matches() ? matcher.group(1) : null; 80 return Main.worker.submit(downloadTask);81 85 } 82 86 -
trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java
r5266 r5345 4 4 5 5 import java.io.InputStream; 6 import java.util.Arrays; 6 7 7 8 import javax.xml.stream.XMLStreamConstants; … … 14 15 public class OsmChangeReader extends OsmReader { 15 16 17 public static final String[] ACTIONS = {"create", "modify", "delete"}; 18 16 19 /** 17 20 * constructor (for private and subclasses use only) … … 46 49 int event = parser.next(); 47 50 if (event == XMLStreamConstants.START_ELEMENT) { 48 if (parser.getLocalName().equals("create")) { 49 parseCreate(); 50 } else if (parser.getLocalName().equals("modify")) { 51 parseModify(); 52 } else if (parser.getLocalName().equals("delete")) { 53 parseDelete(); 51 if (Arrays.asList(ACTIONS).contains(parser.getLocalName())) { 52 parseCommon(parser.getLocalName()); 54 53 } else { 55 54 parseUnknown(); … … 61 60 } 62 61 63 private void parseDelete() throws XMLStreamException { 64 parseCommon(true); 65 } 66 67 private void parseModify() throws XMLStreamException { 68 parseCommon(false); 69 } 70 71 private void parseCreate() throws XMLStreamException { 72 parseCommon(false); 73 } 74 75 private void parseCommon(boolean deletePrimitive) throws XMLStreamException { 62 private void parseCommon(String action) throws XMLStreamException { 76 63 while (parser.hasNext()) { 77 64 int event = parser.next(); … … 87 74 parseUnknown(); 88 75 } 89 if (p != null && deletePrimitive) { 90 p.setDeleted(true); 76 if (p != null && action != null) { 77 if (action.equals("modify")) { 78 p.setModified(true); 79 } else if (action.equals("delete")) { 80 p.setDeleted(true); 81 } 91 82 } 92 83 } else if (event == XMLStreamConstants.END_ELEMENT) {
Note:
See TracChangeset
for help on using the changeset viewer.