Skip to content

Commit

Permalink
Merge pull request #39 from TileDB-Inc/mg/bbox-fix
Browse files Browse the repository at this point in the history
bbox as input parameter added
  • Loading branch information
MargrietGroenendijk authored Jul 11, 2022
2 parents 3d2a0ae + 3584a76 commit 025c0f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pybabylonjs/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def check_point_cloud_args(mode, point_cloud_args_in):
raise ValueError(
"The crs (coordinate reference system) of the data is not specified"
)
if not "bbox" in point_cloud_args_in:
raise ValueError("The bbox is not specified")
elif mode == "gltf":
if not "gltf_data" in point_cloud_args_in:
raise ValueError("gltf_data is not specified")
Expand Down Expand Up @@ -96,7 +98,7 @@ def check_point_cloud_data_local(mode, uri, point_cloud_args):
if os.path.isdir(uri) == False:
raise ValueError("uri: " + uri + " does not exist.")
if not "bbox" in point_cloud_args:
raise ValueError("The bbox for slicing data from " + uri + " is not specified")
raise ValueError("The bbox for slicing data from the array is not specified")

data = create_point_cloud(mode, uri, point_cloud_args["bbox"])

Expand Down
14 changes: 9 additions & 5 deletions pybabylonjs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ def create_mapbox_image(data: dict, point_cloud_args):
mbtoken = point_cloud_args["mbtoken"]
style_id = point_cloud_args["mbstyle"]
data_crs = point_cloud_args["crs"]
bbox_in = point_cloud_args["bbox"]

dst_crs = {"init": "EPSG:4326"} # lat/lon

bbox = BoundingBox(
data["X"].min(), data["Y"].min(), data["X"].max(), data["Y"].max()
)
if bbox_in:
bbox = BoundingBox(
bbox_in["X"][0], bbox_in["Y"][0], bbox_in["X"][1], bbox_in["Y"][1]
)
else:
bbox = BoundingBox(
data["X"].min(), data["Y"].min(), data["X"].max(), data["Y"].max()
)

dst_bbox = transform_bounds(data_crs, dst_crs, *bbox)

# convert point cloud coordinates and replace in `data`

w = bbox[2] - bbox[0]
h = bbox[3] - bbox[1]

Expand Down
2 changes: 2 additions & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export function setPointCloudSwitches(mode: string){
isTopo = true;
}else if(mode == "gltf"){
isGltf = true;
//}else if(mode == "pcl"){
// isPCL = true;
}
return {isTime, isClass, isTopo, isGltf}
}
Expand Down

0 comments on commit 025c0f0

Please sign in to comment.