tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.21k stars 290 forks source link

requests on tiles when enabled set to false #560

Closed michaelhornak closed 7 years ago

michaelhornak commented 7 years ago

Hi,

i want to ask about sending request on tiles behavior when layer option enabled is set to false. I assumed there should be no requests when every layer has enabled set to false, but I got requests on every source even if all layers a disabled and not visible in map.

Is there a way or option that has to be set to disable sending request on tiles? Or I would need to remove completely source and layer and then recreate it again when I need to show it on map.

Thanks.

bcamper commented 7 years ago

Currently, tiles are requested from a given data source if there is at least one top-level layer referencing that source (via the source parameter in the data block).

It shouldn't be difficult to restrict this so that tiles are omitted if enabled: false is set on all top-level layers that reference the data source.

However, if the top-level layer does not itself set enabled: false, we would likely not descend into all deeper layers to see if all of them are disabled (too much complexity for a relatively small savings in these cases).

For example, in the logic described above, this would NOT request tiles for the source names tiles:

layers:
  data: { source: tiles }
  enabled: false # disable this whole layer

However, the following case WOULD continue to request tiles for source tiles:

layers:
  data: { source: tiles }
  # enabled defaults to true, so top-level layer is enabled, but child layers may be disabled

  sublayer1:
     enabled: false
     ...
  sublayer2:
     enabled: false
     ...
michaelhornak commented 7 years ago

My scene.yaml looks like this:

How should I write it if for example knc layer should not send any requests?

sources:
    knc:
        type:"MVT"
        url:"http://12.1.0.4:3001/services/postgis/knc/geom/vector-tiles/{z}/{x}/{y}.pbf?fields=ku,parckey,drp"
    kne:
        type:"MVT"
        url:"http://12.1.0.4:3001/services/postgis/kne/geom/vector-tiles/{z}/{x}/{y}.pbf?fields=ku,parckey,drp"
layers: 
      knc_geom:
           data: { source: knc }
           enabled: false
           draw: xxx
      kne_geom:
           data: { source: kne }
           enabled: false
           draw: xxx
bcamper commented 7 years ago

That example would stop sending tile requests (as you want) if the changes I proposed above were implemented. To be clear, this is not the current behavior, but a change we can make for a future release.

bcamper commented 7 years ago

Addressed in e8b10e4a601dfcf0ab0daa9e49a7b26d4b80d8b8, will be released in v0.12.5

bcamper commented 7 years ago

Released in v0.12.5