Quantcast

Geometry to WKT

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Geometry to WKT

John Cartwright
Hello All,

I'm just looking for a little clarification on converting a Geometry to
it's WKT representation.  It looks to me like Geometry#toString and
Geometry#toText produce the same result. Is there any reason to use one
over the other?  Given both these return the WKT, why would one choose
to use the WKTWriter#write method?

Thanks!

--john


_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

Martin Davis
Right on all counts.

I don't know where that toText method came from - it's a bit redundant.  
It's exactly the same as toString.

WKTWriter supports additional parameters, such as specifying output
should be formatted.  This is why you might want to use an explicit
WKTWriter object, and call write() on it.

Also, WKTWriter reifies the function of writing, which is often useful
in a object-oriented development paradigm (cf the concept of Strategy
classes in GoF).

HTH - Martin

John Cartwright wrote:

> Hello All,
>
> I'm just looking for a little clarification on converting a Geometry
> to it's WKT representation.  It looks to me like Geometry#toString and
> Geometry#toText produce the same result. Is there any reason to use
> one over the other?  Given both these return the WKT, why would one
> choose to use the WKTWriter#write method?
>
> Thanks!
>
> --john
>
>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

John Cartwright
Thanks for your prompt reply Martin and for the explanation!

--john


Martin Davis wrote:

> Right on all counts.
>
> I don't know where that toText method came from - it's a bit
> redundant.  It's exactly the same as toString.
>
> WKTWriter supports additional parameters, such as specifying output
> should be formatted.  This is why you might want to use an explicit
> WKTWriter object, and call write() on it.
> Also, WKTWriter reifies the function of writing, which is often useful
> in a object-oriented development paradigm (cf the concept of Strategy
> classes in GoF).
> HTH - Martin
>
> John Cartwright wrote:
>> Hello All,
>>
>> I'm just looking for a little clarification on converting a Geometry
>> to it's WKT representation.  It looks to me like Geometry#toString
>> and Geometry#toText produce the same result. Is there any reason to
>> use one over the other?  Given both these return the WKT, why would
>> one choose to use the WKTWriter#write method?
>>
>> Thanks!
>>
>> --john
>>
>>
>> _______________________________________________
>> jts-devel mailing list
>> [hidden email]
>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

Ken Tanaka
In reply to this post by John Cartwright
I think that it's reasonable that the methods toString and toText are
the same, but the toString output shouldn't be relied on for WKT
representations--typically toString contains whatever the author of the
API feels is useful to know about the object and its format may change
in future implementations unless the JavaDoc defines and commits to
maintain a given format into the future. The toText is expected conform
to the WKT format

-Ken

John Cartwright wrote:

> Hello All,
>
> I'm just looking for a little clarification on converting a Geometry
> to it's WKT representation.  It looks to me like Geometry#toString and
> Geometry#toText produce the same result. Is there any reason to use
> one over the other?  Given both these return the WKT, why would one
> choose to use the WKTWriter#write method?
>
> Thanks!
>
> --john
>

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

Martin Davis
Good point, Ken.

Maybe even better would be toWKT() and toWKB() methods - that would be
very explicit about what is being returned.

Ken Tanaka wrote:

> I think that it's reasonable that the methods toString and toText are
> the same, but the toString output shouldn't be relied on for WKT
> representations--typically toString contains whatever the author of
> the API feels is useful to know about the object and its format may
> change in future implementations unless the JavaDoc defines and
> commits to maintain a given format into the future. The toText is
> expected conform to the WKT format
>
> -Ken
>
> John Cartwright wrote:
>> Hello All,
>>
>> I'm just looking for a little clarification on converting a Geometry
>> to it's WKT representation.  It looks to me like Geometry#toString
>> and Geometry#toText produce the same result. Is there any reason to
>> use one over the other?  Given both these return the WKT, why would
>> one choose to use the WKTWriter#write method?
>>
>> Thanks!
>>
>> --john
>>
>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

John Cartwright
I like that suggestion even better!

--john


Martin Davis wrote:

> Good point, Ken.
> Maybe even better would be toWKT() and toWKB() methods - that would be
> very explicit about what is being returned.
>
> Ken Tanaka wrote:
>> I think that it's reasonable that the methods toString and toText are
>> the same, but the toString output shouldn't be relied on for WKT
>> representations--typically toString contains whatever the author of
>> the API feels is useful to know about the object and its format may
>> change in future implementations unless the JavaDoc defines and
>> commits to maintain a given format into the future. The toText is
>> expected conform to the WKT format
>>
>> -Ken
>>
>> John Cartwright wrote:
>>> Hello All,
>>>
>>> I'm just looking for a little clarification on converting a Geometry
>>> to it's WKT representation.  It looks to me like Geometry#toString
>>> and Geometry#toText produce the same result. Is there any reason to
>>> use one over the other?  Given both these return the WKT, why would
>>> one choose to use the WKTWriter#write method?
>>>
>>> Thanks!
>>>
>>> --john
>>>
>>
>> _______________________________________________
>> jts-devel mailing list
>> [hidden email]
>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

Martin Davis
Cool - I'll add this for ver 1.11

John Cartwright wrote:

> I like that suggestion even better!
>
> --john
>
>
> Martin Davis wrote:
>> Good point, Ken.
>> Maybe even better would be toWKT() and toWKB() methods - that would
>> be very explicit about what is being returned.
>>
>> Ken Tanaka wrote:
>>> I think that it's reasonable that the methods toString and toText
>>> are the same, but the toString output shouldn't be relied on for WKT
>>> representations--typically toString contains whatever the author of
>>> the API feels is useful to know about the object and its format may
>>> change in future implementations unless the JavaDoc defines and
>>> commits to maintain a given format into the future. The toText is
>>> expected conform to the WKT format
>>>
>>> -Ken
>>>
>>> John Cartwright wrote:
>>>> Hello All,
>>>>
>>>> I'm just looking for a little clarification on converting a
>>>> Geometry to it's WKT representation.  It looks to me like
>>>> Geometry#toString and Geometry#toText produce the same result. Is
>>>> there any reason to use one over the other?  Given both these
>>>> return the WKT, why would one choose to use the WKTWriter#write
>>>> method?
>>>>
>>>> Thanks!
>>>>
>>>> --john
>>>>
>>>
>>> _______________________________________________
>>> jts-devel mailing list
>>> [hidden email]
>>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>>
>>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

John Cartwright
Thanks, that'll be great.  Can you also remove or deprecate the toText
method at that time?

--john

Martin Davis wrote:

> Cool - I'll add this for ver 1.11
>
> John Cartwright wrote:
>> I like that suggestion even better!
>>
>> --john
>>
>>
>> Martin Davis wrote:
>>> Good point, Ken.
>>> Maybe even better would be toWKT() and toWKB() methods - that would
>>> be very explicit about what is being returned.
>>>
>>> Ken Tanaka wrote:
>>>> I think that it's reasonable that the methods toString and toText
>>>> are the same, but the toString output shouldn't be relied on for
>>>> WKT representations--typically toString contains whatever the
>>>> author of the API feels is useful to know about the object and its
>>>> format may change in future implementations unless the JavaDoc
>>>> defines and commits to maintain a given format into the future. The
>>>> toText is expected conform to the WKT format
>>>>
>>>> -Ken
>>>>
>>>> John Cartwright wrote:
>>>>> Hello All,
>>>>>
>>>>> I'm just looking for a little clarification on converting a
>>>>> Geometry to it's WKT representation.  It looks to me like
>>>>> Geometry#toString and Geometry#toText produce the same result. Is
>>>>> there any reason to use one over the other?  Given both these
>>>>> return the WKT, why would one choose to use the WKTWriter#write
>>>>> method?
>>>>>
>>>>> Thanks!
>>>>>
>>>>> --john
>>>>>
>>>>
>>>> _______________________________________________
>>>> jts-devel mailing list
>>>> [hidden email]
>>>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>>>
>>>
>> _______________________________________________
>> jts-devel mailing list
>> [hidden email]
>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Geometry to WKT

Martin Davis
Yeah, I guess it makes sense to deprecate it..

John Cartwright wrote:

> Thanks, that'll be great.  Can you also remove or deprecate the toText
> method at that time?
>
> --john
>
> Martin Davis wrote:
>> Cool - I'll add this for ver 1.11
>>
>> John Cartwright wrote:
>>> I like that suggestion even better!
>>>
>>> --john
>>>
>>>
>>> Martin Davis wrote:
>>>> Good point, Ken.
>>>> Maybe even better would be toWKT() and toWKB() methods - that would
>>>> be very explicit about what is being returned.
>>>>
>>>> Ken Tanaka wrote:
>>>>> I think that it's reasonable that the methods toString and toText
>>>>> are the same, but the toString output shouldn't be relied on for
>>>>> WKT representations--typically toString contains whatever the
>>>>> author of the API feels is useful to know about the object and its
>>>>> format may change in future implementations unless the JavaDoc
>>>>> defines and commits to maintain a given format into the future.
>>>>> The toText is expected conform to the WKT format
>>>>>
>>>>> -Ken
>>>>>
>>>>> John Cartwright wrote:
>>>>>> Hello All,
>>>>>>
>>>>>> I'm just looking for a little clarification on converting a
>>>>>> Geometry to it's WKT representation.  It looks to me like
>>>>>> Geometry#toString and Geometry#toText produce the same result. Is
>>>>>> there any reason to use one over the other?  Given both these
>>>>>> return the WKT, why would one choose to use the WKTWriter#write
>>>>>> method?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> --john
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> jts-devel mailing list
>>>>> [hidden email]
>>>>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>>>>
>>>>
>>> _______________________________________________
>>> jts-devel mailing list
>>> [hidden email]
>>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>>
>>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Loading...