本文檔提供了描述眾所周知的幾何文字表示的獨立參考,該參考在簡單功能存取標準第 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>