MSFContourTileDataSource
Objective-C
@interface MSFContourTileDataSource : MSFTileDataSource
Swift
class MSFContourTileDataSource : MSFTileDataSource
A tile data source that generates vector contour lines on the fly from an RGB-encoded elevation (DEM) tile data source. The wrapped elevation data source is shared (e.g. with a HillshadeRasterTileLayer) so terrain tiles are fetched only once.
The generated tiles are standard Mapbox Vector Tiles containing a single line layer (default name “contour”). Each contour feature carries two attributes:
- ‘ele’: the contour elevation in meters.
- ‘div’: the largest “nice” divisor of the elevation (1000, 500, 250, 200, 100, 50, 20 or 10), matching the gdal_contour based pipeline. This lets CartoCSS filter contour importance by elevation, e.g. #contour[div=500][zoom>=12] { … }.
Attach the source to a normal VectorTileLayer to render lines and labels ([ele] as the label text) fully from the decoder style.
Note: this class is experimental and may change or even be removed in future SDK versions.
-
Constructs a ContourTileDataSource object.
Declaration
Objective-C
- (id)initWithDataSource:(MSFTileDataSource *)dataSource elevationDecoder:(MSFElevationDecoder *)elevationDecoder;Swift
init!(dataSource: MSFTileDataSource!, elevationDecoder: MSFElevationDecoder!)Parameters
dataSourceThe RGB-encoded elevation data source to generate contours from.
elevationDecoderThe decoder used to convert RGB pixels to elevation. If null, the decoder is inferred from the data source ‘encoding’ metadata (defaults to terrarium).
-
Constructs a ContourTileDataSource object, inferring the elevation decoder from the data source ‘encoding’ metadata (defaults to terrarium).
Declaration
Objective-C
- (id)initWithDataSource:(MSFTileDataSource *)dataSource;Swift
init!(dataSource: MSFTileDataSource!)Parameters
dataSourceThe RGB-encoded elevation data source to generate contours from.
-
Returns the name of the generated vector tile layer.
Declaration
Objective-C
- (NSString *)getLayerName;Swift
func getLayerName() -> String!Return Value
The layer name. The default is “contour”.
-
Sets the name of the generated vector tile layer. This must match the layer id used in the CartoCSS style.
Declaration
Objective-C
- (void)setLayerName:(NSString *)name;Swift
func setLayerName(_ name: String!)Parameters
nameThe layer name.
-
Returns the base contour interval in meters.
Declaration
Objective-C
- (float)getBaseInterval;Swift
func getBaseInterval() -> FloatReturn Value
The base contour interval in meters. The default is 10.
-
Sets the base contour interval in meters. This is the FINEST interval generated; coarser tile zooms generate a multiple of it, see setIntervalMultiplier.
Declaration
Objective-C
- (void)setBaseInterval:(float)interval;Swift
func setBaseInterval(_ interval: Float)Parameters
intervalThe base contour interval in meters.
-
Sets the interval multiplier used at tile zooms up to (and including) maxZoom. A tile carries every elevation that is a multiple of BaseInterval x multiplier, and each contour carries ‘div’ so the style picks per camera zoom which of them to draw.
The default table is (9, 50), (11, 10), (13, 5), (any, 1): 500m, 100m, 50m, 10m for a 10m base.
TWO RULES when changing it:
- the multipliers must NEST - each one a multiple of the finer ones - or a line stops dead at the border between tiles of different zoom (200 and 500 share no elevation);
- cost tracks the number of contours emitted, so a multiplier twice as fine is about twice the tracing, the geometry and the draw. Make it no finer than what the style actually draws at the camera zoom where tiles of that zoom are used.
Declaration
Objective-C
- (void)setIntervalMultiplier:(int)maxZoom multiplier:(float)multiplier;Swift
func setIntervalMultiplier(_ maxZoom: Int32, multiplier: Float)Parameters
maxZoomThe highest tile zoom this multiplier applies to, or -1 for every zoom above the other entries.
multiplierThe multiplier of BaseInterval, >= 1.
-
Returns the interval multiplier that applies at the given tile zoom.
Declaration
Objective-C
- (float)getIntervalMultiplier:(int)zoom;Swift
func getIntervalMultiplier(_ zoom: Int32) -> FloatParameters
zoomThe tile zoom.
Return Value
The multiplier of BaseInterval.
-
Removes every interval multiplier entry, so BaseInterval is used at every zoom.
Declaration
Objective-C
- (void)clearIntervalMultipliers;Swift
func clearIntervalMultipliers() -
Returns the target grid resolution used for contour tracing.
Declaration
Objective-C
- (int)getResolution;Swift
func getResolution() -> Int32Return Value
The target grid resolution, 0 for the DEM’s own. The default is 128.
-
Sets the target grid resolution used for contour tracing. The DEM is subsampled so that the traced grid is at most this many samples per side. Lower values produce coarser but much cheaper geometry (fewer vertices to trace, simplify, upload and drape over terrain). Over 3D TERRAIN use 0 (the DEM’s own resolution): the surface is displaced by every texel of the same tile, so a line traced on a subsampled grid follows a height field the ground does not have and cuts through everything between its samples.
Declaration
Objective-C
- (void)setResolution:(int)resolution;Swift
func setResolution(_ resolution: Int32)Parameters
resolutionThe target grid resolution (clamped to at least 8), or 0 for the DEM’s own.
-
Sets the tracing grid resolution used at tile zooms up to (and including) maxZoom, overriding Resolution there. Tracing cost is roughly quadratic in this, and a low zoom tile covers so much ground that a fine grid buys nothing, so this is the cheapest knob to turn for zoomed-out frames - but a costly one for QUALITY: a tile is drawn at roughly the same screen size whatever its zoom, so a grid that shrinks with zoom puts contour vertices hundreds of metres apart and the lines read as straight chords. Empty by default for that reason: Resolution applies at every zoom, and low zoom saves through the interval instead.
Declaration
Objective-C
- (void)setResolutionForZoom:(int)maxZoom resolution:(int)resolution;Swift
func setResolutionForZoom(_ maxZoom: Int32, resolution: Int32)Parameters
maxZoomThe highest tile zoom this resolution applies to, or -1 for every zoom above the other entries.
resolutionThe target grid resolution (clamped to at least 8), or 0 for the DEM’s own.
-
Returns the tracing grid resolution that applies at the given tile zoom.
Declaration
Objective-C
- (int)getResolutionForZoom:(int)zoom;Swift
func getResolutionForZoom(_ zoom: Int32) -> Int32Parameters
zoomThe tile zoom.
Return Value
The target grid resolution, 0 for the DEM’s own.
-
Removes every per-zoom resolution entry, so Resolution is used at every zoom.
Declaration
Objective-C
- (void)clearResolutionsForZoom;Swift
func clearResolutionsForZoom() -
Returns the minimum zoom at which contour geometry is generated.
Declaration
Objective-C
- (int)getMinVisibleZoom;Swift
func getMinVisibleZoom() -> Int32Return Value
The minimum contour zoom. The default is 12.
-
Sets the minimum zoom at which contour geometry is generated. Below this zoom loadTile returns an empty (but valid) tile without fetching or tracing the DEM. Note: in CartoCSS ‘zoom’ means the TILE zoom, so the style must also draw the desired zoom range for contours to actually appear.
Declaration
Objective-C
- (void)setMinVisibleZoom:(int)zoom;Swift
func setMinVisibleZoom(_ zoom: Int32)Parameters
zoomThe minimum contour zoom.
-
Returns whether seamless tile edges are enabled.
Declaration
Objective-C
- (BOOL)isSeamlessEdgesEnabled;Swift
func isSeamlessEdgesEnabled() -> BoolReturn Value
True if seamless edges are enabled. The default is true.
-
Sets whether to generate seamless tile edges. When enabled, the east/north/north-east neighbour DEM tiles are fetched so that a tile’s east and north edges use the exact same elevation samples as the adjacent tiles, removing the small gaps where contour lines meet at tile boundaries. This costs up to three extra DEM tile fetches/decodes per tile (they are usually cached).
Declaration
Objective-C
- (void)setSeamlessEdgesEnabled:(BOOL)enabled;Swift
func setSeamlessEdgesEnabled(_ enabled: Bool)Parameters
enabledTrue to enable seamless edges.
-
Returns the terrain options whose elevation manager the label stubs read.
Declaration
Objective-C
- (MSFTerrainOptions *)getTerrainOptions;Swift
func getTerrainOptions() -> MSFTerrainOptions!Return Value
The terrain options, or null.
-
Sets the terrain options whose ELEVATION MANAGER the label stubs are generated from. With it, a stub tile costs no tile of its own: the seeds are walked over the elevation grid the 3D terrain has already fetched and decoded for that tile, which is how tangram generates contour labels (core/src/style/contourTextStyle.cpp reads the tile’s own elevation raster). Without it, the source loads and decodes the DEM tile a second time - measured at 44% of a tile decode thread, half of it in the image decode alone.
The terrain options must be driven by the SAME elevation data source this tile source wraps, or the labels state heights the map does not show. Only the stubs use it; traced contour geometry keeps reading the DEM at its own resolution, which the terrain’s mesh-capped elevation level cannot supply.
Declaration
Objective-C
- (void)setTerrainOptions:(MSFTerrainOptions *)terrainOptions;Swift
func setTerrainOptions(_ terrainOptions: MSFTerrainOptions!)Parameters
terrainOptionsThe terrain options, or null to decode a DEM tile of our own.
-
Returns whether only short label stubs are generated instead of full contour lines.
Declaration
Objective-C
- (BOOL)isLabelStubsEnabled;Swift
func isLabelStubsEnabled() -> BoolReturn Value
True if label stubs are generated. The default is false.
-
Sets whether to generate short label stubs instead of full contour lines. A stub is a ~20 point polyline lying ON a contour, long enough to lay the elevation text along and nothing more: a grid of 4x4 seeds per tile is walked down the elevation gradient onto the nearest contour level and then along it. The tile then carries a handful of tiny features instead of the full traced geometry, which is what makes the labels affordable when the contour LINES are drawn by the terrain shader (HillshadeRasterTileLayer.setContourEnabled) rather than from this geometry.
The features keep the same layer name and the same ‘ele’/‘div’ attributes, so the existing text rules style them unchanged; they additionally carry ‘stub’ = 1, so a style that also draws contour LINES from this layer can exclude them with a [stub=0] filter.
The stub levels must match the levels the shader draws, or the labels sit between the lines: set LabelInterval to the layer’s ContourInterval (or leave both at their zoom defaults).
Declaration
Objective-C
- (void)setLabelStubsEnabled:(BOOL)enabled;Swift
func setLabelStubsEnabled(_ enabled: Bool)Parameters
enabledTrue to generate label stubs only.
-
Returns the contour interval used for label stubs.
Declaration
Objective-C
- (float)getLabelInterval;Swift
func getLabelInterval() -> FloatReturn Value
The label interval in meters, or 0 to follow the zoom-dependent interval. The default is 0.
-
Sets the contour interval used for label stubs, in meters. Use 0 to follow the same zoom-dependent interval the traced geometry uses.
Declaration
Objective-C
- (void)setLabelInterval:(float)interval;Swift
func setLabelInterval(_ interval: Float)Parameters
intervalThe label interval in meters.
-
Returns the simplification tolerance in tile pixels.
Declaration
Objective-C
- (float)getSimplifyTolerance;Swift
func getSimplifyTolerance() -> FloatReturn Value
The simplification tolerance in tile pixels. The default is 1.0.
-
Sets the simplification tolerance in tile pixels. Use 0.0 to disable simplification.
Declaration
Objective-C
- (void)setSimplifyTolerance:(float)tolerance;Swift
func setSimplifyTolerance(_ tolerance: Float)Parameters
toleranceThe simplification tolerance in tile pixels.
-
Undocumented
Declaration
Objective-C
- (int)getMinZoom;Swift
func getMinZoom() -> Int32 -
Undocumented
Declaration
Objective-C
-(int)getMinZoomSwigExplicitMSFContourTileDataSource;Swift
func getMinZoomSwigExplicitMSFContourTileDataSource() -> Int32 -
Undocumented
Declaration
Objective-C
- (int)getMaxZoom;Swift
func getMaxZoom() -> Int32 -
Undocumented
Declaration
Objective-C
-(int)getMaxZoomSwigExplicitMSFContourTileDataSource;Swift
func getMaxZoomSwigExplicitMSFContourTileDataSource() -> Int32 -
Undocumented
Declaration
Objective-C
- (MSFMapBounds *)getDataExtent;Swift
func getDataExtent() -> MSFMapBounds! -
Undocumented
Declaration
Objective-C
-(MSFMapBounds*)getDataExtentSwigExplicitMSFContourTileDataSource;Swift
func getDataExtentSwigExplicitMSFContourTileDataSource() -> MSFMapBounds! -
Undocumented
Declaration
Objective-C
- (NSString *)getContainerMetaData:(NSString *)key;Swift
func getContainerMetaData(_ key: String!) -> String! -
Undocumented
Declaration
Objective-C
-(NSString*)getContainerMetaDataSwigExplicitMSFContourTileDataSource: (NSString*)key;Swift
func getContainerMetaDataSwigExplicitMSFContourTileDataSource(_ key: String!) -> String! -
Undocumented
Declaration
Objective-C
- (MSFTileData *)loadTile:(MSFMapTile *)tile;Swift
func load(_ tile: MSFMapTile!) -> MSFTileData! -
Undocumented
Declaration
Objective-C
-(MSFTileData*)loadTileSwigExplicitMSFContourTileDataSource: (MSFMapTile*)tile;Swift
func loadTileSwigExplicitMSFContourTileDataSource(_ tile: MSFMapTile!) -> MSFTileData! -
Undocumented
Declaration
Objective-C
-(void)dealloc;Swift
func dealloc()