Skip to content

Commit

Permalink
fix: ensure that closingPoint property exists on closingPoint of free…
Browse files Browse the repository at this point in the history
…hand mode (#373)
  • Loading branch information
JamesLMilner authored Dec 2, 2024
1 parent 8520e24 commit f5c5953
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/modes/freehand/freehand.mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ describe("TerraDrawFreehandMode", () => {
[expect.any(String), expect.any(String)],
"create",
);

const features = store.copyAll();
expect(features.length).toBe(2);
expect(features[0].geometry.type).toBe("Polygon");
expect(features[1].geometry.type).toBe("Point");
expect(features[1].properties.closingPoint).toBe(true);
});

it("finishes drawing polygon on second click", () => {
Expand Down
6 changes: 5 additions & 1 deletion src/modes/freehand/freehand.mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
NumericStyling,
Cursor,
UpdateTypes,
POLYGON_PROPERTIES,
} from "../../common";
import { Polygon } from "geojson";

Expand Down Expand Up @@ -258,7 +259,10 @@ export class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<FreehandPolygon
type: "Point",
coordinates: [event.lng, event.lat],
},
properties: { mode: this.mode },
properties: {
mode: this.mode,
[POLYGON_PROPERTIES.CLOSING_POINT]: true,
},
},
]);

Expand Down

0 comments on commit f5c5953

Please sign in to comment.