-
Notifications
You must be signed in to change notification settings - Fork 11
/
justfile
186 lines (147 loc) · 5.94 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# vim: filetype=just
mapbox_gl_js_version = "0.50.0"
server_address = "localhost:8889"
geocode_api_address = "localhost:8990"
route_api_address = "localhost:8989"
geocode_data_planet = "https://github.com/OSMNames/OSMNames/releases/download/v2.0.4/planet-latest_geonames.tsv.gz"
tile_api_address = "127.0.0.1:8991"
# Open Atlasr in your favorite browser.
open: install
open http://{{server_address}}
# Install Atlasr!
install: install-server install-api install-client
# Test Atlasr.
test: test-server test-client
# Uninstall Atlasr.
uninstall: uninstall-server uninstall-api uninstall-client
# Install the HTTP server.
install-server:
cd source/server && \
SERVER_ADDRESS={{server_address}} \
ROUTE_API_ADDRESS={{route_api_address}} \
GEOCODE_API_ADDRESS={{geocode_api_address}} \
TILE_API_ADDRESS={{tile_api_address}} \
cargo build --release
# Test the HTTP server.
test-server:
cd source/server && cargo test
# Uninstall the HTTP server.
uninstall-server:
rm -rf source/server/Cargo.lock source/server/target
# Run the HTTP server (will not exit).
run-server: install-server
cd source/server && cargo run --release
# Install all the APIs.
install-api: install-api-geocode install-api-route install-api-tile
# Uninstall all the APIs.
uninstall-api: uninstall-api-geocode uninstall-api-route
# Install the geocode API.
install-api-geocode: install-api-geocode-data install-api-geocode-indexer install-api-geocode-searcher
# Install/download data for the geocode API.
install-api-geocode-data: install-api-geocode-indexer
cd source/api/geocode && \
curl -L {{geocode_data_planet}} > planet.tsv.gz && \
gzip -df planet.tsv.gz && \
mkdir -p index && \
./indexer/target/release/atlasr-api-geocode-indexer --source-file planet.tsv --index-directory index
# Install the indexer for the geocode API.
install-api-geocode-indexer:
cd source/api/geocode/indexer && cargo build --release
# Install the searcher for the geocode API.
install-api-geocode-searcher:
cd source/api/geocode/searcher && \
GEOCODE_API_ADDRESS={{geocode_api_address}} \
cargo build --release
uninstall-api-geocode:
# noop
run-api-geocode-searcher:
cd source/api/geocode/searcher && cargo run --release
# Install the route API (GraphHopper).
install-api-route:
git submodule update --init source/api/route
# Uninstall the route API (GraphHopper).
uninstall-api-route:
# noop
# Run the route API (GraphHopper) for a particular PBF zone.
run-api-route map_file='europe_switzerland': install-api-route
cd source/api/route && ./graphhopper.sh web {{map_file}}.pbf
# Install the tile API.
install-api-tile:
cd source/api/tile && \
SERVER_ADDRESS={{server_address}} \
TILE_API_ADDRESS={{tile_api_address}} \
cargo build --release
# Run the tile API.
run-api-tile:
cd source/api/tile && cargo run --release
# Uninstall the tile API.
uninstall-api-tile:
# noop
#run-api-tile map_file='europe_switzerland': install-api-tile
# cd source/api/tile && \
# curl -L 'https://openmaptiles.com/download/WyJjOWUzNGM1NS04MDQxLTQ4MTMtYmUzMy0yNmFjMGUyN2I5MWIiLCItMSIsODcxM10.DsGknA.wk4qsZRjBSL8gQrp22h2CRpCyi4/osm-2017-07-03-v3.6.1-{{map_file}}.mbtiles?usage=open-source' > database/{{map_file}}.mbtiles
# Install client.
install-client: install-client-index install-client-application install-client-dependencies
# Test client.
test-client: test-client-application
# Uninstall client.
uninstall-client: uninstall-client-index uninstall-client-application
# Create a public `index.html` file.
SED_INPLACE_OPTION = "\"s@{MAP-PLACEHOLDER.svg}@`cat public/static/image/map-placeholder.svg | sed -E 's/^ +//g; s/\"/'\"'\"'/g; s/</%3c/g; s/>/%3e/g; s/\\#/%23/g' | tr -d \"\\n\"`@\""
install-client-index:
#!/bin/sh
cp source/client/src/index.html public/static/index.html
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' {{SED_INPLACE_OPTION}} public/static/index.html
else
sed -i {{SED_INPLACE_OPTION}} public/static/index.html
fi
# Remove the public `index.html` file.
uninstall-client-index:
rm -f public/static/index.html
# Compile the Elm application to JS.
install-client-application:
cd source/client && elm make src/Main.elm --optimize --output ../../public/static/javascript/application.elm.js
cd public/static/javascript && \
uglifyjs application.elm.js \
--compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | \
uglifyjs \
--mangle \
--output=application.min.elm.js && \
gzip --best --stdout application.min.elm.js > application.min.elm.js.gz && \
brotli --best --stdout application.min.elm.js > application.min.elm.js.br
# Test the Elm application.
test-client-application:
cd source/client && elm-test tests/unit/
# Remove the Elm build artifact.
uninstall-client-application:
rm -f public/static/javascript/application.elm.js
# Install client dependencies.
install-client-dependencies: install-mapbox-gl-js install-mapbox-gl-css
# Uninstall client dependencies.
uninstall-client-dependencies: uninstall-mapbox-gl-js uninstall-mapbox-gl-css
# Install Mapbox GL JS, so JS and SourceMap.
install-mapbox-gl-js:
cd public/static/javascript/ && \
curl -L https://api.tiles.mapbox.com/mapbox-gl-js/v{{mapbox_gl_js_version}}/mapbox-gl.js > mapbox-gl.js && \
curl -L https://api.tiles.mapbox.com/mapbox-gl-js/v{{mapbox_gl_js_version}}/mapbox-gl.js.map > mapbox-gl.js.map && \
uglifyjs \
--compress \
--mangle \
--output=mapbox-gl.min.js mapbox-gl.js && \
gzip --best --stdout mapbox-gl.min.js > mapbox-gl.min.js.gz && \
brotli --best --stdout mapbox-gl.min.js > mapbox-gl.min.js.br
# Install Mapbox GL CSS
install-mapbox-gl-css:
cd public/static/css/ && \
curl -L https://api.tiles.mapbox.com/mapbox-gl-js/v{{mapbox_gl_js_version}}/mapbox-gl.css > mapbox-gl.css
# Uninstall Mapbox GL JS.
uninstall-mapbox-gl-js:
rm public/static/javascript/mapbox-gl.js
rm public/static/javascript/mapbox-gl.js.map
# Uninstall Mapbox GL CSS.
uninstall-mapbox-gl-css:
rm public/static/css/mapbox-gl.css
# Local Variables:
# mode: makefile
# End: