Skip to content

Commit

Permalink
Add Geojson exports (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbiguenet authored Nov 15, 2024
1 parent 0325c56 commit 1ae8f56
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "reality_apis"
version = "1.2.0"
version = "1.2.2-dev0"
authors = [
{ name="Bentley Systems" },
]
Expand Down
86 changes: 86 additions & 0 deletions python/reality_apis/RDAS/job_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ def to_json(self) -> dict:
json_dict["outputs"].append("exportedObjects3DDGN")
if self.outputs.exported_objects3D_cesium:
json_dict["outputs"].append("exportedObjects3DCesium")
if self.outputs.exported_objects3D_geojson:
json_dict["outputs"].append("exportedObjects3DGeoJSON")
if self.outputs.exported_locations3D_SHP:
json_dict["outputs"].append("exportedLocations3DSHP")
if self.outputs.exported_locations3D_geojson:
json_dict["outputs"].append("exportedLocations3DGeoJSON")
json_dict["options"] = dict()
if self.options.use_tie_points:
json_dict["options"]["useTiePoints"] = "true"
Expand Down Expand Up @@ -126,10 +130,18 @@ def from_json(cls, settings_json: dict) -> ReturnValue[O2DJobSettings]:
new_job_settings.outputs.exported_objects3D_cesium = output_dict[
"id"
]
elif output_dict["type"] == "exportedObjects3DGeoJSON":
new_job_settings.outputs.exported_objects3D_geojson = output_dict[
"id"
]
elif output_dict["type"] == "exportedLocations3DSHP":
new_job_settings.outputs.exported_locations3D_SHP = output_dict[
"id"
]
elif output_dict["type"] == "exportedLocations3DGeoJSON":
new_job_settings.outputs.exported_locations3D_geojson = output_dict[
"id"
]
else:
raise TypeError(
"found non expected output name" + output_dict["type"]
Expand Down Expand Up @@ -176,15 +188,19 @@ class Outputs:
objects3D: Detected 3D objects.
exported_objects3D_DGN: DGN file export with 3D objects.
exported_objects3D_cesium: Cesium 3D Tiles file export with 3D objects.
exported_objects3D_geojson: GeoJSON file export with 3D objects.
exported_locations3D_SHP: ESRI SHP file export with locations of the 3D objects.
exported_locations3D_geojson: GeoJSON file export with locations of the 3D objects.
"""

def __init__(self) -> None:
self.objects2D: str = ""
self.objects3D: str = ""
self.exported_objects3D_DGN: str = ""
self.exported_objects3D_cesium: str = ""
self.exported_objects3D_geojson: str = ""
self.exported_locations3D_SHP: str = ""
self.exported_locations3D_geojson: str = ""

class Options:
"""
Expand Down Expand Up @@ -265,12 +281,16 @@ def to_json(self) -> dict:
json_dict["outputs"].append("exportedLines3DDGN")
if self.outputs.exported_lines3D_cesium:
json_dict["outputs"].append("exportedLines3DCesium")
if self.outputs.exported_lines3D_geojson:
json_dict["outputs"].append("exportedLines3DGeoJSON")
if self.outputs.polygons3D:
json_dict["outputs"].append("polygons3D")
if self.outputs.exported_polygons3D_DGN:
json_dict["outputs"].append("exportedPolygons3DDGN")
if self.outputs.exported_polygons3D_cesium:
json_dict["outputs"].append("exportedPolygons3DCesium")
if self.outputs.exported_polygons3D_geojson:
json_dict["outputs"].append("exportedPolygons3DGeoJSON")
json_dict["options"] = dict()
if self.options.compute_line_width:
json_dict["options"]["computeLineWidth"] = "true"
Expand Down Expand Up @@ -331,6 +351,10 @@ def from_json(cls, settings_json: dict) -> ReturnValue[S2DJobSettings]:
new_job_settings.outputs.exported_lines3D_cesium = output_dict[
"id"
]
elif output_dict["type"] == "exportedLines3DGeoJSON":
new_job_settings.outputs.exported_lines3D_geojson = output_dict[
"id"
]
elif output_dict["type"] == "polygons3D":
new_job_settings.outputs.polygons3D = output_dict["id"]
elif output_dict["type"] == "exportedPolygons3DDGN":
Expand All @@ -341,6 +365,10 @@ def from_json(cls, settings_json: dict) -> ReturnValue[S2DJobSettings]:
new_job_settings.outputs.exported_polygons3D_cesium = output_dict[
"id"
]
elif output_dict["type"] == "exportedPolygons3DGeoJSON":
new_job_settings.outputs.exported_polygons3D_geojson = output_dict[
"id"
]
else:
raise TypeError(
"found non expected output name:" + output_dict["type"]
Expand Down Expand Up @@ -395,9 +423,11 @@ class Outputs:
lines3D: Detected 3D lines.
exported_lines3D_DGN: DGN file export with 3D lines.
exported_lines3D_cesium: Cesium 3D Tiles file export with 3D lines.
exported_lines3D_geojson: GeoJSON file export with 3D lines.
polygons3D: Detected polygons.
exported_polygons3D_DGN: DGN file export with polygons.
exported_polygons3D_cesium: Cesium 3D Tiles file export with 3D polygons.
exported_polygons3D_geojson GeoJSON file export with 3D polygons.
"""

Expand All @@ -407,9 +437,11 @@ def __init__(self) -> None:
self.lines3D: str = ""
self.exported_lines3D_DGN: str = ""
self.exported_lines3D_cesium: str = ""
self.exported_lines3D_geojson: str = ""
self.polygons3D: str = ""
self.exported_polygons3D_DGN: str = ""
self.exported_polygons3D_cesium: str = ""
self.exported_polygons3D_geojson: str = ""

class Options:
"""
Expand Down Expand Up @@ -474,12 +506,16 @@ def to_json(self) -> dict:
json_dict["outputs"].append("polygons2D")
if self.outputs.exported_polygons2D_SHP:
json_dict["outputs"].append("exportedPolygons2DSHP")
if self.outputs.exported_polygons2D_geojson:
json_dict["outputs"].append("exportedPolygons2DGeoJSON")
if self.outputs.lines2D:
json_dict["outputs"].append("lines2D")
if self.outputs.exported_lines2D_DGN:
json_dict["outputs"].append("exportedLines2DDGN")
if self.outputs.exported_lines2D_SHP:
json_dict["outputs"].append("exportedLines2DSHP")
if self.outputs.exported_lines2D_geojson:
json_dict["outputs"].append("exportedLines2DGeoJSON")
return json_dict

@classmethod
Expand Down Expand Up @@ -520,12 +556,18 @@ def from_json(cls, settings_json: dict) -> ReturnValue[SOrthoJobSettings]:
new_job_settings.outputs.exported_polygons2D_SHP = output_dict[
"id"
]
elif output_dict["type"] == "exportedPolygons2DGeoJSON":
new_job_settings.outputs.exported_polygons2D_geojson = output_dict[
"id"
]
elif output_dict["type"] == "lines2D":
new_job_settings.outputs.lines2D = output_dict["id"]
elif output_dict["type"] == "exportedLines2DDGN":
new_job_settings.outputs.exported_lines2D_DGN = output_dict["id"]
elif output_dict["type"] == "exportedLines2DSHP":
new_job_settings.outputs.exported_lines2D_SHP = output_dict["id"]
elif output_dict["type"] == "exportedLines2DGeoJSON":
new_job_settings.outputs.exported_lines2D_geojson = output_dict["id"]
else:
raise TypeError(
"found non expected output type:" + output_dict["type"]
Expand Down Expand Up @@ -556,19 +598,23 @@ class Outputs:
segmented_photos: ContextScene pointing to segmented photos.
polygons2D: Detected 2D polygons.
exported_polygons2D_SHP: 2D polygons exported to ESRI shapefile.
exported_polygons2D_geojson: 2D polygons exported to GeoJSON.
lines2D: Detected 2D lines.
exported_lines2D_SHP: 2D lines exported to ESRI shapefile.
exported_lines2D_DGN: 2D lines exported to DGN file.
exported_lines2D_geojson: 2D lines exported to GeoJSON file.
"""

def __init__(self) -> None:
self.segmentation2D: str = ""
self.segmented_photos: str = ""
self.polygons2D: str = ""
self.exported_polygons2D_SHP: str = ""
self.exported_polygons2D_geojson: str = ""
self.lines2D: str = ""
self.exported_lines2D_SHP: str = ""
self.exported_lines2D_DGN: str = ""
self.exported_lines2D_geojson: str = ""


class S3DJobSettings:
Expand Down Expand Up @@ -641,20 +687,28 @@ def to_json(self) -> dict:
json_dict["outputs"].append("exportedObjects3DDGN")
if self.outputs.exported_objects3D_cesium:
json_dict["outputs"].append("exportedObjects3DCesium")
if self.outputs.exported_objects3D_geojson:
json_dict["outputs"].append("exportedObjects3DGeoJSON")
if self.outputs.exported_locations3D_SHP:
json_dict["outputs"].append("exportedLocations3DSHP")
if self.outputs.exported_locations3D_geojson:
json_dict["outputs"].append("exportedLocations3DGeoJSON")
if self.outputs.lines3D:
json_dict["outputs"].append("lines3D")
if self.outputs.exported_lines3D_DGN:
json_dict["outputs"].append("exportedLines3DDGN")
if self.outputs.exported_lines3D_cesium:
json_dict["outputs"].append("exportedLines3DCesium")
if self.outputs.exported_lines3D_geojson:
json_dict["outputs"].append("exportedLines3DGeoJSON")
if self.outputs.polygons3D:
json_dict["outputs"].append("polygons3D")
if self.outputs.exported_polygons3D_DGN:
json_dict["outputs"].append("exportedPolygons3DDGN")
if self.outputs.exported_polygons3D_cesium:
json_dict["outputs"].append("exportedPolygons3DCesium")
if self.outputs.exported_polygons3D_geojson:
json_dict["outputs"].append("exportedPolygons3DGeoJSON")
json_dict["options"] = dict()
if self.options.compute_line_width:
json_dict["options"]["computeLineWidth"] = "true"
Expand Down Expand Up @@ -734,10 +788,18 @@ def from_json(cls, settings_json: dict) -> ReturnValue[S3DJobSettings]:
new_job_settings.outputs.exported_objects3D_cesium = output_dict[
"id"
]
elif output_dict["type"] == "exportedObjects3DGeoJSON":
new_job_settings.outputs.exported_objects3D_geojson = output_dict[
"id"
]
elif output_dict["type"] == "exportedLocations3DSHP":
new_job_settings.outputs.exported_locations3D_SHP = output_dict[
"id"
]
elif output_dict["type"] == "exportedLocations3DGeoJSON":
new_job_settings.outputs.exported_locations3D_geojson = output_dict[
"id"
]
elif output_dict["type"] == "lines3D":
new_job_settings.outputs.lines3D = output_dict["id"]
elif output_dict["type"] == "exportedLines3DDGN":
Expand All @@ -748,6 +810,10 @@ def from_json(cls, settings_json: dict) -> ReturnValue[S3DJobSettings]:
new_job_settings.outputs.exported_lines3D_cesium = output_dict[
"id"
]
elif output_dict["type"] == "exportedLines3DGeoJSON":
new_job_settings.outputs.exported_lines3D_geojson = output_dict[
"id"
]
elif output_dict["type"] == "polygons3D":
new_job_settings.outputs.polygons3D = output_dict["id"]
elif output_dict["type"] == "exportedPolygons3DDGN":
Expand All @@ -758,6 +824,10 @@ def from_json(cls, settings_json: dict) -> ReturnValue[S3DJobSettings]:
new_job_settings.outputs.exported_polygons3D_cesium = output_dict[
"id"
]
elif output_dict["type"] == "exportedPolygons3DGeoJSON":
new_job_settings.outputs.exported_polygons3D_geojson = output_dict[
"id"
]
else:
raise TypeError(
"found non expected output type:" + output_dict["type"]
Expand Down Expand Up @@ -813,13 +883,17 @@ class Outputs:
objects3D: 3D objects inferred from 3D segmentation.
exported_objects3D_DGN: DGN file export with 3D objects.
exported_objects3D_cesium: Cesium 3D Tiles file export with 3D objects
exported_objects3D_geojson: GeoJSON file export with 3D objects
exported_locations3D_SHP: ESRI SHP file export with locations of the 3D objects
exported_locations3D_geojson: GeoJSON file export with locations of the 3D objects
lines3D: Detected 3D lines.
exported_lines3D_DGN: DGN file export with 3D lines.
exported_lines3D_cesium: Cesium 3D Tiles file export with 3D lines.
exported_lines3D_geojson: GeoJSON file export with 3D lines.
polygons3D: Detected polygons.
exported_polygons3D_DGN: DGN file export with polygons.
exported_polygons3D_cesium: Cesium 3D Tiles file export with 3D polygons.
exported_polygons3D_geojson: GeoJSON file export with 3D polygons.
"""

def __init__(self) -> None:
Expand All @@ -832,13 +906,17 @@ def __init__(self) -> None:
self.objects3D: str = ""
self.exported_objects3D_DGN: str = ""
self.exported_objects3D_cesium: str = ""
self.exported_objects3D_geojson: str = ""
self.exported_locations3D_SHP: str = ""
self.exported_locations3D_geojson: str = ""
self.lines3D: str = ""
self.exported_lines3D_DGN: str = ""
self.exported_lines3D_cesium: str = ""
self.exported_lines3D_geojson: str = ""
self.polygons3D: str = ""
self.exported_polygons3D_DGN: str = ""
self.exported_polygons3D_cesium: str = ""
self.exported_polygons3D_geojson: str = ""

class Options:
"""
Expand Down Expand Up @@ -906,6 +984,8 @@ def to_json(self) -> dict:
json_dict["outputs"].append("objects3D")
if self.outputs.exported_locations3D_SHP:
json_dict["outputs"].append("exportedLocations3DSHP")
if self.outputs.exported_locations3D_geojson:
json_dict["outputs"].append("exportedLocations3DGeoJSON")
json_dict["options"] = dict()
if self.options.color_threshold_low:
json_dict["options"]["colorThresholdLow"] = str(self.options.color_threshold_low)
Expand Down Expand Up @@ -957,6 +1037,10 @@ def from_json(cls, settings_json: dict) -> ReturnValue[ChangeDetectionJobSetting
new_job_settings.outputs.exported_locations3D_SHP = output_dict[
"id"
]
elif output_dict["type"] == "exportedLocations3DGeoJSON":
new_job_settings.outputs.exported_locations3D_geojson = output_dict[
"id"
]
else:
raise TypeError(
"found non expected output type:" + output_dict["type"]
Expand Down Expand Up @@ -1013,11 +1097,13 @@ class Outputs:
Attributes:
objects3D: Regions with changes.
exported_locations3D_SHP: ESRI SHP file export with locations of regions with changes.
exported_locations3D_geojson:GeoJSON export with locations of regions with changes.
"""

def __init__(self) -> None:
self.objects3D: str = ""
self.exported_locations3D_SHP: str = ""
self.exported_locations3D_geojson: str = ""

class Options:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,10 @@ describe("Reality Analysis unit tests", () => {
},
outputs: {
exportedLocations3DSHP: "",
exportedLocations3DGeoJSON: "",
exportedObjects3DCesium: "",
exportedObjects3DDGN: "",
exportedObjects3DGeoJSON: "",
objects2D: "objects2DId",
objects3D: ""
},
Expand Down
Loading

0 comments on commit 1ae8f56

Please sign in to comment.