Input Data Schema
Relevant source files
The following files were used as context for generating this wiki page:
The geo-path-reducer library utilizes a specific data schema to process and simplify geographical paths using the Douglas-Peucker algorithm. The input consists primarily of a collection of coordinate points and a tolerance threshold (epsilon) that dictates the degree of simplification applied to the spatial data.
Sources: README.md:3-8, src/index.js:3
Primary Input Parameters
The main entry point for the library, the geoPathReducer function, accepts two primary arguments that define the path to be processed and the sensitivity of the simplification logic.
| Parameter | Type | Description |
|---|---|---|
points | Array | An ordered collection of geographical coordinate objects. |
epsilon | Number | The maximum allowable distance (in degrees) between the original and simplified curve. |
Sources: README.md:31-36, src/index.js:3
Point Object Structure
Each element within the points array must conform to a specific object structure containing latitude and longitude properties. These properties are used by the underlying distance calculation modules to determine spatial relationships.
| Field | Type | Description |
|---|---|---|
lat | Number | The latitude of the point in decimal degrees. |
lng | Number | The longitude of the point in decimal degrees. |
Sources: README.md:34-35, src/perpendicular-distance.js:5-7, src/distance.js:1
Data Flow and Logic
The input data flows through a recursive process where the schema of individual points remains consistent across recursive calls, while the array of points is partitioned based on the calculated maximum distance from a baseline.
The diagram above illustrates how the input array is evaluated and transformed. If the distance between the most distant point and the line segment formed by the start and end points exceeds the epsilon threshold, the schema is preserved through recursive processing of subsets.
Sources: src/index.js:6-23, src/perpendicular-distance.js:1-11
Distance Calculation Geometry
The input coordinates are processed by the perpendicularDistance module, which decomposes the input points into individual components for trigonometric calculation.
The system calculates distances based on the Earth's radius (6371 km) and converts decimal degree inputs into radians for great-circle distance measurements.
Sources: src/distance.js:3-15, src/perpendicular-distance.js:5-7
Implementation Example
The following JSON-like structure represents the valid input schema required for the module to function correctly.
const points = [
{ lat: 37.7749, lng: -122.4194 },
{ lat: 37.7755, lng: -122.4182 },
{ lat: 37.7769, lng: -122.4159 }
];
const epsilon = 0.0001;
Sources: README.md:17-24
Summary
The geo-path-reducer input schema is designed for simplicity and interoperability with standard geographical data formats. By requiring an array of objects with lat and lng properties, it ensures compatibility with the Douglas-Peucker recursive simplification algorithm and the great-circle distance calculations performed by its internal utilities.