Changeset 35284 in osm for applications
- Timestamp:
- 2020-01-13T21:45:14+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/comfort0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/comfort0/src/net/simon04/comfort0/level0l/Level0LParser.jj
r35283 r35284 17 17 <DEFAULT> //HEADER 18 18 TOKEN: { 19 <H_EOL: ("\n" | "\r" | "\r\n") > 19 <H_EOL: ("\n" | "\r" | "\r\n") > : DATA 20 20 | <H_ID: (["0"-"9"])+ > 21 21 | <NODE: "node" > … … 39 39 TOKEN: { 40 40 <D_EOL: ("\n" | "\r" | "\r\n") > 41 | <D_SPACE: " " > 41 42 | <D_ID: (["0"-"9"])+ > 42 43 | <WY: "wy" > 43 44 | <ND: "nd" > 44 45 | <REL: "rel" > 45 | <EQ: "=" > 46 | <EQ: "=" > : VALUE 46 47 | <IDENT: ["a"-"z", "A"-"Z", "_"] (["a"-"z", "A"-"Z", "_", "-", "0"-"9"])* > 48 } 49 50 <VALUE> 51 TOKEN: { 52 <V_EOL: ("\n" | "\r" | "\r\n") > : DATA 53 | <TEXT: (~["\n", "\r"])+ > 47 54 } 48 55 … … 63 70 { r.setCoor(new LatLon(Double.parseDouble(lat.image), Double.parseDouble(lon.image))); } 64 71 (<COMMENT_START> | <H_EOL>) 72 tags(r) 65 73 { return r; } 66 74 } 75 76 void tags(PrimitiveData r): 77 {} 78 { 79 ( tag(r) )* 80 } 81 82 void tag(PrimitiveData r): 83 { 84 Token k, v; 85 } 86 { 87 <D_SPACE> <D_SPACE> 88 k=<IDENT> 89 ( <D_SPACE> ) * 90 <EQ> 91 v=<TEXT> 92 <V_EOL> 93 { r.put(k.image.trim(), v.image.trim()); } 94 } -
applications/editors/josm/plugins/comfort0/test/unit/net/simon04/comfort0/level0l/parsergen/Level0LParserTest.java
r35283 r35284 2 2 3 3 import static org.hamcrest.CoreMatchers.is; 4 import static org.junit.Assert. *;4 import static org.junit.Assert.assertThat; 5 5 6 6 import java.io.StringReader; … … 12 12 @Test 13 13 public void testNode() throws Exception { 14 final NodeData node = new Level0LParser(new StringReader("node 298884272: 54.0901447, 12.2516513\n")).node(); 14 final String level0l = "" + 15 "node 298884272: 54.0901447, 12.2516513\n" + 16 " name = Neu Broderstorf\n" + 17 " traffic_sign = city_limit\n"; 18 final NodeData node = new Level0LParser(new StringReader(level0l)).node(); 15 19 assertThat(node.getId(), is(298884272L)); 16 20 assertThat(node.getCoor().lat(), is(54.0901447)); 17 21 assertThat(node.getCoor().lon(), is(12.2516513)); 18 22 assertThat(node.getKeys().size(), is(2)); 23 assertThat(node.getKeys().get("name"), is("Neu Broderstorf")); 24 assertThat(node.getKeys().get("traffic_sign"), is("city_limit")); 19 25 } 20 26 }
Note:
See TracChangeset
for help on using the changeset viewer.