Skip to content
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

Feature request: define the contour source in a style file #81

Open
zstadler opened this issue Oct 3, 2023 · 2 comments
Open

Feature request: define the contour source in a style file #81

zstadler opened this issue Oct 3, 2023 · 2 comments

Comments

@zstadler
Copy link

zstadler commented Oct 3, 2023

Please enable defining the contour source in a style file rather than the need to code it in JavaScript.

For example, use this definition in a style file

            contours: {
              type: "contour",
              tiles: [“server.com/{z}/{x}/{y}.png”],
              multiplier: 3.28084,
              thresholds: {
                // zoom: [minor, major]
                11: [200, 1000],
                12: [100, 500],
                13: [100, 500],
                14: [50, 200],
                15: [20, 100],
              },
              elevationKey: "ele",
              levelKey: "level",
              contourLayer: "contours",
              maxzoom: 16,
            },

As the equivalent of this definition in JavaScript:

            contours: {
              type: "vector",
              tiles: [
                demSource.contourProtocolUrl({
                  // meters to feet
                  multiplier: 3.28084,
                  thresholds: {
                    // zoom: [minor, major]
                    11: [200, 1000],
                    12: [100, 500],
                    13: [100, 500],
                    14: [50, 200],
                    15: [20, 100],
                  },
                  elevationKey: "ele",
                  levelKey: "level",
                  contourLayer: "contours",
                }),
              ],
              maxzoom: 16,
            },

Also, is it also possible to define equivalents to DemSource() and sharedDemProtocolUrl that are used in index.html?

==== Note ====
The current alternative is to inline the results of demSource.contourProtocolUrl. For the above example, that would be:

            contours: {
              type: "vector",
              tiles: [
                "dem-contour://{z}/{x}/{y}?buffer=1&contourLayer=contours&elevationKey=ele&extent=4096&levelKey=level&multiplier=3.28084&thresholds=11*250*1000~14*200*800~15*100*400~16*50*200~17*20*100",
              ],
              maxzoom: 16,
            },

This issue is based on this Slack Message

@zstadler
Copy link
Author

zstadler commented Oct 3, 2023

Also, is it also possible to define equivalents to DemSource() and sharedDemProtocolUrl that are used in index.html?

Perhaps the definition of the contour source could include the name of the DEM source. For example:

          sources: {
            dem: {
              type: "raster-dem",
              encoding: "terrarium",
              tiles: [https://elevation-tiles-prod.s3.amazonaws.com/terrarium/{z}/{x}/{y}.png],
              maxzoom: 13,
              tileSize: 256,
            },
            contours: {
              type: "contour",
              demSource: "dem",
              multiplier: 3.28084,
              thresholds: {
                // zoom: [minor, major]
                11: [200, 1000],
                12: [100, 500],
                13: [100, 500],
                14: [50, 200],
                15: [20, 100],
              },
              elevationKey: "ele",
              levelKey: "level",
              contourLayer: "contours",
              maxzoom: 16,
            },
          },

@msbarry
Copy link
Contributor

msbarry commented Oct 3, 2023

Also, is it also possible to define equivalents to DemSource() and sharedDemProtocolUrl that are used in index.html?

Yes, you can just use: "dem-shared://{z}/{x}/{y}"

Perhaps the definition of the contour source could include the name of the DEM source. For example:

I think that config looks great, but it will be a complete rewrite using maplibre's addSourceType API:

https://github.com/maplibre/maplibre-gl-js/blob/a96db2f8ed9ba897eec76042ced0dd045ed9127a/src/ui/map.ts#L2055

It will likely require changes on maplibre side as well since that API is not very well documented and may require changes to maplibre to expose utilities like getting dem tiles from other sources. Overall it should improve things quite a bit though because it will let us run the contour-generation code in maplibre's workers and remove a lot of the code in this plugin for worker coordination, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants