cyipt / actdev

ActDev - Active travel provision and potential in planned and proposed development sites
https://actdev.cyipt.bike
7 stars 3 forks source link

Transform A/B Street JSON scenario files into the new format, as a #176

Closed dabreegster closed 3 years ago

dabreegster commented 3 years ago

workaround for https://github.com/a-b-street/abstr/issues/29.

I just ran a little Python script to modify all the files in-place:

#!/usr/bin/python3
# ./fix_json.py data-small/*/scenario_*.json

import json
import sys

for path in sys.argv[1:]:
    with open(path) as f:
        data = json.load(f)
        for person in data['people']:
            origin = person['origin']
            del person['origin']
            assert(len(person['trips']) == 1)
            person['trips'][0]['origin'] = origin

        with open(path, 'w') as f:
            f.write(json.dumps(data, indent=2))
            f.close()
Robinlovelace commented 3 years ago

Great to see these changes, thanks! I think it will be better if we fix it further upstream in the build script with the updated version of abstr. Suggestion:

Sound like a plan?

dabreegster commented 3 years ago

I agree fixing upstream is the ideal fix. I have no resources to put into that, and in the meantime all of the actdev scenarios are broken, so this is the quick fix. No rush to merge the PR; I already fixed up the data on my side in https://github.com/a-b-street/abstreet/commit/ed59a8a386dcc5f4ec07c78283a42add208744b2 by pointing at this copy.

Robinlovelace commented 3 years ago

Thanks @dabreegster will aim to look at it later today. Loving the use of branches to fix things on the deployed app.