|
| 1 | +import AutoProvider from "@trailstash/ultra/lib/queryProviders/auto.js"; |
1 | 2 | import overpass from "@trailstash/ultra/lib/queryProviders/overpass.js"; |
2 | | -import sparql from "@trailstash/ultra/lib/queryProviders/sparql.js"; |
| 3 | +import { all } from "@trailstash/ultra/lib/queryProviders/index.js"; |
3 | 4 |
|
4 | | -const mapStyle = "https://www.openhistoricalmap.org/map-styles/main/main.json"; |
| 5 | +const mapStyle = "https://styles.maprva.org/openmaptiles-osm.json"; |
5 | 6 | const query = `/* |
6 | 7 | This is an example Overpass query. |
7 | 8 | Try it out by pressing the Run button above! |
8 | 9 | */ |
9 | | -nwr["amenity"="theatre"]["start_date"](if: |
10 | | - t["start_date"] < "1976" && |
11 | | - (!is_tag("end_date") || t["end_date"] >= "1975")); |
12 | | -
|
13 | | -out geom; |
14 | | -`; |
15 | | - |
16 | | -const popupTemplate = ` |
17 | | - <h2> |
18 | | - {{ type }} |
19 | | - <a href="https://openhistoricalmap.org/{{ type }}/{{ id }}" target="_blank">{{ id }}</a> |
20 | | - <a href="https://openhistoricalmap.org/edit?{{ type }}={{ id }}" target="_blank">✏️</a> |
21 | | - </h2> |
22 | | - <h3>Tags</h3> |
23 | | - {%- for tag in tags %} |
24 | | - {%- if tag[0] contains "website" %} |
25 | | - <code>{{ tag[0] }} = <a href="{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code> |
26 | | - {%- elsif tag[0] contains "wikidata" %} |
27 | | - <code>{{ tag[0] }} = <a href="https://wikidata.org/wiki/{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code> |
28 | | - {%- elsif tag[0] contains "wikipedia" %} |
29 | | - {% assign lang = tag[1] | split: ":" | first %} |
30 | | - <code>{{ tag[0] }} = <a href="https://{{ lang }}.wikipedia.org/wiki/{{ tag[1] | replace_first: lang, "" | replace_first: ":", "" }}" target="_blank">{{ tag[1] }}</a></code> |
31 | | - {%- else %} |
32 | | - <code>{{ tag[0] }} = {{ tag[1] }}</code> |
33 | | - {%- endif %} |
34 | | - <br> |
35 | | - {%- endfor %} |
36 | | - {%- if meta %} |
37 | | - <h3>Meta</h3> |
38 | | - {%- for tag in meta %} |
39 | | - {%- if tag[0] == "changeset" %} |
40 | | - <code>{{ tag[0] }} = <a href="https://openhistoricalmap.org/changeset/{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code> |
41 | | - {%- elsif tag[0] == "user" %} |
42 | | - <code>{{ tag[0] }} = <a href="https://openhistoricalmap.org/user/{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code> |
43 | | - {%- else %} |
44 | | - <code>{{ tag[0] }} = {{ tag[1] }}</code> |
45 | | - {%- endif %} |
46 | | - <br> |
47 | | - {%- endfor %} |
48 | | - {%- endif %} |
49 | | - {%- if coordinates %} |
50 | | - <h3>Coordinates</h3> |
51 | | - <a href="geo://{{coordinates[1]}},{{coordinates[0]}}">{{coordinates[1] | round: 6 }} / {{coordinates[0] | round: 6 }}</a> <small>(lat/lon)</small> |
52 | | - {%- endif %} |
53 | | -`; |
54 | | - |
55 | | -const help = ` |
56 | | -# Introduction |
57 | | -
|
58 | | -This is an [OpenHistoricalMap](https://openhistoricalmap.org)-specific deployment of |
59 | | -[Ultra](https://gitlab.com/trailstash/ultra) a web-application made to simplify making maps with |
60 | | -[MapLibre GL JS](https://maplibre.org). It can load [OpenHistoricalMap](https://openhistoricalmap.org) data |
61 | | -from the [Overpass API](https://overpass-api.de/). |
62 | | -
|
63 | | -## Documentation |
64 | | -
|
65 | | -The documentation for Ultra is available at <a target="_blank" href="https://overpass-ultra.us/docs/">overpass-ultra.us/docs</a> |
66 | | -
|
67 | | -## Overpass Queries |
68 | | -
|
69 | | -The Overpass API allows you to query for OHM data by your own search criteria. For this purpose, it |
70 | | -has a specifically crafted query language: [Overpass |
71 | | -QL](https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL) |
72 | | -
|
73 | | -In addition to regular Overpass API queries one can use \`{{bbox}}\` to specify the bounding box |
74 | | -coordinates of the current map view. |
75 | | -
|
76 | | -## Configuration |
77 | | -
|
78 | | -Various aspects of Ultra, such as styling and the Overpass API server to use, can be |
79 | | -configured via [YAML front-matter](https://overpass-ultra.us/docs/yaml). |
80 | | -
|
81 | | -## Styling |
82 | | -
|
83 | | -Ultra supports styling using an |
84 | | -[extended](https://overpass-ultra.us/docs/style#ultra-maplibre-styles) version of the the [MapLibre |
85 | | -Style Spec](https://maplibre.org/maplibre-style-spec/). |
86 | | -
|
87 | | -
|
88 | | -See the [Styling](https://overpass-ultra.us/docs/style) section for more information. |
89 | | -
|
90 | | -## About |
91 | | -
|
92 | | -Ultra is built by Daniel Schep. |
93 | | -
|
94 | | -You can contact me on [Mastodon](https://mapstodon.space/@trailstash). |
95 | | -
|
96 | | -## Feedback, Bug Reports, Feature Requests |
97 | | -
|
98 | | -While Ultra has been in development for a while, it should still be considered experimental. |
99 | | -
|
100 | | -If you would like to report a bug or provide other feedback, please do so in the project's |
101 | | -[Issue Tracker](https://gitlab.com/trailstash/ultra/-/issues). |
102 | | -
|
103 | | -## Source Code</h4> |
104 | | -
|
105 | | -The [source code](https://gitlab.com/trailstash/ultra) of this application is released under the |
106 | | -[MIT license](https://gitlab.com/trailstash/overpass-ultra/-/blob/master/LICENSE). |
107 | | -`; |
| 10 | +[bbox:{{bbox}}]; |
| 11 | +( |
| 12 | +way[highway=path]; |
| 13 | +way[highway=footway]; |
| 14 | +way[highway=cycleway]; |
| 15 | +way[highway=steps]; |
| 16 | +); |
| 17 | +out geom;`; |
| 18 | + |
| 19 | + |
| 20 | +const customAll = { |
| 21 | + ...all, |
| 22 | + overpass: { |
| 23 | + ...overpass, |
| 24 | + source: async function (query, controller, { server }) { |
| 25 | + if (!server) { |
| 26 | + server = "https://overpass.maprva.org/api"; |
| 27 | + } |
| 28 | + return overpass.source(query, controller, { server }); |
| 29 | + }, |
| 30 | + }, |
| 31 | +}; |
108 | 32 |
|
109 | 33 | const settings = { |
110 | | - type: "overpass", |
| 34 | + type: "auto", |
111 | 35 | mapStyle, |
112 | 36 | queryProviders: { |
113 | | - overpass: { |
114 | | - ...overpass, |
115 | | - source: async function (query, controller, { server }) { |
116 | | - if (!server) { |
117 | | - server = "https://overpass-api.openhistoricalmap.org/api"; |
118 | | - } |
119 | | - const src = await overpass.source(query, controller, { server }); |
120 | | - delete src.attribution; |
121 | | - return src; |
122 | | - }, |
123 | | - popupTemplate, |
124 | | - }, |
125 | | - sparql, |
| 37 | + auto: new AutoProvider(customAll), |
| 38 | + ...customAll, |
126 | 39 | }, |
127 | 40 | }; |
128 | 41 |
|
| 42 | +const omtAttribution = '<a target="_blank" href="https://openmaptiles.org">OpenMapTiles</a> (Tiles by <a target="_blank" href="https://tiles.openstreetmap.us/">OSM US</a>)'; |
| 43 | +const styles = [ |
| 44 | + [ |
| 45 | + `OSM OpenMapTiles`, |
| 46 | + "https://styles.maprva.org/openmaptiles-osm.json", |
| 47 | + omtAttribution, |
| 48 | + ], |
| 49 | + [ |
| 50 | + `OSM Liberty`, |
| 51 | + "https://styles.maprva.org/osm-liberty.json", |
| 52 | + omtAttribution, |
| 53 | + ], |
| 54 | + [ |
| 55 | + `OSM Bright`, |
| 56 | + "https://styles.maprva.org/osm-bright.json", |
| 57 | + omtAttribution, |
| 58 | + ], |
| 59 | + [ |
| 60 | + `Positron`, |
| 61 | + "https://styles.maprva.org/positron.json", |
| 62 | + omtAttribution, |
| 63 | + ], |
| 64 | + [ |
| 65 | + `Dark Matter`, |
| 66 | + "https://styles.maprva.org/dark-matter.json", |
| 67 | + omtAttribution, |
| 68 | + ], |
| 69 | + [ |
| 70 | + `MapTiler Basic`, |
| 71 | + "https://styles.maprva.org/maptiler-basic.json", |
| 72 | + omtAttribution, |
| 73 | + ], |
| 74 | + [ |
| 75 | + `MapTiler 3D`, |
| 76 | + "https://styles.maprva.org/maptiler-3d.json", |
| 77 | + omtAttribution, |
| 78 | + ], |
| 79 | + [ |
| 80 | + `Toner`, |
| 81 | + "https://styles.maprva.org/maptiler-toner.json", |
| 82 | + omtAttribution, |
| 83 | + ], |
| 84 | + [ |
| 85 | + `Fiord Color`, |
| 86 | + "https://styles.maprva.org/fiord-color.json", |
| 87 | + omtAttribution, |
| 88 | + ], |
| 89 | + [ |
| 90 | + `Virginia Base Mapping Program`, |
| 91 | + "https://styles.maprva.org/vgin-vbmp-imagery-latest.json", |
| 92 | + `Imagery`, |
| 93 | + ], |
| 94 | + [ |
| 95 | + `Henrico Aerial Imagery`, |
| 96 | + "https://styles.maprva.org/henrico-aerial-imagery-latest.json", |
| 97 | + `Imagery`, |
| 98 | + ], |
| 99 | + [ |
| 100 | + `Esri World Imagery`, |
| 101 | + "https://styles.maprva.org/henrico-aerial-imagery-latest.json", |
| 102 | + `Imagery`, |
| 103 | + ], |
| 104 | +]; |
| 105 | + |
| 106 | + |
129 | 107 | export const defaultMode = "ide"; |
130 | 108 | export const modes = { |
131 | 109 | ide: { |
132 | 110 | query, |
133 | | - help, |
134 | | - styles: [ |
135 | | - [ |
136 | | - "Historic", |
137 | | - mapStyle, |
138 | | - '<a href="https://openhistoricalmap.org">OpenHistoricalMap</a>', |
139 | | - ], |
140 | | - [ |
141 | | - "Rail", |
142 | | - "https://www.openhistoricalmap.org/map-styles/rail/rail.json", |
143 | | - '<a href="https://openhistoricalmap.org">OpenHistoricalMap</a>', |
144 | | - ], |
145 | | - [ |
146 | | - "Woodblock", |
147 | | - "https://www.openhistoricalmap.org/map-styles/woodblock/woodblock.json", |
148 | | - '<a href="https://openhistoricalmap.org">OpenHistoricalMap</a>', |
149 | | - ], |
150 | | - [ |
151 | | - "Japanese Scroll", |
152 | | - "https://www.openhistoricalmap.org/map-styles/japanese_scroll/ohm-japanese-scroll-map.json", |
153 | | - '<a href="https://openhistoricalmap.org">OpenHistoricalMap</a>', |
154 | | - ], |
155 | | - [ |
156 | | - "OSM OpenMapTiles", |
157 | | - "https://styles.trailsta.sh/openmaptiles-osm.json", |
158 | | - '<a href="https://openfreemap.org">OpenFreeMap</a>', |
159 | | - ], |
160 | | - ], |
| 111 | + styles, |
161 | 112 | settings: { |
162 | 113 | ...settings, |
163 | | - title: "OHM Ultra", |
164 | | - url: "https://ohm.overpass-ultra.us", |
| 114 | + title: "MapRVA Ultra", |
| 115 | + url: "https://ultra.maprva.org", |
165 | 116 | options: { |
166 | | - zoom: 13, |
167 | | - center: [-73.9803, 40.7412], |
168 | 117 | attributionControl: { |
169 | 118 | customAttribution: "", |
170 | 119 | }, |
171 | | - maxBounds: [ |
172 | | - [-179.999999999, -85.051129], |
173 | | - [179.999999999, 85.051129], |
174 | | - ], |
175 | 120 | }, |
176 | 121 | }, |
177 | 122 | }, |
|
0 commit comments