@trailstash/ultra 3.8.4 → 3.8.6

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.
package/.gitlab-ci.yml CHANGED
@@ -1,3 +1,8 @@
1
+ test:
2
+ image: node:20
3
+ script:
4
+ - npm ci
5
+ - npm test
1
6
  pages:
2
7
  image: node:20
3
8
  script:
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: Query OSM using Sophox
3
+ description: Load OSM data from Sophox
4
+ type: sparql
5
+ server: https://sophox.org/sparql
6
+ options:
7
+ zoom: -0.1
8
+ center: [0, 30]
9
+ ---
10
+ SELECT * WHERE {
11
+ ?newspaper osmt:office "newspaper";
12
+ osmm:loc ?coordinates.
13
+ }
Binary file
package/docs/yaml.md CHANGED
@@ -131,14 +131,15 @@ Detected if:
131
131
 
132
132
  ### `sparql`
133
133
 
134
- Make a [GeoSPARQL](https://www.ogc.org/publications/standard/geosparql/) query to load data.
134
+ Make a [SPARQL](https://www.w3.org/TR/sparql11-query/) query to load data.
135
135
 
136
- **Note:** requrires you to specify a [server](#server).
136
+ **Note:** requires you to specify a [server](#server).
137
137
 
138
138
  Examples:
139
139
 
140
140
  * [Qlever](./Examples/qlever.md)
141
141
  * [Wikidata Query Service](./Examples/wikidata-sparql.md)
142
+ * [Sophox](./Examples/sophox.md)
142
143
 
143
144
  ### `ohsome`
144
145
 
@@ -14,14 +14,15 @@ const overpassQLRegexes = [
14
14
  /\({{bbox}}\)/,
15
15
  /\[out:json\]/,
16
16
  /\[out:xml\]/,
17
- /node\[[^]\]/,
18
- /way\[[^]\]/,
19
- /relation\[[^]\]/,
20
- /nwr\[[^]\]/,
21
- /nw\[[^]\]/,
22
- /nr\[[^]\]/,
23
- /wr\[[^]\]/,
24
- /area\[[^]\]/,
17
+ /node\[[^\]]+]/,
18
+ /way\[[^\]]+]/,
19
+ /relation\[[^\]]+]/,
20
+ /nwr\[[^\]]+]/,
21
+ /nw\[[^\]]+]/,
22
+ /nr\[[^\]]+]/,
23
+ /wr\[[^\]]+]/,
24
+ /area\[[^\]]+]/,
25
+
25
26
  /node\([^)]\)/,
26
27
  /way\([^)]\)/,
27
28
  /relation\([^)]\)/,
@@ -30,7 +31,8 @@ const overpassQLRegexes = [
30
31
  /nr\([^)]\)/,
31
32
  /wr\([^)]\)/,
32
33
  /area\([^)]\)/,
33
- /out( geom| center| skel)?;/,
34
+
35
+ /out( meta| geom| center| skel)*;/,
34
36
  ];
35
37
  function detect(query) {
36
38
  const doc = new window.DOMParser().parseFromString(query, "text/xml");
@@ -42,9 +44,10 @@ function detect(query) {
42
44
  }
43
45
  for (const re of overpassQLRegexes) {
44
46
  if (query.match(re)) {
45
- return query;
47
+ return true;
46
48
  }
47
49
  }
50
+ return false;
48
51
  }
49
52
 
50
53
  const overpass = {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import overpass from "./overpass.js";
6
+
7
+ describe("overpass", () => {
8
+ it("should detect Overpass XML", () => {
9
+ expect(overpass.detect("<osm-script></osm-script>")).toEqual(true);
10
+ });
11
+ it("should detect OverpassQL", () => {
12
+ expect(overpass.detect("node(8072127669);out;")).toEqual(true);
13
+ expect(
14
+ overpass.detect("node[amenity=bicycle_repair_station];out meta;"),
15
+ ).toEqual(true);
16
+ expect(
17
+ overpass.detect(
18
+ "[bbox:-85.05112899999985,-143.4237868840288,85.05112900000006,143.19307950688642];way[highway];out geom;",
19
+ ),
20
+ ).toEqual(true);
21
+ expect(
22
+ overpass.detect(`[bbox:-85.05112899999985,-143.4237868840288,85.05112900000006,143.19307950688642];
23
+ (
24
+ way[highway=path];
25
+ way[highway=footway];
26
+ way[highway=cycleway];
27
+ way[highway=steps];
28
+ );
29
+ out meta geom;`),
30
+ ).toEqual(true);
31
+ });
32
+ });
@@ -25,15 +25,15 @@ const source = async function (query, controller, { server, bounds }) {
25
25
  }
26
26
  const resp = await fetch(server, {
27
27
  method: "POST",
28
- body: query,
28
+ body: new URLSearchParams([["query", query]]),
29
29
  signal: controller.signal,
30
30
  headers: {
31
- "Content-Type": "application/sparql-query",
31
+ "Content-Type": "application/x-www-form-urlencoded",
32
32
  Accept: "application/sparql-results+json",
33
33
  },
34
34
  });
35
35
  if (!resp.ok) {
36
- throw new Error(`SparQL API returned ${resp.status}: ${await resp.text()}`);
36
+ throw new Error(`SPARQL API returned ${resp.status}: ${await resp.text()}`);
37
37
  }
38
38
  const data = sparql2geojson(await resp.json());
39
39
  let attribution = "";
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.8.4",
6
+ "version": "3.8.6",
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": {
@@ -17,7 +17,7 @@
17
17
  "build:pages": "mkdir -p public && cp -Lr dist/* public/.",
18
18
  "start": "node ./bin/run.js serve",
19
19
  "format": "prettier --print-width=80 --write '**/*.js' '**/*.json' README.md '**/*.css'",
20
- "test": "echo \"Error: no test specified\" && exit 1"
20
+ "test": "jest"
21
21
  },
22
22
  "type": "module",
23
23
  "repository": {
@@ -44,6 +44,9 @@
44
44
  "devDependencies": {
45
45
  "@types/node": "^22.6.1",
46
46
  "@unvt/sprite-one": "^0.1.1",
47
+ "esbuild-jest": "^0.5.0",
48
+ "jest": "^29.7.0",
49
+ "jest-environment-jsdom": "^29.7.0",
47
50
  "prettier": "^3.3.3",
48
51
  "puppeteer": "^23.4.0",
49
52
  "svg2png": "^4.1.1",
@@ -83,5 +86,10 @@
83
86
  "commands": "./cli",
84
87
  "dirname": "ultra",
85
88
  "topicSeparator": " "
89
+ },
90
+ "jest": {
91
+ "transform": {
92
+ "^.+\\.js$": "esbuild-jest"
93
+ }
86
94
  }
87
95
  }