DataMerger
Defined in: packages/core/src/data/merge/data-merger.ts:116
Merges GeoJSON FeatureCollections using configurable strategies.
Remarks
Section titled “Remarks”Supports three merge strategies:
replace: Complete replacement of existing data
- Replaces all existing features with incoming features
- Simple and efficient for full updates
merge: Update by key, keep unmatched
- Updates existing features by matching on a key property
- Adds new features that don’t match existing keys
- Preserves existing features not in the update
- Requires
updateKeyoption
append-window: Add with time/size limits
- Appends incoming features to existing features
- Applies size limit (keeps most recent N features)
- Applies time limit (removes features older than duration)
- Requires
timestampFieldfor time-based filtering
Example
Section titled “Example”const merger = new DataMerger();
// Replace all dataconst result = merger.merge(existing, incoming, { strategy: 'replace'});
// Merge by vehicle IDconst result = merger.merge(existing, incoming, { strategy: 'merge', updateKey: 'vehicleId'});
// Append with 100 feature limit and 1 hour windowconst result = merger.merge(existing, incoming, { strategy: 'append-window', windowSize: 100, windowDuration: 3600000, timestampField: 'timestamp'});Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DataMerger():
DataMerger
Returns
Section titled “Returns”DataMerger
Methods
Section titled “Methods”merge()
Section titled “merge()”merge(
existing,incoming,options):MergeResult
Defined in: packages/core/src/data/merge/data-merger.ts:139
Merge two FeatureCollections using the specified strategy.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
existing | FeatureCollection | Existing feature collection |
incoming | FeatureCollection | Incoming feature collection to merge |
options | MergeOptions | Merge options including strategy |
Returns
Section titled “Returns”Merge result with statistics
Throws
Section titled “Throws”If merge strategy requires missing options
Example
Section titled “Example”const merger = new DataMerger();
const result = merger.merge(existingData, newData, { strategy: 'merge', updateKey: 'id'});
console.log(`Added: ${result.added}, Updated: ${result.updated}`);console.log(`Total features: ${result.total}`);