LukePrior / nbn-upgrade-map

Interactive map showing premises eligible for the NBN FTTP upgrade program.
https://nbn.lukeprior.com/
MIT License
124 stars 11 forks source link

Sort results in output geojson file to make changes stable #136

Closed lyricnz closed 1 year ago

lyricnz commented 1 year ago

At the moment the ordering of results in the output file is unpredictable because it depends on the ordering of the multiple threads querying the NBN API. It would be better if this was stable, so reprocessing files generates less diffs.

lyricnz commented 1 year ago

Sort by... address? locID? gnaf_pid? I think one of the latter two probably makes sense - new addresses will tend to be added at the end.

LukePrior commented 1 year ago

Hmmmm, I think gnaf_pid would probably work best but locID could also work.

lyricnz commented 1 year ago
    for state in data.STATES:
        for file in glob.glob(f"results/{state}/*.geojson"):
            print(file)
            result = geojson.read_json_file(file)
            result["features"] = sorted(result["features"], key=lambda x: x["properties"]["gnaf_pid"])
            geojson.write_json_file(file, result, indent=1)
lyricnz commented 1 year ago

Massive PR https://github.com/LukePrior/nbn-upgrade-map/pull/146