MSFTerrainOptions

Objective-C


@interface MSFTerrainOptions : NSObject {
  void *swigCPtr;
  BOOL swigCMemOwn;
}

Swift

class MSFTerrainOptions : NSObject

3D terrain configuration, attached to the map via Options::setTerrainOptions. The elevation data source can be shared with a HillshadeRasterTileLayer (wrap it in a MemoryCacheTileDataSource to avoid duplicate loads). Note: this class is experimental and may change or even be removed in future SDK versions.

  • Constructs a TerrainOptions object from an elevation data source. The elevation decoder is resolved from the data source “encoding” setting (“mapbox” or “terrarium”), defaulting to the MapBox encoding.

    Declaration

    Objective-C

    - (id)initWithDataSource:(MSFTileDataSource *)dataSource;

    Swift

    init!(dataSource: MSFTileDataSource!)

    Parameters

    dataSource

    The data source with RGB-encoded elevation tiles.

  • Constructs a TerrainOptions object from an elevation data source and an explicit decoder.

    Declaration

    Objective-C

    - (id)initWithDataSource:(MSFTileDataSource *)dataSource
            elevationDecoder:(MSFElevationDecoder *)elevationDecoder;

    Swift

    init!(dataSource: MSFTileDataSource!, elevationDecoder: MSFElevationDecoder!)

    Parameters

    dataSource

    The data source with RGB-encoded elevation tiles.

    elevationDecoder

    The decoder for the elevation tile encoding.

  • Returns the elevation data source.

    Declaration

    Objective-C

    - (MSFTileDataSource *)getDataSource;

    Swift

    func getDataSource() -> MSFTileDataSource!

    Return Value

    The elevation data source.

  • Returns the elevation decoder used as the source-level default. Each tile resolves its own decoder from its “dem_encoding” meta data, so two data sources of different encodings can be combined behind one OrderedTileDataSource.

    Declaration

    Objective-C

    - (MSFElevationDecoder *)getElevationDecoder;

    Swift

    func getElevationDecoder() -> MSFElevationDecoder!

    Return Value

    The default elevation decoder.

  • Returns the enabled state of the terrain.

    Declaration

    Objective-C

    - (BOOL)isEnabled;

    Swift

    func isEnabled() -> Bool

    Return Value

    True if 3D terrain rendering is enabled. The default is true.

  • Sets the enabled state of the terrain. If disabled, the map renders flat, but the elevation data source stays attached.

    Declaration

    Objective-C

    - (void)setEnabled:(BOOL)enabled;

    Swift

    func setEnabled(_ enabled: Bool)

    Parameters

    enabled

    The new enabled state.

  • Returns whether the map is asked to render flat. This is the 2D/3D state, whether it was set by the app or by auto-flattening; the switch itself is animated, so for a moment after a change the map is still on its way there.

    Declaration

    Objective-C

    - (BOOL)isFlattened;

    Swift

    func isFlattened() -> Bool

    Return Value

    True if the map is flat, or on its way to flat. The default is false.

  • Switches the map between flat and 3D terrain without detaching the elevation data (unlike setEnabled). Auto-flattening writes the same state, so an app driving this normally sets both AutoFlatten thresholds to 0. An app that starts in 2D sets this before it adds its layers, so nothing decodes for 3D.

    Declaration

    Objective-C

    - (void)setFlattened:(BOOL)flattened;

    Swift

    func setFlattened(_ flattened: Bool)

    Parameters

    flattened

    True to render flat.

  • Returns how far a flattened terrain goes back towards a plain 2D map.

    Declaration

    Objective-C

    - (enum MSFTerrainFlattenMode)getFlattenMode;

    Swift

    func getFlattenMode() -> MSFTerrainFlattenMode

    Return Value

    The flatten mode. The default is TERRAIN_FLATTEN_MODE_RENDER.

  • Sets how far a flattened terrain goes back towards a plain 2D map: RENDER only stops the terrain passes; FULL also drops the 3D subdivision, re-decoding the visible tiles at each switch (invisibly, while flat). Going back to 3D waits for the tiles it needs before it starts to rise.

    Declaration

    Objective-C

    - (void)setFlattenMode:(enum MSFTerrainFlattenMode)mode;

    Swift

    func setFlattenMode(_ mode: MSFTerrainFlattenMode)

    Parameters

    mode

    The new flatten mode.

  • Returns how far the terrain is flattened right now, 0 (full 3D) to 1 (flat).

    Declaration

    Objective-C

    - (float)getFlattenRatio;

    Swift

    func getFlattenRatio() -> Float

    Return Value

    The flatten ratio.

  • Drives the 2D/3D switch by hand (0 full 3D, 1 flat), e.g. from a camera flight’s own progress. Auto-flattening stays suspended until setFlattened hands the ratio back, so call it once at the end. Below 1 the ground is held flat until the 3D tiles arrive; wait on isSwitching() before starting the animation.

    Declaration

    Objective-C

    - (void)setFlattenRatio:(float)ratio;

    Swift

    func setFlattenRatio(_ ratio: Float)

    Parameters

    ratio

    The new flatten ratio, 0 to 1.

  • Returns whether the switch is holding the ground flat while the tiles 3D needs load.

    Declaration

    Objective-C

    - (BOOL)isSwitching;

    Swift

    func isSwitching() -> Bool

    Return Value

    True while the switch is waiting for tiles.

  • Returns the screen parallax below which the terrain renders flat.

    Declaration

    Objective-C

    - (float)getAutoFlattenParallax;

    Swift

    func getAutoFlattenParallax() -> Float

    Return Value

    The parallax in screen pixels. The default is 2. 0 never flattens.

  • Sets the parallax in screen pixels (halfScreenDiagonal * heightRange * exaggeration / cameraDistance) below which the map renders flat; it writes the same state setFlattened does. Restores at 1.5x this value, so a camera sitting on the boundary does not oscillate.

    Declaration

    Objective-C

    - (void)setAutoFlattenParallax:(float)pixels;

    Swift

    func setAutoFlattenParallax(_ pixels: Float)

    Parameters

    pixels

    The new parallax threshold in screen pixels, or 0 to never flatten. The default is 2.

  • Returns the tilt at or above which the terrain renders flat.

    Declaration

    Objective-C

    - (float)getAutoFlattenTilt;

    Swift

    func getAutoFlattenTilt() -> Float

    Return Value

    The tilt in degrees. The default is 88. 0 never flattens.

  • Sets the tilt, in degrees, at or above which the map renders flat whatever the parallax. 90 is straight down in this SDK, where the displacement is there but shows nothing worth its cost. Restores 2 degrees below the threshold, so a tilt gesture does not oscillate.

    Declaration

    Objective-C

    - (void)setAutoFlattenTilt:(float)tilt;

    Swift

    func setAutoFlattenTilt(_ tilt: Float)

    Parameters

    tilt

    The new tilt threshold in degrees, or 0 to never flatten. The default is 88.

  • Returns how long the terrain takes to sink flat.

    Declaration

    Objective-C

    - (float)getAutoFlattenDuration;

    Swift

    func getAutoFlattenDuration() -> Float

    Return Value

    The duration in seconds. The default is 0.3.

  • Sets how long the terrain takes to sink flat, and to rise unless setAutoFlattenRiseDuration overrides it. The ramp scales heights on the GPU (no re-decode); the wait for the tiles 3D needs is not included.

    Declaration

    Objective-C

    - (void)setAutoFlattenDuration:(float)duration;

    Swift

    func setAutoFlattenDuration(_ duration: Float)

    Parameters

    duration

    The new duration in seconds. 0 switches instantly.

  • Returns how long the terrain takes to rise back into 3D.

    Declaration

    Objective-C

    - (float)getAutoFlattenRiseDuration;

    Swift

    func getAutoFlattenRiseDuration() -> Float

    Return Value

    The duration in seconds, or a negative value to follow getAutoFlattenDuration.

  • Sets how long the terrain takes to rise, separately from sinking. To match a camera flight exactly, drive setFlattenRatio instead: a duration is a second timer.

    Declaration

    Objective-C

    - (void)setAutoFlattenRiseDuration:(float)duration;

    Swift

    func setAutoFlattenRiseDuration(_ duration: Float)

    Parameters

    duration

    The new duration in seconds, or a negative value to use setAutoFlattenDuration.

  • Returns the terrain height exaggeration factor.

    Declaration

    Objective-C

    - (float)getExaggeration;

    Swift

    func getExaggeration() -> Float

    Return Value

    The exaggeration factor. The default is 1.0.

  • Sets the terrain height exaggeration factor. 1.0 means true-to-scale heights. Note: changing the exaggeration triggers a re-tesselation of loaded tiles, which is a relatively expensive operation.

    Declaration

    Objective-C

    - (void)setExaggeration:(float)exaggeration;

    Swift

    func setExaggeration(_ exaggeration: Float)

    Parameters

    exaggeration

    The new exaggeration factor.

  • Returns whether seamless tile edge handling is enabled.

    Declaration

    Objective-C

    - (BOOL)isSeamlessTileEdgesEnabled;

    Swift

    func isSeamlessTileEdgesEnabled() -> Bool

    Return Value

    True if elevation textures take their border texels from neighbouring DEM tiles at any level. The default is true.

  • Enables or disables seamless tile edges: each elevation texture’s 1-texel border is taken from the neighbouring DEM tiles (coarser ones sampled), so adjacent tiles agree on edge height. No IO, a little CPU. Disable if the elevation tiles already match exactly across tile borders.

    Declaration

    Objective-C

    - (void)setSeamlessTileEdgesEnabled:(BOOL)enabled;

    Swift

    func setSeamlessTileEdgesEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to fill elevation texture borders from neighbouring tiles.

  • Returns whether elevation tile prefetching is enabled.

    Declaration

    Objective-C

    - (BOOL)isElevationPrefetchEnabled;

    Swift

    func isElevationPrefetchEnabled() -> Bool

    Return Value

    True if visible tiles and their neighbours are requested from the elevation data source. The default is true.

  • Enables or disables elevation prefetching: each visible terrain tile requests its own elevation tile and the 8 around it, so neighbours share a DEM level; off, cached map tiles stay on coarser ancestor data. Costs requests, decoding and cache pressure; disable for minimal traffic or a fully local tileset.

    Declaration

    Objective-C

    - (void)setElevationPrefetchEnabled:(BOOL)enabled;

    Swift

    func setElevationPrefetchEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to prefetch elevation tiles for visible tiles and their neighbours.

  • Returns the terrain mesh resolution.

    Declaration

    Objective-C

    - (int)getMeshResolution;

    Swift

    func getMeshResolution() -> Int32

    Return Value

    The maximum number of grid cells per tile edge used for terrain geometry. The default is 64.

  • Sets the terrain mesh resolution. Higher values give more detailed terrain at the cost of memory and CPU. The effective resolution is also limited by the resolution of the elevation tiles.

    Declaration

    Objective-C

    - (void)setMeshResolution:(int)meshResolution;

    Swift

    func setMeshResolution(_ meshResolution: Int32)

    Parameters

    meshResolution

    The new mesh resolution (clamped to 2..1024).

  • Returns the distance geo-three’s terrain LOD subdivides at.

    Declaration

    Objective-C

    - (float)getSubdivideDistance;

    Swift

    func getSubdivideDistance() -> Float

    Return Value

    Mercator metres at zoom 20, or 0 while the SDK’s own rule is in use. The default is 0.

  • Cuts and meshes the terrain the way geo-three’s webapp does, so the two render the same picture: a tile at zoom z subdivides while the camera is closer than distance * 2^(20 - z) Mercator metres (geo-three’s desktop value is 70), with no tile budget and bilinear DEM heights.

    Declaration

    Objective-C

    - (void)setSubdivideDistance:(float)distance;

    Swift

    func setSubdivideDistance(_ distance: Float)

    Parameters

    distance

    Mercator metres at zoom 20, or 0 for the SDK’s own rule.

  • Returns the resolution the elevation node field is built at.

    Declaration

    Objective-C

    - (int)getSurfaceNodeResolution;

    Swift

    func getSurfaceNodeResolution() -> Int32

    Return Value

    Node field cells per tile edge, or 0 to follow MeshResolution. The default is 0.

  • Sets the resolution of the height field the terrain is displaced from, per DEM tile edge, independently of the mesh drawn over it. Overzoomed, this field limits the relief, not the mesh. Costs memory per cached DEM grid, not frames. The default 0 follows MeshResolution. Applied to the elevation manager at once, not on the first 3D frame, so no decoded grid is dropped mid-switch.

    Declaration

    Objective-C

    - (void)setSurfaceNodeResolution:(int)resolution;

    Swift

    func setSurfaceNodeResolution(_ resolution: Int32)

    Parameters

    resolution

    Node cells per tile edge (clamped to 2..512), or 0 to follow MeshResolution.

  • Returns the downscale factor of the packed depth/normal texture post-process effects read.

    Declaration

    Objective-C

    - (int)getPostProcessDownscale;

    Swift

    func getPostProcessDownscale() -> Int32

    Return Value

    The divisor applied to the screen size for that buffer. The default is 2.

  • Sets the downscale factor of the packed depth/normal texture that post-process effects read. The default 2 suits shading; an effect that differentiates the normals (ridge lines) shows blocky texels, which 1 removes at four times the fill. The occlusion read-back is unaffected.

    Declaration

    Objective-C

    - (void)setPostProcessDownscale:(int)downscale;

    Swift

    func setPostProcessDownscale(_ downscale: Int32)

    Parameters

    downscale

    The new downscale factor (clamped to 1..4).

  • Returns whether cross-LOD tile edge stitching is enabled.

    Declaration

    Objective-C

    - (BOOL)isTileEdgeStitchingEnabled;

    Swift

    func isTileEdgeStitchingEnabled() -> Bool

    Return Value

    True if grid surface edges follow a coarser neighbour’s lattice. The default is true.

  • Enables or disables cross-LOD edge stitching: the finer tile chords across a coarser neighbour’s grid nodes, closing the crack between them. Needs an even MeshResolution and GPU draping mode; costs one uniform per tile.

    Declaration

    Objective-C

    - (void)setTileEdgeStitchingEnabled:(BOOL)enabled;

    Swift

    func setTileEdgeStitchingEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to snap grid surface edges to a coarser neighbour’s grid.

  • Returns how many terrain surface meshes may be cached.

    Declaration

    Objective-C

    - (int)getMeshCacheSize;

    Swift

    func getMeshCacheSize() -> Int32

    Return Value

    The cache size in meshes, or 0 for the built-in rule. The default is 0.

  • Sets how many terrain surface meshes may be cached; the visible cut holds half as many tiles. The default 0 keeps the built-in 160/80, a map’s working set. Raise it for a panorama, whose wider cut otherwise rebuilds meshes while turning and keeps dropping a zoom level.

    Declaration

    Objective-C

    - (void)setMeshCacheSize:(int)meshes;

    Swift

    func setMeshCacheSize(_ meshes: Int32)

    Parameters

    meshes

    The number of meshes to cache, or 0 for the built-in rule.

  • Returns whether the shared ground pass draws the terrain a second time.

    Declaration

    Objective-C

    - (BOOL)isSharedGroundEnabled;

    Swift

    func isSharedGroundEnabled() -> Bool

    Return Value

    True if the ground is drawn under the layers. The default is true.

  • Enables or disables the flat shared-ground draw when DrapeFillsEnabled is false. The default is true. Disable it only when a surface shader plus labels/billboards is all the map draws; fills and lines need that ground to composite onto.

    Declaration

    Objective-C

    - (void)setSharedGroundEnabled:(BOOL)enabled;

    Swift

    func setSharedGroundEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to draw the shared ground, false to leave the surface shader’s output.

  • Returns whether polygon fills are draped as a render-to-texture surface.

    Declaration

    Objective-C

    - (BOOL)isDrapeFillsEnabled;

    Swift

    func isDrapeFillsEnabled() -> Bool

    Return Value

    True if fills are baked to a per-tile texture and sampled on the surface. The default is true.

  • Enables or disables maplibre-style fill draping (experimental): fills render flat into a per-tile texture sampled by the terrain surface, so they follow it exactly at 2D fill cost. Only native (non-overzoomed) fills drape; lines need DrapeLinesEnabled. Requires GPU draping mode (vertex texture fetch, planar).

    Declaration

    Objective-C

    - (void)setDrapeFillsEnabled:(BOOL)enabled;

    Swift

    func setDrapeFillsEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to drape fills as a texture, false to draw them as geometry.

  • Returns whether vt tile lines are also draped (in addition to fills).

    Declaration

    Objective-C

    - (BOOL)isDrapeLinesEnabled;

    Swift

    func isDrapeLinesEnabled() -> Bool

    Return Value

    True if tile lines are baked into the drape texture. The default is true.

  • Enables or disables draping of tile lines too (needs DrapeFillsEnabled): they follow the terrain exactly at no per-frame geometry cost, but resolve at the drape resolution. Layers matching NoDrapeLayerFilter stay sharp. See docs/internals/rendering/04-terrain.md.

    Declaration

    Objective-C

    - (void)setDrapeLinesEnabled:(BOOL)enabled;

    Swift

    func setDrapeLinesEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to drape tile lines too, false to keep them as sharp geometry.

  • Returns whether bridges and tunnels stand on their own chord (3D bridges).

    Declaration

    Objective-C

    - (BOOL)isBridges3DEnabled;

    Swift

    func isBridges3DEnabled() -> Bool

    Return Value

    True if a span feature is lifted onto the chord between its portals and a span deck is drawn as an extrusion. The default is false.

  • Enables or disables 3D bridges: a line-elevation-mode: span feature (or polygon/building variant) is laid straight between its portals and a span deck stands as an extrusion; off, spans drape and no span work runs. Needs terrain. See docs/internals/rendering/04-terrain.md, “Bridges and tunnels: spans”.

    Declaration

    Objective-C

    - (void)setBridges3DEnabled:(BOOL)enabled;

    Swift

    func setBridges3DEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to lift spans onto their chord, false to drape them.

  • Returns the style layers that are kept out of the terrain drape bake.

    Declaration

    Objective-C

    - (NSString *)getNoDrapeLayerFilter;

    Swift

    func getNoDrapeLayerFilter() -> String!

    Return Value

    A regular expression matched against vt style layer names. The default is “^contour|maneuver.*”; an empty string drapes everything the geometry type allows.

  • Sets which style layers are not baked into the drape texture, as a regular expression over the vt layer name; they are drawn live at screen resolution, still sun and shadow shaded. Meant for hairlines such as contours.

    Declaration

    Objective-C

    - (void)setNoDrapeLayerFilter:(NSString *)filter;

    Swift

    func setNoDrapeLayerFilter(_ filter: String!)

    Parameters

    filter

    The regular expression, or an empty string to drape everything.

  • Returns the per-tile drape texture resolution, 0 when it follows the screen.

    Declaration

    Objective-C

    - (int)getDrapeResolution;

    Swift

    func getDrapeResolution() -> Int32

    Return Value

    The drape texture resolution in pixels, 0 for automatic.

  • Sets the per-tile drape texture resolution, trading thin-content sharpness against video memory (resolution^2 * 4 bytes per visible tile). 0 (the default) follows the screen: 2 * tileDrawSize * pixelScale, one texel per pixel at the tile LOD bound, halved until DrapeWorkingSet tiles fit DrapeCacheSize.

    Declaration

    Objective-C

    - (void)setDrapeResolution:(int)resolution;

    Swift

    func setDrapeResolution(_ resolution: Int32)

    Parameters

    resolution

    The new drape texture resolution, clamped to [128, 2048], or 0 to follow the screen.

  • Returns the minimum tile zoom level with 3D terrain.

    Declaration

    Objective-C

    - (int)getMinZoom;

    Swift

    func getMinZoom() -> Int32

    Return Value

    The minimum zoom level. The default is 5.

  • Sets the minimum tile zoom level with 3D terrain. Tiles below this zoom level render flat and do not fetch elevation data. Terrain displacement is invisible at low zoom levels anyway, so this limits the number of elevation tiles fetched and processed for far-away/zoomed-out views.

    Declaration

    Objective-C

    - (void)setMinZoom:(int)minZoom;

    Swift

    func setMinZoom(_ minZoom: Int32)

    Parameters

    minZoom

    The new minimum zoom level (clamped to 0..24).

  • Returns the maximum tile zoom level the terrain mesh is cut at.

    Declaration

    Objective-C

    - (int)getMaxZoom;

    Swift

    func getMaxZoom() -> Int32

    Return Value

    The maximum zoom level, or 0 while the cut is unbounded.

  • Caps the tile zoom the terrain mesh is cut at and the elevation tiles selected to feed it, so the ground settles once instead of refining under labels and camera (a panorama). The default 0 leaves both to the distance rule, the tile budget and the source maximum.

    Declaration

    Objective-C

    - (void)setMaxZoom:(int)maxZoom;

    Swift

    func setMaxZoom(_ maxZoom: Int32)

    Parameters

    maxZoom

    The new maximum zoom level (clamped to 0..24), or 0 for no cap.

  • Returns the factor applied to the view distance.

    Declaration

    Objective-C

    - (float)getViewDistanceFactor;

    Swift

    func getViewDistanceFactor() -> Float

    Return Value

    The view distance factor. The default is 1, which is exactly tangram’s rule.

  • Sets the view distance and far plane as a factor on tangram’s rule (far = 2 * cameraHeight / cos(pitch + fovy/2), capped at worldTileSize(zoom) * 127); smaller ends the view closer (pair with fog), larger costs depth precision. A style may pin an absolute distance instead, in meters, with “terrain-max-visible-distance”.

    Declaration

    Objective-C

    - (void)setViewDistanceFactor:(float)factor;

    Swift

    func setViewDistanceFactor(_ factor: Float)

    Parameters

    factor

    The new view distance factor. The default is 1.

  • Returns the minimum view distance, in meters.

    Declaration

    Objective-C

    - (float)getViewDistance;

    Swift

    func getViewDistance() -> Float

    Return Value

    The view distance in meters. 0 (the default) leaves the factor rule alone.

  • Sets a minimum distance the map is drawn to, in meters, at any camera height or tilt, for views along the ground. It only ever extends the factor rule and spends depth precision, so pair it with fog. 0 (the default) leaves the factor rule alone.

    Declaration

    Objective-C

    - (void)setViewDistance:(float)distance;

    Swift

    func setViewDistance(_ distance: Float)

    Parameters

    distance

    The new minimum view distance in meters, or 0 for the factor rule alone.

  • Returns the maximum view distance, in meters.

    Declaration

    Objective-C

    - (float)getViewDistanceMax;

    Swift

    func getViewDistanceMax() -> Float

    Return Value

    The view distance ceiling in meters. 0 (the default) is no ceiling.

  • Sets a maximum distance the map is drawn to, in meters, capping culling, the tile walk and the far plane; it also caps setViewDistance. Independent of the fog, which a summit may stand above. 0 (the default) is no ceiling.

    Declaration

    Objective-C

    - (void)setViewDistanceMax:(float)distance;

    Swift

    func setViewDistanceMax(_ distance: Float)

    Parameters

    distance

    The new maximum view distance in meters, or 0 for no ceiling.

  • Returns the drape cache budget in megabytes.

    Declaration

    Objective-C

    - (int)getDrapeCacheSize;

    Swift

    func getDrapeCacheSize() -> Int32

    Return Value

    The drape cache budget in megabytes, or 0 for the built-in 192. The default is 0.

  • Sets how much video memory the cached drape textures may take, in megabytes. It must hold the live cover and the generation it replaced, or the ground blinks during a fast zoom. It also bounds the automatic drape resolution (see DrapeResolution and DrapeWorkingSet).

    Declaration

    Objective-C

    - (void)setDrapeCacheSize:(int)megabytes;

    Swift

    func setDrapeCacheSize(_ megabytes: Int32)

    Parameters

    megabytes

    The new budget in megabytes, or 0 for the default of 192.

  • Returns the elevation grid cache budget in megabytes, 0 for the SDK’s own rule.

    Declaration

    Objective-C

    - (int)getElevationCacheSize;

    Swift

    func getElevationCacheSize() -> Int32

    Return Value

    The elevation cache budget in megabytes. The default is 0.

  • Sets how much memory the decoded elevation grids may take, in megabytes (a 512-texel grid is ~1.8 MB). The default 0 keeps 192 grids, a map’s working set; raise it for a wide view, where a full cache refetches every eviction and keeps the decode threads busy.

    Declaration

    Objective-C

    - (void)setElevationCacheSize:(int)megabytes;

    Swift

    func setElevationCacheSize(_ megabytes: Int32)

    Parameters

    megabytes

    The new budget in megabytes, or 0 for the grid-count rule.

  • Returns how many drape tiles the automatic resolution assumes are cached at once.

    Declaration

    Objective-C

    - (int)getDrapeWorkingSet;

    Swift

    func getDrapeWorkingSet() -> Int32

    Return Value

    The assumed working set in tiles, or 0 for the built-in 64. The default is 0.

  • Sets how many drape tiles the automatic resolution (DrapeResolution 0) assumes must fit DrapeCacheSize at once (live cover plus the next generation). Lower is sharper but thrashes below a real cover’s 15-34 leaves.

    Declaration

    Objective-C

    - (void)setDrapeWorkingSet:(int)tiles;

    Swift

    func setDrapeWorkingSet(_ tiles: Int32)

    Parameters

    tiles

    The assumed working set in tiles, or 0 for the built-in 64.

  • Returns how many zoom levels below the camera a tile may coarsen to.

    Declaration

    Objective-C

    - (int)getMaxTileZoomCoarsening;

    Swift

    func getMaxTileZoomCoarsening() -> Int32

    Return Value

    The maximum tile zoom coarsening. The default is 3.

  • Sets how far below the camera’s zoom the tile LOD may take a tile in terrain mode. The surface is the depth occluder and its DEM level follows the tile, so coarse tiles chop ridge crests (content shows through) and shade blocky; larger values mean fewer tiles at a tilt. 0 pins every tile to the camera’s own zoom.

    Declaration

    Objective-C

    - (void)setMaxTileZoomCoarsening:(int)levels;

    Swift

    func setMaxTileZoomCoarsening(_ levels: Int32)

    Parameters

    levels

    The new maximum tile zoom coarsening. The default is 3.

  • Returns the terrain background color.

    Declaration

    Objective-C

    - (MSFColor *)getBackgroundColor;

    Swift

    func getBackgroundColor() -> MSFColor!

    Return Value

    The terrain background color. The default is transparent (no background).

  • Sets the terrain background color: an opaque base fill under all layers that keeps the terrain shape (and its depth, for occlusion) where no layer paints. Transparent (the default) disables the fill.

    Declaration

    Objective-C

    - (void)setBackgroundColor:(MSFColor *)color;

    Swift

    func setBackgroundColor(_ color: MSFColor!)

    Parameters

    color

    The new terrain background color.

  • Returns the terrain background bitmap state.

    Declaration

    Objective-C

    - (BOOL)isBackgroundBitmapEnabled;

    Swift

    func isBackgroundBitmapEnabled() -> Bool

    Return Value

    True if the map background bitmap is draped over the terrain as the base fill. The default is false.

  • Sets the terrain background bitmap state. When enabled, the map background bitmap (Options::getBackgroundBitmap) is draped as the base fill under all layers instead of the background color.

    Declaration

    Objective-C

    - (void)setBackgroundBitmapEnabled:(BOOL)enabled;

    Swift

    func setBackgroundBitmapEnabled(_ enabled: Bool)

    Parameters

    enabled

    The new background bitmap state.

  • Returns the custom terrain surface fragment shader source, or an empty string if no shaded surface is drawn.

    Declaration

    Objective-C

    - (NSString *)getSurfaceShaderSource;

    Swift

    func getSurfaceShaderSource() -> String!

    Return Value

    The custom surface shader source.

  • Sets a fragment shader defining “vec4 surfaceColor()” (non-premultiplied, not fogged) that paints the terrain surface as the base fill, replacing the background bitmap/color. On compile error it is dropped and logged. Varyings, uniforms and parameters: docs/internals/rendering/04-terrain.md, “The surface shader”.

    Declaration

    Objective-C

    - (void)setSurfaceShaderSource:(NSString *)shaderSource;

    Swift

    func setSurfaceShaderSource(_ shaderSource: String!)

    Parameters

    shaderSource

    The GLSL source, or an empty string for no shaded surface.

  • Returns the value of a terrain surface shader float parameter.

    Declaration

    Objective-C

    - (float)getSurfaceParameter:(NSString *)name;

    Swift

    func getSurfaceParameter(_ name: String!) -> Float

    Parameters

    name

    The name of the parameter.

    Return Value

    The value of the parameter, or 0 if not set.

  • Sets a terrain surface shader float parameter, exposed to the shader as a uniform.

    Declaration

    Objective-C

    - (void)setSurfaceParameter:(NSString *)name value:(float)value;

    Swift

    func setSurfaceParameter(_ name: String!, value: Float)

    Parameters

    name

    The name of the parameter (must be a valid GLSL identifier).

    value

    The new value for the parameter.

  • Returns the value of a terrain surface shader color parameter.

    Declaration

    Objective-C

    - (MSFColor *)getSurfaceColorParameter:(NSString *)name;

    Swift

    func getSurfaceColorParameter(_ name: String!) -> MSFColor!

    Parameters

    name

    The name of the parameter.

    Return Value

    The value of the parameter, or transparent black if not set.

  • Sets a terrain surface shader color parameter, exposed to the shader as a vec4 uniform with components in the 0..1 range.

    Declaration

    Objective-C

    - (void)setSurfaceColorParameter:(NSString *)name color:(MSFColor *)color;

    Swift

    func setSurfaceColorParameter(_ name: String!, color: MSFColor!)

    Parameters

    name

    The name of the parameter (must be a valid GLSL identifier).

    color

    The new value for the parameter.

  • Returns the maximum visible tile zoom offset, relative to the camera zoom level.

    Declaration

    Objective-C

    - (int)getMaxTileZoomOffset;

    Swift

    func getMaxTileZoomOffset() -> Int32

    Return Value

    The maximum tile zoom offset. The default is 100 (no cap).

  • Sets the maximum visible tile zoom offset, relative to the camera zoom level. Distance-based terrain LOD shows near tiles finer than flat rendering would, exposing zoom-dependent styling as hard-edged rings; 0 caps at the flat level, positive values allow that many extra levels. Values of 100 or more disable the cap.

    Declaration

    Objective-C

    - (void)setMaxTileZoomOffset:(int)offset;

    Swift

    func setMaxTileZoomOffset(_ offset: Int32)

    Parameters

    offset

    The new maximum tile zoom offset (values >= 100 disable the cap).

  • Returns the camera terrain clearance floor: an explicit minimum height the camera is kept above the terrain surface, in meters.

    Declaration

    Objective-C

    - (float)getCameraClearance;

    Swift

    func getCameraClearance() -> Float

    Return Value

    The camera clearance floor in meters. The default is 0.

  • Sets the camera terrain clearance floor, in meters, added under the zoom-relative rule (as in mapbox, a share of the camera’s altitude, see CameraClearanceFraction). A zoom in stops at the clearance; a camera pushed under it by a pan or arriving elevation is lifted at a constant zoom, by reducing the tilt.

    Declaration

    Objective-C

    - (void)setCameraClearance:(float)clearance;

    Swift

    func setCameraClearance(_ clearance: Float)

    Parameters

    clearance

    The new clearance floor in meters. 0 (the default) applies the zoom-relative rule alone.

  • Returns the share of the camera’s altitude that the terrain clearance takes.

    Declaration

    Objective-C

    - (float)getCameraClearanceFraction;

    Swift

    func getCameraClearanceFraction() -> Float

    Return Value

    The clearance fraction. The default is 1/16.

  • Sets the share of the camera’s altitude the clearance takes (default 1/16). 0 leaves CameraClearance alone as a fixed height above the ground, as a first-person view needs.

    Declaration

    Objective-C

    - (void)setCameraClearanceFraction:(float)fraction;

    Swift

    func setCameraClearanceFraction(_ fraction: Float)

    Parameters

    fraction

    The new fraction, clamped to [0, 1). 1/16 is the default.

  • Returns the height the viewpoint is lifted above the ground-following focus, in meters.

    Declaration

    Objective-C

    - (float)getFocusLift;

    Swift

    func getFocusLift() -> Float

    Return Value

    The focus lift in meters. The default is 0.

  • Sets the height the viewpoint is lifted above the ground under it, in meters, added to the ground-following rule (a focus z is recomputed every frame). For a first-person viewpoint standing above the ridge in front of it.

    Declaration

    Objective-C

    - (void)setFocusLift:(float)lift;

    Swift

    func setFocusLift(_ lift: Float)

    Parameters

    lift

    The new lift in meters. 0 (the default) leaves the focus on the ground.

  • Returns the duration of the camera terrain-following correction animation.

    Declaration

    Objective-C

    - (float)getCameraClampDuration;

    Swift

    func getCameraClampDuration() -> Float

    Return Value

    The correction duration in seconds. The default is 0 (instant correction).

  • Sets the duration of the camera terrain-following correction animation.

    Declaration

    Objective-C

    - (void)setCameraClampDuration:(float)duration;

    Swift

    func setCameraClampDuration(_ duration: Float)

    Parameters

    duration

    The new duration in seconds. 0 applies corrections instantly.

  • Returns the clip-space depth bias used when depth-testing draped 2D geometry against the terrain.

    Declaration

    Objective-C

    - (float)getDepthBias;

    Swift

    func getDepthBias() -> Float

    Return Value

    The depth bias. The default is 0.0002.

  • Sets the clip-space depth bias used when depth-testing draped 2D geometry against the terrain. Larger values prevent draped layers from being clipped by the terrain surface itself, at the cost of geometry slightly behind terrain ridges ‘shining through’ near silhouettes.

    Declaration

    Objective-C

    - (void)setDepthBias:(float)depthBias;

    Swift

    func setDepthBias(_ depthBias: Float)

    Parameters

    depthBias

    The new depth bias (clamped to 0..0.01).

  • Returns the billboard/label terrain occlusion tolerance.

    Declaration

    Objective-C

    - (float)getBillboardOcclusionTolerance;

    Swift

    func getBillboardOcclusionTolerance() -> Float

    Return Value

    The relative depth tolerance. The default is 0.05.

  • Sets how far behind the terrain a billboard or label anchor may sit and still count as visible, as a fraction of its distance from the camera. The default is 0.05; 0 hides a label the moment its anchor goes behind the relief; larger values let a summit just behind a nearer ridge keep its name.

    Declaration

    Objective-C

    - (void)setBillboardOcclusionTolerance:(float)tolerance;

    Swift

    func setBillboardOcclusionTolerance(_ tolerance: Float)

    Parameters

    tolerance

    The new relative tolerance (clamped to 0..1).

  • Returns the ground distance the surface normals are measured over, in meters.

    Declaration

    Objective-C

    - (float)getNormalSampleDistance;

    Swift

    func getNormalSampleDistance() -> Float

    Return Value

    The normal sample distance, or 0 while the mesh’s own spacing is used.

  • Sets the ground distance the per-vertex surface normals are measured over, in meters. The default 0 uses the mesh spacing, which differs across LOD boundaries and draws them as lines in a normal- differentiating effect; 60-150 m reads ridges. Planar surfaces only.

    Declaration

    Objective-C

    - (void)setNormalSampleDistance:(float)distance;

    Swift

    func setNormalSampleDistance(_ distance: Float)

    Parameters

    distance

    The new sample distance in meters, or 0 for the mesh’s own spacing.

  • Returns the opacity a label keeps while its anchor is behind 3D content.

    Declaration

    Objective-C

    - (float)getTextOcclusionOpacity;

    Swift

    func getTextOcclusionOpacity() -> Float

    Return Value

    The opacity of an occluded label. The default is 1, i.e. no occlusion.

  • Sets the opacity a label keeps while its anchor is hidden by buildings (terrain occludes regardless), faded per label by how much of a small square around the anchor is covered. 1, the default, disables it; below 1 costs one extra pass over visible extrusions. The style’s ‘text-occlusion-opacity’ wins where it sets one.

    Declaration

    Objective-C

    - (void)setTextOcclusionOpacity:(float)opacity;

    Swift

    func setTextOcclusionOpacity(_ opacity: Float)

    Parameters

    opacity

    The opacity of an occluded label (clamped to 0..1).

  • Returns the billboard/label terrain occlusion state.

    Declaration

    Objective-C

    - (BOOL)isBillboardOcclusionEnabled;

    Swift

    func isBillboardOcclusionEnabled() -> Bool

    Return Value

    True if billboards and labels hidden behind terrain are faded out. The default is true.

  • Sets the billboard/label terrain occlusion state.

    Declaration

    Objective-C

    - (void)setBillboardOcclusionEnabled:(BOOL)enabled;

    Swift

    func setBillboardOcclusionEnabled(_ enabled: Bool)

    Parameters

    enabled

    The new occlusion state.

  • Returns the terrain elevation in meters at the given position. The position is expected to be in WGS84 coordinates. Note: this method may block on network/IO if the elevation tile is not cached.

    Declaration

    Objective-C

    - (double)getElevation:(MSFMapPos *)pos;

    Swift

    func getElevation(_ pos: MSFMapPos!) -> Double

    Parameters

    pos

    The position to query.

    Return Value

    The elevation in meters, or -1000000 if no elevation data is available.

  • Returns terrain elevations in meters at the given positions (WGS84). One value is returned for every input position, in the input order. Note: this method may block on network/IO if the elevation tiles are not cached.

    Declaration

    Objective-C

    - (MSFDoubleVector *)getElevations:(MSFMapPosVector *)poses;

    Swift

    func getElevations(_ poses: MSFMapPosVector!) -> MSFDoubleVector!

    Parameters

    poses

    The positions to query.

    Return Value

    The elevations in meters (-1000000 where no data is available).

  • Returns whether tiles are decoded for terrain even while the terrain is disabled.

    Declaration

    Objective-C

    - (BOOL)isAlwaysDecode;

    Swift

    func isAlwaysDecode() -> Bool

    Return Value

    True if setEnabled never re-decodes the tiles. The default is false.

  • Sets whether tiles are decoded for terrain, and the elevation data warmed, while the terrain is disabled. Costs the terrain tile set and the elevation fetches in 2D, saves the re-decode on setEnabled.

    Declaration

    Objective-C

    - (void)setAlwaysDecode:(BOOL)alwaysDecode;

    Swift

    func setAlwaysDecode(_ alwaysDecode: Bool)

    Parameters

    alwaysDecode

    The new state.

  • Undocumented

    Declaration

    Objective-C

    -(void)dealloc;

    Swift

    func dealloc()