@wemap/osm 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"code":"Ok","routes":[{"geometry":{"coordinates":[[3.89678,43.600032],[3.896532,43.600216],[3.896247,43.600432],[3.896188,43.600488],[3.896151,43.600523],[3.895937,43.600726],[3.895824,43.600837],[3.89566,43.601048],[3.895605,43.601131],[3.895549,43.601243],[3.895511,43.601337],[3.895492,43.601413],[3.895485,43.601506],[3.89549,43.601585],[3.895549,43.601785],[3.895413,43.60181],[3.895353,43.601826],[3.895305,43.601628],[3.8953,43.60157],[3.89532,43.60143]],"type":"LineString"},"legs":[{"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[316],"location":[3.89678,43.600032]}],"driving_side":"right","geometry":{"coordinates":[[3.89678,43.600032],[3.896532,43.600216],[3.896247,43.600432],[3.896188,43.600488],[3.896151,43.600523],[3.895937,43.600726],[3.895824,43.600837],[3.89566,43.601048],[3.895605,43.601131],[3.895549,43.601243],[3.895511,43.601337],[3.895492,43.601413],[3.895485,43.601506],[3.89549,43.601585],[3.895549,43.601785]],"type":"LineString"},"mode":"walking","duration":165.6,"maneuver":{"bearing_after":316,"type":"depart","modifier":"right","bearing_before":0,"location":[3.89678,43.600032]},"weight":165.6,"distance":230.1,"name":""},{"intersections":[{"out":2,"location":[3.895549,43.601785],"bearings":[15,195,285],"entry":[true,false,true],"in":1}],"driving_side":"right","geometry":{"coordinates":[[3.895549,43.601785],[3.895413,43.60181],[3.895353,43.601826]],"type":"LineString"},"mode":"walking","duration":11.8,"maneuver":{"bearing_after":284,"type":"turn","modifier":"left","bearing_before":11,"location":[3.895549,43.601785]},"weight":11.8,"distance":16.5,"name":""},{"intersections":[{"out":2,"location":[3.895353,43.601826],"bearings":[15,105,195,285],"entry":[true,false,true,true],"in":1}],"driving_side":"right","geometry":{"coordinates":[[3.895353,43.601826],[3.895305,43.601628],[3.8953,43.60157],[3.89532,43.60143]],"type":"LineString"},"mode":"walking","duration":32.2,"maneuver":{"bearing_after":189,"type":"turn","modifier":"left","bearing_before":286,"location":[3.895353,43.601826]},"weight":32.2,"distance":44.5,"name":""},{"intersections":[{"in":0,"entry":[true],"bearings":[354],"location":[3.89532,43.60143]}],"driving_side":"right","geometry":{"coordinates":[[3.89532,43.60143],[3.89532,43.60143]],"type":"LineString"},"mode":"walking","duration":0,"maneuver":{"bearing_after":0,"location":[3.89532,43.60143],"bearing_before":174,"type":"arrive"},"weight":0,"distance":0,"name":""}],"distance":291,"duration":209.6,"summary":"","weight":209.6}],"distance":291,"duration":209.6,"weight_name":"duration","weight":209.6}],"waypoints":[{"hint":"4dUHgOOrJ4DOAAAAnwAAAKoFAAB5AwAAzgAAAJ8AAACqBQAAeQMAAAIAAADMdTsAoEiZAjd2OwDrSJkCDQB_CA61bn8=","name":"","location":[3.89678,43.600032]},{"hint":"3vZTgejVB4AEAAAAcgAAAF8AAADQAAAABAAAAHIAAABfAAAA0AAAAAIAAAAYcDsAFk6ZAhdwOwAWTpkCAgAvFg61bn8=","name":"","location":[3.89532,43.60143]}]}
1
+ {"code":"Ok","routes":[{"geometry":{"coordinates":[[3.875607,43.600777],[3.875723,43.600109],[3.875766,43.600086],[3.876247,43.599974],[3.876341,43.599956],[3.876396,43.599881],[3.876234,43.599853],[3.875869,43.599787],[3.875829,43.599781],[3.875671,43.599759],[3.875643,43.599755],[3.875606,43.599749],[3.875578,43.599746],[3.875498,43.599734],[3.87536,43.599707],[3.875169,43.599674],[3.874655,43.599577],[3.874623,43.599063],[3.873865,43.59906]],"type":"LineString"},"legs":[{"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[173],"location":[3.875607,43.600777]}],"driving_side":"right","geometry":{"coordinates":[[3.875607,43.600777],[3.875723,43.600109],[3.875766,43.600086],[3.876247,43.599974],[3.876341,43.599956],[3.876396,43.599881]],"type":"LineString"},"mode":"walking","duration":98.7,"maneuver":{"bearing_after":173,"type":"depart","modifier":"left","bearing_before":0,"location":[3.875607,43.600777]},"weight":98.7,"distance":137.2,"name":""},{"intersections":[{"out":1,"location":[3.876396,43.599881],"bearings":[75,255,330],"entry":[true,true,false],"in":2},{"out":2,"location":[3.876234,43.599853],"bearings":[75,180,255],"entry":[false,true,true],"in":0},{"out":2,"location":[3.875829,43.599781],"bearings":[75,195,255],"entry":[false,true,true],"in":0},{"out":2,"location":[3.875643,43.599755],"bearings":[75,135,255],"entry":[false,true,true],"in":0},{"out":2,"location":[3.875498,43.599734],"bearings":[75,165,255,345],"entry":[false,true,true,true],"in":0},{"out":2,"location":[3.875169,43.599674],"bearings":[75,180,255],"entry":[false,true,true],"in":0}],"driving_side":"right","geometry":{"coordinates":[[3.876396,43.599881],[3.876234,43.599853],[3.875869,43.599787],[3.875829,43.599781],[3.875671,43.599759],[3.875643,43.599755],[3.875606,43.599749],[3.875578,43.599746],[3.875498,43.599734],[3.87536,43.599707],[3.875169,43.599674],[3.874655,43.599577]],"type":"LineString"},"mode":"walking","duration":103.9,"maneuver":{"bearing_after":255,"type":"turn","modifier":"right","bearing_before":149,"location":[3.876396,43.599881]},"weight":103.9,"distance":144.3,"name":"Boulevard Vieussens"},{"intersections":[{"out":1,"location":[3.874655,43.599577],"bearings":[75,180,255],"entry":[false,true,true],"in":0}],"driving_side":"right","geometry":{"coordinates":[[3.874655,43.599577],[3.874623,43.599063]],"type":"LineString"},"mode":"walking","duration":41.2,"maneuver":{"bearing_after":181,"type":"turn","modifier":"left","bearing_before":254,"location":[3.874655,43.599577]},"weight":41.2,"distance":57.2,"name":"Impasse Bizeray"},{"intersections":[{"out":2,"location":[3.874623,43.599063],"bearings":[0,90,270],"entry":[false,true,true],"in":0}],"driving_side":"right","geometry":{"coordinates":[[3.874623,43.599063],[3.873865,43.59906]],"type":"LineString"},"mode":"walking","duration":44,"maneuver":{"bearing_after":268,"type":"turn","modifier":"right","bearing_before":181,"location":[3.874623,43.599063]},"weight":44,"distance":61.1,"name":"Rue du Docteur Louis Perrier"},{"intersections":[{"in":0,"entry":[true],"bearings":[90],"location":[3.873865,43.59906]}],"driving_side":"right","geometry":{"coordinates":[[3.873865,43.59906],[3.873865,43.59906]],"type":"LineString"},"mode":"walking","duration":0,"maneuver":{"bearing_after":0,"type":"arrive","modifier":"left","bearing_before":270,"location":[3.873865,43.59906]},"weight":0,"distance":0,"name":"Rue du Docteur Louis Perrier"}],"distance":399.7,"duration":287.8,"summary":"Boulevard Vieussens, Boulevard Berthelot","weight":287.8}],"distance":399.7,"duration":287.8,"weight_name":"duration","weight":287.8}],"waypoints":[{"hint":"d89TgaHPU4GmAQAAGwIAAB0AAADAAQAApgEAABsCAAAdAAAAwAEAAAIAAAAXIzsAiUuZAoojOwCTS5kCAQDPCg61bn8=","name":"","location":[3.875607,43.600777]},{"hint":"dNRTgZbUU4FHAAAAuAEAAIMAAAAAAAAARwAAALgBAACDAAAAAAAAAAIAAABJHDsA1ESZAkocOwAdRJkCAwCfBQ61bn8=","name":"Rue du Docteur Louis Perrier","location":[3.873865,43.59906]}]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "directory": "packages/osm"
12
12
  },
13
13
  "name": "@wemap/osm",
14
- "version": "0.2.9",
14
+ "version": "0.2.11",
15
15
  "bugs": {
16
16
  "url": "https://github.com/wemap/wemap-utils-js/issues"
17
17
  },
@@ -26,10 +26,10 @@
26
26
  ],
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
- "@wemap/geo": "^0.3.7",
29
+ "@wemap/geo": "^0.3.9",
30
30
  "@wemap/logger": "^0.1.6",
31
31
  "lodash.isnumber": "^3.0.3",
32
32
  "sax": "^1.2.4"
33
33
  },
34
- "gitHead": "dfef19c363ee76ad4b4e23f9e36912034c10ccca"
34
+ "gitHead": "84a60e64b0968bc45f0f76cc26c08e165dbe6985"
35
35
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-statements */
1
2
  import sax from 'sax';
2
3
 
3
4
  import { Level } from '@wemap/geo';
@@ -16,16 +17,24 @@ class OsmParser {
16
17
 
17
18
  let buffer;
18
19
 
20
+ const isDeleted = element => element.attributes.action && element.attributes.action === 'delete';
21
+
19
22
  parser.onopentag = (node) => {
20
23
 
21
24
  switch (node.name) {
22
25
  case 'node': {
26
+ if (isDeleted(node)) {
27
+ break;
28
+ }
23
29
  const osmNode = OsmNode.fromSax(node.attributes);
24
30
  buffer = osmNode;
25
31
  model.nodes.push(osmNode);
26
32
  break;
27
33
  }
28
34
  case 'way': {
35
+ if (isDeleted(node)) {
36
+ break;
37
+ }
29
38
  const osmWay = OsmWay.fromSax(node.attributes);
30
39
  buffer = osmWay;
31
40
  model.ways.push(osmWay);
@@ -175,18 +175,41 @@ class OsrmUtils {
175
175
 
176
176
  for (let i = 0; i < steps.length; i++) {
177
177
  const step = steps[i];
178
+
179
+ const nodeData = {};
180
+ const nextEdgeData = {};
181
+
178
182
  if (step.wemap) {
183
+ if (step.wemap.nodeTags) {
184
+ nodeData.tags = step.wemap.nodeTags;
185
+ }
186
+
187
+ if (step.wemap.nextEdgeTags) {
188
+ nextEdgeData.osmTags = step.wemap.nextEdgeTags;
189
+ if (nextEdgeData.osmTags.name) {
190
+ nextEdgeData.name = nextEdgeData.osmTags.name;
191
+ }
192
+ }
193
+ }
194
+
195
+ if (step.name) {
196
+ nextEdgeData.name = step.name;
197
+ }
198
+
199
+ const hasNodeData = Object.keys(nodeData).length !== 0;
200
+ const hasNextEdgeData = Object.keys(nextEdgeData).length !== 0;
201
+ if (hasNodeData || hasNextEdgeData) {
179
202
  const stepLocation = step.maneuver.location;
180
203
  const location = OsrmUtils.jsonToWgs84(stepLocation);
181
204
  const existingNode = itinerary.getNodeByCoords(location);
182
205
 
183
- if (step.wemap.nodeTags) {
184
- existingNode.data = { tags: step.wemap.nodeTags };
206
+ if (hasNodeData) {
207
+ existingNode.data = nodeData;
185
208
  }
186
209
 
187
- if (step.wemap.nextEdgeTags) {
210
+ if (hasNextEdgeData && i !== steps.length - 1) {
188
211
  const nextEdge = existingNode.edges[i === 0 ? 0 : 1];
189
- nextEdge.data = { tags: step.wemap.nextEdgeTags };
212
+ nextEdge.data = nextEdgeData;
190
213
  }
191
214
  }
192
215
  }
@@ -24,8 +24,8 @@ describe('OsrmUtils', () => {
24
24
 
25
25
  const json = JSON.parse(fileString);
26
26
 
27
- const start = [3.8968868999999997, 43.6001066];
28
- const end = [3.895319, 43.601430];
27
+ const start = [3.8757218000000004, 43.6007871];
28
+ const end = [3.873866, 43.598877];
29
29
 
30
30
  const itinerary = OsrmUtils.createItineraryFromJson(json, start, end);
31
31