A .geojson file needs no GPX/FIT conversion — it's already the shape gpx.js expects — so GpxStore#geojson now just reads and returns it as-is, no cache sidecar. save/tree/the upload dropzone and its zip handling all pick it up through the existing TRACK_EXTENSIONS list. Also fixes a bug the new "cached" tree icon would have shipped with: a GPX/FIT's own .geojson cache sidecar (e.g. "ride.gpx.geojson") also matches the new .geojson branch in list_children, which would have listed it as a second, phantom tree entry — excluded explicitly, with a regression test.
19 lines
760 B
Ruby
19 lines
760 B
Ruby
module Maptool
|
|
# A directly-uploaded .geojson file needs no conversion — GpxStore serves
|
|
# it straight from disk (see GpxStore#geojson) — so unlike Gpx/Fit there's
|
|
# no to_geojson here. Only kind-detection lives here, for the tree's badge
|
|
# icons, mirroring Gpx.kinds' cheap substring-search rather than a full
|
|
# JSON parse: a POI export can be tens of MB, geojson or not, and a full
|
|
# parse just to answer "does this have any points/lines" would cost the
|
|
# same either way.
|
|
module Geojson
|
|
def self.kinds(path)
|
|
content = File.read(path)
|
|
kinds = []
|
|
kinds << "waypoint" if content.include?('"Point"')
|
|
kinds << "track" if content.include?('"LineString"') # matches MultiLineString too
|
|
kinds
|
|
end
|
|
end
|
|
end
|