Skip to content

Commit

Permalink
Match Output Bounding Box to Geojson Feature (spatialdev#18)
Browse files Browse the repository at this point in the history
* boundary file

* use boundary.json
  • Loading branch information
Bentleysb authored Aug 7, 2019
1 parent 842bee8 commit 7b98ec4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Note:

1. Users can adjust all parameters, and minimum value of the depth number is 1.<br />
2. When users specify the maximum count to the second k-d tree, the tool performs the second tree automatically. <br />
3. If you add a geojson file name 'boundary.json' to any of the sub-directories of the input folder, the bounding box
of the first feature in that file will be used as the bounding box of the folders results.

**Output Format:**

Expand Down
13 changes: 11 additions & 2 deletions src/mqm/geo_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,17 @@ def bounding_box_process(self):
start_point = len(data['features'])


# get a folder bounding box giving one or more fix bounding box
final_bounding_box = self.final_bounding_box_generation(folder_bounding_box_set, 4)
# get a folder bounding box giving one or more fix bounding box, or a boundary file
if "boundary.json" in os.listdir(self.folder_path):
try:
with open(os.path.join(self.folder_path, "boundary.json")) as bounds_file:
feature = json.loads(bounds_file.read())["features"][0]["geometry"]
final_bounding_box = self.min_max_calculation(feature["type"], feature["coordinates"])
except Exception:
print("Error reading the boundary file.")
raise
else:
final_bounding_box = self.final_bounding_box_generation(folder_bounding_box_set, 4)


return self.output_data, final_bounding_box, name_num_list
Expand Down

0 comments on commit 7b98ec4

Please sign in to comment.