3

The WKT specification allows both period and comma to be the decimal separator in floating-point numbers (section 7.2.1):

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

However, a comma could result in ambiguous WKT representations. In this example, the polygon is specified with five points, but the WKT could also be parsed as having three points:

POLYGON((0 0,0 1,1 1,1 0,0 0))

I'm assuming that nobody deliberately uses , as decimal separator, but is that really true?

Is there any reason to try to parse numbers in WKT with ,? Or shouly I assume that the specification is just buggy?

9
  • 2
    in some locales it is perfectly normal to use , as decimal separator. en.wikipedia.org/wiki/Decimal_mark
    – Ian Turton
    Commented May 17, 2013 at 13:58
  • But why should WKT representations be locale sensitive?
    – CL.
    Commented May 17, 2013 at 13:59
  • but why should they not?
    – Ian Turton
    Commented May 17, 2013 at 14:01
  • Because you'd get ambiguities, as shown in the question.
    – CL.
    Commented May 17, 2013 at 14:03
  • 1
    I think the interpretation of white space removes those ambiguities, from a parsing perspective.
    – L_Holcombe
    Commented May 17, 2013 at 14:15

2 Answers 2

1

Because the coordinate pairs must be separated with a comma, and whitespace is treated as a separator between numbers in a coordinate pair, such ambiguities can be easily worked out by the parser.

(I personally think this is an example of something that could and should be internationally standardized - but then again, I'm also an American who has trouble with the metric system.)

1
POLYGON((0 0,0 1,1 1,1 0,0 0)) 

is not ambiguous, because the number of values for a point cannot be 3 (that would be POLYGON M or POLYGON Z).

That said, at least SpatiaLite doesn't support comma as a decimal separator. I didn't try other applications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.