WKT Format for SUAS MapServer

WKT Format for SUAS MapServeri

Dr. Franz-Josef Behr, Karlsruhe,
franz-josef.behr [at] hft[minus]stuttgart[dot]de

Generally spoken geographical entities can be interpreted to belong to one of these categories:

  • points,
  • lines,
  • polygons.

Each geometry type has a so-called Well-known Text Representation that can be easily generated and parsed by programs and human beings as well.

This format has been published by the Open Geospatial Consortium (OGC) by the specification OpenGIS® Implementation Specification for Geographic information - Simple feature access - Part 1: Common architecture, Version 1.1.0.

In this specification the following geometry types have been taken into consideration:

  • Point
  • LineString
  • Polygon
  • Multipoint
  • MultiLineString
  • MultiPolygon and
  • GeomCollection

Now, what's behind these terms? For a point it might be obvious, but what's with the other geometries?

Point, Linestring, Polygon

In the standard, the term curve is introduced, a "1-dimensional geometric object usually stored as a sequence of Points, with the subtype of Curve specifying the form of the interpolation between Points."

In this context, ISO 19125 defines only one subclass (type) of curve, the linestring, which uses linear interpolation between points.

We can imagine that a linestring is nothing else than a polyline, a term which is used in many GIS.

In a similar way a surface is defined being a 2-dimensional geometric object. A simple Surface consists of a single "patch" that is associated with one "exterior boundary" and 0 or more "interior" boundaries. The only instantiable subclass of surface defined in this specification, Polygon, is a simple surface that is planar.

In Version 1.2.0 of this specification (making the former specification deprecated) this list has been extended by the following geometry types:

  • PolyhedralSurface
  • TIN

Additionally, geometries with height values (z values) and values in a linear reference system are supported.

A binary equivalent, known as well-known binary (WKB) is used to store the same information on databases.

In OGC's Coordinate Transformation Service specifications WKT format is also used to describe spatial reference systems and coordinate transformations.

As you will see in the examples from the specification, Well known text is case insensitive and quite easy to understand.

Point POINT (10 10)
LineString LINESTRING (10 10, 20 20)
Polygon POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))
Multipoint MULTIPOINT (10 10, 20 20)
MultiLineString MULTILINESTRING ((10 10, 20 20),(15 15, 30 15))
MultiPolygon MULTIPOLYGON (((10 10, 10 20, 20 20, 20 15, 10 10)),
((60 60, 70 70, 80 60, 60 60 ) ))
GeomCollection GEOMETRYCOLLECTION (POINT (10 10),
POINT (30 30),
LINESTRING (15 15, 20 20))

WKT format is supported by spatial operations of Database Management Systems like MySQL (version 5), PostGIS, and Oracle.

But perhaps you will notice that labels (textual information) and raster based geodata (gridded data) are not mentioned here at all.

Providing geodata in WKT foramt for SUAS MapServer

SUAS MapServer uses WKT corresponding to Simple feature access Implementation Specification, Version 1.1.0 for uploading data into the database. Internally the WKB format is used to store the geodata in the database.

Each geographical feature is stored in a table record consisting of a unique id, internally provided by SUAS, a layer name, an identifying (perhaps also unique) key provided by the data provider (like you!), information about the geometry type, the bounding box (geographical extents) of the feature, the geometry in WKT format, an optional hyperlink, information about the spatial reference system, alphanumerical attributes, and optional styling information.

SUAS Feature Geometry Table

Alphanumerical attributes are stored using an XML fragment, as shown in the example below:

Uploading point data in SUAS MapServer database

The structure of a CSV record for the import of point data into the SUAS MapServer database looks as follows:

`id` `layer` `recid` `geomtype` Point `xmin` `ymin` `xmax` `ymax` `geom` POINT(15 20) `svgxlink` `srs` `attributes` <attributes>...</attributes> `style`

In order to import point data into the SUAS MapServer database using CSV format, a CSV record looks like this:

;TestCases;TestCases_0001;Point;9.25;51.2333;9.25;51.2333;POINT(9.25 51.2333);;EPSG:4326;<attributes><attribute name='Name' type='C' length='64' dec='0'>Bad Emstal</attribute></attributes>;
Uploading linestring data in SUAS MapServer database

The structure of a CSV record for the import of linestring data into the SUAS MapServer database looks as follows:

`id` `layer` `recid` `geomtype` Point `xmin` `ymin` `xmax` `ymax` `geom` LINESTRING(8.923413 51.145754,9.06189 51.052511) `svgxlink` `srs` `attributes` <attributes>...</attributes> `style`

In order to import linestring data into the SUAS MapServer database using CSV format, a CSV record looks like this:

;TestCases;TestCases_0008;LINESTRING;8.92341;50.712;9.71563;51.1458;LINESTRING(8.923413 51.145754,9.06189 51.052511,8.955617 50.908592,9.106976 50.764673,9.374269 50.744403,9.660885 50.776835,9.715633 50.71197);;EPSG:4326;<attributes><attribute name='Name' type='C' length='64' dec='0'></attribute></attributes>;
Uploading polygon data in SUAS MapServer database

The structure of a CSV record for the import of polygon data into the SUAS MapServer database looks as follows:

`id` `layer` `recid` `geomtype` Point `xmin` `ymin` `xmax` `ymax` `geom` POLYGON((9.583596 51.107241,9.316302 50.884268,9.912077 50.833592,9.989367 51.018051)) `svgxlink` `srs` `attributes` <attributes>...</attributes> `style`

In order to import polygon data into the SUAS MapServer database using CSV format, a CSV record looks like this:

;TestCases;TestCases_0006;POLYGON;9.3163;50.8336;9.98937;51.1072;POLYGON((9.583596 51.107241,9.316302 50.884268,9.912077 50.833592,9.989367 51.018051,9.818685 51.0667,9.583596 51.107241));;EPSG:4326;<attributes><attribute name='Name' type='C' length='64' dec='0'></attribute></attributes>;
Uploading labels in SUAS MapServer database

Labels (text objects) are stored as Point objects in the database. To upload such records into the database, use the following CSV syntax:

`id` `layer` `recid` `geomtype` Text `xmin` `ymin` `xmax` `ymax` `geom` POINT(15 20) `svgxlink` `srs` `attributes` <attributes>...</attributes> `style`

The POINT geometry defines the location of the label. The text itself (and optioally additional parameters) are provided in the attributes field in XML format:


<attributes> <attribute name='Labeltext' type='C' length='64' dec='0'> Bad Emstal </attribute> <attribute name='angle' type='N' length='10' dec='1'> 45.0 </attribute> </attributes>
Referencing raster tiles in SUAS MapServer database

Raster tiles are stored as Linestring objects in the database. To upload such records into the database, use the following CSV syntax:

`id` `layer` `recid` `geomtype` Image `xmin` `ymin` `xmax` `ymax` `geom` LINESTRING(135.0 -270.0, 135.0 -235.0, 180 -235, 180 -270.0, 135.0 -270.0) `svgxlink` rasterimagee/2-7-3rasterimagee/continent-2-7-3.png `srs` `attributes` `style`

The geo attribute desribes the location of the image by its lower left, upper left, upper right and lower right corner.

The svgxlink attribute contains the URL path to the raster file.

dp.SyntaxHighlighter.HighlightAll('codesyntax');