| 1 | -------------------------------------------------------------------------
|
|---|
| 2 |
|
|---|
| 3 | TITLE: ZM values and SRID for Simple Features
|
|---|
| 4 |
|
|---|
| 5 | AUTHOR: Name: Sandro Santilli
|
|---|
| 6 | Email: strk@refractions.net
|
|---|
| 7 |
|
|---|
| 8 | DATE: 27 December 2005
|
|---|
| 9 |
|
|---|
| 10 | CATEGORY: Simple Features Revision Proposal
|
|---|
| 11 |
|
|---|
| 12 | -------------------------------------------------------------------------
|
|---|
| 13 |
|
|---|
| 14 | 1. Background
|
|---|
| 15 |
|
|---|
| 16 | OpenGIS document 99-402r2 introduces semantic and well-known
|
|---|
| 17 | representations for Z-geometries. This proposal extend the well-known
|
|---|
| 18 | representations to optionally also hold a measure (M) and a SRID.
|
|---|
| 19 | Misures, as Z values, are attributes of 2D vertexes, but their
|
|---|
| 20 | semantic is unspecified in this document, as they could be used
|
|---|
| 21 | for any kind 'misurement'. SRID is an attribute of the whole feature.
|
|---|
| 22 |
|
|---|
| 23 | This document defines how geometry can have Z,M or both values and SRID
|
|---|
| 24 | in a way which is compatible to the existing 2D OpenGIS Simple Features
|
|---|
| 25 | specification AND to the Z-Geometry documented in OpenGIS 99-402r2.
|
|---|
| 26 |
|
|---|
| 27 | 2. Proposal
|
|---|
| 28 |
|
|---|
| 29 | 2.1. Definition of ZM-Geometry
|
|---|
| 30 |
|
|---|
| 31 | a) A geometry can have either 2, 3 or 4 dimensions.
|
|---|
| 32 | b) 3rd dimension of a 3d geometry can either represent Z or M (3DZ or 3DM).
|
|---|
| 33 | c) 4d geometries contain both Z and M (in this order).
|
|---|
| 34 | d) M and Z values are associated with every vertex.
|
|---|
| 35 | e) M and Z values are undefined within surface interiors.
|
|---|
| 36 |
|
|---|
| 37 | Any ZM-Geometry can be converted into a 2D geometry by discarding all its
|
|---|
| 38 | Z and M values. The resulting 2D geometry is the "shadow" of the ZM-Geometry.
|
|---|
| 39 | 2D geometries cannot be safely converted into ZM-Geometries, since their Z
|
|---|
| 40 | and M values are undefined, and not necessarily zero.
|
|---|
| 41 |
|
|---|
| 42 | 2.2. Extensions to Well-Known-Binary format
|
|---|
| 43 |
|
|---|
| 44 | The 2d OpenGIS Simple Features specification has the following geometry types:
|
|---|
| 45 |
|
|---|
| 46 | enum wkbGeometryType {
|
|---|
| 47 | wkbPoint = 1,
|
|---|
| 48 | wkbLineString = 2,
|
|---|
| 49 | wkbPolygon = 3,
|
|---|
| 50 | wkbMultiPoint = 4,
|
|---|
| 51 | wkbMultiLineString = 5,
|
|---|
| 52 | wkbMultiPolygon = 6,
|
|---|
| 53 | wkbGeometryCollection = 7
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | Document 99-402r2 introduces a Z-presence flag (wkbZ) which OR'ed
|
|---|
| 57 | to the type specifies the presence of Z coordinate:
|
|---|
| 58 |
|
|---|
| 59 | wkbZ = 0x80000000
|
|---|
| 60 |
|
|---|
| 61 | This proposal suggest the use of an M-presence flag (wkbM) to
|
|---|
| 62 | allow for XY, XYM, XYZ and XYZM geometries, and SRID-presence
|
|---|
| 63 | flag to allow for embedded SRID:
|
|---|
| 64 |
|
|---|
| 65 | wkbM = 0x40000000
|
|---|
| 66 | wkbSRID = 0x20000000
|
|---|
| 67 |
|
|---|
| 68 | Possible resulting geometry types are:
|
|---|
| 69 |
|
|---|
| 70 | enum wkbGeometryTypeZ {
|
|---|
| 71 |
|
|---|
| 72 | wkbPoint = 1,
|
|---|
| 73 | wkbLineString = 2,
|
|---|
| 74 | wkbPolygon = 3,
|
|---|
| 75 | wkbMultiPoint = 4,
|
|---|
| 76 | wkbMultiLineString = 5,
|
|---|
| 77 | wkbMultiPolygon = 6,
|
|---|
| 78 | wkbGeometryCollection = 7,
|
|---|
| 79 |
|
|---|
| 80 | // | 0x80000000
|
|---|
| 81 | wkbPointZ = 0x80000001,
|
|---|
| 82 | wkbLineStringZ = 0x80000002,
|
|---|
| 83 | wkbPolygonZ = 0x80000003,
|
|---|
| 84 | wkbMultiPointZ = 0x80000004,
|
|---|
| 85 | wkbMultiLineStringZ = 0x80000005,
|
|---|
| 86 | wkbMultiPolygonZ = 0x80000006,
|
|---|
| 87 | wkbGeometryCollectionZ = 0x80000007,
|
|---|
| 88 |
|
|---|
| 89 | // | 0x40000000
|
|---|
| 90 | wkbPointM = 0x40000001,
|
|---|
| 91 | wkbLineStringM = 0x40000002,
|
|---|
| 92 | wkbPolygonM = 0x40000003,
|
|---|
| 93 | wkbMultiPointM = 0x40000004,
|
|---|
| 94 | wkbMultiLineStringM = 0x40000005,
|
|---|
| 95 | wkbMultiPolygonM = 0x40000006,
|
|---|
| 96 | wkbGeometryCollectionM = 0x40000007,
|
|---|
| 97 |
|
|---|
| 98 | // | 0x40000000 | 0x80000000
|
|---|
| 99 | wkbPointZM = 0xC0000001,
|
|---|
| 100 | wkbLineStringZM = 0xC0000002,
|
|---|
| 101 | wkbPolygonZM = 0xC0000003,
|
|---|
| 102 | wkbMultiPointZM = 0xC0000004,
|
|---|
| 103 | wkbMultiLineStringZM = 0xC0000005,
|
|---|
| 104 | wkbMultiPolygonZM = 0xC0000006,
|
|---|
| 105 | wkbGeometryCollectionZM = 0xC0000007,
|
|---|
| 106 |
|
|---|
| 107 | // | 0x20000000
|
|---|
| 108 | wkbPointS = 0x20000001,
|
|---|
| 109 | wkbLineStringS = 0x20000002,
|
|---|
| 110 | wkbPolygonS = 0x20000003,
|
|---|
| 111 | wkbMultiPointS = 0x20000004,
|
|---|
| 112 | wkbMultiLineStringS = 0x20000005,
|
|---|
| 113 | wkbMultiPolygonS = 0x20000006,
|
|---|
| 114 | wkbGeometryCollectionS = 0x20000007,
|
|---|
| 115 |
|
|---|
| 116 | // | 0x20000000 | 0x80000000
|
|---|
| 117 | wkbPointZS = 0xA0000001,
|
|---|
| 118 | wkbLineStringZS = 0xA0000002,
|
|---|
| 119 | wkbPolygonZS = 0xA0000003,
|
|---|
| 120 | wkbMultiPointZS = 0xA0000004,
|
|---|
| 121 | wkbMultiLineStringZS = 0xA0000005,
|
|---|
| 122 | wkbMultiPolygonZS = 0xA0000006,
|
|---|
| 123 | wkbGeometryCollectionZS = 0xA0000007,
|
|---|
| 124 |
|
|---|
| 125 | // | 0x20000000 | 0x40000000
|
|---|
| 126 | wkbPointMS = 0x60000001,
|
|---|
| 127 | wkbLineStringMS = 0x60000002,
|
|---|
| 128 | wkbPolygonMS = 0x60000003,
|
|---|
| 129 | wkbMultiPointMS = 0x60000004,
|
|---|
| 130 | wkbMultiLineStringMS = 0x60000005,
|
|---|
| 131 | wkbMultiPolygonMS = 0x60000006,
|
|---|
| 132 | wkbGeometryCollectionMS = 0x60000007,
|
|---|
| 133 |
|
|---|
| 134 | // | 0x20000000 | 0x40000000 | 0x80000000
|
|---|
| 135 | wkbPointZMS = 0xE0000001,
|
|---|
| 136 | wkbLineStringZMS = 0xE0000002,
|
|---|
| 137 | wkbPolygonZMS = 0xE0000003,
|
|---|
| 138 | wkbMultiPointZMS = 0xE0000004,
|
|---|
| 139 | wkbMultiLineStringZMS = 0xE0000005,
|
|---|
| 140 | wkbMultiPolygonZMS = 0xE0000006,
|
|---|
| 141 | wkbGeometryCollectionZMS = 0xE0000007,
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 | If the SRID flag is set it's value is encoded as a 4byte integer
|
|---|
| 146 | right after the type integer.
|
|---|
| 147 |
|
|---|
| 148 | If only wkbZ or wkbM flags are set Point coordinates will
|
|---|
| 149 | be XYZ or XYM, if both wkbZ and wkbM flags are set Point
|
|---|
| 150 | coordinates will be XYZM (Z first).
|
|---|
| 151 |
|
|---|
| 152 | For example, a ZM-Point geometry at the location (10,20) with Z==30,
|
|---|
| 153 | M==40 and SRID=4326 would be:
|
|---|
| 154 |
|
|---|
| 155 | WKBPoint {
|
|---|
| 156 |
|
|---|
| 157 | byte byteOrder; // wkbXDR or wkbNDR
|
|---|
| 158 |
|
|---|
| 159 | uint32 wkbType; // (wkbPoint+wkbZ+wkbM+wkbSRID) =
|
|---|
| 160 | // 0xE0000001
|
|---|
| 161 |
|
|---|
| 162 | uint32 SRID; // 4326
|
|---|
| 163 |
|
|---|
| 164 | Point {
|
|---|
| 165 | Double x; // 10.0
|
|---|
| 166 | Double y; // 20.0
|
|---|
| 167 | Double z; // 30.0
|
|---|
| 168 | Double m; // 40.0
|
|---|
| 169 | }
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | 2.3. Extensions to Well-Known-Text format
|
|---|
| 174 |
|
|---|
| 175 | Geometry SRID presence and value would be represented using a
|
|---|
| 176 | "SRID=#;" prefix to the WKT text:
|
|---|
| 177 |
|
|---|
| 178 | "SRID=4326;POINT(1 2)"
|
|---|
| 179 |
|
|---|
| 180 | 3DZ geometry will be represented as:
|
|---|
| 181 |
|
|---|
| 182 | "POINT(1 2 3)"
|
|---|
| 183 |
|
|---|
| 184 | 4D geometry will be represented as:
|
|---|
| 185 |
|
|---|
| 186 | "POINT(1 2 3 4)"
|
|---|
| 187 |
|
|---|
| 188 | 3DM geometry will be represented as:
|
|---|
| 189 |
|
|---|
| 190 | "POINTM(1 2 3)"
|
|---|
| 191 | or
|
|---|
| 192 | "GEOMETRYCOLLECTIONM(POINTM(1 2 3), LINESTRINGM(1 2 3, 4 5 6))"
|
|---|
| 193 |
|
|---|
| 194 | Note that the coordinates structure of a geometry must be consistent,
|
|---|
| 195 | you can't mix dimensions in a single geometry.
|
|---|
| 196 |
|
|---|