Dirk Stöcker writes:
http://josm.openstreetmap.de/ticket/1712
Incomplete ways are discarded without notice
This is a minimal patch. I didn't want to make too many changes
because somebody else is going to have to read this patch before they
apply it. I don't know Java very well, so if anybody spots anything
un-Javanic, please tell me.
Potential improvements:
o convert all invocations of OsmReader.parseDataSet() to
OsmReader.parseDataSetOsm() to gain access to getParseNotes().
o Doing something more sensible with the output presentation if
there are too many warnings than can fit on the screen (or will it
switch to a scrollbox?)
o It's possible that DataSet ought to be the entity that has
parseNotes. That would make for a simpler patch, but not
necessarily more correct.
Index: src/org/openstreetmap/josm/actions/OpenFileAction.java
===
--- src/org/openstreetmap/josm/actions/OpenFileAction.java (revision 1180)
+++ src/org/openstreetmap/josm/actions/OpenFileAction.java (working copy)
@@ -74,10 +74,14 @@
private void openAsData(File file) throws SAXException, IOException,
FileNotFoundException {
String fn = file.getName();
if
(ExtensionFileFilter.filters[ExtensionFileFilter.OSM].acceptName(fn)) {
-DataSet dataSet = OsmReader.parseDataSet(new
FileInputStream(file), null, Main.pleaseWaitDlg);
+OsmReader osm = OsmReader.parseDataSetOsm(new
FileInputStream(file), null, Main.pleaseWaitDlg);
+DataSet dataSet = osm.getDs();
OsmDataLayer layer = new OsmDataLayer(dataSet, file.getName(),
file);
Main.main.addLayer(layer);
layer.fireDataChange();
+if (osm.getParseNotes().length() != 0) {
+JOptionPane.showMessageDialog(Main.parent,
osm.getParseNotes());
+}
}
else
JOptionPane.showMessageDialog(Main.parent, fn+: +tr(Unknown
file extension: {0}, fn.substring(file.getName().lastIndexOf('.')+1)));
Index: src/org/openstreetmap/josm/io/OsmReader.java
===
--- src/org/openstreetmap/josm/io/OsmReader.java(revision 1180)
+++ src/org/openstreetmap/josm/io/OsmReader.java(working copy)
@@ -59,8 +59,18 @@
* The dataset to add parsed objects to.
*/
private DataSet ds = new DataSet();
+ public DataSet getDs() { return ds; }
/**
+ * Record warnings. If there were any data inconsistencies, append
+ * a newline-terminated string.
+ */
+ private String parseNotes = new String();
+ public String getParseNotes() {
+ return parseNotes;
+ }
+
+ /**
* The visitor to use to add the data to the set.
*/
private AddVisitor adder = new AddVisitor(ds);
@@ -332,6 +342,7 @@
for (long id : e.getValue()) {
Node n = findNode(id);
if (n == null) {
+ parseNotes += Skipping a way because it includes a
node that doesn't exist: + id + \n;
failed = true;
break;
}
@@ -434,6 +445,10 @@
* elemet found there is returned.
*/
public static DataSet parseDataSet(InputStream source, DataSet ref,
PleaseWaitDialog pleaseWaitDlg) throws SAXException, IOException {
+ return parseDataSetOsm(source, ref, pleaseWaitDlg).ds;
+ }
+
+ public static OsmReader parseDataSetOsm(InputStream source, DataSet ref,
PleaseWaitDialog pleaseWaitDlg) throws SAXException, IOException {
OsmReader osm = new OsmReader();
osm.references = ref == null ? new DataSet() : ref;
@@ -467,6 +482,6 @@
if (o.id 0)
o.id = 0;
- return osm.ds;
+ return osm;
}
}
___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev