The Scale Filters
When you create a map, you may want one manager layer displaying a certain type of information to be visible only at a given scale. For example, concerning a roadway infrastructure, you may want the secondary roads to be visible only if the map is sufficiently zoomed so that the map is not overloaded at a small scale.
The Layers window in the Views Map Builder provides a scale filtering command. However, you can also perform scale filtering using the IlvScaleVisibilityFilter class. This class is an extension of the general class IlvLayerVisibilityFilter of Views 4.0 that has been customized for cartography.
The following is an example of code specifying that a layer be visible only when the scale factor is between 1/100,000 and 1/500,000:
IlvScaleVisibilityFilter* filter = new IlvScaleVisibilityFilter(1./500000., 1./100000.); layer->addVisibilityFilter(filter); |
The IlvScaleVisibilityFilter constructor takes two scales factors as argument. The layer will be visible if the scale of the manager layer lies between these two values. You can also pass a value of NoLimit() as a scale value if you want to discard the checking for this limit. The scale of the manager layer is computed using the IlvMapInfo attached to the manager, which indicates the unit of measurement in which the manager coordinates are expressed (meters, centimeters, yards or other). Scales are computed according to the unit of measurement set for the manager holding the layer.
The following code example specifies that a layer is only visible for scales inferior to 1f/500,000.
IlvScaleVisibilityFilter* scaleFilter = new IlvScaleVisibilityFilter(IlvScaleVisibilityFilter::NoLimit(), 1./500000.); layer->addVisibilityFilter(scaleFilter); |
Visibility filters attached to a layer are automatically saved to an .ilv file.