practiced the followings: • VT consumption in GIS tools like QGIS. • Simple VT tile styling. • VT hosting as static file. • VT data conversion. • Simple conversion • Advanced conversion with nodejs Today’s content: • Vector tile hosting • Delivering VT from mbtiles. You can launch your local server today. This means that you can consume your VT even without the access to the Internet.
a vector tile server in your local environment. • Part 2: Explanation how we can add Azure AD authentication to the server. Produce Host Style Optimize Import UNVT workflow of developing vector tile for base map Supported by UNVT, open source scripts Source DB Web APP Users Our focus today.
is mainly for the windows users. • Can you use nodejs (ver 12.x) in your CLI? → If yes, you do not have to use Docker (unvt/nanban) → If no, let’s use Docker. Tips: You may remember, for data conversion, a windows user may need to use Docker (or WSL) to run the conversion tool “Tippecanoe.” But for hosting, nodejs is good enough. Tips: Let’s use nodejs ver. 12.x. Ver. 13 or later may not work well with certain package we use.
the MS Teams channel. Or download it at https://github.com/unvt/ezPrac (ex4-data) * mbtiles is not included in GitHub repository • Start command prompt (I used Windows Powershell), and move to the working directory.
nodejs, we will establish a vector tile hosting server in local environment. • Port: 8836 (try http://localhost:8836/index.html when done) • Static hosting directory: htdocs • Log directory: log • Mbtiles Directory: mbtiles • Pbf file is delivered from mbtiles. • Confirm there is no pbf tile in the folders. We have only one mbitles file in the mbtiles directory. • The tile will served from http://localhost:8836/zxy/(mbtiles name)/{z}/{x}/{y}.pbf. • We will see our web map there. • http://localhost:8836/zxy/(mbtiles name)/{z}/{x}/{y}.pbf.
Docker, skip the first three lines.) • Then, start Docker (unvt/nanban), install tools > docker pull unvt/nanban > docker run -it --rm -v ${PWD}:/data -p 8836:8836 unvt/nanban > cd /data > npm install > npm install sqlite3 Here, I do not explain the preparation of the Docker environment. Please see https://docs.docker.com/docker-for-windows/install/ Tips: This time, you are specifying the port. Tips: Sqlite3 may be needed
confirm: • If you are at the exercise directory and can see all necessary files • Move to /data and check if you can see “package.json” • Try “node –version ” to see if you can use nodejs. (ver 12.x)
config directory. For this practice, you can use the current setting as is. • We do not have to care all components, but you can specify: • static hosting folder (htdocsPath), • Mbtiles directory (mbtilesDir), • log directory (logDirPath), • port for http, etc. • If you want to use https instead of http, please edit SSL/TLS key locations, store them in that place, and edit app.js.
> node app.js * Ctrl + c to stop • Access the index.html to confirm if the server is working. http://localhost:8836/index.html • Try if you can download VT. http://localhost:8836/zxy/clearm ap-test/1/1/1.pbf * If there is a mbtiles file, pbf files are generated from it.
(nodejs/express) and host a static contents in htdocs. • We are using @mapbox/mbtiles package, and pbf files are generated from the source mbtiles to be delivered upon requests. Vector Tile Server (nodejs/express) Style VT in mbtiles VT in pbf library Font, etc. htdocs folder (static) Mbtiles folder Tips: If the data is small, you can simply load VT as pbf data (a static content).
just for internal practice. I do not upload this file to GitHub. Now you can make VT, style, html, etc. by yourself. So, you can make your own web map APP.
and map APP? • Make your vector tiles (pbf / mbtile) and put it to the folders: • pbf format: static hosting at “htdocs” → http://localhost:8836/(foldername)/{z}/{x}/{y}.pbf • mbtiles format: Store it at “mbtiles” to be delivered as pbf upon requested → http://localhost:8836/zxy/(filename)/{z}/{x}/{y}.pbf • You can also add style, fonts, html files, js libraries at htdocs folder. • Please review previous exercise if necessary. • How to prepare style file for a web map • How to prepare html file for a web map
operation. • Run nodejs server using PM2 so that we can run it as a deamon process. • If you use Linux server, using crontab to re-start the server regularly would be a good idea. • Increase the source • We may use more than one mbtiles file for certain source.(e.g. our prototype has 841 mbtiles for a single source covering the whole globe). We can use module approach. Please look at https://github.com/un-vector-tile-toolkit/onyx
vector tile hosting server in local environment. • We can deliver pbf files, generated from mbtiles, from the hosting server. • We can now make our own web map app by: • Preparing vector tile, • Designing style, • Preparing html and other necessary files
of standard authentication used in UN. How? • There is a good tutorial of deploying Azure AD authentication with nodejs/express server. • https://docs.microsoft.com/en- us/graph/tutorials/node?WT.mc_id=Portal- Microsoft_AAD_RegisteredApps&tutorial-step=3
a routing for VT delivery For Static hosting You can add vector tile delivery script here But, preparing this by yourself would be tough work… So, let’s do with an easier way.
with Azure AD authentication for actual use) https://github.com/un-vector-tile- toolkit/coesite • UNVT azure-onyx2: Simpler than coesite https://github.com/un-vector-tile- toolkit/azure-onyx2