Working with Vector Data
This guide provides information and tips for using map data in vector format in Carmenta Engine, such as getting good performance in visualization of complex data sets.
Filtering the data
To reduce the amount of data to render to a map you should filter features before sending them to the view.
Filtering per layer
To improve performance, you should display only those vector features that are appropriate for the view scale. For example, suppose you have a road network represented by three datasets: one for major highways, one for ordinary roads, and one for streets and country lanes.
At detailed scales, you can to display all three datasets.
At medium scales, you should turn off the streets and country lanes.
At zoomed-out scales, you should only display the major highways.
Use Layer.MaxScale to turn off data as the view is zoomed out.
Filtering per feature
If you need some but not all features of a dataset, you can insert a FilterOperator whose condition allows only those you need.
Indexing
Most datasets will construct spatial indexes of their data, which improves performance. But if you do not specify a path where these indexes shall be stored, they will be kept in memory only, and regenerated every time your application is restarted, which takes time. So, if your dataset has some property called indexPath or featureIndexPath, make sure they are specified.
Clipping
It is inefficient when features are much larger than the typical view area. For example, if the Russia border is stored as a single polygon feature, all of it could be retrieved even if the view showed only Saint Petersburg. Fortunately, in most datasets, the features have already been clipped into small parts by the data provider. Otherwise, if you have a ShapefileDataSet, you can set its clipSize property; this will make the dataset behave as if its features were clipped into small parts, although the underlying .shp files are not modified.
More generally, the RectangleClipOperator can clip any feature to the view area. It is an efficient operator and will usually improve performance, since the visualizers get less work.
Generalization
Vector data designed for detailed scales can be generalized to versions suitable for more zoomed-out scales. Creating generalized data is often a difficult process, but with Carmenta Engine you can often achieve good results by using the built-in thinning operator.
Thinning
When a dataset of lines or polygons is used in a map scale that is more zoomed out than the dataset is designed for, you can use the LineThinningOperator to decrease the fine detail of the features. This can improve performance, because the operator is surprisingly fast, and visualizers, as well as other operators, becomes more efficient when the features have been simplified. It is usually best if the LineThinningOperator.MaxError corresponds to about half a screen pixel.
TileLayer decreases details of both line and polygon features automatically if TileLayer.AutoThin has been set to True.
Rasterization
If you have achieved a good but slow visualization of some vector data, you should consider turning the result into a set of raster maps. But the raster generation will be a time-consuming task. Carmenta can help you, as we have long experience of this approach.