Changeset 35285 in osm for applications
- Timestamp:
- 2020-01-13T21:45:18+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
r35284 r35285 46 46 | <EQ: "=" > : VALUE 47 47 | <IDENT: ["a"-"z", "A"-"Z", "_"] (["a"-"z", "A"-"Z", "_", "-", "0"-"9"])* > 48 | <D_COMMENT_START: "#"> : COMMENT 48 49 } 49 50 … … 69 70 lon=<FLOAT> 70 71 { r.setCoor(new LatLon(Double.parseDouble(lat.image), Double.parseDouble(lon.image))); } 71 ( <COMMENT_START> | <H_EOL>)72 tags(r)72 ( <COMMENT_START> | <H_EOL> ) 73 ( tag(r) )* 73 74 { return r; } 74 75 } 75 76 76 void tags(PrimitiveData r): 77 WayData way(): 78 { 79 WayData r; 80 Token id; 81 } 82 { 83 <WAY> 84 { r = new WayData(); } 85 id=<H_ID> 86 { r.setId(Long.parseLong(id.image)); } 87 ( <COMMENT_START> | <H_EOL> ) 88 way_data(r) 89 { return r; } 90 } 91 92 void way_data(WayData r): 77 93 {} 78 94 { 95 LOOKAHEAD(3) 96 ( way_node(r) way_data(r) ) // TODO avoid recursive call to way_data 97 | 79 98 ( tag(r) )* 99 } 100 101 void way_node(WayData r): 102 { 103 Token id; 104 } 105 { 106 <D_SPACE> <D_SPACE> 107 <ND> 108 ( <D_SPACE> )+ 109 id=<D_ID> 110 { r.getNodeIds().add(Long.parseLong(id.image)); } 111 ( <D_SPACE> )* 112 ( <D_COMMENT_START> | <D_EOL> ) 80 113 } 81 114 -
applications/editors/josm/plugins/comfort0/test/unit/net/simon04/comfort0/level0l/parsergen/Level0LParserTest.java
r35284 r35285 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.data.osm.NodeData; 10 import org.openstreetmap.josm.data.osm.WayData; 10 11 11 12 public class Level0LParserTest { … … 24 25 assertThat(node.getKeys().get("traffic_sign"), is("city_limit")); 25 26 } 27 28 @Test 29 public void testWay() throws Exception { 30 final String level0l = "" + 31 "way 26659127\n" + 32 " nd 292403538\n" + 33 " nd 298884289\n" + 34 " nd 261728686\n" + 35 " highway = unclassified\n" + 36 " name = Pastower Straße\n"; 37 final WayData way = new Level0LParser(new StringReader(level0l)).way(); 38 assertThat(way.getId(), is(26659127L)); 39 assertThat(way.getNodesCount(), is(3)); 40 assertThat(way.getNodeId(0), is(292403538L)); 41 assertThat(way.getNodeId(1), is(298884289L)); 42 assertThat(way.getNodeId(2), is(261728686L)); 43 assertThat(way.getKeys().size(), is(2)); 44 assertThat(way.getKeys().get("highway"), is("unclassified")); 45 assertThat(way.getKeys().get("name"), is("Pastower Straße")); 46 } 26 47 }
Note:
See TracChangeset
for help on using the changeset viewer.