-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle missing coordinates (#177)
* fix: handle missing coordinates * refactor: extract abstract profile layer class * test: update story snapshots * refactor: apply lint conditions * fix: sanitize missing coordinates * test: disable test in CI * test: disable flaky visual test * test: remove redundant story snapshots
- Loading branch information
Showing
20 changed files
with
130 additions
and
117 deletions.
There are no files selected for viewing
Binary file modified
BIN
-36.4 KB
(92%)
__snapshots__/chromium_layers-activity-layer--activity-vertical-scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-719 Bytes
(100%)
__snapshots__/chromium_layers-activity-layer--activity-with-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.92 KB
(94%)
__snapshots__/chromium_layers-activity-layer--jotunheimen-rundt-activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.94 KB
(99%)
__snapshots__/chromium_layers-activity-layer--phong-shading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.7 KB
(99%)
__snapshots__/chromium_layers-activity-layer--profile-width.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-783 Bytes
(100%)
__snapshots__/chromium_layers-activity-layer--set-activity-color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.92 KB
(94%)
__snapshots__/chromium_layers-activity-layer--use-data-url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-994 Bytes
(93%)
...hots__/chromium_layers-face-profile-layer--face-profile-zero-length-segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.04 KB
(90%)
...hots__/chromium_layers-side-profile-layer--side-profile-zero-length-segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-412 Bytes
(96%)
...pshots__/chromium_layers-top-profile-layer--top-profile-zero-length-segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-27.4 KB
(95%)
__snapshots__/webkit_layers-activity-layer--activity-vertical-scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.3 KB
(99%)
__snapshots__/webkit_layers-activity-layer--phong-shading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.88 KB
(100%)
__snapshots__/webkit_layers-activity-layer--profile-width.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-715 Bytes
(100%)
__snapshots__/webkit_layers-activity-layer--set-activity-color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.32 KB
(94%)
__snapshots__/webkit_layers-activity-layer--use-data-url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
66 changes: 66 additions & 0 deletions
66
src/layers/face-profile-layer/abstract-profile-layer/abstract-profile-layer.ts
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,66 @@ | ||
import { SimpleMeshLayer, SimpleMeshLayerProps } from "@deck.gl/mesh-layers"; | ||
import { type DefaultProps } from "@deck.gl/core"; | ||
import { | ||
Polyline, | ||
getOffset, | ||
} from "../../profile-layer/extrudePolylineProfile"; | ||
import { UpdateParameters, type Position } from "@deck.gl/core"; | ||
import { lineString, multiLineString } from "@turf/helpers"; | ||
import { Feature, LineString, MultiLineString } from "geojson"; | ||
import { centroid } from "@turf/centroid"; | ||
import { cleanCoords } from "@turf/clean-coords"; | ||
import { extrudeRoadMeshes } from "../util/extrudeRoadMeshes"; | ||
|
||
export type AbstractProfileLayerData = Polyline[]; | ||
|
||
export interface AbstractProfileLayerProps<DataT = unknown> | ||
extends Omit<SimpleMeshLayerProps<DataT>, "mesh"> { | ||
width?: number; | ||
phongShading?: boolean; | ||
} | ||
|
||
const getPosition = (data: unknown) => { | ||
const path = lineString(data as Polyline); | ||
const origin = centroid(path as Feature<LineString>).geometry.coordinates; | ||
return [origin[0], origin[1], 0] as Position; | ||
}; | ||
|
||
const defaultProps: DefaultProps<AbstractProfileLayerProps> = { | ||
...SimpleMeshLayer.defaultProps, | ||
id: "road-layer", | ||
getPosition, | ||
getColor: [200, 100, 150, 255], | ||
parameters: { | ||
cullMode: "back", | ||
}, | ||
phongShading: false, | ||
}; | ||
|
||
export abstract class AbstractProfileLayer< | ||
DataT = AbstractProfileLayerData, | ||
PropsT = AbstractProfileLayerProps, | ||
> extends SimpleMeshLayer<DataT, PropsT & AbstractProfileLayerProps> { | ||
static layerName = "AbstractProfileLayer"; | ||
static defaultProps = defaultProps; | ||
|
||
_getMesh(activities: AbstractProfileLayerData) { | ||
const paths = multiLineString(activities); | ||
|
||
const clean = cleanCoords(paths); | ||
|
||
const origin = centroid(clean as Feature<MultiLineString>); | ||
|
||
const pathMeterOffset = clean.geometry.coordinates.map( | ||
(polyline: Polyline) => | ||
getOffset(polyline, origin.geometry.coordinates), | ||
); | ||
|
||
const profileWidth = this.props.width ?? 100; | ||
|
||
return extrudeRoadMeshes(pathMeterOffset[0] as Polyline, profileWidth); | ||
} | ||
|
||
updateState(args: UpdateParameters<this>) { | ||
super.updateState(args); | ||
} | ||
} |
69 changes: 12 additions & 57 deletions
69
src/layers/face-profile-layer/side-profile-layer/side-profile-layer.ts
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
69 changes: 12 additions & 57 deletions
69
src/layers/face-profile-layer/top-profile-layer/top-profile-layer.ts
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