- Timestamp:
- 2024-05-31T21:52:43+02:00 (8 months ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
r19089 r19092 1188 1188 * Convert a length unit to meters 1189 1189 * <p> 1190 * Tries to convert a length unit to meter value or returns a -when impossible1190 * Tries to convert a length unit to meter value or returns {@code null} when impossible 1191 1191 * @param s arbitrary string representing a length 1192 1192 * @return the length converted to meters … … 1201 1201 Logging.debug(e); 1202 1202 } 1203 return "-";1203 return null; 1204 1204 } 1205 1205 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19090 r19092 91 91 private static final Pattern REMOVE_DIACRITICS = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); 92 92 93 private static final Pattern PATTERN_LENGTH = Pattern.compile("^(\\d+(?:\\.\\d+)?)(cm|m m|m|ft|in|'|\")?$");94 private static final Pattern PATTERN_LENGTH2 = Pattern.compile("^(\\d+(?:\\.\\d+)?)(ft|')(\\d+(?:\\.\\d+)?)(in|\")?$"); 93 private static final Pattern PATTERN_LENGTH = Pattern.compile("^(-?\\d+(?:\\.\\d+)?)(cm|mi|mm|m|ft|km|nmi|in|'|\")?$"); 94 private static final Pattern PATTERN_LENGTH2 = Pattern.compile("^(-?)(\\d+(?:\\.\\d+)?)(ft|')(\\d+(?:\\.\\d+)?)(in|\")?$"); 95 95 96 96 private static final String DEFAULT_STRIP = "\uFEFF\u200B"; … … 2078 2078 else if ("mm".equals(m.group(2))) 2079 2079 v *= 0.001; 2080 else if ("km".equals(m.group(2))) 2081 v *= 1000.0; 2082 else if ("nmi".equals(m.group(2))) 2083 v *= 1852.0; 2084 else if ("mi".equals(m.group(2))) 2085 v *= 1609.344; 2080 2086 else if ("ft".equals(m.group(2)) || "'".equals(m.group(2))) 2081 2087 v *= 0.3048; … … 2086 2092 m = PATTERN_LENGTH2.matcher(s); 2087 2093 if (m.matches()) { 2088 return Double.valueOf(m.group(1))*0.3048+Double.valueOf(m.group(3))*0.0254; 2094 /* NOTE: we assume -a'b" means -(a'+b") and not (-a')+b" - because of such issues SI units have been invented 2095 and have been adapted by the majority of the world */ 2096 return (Double.valueOf(m.group(2))*0.3048+Double.valueOf(m.group(4))*0.0254)*(m.group(1).isEmpty()?1.0:-1.0); 2089 2097 } 2090 2098 }
Note:
See TracChangeset
for help on using the changeset viewer.