Changeset 35240 in osm for applications
- Timestamp:
- 2019-11-30T18:25:05+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/model/IndoorLevel.java
r34734 r35240 19 19 package model; 20 20 21 import java.util.regex.Matcher; 22 import java.util.regex.Pattern; 23 21 24 import org.openstreetmap.josm.data.osm.Tag; 22 25 … … 30 33 31 34 public class IndoorLevel { 35 36 private static final Pattern RANGE = Pattern.compile("(-?[0-9]+)-(-?[0-9]+)"); 32 37 33 38 private Tag levelNumberTag; … … 119 124 for (String val : vals.split(";")) { 120 125 int firstVal, secVal; 126 Matcher m = RANGE.matcher(val); 121 127 122 128 //Extract values 123 if (val.indexOf("-") == 0) { 124 firstVal = Integer.parseInt(val.split("-", 2)[1].split("-", 2)[0])*-1; 125 secVal = Integer.parseInt(val.split("-", 2)[1].split("-", 2)[1]); 126 } else if (val.contains("-")) { 127 firstVal = Integer.parseInt(val.split("-")[0]); 128 secVal = Integer.parseInt(val.split("-")[1]); 129 if (m.matches()) { 130 firstVal = Integer.parseInt(m.group(1)); 131 secVal = Integer.parseInt(m.group(2)); 129 132 } else { 130 133 firstVal = Integer.parseInt(val); -
applications/editors/josm/plugins/indoorhelper/test/unit/model/IndoorLevelTest.java
r34309 r35240 17 17 @Test 18 18 public void testIsPartOfWorkingLevel() { 19 assertTrue(IndoorLevel.isPartOfWorkingLevel("-3--1", -3)); 20 assertTrue(IndoorLevel.isPartOfWorkingLevel("-3--1", -2)); 21 assertTrue(IndoorLevel.isPartOfWorkingLevel("-3--1", -1)); 22 assertFalse(IndoorLevel.isPartOfWorkingLevel("-3--1", 0)); 23 24 assertTrue(IndoorLevel.isPartOfWorkingLevel("-1;0;1", -1)); 25 assertTrue(IndoorLevel.isPartOfWorkingLevel("-1;0;1", 0)); 26 assertTrue(IndoorLevel.isPartOfWorkingLevel("-1;0;1", 1)); 27 19 28 assertFalse(IndoorLevel.isPartOfWorkingLevel("1;2", 0)); 20 29 assertTrue(IndoorLevel.isPartOfWorkingLevel("1;2", 1));
Note:
See TracChangeset
for help on using the changeset viewer.