· WKT
Description geometric object
WKT (well-known text) describes geometric objects through text. The following example shows what WKT is:
Geometric type |
WKT Example |
Description |
Point |
Point (10 10) |
Point |
Linestring |
Linestring (10 10, 20 20, 30 40) |
Line with 3 nodes |
Polygon |
Polygon (10 10, 10 20, 20 20, 20 15, 10 10 )) |
There is only one outer ring polygon. |
Multipoint |
Multipoint ( (10 10 ), (20 20) ) |
Multi-Point |
Multilinestring |
Multilinestring ( (10 10, 20 20 ), (15 15, 30 15) ) |
Multiline |
Multipolygon
|
Multipolygon ( (10 10, 10 20, 20 20, 20 15, 10 10 )), (60 60, 70 70, 80 60, 60 60 )) ) |
Multidimensional |
Geometrycollection |
Geometrycollection ( Point (10 10 ), Point (30 30 ), Linestring (15 15, 20 20) ) |
Geometric set |
Polyhedralsurface |
Polyhedralsurface Z ( (0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 )), (0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 )), (0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 )), (1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 0 )), (0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0 )), (0 0 1, 1 0 1, 1 1 1, 0 1 1. 0 0 1 )) ) |
Cubes composed of multiple Surfaces |
Tin |
Tin Z ( (0 0 0, 0 0 1, 0 1 0, 0 0 )), (0 0 0, 0 1 0, 1 0 0, 0 0 )), (0 0 0, 1 0 0, 0 0 1, 0 0 0 )), (1 0 0, 0 1 0, 0 0 1, 1 0 )), ) |
Tin mesh composed of four triangles |
Point |
Point Z (10 10 5) |
3D point |
Point |
Point ZM (10 10 5 40) |
3D point with M Value |
Point |
Point M (10 10 40) |
Two-dimensional point with M Value |
Table 2 WKT geometric object example
· WKB
Description geometric object
WKB (well-known binary) describes geometric objects through serialized byte objects. WKB mainly involves two numeric types: one is uint32, which occupies 4 bytes, used to store information such as the number of nodes and geometric object type; the other is double, takes 8 bytes to store the node coordinate value. The following table lists the integers corresponding to the geometric object type:
Figure 3 integer corresponding to geometric type in WKB
In addition, WKB stores an additional byte in the first place to identify the byte order [1].
(0 = big-Indian, 1 = little-Indian ). Therefore, for a point (two-dimensional point without m value), its WKB description should be similar to the following structure, occupying a total of 21 Bytes:
Figure 4 the byte structure of the WKB description point
For a line with two nodes, the WKB description should contain 41 Bytes:
Figure 5 the byte structure of the WKB line
For a polygon consisting of only one outer ring and three nodes, the WKB description should contain 77 Bytes:
Figure 6 WKB describe the byte structure of a polygon
· WKT
Description space reference
WKT can describe both geometric objects and spatial references. Two examples show how to use text to describe spatial references.
For a geographic coordinate system, such as the most common WGS84 coordinate system, WKT describes the following:
Geogcs
[
"Gcs_wgs_1984 ",
Datum ["d_wgs_1984", spheroid ["wgs_1984", 6378137.0, 298.257223563],
Primem ["Greenwich", 0.0],
Unit ["degree", 0.0174532925199433],
Authority ["epsg", 4326]
]
"Geogcs" indicates that the following "[]" describes a geographical coordinate system. The coordinate system is named "gcs_wgs_1984" and the d_" is "d_wgs_1984". the Y axis of the oid is 6378137.0 meters and the flat rate is 298.257223563; start with a zero-degree meridian in Greenwich Mean. The unit of the map is degree. The conversion factor of this unit is [2].
0. 0174532925199433 (π/180). Finally, the coordinate system is in the
The encoding is "4326 ".
For a projection coordinate system, such as the WGS84 web Mercator (Auxiliary sphere) coordinate system, WKT describes the following:
Projcs
[
"Wgs_1984_web_mercator_auxiliary_sphere ",
Geogcs
[
"Gcs_wgs_1984 ",
Datum ["d_wgs_1984", spheroid ["wgs_1984", 6378137.0, 298.257223563],
Primem ["Greenwich", 0.0],
Unit ["degree", 0.0174532925199433]
],
Projection ["mercator_auxiliary_sphere"],
Parameter ["false_easting", 0.0],
Parameter ["false_northing", 0.0],
Parameter ["central_meridian", 0.0],
Parameter ["standard_parallel_1", 0.0],
Parameter ["auxiliary_sphere_type", 0.0],
Unit ["meter", 1.0],
Authority ["epsg", 3857]
]
Similarly, "projcs" represents a projection coordinate system. The projection coordinate system must include a geographic coordinate system. The geographic coordinate system here is "gcs_wgs_1984". The definition of this geographic coordinate system is similar to that above. The following is followed by the projection parameters. "mercator_auxiliary_sphere" is the projection name. The projection coordinate system uses the 0-degree longitude line as the central longitude line for projection. The coordinate system is in meters (obviously, the conversion factor is 1.0), and The epsg code of the coordinate system is "3857 ".
[1]
For more information about byte order, see: http://zh.wikipedia.org/zh/%E5%AD%97%E8%8A%82%E5%BA%8F
[2]
The conversion factor indicates the meter (linear unit) represented by a unit or the number of radians (angle unit ).
[3]
Online epsg encoding reference: http://spatialreference.org/ref/epsg/