Changeset 29493 in osm for applications/editors/josm/plugins/opendata/src
- Timestamp:
- 2013-04-14T15:54:06+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r29299 r29493 60 60 public static final String PREF_MAXDISTANCE = "opendata.maxdistance"; 61 61 public static final double DEFAULT_MAXDISTANCE = 10; 62 63 public static final String PREF_TOLERANCE = "opendata.spreadsheet.tolerance"; 64 public static final double DEFAULT_TOLERANCE = 0.1; 62 65 63 66 public static final String PREF_MODULES = "opendata.modules"; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java
r29299 r29493 72 72 73 73 public static class CoordinateColumns { 74 public Projection proj = null; 74 75 public int xCol = -1; 75 76 public int yCol = -1; … … 77 78 return xCol > -1 && yCol > -1; 78 79 } 79 @Override 80 public String toString() { 81 return "[xCol=" + xCol + ", yCol=" + yCol + "]"; 80 @Override public String toString() { 81 return "CoordinateColumns [proj=" + proj + ", xCol=" + xCol + ", yCol=" + yCol + "]"; 82 82 } 83 83 } … … 112 112 } 113 113 114 Projection proj = null;115 114 final List<CoordinateColumns> columns = new ArrayList<CoordinateColumns>(); 116 115 … … 119 118 if (col.isOk()) { 120 119 columns.add(col); 121 if ( proj == null) {122 proj = pp.getProjection(header[col.xCol], header[col.yCol]);120 if (col.proj == null) { 121 col.proj = pp.getProjection(header[col.xCol], header[col.yCol]); 123 122 } 124 123 } … … 128 127 final boolean handlerOK = handler != null && handler.handlesProjection(); 129 128 130 if (proj != null) { 129 boolean projFound = false; 130 131 for (CoordinateColumns c : columns) { 132 if (c.proj != null) { 133 projFound = true; 134 break; 135 } 136 } 137 138 if (projFound) { 131 139 // projection identified, do nothing 132 140 } else if (!columns.isEmpty()) { … … 137 145 return null; // User clicked Cancel 138 146 } 139 proj = dialog.getProjection(); 147 Projection proj = dialog.getProjection(); 148 for (CoordinateColumns c : columns) { 149 c.proj = proj; 150 } 140 151 } 141 152 … … 149 160 message += "; "; 150 161 } 151 message += header[c.xCol]+", "+header[c.yCol];152 } 153 154 System.out.println("Loading data using projection "+proj+" ("+message+")");162 message += c.proj + "("+header[c.xCol]+", "+header[c.yCol]+")"; 163 } 164 165 System.out.println("Loading data using projections "+message); 155 166 156 167 final DataSet ds = new DataSet(); … … 204 215 } 205 216 } 217 Node firstNode = null; 206 218 for (CoordinateColumns c : columns) { 207 219 Node n = nodes.get(c); 208 220 EastNorth en = ens.get(c); 209 221 if (en.isValid()) { 210 n.setCoor( proj != null && !handlerOK ?proj.eastNorth2latlon(en) : handler.getCoor(en, fields));222 n.setCoor(c.proj != null && !handlerOK ? c.proj.eastNorth2latlon(en) : handler.getCoor(en, fields)); 211 223 } else { 212 224 System.err.println("Warning: Skipping line "+lineNumber+" because no valid coordinates have been found at columns "+c); 213 225 } 214 226 if (n.getCoor() != null) { 215 ds.addPrimitive(n); 227 if (firstNode == null) { 228 firstNode = n; 229 } 230 if (n == firstNode || n.getCoor().greatCircleDistance(firstNode.getCoor()) > Main.pref.getDouble(PREF_TOLERANCE, DEFAULT_TOLERANCE)) { 231 ds.addPrimitive(n); 232 } else { 233 nodes.remove(c); 234 } 216 235 } 217 236 }
Note:
See TracChangeset
for help on using the changeset viewer.