Changeset 32898 in osm
- Timestamp:
- 2016-09-02T21:32:04+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r32545 r32898 102 102 public static final String X_STRING = "X|LON|LONGI|.*LONGITUDE.*|EASTING"; 103 103 public static final String Y_STRING = "Y|LAT|LATI|.*LATITUDE.*|NORTHING"; 104 public static final String XY_STRING = "POINT"; 104 105 105 106 // The list of all ProjectionPatterns (filled at each constructor call) … … 107 108 108 109 // CHECKSTYLE.OFF: LineLength 109 public static final ProjectionPatterns PRJ_WGS84 = new ProjectionPatterns("GPS|WGS84|°décimaux", Projections.getProjectionByCode("EPSG:4326")); 110 public static final ProjectionPatterns PRJ_WGS84 = new ProjectionPatterns("GPS|WGS84|°décimaux|GEO", Projections.getProjectionByCode("EPSG:4326")); 110 111 public static final ProjectionPatterns PRJ_LAMBERT_93 = new ProjectionPatterns("LAMB93|L93", Projections.getProjectionByCode("EPSG:2154")); 111 112 public static final ProjectionPatterns PRJ_LAMBERT_CC_9_ZONES = new LambertCC9ZonesProjectionPatterns("LAMBZ|CC(42|43|44|45|46|47|48|49|50)"); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/ProjectionPatterns.java
r30723 r32898 11 11 private final Pattern xPattern; 12 12 private final Pattern yPattern; 13 private final Pattern xyPattern; 13 14 private final Projection projection; 14 15 public ProjectionPatterns(Pattern xPattern, Pattern yPattern, Projection projection) { 15 16 public ProjectionPatterns(Pattern xPattern, Pattern yPattern, Pattern xyPattern, Projection projection) { 16 17 this.xPattern = xPattern; 17 18 this.yPattern = yPattern; 19 this.xyPattern = xyPattern; 18 20 this.projection = projection; 19 21 OdConstants.PROJECTIONS.add(this); 20 22 } 21 23 22 public ProjectionPatterns(Pattern xPattern, Pattern yPattern) {23 this(xPattern, yPattern, null);24 }25 26 24 public ProjectionPatterns(String proj, Projection projection) { 27 this(getCoordinatePattern(OdConstants.X_STRING, proj), getCoordinatePattern(OdConstants.Y_STRING, proj), projection); 25 this(getCoordinatePattern(OdConstants.X_STRING, proj), 26 getCoordinatePattern(OdConstants.Y_STRING, proj), 27 getCoordinatePattern(OdConstants.XY_STRING, proj), projection); 28 28 } 29 29 30 30 public ProjectionPatterns(String proj) { 31 this( getCoordinatePattern(OdConstants.X_STRING, proj), getCoordinatePattern(OdConstants.Y_STRING, proj), null);31 this(proj, null); 32 32 } 33 33 34 34 public final Pattern getXPattern() { 35 35 return xPattern; 36 36 } 37 37 38 38 public final Pattern getYPattern() { 39 39 return yPattern; 40 } 41 42 public final Pattern getXYPattern() { 43 return xyPattern; 40 44 } 41 45 … … 58 62 @Override 59 63 public String toString() { 60 return "[xPattern=" + xPattern + ", yPattern=" + yPattern + ", projection=" + projection + "]";64 return "[xPattern=" + xPattern + ", yPattern=" + yPattern + ", xyPattern=" + xyPattern + ", projection=" + projection + ']'; 61 65 } 62 66 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java
r32545 r32898 15 15 import java.util.Locale; 16 16 import java.util.Map; 17 import java.util.regex.Matcher; 18 import java.util.regex.Pattern; 17 19 18 20 import org.openstreetmap.josm.Main; … … 32 34 private static final NumberFormat formatUK = NumberFormat.getInstance(Locale.UK); 33 35 36 private static final String COOR = "(\\-?\\d+(?:[\\.,]\\d+)?)"; 37 private static final Pattern LATLON_PATTERN = Pattern.compile("^"+COOR+"[,;]?\\s*"+COOR+"$"); 38 34 39 protected final SpreadSheetHandler handler; 35 40 … … 68 73 @Override 69 74 public String toString() { 70 return "CoordinateColumns [proj=" + proj + ", xCol=" + xCol + ", yCol=" + yCol + "]";75 return "CoordinateColumns [proj=" + proj + ", xCol=" + xCol + ", yCol=" + yCol + ']'; 71 76 } 72 77 } … … 91 96 } 92 97 CoordinateColumns col = columns.isEmpty() ? null : columns.get(columns.size()-1); 93 if (pp.getXPattern().matcher(header[i]).matches()) { 98 if (pp.getXYPattern().matcher(header[i]).matches()) { 99 CoordinateColumns coorCol = addCoorColIfNeeded(columns, col); 100 coorCol.xCol = i; 101 coorCol.yCol = i; 102 break; 103 } else if (pp.getXPattern().matcher(header[i]).matches()) { 94 104 addCoorColIfNeeded(columns, col).xCol = i; 95 105 break; … … 184 194 for (CoordinateColumns c : columns) { 185 195 EastNorth en = ens.get(c); 186 if (i == c.xCol) { 196 if (i == c.xCol && i == c.yCol) { 197 Matcher m = LATLON_PATTERN.matcher(fields[i]); 198 if (m.matches()) { 199 coordinate = true; 200 ens.put(c, new EastNorth(parseDouble(m.group(2)), parseDouble(m.group(1)))); 201 if (handler != null) { 202 handler.setXCol(i); 203 handler.setYCol(i); 204 } 205 } 206 } else if (i == c.xCol) { 187 207 coordinate = true; 188 208 ens.put(c, new EastNorth(parseDouble(fields[i]), en.north())); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReaderTest.java
r32545 r32898 56 56 57 57 /** 58 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/13508">#13508</a> 59 * @throws IOException if an error occurs during reading 60 */ 61 @Test 62 public void testTicket13508() throws IOException, XMLStreamException, FactoryConfigurationError { 63 try (InputStream is = TestUtils.getRegressionDataStream(13508, "arrets-de-bus0.csv")) { 64 NonRegFunctionalTests.testGeneric("#13508", CsvReader.parseDataSet(is, newHandler("EPSG:4326"), null)); 65 } 66 } 67 68 /** 58 69 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/10214">#10214</a> 59 70 * @throws IOException if an error occurs during reading
Note:
See TracChangeset
for help on using the changeset viewer.