@mapbox/graph-normalizer
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -11,2 +11,3 @@ 'use strict'; | ||
options.mergeBridges = (options.mergeBridges === undefined) ? false : options.mergeBridges; | ||
options.mergeMaxspeed = (options.mergeMaxspeed === undefined) ? false : options.mergeMaxspeed; | ||
@@ -73,2 +74,9 @@ // build node and way hashes | ||
) | ||
) || | ||
( | ||
(!options.mergeMaxspeed) && | ||
( | ||
owners[0].properties.maxspeed !== | ||
owners[1].properties.maxspeed | ||
) | ||
) | ||
@@ -150,3 +158,3 @@ ) nodes.delete(node); | ||
// persist oneway, highway, bridge, and tunnel tags if they are present | ||
// persist oneway, highway, bridge, tunnel and maxspeed tags if they are present | ||
if (opening.properties.hasOwnProperty('oneway')) combined.properties.oneway = opening.properties.oneway; | ||
@@ -173,2 +181,15 @@ | ||
if (options.mergeMaxspeed) { | ||
// if maxspeed tags are the same, keep them, else set as min | ||
if (opening.properties.hasOwnProperty('maxspeed') && closing.properties.hasOwnProperty('maxspeed')) { | ||
if (opening.properties.maxspeed === closing.properties.maxspeed) { | ||
combined.properties.maxspeed = opening.properties.maxspeed; | ||
} else { | ||
combined.properties.maxspeed = Math.min(opening.properties.maxspeed, closing.properties.maxspeed); | ||
} | ||
} else if (opening.properties.hasOwnProperty('maxspeed')) { | ||
combined.properties.maxspeed = opening.properties.maxspeed; | ||
} else combined.properties.maxspeed = closing.properties.maxspeed; | ||
} else if (opening.properties.hasOwnProperty('maxspeed')) combined.properties.maxspeed = opening.properties.maxspeed; | ||
// insert combined way into hash | ||
@@ -175,0 +196,0 @@ ways[combined.properties.id] = combined; |
@@ -44,3 +44,3 @@ 'use strict'; | ||
// persist oneway, highway, bridge, tunnel, name, and ref tags if they are present | ||
// persist oneway, highway, bridge, tunnel, maxspeed, name, and ref tags if they are present | ||
if (way.properties.hasOwnProperty('oneway')) waySlice.properties.oneway = way.properties.oneway; | ||
@@ -50,2 +50,3 @@ if (way.properties.hasOwnProperty('highway')) waySlice.properties.highway = way.properties.highway; | ||
if (way.properties.hasOwnProperty('tunnel')) waySlice.properties.tunnel = way.properties.tunnel; | ||
if (way.properties.hasOwnProperty('maxspeed')) waySlice.properties.maxspeed = way.properties.maxspeed; | ||
if (way.properties.hasOwnProperty('name')) waySlice.properties.name = way.properties.name; | ||
@@ -77,2 +78,3 @@ if (way.properties.hasOwnProperty('ref')) waySlice.properties.ref = way.properties.ref; | ||
if (way.properties.hasOwnProperty('tunnel')) waySlice.properties.tunnel = way.properties.tunnel; | ||
if (way.properties.hasOwnProperty('maxspeed')) waySlice.properties.maxspeed = way.properties.maxspeed; | ||
if (way.properties.hasOwnProperty('name')) waySlice.properties.name = way.properties.name; | ||
@@ -79,0 +81,0 @@ if (way.properties.hasOwnProperty('ref')) waySlice.properties.ref = way.properties.ref; |
{ | ||
"name": "@mapbox/graph-normalizer", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "Takes nodes and ways and turn them into a normalized graph of intersections and ways.", | ||
@@ -8,3 +8,3 @@ "bin": "./bin/normalize-ways", | ||
"engines": { | ||
"node": "4.4.3" | ||
"node": ">=10" | ||
}, | ||
@@ -11,0 +11,0 @@ "scripts": { |
@@ -24,2 +24,3 @@ # Graph-normalizer | ||
--mergeBridges <optional - merge ways with different bridge tags - default false> | ||
--mergeMaxspeed <optional - merge ways with different maxspeed tags - default false> | ||
``` | ||
@@ -33,7 +34,8 @@ | ||
- Normalized way ids keep track of the history of transformations that led to it. | ||
- `highway`, `oneway`, `bridge` and `tunnel` tags are conserved from the original graph by default. | ||
- `highway`, `bridge` and `tunnel` tags can be merged using optional arguments. When merging different tags: | ||
- `highway`, `oneway`, `bridge`, `tunnel` and `maxspeed` tags are conserved from the original graph by default. | ||
- `highway`, `bridge`, `tunnel` and `maxspeed` tags can be merged using optional arguments. When merging different tags: | ||
- `highway` tag is set as `unclassified` | ||
- `tunnel` tag is set to `yes` i.e. we keep the info that there is a tunnel in the merged way | ||
- `bridge` tag is set to `yes` i.e. we keep the info that there is a bridge in the merged way | ||
- `maxspeed` tag is set to `min([maxspeeds])` i.e. we get the minimum of speed limit in the merged way | ||
@@ -40,0 +42,0 @@ Edges that are shared by multiple tiles are conserved in all of them. |
@@ -1,1 +0,1 @@ | ||
{ "type": "Feature", "properties": { "id": "testboundary|0!0;03201011120", "refs": ["2982064778","2982064775","2982064777","261408719","261386882"], "oneway": 0, "highway": "residential" }, "geometry": { "type": "LineString", "coordinates": [[-73.652215, 40.624132], [-73.652344, 40.62412], [-73.652446, 40.624124], [-73.652537, 40.624144], [-73.654897, 40.624816]]}} | ||
{ "type": "Feature", "properties": { "id": "testboundary|0!0;03201011120", "refs": ["2982064778","2982064775","2982064777","261408719","261386882"], "oneway": 0, "highway": "residential", "maxspeed":"20" }, "geometry": { "type": "LineString", "coordinates": [[-73.652215, 40.624132], [-73.652344, 40.62412], [-73.652446, 40.624124], [-73.652537, 40.624144], [-73.654897, 40.624816]]}} |
@@ -1,1 +0,1 @@ | ||
{ "type": "Feature", "properties": { "id": "testboundary|0!0;03201011121", "refs": ["2982064778","2982064775"], "oneway": 0, "highway": "residential" }, "geometry": { "type": "LineString", "coordinates": [[-73.652215, 40.624132], [-73.652344, 40.62412]]}} | ||
{ "type": "Feature", "properties": { "id": "testboundary|0!0;03201011121", "refs": ["2982064778","2982064775"], "oneway": 0, "highway": "residential", "maxspeed":"20" }, "geometry": { "type": "LineString", "coordinates": [[-73.652215, 40.624132], [-73.652344, 40.62412]]}} |
@@ -1,3 +0,3 @@ | ||
{"type": "Feature", "properties": {"oneway": 1, "refs": ["1", "2", "3"], "id": "123|0!0;12022001101", "highway": "motorway", "openLR": "CwG/kSLC9wEVNvJS+WIBBA=="}, "geometry": {"type":"LineString", "coordinates": [[2.4585342407226562,48.883456897746534],[2.4451446533203125,48.877812415009195],[2.4235153198242188,48.866521538507754]]}} | ||
{"type": "Feature", "properties": {"oneway": 1, "refs": ["1", "2", "3"], "id": "123|0!0;12022001101", "highway": "motorway", "maxspeed":"60", "openLR": "CwG/kSLC9wEVNvJS+WIBBA=="}, "geometry": {"type":"LineString", "coordinates": [[2.4585342407226562,48.883456897746534],[2.4451446533203125,48.877812415009195],[2.4235153198242188,48.866521538507754]]}} | ||
{"type": "Feature", "properties": {"oneway": 1, "refs": ["11", "22", "33"], "id": "223|0!0;12022001101", "highway": "motorway", "openLR": "CwG5MSK/4QEENg2uBp4BFQ=="}, "geometry": {"type":"LineString", "coordinates": [[2.4235153198242188,48.866521538507754],[2.4451446533203125,48.877812415009195],[2.4585342407226562,48.883456897746534]]}} | ||
{"type": "Feature", "properties": {"oneway": 0, "refs": ["44", "55"], "id": "224|0!0;12022001101", "highway": "residential", "openLR": "CwG/kSLC9yu/Av/TAJcrDw==", "reverseOpenLR": "CwG/fCLDPSuvAgAt/2krHw=="}, "geometry": {"type":"LineString", "coordinates": [[2.4585342407226562,48.883456897746534],[2.4580836296081543,48.884966688891]]}} | ||
{"type": "Feature", "properties": {"oneway": 0, "refs": ["44", "55"], "id": "224|0!0;12022001101", "highway": "residential", "maxspeed":"20", "openLR": "CwG/kSLC9yu/Av/TAJcrDw==", "reverseOpenLR": "CwG/fCLDPSuvAgAt/2krHw=="}, "geometry": {"type":"LineString", "coordinates": [[2.4585342407226562,48.883456897746534],[2.4580836296081543,48.884966688891]]}} |
@@ -1,1 +0,1 @@ | ||
{"type": "Feature", "properties": {"oneway": 0, "refs": ["5", "6"], "id": "567|0!0;12022001110", "highway": "secondary_link", "openLR": "CwHTeSK/1x59Cv51Ac8eDQ==", "reverseOpenLR": "CwHSwSLArx5tCgGL/jEeHQ=="}, "geometry": {"type":"LineString", "coordinates": [[2.567882537841797,48.866295694987045],[2.563934326171875,48.87092528343819]]}} | ||
{"type": "Feature", "properties": {"oneway": 0, "refs": ["5", "6"], "id": "567|0!0;12022001110", "highway": "secondary_link", "maxspeed":"50", "openLR": "CwHTeSK/1x59Cv51Ac8eDQ==", "reverseOpenLR": "CwHSwSLArx5tCgGL/jEeHQ=="}, "geometry": {"type":"LineString", "coordinates": [[2.567882537841797,48.866295694987045],[2.563934326171875,48.87092528343819]]}} |
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[139.881516,35.718264],[139.881492,35.718321],[139.881163,35.719134],[139.880924,35.719718],[139.880436,35.720829],[139.880243,35.721245],[139.880106,35.721514],[139.880106,35.721598],[139.880106,35.721718]]},"properties":{"id":"10765432100123456789|0!0;13300211231112","refs":["60721926","60721925","60721906","60721899","60721222","60721191","60721190","60721187","60721186"],"oneway":0,"highway":"residential"}} | ||
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[139.881516,35.718264],[139.880175,35.717895]]},"properties":{"id":"10765432100123456790|0!0;13300211231112","refs":["60721926","60721894"],"oneway":0,"highway":"unclassified"}} | ||
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[139.881516,35.718264],[139.880175,35.717895]]},"properties":{"id":"10765432100123456790|0!0;13300211231112","refs":["60721926","60721894"],"oneway":0,"highway":"unclassified","maxspeed":"15"}} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2404267
125
1013
71