Skip to content

Commit

Permalink
Added simple dataframe test
Browse files Browse the repository at this point in the history
  • Loading branch information
migurski committed Sep 17, 2018
1 parent 87a7062 commit 5cafb5b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
version: 2
jobs:
build-2.7:
test-2.7:
docker:
- image: circleci/python:2.7

Expand All @@ -30,7 +30,7 @@ jobs:
. venv/bin/activate
python setup.py test
build-3.5:
test-3.5:
docker:
- image: circleci/python:3.5

Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
. venv/bin/activate
python setup.py test
build-3.6:
test-3.6:
docker:
- image: circleci/python:3.6

Expand Down Expand Up @@ -119,15 +119,15 @@ workflows:
version: 2
build:
jobs:
- build-2.7
- build-3.5
- build-3.6
- test-2.7
- test-3.5
- test-3.6
- release:
filters:
branches:
only:
- migurski/add-local-representation
requires:
- build-2.7
- build-3.5
- build-3.6
- test-2.7
- test-3.5
- test-3.6
8 changes: 4 additions & 4 deletions sharedstreets/dataframe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def apply(self, dataframe):
things7 = delete_things123.apply(add_thing4.apply(things1))
assert len(things7) == 1

print('getting')
#print('getting')
#frames = get_tile(12, 656, 1582, data_url_template='http://0.0.0.0:8000/planet-180312-{z}-{x}-{y}.{layer}.6.pbf')
#frames = get_bbox(-122.26482, 37.79760, -122.24636, 37.81286, data_url_template='http://0.0.0.0:8000/planet-180312-{z}-{x}-{y}.{layer}.6.pbf')
frames = get_bbox(-122.26713, 37.84947, -122.25177, 37.86960) #, data_url_template='http://0.0.0.0:8000/planet-180312-{z}-{x}-{y}.{layer}.6.pbf')
print(frames.intersections)
print(frames.geometries)
#frames = get_bbox(-122.26713, 37.84947, -122.25177, 37.86960, data_url_template='http://0.0.0.0:8000/planet-180312-{z}-{x}-{y}.{layer}.6.pbf')
#print(frames.intersections)
#print(frames.geometries)
34 changes: 34 additions & 0 deletions sharedstreets/tests/test_dataframe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import unittest, mock, collections
from .. import dataframe

Geometry = collections.namedtuple('Geometry', ['id', 'roadClass',
'fromIntersectionId', 'toIntersectionId', 'forwardReferenceId',
'backReferenceId', 'lonlats'])

Intersection = collections.namedtuple('Intersection', ['id', 'nodeId',
'inboundReferenceIds', 'outboundReferenceIds', 'lon', 'lat'])

class TestDataframe (unittest.TestCase):

def test_get_tile(self):

with mock.patch('sharedstreets.tile.get_tile') as get_tile:
mock_tile = get_tile.return_value
mock_tile.intersections = {
'NNNN': Intersection('NNNN', 1, ['IN'], ['NI'], -0.000113, 0.000038),
'dddd': Intersection('dddd', 4, ['NI'], ['IN'], 0.000231, -0.000032),
}
mock_tile.geometries = {
'NlId': Geometry('NlId', 6, 'NNNN', 'dddd', 'NI', 'IN',
[-0.000113, 0.000038, 0.000027, 0.000032, 0.000038, -0.000027, 0.000231, -0.000032]),
}

# N -0.000113 0.000038
# l 0.000027 0.000032
# I 0.000038 -0.000027
# d 0.000231 -0.000032

frames = dataframe.get_tile(12, 2048, 2048)

print(frames.intersections)
print(frames.geometries)
2 changes: 1 addition & 1 deletion sharedstreets/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
OSM = ModestMaps.OpenStreetMap.Provider()

class Tile:
''' Container for lists of SharedStreets geometries, intersections, references, and metadata.
''' Container for dicts of SharedStreets geometries, intersections, references, and metadata.
'''
def __init__(self, geometries, intersections, references, metadata):
self.geometries = geometries
Expand Down

0 comments on commit 5cafb5b

Please sign in to comment.