[OpenLayers-Dev] WKT support?
Paul Spencer
pspencer at dmsolutions.ca
Mon Mar 26 08:39:40 EDT 2007
WKT could be useful in a few scenarios. PostGIS, for instance,
stores geometries in WKT - or WKB (well known binary) with easy
access to a WKT version - which makes it convenient for working with
features (or rather, their geometries) in a PostGIS database.
MapGuide Open Source also has methods to dump feature geometries into
WKT format. And MapServer/MapScript can now create features from WKT.
OTOH, it would probably be more efficient to convert said WKT into
GeoJSON before returning it to the browser and thus reduce the client
load.
If WKT support is added, I would prefer to use Chris' approach of
having a couple of utility functions that go to/from geometries ...
and also discourage general use of WKT in favour of something like
GeoJSON. I would actually see more use in having a Geometry.asWKT()
function to work with various server-side pieces that support WKT
directly rather than having to futz with GML conversion at both ends.
Re the 'well known' part, I have not directly run into problems with
this myself, but I have worked mostly with the simple types (POINT,
LINE, POLYGON) which do seem to be pretty standard. Given the types
of geometry that OpenLayers supports, I think these three would be
all that would be required (for output anyway) and would be pretty
standard.
Cheers
Paul
On 26-Mar-07, at 7:51 AM, Christopher Schmidt wrote:
> On Sun, Mar 25, 2007 at 08:38:25PM -0500, John R. Frank wrote:
>>
>> Mostly out of curiousity, what, if any, support exists in the
>> vector code
>> for loading Well-Known Text? I mean strings like this:
>
> None at the moment. There are two reasons for this:
> * WKT is seldom used as an interchange format. Typically, for
> interchange, data is converted to GML, and GML has a seperate
> notion
> of how to describe geometry.
>
> This is actually most important, because there is no service to
> test
> support against. In almost every case, we've set up an example
> of our
> support for a particular format via a file in the examples/
> directory: if we have no service, we can't have an example/ file
> very
> easily, and that delays adoption into the source of OpenLayers.
>
> * The "Well-Known" part of WKT is not entirely clear to me. I have
> copied WKT from one supposed "Well-Known" text parser to
> another, and
> had that text break. Without a wide variety of samples -- or a
> constrained target -- WKT support could be confusing to users.
> (I'd
> be glad to be told I was wrong on this, and that my description is
> wrong, and everyone uses the same WKT. Really glad. I just am not
> convinced with my limited experience.)
>
> Utility functions for parsing WKT would be welcome, though. Since it
> isn't a "format" per se -- it describes only geometries, not
> features --
> they probably belong in ... hm. Perhaps Util, perhaps somewhere else?
> Maybe OpenLayers.Geometry.createFromWKT() or something, a static
> function in the geometry namespace. Other devs might have more
> opinions
> on that.
>
>> Also, tschaub: should GeoJSON use WKT?
>
> No, please God no :)
>
> * GeoJSON is designed such that it can be dropped in a callback with
> *no parsing* and used to create feature objects in javascript.
> Parsing coordinate pairs out of long geometries for GML can
> take up to 30% of the time of working with WFS layers; GeoJSON's
> coordinate support removes this parsing time. (Up to another 30%
> can be attribute parsing: this removes that cost as well.) WKT to
> Javascript is basically unstructured content -- which is harder to
> parse. GeoJSOn is designed to fix that problem.
>
> * The above-mentioned "WKT isn't so well known" possibility still
> applies.
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Chief Technology Officer |
|DM Solutions Group Inc http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+
More information about the Dev
mailing list