This tutorial shows how to deviate an example node of WellLogJS's TrackContainer and its contents. See the WellLog Tracks tutorial for track container basics.
The DeviationJS library is a part of the GeoToolkitJS library that provides a set of classes to render deviated nodes. It provides transformers from linear coordinates to trajectory coordinates. Transformations from linear space (where vertical coordinates represent either measured depths or true vertical depths) are currently supported.
# Steps to Setup Deviation
1. A trajectory (geotoolkit/deviation/Trajectory2d) can be defined in two ways: through its constructor or through the static createTrajectory method. The constructor is passed x-component and y-component arrays with the option of a measured depth (MD) array. Alternatively, the static method creates a trajectory from arrays with azimuth, inclination, and measured depth data sets.
2. Set a deviated node (geotoolkit/deviation/scene/DeviatedCompositeNode) by using the setDeviation function call. Note that 'trajectory' is the only mandatory parameter; 'transformer', 'trackWidth' and 'offset' are all optional.
3. A Node instance should be added to the DeviatedCompositeNode instance through the addChild call.
4. The DeviatedCompositeNode instance itself (like any other geotoolkit/scene/Node implementation) should be added to geotoolkit/plot/Plot or a parent composite node.
This tutorial shows WellLogJS's TrackContainer as an example of a node that can be deviated.
import { Plot } from "@int/geotoolkit/plot/Plot.ts";
import { Group } from "@int/geotoolkit/scene/Group.ts";
import { TrackContainer } from "@int/geotoolkit/welllog/TrackContainer.ts";
import { LogCurve } from "@int/geotoolkit/welllog/LogCurve.ts";
import { LogData } from "@int/geotoolkit/welllog/data/LogData.ts";
import { Grid } from "@int/geotoolkit/axis/Grid.ts";
import { LogAxis } from "@int/geotoolkit/welllog/LogAxis.ts";
import { NumericLinearTickGenerator } from "@int/geotoolkit/axis/NumericLinearTickGenerator.ts";
import { LogTrack } from "@int/geotoolkit/welllog/LogTrack.ts";
import { DeviatedCompositeNode } from "@int/geotoolkit/deviation/scene/DeviatedCompositeNode.ts";
import { RgbaColor } from "@int/geotoolkit/util/RgbaColor.ts";
import { Rect } from "@int/geotoolkit/util/Rect.ts";
import { Trajectory2d } from "@int/geotoolkit/deviation/Trajectory2d.ts";
import { curveData } from "/src/code/WellLog/utils/curveData.ts";
const minDepth = 100, maxDepth = 1100, trackWidth = 70, depthTrackWidth = 50, stepMajor = 100;
function createTrack(trackStart, trackWidth2) {
return new LogTrack().setBounds(new Rect(trackStart, minDepth, trackStart + trackWidth2, maxDepth)).setDepthLimits(minDepth, maxDepth).enableClipping(true).setLineStyle({
"color": "#bdbdbd",
"pixelsnapmode": true
});
}
function createDepthTrack(trackStart, trackWidth2, showLeftBorder, showRightBorder) {
const tgDepth = new NumericLinearTickGenerator().setTickStep("major", stepMajor);
return createTrack(trackStart, trackWidth2).setBorders({ "left": showLeftBorder, "right": showRightBorder }).addChild(new LogAxis(tgDepth).setBaseLineStyle(null));
}
function createLinearTrack(trackStart, trackWidth2) {
const tgValue = new NumericLinearTickGenerator().setTickStep("major", 0.5).setTickStep("minor", 0.25);
const tgDepth = new NumericLinearTickGenerator().setTickStep("major", stepMajor);
return createTrack(trackStart, trackWidth2).addChild(new Grid(tgDepth, tgValue));
}
function createLogData(minDepth2, maxDepth2, curveName) {
const logData = new LogData(curveName);
const data = curveData[curveName];
const dDepth = (maxDepth2 - minDepth2) / (data.length - 1);
const depthData = data.map((value, index) => minDepth2 + index * dDepth);
logData.setValues(depthData, data);
return logData;
}
function createCurve(dataSource, color) {
return new LogCurve(dataSource).setLineStyle({
"color": color,
"width": 2
});
}
function createScene(canvas) {
let lastTrack = null;
const getPosition = () => lastTrack ? lastTrack.getBounds().getRight() + 1 : 0;
const plot = new Plot({
"canvaselement": canvas,
"autorootbounds": true,
"root": new Group().setAutoModelLimitsMode(true)
});
const root = plot.getRoot();
let limits = root.getModelLimits();
const plotContainer = new Group().setBounds(new Rect(2, 2, limits.getRight() - 2, limits.getBottom() - 2)).setAutoModelLimitsMode(true);
root.addChild(plotContainer);
const trackContainer = new TrackContainer().addChild([
lastTrack = createDepthTrack(getPosition(), depthTrackWidth, true, false),
lastTrack = createLinearTrack(getPosition(), trackWidth).addChild(createCurve(createLogData(minDepth, maxDepth, "CALI"), new RgbaColor(255, 162, 20))),
lastTrack = createLinearTrack(getPosition(), trackWidth).addChild(createCurve(createLogData(minDepth, maxDepth, "RILM"), new RgbaColor(111, 164, 217))),
lastTrack = createDepthTrack(getPosition(), depthTrackWidth, false, true)
]).setDepthLimits(minDepth, maxDepth).setModelLimits(new Rect(0, minDepth, lastTrack.getBounds().getRight(), maxDepth));
limits = plotContainer.getModelLimits();
const width = getPosition();
const deviatedNode = new DeviatedCompositeNode().setDeviation({
"trajectory": new Trajectory2d({
"data": {
"x": [0, 0, 300],
"y": [0, 500, 500],
"d": [minDepth, (minDepth + maxDepth) / 2, maxDepth]
}
}),
"trackwidth": width + 2,
"offset": 0
}).addChild(trackContainer).setBounds(new Rect(width / 2, 0, limits.getWidth(), limits.getHeight() - width / 2));
plotContainer.addChild(deviatedNode);
return plot;
}
export { createScene };
createScene(document.querySelector('[ref="plot"]'));