Skip to content

FeatureLayerTranslator

Namespace: ThinkGeo.Core.Styling

Translates a classic FeatureLayer - its feature source and the styles on its ZoomLevelSet - into the GPU's terms.

public static class FeatureLayerTranslator

Inheritance object → FeatureLayerTranslator

Remarks:

Each style on a zoom level becomes a run of code-built layers bounded to the scales the classic renderer draws that style at - asked of the layer's own ZoomLevelSet the way that renderer asks it, so the two switch at the same scales. That rule is not "the nearest level": a level with an ApplyUntilZoomLevel applies while the scale lies between the until level's scale and its own; outside every such window the nearest threshold decides; and where two windows overlap only their custom styles draw. The scales become the map's zoom over the ladder given (the default of a metre-unit map when none is).

An AreaStyle is a fill, and a line for its outline when the pen is more than one solid pixel; a hatch brush becomes the fill's pattern. A LineStyle is a line per pen with ink, outer under inner under centre. A PointStyle is a circle when its symbol is one, and otherwise a symbol layer whose icon is the style drawn once. A TextStyle is a symbol layer whose text is built the way the classic label was: the column, or the TextContent template, through NumericFormat, DateFormat and TextFormat, then LetterCase. ValueStyle, ClassBreakStyle, RegexStyle and CompositeStyle become their item styles with a filter each - a lambda over the feature, which is what a code-built layer takes - so a choropleth stays a choropleth. The layer's LabelDisplayMode is honoured as classic drawing honours it: LabelsOnly translates only its text styles, ShapesOnly everything but them. The layer's DrawingMarginInPixel becomes the source's tile buffer (FeatureSourceVectorTileSource.TileBufferInPixel): the widest margin of the layers translated into the source, replacing a value set on it before, and replaced by one set after. The layer's Opacity multiplies into every paint; IsGrayscale, IsNegative and the colour translations are warnings. Everything else is a warning, not a guess.

Methods

Translate(FeatureLayer, Collection<double>, string)

public static FeatureLayerTranslation Translate(FeatureLayer layer, Collection<double> zoomScales, string sourceId)

Parameters

layer FeatureLayer
The classic layer. Its feature source is used as it is - a projection converter on it stays in effect.

zoomScales Collection<double>
The map's ZoomScales ladder, which the level bounds are expressed in. Null is the default ladder of a metre-unit map.

sourceId string
The name the layers refer to the source by; null takes the layer's name, or its data's.

Returns

FeatureLayerTranslation

Translate(WebBasedAsyncFeatureLayer, Collection<double>, string)

FeatureLayerTranslator.Translate(FeatureLayer, Collection<double>, string) for an asynchronous layer - a WfsV2AsyncLayer, an OgcApiAsyncLayer. The styles on its ZoomLevelSet translate the same way; its source is cut through a synchronous view of it (FeatureSourceLayerCollection.Add(string, AsyncFeatureSource)). https://community.thinkgeo.com/t/wfsv2featurelayer-vs-wfsv2asynclayer/12449

public static FeatureLayerTranslation Translate(WebBasedAsyncFeatureLayer layer, Collection<double> zoomScales, string sourceId)

Parameters

layer WebBasedAsyncFeatureLayer

zoomScales Collection<double>

sourceId string

Returns

FeatureLayerTranslation

TranslateInto(WebBasedAsyncFeatureLayer, FeatureSourceVectorTileSource, Collection<double>)

FeatureLayerTranslator.TranslateInto(WebBasedAsyncFeatureLayer, FeatureSourceVectorTileSource, Collection<double>) for an asynchronous layer - a WfsV2AsyncLayer, an OgcApiAsyncLayer: its data goes into , added if the source does not cut it yet.

public static FeatureLayerTranslation TranslateInto(WebBasedAsyncFeatureLayer layer, FeatureSourceVectorTileSource source, Collection<double> zoomScales)

Parameters

layer WebBasedAsyncFeatureLayer
The asynchronous layer.

source FeatureSourceVectorTileSource
The tile source to translate into.

zoomScales Collection<double>
The map's ZoomScales ladder. Null is the default ladder of a metre-unit map.

Returns

FeatureLayerTranslation

Exceptions

ArgumentException
The source already cuts different data under the layer's name.

TranslateInto(FeatureLayer, FeatureSourceVectorTileSource, Collection<double>)

Translates into a tile source the caller gives, instead of a new one. The layer's data is added to the source if the source does not cut it yet.

public static FeatureLayerTranslation TranslateInto(FeatureLayer layer, FeatureSourceVectorTileSource source, Collection<double> zoomScales)

Parameters

layer FeatureLayer
The classic layer.

source FeatureSourceVectorTileSource
The tile source to translate into.

zoomScales Collection<double>
The map's ZoomScales ladder, which the level bounds are expressed in. Null is the default ladder of a metre-unit map.

Returns

FeatureLayerTranslation

Exceptions

ArgumentException
The source already cuts different data under the layer's name.

Remarks:

Three uses: Restyle without losing tiles. A style swap keeps the decoded tiles of every source object it already holds and drops those of a source it has not seen, so a fresh translation re-cuts the data even when only a colour changed. Pass the previous translation's : the layers are rebuilt on the same object, under the same name, so their ids and the tiles stay.Several layers, one set of tiles. Translate each layer into the same source: every tile then carries all their data as source-layers, cut once.A grid of your own. A source made with a projected grid () cuts the layer on that grid instead of Web Mercator.