@flatfile/plugin-enrich-gpx
v0.2.0
Published
A Flatfile plugin for parsing GPX files and extracting relevant data
Downloads
145
Readme
@flatfile/plugin-enrich-gpx
A powerful Flatfile Listener plugin for parsing and analyzing GPX (GPS Exchange Format) files. This plugin extracts valuable information from GPX files, performs data processing, and provides statistical analysis.
Event Type:
listener.on('commit:created')
Features
- Parse GPX files containing waypoints, tracks, and routes
- Convert GPX data to a tabular format
- Calculate total distance and elevation gain
- Remove duplicate points
- Filter data by date range
- Extract metadata such as name and description
- Count waypoints, tracks, and routes
Installation
To install the plugin, run the following command:
npm install @flatfile/plugin-enrich-gpx
Example Usage
import { FlatfileListener } from "@flatfile/listener";
import { enrichGpx } from "@flatfile/plugin-enrich-gpx";
export default function (listener: FlatfileListener) {
listener.use(enrichGpx({
sheetSlug: 'gpx-data',
gpxFileField: 'gpx_file',
removeDuplicatesField: 'remove_duplicates',
filterDatesField: 'filter_dates',
startDateField: 'start_date',
endDateField: 'end_date'
}));
}
Configuration
The plugin accepts the following configuration options through record fields:
sheetSlug
: (Required) The sheet to apply the GPX enrichment to as a stringgpxFileField
: (Required) The field in the record that contains the GPX file content as a stringremove_duplicates
: Set to "true" to remove duplicate pointsfilter_dates
: Set to "true" to filter points by date rangestart_date
: The start date for filtering (whenfilter_dates
is true)end_date
: The end date for filtering (whenfilter_dates
is true)
Behavior
- The plugin parses the GPX file content provided in the
gpx_file
field. - It extracts waypoints, tracks, and routes from the GPX data.
- The data is converted to a tabular format for easier processing.
- If
remove_duplicates
is set to "true", duplicate points are removed. - If
filter_dates
is set to "true" and valid start and end dates are provided, the data is filtered by date range. - The plugin calculates statistics such as total distance and elevation gain.
- Metadata and statistics are set on the record fields:
name
: Name from GPX metadatadescription
: Description from GPX metadatawaypoint_count
: Number of waypointstrack_count
: Number of tracksroute_count
: Number of routestotal_distance
: Calculated total distance in kilometerselevation_gain
: Calculated elevation gain in meterspoint_count
: Total number of points after processingtabular_data
: JSON string of the processed tabular data
The plugin handles errors gracefully and adds appropriate error messages to the record if parsing fails or required data is missing.