cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Can the options in WebMapServiceImageryProvider support customTags field?

Open itancc opened this issue 10 months ago • 6 comments

Feature

Can the options in WebMapServiceImageryProvider support customTags field? I have an idea: on WebMapServiceImageryProvider source may be able to add some UrlTemplateImageryProvider options? image

itancc avatar Apr 24 '24 09:04 itancc

I commit a PR for this issue, I really need this change to facilitate my implementation of a feature,Many thanks.

itancc avatar Apr 25 '24 07:04 itancc

Hi @itancc! Thanks for the interest!

There is a parameters option which lets you append additional query parameters. Is that sufficient for your use? If not, could you please explain your use case a bit further?

ggetz avatar Apr 25 '24 17:04 ggetz

Oh, the parameters may not be suitable. For example, I need to modify the BBox parameters because I will be performing a coordinate transformation, so supporting customtags would be convenient for me to rewrite the bbox

itancc avatar Apr 25 '24 17:04 itancc

Here is some pseudo-code:

const imageryProvider = new WebMapServiceImageryProvider({
  parameters: {
    bbox: "{customBBox}",
  },
  // @ts-ignore
  customTags: {
    customBBox: (
      imageryProvider: ImageryProvider,
      x: number,
      y: number,
      level: number
    ) => {
    const rect = imageryProvider.tilingScheme.tileXYToRectangle(x, y, level);
      // here I can do some custom logic, like transforming the bounding box
      const customRect = transformBboxFunction(rect);
      return `${customRect.west},${customRect.south},${customRect.east},${customRect.north}`
    },
  },
});

itancc avatar Apr 25 '24 18:04 itancc

For example, I need to modify the BBox parameters because I will be performing a coordinate transformation,

Thanks @itancc. This may be a bit of an edge case in my opinion. Given that you're re-writing one of the existing parameters, it may be better for you to use UrlTemplateImageryProvider directly.

ggetz avatar Apr 26 '24 13:04 ggetz

I hope to make the most of some optimizations available in the existing WmsMapServiceImageryProvider, such as cache, which I find excellent! If I switch to using UrlTemplateImageryProvider, I might need to rewrite a whole set of code similar to WmsMapServiceImageryProvider. So, it would be convenient if such an option could be provided. Also, this shouldn't be disruptive, right?

itancc avatar Apr 26 '24 13:04 itancc