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