[geos-devel] WKT / WKB Writer Output Dimension

Frank Warmerdam warmerdam at pobox.com
Wed May 26 00:41:53 EDT 2010

Martin Davis wrote:
> FWIW, the semantics of JTS were intended to be that setting the output 
> dimension determines the *maximum* number of dimensions written.  If the 
> input geometry does not provide that many dimensions, the extra ones are 
> not written.  So this is somewhat equivalent to "letting the input 
> geometry determine the number of dimensions to output".


Gotcha. I'll take the same approach in GEOS then.  I see now the
WKBWriter is actually broken if output dimension is set to 3 and a
2D geometry is passed in but that is just a bug.


I'll fix that while applying the suggest behavior.

> The WKTWriter accepts this value in the constructor.  WKTWriter was 
> intended to be a lightweight immutable class, so this makes sense for 
> Java.  In the C world perhaps it's better to have an explicit setter.

Output Dimension can be set in the constructor of the WKBWriter, but
also via a later setter.  I'll try to following the WKBWriter pattern
in the WKTWriter.

> If you want to force always outputting a given number of dimensions, 
> would you want to support supplying a default value for missing 
> dimensions? Or just default to 0?

Since I'm not going to force 3D output it doesn't matter, but if I had
been going to do so I would have wanted to write 0.

> Seems like a good idea to support outputting the new syntax, via a flag.

Note that I'll default to writing the new syntax.  I'm not sure if I
will support writing the old syntax or not via a flag.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the geos-devel mailing list