diff --git a/app/styles/main.css b/app/css/main.css similarity index 100% rename from app/styles/main.css rename to app/css/main.css diff --git a/app/callout.js b/app/js/audio/callout.js similarity index 97% rename from app/callout.js rename to app/js/audio/callout.js index 4156f2f..cf6a261 100644 --- a/app/callout.js +++ b/app/js/audio/callout.js @@ -1,7 +1,7 @@ // Copyright (c) Daniel W. Steinbrook. // with many thanks to ChatGPT -import { enumerateTilesAround } from './tile.js' +import { enumerateTilesAround } from '../data/tile.js' export function createCalloutAnnouncer(audioQueue, proximityThresholdMeters, includeDistance) { // Avoid repeating myself, by maintaining a list of the most recent POIs announced diff --git a/app/audio.js b/app/js/audio/sound.js similarity index 100% rename from app/audio.js rename to app/js/audio/sound.js diff --git a/app/config.js b/app/js/config.js similarity index 100% rename from app/config.js rename to app/js/config.js diff --git a/app/cache.js b/app/js/data/cache.js similarity index 100% rename from app/cache.js rename to app/js/data/cache.js diff --git a/app/tile.js b/app/js/data/tile.js similarity index 97% rename from app/tile.js rename to app/js/data/tile.js index 9597c19..39b8d1c 100644 --- a/app/tile.js +++ b/app/js/data/tile.js @@ -2,8 +2,8 @@ // with many thanks to ChatGPT import { addToFeatureCache, fetchUrlIfNotCached, openFeatureCache } from './cache.js' -import config from './config.js' -import { createBoundingBox, enumerateTilesInBoundingBox } from './geospatial.js' +import config from '../config.js' +import { createBoundingBox, enumerateTilesInBoundingBox } from '../spatial/geo.js' const maxAge = 604800000; // 1 week, in ms export const zoomLevel = 16; diff --git a/app/gpx.js b/app/js/gpx.js similarity index 92% rename from app/gpx.js rename to app/js/gpx.js index 7fb7221..913a8ca 100644 --- a/app/gpx.js +++ b/app/js/gpx.js @@ -1,11 +1,11 @@ // Copyright (c) Daniel W. Steinbrook. // with many thanks to ChatGPT -import { createSpatialPlayer } from './audio.js' -import { createCalloutAnnouncer } from './callout.js'; -import { createLocationProvider } from './geospatial.js' -import { HeadingCalculator } from './heading.js' -import { createMap } from './map.js' +import { createSpatialPlayer } from './audio/sound.js' +import { createCalloutAnnouncer } from './audio/callout.js'; +import { createLocationProvider } from './spatial/location.js' +import { HeadingCalculator } from './spatial/heading.js' +import { createMap } from './spatial/map.js' const speedUpFactor = 5; const proximityThresholdMeters = 80; diff --git a/app/main.js b/app/js/main.js similarity index 87% rename from app/main.js rename to app/js/main.js index b76dba3..165340a 100644 --- a/app/main.js +++ b/app/js/main.js @@ -1,11 +1,12 @@ // Copyright (c) Daniel W. Steinbrook. // with many thanks to ChatGPT -import { createSpatialPlayer } from './audio.js' -import { clearFeatureCache, clearURLCache } from './cache.js' -import { createCalloutAnnouncer } from './callout.js' -import { getLocation, createLocationProvider } from "./geospatial.js"; -import { createMap } from './map.js'; +import { createSpatialPlayer } from './audio/sound.js' +import { createCalloutAnnouncer } from './audio/callout.js' +import { clearFeatureCache, clearURLCache } from './data/cache.js' +import { getLocation } from './spatial/geo.js'; +import { createLocationProvider } from './spatial/location.js' +import { createMap } from './spatial/map.js'; const proximityThresholdMeters = 500; diff --git a/app/geospatial.js b/app/js/spatial/geo.js similarity index 78% rename from app/geospatial.js rename to app/js/spatial/geo.js index 593a6a5..5c9d864 100644 --- a/app/geospatial.js +++ b/app/js/spatial/geo.js @@ -103,38 +103,3 @@ export function geoToXY(myLocation, myHeading, poiLocation) { const scaleFactor = 0.05; return { x: x * scaleFactor, y: y * scaleFactor }; } - -export function createLocationProvider() { - var locationProvider = { - subscribed: [], - - // Register a function to be called whenever location changes - subscribe: function(callback) { - locationProvider.subscribed.push(callback); - }, - - update: function(latitude, longitude, heading) { - locationProvider.latitude = latitude; - locationProvider.longitude = longitude; - locationProvider.heading = heading; - - // Trigger all subscribed functions - locationProvider.subscribed.forEach(callback => { - callback(latitude, longitude, heading); - }); - }, - - turfPoint: function() { - return turf.point([locationProvider.longitude, locationProvider.latitude]); - }, - - relativePosition: function(someLocation) { - return geoToXY(locationProvider.turfPoint(), locationProvider.heading, someLocation); - }, - - distance: function(someLocation, options) { - return turf.distance(locationProvider.turfPoint(), someLocation, options); - }, - }; - return locationProvider; -} \ No newline at end of file diff --git a/app/heading.js b/app/js/spatial/heading.js similarity index 100% rename from app/heading.js rename to app/js/spatial/heading.js diff --git a/app/js/spatial/location.js b/app/js/spatial/location.js new file mode 100644 index 0000000..39bbfad --- /dev/null +++ b/app/js/spatial/location.js @@ -0,0 +1,39 @@ +// Copyright (c) Daniel W. Steinbrook. +// with many thanks to ChatGPT + +import { geoToXY } from './geo.js' + +export function createLocationProvider() { + var locationProvider = { + subscribed: [], + + // Register a function to be called whenever location changes + subscribe: function(callback) { + locationProvider.subscribed.push(callback); + }, + + update: function(latitude, longitude, heading) { + locationProvider.latitude = latitude; + locationProvider.longitude = longitude; + locationProvider.heading = heading; + + // Trigger all subscribed functions + locationProvider.subscribed.forEach(callback => { + callback(latitude, longitude, heading); + }); + }, + + turfPoint: function() { + return turf.point([locationProvider.longitude, locationProvider.latitude]); + }, + + relativePosition: function(someLocation) { + return geoToXY(locationProvider.turfPoint(), locationProvider.heading, someLocation); + }, + + distance: function(someLocation, options) { + return turf.distance(locationProvider.turfPoint(), someLocation, options); + }, + }; + return locationProvider; +} \ No newline at end of file diff --git a/app/map.js b/app/js/spatial/map.js similarity index 100% rename from app/map.js rename to app/js/spatial/map.js diff --git a/index.html b/index.html index 1982686..3bbab98 100644 --- a/index.html +++ b/index.html @@ -5,11 +5,11 @@ - + - +
diff --git a/replay_gpx.html b/replay_gpx.html index 22246e6..1aace8c 100644 --- a/replay_gpx.html +++ b/replay_gpx.html @@ -5,11 +5,11 @@ - + - +