-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSLUX-698: [FIX] mvt urls #106
Changes from all commits
95c0ddf
db930d9
4f96fe8
9b66987
8f9be6d
5e5506f
6b11493
08d77a5
e394b7c
e48536c
e3c361c
de8417e
e155990
cb91777
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
# Proxy urls | ||
VITE_USE_PROXYURL=true | ||
VITE_PROXYURL_WMS="https://map.geoportail.lu/ogcproxywms" | ||
VITE_PROXYURL_REMOTE="https://map.geoportail.lu/httpsproxy" | ||
|
||
# Urls for vectortiles | ||
VITE_VECTORTILES_URL="https://vectortiles.geoportail.lu" | ||
|
||
# Paths for MVT styles | ||
VITE_MVTSTYLES_PATH_GET="/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="/uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="/deletevtstyle" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Proxy urls | ||
VITE_USE_PROXYURL=true | ||
VITE_PROXYURL_WMS="https://map.geoportail.lu/ogcproxywms" | ||
VITE_PROXYURL_REMOTE="https://map.geoportail.lu/httpsproxy" | ||
|
||
# Urls for vectortiles | ||
VITE_VECTORTILES_URL="https://vectortiles-staging.geoportail.lu" | ||
|
||
# Paths for MVT styles | ||
VITE_MVTSTYLES_PATH_GET="https://migration.geoportail.lu/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="https://migration.geoportail.lu/uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="https://migration.geoportail.lu/deletevtstyle" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
/out-tsc/ | ||
.parcel-cache | ||
.env | ||
.env.* | ||
|
||
# fixtures | ||
/src/__fixtures__/ | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
"build": "run-p type-check build-only", | ||
"build-only": "vite build", | ||
"build:lib:prod": "npx vite build --mode prod --config vite-dist.config.ts --minify=esbuild --debug && npx babel bundle/lux.dist.mjs --out-file bundle/lux.dist.js", | ||
"build:lib:dev": "npx vite build --mode dev --config vite-dist.config.ts --minify=false --base=/dev/main.html/ --debug && cp bundle/lux.dist.mjs bundle/lux.dist.js", | ||
"build:lib:dev": "npx vite build --mode staging --config vite-dist.config.ts --minify=false --base=/dev/main.html/ --debug && cp bundle/lux.dist.mjs bundle/lux.dist.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it would make sense to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use staging mode for npm start we would use |
||
"preview": "vite preview", | ||
"test": "npm run test:unit", | ||
"test:unit": "vitest --environment jsdom --root .", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
## Styling Vector Tiles | ||
|
||
## Introduction | ||
|
||
In the Luxembourg geoportal, map background styles can be customized by the user through the three components of the `style-selector`: | ||
|
||
- one component for simple mode, | ||
- one for medium mode, | ||
- and a final one for expert mode | ||
|
||
The styles modified by the user are saved or reloaded via `/getvtstyle`, `/uploadvtstyle`, `/deletevtstyle` and `vectortilesurl` requests. | ||
|
||
⚠️ Users styles are stored using file system on the luxembourg geoportal server https://map.geoportail.lu into a shared directory `VT_DIR`. The tile server https://vectortiles.geoportail.lu is able to retrieve styling info from this shared directory. | ||
|
||
This processing is done on the backend side, see legacy v3 code for more info: | ||
🔗 [Geoportail-Luxembourg/geoportailv3](https://github.com/Geoportail-Luxembourg/geoportailv3/blob/18ab23ff9cf1ac7fce4fc6a19cae71f1b94e0715/geoportal/geoportailv3_geoportal/views/upload.py#L18) | ||
|
||
⚠️ The https://vectortiles.geoportail.lu is mandatory to make the print and the 3D map work because both functionalities need raster images. | ||
|
||
⚠️ For dev purposes, we will be using https://migration.geoportail.lu and https://vectortiles-staging.geoportail.lu plateform instead. | ||
|
||
## 💡 How it works | ||
|
||
### Default styles `style.json` | ||
|
||
First, default styles are loaded for each vector background layers (currently, there are 3 background layers available), eg: | ||
|
||
- https://vectortiles.geoportail.lu/styles/roadmap/style.json | ||
- https://vectortiles.geoportail.lu/styles/topomap/style.json | ||
- https://vectortiles.geoportail.lu/styles/topomap_gray/style.json | ||
|
||
### User' styles | ||
|
||
- `/uploadvtstyle`: each time the user changes the vector tile style, the frontend sends the new style to the server. The new style is saved and a **new id is created and associated to this new style**. | ||
- `/getvtstyle`: given a style id, get the style content from the server. | ||
- `/deletevtstyle`: remove the associated style content from the server. | ||
|
||
## 🔧 Configure styles urls | ||
|
||
`/getvtstyle`, `/uploadvtstyle`, `/deletevtstyle` requests can be configured through `.env` (or `.env-staging`) variables: `VITE_MVTSTYLES_PATH_GET`, `VITE_MVTSTYLES_PATH_UPLOAD`, `VITE_MVTSTYLES_PATH_DELETE`. See below for details about .env configuration. | ||
|
||
It is also possible to override theses values by settings new urls using `useMvtStyles().setRegisterUrl_v3()`. This function is meant to be used by the legacy v3 version of Luxembourg geoportal. | ||
|
||
```js | ||
// MainController.js | ||
// Override urls on legacy v3 side: | ||
const mvtStyles = useMvtStyles() | ||
mvtStyles.setRegisterUrl_v3({ | ||
get: 'https://migration.geoportail.lu/getvtstyle', | ||
upload: 'https://migration.geoportail.lu/uploadvtstyle', | ||
delete: 'https://migration.geoportail.lu/deletevtstyle', | ||
vectortiles: 'https://vectortiles-staging.geoportail.lu', | ||
}) | ||
``` | ||
|
||
### Save styles on local dev server | ||
|
||
Style files will be saved on local dev server (v3 in docker environment). | ||
|
||
```sh | ||
# Urls for vectortiles | ||
VITE_VECTORTILES_URL="https://vectortiles-staging.geoportail.lu" | ||
|
||
# Paths for MVT styles | ||
VITE_MVTSTYLES_PATH_GET="https://localhost:8080/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="https://localhost:8080//uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="https://localhost:8080/deletevtstyle" | ||
``` | ||
|
||
same as using relative urls: | ||
|
||
```sh | ||
# Urls for vectortiles | ||
VITE_VECTORTILES_URL="https://vectortiles-staging.geoportail.lu" # ⚠️ NO VECTORTILES SERVER ON LOCAL DEV | ||
|
||
# Paths for MVT styles | ||
VITE_MVTSTYLES_PATH_GET="/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="/uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="/deletevtstyle" | ||
``` | ||
|
||
NB. Using relative urls is possible because proxy urls are defined in `vite.config.ts`. | ||
|
||
⚠️ There is no vectortiles server providing default `style.json` nor raster images on local dev, this is why you should always use `VITE_VECTORTILES_URL="https://vectortiles-staging.geoportail.lu"`. Raster images are used for 3D and printing. | ||
|
||
### Save styles on staging server | ||
|
||
```sh | ||
# Urls for vectortiles | ||
VITE_VECTORTILES_URL="https://vectortiles-staging.geoportail.lu" | ||
|
||
# Paths for MVT styles | ||
VITE_MVTSTYLES_PATH_GET="https://migration.geoportail.lu/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="https://migration.geoportail.lu/uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="https://migration.geoportail.lu/deletevtstyle" | ||
``` | ||
|
||
### Save styles on production server | ||
|
||
```sh | ||
# Urls for vectortiles | ||
VITE_VECTORTILES_URL="https://vectortiles.geoportail.lu" | ||
|
||
# Paths for MVT styles | ||
VITE_MVTSTYLES_PATH_GET="https://map.geoportail.lu/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="https://map.geoportail.lu/uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="https://map.geoportail.lu/deletevtstyle" | ||
``` | ||
|
||
### Relative urls | ||
|
||
You can also use relative urls if your environment allows it. | ||
|
||
```sh | ||
VITE_MVTSTYLES_PATH_GET="/getvtstyle" | ||
VITE_MVTSTYLES_PATH_UPLOAD="/uploadvtstyle" | ||
VITE_MVTSTYLES_PATH_DELETE="/deletevtstyle" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On local dev in v3 I get CORS errors for these. I'm wondering
"/getvtstyle"
and introduce a separate mode for gh-pagesFor option 1. I'm not sure where the calls to
localhost:8080/uploadvtstyle
actually end up. Do they stay locally, or are they forwarded to migration or prod somehow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it ends up to a 405, see gh-pages pointing on
main
:https://geoportail-luxembourg.github.io/luxembourg-geoportail/main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think gh-pages indeed needs https://migration.geoportail.lu/getvtstyle urls, since there is no local backend, but I was wondering about the calls on local dev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local calls are forwarded to
backendHost
which is defined asconst backendHost = 'http://localhost:8080'
https://github.com/Geoportail-Luxembourg/luxembourg-geoportail/blob/GSLUX-698-fix-mvt-urls/vite.config.ts#L40C24-L40C35
so if you have a v3 instance running locally listening on port 8080, it will be used