mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
import geojson types explicitly
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { ramerDouglasPeucker } from "./simplify";
|
import { ramerDouglasPeucker } from "./simplify";
|
||||||
import { Coordinates, GPXFileAttributes, GPXFileType, LineStyleExtension, Link, Metadata, RouteType, TrackExtensions, TrackPointExtensions, TrackPointType, TrackSegmentType, TrackType, WaypointType } from "./types";
|
import { Coordinates, GPXFileAttributes, GPXFileType, LineStyleExtension, Link, Metadata, RouteType, TrackExtensions, TrackPointExtensions, TrackPointType, TrackSegmentType, TrackType, WaypointType } from "./types";
|
||||||
import { immerable, isDraft, original, freeze } from "immer";
|
import { immerable, isDraft, original, freeze } from "immer";
|
||||||
|
import { Feature, FeatureCollection } from "geojson";
|
||||||
|
|
||||||
function cloneJSON<T>(obj: T): T {
|
function cloneJSON<T>(obj: T): T {
|
||||||
if (obj === null || typeof obj !== 'object') {
|
if (obj === null || typeof obj !== 'object') {
|
||||||
@@ -23,7 +24,7 @@ export abstract class GPXTreeElement<T extends GPXTreeElement<any>> {
|
|||||||
abstract getSegments(): TrackSegment[];
|
abstract getSegments(): TrackSegment[];
|
||||||
abstract getTrackPoints(): TrackPoint[];
|
abstract getTrackPoints(): TrackPoint[];
|
||||||
|
|
||||||
abstract toGeoJSON(): GeoJSON.Feature | GeoJSON.Feature[] | GeoJSON.FeatureCollection | GeoJSON.FeatureCollection[];
|
abstract toGeoJSON(): Feature | Feature[] | FeatureCollection | FeatureCollection[];
|
||||||
|
|
||||||
// Producers
|
// Producers
|
||||||
abstract _reverse(originalNextTimestamp?: Date, newPreviousTimestamp?: Date);
|
abstract _reverse(originalNextTimestamp?: Date, newPreviousTimestamp?: Date);
|
||||||
@@ -218,7 +219,7 @@ export class GPXFile extends GPXTreeNode<Track> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toGeoJSON(): GeoJSON.FeatureCollection {
|
toGeoJSON(): FeatureCollection {
|
||||||
return {
|
return {
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
features: this.children.flatMap((child) => child.toGeoJSON())
|
features: this.children.flatMap((child) => child.toGeoJSON())
|
||||||
@@ -518,7 +519,7 @@ export class Track extends GPXTreeNode<TrackSegment> {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
toGeoJSON(): GeoJSON.Feature[] {
|
toGeoJSON(): Feature[] {
|
||||||
return this.children.map((child) => {
|
return this.children.map((child) => {
|
||||||
let geoJSON = child.toGeoJSON();
|
let geoJSON = child.toGeoJSON();
|
||||||
if (this.extensions && this.extensions['gpx_style:line']) {
|
if (this.extensions && this.extensions['gpx_style:line']) {
|
||||||
@@ -879,7 +880,7 @@ export class TrackSegment extends GPXTreeLeaf {
|
|||||||
return this.trkpt;
|
return this.trkpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
toGeoJSON(): GeoJSON.Feature {
|
toGeoJSON(): Feature {
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
geometry: {
|
geometry: {
|
||||||
|
Reference in New Issue
Block a user