[OpenLayers-Dev] What is right format for WKT in OpenLayers (comma white space vs. comma)?

Trond Michelsen trondmm-openlayers at crusaders.no
Thu Jun 9 04:48:25 EDT 2011


On Thu, Jun 09, 2011 at 06:24:48PM +1000, Noli Sicad wrote:
> I ask this question a few hours ago about why the comma white space
> format of my LINESTRING would not work  in Openlayers WKT example and
> I got the answer that my LINESTRING has wrong format i.e comma white
> space format.

Well, the official standard says:
http://www.opengeospatial.org/standards/sfa

<x>           ::= <signed numeric literal>
<y>           ::= <signed numeric literal>
<point>       ::= <x> <y>
<left paren>  ::= (
<right paren> ::= )
<comma>       ::= ,
<space>       ::= " "
<linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren>

So, "space" is not explicitly mentioned to be allowed between the
comma and the point, but it's not explicitly mentioned between the x
and y values of the point either.

However, the standard also says:

<decimal point> ::= <period> | <comma>

So, both "5.4" and "5,4" must be accepted. If you omit the space
behind the comma, it'll be impossible to correctly parse a string like
this:

linestring(1,2 0,3,5 3,2)

Should this be parsed as 

linestring(1.2 0.3, 5 3.2) or linestring(1.2 0, 3.5 3.2)?

So basically, the standard is a bit ambigous. A space in a definition
is optional or mandatory depending on where you find it.

-- 
Trond Michelsen


More information about the Dev mailing list