Skip to content

Commit

Permalink
Code review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscb committed Jan 27, 2025
1 parent 73ae130 commit 8ba218f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { CollisionFilterExtension } from "@deck.gl/extensions";

const injectionVs = {
"vs:DECKGL_FILTER_COLOR": `
color.a = 1.0 / collision_fade; // Note: this will counteract the fading of the labels caused by deck.gl's CollisionFilterExtension
if (collision_fade != 0.0) {
color.a = 1.0 / collision_fade; // Note: this will counteract the fading of the labels caused by deck.gl's CollisionFilterExtension
}
`,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ import {
invertPath,
splineRefine,
} from "./utils/spline";
import { create, all } from "mathjs";

const math = create(all, { randomSeed: "a" });
const randomFunc = math?.random ? math.random : Math.random;

type StyleAccessorFunction = (
object: Feature,
Expand Down Expand Up @@ -117,7 +121,7 @@ export interface WellsLayerProps extends ExtendedLayerProps {
/** If true will prevent well name cluttering by not displaying overlapping names.
* default false.
*/
wellNameReduceClutter: boolean;
hideOverlappingWellNames: boolean;
isLog: boolean;
depthTest: boolean;
/** If true means that input z values are interpreted as depths.
Expand Down Expand Up @@ -154,7 +158,7 @@ const defaultProps = {
wellNameAtTop: false,
wellNameSize: 14,
wellNameColor: [0, 0, 0, 255],
wellNameReduceClutter: false,
hideOverlappingWellNames: false,
selectedWell: "@@#editedData.selectedWells", // used to get data from deckgl layer
depthTest: true,
ZIncreasingDownwards: true,
Expand Down Expand Up @@ -628,7 +632,6 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
collisionEnabled: true,
getCollisionPriority: (d: Feature<Geometry, GeoJsonProperties>) => {
const labelSize = d.properties?.["name"].length ?? 1;
//return labelSize;
if (is3d) {
// In 3D prioritize according to label size.
return labelSize;
Expand All @@ -642,7 +645,7 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
);

const priority = labelPosition
? (labelPosition?.[2] ?? 1) / 10 + Math.random() // priority must be in [-1000, 1000]
? (labelPosition?.[2] ?? 1) / 10 + randomFunc() // priority must be in [-1000, 1000]
: labelSize;
return priority;
}
Expand Down Expand Up @@ -680,10 +683,20 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
parameters,
visible: this.props.wellNameVisible && !fastDrawing,

...(this.props.wellNameReduceClutter ? clutterProps : {}),
...(this.props.hideOverlappingWellNames ? clutterProps : {}),
})
);

console.log(randomFunc())

Check failure on line 690 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 691 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 692 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 693 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 694 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 695 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 696 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 697 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`
console.log(randomFunc())

Check failure on line 698 in typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

View workflow job for this annotation

GitHub Actions / typescript

Insert `;`

const layers = [
outlineLayer,
logLayer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ export const SimplifiedRendering: StoryObj<typeof SubsurfaceViewer> = {
};

type ClutterProps = {
wellNameReduceClutter: boolean;
hideOverlappingWellNames: boolean;
wellNameAtTop: boolean;
};

Expand All @@ -674,7 +674,7 @@ const ReducedWellNameClutterComponent: React.FC<ClutterProps> = (
wellNameVisible: true,
wellNameAtTop: props.wellNameAtTop,
wellHeadStyle: { size: 4 },
wellNameReduceClutter: props.wellNameReduceClutter,
hideOverlappingWellNames: props.hideOverlappingWellNames,
refine: true,
outline: true,
ZIncreasingDownwards: false,
Expand Down Expand Up @@ -712,7 +712,7 @@ export const ReducedWellNameClutter3D: StoryObj<
typeof ReducedWellNameClutterComponent
> = {
args: {
wellNameReduceClutter: false,
hideOverlappingWellNames: false,
wellNameAtTop: true,
},
render: (args) => <ReducedWellNameClutterComponent {...args} />,
Expand All @@ -729,7 +729,7 @@ const ReducedWellNameClutterComponent2D: React.FC<ClutterProps> = (
wellNameVisible: true,
wellNameAtTop: props.wellNameAtTop,
wellHeadStyle: { size: 4 },
wellNameReduceClutter: props.wellNameReduceClutter,
hideOverlappingWellNames: props.hideOverlappingWellNames,
refine: true,
outline: true,
ZIncreasingDownwards: false,
Expand Down Expand Up @@ -758,7 +758,7 @@ export const ReducedWellNameClutter2D: StoryObj<
typeof ReducedWellNameClutterComponent
> = {
args: {
wellNameReduceClutter: false,
hideOverlappingWellNames: false,
wellNameAtTop: true,
},
render: (args) => <ReducedWellNameClutterComponent2D {...args} />,
Expand Down

0 comments on commit 8ba218f

Please sign in to comment.