Configuring Local Dataset (using a VRT file)
This article is only relevant for Pozi Enterprise clients who are hosting datasets within their own network for internal use only.
Introduction
Datasets which are hosted internally are usually made available to Pozi as shape files, tab files, or directly out of an internal database such as SQL Server.
While it is common for Pozi to directly apply styling to these layers within the site configuration, it is also possible for the client to have some control over the styling through the use of VRT files.
In essence, the VRT file reads the dataset and applies some styling, and Pozi reads from the VRT file (rather than from the underlying dataset).
The VRT File
In its simplest form, a VRT file will look something like this:
<OGRVRTDataSource> <OGRVRTLayer name="StreetTrees"> <SrcDataSource>MSSQL:server=GISServer;database=GISDatabase</SrcDataSource> <SrcLayer>vw_ASSET_StreetTrees</SrcLayer> </OGRVRTLayer> </OGRVRTDataSource>
<OGRVRTDataSource> <OGRVRTWarpedLayer> <OGRVRTLayer name="assetic_trees"> <SrcDataSource>MSSQL:server=GISServer;database=GISServer</SrcDataSource> <SrcSQL dialect="sqlite"> select *, '#00FF00' as "marker-color" from pozi.assetic_trees </SrcSQL> </OGRVRTLayer> <TargetSRS>EPSG:4326</TargetSRS> </OGRVRTWarpedLayer> </OGRVRTDataSource>
<OGRVRTDataSource> <OGRVRTLayer name="assetic_trees"> <SrcDataSource>MSSQL:server=GISServer;database=GISServer</SrcDataSource> <SrcSQL dialect="sqlite"> select *, CASE WHEN [radius] < 103 THEN '#0000ff' WHEN [radius] < 154 and [radius] > 102 THEN '#d7191c' WHEN [radius] < 237 and [radius] > 153 THEN '#fec981' WHEN [radius] < 343 and [radius] > 236 THEN '#c4e687' ELSE '#1a9641' END as "marker-color", from pozi.assetic_trees </SrcSQL> </OGRVRTLayer> </OGRVRTDataSource>
Styling Options
Point style
- "marker-color": eg #0000FF (default)
- "marker-size": eg 1,2,3,etc,small,large
- "marker-symbol": circle (default)|square|diamond|triangle|hexagon|star|heptagon
- "marker-opacity": eg 0.25 (default)
Line style
- "stroke": eg #0000FF (default)
- "stroke-opacity": eg 1 (default)
- "stroke-width": eg 2 (default)
Polygon style
- "stroke": eg #0000FF (default)
- "stroke-opacity": eg 1 (default)
- "stroke-width": eg 2 (default)
- "fill": eg #0000FF (default)
- "fill-opacity": eg 0.25 (default)
Note: field aliases such as "fill-opacity" should be enclosed in double quotes (") to avoid syntax errors, especially for field names containing dashes.
Usage of Special Characters
&
The & is the escape character (so is always &), the #38 is the ASCII code for the special character (in this case ampersand), and the ; is the terminator.
Other examples are < for the less than symbol (<), and > for the greater than symbol (>).
See https://theasciicode.com.ar/ for a complete list of codes.
Note that some codes have a corresponding name which can be used instead, eg. Less Than can be escaped as < instead of <. This can sometimes make the escape coding more readable. See https://www.freeformatter.com/html-entities.html for a mapping of codes to names.
Spatial Operations
<SrcSql dialect="sqlite"> select ass_num_char, ownername as "label", ST_PointOnSurface(geometry) as geometry from "propertymp_ratepayerowner" </SrcSql>
Summary
The fundamental idea behind using VRT files is to provide the client with more direct control over the way their internal datasets are exposed to Pozi.
Footnote: Although this article has focused on using VRT files to provide some styling control for Pozi clients, VRT files can also be used more extensively to create dynamically manipulated dataset combinations such as, for example, to extract data from multiple database tables via table joins constructed within the VRT file.
For more information about the VRT file format, see https://www.gdal.org/drv_vrt.html.