- Timestamp:
- 2018-04-07T20:42:34+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Bounds.java
r13173 r13602 355 355 public String toShortString(DecimalFormat format) { 356 356 return format.format(minLat) + ' ' 357 + format.format(minLon) + " / "358 + format.format(maxLat) + ' '359 + format.format(maxLon);357 + format.format(minLon) + " / " 358 + format.format(maxLat) + ' ' 359 + format.format(maxLon); 360 360 } 361 361 … … 513 513 */ 514 514 public double getArea() { 515 double w = getWidth(); 516 return w * (maxLat - minLat); 515 return getWidth() * (maxLat - minLat); 517 516 } 518 517 … … 523 522 */ 524 523 public String encodeAsString(String separator) { 525 StringBuilder sb = new StringBuilder(); 526 sb.append(minLat).append(separator).append(minLon) 527 .append(separator).append(maxLat).append(separator) 528 .append(maxLon); 529 return sb.toString(); 524 return new StringBuilder() 525 .append(minLat).append(separator).append(minLon).append(separator) 526 .append(maxLat).append(separator).append(maxLon).toString(); 530 527 } 531 528 … … 574 571 Bounds bounds = (Bounds) obj; 575 572 return Double.compare(bounds.minLat, minLat) == 0 && 576 577 578 573 Double.compare(bounds.minLon, minLon) == 0 && 574 Double.compare(bounds.maxLat, maxLat) == 0 && 575 Double.compare(bounds.maxLon, maxLon) == 0; 579 576 } 580 577 } -
trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java
r12838 r13602 50 50 private static final Pattern P_XML = Pattern.compile( 51 51 "lat=[\"']([+|-]?\\d+[.,]\\d+)[\"']\\s+lon=[\"']([+|-]?\\d+[.,]\\d+)[\"']"); 52 53 private static final String FLOAT = "(\\d+(\\.\\d*)?)"; 54 /** Degree-Minute-Second pattern **/ 55 private static final String DMS = "(?<neg1>-)?" 56 + "(?=\\d)(?:(?<single>" + FLOAT + ")|" 57 + "((?<degree>" + FLOAT + ")d)?" 58 + "((?<minutes>" + FLOAT + ")\')?" 59 + "((?<seconds>" + FLOAT + ")\")?)" 60 + "(?:[NE]|(?<neg2>[SW]))?"; 61 private static final Pattern P_DMS = Pattern.compile("^" + DMS + "$"); 52 62 53 63 private static class LatLonHolder { … … 199 209 */ 200 210 public static double parseCoordinate(String angleStr) { 201 final String floatPattern = "(\\d+(\\.\\d*)?)";202 211 // pattern does all error handling. 203 Matcher in = Pattern.compile("^(?<neg1>-)?" 204 + "(?=\\d)(?:(?<single>" + floatPattern + ")|" 205 + "((?<degree>" + floatPattern + ")d)?" 206 + "((?<minutes>" + floatPattern + ")\')?" 207 + "((?<seconds>" + floatPattern + ")\")?)" 208 + "(?:[NE]|(?<neg2>[SW]))?$").matcher(angleStr); 212 Matcher in = P_DMS.matcher(angleStr); 209 213 210 214 if (!in.find()) { -
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r13599 r13602 315 315 List<ProjectionDefinition> result = new ArrayList<>(); 316 316 Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>"); 317 String coor = "(-?\\d+\\.\\d+)"; 318 Pattern areaPattern = Pattern.compile("# area: \\(lat: "+coor+", "+coor+"\\) - \\(lon: "+coor+", "+coor+"\\).*"); 317 319 StringBuilder sb = new StringBuilder(); 320 String bounds = null; 318 321 String line; 319 322 while ((line = r.readLine()) != null) { 320 323 line = line.trim(); 321 if (!line.isEmpty() ) {324 if (!line.isEmpty() && !line.startsWith("##")) { 322 325 if (!line.startsWith("#")) { 323 326 Matcher m = epsgPattern.matcher(line); … … 325 328 String code = "EPSG:" + m.group(1); 326 329 String definition = m.group(2).trim(); 330 if (!definition.contains("+bounds=") && bounds != null) { 331 definition += bounds; 332 } 327 333 result.add(new ProjectionDefinition(code, sb.toString(), definition)); 328 334 } else { … … 330 336 } 331 337 sb.setLength(0); 332 } else if (!line.startsWith("# area: ")) { 338 bounds = null; 339 } else if (line.startsWith("# area: ")) { 340 Matcher m = areaPattern.matcher(line); 341 if (m.matches()) { 342 bounds = " +bounds=" + String.join(",", m.group(3), m.group(1), m.group(4), m.group(2)); 343 } 344 } else { 345 String s = line.substring(1).trim(); 333 346 if (sb.length() == 0) { 334 sb.append( line.substring(1).trim());347 sb.append(s); 335 348 } else { 336 sb.append('(').append( line.substring(1).trim()).append(')');349 sb.append('(').append(s).append(')'); 337 350 } 338 351 }
Note:
See TracChangeset
for help on using the changeset viewer.