Skip to content

Commit

Permalink
add missing always_xy=True to a couple of transformers (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
KasiaKoz authored Apr 27, 2021
1 parent 4859a15 commit 1515b3e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion genet/inputs_handler/matsim_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def read_schedule(schedule_path, epsg):
:return: list of Service objects
"""
services = []
transformer = Transformer.from_proj(Proj(epsg), Proj('epsg:4326'))
transformer = Transformer.from_proj(Proj(epsg), Proj('epsg:4326'), always_xy=True)

def write_transitLinesTransitRoute(transitLine, transitRoutes, transportMode):
mode = transportMode['transportMode']
Expand Down
2 changes: 1 addition & 1 deletion genet/outputs_handler/matsim_xml_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def write_matsim_schedule(output_dir, schedule, epsg=''):
fname = os.path.join(output_dir, "schedule.xml")
if not epsg:
epsg = schedule.epsg
transformer = Transformer.from_proj(Proj('epsg:4326'), Proj(epsg))
transformer = Transformer.from_proj(Proj('epsg:4326'), Proj(epsg), always_xy=True)
logging.info('Writing {}'.format(fname))

with open(fname, "wb") as f, etree.xmlfile(f, encoding='utf-8') as xf:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_core_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,20 @@ def test_read_matsim_schedule_returns_expected_schedule():
assert_semantically_equal(schedule.route('VJbd8660f05fe6f744e58a66ae12bd66acbca88b98').trips,
{'trip_id': ['VJ00938baa194cee94700312812d208fe79f3297ee_04:40:00'],
'trip_departure_time': ['04:40:00'], 'vehicle_id': ['veh_0_bus']})
assert_semantically_equal(
dict(schedule.graph().nodes(data=True)),
{'26997928P': {'services': {'10314'}, 'routes': {'VJbd8660f05fe6f744e58a66ae12bd66acbca88b98'},
'id': '26997928P', 'x': 528464.1342843144, 'y': 182179.7435136598, 'epsg': 'epsg:27700',
'name': 'Brunswick Place (Stop P)', 'lat': 51.52393050617373, 'lon': -0.14967658860132668,
's2_id': 5221390302759871369, 'additional_attributes': {'name', 'isBlocking'},
'isBlocking': 'false'},
'26997928P.link:1': {'services': {'10314'}, 'routes': {'VJbd8660f05fe6f744e58a66ae12bd66acbca88b98'},
'id': '26997928P.link:1', 'x': 528464.1342843144, 'y': 182179.7435136598,
'epsg': 'epsg:27700', 'name': 'Brunswick Place (Stop P)', 'lat': 51.52393050617373,
'lon': -0.14967658860132668, 's2_id': 5221390302759871369,
'additional_attributes': {'name', 'linkRefId', 'isBlocking'}, 'linkRefId': '1',
'isBlocking': 'false'}}
)


def test_reading_vehicles_with_a_schedule():
Expand Down

0 comments on commit 1515b3e

Please sign in to comment.