Skip to content

Commit

Permalink
fix: Use geojson instead of json to read in the boundary file
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Nov 8, 2023
1 parent b688408 commit 7de0f6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions osm_fieldwork/basemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import argparse
import concurrent.futures
import json
import geojson
import logging
import queue
import re
Expand Down Expand Up @@ -292,10 +292,10 @@ def makeBbox(

log.debug(f"Reading geojson file: {boundary}")
with open(boundary, "r") as f:
poly = json.load(f)
poly = geojson.load(f)
if "features" in poly:
geometry = shape(poly["features"][0]["geometry"])
if "geometry" in poly:
elif "geometry" in poly:
geometry = shape(poly["geometry"])
else:
geometry = shape(poly)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
log = logging.getLogger(__name__)

rootdir = os.path.dirname(os.path.abspath(__file__))
infile = f"{rootdir}/testdata/Rollinsville.geojson"
boundary = f"{rootdir}/testdata/Rollinsville.geojson"
outfile = f"{rootdir}/testdata/rollinsville.mbtiles"
base = "./tiles"
# boundary = open(infile, "r")
Expand All @@ -45,7 +45,7 @@
def test_create():
"""See if the file got loaded."""
hits = 0
basemap = BaseMapper(infile, base, "topo", False)
basemap = BaseMapper(boundary, base, "topo", False)
tiles = list()
for level in [8, 9, 10, 11, 12]:
basemap.getTiles(level)
Expand All @@ -65,6 +65,5 @@ def test_create():

assert hits == 2


if __name__ == "__main__":
test_create()

0 comments on commit 7de0f6a

Please sign in to comment.