Release Geo Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 12:02:09 +02:00
parent 2acdb66399
commit 3538e4e12b
29 changed files with 1352 additions and 172 deletions
+33 -1
View File
@@ -44,6 +44,38 @@ test("parses coordinate CSV and updates the local analysis", async ({
expect(external).toEqual([]);
});
test("edits full-feature geometry, inventories tracks and measures locally", async ({
page,
}) => {
await page.goto("/deep/nested/geo/");
await expect(
page.getByRole("heading", { name: "Track inventory" }),
).toBeVisible();
await expect(
page
.getByRole("region", { name: "Track inventory" })
.getByText("Berlin walk", { exact: true }),
).toBeVisible();
await page.getByLabel("Editable GeoJSON feature").fill(
JSON.stringify({
type: "Feature",
properties: { name: "Edited point" },
geometry: { type: "Point", coordinates: [7.1, 50.7] },
}),
);
await page.getByRole("button", { name: "Apply feature edit" }).click();
const featurePicker = page
.getByRole("region", { name: "Edit any GeoJSON feature" })
.getByRole("combobox");
await expect(featurePicker.locator("option:checked")).toHaveText(
"1: Edited point",
);
await page.getByLabel("Start longitude,latitude[,elevation]").fill("0,0");
await page.getByLabel("End longitude,latitude[,elevation]").fill("1,0");
await expect(page.getByText(/111195/)).toBeVisible();
await expect(page.getByText("90.00°")).toBeVisible();
});
test("serves the release identity and hardened headers", async ({
request,
}) => {
@@ -56,7 +88,7 @@ test("serves the release identity and hardened headers", async ({
const manifest = await request.get("/deep/nested/geo/toolbox-app.json");
await expect(manifest.json()).resolves.toMatchObject({
id: "de.add-ideas.geo-tools",
version: "0.1.0",
version: "0.2.0",
entry: "./",
});
});
+18
View File
@@ -0,0 +1,18 @@
import { expect, test } from "@playwright/test";
test("keeps the primary workspace inside a narrow viewport", async ({
page,
}) => {
await page.goto("/deep/nested/geo/");
await expect(page.locator("main").first()).toBeVisible();
await expect(
page.locator("main .loading, main .workbench-loading"),
).toHaveCount(0);
const widths = await page.evaluate(() => ({
content: document.documentElement.scrollWidth,
viewport: document.documentElement.clientWidth,
}));
expect(widths.viewport).toBeLessThanOrEqual(430);
expect(widths.content).toBeLessThanOrEqual(widths.viewport + 1);
});
+155
View File
@@ -5,6 +5,15 @@ import {
simplifyLine,
toDms,
} from "../../src/geo/analysis";
import {
appendFeature,
listPositionReferences,
measureSegment,
replaceFeature,
reverseFeatureTracks,
summarizeTracks,
updatePosition,
} from "../../src/geo/editor";
import {
parseCoordinateCsv,
parseGeoJson,
@@ -33,6 +42,70 @@ describe("geospatial formats", () => {
parseGeoJson(serializeGeo(result.collection, "geojson").text).collection,
).toEqual(result.collection);
});
it("preserves every GeoJSON multi geometry and bounded collections", () => {
const result = parseGeoJson(
JSON.stringify({
type: "Feature",
properties: { name: "Mixed" },
geometry: {
type: "GeometryCollection",
geometries: [
{
type: "MultiPoint",
coordinates: [
[1, 2],
[3, 4],
],
},
{
type: "MultiLineString",
coordinates: [
[
[0, 0],
[1, 0],
],
[
[2, 0],
[3, 0],
],
],
},
{
type: "MultiPolygon",
coordinates: [
[
[
[0, 0],
[1, 0],
[0, 0],
],
],
],
},
],
},
}),
);
expect(
parseGeoJson(serializeGeo(result.collection, "geojson").text).collection,
).toEqual(result.collection);
expect(analyseCollection(result.collection)).toMatchObject({
points: 9,
features: 1,
});
expect(serializeGeo(result.collection, "kml").text).toContain(
"<MultiGeometry>",
);
expect(serializeGeo(result.collection, "gpx").text).toContain("<trkseg>");
});
it("bounds nested GeometryCollections", () => {
let geometry: unknown = { type: "Point", coordinates: [0, 0] };
for (let index = 0; index < 18; index += 1)
geometry = { type: "GeometryCollection", geometries: [geometry] };
expect(() => parseGeoJson(JSON.stringify(geometry))).toThrow(
/nesting limit/iu,
);
});
});
describe("geospatial analysis", () => {
@@ -74,3 +147,85 @@ describe("geospatial analysis", () => {
it("formats directional DMS", () =>
expect(toDms(-13.5, "longitude")).toBe("13° 30 0.000″ W"));
});
describe("bounded geometry editing and local measurement", () => {
const mixed = parseGeoJson(
JSON.stringify({
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: { name: "Track" },
geometry: {
type: "GeometryCollection",
geometries: [
{ type: "Point", coordinates: [13, 52] },
{
type: "MultiLineString",
coordinates: [
[
[13, 52, 10],
[13.01, 52, 20],
],
],
},
],
},
},
],
}),
).collection;
it("addresses and updates coordinates inside GeometryCollections", () => {
const references = listPositionReferences(mixed);
expect(references).toHaveLength(3);
const updated = updatePosition(mixed, references[2]!, [14, 53, 25]);
expect(listPositionReferences(updated)[2]?.position).toEqual([14, 53, 25]);
expect(listPositionReferences(mixed)[2]?.position).toEqual([13.01, 52, 20]);
});
it("replaces/appends full geometry features and reverses only tracks", () => {
const reversed = reverseFeatureTracks(mixed, 0);
expect(
listPositionReferences(reversed).map((item) => item.position),
).toEqual([
[13, 52],
[13.01, 52, 20],
[13, 52, 10],
]);
expect(summarizeTracks(reversed)[0]).toMatchObject({
pathCount: 1,
positions: 2,
hasElevation: true,
});
const replacement = {
type: "Feature",
properties: { name: "Area" },
geometry: {
type: "MultiPolygon",
coordinates: [
[
[
[0, 0],
[1, 0],
[0, 0],
],
],
],
},
};
expect(
replaceFeature(mixed, 0, replacement).features[0]?.geometry.type,
).toBe("MultiPolygon");
expect(appendFeature(mixed, replacement).features).toHaveLength(2);
});
it("measures a bounded great-circle segment and bearing", () => {
const result = measureSegment([0, 0], [1, 0]);
expect(result.distanceMetres).toBeCloseTo(111_195, -1);
expect(result.initialBearingDegrees).toBeCloseTo(90);
expect(result.midpoint).toEqual([0.5, 0]);
expect(measureSegment([179, 0], [-179, 0]).midpoint[0]).toBeCloseTo(-180);
expect(() => measureSegment([0, 0], [180, 0])).toThrow(/antipodal/u);
});
});