Esempio n. 1
0
def test_add_length_ways_only(roads):
    result = list(RollUpLength(True, False).process(roads))
    assert result[0]['ways'][0]['length'] == 11
    assert result[0]['ways'][1]['length'] == 15
    assert 'length' not in result[0]
    assert result[1]['ways'][0]['length'] == 35
    assert 'length' not in result[1]
Esempio n. 2
0
def test_add_length_collections_only(roads):
    result = list(RollUpLength(False, True).process(roads))
    assert result[0]['length'] == 26
    assert 'length' not in result[0]['ways'][0]
    assert 'length' not in result[0]['ways'][1]
    assert result[1]['length'] == 35
    assert 'length' not in result[1]['ways'][0]
Esempio n. 3
0
def test_add_length(roads):
    result = list(RollUpLength().process(roads))
    assert result[0]['ways'][0]['length'] == 11
    assert result[0]['ways'][1]['length'] == 15
    assert result[0]['length'] == 26
    assert result[1]['ways'][0]['length'] == 35
    assert result[1]['length'] == 35
Esempio n. 4
0
#    highlighting long straight roads with infrequent curvy-sections.
# 6. Sum the length and curvature of the sections in each way for reuse.
# 7. Filter out collections not meeting our minimum curvature thresholds.
# 3. Sort the items by their curvature value.
# 3. Save the intermediate data.


chain = [
  FilterOutWaysWithTag('surface', ['unpaved','dirt','gravel','fine_gravel','sand','grass','ground','pebblestone','mud','clay','dirt/sand','soil']),
  FilterOutWaysWithTag('service', ['driveway', 'parking_aisle', 'drive-through', 'parking', 'bus', 'emergency_access']),
  AddSegments(),
  AddSegmentLengthAndRadius(),
  AddSegmentCurvature(),
  FilterSegmentDeflections(),
  SplitCollectionsOnStraightSegments(2414),
  RollUpLength(),
  RollUpCurvature(),
  FilterCollectionsByCurvature(min=300),
  SortCollectionsBySum(key='curvature', reverse=True)
]

def print_msgpack(arg):
  sys.stdout.buffer.write(msgpack.packb(arg, use_bin_type=True))

prev_callback = print_msgpack

for processor in reversed(chain):
  prev_callback = CallbackedProcessor(processor, prev_callback).input

for collection in msgpack.Unpacker(sys.stdin.buffer, use_list=True, encoding='utf-8'):
  prev_callback(collection)