-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow creating view annotations using ViewAnnotation component. (#1384)
* Allow creating view annotations using ViewAnnotation component. Allows creating view annotations using Dash. * Fixed ViewAnnotation handling with Dash * Removed SubsurfaceViewerDashWrapper story, as it only works to demonstrate Dash. * Applied black formatting. Co-authored-by: Havard Bjerke <[email protected]>
- Loading branch information
Showing
6 changed files
with
155 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import numpy as np | ||
import xtgeo | ||
import dash | ||
import webviz_subsurface_components as wsc | ||
|
||
from utils.xtgeo_surface_to_float32 import get_surface_float32 | ||
from utils.xtgeo_polygons_to_json import xtgeo_polygons_to_polylines_geojson | ||
|
||
# Import a depth surface and a property surface using xtgeo | ||
depth_surface = xtgeo.surface_from_file("examples/example-data/topvolantis_depth.gri") | ||
property_surface = xtgeo.surface_from_file( | ||
"examples/example-data/topvolantis_seismic_attribute.gri" | ||
) | ||
polygons = xtgeo.polygons_from_file( | ||
"examples/example-data/topvolantis_faultpolygons.pol" | ||
) | ||
|
||
app = dash.Dash(__name__) | ||
|
||
app.layout = wsc.SubsurfaceViewerDashWrapper( | ||
id="deckgl-map", | ||
layers=[ | ||
{ | ||
"@@type": "AxesLayer", | ||
"id": "axes-layer", | ||
"bounds": [ | ||
depth_surface.xmin, | ||
depth_surface.ymin, | ||
-np.nanmax(depth_surface.values), | ||
depth_surface.xmax, | ||
depth_surface.ymax, | ||
np.nanmin(depth_surface.values), | ||
], | ||
}, | ||
{ | ||
"@@type": "MapLayer", | ||
"id": "mesh-layer", | ||
"meshUrl": "/map/mesh", | ||
"frame": { | ||
"origin": [depth_surface.xori, depth_surface.yori], | ||
"count": [depth_surface.ncol, depth_surface.nrow], | ||
"increment": [depth_surface.xinc, depth_surface.yinc], | ||
"rotDeg": depth_surface.rotation, | ||
}, | ||
"contours": [0, 20], | ||
"isContoursDepth": True, | ||
"gridLines": False, | ||
"material": True, | ||
"colorMapName": "Physics", | ||
"name": "mesh", | ||
}, | ||
{ | ||
"@@type": "MapLayer", | ||
"id": "mesh-and-property-layer", | ||
"meshUrl": "/map/mesh", | ||
"propertiesUrl": "/map/property", | ||
"frame": { | ||
"origin": [depth_surface.xori, depth_surface.yori], | ||
"count": [depth_surface.ncol, depth_surface.nrow], | ||
"increment": [depth_surface.xinc, depth_surface.yinc], | ||
"rotDeg": depth_surface.rotation, | ||
}, | ||
"isContoursDepth": True, | ||
"gridLines": False, | ||
"material": True, | ||
"colorMapName": "Seismic", | ||
"name": "mesh", | ||
}, | ||
{ | ||
"@@type": "FaultPolygonsLayer", | ||
"id": "fault-layer", | ||
"data": "/faults/faults.json", | ||
"refine": False, | ||
}, | ||
], | ||
views={ | ||
"layout": [1, 2], | ||
"showLabel": True, | ||
"viewports": [ | ||
{ | ||
"id": "view_1", | ||
"show3D": False, | ||
"name": "Depth surface", | ||
"layerIds": ["axes-layer", "mesh-layer"], | ||
"isSync": True, | ||
}, | ||
{ | ||
"id": "view_2", | ||
"show3D": False, | ||
"name": "Property mapped on depth surface", | ||
"layerIds": [ | ||
"fault-layer", | ||
"axes-layer", | ||
"mesh-and-property-layer", | ||
], | ||
"isSync": True, | ||
}, | ||
], | ||
}, | ||
children=[ | ||
wsc.ViewAnnotation(id="view_1", children=[wsc.ViewFooter(children="Hugin")]), | ||
wsc.ViewAnnotation(id="view_2", children=[wsc.ViewFooter(children="sdfsfd")]), | ||
], | ||
) | ||
|
||
|
||
@app.server.route("/map/<map_name>") | ||
def send_map(map_name: str): | ||
if map_name == "mesh": | ||
return get_surface_float32(depth_surface) | ||
if map_name == "property": | ||
return get_surface_float32(property_surface) | ||
|
||
|
||
@app.server.route("/faults/faults.json") | ||
def send_faults(): | ||
return xtgeo_polygons_to_polylines_geojson(polygons, xy_only=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run_server(debug=True) |
59 changes: 0 additions & 59 deletions
59
react/src/lib/components/DeckGLMap/SubsurfaceViewerDashWrapper.stories.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
react/src/lib/components/DeckGLMap/components/ViewAnnotation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
interface ViewAnnotationProps { | ||
id: string; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export const ViewAnnotation: React.FC<ViewAnnotationProps> = ({ children }) => { | ||
return <> {children} </>; | ||
}; | ||
|
||
ViewAnnotation.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
children: PropTypes.any, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters