terra-draw 1.0.0-beta.1 → 1.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/adapters/common/adapter-listener.d.ts +22 -0
- package/dist/adapters/common/base.adapter.d.ts +59 -0
- package/dist/adapters/mapbox-gl.adapter.d.ts +0 -1
- package/dist/adapters/openlayers.adapter.d.ts +14 -13
- package/dist/common.d.ts +11 -9
- package/dist/extend.d.ts +4 -0
- package/dist/geometry/calculate-relative-angle.d.ts +2 -10
- package/dist/geometry/clockwise.d.ts +2 -0
- package/dist/geometry/determine-halfplane.d.ts +2 -10
- package/dist/geometry/measure/bearing.d.ts +3 -7
- package/dist/geometry/measure/destination.d.ts +2 -7
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +2 -10
- package/dist/geometry/measure/pixel-distance.d.ts +2 -7
- package/dist/geometry/point-on-line.d.ts +5 -0
- package/dist/geometry/project/web-mercator.d.ts +2 -4
- package/dist/geometry/web-mercator-centroid.d.ts +2 -4
- package/dist/geometry/web-mercator-point-on-line.d.ts +11 -0
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +2 -7
- package/dist/modes/base.mode.d.ts +3 -1
- package/dist/modes/circle/circle.mode.d.ts +3 -2
- package/dist/modes/coordinate-snapping.behavior.d.ts +16 -0
- package/dist/modes/freehand/freehand.mode.d.ts +8 -2
- package/dist/modes/{snapping.behavior.d.ts → line-snapping.behavior.d.ts} +1 -1
- package/dist/modes/linestring/linestring.mode.d.ts +16 -5
- package/dist/modes/point/point.mode.d.ts +2 -2
- package/dist/modes/polygon/polygon.mode.d.ts +17 -4
- package/dist/modes/rectangle/rectangle.mode.d.ts +2 -2
- package/dist/modes/render/render.mode.d.ts +2 -1
- package/dist/modes/sector/sector.mode.d.ts +60 -0
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +2 -2
- package/dist/modes/sensor/sensor.mode.d.ts +69 -0
- package/dist/store/store-feature-validation.d.ts +8 -2
- package/dist/store/store.d.ts +7 -3
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +12 -13
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/dist/validation-reasons.d.ts +13 -0
- package/dist/validations/common-validations.d.ts +2 -0
- package/dist/validations/linestring.validation.d.ts +4 -1
- package/dist/validations/max-size.validation.d.ts +3 -1
- package/dist/validations/min-size.validation.d.ts +3 -1
- package/dist/validations/not-self-intersecting.validation.d.ts +4 -1
- package/dist/validations/point.validation.d.ts +4 -1
- package/dist/validations/polygon.validation.d.ts +8 -2
- package/e2e/package-lock.json +5 -4
- package/e2e/package.json +1 -1
- package/e2e/public/index.html +2 -0
- package/e2e/tests/leaflet.spec.ts +414 -18
- package/e2e/tests/setup.ts +16 -5
- package/eslint.config.js +32 -0
- package/package.json +29 -28
- package/tsconfig.json +2 -1
- package/readme.gif +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const ValidationReasons: {
|
|
2
|
+
ValidationReasonFeatureNotPoint: string;
|
|
3
|
+
ValidationReasonFeatureInvalidCoordinates: string;
|
|
4
|
+
ValidationReasonFeatureNotPolygon: string;
|
|
5
|
+
ValidationReasonFeatureHasHoles: string;
|
|
6
|
+
ValidationReasonFeatureLessThanFourCoordinates: string;
|
|
7
|
+
ValidationReasonFeatureHasInvalidCoordinates: string;
|
|
8
|
+
ValidationReasonFeatureCoordinatesNotClosed: string;
|
|
9
|
+
ValidationReasonFeatureNotPolygonOrLineString: string;
|
|
10
|
+
ValidationReasonFeatureSelfIntersects: string;
|
|
11
|
+
ValidationReasonFeatureLessThanMinSize: string;
|
|
12
|
+
ValidationReasonModeMismatch: string;
|
|
13
|
+
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { Validation } from "../common";
|
|
1
2
|
import { GeoJSONStoreFeatures } from "../terra-draw";
|
|
2
|
-
export declare
|
|
3
|
+
export declare const ValidationReasonFeatureIsNotALineString = "Feature is not a LineString";
|
|
4
|
+
export declare const ValidationReasonFeatureHasLessThanTwoCoordinates = "Feature has less than 2 coordinates";
|
|
5
|
+
export declare function ValidateLineStringFeature(feature: GeoJSONStoreFeatures, coordinatePrecision: number): ReturnType<Validation>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { Validation } from "../common";
|
|
1
2
|
import { GeoJSONStoreFeatures } from "../terra-draw";
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const ValidationMaxAreaSquareMetersReason = "Feature is larger than the maximum area";
|
|
4
|
+
export declare const ValidateMaxAreaSquareMeters: (feature: GeoJSONStoreFeatures, maxSize: number) => ReturnType<Validation>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { Validation } from "../common";
|
|
1
2
|
import { GeoJSONStoreFeatures } from "../terra-draw";
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const ValidationReasonFeatureLessThanMinSize = "Feature is smaller than the minimum area";
|
|
4
|
+
export declare const ValidateMinAreaSquareMeters: (feature: GeoJSONStoreFeatures, minSize: number) => ReturnType<Validation>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { GeoJSONStoreFeatures } from "../terra-draw";
|
|
2
|
-
|
|
2
|
+
import { Validation } from "../common";
|
|
3
|
+
export declare const ValidationReasonFeatureNotPolygonOrLineString = "Feature is not a Polygon or LineString";
|
|
4
|
+
export declare const ValidationReasonFeatureSelfIntersects = "Feature intersects itself";
|
|
5
|
+
export declare const ValidateNotSelfIntersecting: (feature: GeoJSONStoreFeatures) => ReturnType<Validation>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { Validation } from "../common";
|
|
1
2
|
import { GeoJSONStoreFeatures } from "../terra-draw";
|
|
2
|
-
export declare
|
|
3
|
+
export declare const ValidationReasonFeatureNotPoint = "Feature is not a Point";
|
|
4
|
+
export declare const ValidationReasonFeatureInvalidCoordinates = "Feature has invalid coordinates";
|
|
5
|
+
export declare function ValidatePointFeature(feature: GeoJSONStoreFeatures, coordinatePrecision: number): ReturnType<Validation>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { GeoJSONStoreFeatures } from "../terra-draw";
|
|
2
|
-
|
|
3
|
-
export declare
|
|
2
|
+
import { Validation } from "../common";
|
|
3
|
+
export declare const ValidationReasonFeatureNotPolygon = "Feature is not a Polygon";
|
|
4
|
+
export declare const ValidationReasonFeatureHasHoles = "Feature has holes";
|
|
5
|
+
export declare const ValidationReasonFeatureLessThanFourCoordinates = "Feature has less than 4 coordinates";
|
|
6
|
+
export declare const ValidationReasonFeatureHasInvalidCoordinates = "Feature has invalid coordinates";
|
|
7
|
+
export declare const ValidationReasonFeatureCoordinatesNotClosed = "Feature coordinates are not closed";
|
|
8
|
+
export declare function ValidatePolygonFeature(feature: GeoJSONStoreFeatures, coordinatePrecision: number): ReturnType<Validation>;
|
|
9
|
+
export declare function ValidateNonIntersectingPolygonFeature(feature: GeoJSONStoreFeatures, coordinatePrecision: number): ReturnType<Validation>;
|
package/e2e/package-lock.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@types/node": "20.10.5",
|
|
15
15
|
"dotenv-webpack": "8.0.0",
|
|
16
16
|
"ts-loader": "9.5.1",
|
|
17
|
-
"typescript": "5.
|
|
17
|
+
"typescript": "5.6.3",
|
|
18
18
|
"webpack": "5.73.0",
|
|
19
19
|
"webpack-cli": "4.10.0",
|
|
20
20
|
"webpack-dev-server": "4.11.1"
|
|
@@ -3756,10 +3756,11 @@
|
|
|
3756
3756
|
}
|
|
3757
3757
|
},
|
|
3758
3758
|
"node_modules/typescript": {
|
|
3759
|
-
"version": "5.
|
|
3760
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.
|
|
3761
|
-
"integrity": "sha512-
|
|
3759
|
+
"version": "5.6.3",
|
|
3760
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
|
|
3761
|
+
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
|
|
3762
3762
|
"dev": true,
|
|
3763
|
+
"license": "Apache-2.0",
|
|
3763
3764
|
"bin": {
|
|
3764
3765
|
"tsc": "bin/tsc",
|
|
3765
3766
|
"tsserver": "bin/tsserver"
|
package/e2e/package.json
CHANGED
package/e2e/public/index.html
CHANGED
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
<button id="polygon">Polygon</button>
|
|
43
43
|
<button id="rectangle">Rectangle</button>
|
|
44
44
|
<button id="angled-rectangle">Angled Rectangle</button>
|
|
45
|
+
<button id="sector">Sector</button>
|
|
46
|
+
<button id="sensor">Sensor</button>
|
|
45
47
|
<button id="circle">Circle</button>
|
|
46
48
|
<button id="clear">Clear</button>
|
|
47
49
|
</div>
|
|
@@ -53,7 +53,7 @@ test.describe("page setup", () => {
|
|
|
53
53
|
test.describe("point mode", () => {
|
|
54
54
|
const mode = "point";
|
|
55
55
|
|
|
56
|
-
test("mode can set and
|
|
56
|
+
test("mode can set and used to create a point", async ({ page }) => {
|
|
57
57
|
const mapDiv = await setupMap({ page });
|
|
58
58
|
await changeMode({ page, mode });
|
|
59
59
|
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
@@ -61,9 +61,7 @@ test.describe("point mode", () => {
|
|
|
61
61
|
await expectPaths({ page, count: 1 });
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
test("mode can set and
|
|
65
|
-
page,
|
|
66
|
-
}) => {
|
|
64
|
+
test("mode can set and used to create multiple points", async ({ page }) => {
|
|
67
65
|
const mapDiv = await setupMap({ page });
|
|
68
66
|
await changeMode({ page, mode });
|
|
69
67
|
|
|
@@ -91,7 +89,7 @@ test.describe("linestring mode", () => {
|
|
|
91
89
|
] as { name: string; config: TestConfigOptions[] }[];
|
|
92
90
|
|
|
93
91
|
for (const { name, config } of options) {
|
|
94
|
-
test(`mode can set and
|
|
92
|
+
test(`mode can set and used to create a linestring${name}`, async ({
|
|
95
93
|
page,
|
|
96
94
|
}) => {
|
|
97
95
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -108,7 +106,7 @@ test.describe("linestring mode", () => {
|
|
|
108
106
|
await expectPaths({ page, count: 1 });
|
|
109
107
|
});
|
|
110
108
|
|
|
111
|
-
test(`mode can set and
|
|
109
|
+
test(`mode can set and used to create a linestring with multiple points${name}`, async ({
|
|
112
110
|
page,
|
|
113
111
|
}) => {
|
|
114
112
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -133,7 +131,7 @@ test.describe("linestring mode", () => {
|
|
|
133
131
|
await expectPaths({ page, count: 1 });
|
|
134
132
|
});
|
|
135
133
|
|
|
136
|
-
test(`mode can set and
|
|
134
|
+
test(`mode can set and used to create a linestring with multiple clicked points${name}`, async ({
|
|
137
135
|
page,
|
|
138
136
|
}) => {
|
|
139
137
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -158,7 +156,7 @@ test.describe("linestring mode", () => {
|
|
|
158
156
|
await expectPaths({ page, count: 1 });
|
|
159
157
|
});
|
|
160
158
|
|
|
161
|
-
test(`mode can set and
|
|
159
|
+
test(`mode can set and used to create multiple linestrings${name}`, async ({
|
|
162
160
|
page,
|
|
163
161
|
}) => {
|
|
164
162
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -191,13 +189,54 @@ test.describe("linestring mode", () => {
|
|
|
191
189
|
// Two lines
|
|
192
190
|
await expectPaths({ page, count: 2 });
|
|
193
191
|
});
|
|
192
|
+
|
|
193
|
+
test(`mode can set with snapping enabled used to create multiple linestrings${name}`, async ({
|
|
194
|
+
page,
|
|
195
|
+
}) => {
|
|
196
|
+
const configQueryParam: TestConfigOptions[] = config
|
|
197
|
+
? [...config, "snappingCoordinate"]
|
|
198
|
+
: ["snappingCoordinate"];
|
|
199
|
+
|
|
200
|
+
const mapDiv = await setupMap({
|
|
201
|
+
page,
|
|
202
|
+
configQueryParam,
|
|
203
|
+
});
|
|
204
|
+
await changeMode({ page, mode });
|
|
205
|
+
|
|
206
|
+
// First line
|
|
207
|
+
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2);
|
|
208
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
209
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3);
|
|
210
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
211
|
+
|
|
212
|
+
// One point + one line
|
|
213
|
+
await expectPaths({ page, count: 2 });
|
|
214
|
+
|
|
215
|
+
// Close first line
|
|
216
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
217
|
+
|
|
218
|
+
// One line
|
|
219
|
+
await expectPaths({ page, count: 1 });
|
|
220
|
+
|
|
221
|
+
// Second line
|
|
222
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3);
|
|
223
|
+
|
|
224
|
+
// Should see snapping point
|
|
225
|
+
await expectPaths({ page, count: 2 });
|
|
226
|
+
|
|
227
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
228
|
+
await page.mouse.move(mapDiv.width / 4, mapDiv.height / 4);
|
|
229
|
+
|
|
230
|
+
// Snapping point disappears but the second line is created so it is still 2
|
|
231
|
+
await expectPaths({ page, count: 2 });
|
|
232
|
+
});
|
|
194
233
|
}
|
|
195
234
|
});
|
|
196
235
|
|
|
197
236
|
test.describe("polygon mode", () => {
|
|
198
237
|
const mode = "polygon";
|
|
199
238
|
|
|
200
|
-
test("mode can set and
|
|
239
|
+
test("mode can set and used to create a polygon", async ({ page }) => {
|
|
201
240
|
const mapDiv = await setupMap({ page });
|
|
202
241
|
await changeMode({ page, mode });
|
|
203
242
|
|
|
@@ -307,14 +346,66 @@ test.describe("polygon mode", () => {
|
|
|
307
346
|
// over the limit of 1000000 square meters.
|
|
308
347
|
await expectPaths({ page, count: 1 });
|
|
309
348
|
});
|
|
349
|
+
|
|
350
|
+
test("mode can set and used to create a polygon with snapping enabled", async ({
|
|
351
|
+
page,
|
|
352
|
+
}) => {
|
|
353
|
+
const mapDiv = await setupMap({
|
|
354
|
+
page,
|
|
355
|
+
configQueryParam: ["snappingCoordinate"],
|
|
356
|
+
});
|
|
357
|
+
await changeMode({ page, mode });
|
|
358
|
+
|
|
359
|
+
// The length of the square sides in pixels
|
|
360
|
+
const sideLength = 100;
|
|
361
|
+
|
|
362
|
+
// Calculating the half of the side length
|
|
363
|
+
const halfLength = sideLength / 2;
|
|
364
|
+
|
|
365
|
+
// Coordinates of the center
|
|
366
|
+
const centerX = mapDiv.width / 2;
|
|
367
|
+
const centerY = mapDiv.height / 2;
|
|
368
|
+
|
|
369
|
+
// Coordinates of the four corners of the square
|
|
370
|
+
const topLeft = { x: centerX - halfLength, y: centerY - halfLength };
|
|
371
|
+
const topRight = { x: centerX + halfLength, y: centerY - halfLength };
|
|
372
|
+
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength };
|
|
373
|
+
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength };
|
|
374
|
+
|
|
375
|
+
// Perform clicks at each corner
|
|
376
|
+
await page.mouse.click(topLeft.x, topLeft.y);
|
|
377
|
+
await page.mouse.click(topRight.x, topRight.y);
|
|
378
|
+
await page.mouse.click(bottomRight.x, bottomRight.y);
|
|
379
|
+
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
380
|
+
|
|
381
|
+
// Close the square
|
|
382
|
+
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
383
|
+
|
|
384
|
+
// One point + one line
|
|
385
|
+
await expectPaths({ page, count: 1 });
|
|
386
|
+
|
|
387
|
+
// Let's create a new polygon attached to the square, snapping to it
|
|
388
|
+
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
389
|
+
await page.mouse.click(bottomRight.x, bottomRight.y);
|
|
390
|
+
await page.mouse.click(bottomRight.x, bottomRight.y + 50);
|
|
391
|
+
|
|
392
|
+
await expectPaths({ page, count: 4 });
|
|
393
|
+
|
|
394
|
+
await page.mouse.click(bottomRight.x, bottomRight.y + 50);
|
|
395
|
+
|
|
396
|
+
await expectPaths({ page, count: 2 });
|
|
397
|
+
|
|
398
|
+
// Go to another corner and it should snap with a point appearing
|
|
399
|
+
await page.mouse.click(topLeft.x, topLeft.y);
|
|
400
|
+
|
|
401
|
+
await expectPaths({ page, count: 3 });
|
|
402
|
+
});
|
|
310
403
|
});
|
|
311
404
|
|
|
312
405
|
test.describe("rectangle mode", () => {
|
|
313
406
|
const mode = "rectangle";
|
|
314
407
|
|
|
315
|
-
test("mode can set and
|
|
316
|
-
page,
|
|
317
|
-
}) => {
|
|
408
|
+
test("mode can set and used to create a rectangle", async ({ page }) => {
|
|
318
409
|
const mapDiv = await setupMap({ page });
|
|
319
410
|
await changeMode({ page, mode });
|
|
320
411
|
|
|
@@ -331,7 +422,7 @@ test.describe("rectangle mode", () => {
|
|
|
331
422
|
test.describe("angled rectangle mode", () => {
|
|
332
423
|
const mode = "angled-rectangle";
|
|
333
424
|
|
|
334
|
-
test("mode can set and
|
|
425
|
+
test("mode can set and used to create an angled rectangle (horizontal up)", async ({
|
|
335
426
|
page,
|
|
336
427
|
}) => {
|
|
337
428
|
const mapDiv = await setupMap({ page });
|
|
@@ -350,7 +441,7 @@ test.describe("angled rectangle mode", () => {
|
|
|
350
441
|
await expectPathDimensions({ page, width: 217, height: 74 });
|
|
351
442
|
});
|
|
352
443
|
|
|
353
|
-
test("mode can set and
|
|
444
|
+
test("mode can set and used to create an angled rectangle (horizontal down)", async ({
|
|
354
445
|
page,
|
|
355
446
|
}) => {
|
|
356
447
|
const mapDiv = await setupMap({ page });
|
|
@@ -369,7 +460,7 @@ test.describe("angled rectangle mode", () => {
|
|
|
369
460
|
await expectPathDimensions({ page, width: 217, height: 84 });
|
|
370
461
|
});
|
|
371
462
|
|
|
372
|
-
test("mode can set and
|
|
463
|
+
test("mode can set and used to create an angled (diagonal)", async ({
|
|
373
464
|
page,
|
|
374
465
|
}) => {
|
|
375
466
|
const mapDiv = await setupMap({ page });
|
|
@@ -388,7 +479,7 @@ test.describe("angled rectangle mode", () => {
|
|
|
388
479
|
await expectPathDimensions({ page, width: 245, height: 174 });
|
|
389
480
|
});
|
|
390
481
|
|
|
391
|
-
test("mode can set and
|
|
482
|
+
test("mode can set and used to create an angled (diagonal 2)", async ({
|
|
392
483
|
page,
|
|
393
484
|
}) => {
|
|
394
485
|
const mapDiv = await setupMap({ page });
|
|
@@ -410,10 +501,315 @@ test.describe("angled rectangle mode", () => {
|
|
|
410
501
|
});
|
|
411
502
|
});
|
|
412
503
|
|
|
504
|
+
test.describe("sector mode", () => {
|
|
505
|
+
const mode = "sector";
|
|
506
|
+
|
|
507
|
+
test("mode can set and used to create a sector less than 90 degrees (clockwise)", async ({
|
|
508
|
+
page,
|
|
509
|
+
}) => {
|
|
510
|
+
const mapDiv = await setupMap({ page });
|
|
511
|
+
await changeMode({ page, mode });
|
|
512
|
+
|
|
513
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
514
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
515
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
516
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, {
|
|
517
|
+
steps: 30,
|
|
518
|
+
});
|
|
519
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
520
|
+
|
|
521
|
+
await expectPaths({ page, count: 1 });
|
|
522
|
+
|
|
523
|
+
await expectPathDimensions({ page, width: 217, height: 109 });
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
test("mode can set and used to create a sector more than 90 degrees (clockwise)", async ({
|
|
527
|
+
page,
|
|
528
|
+
}) => {
|
|
529
|
+
const mapDiv = await setupMap({ page });
|
|
530
|
+
await changeMode({ page, mode });
|
|
531
|
+
|
|
532
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
533
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
534
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
535
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
536
|
+
steps: 30,
|
|
537
|
+
});
|
|
538
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
|
|
539
|
+
|
|
540
|
+
await expectPaths({ page, count: 1 });
|
|
541
|
+
|
|
542
|
+
await expectPathDimensions({ page, width: 417, height: 217 });
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
test("mode can set and used to create a sector more than 180 degrees (clockwise)", async ({
|
|
546
|
+
page,
|
|
547
|
+
}) => {
|
|
548
|
+
const mapDiv = await setupMap({ page });
|
|
549
|
+
await changeMode({ page, mode });
|
|
550
|
+
|
|
551
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
552
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
553
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
554
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
555
|
+
steps: 10,
|
|
556
|
+
});
|
|
557
|
+
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
558
|
+
steps: 10,
|
|
559
|
+
});
|
|
560
|
+
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
561
|
+
|
|
562
|
+
await expectPaths({ page, count: 1 });
|
|
563
|
+
|
|
564
|
+
await expectPathDimensions({ page, width: 430, height: 430 });
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
test("mode can set and used to create a sector less than 90 degrees (anticlockwise)", async ({
|
|
568
|
+
page,
|
|
569
|
+
}) => {
|
|
570
|
+
const mapDiv = await setupMap({ page });
|
|
571
|
+
await changeMode({ page, mode });
|
|
572
|
+
|
|
573
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
574
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
575
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
576
|
+
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
577
|
+
steps: 30,
|
|
578
|
+
});
|
|
579
|
+
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
580
|
+
|
|
581
|
+
await expectPaths({ page, count: 1 });
|
|
582
|
+
|
|
583
|
+
await expectPathDimensions({ page, width: 217, height: 150 });
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
test("mode can set and used to create a sector more than 90 degrees (anticlockwise)", async ({
|
|
587
|
+
page,
|
|
588
|
+
}) => {
|
|
589
|
+
const mapDiv = await setupMap({ page });
|
|
590
|
+
await changeMode({ page, mode });
|
|
591
|
+
|
|
592
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
593
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
594
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
595
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
596
|
+
steps: 30,
|
|
597
|
+
});
|
|
598
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.5);
|
|
599
|
+
|
|
600
|
+
await expectPaths({ page, count: 1 });
|
|
601
|
+
|
|
602
|
+
await expectPathDimensions({ page, width: 417, height: 217 });
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
test("mode can set and used to create a sector more than 180 degrees (anticlockwise)", async ({
|
|
606
|
+
page,
|
|
607
|
+
}) => {
|
|
608
|
+
const mapDiv = await setupMap({ page });
|
|
609
|
+
await changeMode({ page, mode });
|
|
610
|
+
|
|
611
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
612
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
613
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
614
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
615
|
+
steps: 30,
|
|
616
|
+
});
|
|
617
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
618
|
+
steps: 30,
|
|
619
|
+
});
|
|
620
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
|
|
621
|
+
|
|
622
|
+
await expectPaths({ page, count: 1 });
|
|
623
|
+
|
|
624
|
+
await expectPathDimensions({ page, width: 430, height: 292 });
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
test.describe("sensor mode", () => {
|
|
629
|
+
const mode = "sensor";
|
|
630
|
+
|
|
631
|
+
test("mode can set and creates center point on first click", async ({
|
|
632
|
+
page,
|
|
633
|
+
}) => {
|
|
634
|
+
const mapDiv = await setupMap({ page });
|
|
635
|
+
await changeMode({ page, mode });
|
|
636
|
+
|
|
637
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
638
|
+
|
|
639
|
+
await expectPaths({ page, count: 1 });
|
|
640
|
+
|
|
641
|
+
await expectPathDimensions({ page, width: 12, height: 12 });
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
test("mode can set and but won't close if the mouse goes behind the initial arc", async ({
|
|
645
|
+
page,
|
|
646
|
+
}) => {
|
|
647
|
+
const mapDiv = await setupMap({ page });
|
|
648
|
+
await changeMode({ page, mode });
|
|
649
|
+
|
|
650
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
651
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
652
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
653
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, { steps: 30 });
|
|
654
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
655
|
+
|
|
656
|
+
// The cursor is now behind the initial arc and so wont close the sensor
|
|
657
|
+
await page.mouse.move(mapDiv.width / 1, mapDiv.height / 3, { steps: 30 });
|
|
658
|
+
await page.mouse.click(mapDiv.width / 1, mapDiv.height / 3);
|
|
659
|
+
|
|
660
|
+
// We expect the count to be 2 because the sensor polygon is not finished
|
|
661
|
+
// and we are left with the center point and the arc line
|
|
662
|
+
await expectPaths({ page, count: 2 });
|
|
663
|
+
|
|
664
|
+
await expectPathDimensions({ page, width: 12, height: 12, item: 0 });
|
|
665
|
+
await expectPathDimensions({ page, width: 31, height: 109, item: 1 });
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
test("mode can set and used to create a sensor less than 90 degrees (clockwise)", async ({
|
|
669
|
+
page,
|
|
670
|
+
}) => {
|
|
671
|
+
const mapDiv = await setupMap({ page });
|
|
672
|
+
await changeMode({ page, mode });
|
|
673
|
+
|
|
674
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
675
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
676
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
677
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, { steps: 30 });
|
|
678
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
679
|
+
|
|
680
|
+
// Finalise the sensor polygon
|
|
681
|
+
await page.mouse.move(mapDiv.width / 5, mapDiv.height / 3, { steps: 30 });
|
|
682
|
+
await page.mouse.click(mapDiv.width / 5, mapDiv.height / 3);
|
|
683
|
+
|
|
684
|
+
await expectPaths({ page, count: 1 });
|
|
685
|
+
|
|
686
|
+
await expectPathDimensions({ page, width: 220, height: 201 });
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
test("mode can set and used to create a sensor more than 90 degrees (clockwise)", async ({
|
|
690
|
+
page,
|
|
691
|
+
}) => {
|
|
692
|
+
const mapDiv = await setupMap({ page });
|
|
693
|
+
await changeMode({ page, mode });
|
|
694
|
+
|
|
695
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
696
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
697
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
698
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 2.5, {
|
|
699
|
+
steps: 30,
|
|
700
|
+
});
|
|
701
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 2.5);
|
|
702
|
+
|
|
703
|
+
// Finalise the sensor polygon
|
|
704
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 5, {
|
|
705
|
+
steps: 30,
|
|
706
|
+
});
|
|
707
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 5);
|
|
708
|
+
|
|
709
|
+
await expectPathDimensions({ page, width: 767, height: 390 });
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
test("mode can set and used to create a sensor more than 180 degrees (clockwise)", async ({
|
|
713
|
+
page,
|
|
714
|
+
}) => {
|
|
715
|
+
const mapDiv = await setupMap({ page });
|
|
716
|
+
await changeMode({ page, mode });
|
|
717
|
+
|
|
718
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
719
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
720
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
721
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
722
|
+
steps: 10,
|
|
723
|
+
});
|
|
724
|
+
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
725
|
+
steps: 10,
|
|
726
|
+
});
|
|
727
|
+
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
728
|
+
|
|
729
|
+
// Finalise the sensor polygon
|
|
730
|
+
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.25);
|
|
731
|
+
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.25);
|
|
732
|
+
|
|
733
|
+
await expectPaths({ page, count: 1 });
|
|
734
|
+
|
|
735
|
+
await expectPathDimensions({ page, width: 506, height: 506 });
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
test("mode can set and used to create a sensor less than 90 degrees (anticlockwise)", async ({
|
|
739
|
+
page,
|
|
740
|
+
}) => {
|
|
741
|
+
const mapDiv = await setupMap({ page });
|
|
742
|
+
await changeMode({ page, mode });
|
|
743
|
+
|
|
744
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
745
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
746
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
747
|
+
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
748
|
+
steps: 30,
|
|
749
|
+
});
|
|
750
|
+
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
751
|
+
|
|
752
|
+
// Finalise the sensor polygon
|
|
753
|
+
await page.mouse.move(mapDiv.width * 0.3, mapDiv.height / 1.25);
|
|
754
|
+
await page.mouse.click(mapDiv.width * 0.3, mapDiv.height / 1.25);
|
|
755
|
+
|
|
756
|
+
await expectPaths({ page, count: 1 });
|
|
757
|
+
|
|
758
|
+
await expectPathDimensions({ page, width: 183, height: 233 });
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
test("mode can set and used to create a sensor more than 90 degrees (anticlockwise)", async ({
|
|
762
|
+
page,
|
|
763
|
+
}) => {
|
|
764
|
+
const mapDiv = await setupMap({ page });
|
|
765
|
+
await changeMode({ page, mode });
|
|
766
|
+
|
|
767
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
768
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
769
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
770
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
771
|
+
steps: 30,
|
|
772
|
+
});
|
|
773
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.5);
|
|
774
|
+
|
|
775
|
+
// Finalise the sensor polygon
|
|
776
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.3);
|
|
777
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.3);
|
|
778
|
+
|
|
779
|
+
await expectPathDimensions({ page, width: 728, height: 378 });
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
test("mode can set and used to create a sensor more than 180 degrees (anticlockwise)", async ({
|
|
783
|
+
page,
|
|
784
|
+
}) => {
|
|
785
|
+
const mapDiv = await setupMap({ page });
|
|
786
|
+
await changeMode({ page, mode });
|
|
787
|
+
|
|
788
|
+
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
789
|
+
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
790
|
+
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
791
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
792
|
+
steps: 30,
|
|
793
|
+
});
|
|
794
|
+
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
795
|
+
steps: 30,
|
|
796
|
+
});
|
|
797
|
+
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
|
|
798
|
+
|
|
799
|
+
// Finalise the sensor polygon
|
|
800
|
+
await page.mouse.move(mapDiv.width * 0.8, mapDiv.height / 3, { steps: 30 });
|
|
801
|
+
await page.mouse.click(mapDiv.width * 0.8, mapDiv.height / 3);
|
|
802
|
+
|
|
803
|
+
await expectPaths({ page, count: 1 });
|
|
804
|
+
|
|
805
|
+
await expectPathDimensions({ page, width: 808, height: 547 });
|
|
806
|
+
});
|
|
807
|
+
});
|
|
808
|
+
|
|
413
809
|
test.describe("circle mode", () => {
|
|
414
810
|
const mode = "circle";
|
|
415
811
|
|
|
416
|
-
test("mode can set and
|
|
812
|
+
test("mode can set and used to create a web mercator circle", async ({
|
|
417
813
|
page,
|
|
418
814
|
}) => {
|
|
419
815
|
const mapDiv = await setupMap({ page });
|
|
@@ -428,7 +824,7 @@ test.describe("circle mode", () => {
|
|
|
428
824
|
await expectPathDimensions({ page, width: 146, height: 146 });
|
|
429
825
|
});
|
|
430
826
|
|
|
431
|
-
test("mode can set and
|
|
827
|
+
test("mode can set and used to create a geodesic circle", async ({
|
|
432
828
|
page,
|
|
433
829
|
}) => {
|
|
434
830
|
const mapDiv = await setupMap({ page, configQueryParam: ["globeCircle"] });
|