Skip to content

Commit

Permalink
Use new route/area tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Nov 25, 2024
1 parent e9d9b40 commit 0d4e4e8
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 104 deletions.
60 changes: 10 additions & 50 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion src/lib/browse/layers/points/UserData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@

<div slot="controls" style="border: 1px solid black; padding: 8px;">
<FileInput label="Load your own GeoJSON file" onLoad={loadFile} />
<p><i>Note this file doesn't leave your computer; it's not uploaded anywhere</i></p>
<p>
<i>
Note this file doesn't leave your computer; it's not uploaded anywhere
</i>
</p>
<p>Currently showing {data.features.length.toLocaleString()} features</p>
</div>
</LayerControl>
Expand Down
8 changes: 0 additions & 8 deletions src/lib/maplibre/zorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,8 @@ export let layerZorder = [
// Problem points are one layer that should display on top of scheme data
browse("problems"),

sketch("edit-polygon-fill"),
sketch("edit-polygon-lines"),
sketch("edit-polygon-vertices"),

sketch("draw-split-route"),

sketch("route-points"),
sketch("route-lines"),
sketch("route-polygons"),

// Draw most things beneath text road labels. These IDs come from the
// MapTiler basemap, and there are different ones for each basemap. Note for
// OS raster basemaps, we draw everything on top of the rasters.
Expand Down
7 changes: 6 additions & 1 deletion src/pages/LandingPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@
<DefaultButton on:click={goToBrowser}>Start</DefaultButton>

<h3>Accessibility</h3>
<p>Our accessibility statement can be found <a href="accessibility.html">here</a>.</p>
<p>
Our accessibility statement can be found <a href="accessibility.html">
here
</a>
.
</p>
</div>
6 changes: 1 addition & 5 deletions src/pages/SketchSchemes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
BoundaryLayer,
ImageLayer,
InterventionLayer,
PolygonToolLayer,
RouteSnapperLayer,
Toolbox,
NewFeatureForm,
} from "scheme-sketcher-lib/draw";
Expand Down Expand Up @@ -107,7 +105,7 @@

{#if $mode.mode == "list" || $mode.mode == "split-route" || $mode.mode == "set-image" || $mode.mode == "streetview"}
<ListMode {cfg} {gjSchemes} />
{:else if $mode.mode == "new-point" || $mode.mode == "new-freehand-polygon" || $mode.mode == "new-snapped-polygon" || $mode.mode == "new-route"}
{:else if $mode.mode == "new-point" || $mode.mode == "new-area" || $mode.mode == "new-route"}
<NewFeatureForm {cfg} {gjSchemes} />
{:else if $mode.mode == "edit"}
<EditFeatureForm {cfg} {gjSchemes} id={$mode.id} />
Expand All @@ -125,8 +123,6 @@
<InterventionLayer {cfg} {gjSchemes} />
<ImageLayer {cfg} />
<Toolbox {cfg} {gjSchemes} {routeSnapperUrl} />
<RouteSnapperLayer {cfg} />
<PolygonToolLayer {cfg} />
{/if}
</MapLibreMap>
</div>
Expand Down
20 changes: 2 additions & 18 deletions tests/edits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ test.beforeEach(async ({ page }) => {
await resetSketch(page);
});

test("edit a freehand area, then cancel", async ({ page }) => {
await page.getByRole("button", { name: "New area (freehand)" }).click();
test("edit an area, then cancel", async ({ page }) => {
await page.getByRole("button", { name: "New area" }).click();
await clickMap(page, 500, 500);
await clickMap(page, 400, 500);
await clickMap(page, 400, 600);
Expand All @@ -21,22 +21,6 @@ test("edit a freehand area, then cancel", async ({ page }) => {
await expectListMode(page);
});

test("edit a snapped area, then cancel", async ({ page }) => {
await page.getByRole("button", { name: "New area (snapped)" }).click();
await clickMap(page, 500, 500);
await clickMap(page, 400, 500);
await clickMap(page, 400, 600);
await page.getByRole("button", { name: "Finish" }).click();

await page.getByRole("link", { name: "Untitled area" }).click();
await clickMap(page, 430, 515);
// This button indicates the mode is working
await expect(page.getByRole("button", { name: "Cancel" })).toBeVisible();

await page.keyboard.down("Escape");
await expectListMode(page);
});

// TODO Edit each type of object without saving, and verify the edits are
// retained. Or cancel and make sure they're reverted. (How to test for
// geometry changes?)
Expand Down
28 changes: 7 additions & 21 deletions tests/modes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ test("creating a new point opens a form", async ({ page }) => {
await page.getByRole("link", { name: "Point name" }).click();
});

test("creating a new freehand area opens a form", async ({ page }) => {
await page.getByRole("button", { name: "New area (freehand)" }).click();
test("creating a new area opens a form", async ({ page }) => {
await page.getByRole("button", { name: "New area" }).click();
await page.getByLabel("Name").fill("Area name");
await page.getByLabel("Description").click();

Expand All @@ -28,10 +28,10 @@ test("creating a new freehand area opens a form", async ({ page }) => {
await page.getByRole("link", { name: "Area name" }).click();
});

test("creating a new freehand area and canceling doesn't save anything", async ({
test("creating a new area and canceling doesn't save anything", async ({
page,
}) => {
await page.getByRole("button", { name: "New area (freehand)" }).click();
await page.getByRole("button", { name: "New area" }).click();
await clickMap(page, 500, 500);
await clickMap(page, 400, 500);
await clickMap(page, 400, 600);
Expand All @@ -44,19 +44,6 @@ test("creating a new freehand area and canceling doesn't save anything", async (

// TODO Repeat canceling for other draw tools

test("creating a new snapped area opens a form", async ({ page }) => {
await page.getByRole("button", { name: "New area (snapped)" }).click();
await page.getByLabel("Name").fill("Area name");
await page.getByLabel("Description").click();

await clickMap(page, 500, 500);
await clickMap(page, 400, 500);
await clickMap(page, 400, 600);
await page.getByRole("button", { name: "Finish" }).click();

await page.getByRole("link", { name: "Area name" }).click();
});

test("creating a new route opens a form, and auto-fill sets its name", async ({
page,
}) => {
Expand All @@ -83,9 +70,9 @@ test("creating a new route opens a form, and auto-fill sets its name", async ({
).toBeVisible();
});

test("editing geometry of a area works", async ({ page }) => {
test("editing geometry of an area works", async ({ page }) => {
// Create an area
await page.getByRole("button", { name: "New area (snapped)" }).click();
await page.getByRole("button", { name: "New area" }).click();
await clickMap(page, 241, 509);
await clickMap(page, 235, 431);
await clickMap(page, 465, 459);
Expand Down Expand Up @@ -135,8 +122,7 @@ test("escape key works from every mode", async ({ page }) => {
// From each tool, make sure escape goes back to list mode
for (let mode of [
"New point",
"New area (freehand)",
"New area (snapped)",
"New area",
"New route",
"Split route",
"StreetView",
Expand Down

0 comments on commit 0d4e4e8

Please sign in to comment.