opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.66k stars 870 forks source link

[BUG] Vega maps visualization doesn't use custom WMS server #934

Open jcgraybill opened 2 years ago

jcgraybill commented 2 years ago

Describe the bug

The vega maps visualization only uses the default WMS tile server. If an admin overrides the default, that override is used for "region maps" visualizations but not vega maps visualizations.

To Reproduce Add to opensearch_dashboards.yml

map.includeOpenSearchMapsService: false map.tilemap.url: https://tiles.maps.opensearch.org/tiles/{z}/{x}/{y}.png map.tilemap.options.attribution: "Im a map"

Create a new Vega visualization.

{ $schema: https://vega.github.io/schema/vega/v5.json config: { kibana: {type: "map"} } data: [ ...

Expected behavior Displayed map should use the tile server, attribution, etc from opensearch_dashboards.yml

OpenSearch Version 1.1.0

Dashboards Version 1.1.0

Plugins Default installation

Additional context https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/src/plugins/vis_type_vega/public/vega_view

ahopp commented 2 years ago

@jcgraybill thanks for opening. Quick clarification: we're seeing an error "tmsServiceConfig is undefined" when trying to reproduce. Is this what you were seeing?

image

jcgraybill commented 2 years ago

I don't see that. See my screenshot... image

kavilla commented 2 years ago

I believe we might need to fork EMS Client. Will need to prioritize in that.

jcgraybill commented 2 years ago

Any update?

kavilla commented 2 years ago

Any update?

I have a private fork of the maps client that I'm current renaming.

kavilla commented 2 years ago

Followup, this is coming from the maps client but with forking there exist the issue that could change the expected behavior of the client.

Details:

It's failing because it can't find information within the provided TMS configurations provided. Within the client there exists this code that executes when includeOpenSearchMapsService is equal to false

 this._getMainCatalog = _.once(async (): Promise<OpenSearchMapsCatalogManifest> => {
      // Preserve manifestServiceUrl parameter for backwards compatibility with OpenSearchMaps v7.2
      if (this._manifestServiceUrl) {
        console.warn(`The "manifestServiceUrl" parameter is deprecated.
        Consider using "tileApiUrl" and "fileApiUrl" instead.`);
        return await this._getManifestWithParams(this._manifestServiceUrl);
      } else {
        const services = [];
        if (this._tileApiUrl) {
          services.push({
            type: 'tms',
            manifest: toAbsoluteUrl(this._tileApiUrl, `${this._opensearchMapsVersion}/manifest`),
          });
        }
        if (this._fileApiUrl) {
          services.push({
            type: 'file',
            manifest: toAbsoluteUrl(this._fileApiUrl, `${this._opensearchMapsVersion}/manifest`),
          });
        }
        return { services: services };
      }
    });

toAbsoluteUrl actually takes the value provided map.tilemap.url and tries to point it the the version of OpenSearch maps (which is defaulted to v7.10) + manifest. For example, in it's current stat it will try to make https://tiles.maps.opensearch.org/tiles/{z}/{x}/{y}.png to be https://tiles.maps.opensearch.org/v${mapsVersion}/manifest. Then the Maps Client attempts to get the manifest but fails since this does not exist. The actual value that this should be pointing to is https://maps.opensearch.org/tiles/v2.json. Then it would be able to get the value that OpenSearch Dashboards is expecting for example mapStyle being equal to road_map.

To work around this I was thinking add another configuration to allow for defining the manifest Url for tile maps and file maps, and I believe I was able to update the current maps visualizations but legacy map, ie map.tilemap, requires even more work.

Workaround proposal:

I think in the meantime to resolve this, I think if we can have if we can create a re-direct that points specifically https://tiles.maps.opensearch.org/v7.10/manifest to https://maps.opensearch.org/tiles/v2.json then using map.tilemap.url: https://tiles.maps.opensearch.org/tiles/{z}/{x}/{y}.png should work.