Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Aug 6, 2024
1 parent 697cb17 commit 209f4a8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 42 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"govuk-frontend": "^5.4.0",
"jspdf": "^2.5.1",
"lit": "^3.0.1",
"ol": "^9.1.0",
"ol": "^9.2.4",
"ol-ext": "^4.0.21",
"ol-mapbox-style": "^12.3.0",
"ol-mapbox-style": "^12.3.4",
"postcode": "^5.1.0",
"proj4": "^2.11.0",
"rambda": "^9.2.1"
Expand All @@ -45,7 +45,7 @@
"@testing-library/user-event": "^14.5.2",
"@types/file-saver": "^2.0.7",
"@types/node": "22.0.3",
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@^3.3.0",
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@^3.4.0",
"@types/proj4": "^2.5.5",
"@vitest/ui": "^0.34.7",
"happy-dom": "^9.1.9",
Expand Down
82 changes: 47 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/my-map/drawing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FeatureLike } from "ol/Feature";
import { MultiPoint, MultiPolygon, Polygon } from "ol/geom";
import { Type } from "ol/geom/Geometry";
import { Draw, Modify, Snap } from "ol/interaction";
Expand All @@ -6,7 +7,6 @@ import { Vector as VectorSource } from "ol/source";
import { Circle, Fill, RegularShape, Stroke, Style, Text } from "ol/style";
import CircleStyle from "ol/style/Circle";
import { pointsSource } from "./snapping";
import { FeatureLike } from "ol/Feature";

export type DrawTypeEnum = Extract<Type, "Polygon" | "Point" | "Circle">;
export type DrawPointerEnum = "crosshair" | "dot";
Expand Down
10 changes: 7 additions & 3 deletions src/components/my-map/snapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Feature } from "ol";
import { FeatureLike } from "ol/Feature";
import { Geometry } from "ol/geom";
import Point from "ol/geom/Point";
import { Vector as VectorLayer } from "ol/layer";
import VectorTileLayer from "ol/layer/VectorTile";
Expand All @@ -7,7 +9,7 @@ import { Fill, Style } from "ol/style";
import CircleStyle from "ol/style/Circle";
import { splitEvery } from "rambda";

export const pointsSource = new VectorSource({
export const pointsSource: VectorSource<Feature<Geometry>> = new VectorSource({
features: [],
wrapX: false,
});
Expand All @@ -34,15 +36,17 @@ export const pointsLayer = new VectorLayer({
* @returns - a VectorSource populated with points within the extent
*/
export function getSnapPointsFromVectorTiles(
basemap: VectorTileLayer,
basemap: VectorTileLayer<FeatureLike>,
extent: number[],
) {
const points =
basemap &&
basemap
.getSource()
?.getFeaturesInExtent(extent)
?.filter((feature) => feature.getGeometry()?.getType() !== "Point")
?.filter(
(feature: FeatureLike) => feature.getGeometry()?.getType() !== "Point",
)
?.flatMap((feature: any) => feature.flatCoordinates_);

if (points) {
Expand Down

0 comments on commit 209f4a8

Please sign in to comment.