WKTGeometry: one of WKTPoint WKTLineString WKTLinearRing WKTPolygon WKTMultiPoint WKTMultiLineString WKTMultiPolygon WKTGeometryCollection WKTPoint: POINT ( Coordinate ) WKTLineString: LINESTRING CoordinateSequence WKTLinearRing: LINEARRING CoordinateSequence WKTPolygon: POLYGON CoordinateSequenceList WKTMultiPoint: MULTIPOINT CoordinateSequence WKTMultiLineString: MULTILINESTRING CoordinateSequenceList WKTMultiPolygon: MULTIPOLYGON ( CoordinateSequenceList { , CoordinateSequenceList } ) WKTGeometryCollection: GEOMETRYCOLLECTION ( WKTGeometry { , WKTGeometry } ) CoordinateSequenceList: ( CoordinateSequence { , CoordinateSequence } ) CoordinateSequence: ( Coordinate { , Coordinate } ) Coordinate: Number Number Numberopt Number: A Java-style floating-point number |
The WKB orignally defined in the OGC-SFS supports only 2-dimensional coordinates. Since many systems need to support 3-D coordinates, an extension to WKB has been informally defined as EWKB. It extends the WKB spec to allow representing geometry with 3-D coordinates. Each WKB packet is tagged to indicate whether it contains 2 or 3 dimensional coordinates. JTS supports the EWKB extension.
The following syntax specification describes the version of Well-Known Binary supported by JTS. The specification uses a language similar to the C type description syntax. Note the use of bit-field specifiers to define how the dimension indicator and the geometry type code are stored in the same 32-bit word.
Coordinate { double x; double y; [ double z; ] // only if 3-D } CoordinateSeq { uint32 numCoords; Coordinate pts[numCoords]; } enum wkbGeometryType { wkbPoint = 1, wkbLineString = 2, wkbPolygon = 3, wkbMultiPoint = 4, wkbMultiLineString = 5, wkbMultiPolygon = 6, wkbGeometryCollection = 7 } enum wkbByteOrder { wkbXDR = 0, // Big Endian wkbNDR = 1 // Little Endian } enum wkbDimension { is2D = 0, // 2-D coordinates is3D = 1 // 3-D coordinates } WKBType { uint32 dimension : 1; uint32 geomType : 31; } WKBGeometry { union { WKBPoint point; WKBLineString linestring; WKBPolygon polygon; WKBGeometryCollection collection; WKBMultiPoint mpoint; WKBMultiLineString mlinestring; WKBMultiPolygon mpolygon; } } WKBPoint { byte byteOrder; WKBType wkbType; // = 1 Coordinate point; } WKBLineString { byte byteOrder; WKBType wkbType; // = 2 CoordinateSeq seq; } WKBPolygon { byte byteOrder; WKBType wkbType; // = 3 uint32 numItems; CoordinateSeq rings[numItems]; } WKBMultiPoint { byte byteOrder; WKBType wkbType; // = 4 CoordinateSeq seq; } WKBMultiLineString { byte byteOrder; WKBType wkbType; // = 5 uint32 numItems; WKBLineString wkbLineStrings[numItems]; } WKBMultiPolygon { byte byteOrder; WKBType wkbType; // = 6 uint32 numItems; WKBPolygon wkbPolygons[numItems]; } WKBGeometryCollection { byte byteOrder; WKBType wkbType; // = 7 uint32 numItems; WKBGeometry wkbGeometries[numItems]; } |