Skip to content

Commit

Permalink
add osm2cityflow converter
Browse files Browse the repository at this point in the history
  • Loading branch information
only-changer committed Oct 30, 2019
1 parent 07fdee1 commit a6699c7
Show file tree
Hide file tree
Showing 4 changed files with 548 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tests/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ stages:
steps:
- script: sudo -E apt-add-repository -y ppa:deadsnakes/ppa
displayName: Update source
- script: sudo apt update && sudo apt install -y python3.7-dev
- script: sudo apt update && sudo apt install -y python3.7-dev && python3.7 -m pip install pyproj folium
displayName: Install dependency
- script: git clone https://github.com/cityflow-project/data.git
displayName: Download data
- template: template/install_gtest.yml
- template: template/build.yml
parameters:
Expand All @@ -95,6 +97,10 @@ stages:
pool:
vmImage: 'macOS-latest'
steps:
- script: python3 -m pip install pyproj folium
displayName: Install dependency
- script: git clone https://github.com/cityflow-project/data.git
displayName: Download data
- template: template/install_gtest.yml
- template: template/build.yml
parameters:
Expand Down
23 changes: 23 additions & 0 deletions tests/python/test_osm_converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest
import os
import json
from tools.converter.osm2cityflow import extract, draw


class TestOsmConverter(unittest.TestCase):
dataPath = os.getcwd() + '/data/tools/Converter/examples/'
osmFile = dataPath + 'statecollege.osm'
CityFlowFile = dataPath + 'statecollege_roadnet.json'

def test_converter(self):
nodes = extract(osmFile=self.osmFile)
draw(nodes, self.CityFlowFile, True)
with open(self.CityFlowFile, 'r') as f:
roadnet = json.load(f)
intersectionsNum = len(roadnet["intersections"])
roadsNum = len(roadnet["roads"])
self.assertTrue(intersectionsNum <= roadsNum)


if __name__ == '__main__':
unittest.main(verbosity=2)
Loading

0 comments on commit a6699c7

Please sign in to comment.