Class: Wkt

Wkt(textRepresentation)

new Wkt(textRepresentation)

Wkt is capable of parsing the text representation of the WKT objects. The explanation of what all is supported is to be found in the README.MD in this directory.

The simplest possible usage is:
var layer = new WorldWind.RenderableLayer();
var parser = new Wkt('POINT (19 23)');
parser.load(null, null, layer);
wwd.addLayer(layer);
This example adds the WKT into the map
The more complex usage allows you to do whatever you want with the parsed objects. For example you can make sure that only points are displayed
var layer = new WorldWind.RenderableLayer();
var parser = new Wkt('POINT (19 23)');
parser.load(function(wkt, objects){
var shapes = [];
objects.forEach(function(object){
if(object.type == WorldWind.WktType.SupportedGeometries.POINT) {
shapes.push.apply(shapes, object.shapes());
}
});

if(wkt.layer) {
wkt.layer.addRenderables(shapes);
}
}, null, layer);
wwd.addLayer(layer);
The most complex usage is when you want to supply different configuration for object before it is added to the layer.
var layer = new WorldWind.RenderableLayer();
var parser = new Wkt('POINT (19 23)');
parser.load(null, function(shape) {
if(shape.type == WktType.SupportedGeometries.POINT) {
var shapeAttributes = new ShapeAttributes(null);
shapeAttributes.fontColor = Color.RED;
return {
attributes: shapeAttributes
};
}
}, layer);
wwd.addLayer(layer);
Parameters:
Name Type Description
textRepresentation String Text representation of WKT objects.
Source:

Members

(readonly) layer :RenderableLayer

The layer containing the shapes representing the records in this wkt, as specified to this wkt's constructor.
Type:
Source:

(readonly) parserCompletionCallback :function

The completion callback specified to load. This function is called when wkt parsing is done but before creating shapes for the wkt. It's single argument is the WKT string.
Type:
  • function
Default Value:
Source:

(readonly) shapeConfigurationCallback :function

The attribute callback specified to load. See that method's description for details.
Type:
  • function
Default Value:
Source:

Methods

defaultParserCompletionCallback(objects, wkt)

It is the default implementation of the parser completion callback. It is called with all parsed objects and the default one then calls shape configuration callback for each of them and then add the shapes into the provided layer if such is provided.
Parameters:
Name Type Description
objects Array.<WktObject> Array of the Renderables to be displayed. This is the last time to modify them.
wkt Wkt Object representing the Wkt. It is used to retrieve layer, shape configuration callback.
Source:

defaultShapeConfigurationCallback(shape) → {Object}

It is the default implementation of the shape configuration callback. It is called for every generated shape.
Parameters:
Name Type Description
shape Renderable It is a renderable for which you can provide custom attributes.
Source:
Returns:
This object can contain attributes to be used for the shape, highlight attributes to be used for the shape, pickDelegate to be used and userProperties. All these properties are applied to the shape.
Type
Object

load(parserCompletionCallback, shapeConfigurationCallback, layer)

It parses the received string and create the Objects, which then can be rendered.
Parameters:
Name Type Description
parserCompletionCallback function An optional function called when the WKT loading is complete and all the shapes have been added to the layer.
shapeConfigurationCallback function This function is called whenever new shape is created. It provides the current shape as the first argument. In this way it is possible to modify the shape even provide another one. If any shape is returned it is used in place of the previous one. This function should be synchronous and if you want to provide custom shape, it has to be synchronous.
layer RenderableLayer Layer to use for adding all the parsed shapes. It is optional. It is possible to use this class as only a parser by providing custom parser completion callback.
Source: