Skip to content

Commit

Permalink
Make web settings not produce invalid numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jun 14, 2024
1 parent ea225ac commit db19623
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion web/src/OptionalNumber.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
export let label: string;
export let value: number | undefined;
export let defaultNumber: number;
// Use both as step size and minimum
export let step: number;
let checked = value != undefined;
Expand All @@ -16,5 +18,5 @@
<input type="checkbox" bind:checked />
{label}

<input type="number" bind:value disabled={!checked} />
<input type="number" bind:value disabled={!checked} {step} min={step} />
</label>
12 changes: 11 additions & 1 deletion web/src/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
label="Remove holes in input polygons larger than this area (sq m)"
bind:value={cfg.remove_holes}
defaultNumber={100}
step={1}
/>

<div>
Expand All @@ -24,6 +25,7 @@
label="Filter skeleton lines closer than this to the boundary (m)"
bind:value={cfg.filter_skeletons_near_boundary}
defaultNumber={0.1}
step={1}
/>

<div>
Expand All @@ -37,24 +39,32 @@
label="Remove short skeleton lines less than this ratio (to the longest)"
bind:value={cfg.remove_short_skeletons}
defaultNumber={0.1}
step={0.1}
/>

<OptionalNumber
label="Generate perpendicular lines at this step size (m)"
bind:value={cfg.make_perps_step_size}
defaultNumber={5.0}
step={0.5}
/>

<OptionalNumber
label="If the ratio of lengths between each 'half' of a perpendicular line is less than this, skip it"
bind:value={cfg.perp_midpoint_ratio}
defaultNumber={0.5}
step={0.1}
/>

<div>
<label>
Granularity of width (m) in center lines
<input type="number" bind:value={cfg.width_granularity} />
<input
type="number"
bind:value={cfg.width_granularity}
min="0.1"
step="0.1"
/>
</label>
</div>
</details>
Expand Down

0 comments on commit db19623

Please sign in to comment.