@trailstash/ultra 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,9 +23,9 @@ ${description}
23
23
  ${queryContent}
24
24
  \`\`\`
25
25
  <br>
26
- <a target="_blank" href="/#map&${params.toString()}">View Map on Overpass Ultra</a>
26
+ <a target="_blank" href="/#map&${params.toString()}">View Map on Ultra</a>
27
27
  <br>
28
- <a target="_blank" href="/#${params.toString()}">Edit Query on Overpass Ultra</a>`;
28
+ <a target="_blank" href="/#${params.toString()}">Edit Query on Ultra</a>`;
29
29
  if (dir.startsWith("MapLibre-Examples"))
30
30
  html += `<br>
31
31
  <a target="_blank" href="https://maplibre.org/maplibre-gl-js/docs/examples/${file.replace(".ultra", "")}/">View MapLibre Example</a>
package/cli/.build.js.swo CHANGED
Binary file
package/cli/build.js CHANGED
@@ -11,9 +11,9 @@ const engine = new Liquid();
11
11
  export const getHTMLContext = async (configFile) => {
12
12
  const config = await import(configFile);
13
13
  const {
14
- settings: { title, description, url, mastodon },
14
+ settings: { title, icon, description, url, mastodon },
15
15
  } = config.modes[config.defaultMode];
16
- return { title, description, url, mastodon };
16
+ return { title, icon, description, url, mastodon };
17
17
  };
18
18
 
19
19
  export const buildConfigFromQuery = async (config, query) => {
@@ -95,7 +95,7 @@ export class UltraIDE extends HTMLElement {
95
95
  "options",
96
96
  "controls",
97
97
  "mapStyle",
98
- "extraQueryProviders",
98
+ "queryProviders",
99
99
  "persistState",
100
100
  ];
101
101
  static props = ["settings", "query", "styles", "title", "icon", "help"];
@@ -5,7 +5,6 @@ import { setQueryBounds } from "../lib/bounds.js";
5
5
  import { setBaseStyle } from "../lib/style.js";
6
6
  import { parseSettings } from "../lib/settings.js";
7
7
  import queryProviders from "../lib/queryProviders/index.js";
8
- import AutoProvider from "../lib/queryProviders/auto.js";
9
8
  import {
10
9
  hasHash,
11
10
  getOptionsFromQueryParams,
@@ -48,7 +47,7 @@ export class UltraMap extends HTMLElement {
48
47
  options: {},
49
48
  controls: [],
50
49
  fitBounds: false,
51
- extraQueryProviders: {},
50
+ queryProviders,
52
51
  persistState: false,
53
52
  };
54
53
 
@@ -70,10 +69,10 @@ export class UltraMap extends HTMLElement {
70
69
 
71
70
  persistState = UltraMap.defaults.persistState;
72
71
 
73
- extraQueryProviders = UltraMap.defaults.extraQueryProviders;
72
+ queryProviders = UltraMap.defaults.queryProviders;
74
73
 
75
74
  static CONFIG_SETTINGS = [
76
- "extraQueryProviders",
75
+ "queryProviders",
77
76
  "loadSettingsFromQueryParams",
78
77
  "persistState",
79
78
  ];
@@ -192,7 +191,8 @@ export class UltraMap extends HTMLElement {
192
191
  this.#fitBounds &&
193
192
  (!this.options.hash || !hadHash) &&
194
193
  !this.options.bounds &&
195
- (this.options.zoom === undefined || !this.options.center)
194
+ this.options.zoom === undefined &&
195
+ !this.options.center
196
196
  ) {
197
197
  if (
198
198
  this.#cachedSource?.type === "geojson" &&
@@ -241,7 +241,7 @@ export class UltraMap extends HTMLElement {
241
241
  controller = new AbortController();
242
242
  }
243
243
 
244
- const queryProvider = this.#queryProviders[this.type];
244
+ const queryProvider = this.queryProviders[this.type];
245
245
  if (!queryProvider) {
246
246
  throw new Error(`invalid query provider: ${this.type}`);
247
247
  }
@@ -266,25 +266,11 @@ export class UltraMap extends HTMLElement {
266
266
  return this.#cachedSource.data;
267
267
  }
268
268
 
269
- get #queryProviders() {
270
- if (!this.#autoProvider) {
271
- this.#autoProvider = new AutoProvider({
272
- ...queryProviders,
273
- ...this.extraQueryProviders,
274
- });
275
- }
276
- return {
277
- auto: this.#autoProvider,
278
- ...queryProviders,
279
- ...this.extraQueryProviders,
280
- };
281
- }
282
-
283
269
  get #fitBounds() {
284
270
  if (this.fitBounds) {
285
271
  return this.fitBounds;
286
272
  }
287
- const queryProvider = this.#queryProviders[this.type];
273
+ const queryProvider = this.queryProviders[this.type];
288
274
  if (queryProvider && queryProvider.fitBounds) {
289
275
  return queryProvider.fitBounds;
290
276
  }
@@ -294,14 +280,14 @@ export class UltraMap extends HTMLElement {
294
280
  if (this.popupTemplate) {
295
281
  return this.popupTemplate;
296
282
  }
297
- const queryProvider = this.#queryProviders[this.type];
283
+ const queryProvider = this.queryProviders[this.type];
298
284
  if (queryProvider && queryProvider.popupTemplate) {
299
285
  return queryProvider.popupTemplate;
300
286
  }
301
287
  return this.popupTemplate;
302
288
  }
303
289
  get #popupContextBuilder() {
304
- const queryProvider = this.#queryProviders[this.type];
290
+ const queryProvider = this.queryProviders[this.type];
305
291
  if (queryProvider && queryProvider.popupContextBuilder) {
306
292
  return queryProvider.popupContextBuilder;
307
293
  }
package/docs/yaml.md CHANGED
@@ -42,26 +42,89 @@ popupTemplate: "{{type}} {{id}} - {{tags.name}}"
42
42
 
43
43
  Specify the type of source in the query.
44
44
 
45
- **Default:** `overpass`
45
+ **Default:** `auto`
46
+
47
+ ### `auto`
48
+ Automatically detects and chooses the right query provider out of the following:
49
+ * `overpass`
50
+ * `osmWebsite`
51
+ * `osmWiki`
52
+ * `geojson`
53
+ * `osmxml`
54
+ * `osmjson`
55
+ * `kml`
56
+ * `gpx`
57
+ * `tcx`
58
+
59
+ See each provider for how it is auto-detected
46
60
 
47
61
  ### `overpass`
48
62
  An [Overpass QL](https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL) query. Results
49
63
  converted into a [GeoJSON source](https://maplibre.org/maplibre-style-spec/sources/#geojson) with
50
64
  [`osmtogeojson`](https://github.com/tyrasd/osmtogeojson).
51
65
 
66
+ Detected if:
67
+ * Parses as XML and the top level tag is `osm-script`
68
+ * Matches one of the regexes defined [here](https://gitlab.com/trailstash/ultra/-/blob/main/lib/queryProviders/overpass.js#L11-34)
69
+
70
+ ### `osmWebsite`
71
+ Parses a URL to an node/way/relation on `osm.org` and fetches that element using an Overpass query
72
+ using `out geom;`
73
+
74
+ Detected if:
75
+ * A URL on osm.org starting with node/way/relation
76
+
77
+ ### `osmWiki`
78
+ Perform an Overpass query using `nwr` and `out geom;` for an OSM wiki URL starting with `Tag:` or
79
+ `Key:`
80
+
81
+ Detected if:
82
+ * A URL to the OSM wiki starting with `Tag:` or `Key:`
83
+
52
84
  ### `osmxml`
53
85
  An [OSM XML](https://wiki.openstreetmap.org/wiki/OSM_XML) document or a URL to one. Converted into
54
86
  a [GeoJSON source](https://maplibre.org/maplibre-style-spec/sources/#geojson) with
55
87
  [`osmtogeojson`](https://github.com/tyrasd/osmtogeojson).
56
88
 
89
+ Detected if:
90
+ * Parses as XML and the top level tag is `osm`
91
+ * Parses as a URL and the path matches that of an `node/:id`, `way/:id/full`, or
92
+ `relation/:id/full` OSM API route
93
+
57
94
  ### `osmjson`
58
95
  An [OSM JSON](https://wiki.openstreetmap.org/wiki/OSM_JSON) document or a URL to one. Converted
59
96
  into a [GeoJSON source](https://maplibre.org/maplibre-style-spec/sources/#geojson) with
60
97
  [`osmtogeojson`](https://github.com/tyrasd/osmtogeojson).
61
98
 
99
+ Detected if:
100
+ * Parses as JSON and contains a `version` key containing the value `0.6` at the top level.
101
+ * Parses as a URL and the path matches that of an `node/:id`, `way/:id/full`, or
102
+ `relation/:id/full` OSM API route
103
+
62
104
  ### `geojson`
63
105
  A JSON-encoded GeoJSON object or a URL to a GeoJSON file.
64
106
 
107
+ Detected if:
108
+ * Parses as JSON and contains a `type` with a valid GeoJSON type.
109
+
110
+ ### `kml`
111
+ A KML file or URL to a KML file.
112
+
113
+ Detected if
114
+ * Parses as XML and contains a top level `kml` tag
115
+
116
+ ### `gpx`
117
+ A GPX file or URL to a GPX file.
118
+
119
+ Detected if
120
+ * Parses as XML and contains a top level `gpx` tag
121
+
122
+ ### `tcx`
123
+ A TCX file or URL to a TCX file.
124
+
125
+ Detected if
126
+ * Parses as XML and contains a top level `tcx` tag
127
+
65
128
  ### `raster`
66
129
  A line delimited list of [tile URLs](https://maplibre.org/maplibre-style-spec/sources/#tiles_1) for
67
130
  a [raster source](https://maplibre.org/maplibre-style-spec/sources/#raster) or a [TileJSON
package/index.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <link rel="icon" href="./logo.png" />
6
+ <link rel="icon" href="{{ icon | default: "./logo.png" }}"/>
7
7
  {% if mastodon %}
8
8
  <link rel="me" href="{{ mastodon }}" />
9
9
  {% endif %}
@@ -42,16 +42,16 @@ const fetchURL = async (url) => {
42
42
  };
43
43
 
44
44
  export const hasHash = (hashName) => {
45
- let hash = window.location.hash.slice(1)
45
+ let hash = window.location.hash.slice(1);
46
46
  if (hashName) {
47
47
  const params = new URLSearchParams(hash);
48
48
  hash = params.get(hashName);
49
49
  }
50
50
  if (!hash) {
51
- return false
51
+ return false;
52
52
  }
53
53
  const loc = hash.split("/");
54
- return loc.length >= 3 && !loc.some(v => isNaN(v));
54
+ return loc.length >= 3 && !loc.some((v) => isNaN(v));
55
55
  };
56
56
 
57
57
  export const getQueryFromQueryParams = () => {
@@ -1,3 +1,4 @@
1
+ import AutoProvider from "./auto.js";
1
2
  import overpass, { osmWebsite, osmWiki } from "./overpass.js";
2
3
  import geojson from "./geojson.js";
3
4
  import raster from "./raster.js";
@@ -7,7 +8,7 @@ import kml from "./kml.js";
7
8
  import gpx from "./gpx.js";
8
9
  import tcx from "./tcx.js";
9
10
 
10
- export default {
11
+ export const all = {
11
12
  overpass,
12
13
  osmWebsite,
13
14
  osmWiki,
@@ -20,3 +21,5 @@ export default {
20
21
  raster,
21
22
  vector,
22
23
  };
24
+
25
+ export default { auto: new AutoProvider(all), ...all };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.2.2",
6
+ "version": "3.3.0",
7
7
  "description": "A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc",
8
8
  "main": "index.js",
9
9
  "scripts": {