WKT support?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

WKT support?

John R. Frank

Mostly out of curiousity, what, if any, support exists in the vector code
for loading Well-Known Text?  I mean strings like this:

        "POINT ( -71.060280 42.358330 )"

        "MULTIPOLYGON (((-70.82057189941406 42.87516784667969, ...

For further reference:
        http://en.wikipedia.org/wiki/Well-known_text


Also, tschaub:  should GeoJSON use WKT?


John
_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Christopher Schmidt-2
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
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Paul Spencer-2
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
> [hidden email]
> http://openlayers.org/mailman/listinfo/dev

+-----------------------------------------------------------------+
|Paul Spencer                          [hidden email]    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+




_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Christopher Schmidt-2
On Mon, Mar 26, 2007 at 08:39:40AM -0400, Paul Spencer wrote:
> 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.

That's the path I'd like to see encouraged, yeah.

> 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.

Agreed. Geometry.asWKT() is definitely a nice feature that I'd like to
see come in with 2.5 (or with 2.4 if someone cooks up a decent patch
before we get to an RC cycle :))

> 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.

Hm, that sparks a memory that perhaps it was only the MULTI stuff that I
was having problems with. What I remember (this was in my early days of
geo, more than a year ago now) was that copying something from whatever
postgis I had installed (something along the lines of 0.6 or really
early like that) into some tool I was interacating with at the Python
interactive interpreter broke... but this was all long enough ago that
it's certainly possible it's ancient history (or an imaginary part of
history to begin with).  

Regards,
--
Christopher Schmidt
MetaCarta
_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Tim Schaub-2
In reply to this post by John R. Frank
Hey-

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:
>
> "POINT ( -71.060280 42.358330 )"
>
> "MULTIPOLYGON (((-70.82057189941406 42.87516784667969, ...
>

There is currently no WKT support in OpenLayers.  It wouldn't be hard to
write an OpenLayers/Format/WKT.js that could read WKT and return a
geometry or take a geometry and write WKT.

>
> Also, tschaub:  should GeoJSON use WKT?
>

This sort of gets away from the benefits of JSON - in particular the
ability to deserialize data structures into objects that are immediately
useful.  If GeoJSON used WKT, something would still have to parse the
WKT string and make sense of it.

And, since I don't think GeoJSON has been mentioned here before, see
http://geojson.org if you're interested.  My proposal for the format is
demonstrated here:

http://dev.openlayers.org/sandbox/tschaub/geojson/examples/geojson.html

Tim
_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Cameron Shorter
In reply to this post by Christopher Schmidt-2
I seemed to have missed the development of GeoJSON. What is the state of
GeoJSON?
Where is the syntax defined? Is anyone other than OpenLayers using it?
Is it a candidate we should be presenting to the OGC with a
recommendation that it become standardised?

Christopher Schmidt wrote:

>  
>> 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,
>  


--
Cameron Shorter
Systems Architect, http://lisasoft.com.au
Tel: +61 (0)2 8570 5011
Mob: +61 (0)419 142 254

_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Cameron Shorter
Please disregard this email. Tim answered further down the email thread.
I should have read on.

Cameron Shorter wrote:

> I seemed to have missed the development of GeoJSON. What is the state
> of GeoJSON?
> Where is the syntax defined? Is anyone other than OpenLayers using it?
> Is it a candidate we should be presenting to the OGC with a
> recommendation that it become standardised?
>
> Christopher Schmidt wrote:
>>  
>>> 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,
>>  
>
>


--
Cameron Shorter
Systems Architect, http://lisasoft.com.au
Tel: +61 (0)2 8570 5011
Mob: +61 (0)419 142 254

_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WKT support?

Tim Schaub-2
In reply to this post by John R. Frank
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:
>

The 2.4 release will have read/write support for the WKT representation
of geometries (for simple features).

http://openlayers.org/dev/examples/wkt.html

You also now get well-known text when you use a geometry in a string
context.

Tim

_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev