Skip to content

Commit

Permalink
Merge remote-tracking branch 'rubenthoms/spike-layer-system' into spi…
Browse files Browse the repository at this point in the history
…ke-layer-system
  • Loading branch information
rubenthoms committed Sep 12, 2024
2 parents 366dcaf + c3aff4e commit edce812
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ export class DrilledWellTrajectoriesContext implements SettingsContext<DrilledWe
}

fetchData(oldValues: DrilledWellTrajectoriesSettings, newValues: DrilledWellTrajectoriesSettings): void {
if (oldValues[SettingType.ENSEMBLE] === newValues[SettingType.ENSEMBLE]) {
if (isEqual(oldValues[SettingType.ENSEMBLE], newValues[SettingType.ENSEMBLE])) {
return;
}

const queryClient = this.getDelegate().getLayerManager().getQueryClient();

const settings = this.getDelegate().getSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ export class RealizationSurfaceLayer

const surfAddrStr = surfaceAddress ? encodeSurfAddrStr(surfaceAddress) : null;

const queryKey = ["getSurfaceData", surfAddrStr, null, "float"];
const queryKey = ["getSurfaceData", surfAddrStr, null, "png"];

this._layerDelegate.registerQueryKey(queryKey);

const promise = queryClient
.fetchQuery({
queryKey,
queryFn: () => apiService.surface.getSurfaceData(surfAddrStr ?? "", "float", null),
queryFn: () => apiService.surface.getSurfaceData(surfAddrStr ?? "", "png", null),
staleTime: STALE_TIME,
gcTime: CACHE_TIME,
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/LayerSpike/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function Settings(props: ModuleSettingsProps<any>): React.ReactNode {
groupDelegate.prependChild(new SharedSetting(new Realization()));
}
if (settingType === SharedSettingType.SURFACE_NAME) {
groupDelegate.appendChild(new SharedSetting(new SurfaceName()));
groupDelegate.prependChild(new SharedSetting(new SurfaceName()));
}
}

Expand Down
45 changes: 40 additions & 5 deletions frontend/src/modules/LayerSpike/view/layerFactory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { PolygonData_api, WellboreTrajectory_api } from "@api";
import { PolygonData_api, SurfaceDef_api, WellboreTrajectory_api } from "@api";
import { Layer } from "@deck.gl/core/typed";
import { GeoJsonLayer } from "@deck.gl/layers/typed";
import { Vec2, rotatePoint2Around } from "@lib/utils/vec2";
import { SurfaceDataFloat_trans } from "@modules/_shared/Surface/queryDataTransforms";
import { MapLayer, WellsLayer } from "@webviz/subsurface-viewer/dist/layers";
import { ColormapLayer, Hillshading2DLayer, MapLayer, WellsLayer } from "@webviz/subsurface-viewer/dist/layers";

import { Feature } from "geojson";
import { SurfaceDataPng } from "src/api/models/SurfaceDataPng";

import { DrilledWellTrajectoriesLayer } from "../layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer";
import { ObservedSurfaceLayer } from "../layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer";
Expand All @@ -15,14 +17,15 @@ import { Layer as LayerInterface } from "../layers/interfaces";

export function makeLayer(layer: LayerInterface<any, any>): Layer | null {
const data = layer.getLayerDelegate().getData();

if (!data) {
return null;
}
if (layer instanceof ObservedSurfaceLayer) {
return createMapFloatLayer(data, layer.getItemDelegate().getId());
return createMapImageLayer(data, layer.getItemDelegate().getId());
}
if (layer instanceof RealizationSurfaceLayer) {
return createMapFloatLayer(data, layer.getItemDelegate().getId());
return createMapImageLayer(data, layer.getItemDelegate().getId());
}
if (layer instanceof StatisticalSurfaceLayer) {
return createMapFloatLayer(data, layer.getItemDelegate().getId());
Expand Down Expand Up @@ -59,6 +62,38 @@ function createMapFloatLayer(layerData: SurfaceDataFloat_trans, id: string): Map
depthTest: false,
});
}

function createMapImageLayer(layerData: SurfaceDataPng, id: string): ColormapLayer {
return new ColormapLayer({
id: id,
image: `data:image/png;base64,${layerData.png_image_base64}`,
bounds: _calcBoundsForRotationAroundUpperLeftCorner(layerData.surface_def),
rotDeg: layerData.surface_def.rot_deg,
valueRange: [layerData.value_min, layerData.value_max],
colorMapRange: [layerData.value_min, layerData.value_max],
colorMapName: "Physics",
parameters: {
depthTest: false,
},
});
}
function _calcBoundsForRotationAroundUpperLeftCorner(surfDef: SurfaceDef_api): [number, number, number, number] {
const width = (surfDef.npoints_x - 1) * surfDef.inc_x;
const height = (surfDef.npoints_y - 1) * surfDef.inc_y;
const orgRotPoint: Vec2 = { x: surfDef.origin_utm_x, y: surfDef.origin_utm_y };
const orgTopLeft: Vec2 = { x: surfDef.origin_utm_x, y: surfDef.origin_utm_y + height };

const transTopLeft: Vec2 = rotatePoint2Around(orgTopLeft, orgRotPoint, (surfDef.rot_deg * Math.PI) / 180);
const tLeft = transTopLeft.x;
const tBottom = transTopLeft.y - height;
const tRight = transTopLeft.x + width;
const tTop = transTopLeft.y;

const bounds: [number, number, number, number] = [tLeft, tBottom, tRight, tTop];

return bounds;
}

function createFaultPolygonsLayer(polygonsData: PolygonData_api[], id: string): GeoJsonLayer {
const features: Record<string, unknown>[] = polygonsData.map((polygon) => {
return surfacePolygonsToGeojson(polygon);
Expand All @@ -71,7 +106,7 @@ function createFaultPolygonsLayer(polygonsData: PolygonData_api[], id: string):
return new GeoJsonLayer({
id: id,
data: data,
opacity: 0.5,
// opacity: 0.5,
parameters: {
depthTest: false,
},
Expand Down

0 comments on commit edce812

Please sign in to comment.