@trailstash/ultra 4.2.3 → 4.2.4
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/lib/queryProviders/postpass.js +14 -12
- package/package.json +1 -1
|
@@ -6,35 +6,37 @@ import { layers, popupTemplate, popupContextBuilder } from "./osm.js";
|
|
|
6
6
|
const nonTags = {
|
|
7
7
|
osm_id: true,
|
|
8
8
|
tags: true,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// yes... these are not tags... but they are useful! so we're keeping them.
|
|
10
|
+
// way_area: true,
|
|
11
|
+
// z_order: true,
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const flattenPropertiesAndInferIdAndType = (geoJSON) => {
|
|
14
15
|
// prety major assumption basked into this as Postpass executes arbitrary SQL so the returned
|
|
15
16
|
// data could be anything. This assumes that the query returns un-renamed columns.
|
|
16
|
-
geoJSON.features = geoJSON.features.map((
|
|
17
|
+
geoJSON.features = geoJSON.features.map((f) => {
|
|
17
18
|
const properties = {};
|
|
18
|
-
if (
|
|
19
|
-
properties["@
|
|
20
|
-
properties["@id"] = x.properties.osm_id;
|
|
19
|
+
if (f.properties.osm_id) {
|
|
20
|
+
properties["@id"] = f.properties.osm_id;
|
|
21
21
|
if (properties["@id"] < 0) {
|
|
22
22
|
properties["@id"] = -properties["@id"];
|
|
23
23
|
properties["@type"] = "relation";
|
|
24
|
+
} else {
|
|
25
|
+
properties["@type"] = f.geometry.type === "Point" ? "node" : "way";
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
if (
|
|
27
|
-
for (const [k, v] of Object.entries(
|
|
28
|
+
if (f.properties.tags) {
|
|
29
|
+
for (const [k, v] of Object.entries(f.properties.tags)) {
|
|
28
30
|
properties[k] = v;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
for (const [
|
|
32
|
-
if (!nonTags[
|
|
33
|
-
properties
|
|
33
|
+
for (const [k, v] of Object.entries(f.properties)) {
|
|
34
|
+
if (!nonTags[k]) {
|
|
35
|
+
properties[k] = v;
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
return {
|
|
37
|
-
...
|
|
39
|
+
...f,
|
|
38
40
|
properties,
|
|
39
41
|
};
|
|
40
42
|
});
|
package/package.json
CHANGED