Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: format handler for multiple geometry types and formats #1276

Merged
merged 31 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
180306b
feat: added initial bounding box format handler for jsonform
santilland Sep 25, 2024
c5d7aaf
feat: add polygons and editors
A-Behairi Oct 9, 2024
2dfe5c7
chore: cleanup
A-Behairi Oct 9, 2024
5e46728
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Oct 10, 2024
1725bff
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Oct 22, 2024
7f3a774
feat: selection input + adjusted returned values accordingly
A-Behairi Oct 22, 2024
6bf7375
fix: feature selection story & renamed drawtool to bbox
A-Behairi Oct 22, 2024
ca762fa
chore: format
A-Behairi Oct 22, 2024
e20e4ec
fix: lint & tests
A-Behairi Oct 22, 2024
2614e1c
fix: spread features
A-Behairi Oct 25, 2024
e3f7a60
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Oct 29, 2024
029e3fa
feat: type spatial custom validator
A-Behairi Oct 31, 2024
5b6afce
chore: update collection schema
A-Behairi Nov 7, 2024
c706f7f
test: render drawtools on type spatial
A-Behairi Nov 7, 2024
44cec24
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Nov 7, 2024
512e2d0
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Nov 7, 2024
cf8599b
feat: add projection option
A-Behairi Nov 7, 2024
c291d3e
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Nov 7, 2024
8985256
test: projection
A-Behairi Nov 7, 2024
1d9f22a
fix: auto start drawing
A-Behairi Nov 22, 2024
f7902b1
fix: remove `*-editor` formats
A-Behairi Nov 22, 2024
ddf3459
fix: update editors types & adapt the validator and stories
A-Behairi Nov 22, 2024
ac976e7
feat: support format point/points
A-Behairi Nov 26, 2024
1668a63
Merge remote-tracking branch 'origin/main' into jsonform/feature/draw…
A-Behairi Nov 27, 2024
4af41c0
feat: support wkt and geojson types and handle their validations
A-Behairi Nov 27, 2024
33e2c36
chore: update stories and clean up
A-Behairi Nov 27, 2024
8f7d8ea
test: adjust tests
A-Behairi Nov 27, 2024
09e5f5e
fix: return a feature for single formats and feature collection for p…
A-Behairi Nov 29, 2024
76f93d5
feat: support line/lines format
A-Behairi Nov 29, 2024
c6abbd9
fix: discard drawing on destroy
A-Behairi Dec 2, 2024
3af6909
fix: adjust collection schema and format
A-Behairi Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions elements/jsonform/src/custom-inputs/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { JSONEditor } from "@json-editor/json-editor/src/core.js";
import { MinMaxEditor } from "./minmax";
import { SpatialEditor, spatialValidatorCreator } from "./spatial";

// Define custom input types
const inputs = [
Expand All @@ -8,6 +9,145 @@ const inputs = [
format: "minmax",
func: MinMaxEditor,
},
{
type: "array",
format: "bounding-boxes",
func: SpatialEditor,
},
{
type: "wkt",
format: "bounding-boxes",
func: SpatialEditor,
},
{
type: "geojson",
format: "bounding-boxes",
func: SpatialEditor,
},
{
type: "array",
format: "bounding-box",
func: SpatialEditor,
},
{
type: "wkt",
format: "bounding-box",
func: SpatialEditor,
},
{
type: "geojson",
format: "bounding-box",
func: SpatialEditor,
},
{
type: "array",
format: "polygons",
func: SpatialEditor,
},
{
type: "wkt",
format: "polygons",
func: SpatialEditor,
},
{
type: "geojson",
format: "polygons",
func: SpatialEditor,
},
{
type: "object",
format: "polygon",
func: SpatialEditor,
},
{
type: "wkt",
format: "polygon",
func: SpatialEditor,
},
{
type: "geojson",
format: "polygon",
func: SpatialEditor,
},
{
type: "array",
format: "points",
func: SpatialEditor,
},
{
type: "wkt",
format: "points",
func: SpatialEditor,
},
{
type: "geojson",
format: "points",
func: SpatialEditor,
},
{
type: "array",
format: "point",
func: SpatialEditor,
},
{
type: "wkt",
format: "point",
func: SpatialEditor,
},
{
type: "geojson",
format: "point",
func: SpatialEditor,
},
{
format: "feature",
func: SpatialEditor,
},
{
type: "array",
format: "features",
func: SpatialEditor,
},
{
type: "wkt",
format: "features",
func: SpatialEditor,
},
{
type: "geojson",
format: "features",
func: SpatialEditor,
},
{
type: "array",
format: "line",
func: SpatialEditor,
},
{
type: "wkt",
format: "line",
func: SpatialEditor,
},
{
type: "geojson",
format: "line",
func: SpatialEditor,
},
{
type: "array",
format: "lines",
func: SpatialEditor,
},
{
type: "wkt",
format: "lines",
func: SpatialEditor,
},
{
type: "geojson",
format: "lines",
func: SpatialEditor,
},
];

/**
Expand All @@ -16,6 +156,11 @@ const inputs = [
* @param {{[key: string]: any}} startVals - Initial values for the custom inputs
*/
export const addCustomInputs = (startVals) => {
// Add custom validators for spatial inputs
JSONEditor.defaults["custom_validators"].push(
spatialValidatorCreator(inputs),
);

// Iterate over each custom input definition
inputs.map(({ type, format, func }) => {
JSONEditor.defaults["startVals"] = startVals;
Expand All @@ -24,6 +169,8 @@ export const addCustomInputs = (startVals) => {
// Add a resolver to determine which format to use based on the schema
JSONEditor.defaults.resolvers.unshift((schema) => {
if (schema.type === type && schema.format === format) return format;
// If the schema format is "feature" use the SpatialEditor for all types
if (schema.format === "feature") return format;
});
});
};
Expand Down
Loading
Loading