@honua/react 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/columnar/apache-arrow.d.ts +17 -0
- package/columnar/apache-arrow.d.ts.map +1 -0
- package/columnar/apache-arrow.js +1036 -0
- package/columnar/batch-cache-conformance.d.ts +66 -0
- package/columnar/batch-cache-conformance.d.ts.map +1 -0
- package/columnar/batch-cache-conformance.js +317 -0
- package/columnar/batch-cache-indexeddb.d.ts +31 -0
- package/columnar/batch-cache-indexeddb.d.ts.map +1 -0
- package/columnar/batch-cache-indexeddb.js +148 -0
- package/columnar/batch-cache.d.ts +298 -0
- package/columnar/batch-cache.d.ts.map +1 -0
- package/columnar/batch-cache.js +757 -0
- package/columnar/geoarrow-aggregate.d.ts +178 -0
- package/columnar/geoarrow-aggregate.d.ts.map +1 -0
- package/columnar/geoarrow-aggregate.js +976 -0
- package/columnar/geoarrow-patch.d.ts +382 -0
- package/columnar/geoarrow-patch.d.ts.map +1 -0
- package/columnar/geoarrow-patch.js +1656 -0
- package/columnar/geoarrow-reproject.d.ts +22 -0
- package/columnar/geoarrow-reproject.d.ts.map +1 -0
- package/columnar/geoarrow-reproject.js +119 -0
- package/columnar/geoarrow-serialization.d.ts +68 -0
- package/columnar/geoarrow-serialization.d.ts.map +1 -0
- package/columnar/geoarrow-serialization.js +331 -0
- package/columnar/geoarrow-types.d.ts +271 -0
- package/columnar/geoarrow-types.d.ts.map +1 -0
- package/columnar/geoarrow-types.js +15 -0
- package/columnar/geoarrow.d.ts +52 -0
- package/columnar/geoarrow.d.ts.map +1 -0
- package/columnar/geoarrow.js +1469 -0
- package/columnar/index.d.ts +43 -0
- package/columnar/index.d.ts.map +1 -0
- package/columnar/index.js +29 -0
- package/columnar/operators.d.ts +70 -0
- package/columnar/operators.d.ts.map +1 -0
- package/columnar/operators.js +307 -0
- package/columnar/result.d.ts +369 -0
- package/columnar/result.d.ts.map +1 -0
- package/columnar/result.js +815 -0
- package/columnar/telemetry.d.ts +152 -0
- package/columnar/telemetry.d.ts.map +1 -0
- package/columnar/telemetry.js +265 -0
- package/columnar/transfer.d.ts +28 -0
- package/columnar/transfer.d.ts.map +1 -0
- package/columnar/transfer.js +669 -0
- package/columnar/types.d.ts +175 -0
- package/columnar/types.d.ts.map +1 -0
- package/columnar/types.js +22 -0
- package/columnar/worker.d.ts +157 -0
- package/columnar/worker.d.ts.map +1 -0
- package/columnar/worker.js +1059 -0
- package/connect-url-safety.d.ts +53 -0
- package/connect-url-safety.js +189 -0
- package/contract/pmtiles.d.ts +6 -5
- package/contract/pmtiles.d.ts.map +1 -1
- package/contract/pmtiles.js +30 -5
- package/contract/source.d.ts.map +1 -1
- package/contract/source.js +11 -8
- package/core/client.d.ts.map +1 -1
- package/core/client.js +87 -19
- package/core/deprecation-notice.d.ts +28 -0
- package/core/deprecation-notice.d.ts.map +1 -0
- package/core/deprecation-notice.js +22 -0
- package/core/esri-geojson.d.ts.map +1 -1
- package/core/esri-geojson.js +14 -8
- package/core/optional-grpc-peer.d.ts +15 -0
- package/core/optional-grpc-peer.d.ts.map +1 -0
- package/core/optional-grpc-peer.js +60 -0
- package/esri-compat/basemap-gallery.d.ts +2 -0
- package/esri-compat/basemap-gallery.d.ts.map +1 -1
- package/esri-compat/basemap-gallery.js +12 -0
- package/esri-compat/basemap.d.ts +4 -0
- package/esri-compat/basemap.d.ts.map +1 -1
- package/esri-compat/basemap.js +70 -0
- package/esri-compat/bookmarks.d.ts +2 -0
- package/esri-compat/bookmarks.d.ts.map +1 -1
- package/esri-compat/bookmarks.js +12 -0
- package/esri-compat/controls.d.ts +18 -0
- package/esri-compat/controls.d.ts.map +1 -1
- package/esri-compat/controls.js +120 -57
- package/esri-compat/directions.d.ts +4 -0
- package/esri-compat/directions.d.ts.map +1 -1
- package/esri-compat/directions.js +30 -20
- package/esri-compat/editor.d.ts +4 -0
- package/esri-compat/editor.d.ts.map +1 -1
- package/esri-compat/editor.js +16 -0
- package/esri-compat/esri-config.d.ts +2 -1
- package/esri-compat/esri-config.d.ts.map +1 -1
- package/esri-compat/feature-effect.d.ts +23 -0
- package/esri-compat/feature-effect.d.ts.map +1 -0
- package/esri-compat/feature-effect.js +12 -0
- package/esri-compat/feature-form.d.ts +6 -0
- package/esri-compat/feature-form.d.ts.map +1 -1
- package/esri-compat/feature-form.js +63 -0
- package/esri-compat/feature-layer.d.ts +21 -2
- package/esri-compat/feature-layer.d.ts.map +1 -1
- package/esri-compat/feature-layer.js +172 -1
- package/esri-compat/feature-table.d.ts +5 -0
- package/esri-compat/feature-table.d.ts.map +1 -1
- package/esri-compat/feature-table.js +23 -0
- package/esri-compat/identity-manager.d.ts +1 -1
- package/esri-compat/identity-manager.js +1 -1
- package/esri-compat/legend.d.ts +2 -0
- package/esri-compat/legend.d.ts.map +1 -1
- package/esri-compat/legend.js +98 -0
- package/esri-compat/locator.d.ts +1 -1
- package/esri-compat/locator.js +1 -1
- package/esri-compat/map-view-mount.d.ts +1 -0
- package/esri-compat/map-view-mount.d.ts.map +1 -1
- package/esri-compat/map-view-mount.js +46 -25
- package/esri-compat/map-view.d.ts +13 -0
- package/esri-compat/map-view.d.ts.map +1 -1
- package/esri-compat/map-view.js +94 -8
- package/esri-compat/map.d.ts +5 -1
- package/esri-compat/map.d.ts.map +1 -1
- package/esri-compat/map.js +10 -0
- package/esri-compat/measurement.d.ts +2 -0
- package/esri-compat/measurement.d.ts.map +1 -1
- package/esri-compat/measurement.js +14 -0
- package/esri-compat/point.d.ts +7 -0
- package/esri-compat/point.d.ts.map +1 -1
- package/esri-compat/point.js +33 -3
- package/esri-compat/popup.d.ts +2 -0
- package/esri-compat/popup.d.ts.map +1 -1
- package/esri-compat/popup.js +12 -0
- package/esri-compat/portal.d.ts +1 -1
- package/esri-compat/portal.js +1 -1
- package/esri-compat/print.d.ts +3 -0
- package/esri-compat/print.d.ts.map +1 -1
- package/esri-compat/print.js +15 -0
- package/esri-compat/search.d.ts +4 -0
- package/esri-compat/search.d.ts.map +1 -1
- package/esri-compat/search.js +25 -28
- package/esri-compat/sketch.d.ts +2 -0
- package/esri-compat/sketch.d.ts.map +1 -1
- package/esri-compat/sketch.js +12 -0
- package/esri-compat/widget-host.d.ts +46 -17
- package/esri-compat/widget-host.d.ts.map +1 -1
- package/esri-compat/widget-host.js +84 -20
- package/esri-compat/widget-shell-hosts.d.ts +61 -0
- package/esri-compat/widget-shell-hosts.d.ts.map +1 -0
- package/esri-compat/widget-shell-hosts.js +76 -0
- package/geocoding/index.d.ts +114 -0
- package/geocoding/index.d.ts.map +1 -0
- package/geocoding/index.js +293 -0
- package/geocoding/provider-http.d.ts +37 -0
- package/geocoding/provider-http.d.ts.map +1 -0
- package/geocoding/provider-http.js +93 -0
- package/geocoding/provider.d.ts +145 -0
- package/geocoding/provider.d.ts.map +1 -0
- package/geocoding/provider.js +41 -0
- package/geocoding/providers/honua.d.ts +28 -0
- package/geocoding/providers/honua.d.ts.map +1 -0
- package/geocoding/providers/honua.js +68 -0
- package/geocoding/providers/nominatim.d.ts +47 -0
- package/geocoding/providers/nominatim.d.ts.map +1 -0
- package/geocoding/providers/nominatim.js +105 -0
- package/geocoding/providers/pelias.d.ts +40 -0
- package/geocoding/providers/pelias.d.ts.map +1 -0
- package/geocoding/providers/pelias.js +115 -0
- package/geocoding/providers/photon.d.ts +39 -0
- package/geocoding/providers/photon.d.ts.map +1 -0
- package/geocoding/providers/photon.js +107 -0
- package/geometry/convert.d.ts +13 -0
- package/geometry/convert.d.ts.map +1 -0
- package/geometry/convert.js +12 -0
- package/geometry/index.d.ts +17 -0
- package/geometry/index.d.ts.map +1 -0
- package/geometry/index.js +15 -0
- package/geometry/internal.d.ts +25 -0
- package/geometry/internal.d.ts.map +1 -0
- package/geometry/internal.js +40 -0
- package/geometry/ops.d.ts +71 -0
- package/geometry/ops.d.ts.map +1 -0
- package/geometry/ops.js +147 -0
- package/geometry/project.d.ts +40 -0
- package/geometry/project.d.ts.map +1 -0
- package/geometry/project.js +88 -0
- package/geometry/types.d.ts +36 -0
- package/geometry/types.d.ts.map +1 -0
- package/geometry/types.js +12 -0
- package/kernel/renderer.d.ts +82 -0
- package/kernel/renderer.js +1 -0
- package/offline/digest.d.ts +15 -0
- package/offline/digest.js +58 -0
- package/offline/quota.d.ts +161 -0
- package/offline/quota.js +370 -0
- package/offline/types.d.ts +349 -0
- package/offline/types.js +75 -0
- package/package.json +14 -2
- package/realtime/odata-delta.d.ts +1 -1
- package/realtime/odata-delta.d.ts.map +1 -1
- package/realtime/odata-delta.js +38 -10
- package/widget-capabilities.d.ts +67 -0
- package/widget-capabilities.js +152 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers behind sketch snapping, histogram bins, form expressions,
|
|
3
|
+
* multi-feature edits, and elevation samples.
|
|
4
|
+
*/
|
|
5
|
+
export function snapVertex(pointer, vertices, enabled, tolerance = 1) {
|
|
6
|
+
if (!enabled || vertices.length === 0)
|
|
7
|
+
return { ...pointer };
|
|
8
|
+
let nearest = vertices[0];
|
|
9
|
+
let nearestDistance = distance(pointer, nearest);
|
|
10
|
+
for (const vertex of vertices.slice(1)) {
|
|
11
|
+
const candidate = distance(pointer, vertex);
|
|
12
|
+
if (candidate < nearestDistance) {
|
|
13
|
+
nearest = vertex;
|
|
14
|
+
nearestDistance = candidate;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return nearestDistance <= tolerance ? { x: nearest.x, y: nearest.y } : { ...pointer };
|
|
18
|
+
}
|
|
19
|
+
function distance(a, b) {
|
|
20
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
21
|
+
}
|
|
22
|
+
export function histogramBins(values, stats, classes, method) {
|
|
23
|
+
if (classes < 1)
|
|
24
|
+
throw new Error("histogram classes must be at least 1");
|
|
25
|
+
assertStats(values, stats);
|
|
26
|
+
const breaks = method === "quantile" ? quantileEdges(values, classes) : equalIntervalEdges(stats.min, stats.max, classes);
|
|
27
|
+
const bins = [];
|
|
28
|
+
for (let index = 0; index < breaks.length - 1; index += 1) {
|
|
29
|
+
const min = breaks[index] ?? stats.min;
|
|
30
|
+
const max = breaks[index + 1] ?? stats.max;
|
|
31
|
+
const last = index === breaks.length - 2;
|
|
32
|
+
const value = values.filter((item) => (last ? item >= min && item <= max : item >= min && item < max)).length;
|
|
33
|
+
bins.push({ label: `${min}–${max}`, min, max, value });
|
|
34
|
+
}
|
|
35
|
+
return bins;
|
|
36
|
+
}
|
|
37
|
+
export function histogramRangeFilter(min, max) {
|
|
38
|
+
return `value >= ${min} AND value <= ${max}`;
|
|
39
|
+
}
|
|
40
|
+
function assertStats(values, stats) {
|
|
41
|
+
const count = values.length;
|
|
42
|
+
const sum = values.reduce((total, value) => total + value, 0);
|
|
43
|
+
const min = values.length === 0 ? Number.NaN : Math.min(...values);
|
|
44
|
+
const max = values.length === 0 ? Number.NaN : Math.max(...values);
|
|
45
|
+
const average = count === 0 ? Number.NaN : sum / count;
|
|
46
|
+
if (stats.count !== count ||
|
|
47
|
+
stats.sum !== sum ||
|
|
48
|
+
stats.min !== min ||
|
|
49
|
+
stats.max !== max ||
|
|
50
|
+
stats.average !== average) {
|
|
51
|
+
throw new Error("histogram statistics do not match the feature values");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function equalIntervalEdges(min, max, classes) {
|
|
55
|
+
const width = classes === 0 ? 0 : (max - min) / classes;
|
|
56
|
+
return Array.from({ length: classes + 1 }, (_, index) => min + width * index);
|
|
57
|
+
}
|
|
58
|
+
function quantileEdges(values, classes) {
|
|
59
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
60
|
+
if (sorted.length === 0)
|
|
61
|
+
return [0, 0];
|
|
62
|
+
const edges = [sorted[0] ?? 0];
|
|
63
|
+
for (let index = 1; index < classes; index += 1) {
|
|
64
|
+
const position = (index * (sorted.length - 1)) / classes;
|
|
65
|
+
const lower = Math.floor(position);
|
|
66
|
+
const upper = Math.ceil(position);
|
|
67
|
+
const weight = position - lower;
|
|
68
|
+
const left = sorted[lower] ?? sorted[0] ?? 0;
|
|
69
|
+
const right = sorted[upper] ?? left;
|
|
70
|
+
edges.push(left + (right - left) * weight);
|
|
71
|
+
}
|
|
72
|
+
edges.push(sorted[sorted.length - 1] ?? edges[0] ?? 0);
|
|
73
|
+
return edges;
|
|
74
|
+
}
|
|
75
|
+
export function evaluateFormExpressions(fields, feature) {
|
|
76
|
+
const hidden = [];
|
|
77
|
+
const values = {};
|
|
78
|
+
const errors = [];
|
|
79
|
+
for (const field of fields) {
|
|
80
|
+
if (field.visibleExpression) {
|
|
81
|
+
const visible = evaluateExpression(field.visibleExpression, feature.attributes ?? {}, field.name, errors);
|
|
82
|
+
if (visible === false)
|
|
83
|
+
hidden.push(field.name);
|
|
84
|
+
}
|
|
85
|
+
if (field.valueExpression) {
|
|
86
|
+
const value = evaluateExpression(field.valueExpression, feature.attributes ?? {}, field.name, errors);
|
|
87
|
+
if (value !== undefined &&
|
|
88
|
+
!errors.some((error) => error.field === field.name && error.message.includes(field.valueExpression ?? ""))) {
|
|
89
|
+
values[field.name] = value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { hidden, values, errors };
|
|
94
|
+
}
|
|
95
|
+
function evaluateExpression(expression, attributes, field, errors) {
|
|
96
|
+
const call = expression.match(/^([A-Za-z_][A-Za-z0-9_]*)\(/);
|
|
97
|
+
if (call && call[1] !== "Number") {
|
|
98
|
+
errors.push({ field, message: `unknown function ${call[1]} in ${expression}` });
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const equality = expression.match(/^\$feature\.([A-Za-z0-9_]+)\s*==\s*'([^']*)'$/);
|
|
102
|
+
if (equality)
|
|
103
|
+
return attributes[equality[1] ?? ""] === equality[2];
|
|
104
|
+
const sum = expression.match(/^\$feature\.([A-Za-z0-9_]+)\s*\+\s*\$feature\.([A-Za-z0-9_]+)$/);
|
|
105
|
+
if (sum)
|
|
106
|
+
return Number(attributes[sum[1] ?? ""]) + Number(attributes[sum[2] ?? ""]);
|
|
107
|
+
const reference = expression.match(/^\$feature\.([A-Za-z0-9_]+)$/);
|
|
108
|
+
if (reference)
|
|
109
|
+
return attributes[reference[1] ?? ""];
|
|
110
|
+
errors.push({ field, message: `unsupported expression ${expression}` });
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
export async function applyToFeatures(features, change, applyEdits) {
|
|
114
|
+
const applied = [];
|
|
115
|
+
const rejected = [];
|
|
116
|
+
for (const feature of features) {
|
|
117
|
+
const update = { attributes: { ...(feature.attributes ?? {}), ...change } };
|
|
118
|
+
const result = await applyEdits({ update });
|
|
119
|
+
if (result.error || result.reason)
|
|
120
|
+
rejected.push({ feature, reason: result.reason ?? result.error ?? "rejected" });
|
|
121
|
+
else
|
|
122
|
+
applied.push(update);
|
|
123
|
+
}
|
|
124
|
+
return { applied, rejected };
|
|
125
|
+
}
|
|
126
|
+
export function sampleElevations(line, terrain, spacing = 1) {
|
|
127
|
+
if (!terrain)
|
|
128
|
+
return { samples: [], error: "terrain-missing" };
|
|
129
|
+
const densified = densify(line, spacing);
|
|
130
|
+
return {
|
|
131
|
+
samples: densified.map((position) => ({
|
|
132
|
+
position,
|
|
133
|
+
elevation: terrain.elevationAt(position[0], position[1]),
|
|
134
|
+
})),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function densify(line, spacing) {
|
|
138
|
+
if (line.length === 0)
|
|
139
|
+
return [];
|
|
140
|
+
const points = [line[0]];
|
|
141
|
+
for (let index = 1; index < line.length; index += 1) {
|
|
142
|
+
const start = line[index - 1];
|
|
143
|
+
const end = line[index];
|
|
144
|
+
const length = Math.hypot(end[0] - start[0], end[1] - start[1]);
|
|
145
|
+
const steps = Math.max(1, Math.ceil(length / spacing));
|
|
146
|
+
for (let step = 1; step <= steps; step += 1) {
|
|
147
|
+
const t = step / steps;
|
|
148
|
+
points.push([start[0] + (end[0] - start[0]) * t, start[1] + (end[1] - start[1]) * t]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return points;
|
|
152
|
+
}
|