本文档提供了描述众所周知的几何文本表示的独立参考,该参考在简单功能访问标准第 7 节中进行了完整规定(TODO:当在线有 html 版本时,提供直接到该部分的链接)。
警告:这是一项正在进行的工作,无论如何都不应该被认为是最终的。但我们希望尽快推出完成版本。
TODO:描述 WKT 是什么以及它的用途。
该存储库旨在成为众所周知的文本的权威参考。如果您在寻找官方参考资料时遇到困难,请帮忙!鼓励拉取请求。在这成为明确的参考之前,我们需要一些官方审查,但我们应该迭代以使其更有用。整本书中有很多待办事项,我们可能会发展到使用 github 问题。但我们也希望将其变成一件“小”事,而不是一件大事,只需进行迭代改进并“交付”即可。
下面正式定义了众所周知的文本,但从一些示例开始更容易理解它。
几何类型 | 文本文字表示 | 评论 |
---|---|---|
观点 | 点 (10 10) | 一个点 |
线串 | 线串(10 10、20 20、30 40) | 具有 3 个点的 LineString |
多边形 | 多边形 ((10 10, 10 20, 20 20, 20 15, 10 10)) | 具有 1 个外部环和 0 个内部环的多边形 |
多点 | 多点 ((10 10), (20 20)) | 具有 2 个点的多点 |
多行字符串 | 多线字符串 ((10 10, 20 20), (15 15, 30 15)) | 具有 2 个线串的 MultiLineString |
多重多边形 | 多多边形 (((10 10, 10 20, 20 20, 20 15, 10 10)), ((60 60, 70 70, 80 60, 60 60 )) ) | 具有 2 个多边形的 MultiPolygon |
几何集合 | 几何集合 ( POINT (10 10), POINT (30 30), LINESTRING (15 15, 20 20) ) | 由 2 个 Point 值和一个 LineString 值组成的 GeometryCollection |
多面体 | 多面体 Z (((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)) , ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 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)) ) | 多面体立方体,角位于原点,对角位于 (1, 1, 1)。 |
锡 | 锡 Z (((0 0 0, 0 0 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 0 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 0)),) | 一个四面体(4 个三角形面),原点处的角和每个单位坐标数字。 |
观点 | Z 点 (10 10 5) | 3D 点 |
观点 | 点 ZM (10 10 5 40) | M 值为 40 的相同 3D 点 |
观点 | M 点 (10 10 40) | M 值为 40 的 2D 点 |
TODO:重新审视这些示例,这些示例直接来自规范,但可能更好从核心开始。维基百科做得更好,也许只是复制他们的,还有漂亮的图片:https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
注意:核心规范有 4 个 BNF 定义,分别针对 2d、3d 和“测量”版本。现在我们只包括第 2 个(未测量)
下面使用 BNF 定义了众所周知的几何文本表示形式。
实现的可实例化几何类型的文本表示应符合此语法。众所周知的文本不区分大小写。
注意:所有产生式均按坐标类型分隔。这意味着任何元素的任何两个子元素将始终具有相同的坐标类型,这将是较大包含元素的坐标类型。
本节和下节中的语法旨在支持几何对象的紧凑且可读的文本表示。由一组同质组件组成的几何对象的表示不包括每个嵌入组件的标签。第一组产生式是定义双精度文字。
<x> ::= <signed numeric literal>
<y> ::= <signed numeric literal>
<z> ::= <signed numeric literal>
<m> ::= <signed numeric literal>
<quoted name> ::= <double quote> <name> <double quote>
<name> ::= <letters>
<letters> ::= (<letter>)*
<letter> ::= <simple Latin letter>|<digit>|<special>
<simple Latin letter> ::= <simple Latin upper case letter>|<simple Latin lower case letter>
<signed numeric literal> ::= {<sign>}<unsigned numeric literal>
<unsigned numeric literal> ::= <exact numeric literal>|<approximate numeric literal>
<approximate numeric
literal> ::=
<mantissa>E<exponent>
<mantissa> ::= <exact numeric literal>
<exponent> ::= <signed integer>
<exact numeric literal> ::= <unsigned integer>{<decimal point>{<unsigned integer>}}|<decimal point><unsigned integer>
<signed integer> ::= {<sign>}<unsigned integer>
<unsigned integer> ::= (<digit>)*
<left delimiter> ::= <left paren>|<left bracket> // must match balancing right delimiter
<right delimiter> ::= <right paren>|<right bracket> // must match balancing left delimiter
<special> ::= <right paren>|<left paren>|<minus sign>|<underscore>|<period>|<quote>|<space>
<sign> ::= <plus sign> | <minus sign>
<decimal point> ::= <period> | <comma>
<empty set> ::= EMPTY
<minus sign> ::= -
<left paren> ::= (
<right paren> ::= )
<left bracket> ::= [
<right bracket> ::= ]
<period> ::= .
<plus sign> ::= +
<double quote> ::= "
<quote> ::= '
<comma> ,
<underscore> ::= _
<digit> ::= 0|1|2|3|4|5|6|7|8|9
<simple Latin lower caseletter> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
<simple Latin upper case letter> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
<space>= " "// unicode "U+0020" (space)
TODO:在这里获得一些更好的格式。 CQL.bnf 感觉更干净,但它似乎使用不同的 BNF,因此需要弄清楚这一切是如何工作的。这些可能会放在单独的文档中,并保持主文档更清晰 - 只需讨论它是如何工作的并给出示例
以下 BNF 定义 (x, y) 坐标空间中的二维几何形状。除了添加多面体表面之外,这些结构与本标准的早期版本相比没有变化。
<point> ::= <x> <y>
<geometry tagged text> ::= <point tagged text> | <linestring tagged text> | <polygon tagged text> | <triangle tagged text> | <polyhedralsurface tagged text> | <tin tagged text> | <multipoint tagged text> | <multilinestring tagged text> | <multipolygon tagged text>| <geometrycollection tagged text>
<point tagged text> ::= point <point text>
<linestring tagged text> ::= linestring <linestring text>
<polygon tagged text> ::= polygon <polygon text>
<polyhedralsurface tagged text> ::= polyhedralsurface <polyhedralsurface text>
<triangle tagged text> ::= triangle <polygon text>
<tin tagged text> tin <polyhedralsurface text>
<multipoint tagged text> ::= multipoint <multipoint text>
<multilinestring tagged text> ::= multilinestring <multilinestring text>
<multipolygon tagged text> ::= multipolygon <multipolygon text>
<geometrycollection tagged text> ::= geometrycollection
<geometrycollection text>
<point text> ::= <empty set> | <left paren> <point> <right paren>
<linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren>
<polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
<polyhedralsurface text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>
<multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren>
<multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
<multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>
<geometrycollection text> ::= <empty set> | <left paren> <geometry tagged text> {<comma> <geometry tagged text>}* <right paren>