JTS KML?

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

JTS KML?

Lee Goddard-3-3
Could someone please recommend a good starting-point for KML from JTS
objects?

Conversion is very slow the way I'm doing it.

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

Re: JTS KML?

Martin Davis
You mean you want a way to convert JTS objects to KML?

This is pretty straightforward - just write out the text of the KML,
producing the geometry elements by traversing the JTS geometry.  Check
out GMLWriter for an example. In fact, as long as you don't need to use
the KML elements which are embedded in the geometry, you can probably
use the GMLWriter directly (or with minor modification).

Hard to see how the efficiency of this process can vary by much.  How
are you doing it?

Lee Goddard wrote:

> Could someone please recommend a good starting-point for KML from JTS
> objects?
>
> Conversion is very slow the way I'm doing it.
>
> Thanks in anticipation
> Lee
> _______________________________________________
> 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
|

Re: JTS KML?

Lee Goddard-3-3
Thanks, Martin. I just hoped that there might be a faster in-built
mechanism, but I don't see how that's possible.

Cheers
Lee

Martin Davis wrote:

> You mean you want a way to convert JTS objects to KML?
>
> This is pretty straightforward - just write out the text of the KML,
> producing the geometry elements by traversing the JTS geometry.  Check
> out GMLWriter for an example. In fact, as long as you don't need to
> use the KML elements which are embedded in the geometry, you can
> probably use the GMLWriter directly (or with minor modification).
>
> Hard to see how the efficiency of this process can vary by much.  How
> are you doing it?
>
> Lee Goddard wrote:
>> Could someone please recommend a good starting-point for KML from JTS
>> objects?
>>
>> Conversion is very slow the way I'm doing it.
>>
>> Thanks in anticipation
>> Lee


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

Re: JTS KML?

Martin Davis
Lee,

One common cause of slowness in string generation is to use string
concatenation ("+") rather than appending to a StringBuffer.  Could that
be what you're experiencing?

Lee Goddard wrote:

> Thanks, Martin. I just hoped that there might be a faster in-built
> mechanism, but I don't see how that's possible.
>
> Cheers
> Lee
>
> Martin Davis wrote:
>> You mean you want a way to convert JTS objects to KML?
>>
>> This is pretty straightforward - just write out the text of the KML,
>> producing the geometry elements by traversing the JTS geometry.  
>> Check out GMLWriter for an example. In fact, as long as you don't
>> need to use the KML elements which are embedded in the geometry, you
>> can probably use the GMLWriter directly (or with minor modification).
>>
>> Hard to see how the efficiency of this process can vary by much.  How
>> are you doing it?
>>
>> Lee Goddard wrote:
>>> Could someone please recommend a good starting-point for KML from
>>> JTS objects?
>>>
>>> Conversion is very slow the way I'm doing it.
>>>
>>> Thanks in anticipation
>>> Lee
>
>
> _______________________________________________
> 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
|

Re: JTS KML?

Lee Goddard-3-3

Could be! Been a few yaers since I did Java, only picking it up again
recently. StringBuffer it is!
Thanks
Lee

Martin Davis wrote:

> Lee,
>
> One common cause of slowness in string generation is to use string
> concatenation ("+") rather than appending to a StringBuffer.  Could
> that be what you're experiencing?
>
> Lee Goddard wrote:
>> Thanks, Martin. I just hoped that there might be a faster in-built
>> mechanism, but I don't see how that's possible.
>>
>> Cheers
>> Lee
>>
>> Martin Davis wrote:
>>> You mean you want a way to convert JTS objects to KML?
>>>
>>> This is pretty straightforward - just write out the text of the KML,
>>> producing the geometry elements by traversing the JTS geometry.  
>>> Check out GMLWriter for an example. In fact, as long as you don't
>>> need to use the KML elements which are embedded in the geometry, you
>>> can probably use the GMLWriter directly (or with minor modification).
>>>
>>> Hard to see how the efficiency of this process can vary by much.  
>>> How are you doing it?
>>>
>>> Lee Goddard wrote:
>>>> Could someone please recommend a good starting-point for KML from
>>>> JTS objects?
>>>>
>>>> Conversion is very slow the way I'm doing it.
>>>>
>>>> Thanks in anticipation


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

Re: JTS KML?

David Zwiers
Depending on the Java version you are using, you may also consider
StringBuilder.

David

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Lee
Goddard
Sent: October 8, 2009 9:13 AM
To: JTS Topology Suite Development
Subject: Re: [jts-devel] JTS KML?


Could be! Been a few yaers since I did Java, only picking it up again
recently. StringBuffer it is!
Thanks
Lee

Martin Davis wrote:

> Lee,
>
> One common cause of slowness in string generation is to use string
> concatenation ("+") rather than appending to a StringBuffer.  Could
> that be what you're experiencing?
>
> Lee Goddard wrote:
>> Thanks, Martin. I just hoped that there might be a faster in-built
>> mechanism, but I don't see how that's possible.
>>
>> Cheers
>> Lee
>>
>> Martin Davis wrote:
>>> You mean you want a way to convert JTS objects to KML?
>>>
>>> This is pretty straightforward - just write out the text of the KML,

>>> producing the geometry elements by traversing the JTS geometry.  
>>> Check out GMLWriter for an example. In fact, as long as you don't
>>> need to use the KML elements which are embedded in the geometry, you

>>> can probably use the GMLWriter directly (or with minor
modification).

>>>
>>> Hard to see how the efficiency of this process can vary by much.  
>>> How are you doing it?
>>>
>>> Lee Goddard wrote:
>>>> Could someone please recommend a good starting-point for KML from
>>>> JTS objects?
>>>>
>>>> Conversion is very slow the way I'm doing it.
>>>>
>>>> Thanks in anticipation


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

Merging many polygons

Lee Goddard-3-3
I have several million points that compose several thousand polygons,
and I'm outputting KMZ.

The KMZ is about 2MB, and I'm trying to reduce the size by merging
polygons that have adjecent edges, and drop those that are contained
within others.

I have created to arrays of polygons: one of all unprocessed, one empty.
For each unprocessed polygon, I try to compare it the processed,
dropping the unprocessed or merging it, as appropriate.

This seems frr from ideal. This must be a common task, but being new to
JTS and topology in general, I'm not sure if I should be able to find a
method to do this for me, or if I should continue trying to do it my own
way?

Thanks
Lee

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

Re: Merging many polygons

Martin Davis
One way you can speed this up is to use a spatial index on your
processed polygon set.  You'll be updating it as you merge polygons, so
it needs to be a Quadtree.

Do you have attributes attached to your polygons?  If *not*, then you
could cluster polygons together (ie spatially by proximity) and then use
UnaryUnion to merge them all together at once (ie
GeometryCollection.union())  One way to cluster the polygons is to make
a coarse grid over the extent of the polygons, assign each polygon to
the grid cell containing it's centroid, then take each grid cell group
as a cluster.



Lee Goddard wrote:

> I have several million points that compose several thousand polygons,
> and I'm outputting KMZ.
>
> The KMZ is about 2MB, and I'm trying to reduce the size by merging
> polygons that have adjecent edges, and drop those that are contained
> within others.
>
> I have created to arrays of polygons: one of all unprocessed, one
> empty. For each unprocessed polygon, I try to compare it the
> processed, dropping the unprocessed or merging it, as appropriate.
>
> This seems frr from ideal. This must be a common task, but being new
> to JTS and topology in general, I'm not sure if I should be able to
> find a method to do this for me, or if I should continue trying to do
> it my own way?
>
> Thanks
> Lee
>
> _______________________________________________
> 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
|

Re: Merging many polygons

Lee Goddard-3-3

That's a good idea, and makes sense.

But won't I still need to check that the polygons are able to merge? If
I supply two disconnected polygons to the union function, I imagine it
won't be happy?

Martin Davis wrote:

> One way you can speed this up is to use a spatial index on your
> processed polygon set.  You'll be updating it as you merge polygons,
> so it needs to be a Quadtree.
>
> Do you have attributes attached to your polygons?  If *not*, then you
> could cluster polygons together (ie spatially by proximity) and then
> use UnaryUnion to merge them all together at once (ie
> GeometryCollection.union())  One way to cluster the polygons is to
> make a coarse grid over the extent of the polygons, assign each
> polygon to the grid cell containing it's centroid, then take each grid
> cell group as a cluster.
>
>
>
> Lee Goddard wrote:
>> I have several million points that compose several thousand polygons,
>> and I'm outputting KMZ.
>>
>> The KMZ is about 2MB, and I'm trying to reduce the size by merging
>> polygons that have adjecent edges, and drop those that are contained
>> within others.
>>
>> I have created to arrays of polygons: one of all unprocessed, one
>> empty. For each unprocessed polygon, I try to compare it the
>> processed, dropping the unprocessed or merging it, as appropriate.
>>
>> This seems frr from ideal. This must be a common task, but being new
>> to JTS and topology in general, I'm not sure if I should be able to
>> find a method to do this for me, or if I should continue trying to do
>> it my own way?
>>

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

Re: Merging many polygons

Martin Davis
Nope, union is quite happy accepting disjoint polygons.  The output will
be a MultiPolygon containing the disjoint polys as components.

Lee Goddard wrote:

>
> That's a good idea, and makes sense.
>
> But won't I still need to check that the polygons are able to merge?
> If I supply two disconnected polygons to the union function, I imagine
> it won't be happy?
>
> Martin Davis wrote:
>> One way you can speed this up is to use a spatial index on your
>> processed polygon set.  You'll be updating it as you merge polygons,
>> so it needs to be a Quadtree.
>>
>> Do you have attributes attached to your polygons?  If *not*, then you
>> could cluster polygons together (ie spatially by proximity) and then
>> use UnaryUnion to merge them all together at once (ie
>> GeometryCollection.union())  One way to cluster the polygons is to
>> make a coarse grid over the extent of the polygons, assign each
>> polygon to the grid cell containing it's centroid, then take each
>> grid cell group as a cluster.
>>
>>
>>
>> Lee Goddard wrote:
>>> I have several million points that compose several thousand
>>> polygons, and I'm outputting KMZ.
>>>
>>> The KMZ is about 2MB, and I'm trying to reduce the size by merging
>>> polygons that have adjecent edges, and drop those that are contained
>>> within others.
>>>
>>> I have created to arrays of polygons: one of all unprocessed, one
>>> empty. For each unprocessed polygon, I try to compare it the
>>> processed, dropping the unprocessed or merging it, as appropriate.
>>>
>>> This seems frr from ideal. This must be a common task, but being new
>>> to JTS and topology in general, I'm not sure if I should be able to
>>> find a method to do this for me, or if I should continue trying to
>>> do it my own way?
>>>
>
> _______________________________________________
> 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
|

Re: Merging many polygons

Lee Goddard-3-3

Wow. I love JTS. Is there a book on the library you would recommend?

Martin Davis wrote:

> Nope, union is quite happy accepting disjoint polygons.  The output
> will be a MultiPolygon containing the disjoint polys as components.
>
> Lee Goddard wrote:
>>
>> That's a good idea, and makes sense.
>>
>> But won't I still need to check that the polygons are able to merge?
>> If I supply two disconnected polygons to the union function, I
>> imagine it won't be happy?
>>
>> Martin Davis wrote:
>>> One way you can speed this up is to use a spatial index on your
>>> processed polygon set.  You'll be updating it as you merge polygons,
>>> so it needs to be a Quadtree.
>>>
>>> Do you have attributes attached to your polygons?  If *not*, then
>>> you could cluster polygons together (ie spatially by proximity) and
>>> then use UnaryUnion to merge them all together at once (ie
>>> GeometryCollection.union())  One way to cluster the polygons is to
>>> make a coarse grid over the extent of the polygons, assign each
>>> polygon to the grid cell containing it's centroid, then take each
>>> grid cell group as a cluster.
>>>
>>>
>>>
>>> Lee Goddard wrote:
>>>> I have several million points that compose several thousand
>>>> polygons, and I'm outputting KMZ.
>>>>
>>>> The KMZ is about 2MB, and I'm trying to reduce the size by merging
>>>> polygons that have adjecent edges, and drop those that are
>>>> contained within others.
>>>>
>>>> I have created to arrays of polygons: one of all unprocessed, one
>>>> empty. For each unprocessed polygon, I try to compare it the
>>>> processed, dropping the unprocessed or merging it, as appropriate.
>>>>
>>>> This seems frr from ideal. This must be a common task, but being
>>>> new to JTS and topology in general, I'm not sure if I should be
>>>> able to find a method to do this for me, or if I should continue
>>>> trying to do it my own way?
>>>>
>>
>> _______________________________________________
>> jts-devel mailing list
>> [hidden email]
>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.409 / Virus Database: 270.14.2/2408 - Release Date: 10/01/09 18:23:00
>
>  

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

Re: Merging many polygons

Martin Davis
Great!

No book yet unfortunately...  I did approach O'Reilly at one time, but
nothing came of it.  It would be nice to have for sure...

Lee Goddard wrote:

>
> Wow. I love JTS. Is there a book on the library you would recommend?
>
> Martin Davis wrote:
>> Nope, union is quite happy accepting disjoint polygons.  The output
>> will be a MultiPolygon containing the disjoint polys as components.
>>
>> Lee Goddard wrote:
>>>
>>> That's a good idea, and makes sense.
>>>
>>> But won't I still need to check that the polygons are able to merge?
>>> If I supply two disconnected polygons to the union function, I
>>> imagine it won't be happy?
>>>
>>> Martin Davis wrote:
>>>> One way you can speed this up is to use a spatial index on your
>>>> processed polygon set.  You'll be updating it as you merge
>>>> polygons, so it needs to be a Quadtree.
>>>>
>>>> Do you have attributes attached to your polygons?  If *not*, then
>>>> you could cluster polygons together (ie spatially by proximity) and
>>>> then use UnaryUnion to merge them all together at once (ie
>>>> GeometryCollection.union())  One way to cluster the polygons is to
>>>> make a coarse grid over the extent of the polygons, assign each
>>>> polygon to the grid cell containing it's centroid, then take each
>>>> grid cell group as a cluster.
>>>>
>>>>
>>>>
>>>> Lee Goddard wrote:
>>>>> I have several million points that compose several thousand
>>>>> polygons, and I'm outputting KMZ.
>>>>>
>>>>> The KMZ is about 2MB, and I'm trying to reduce the size by merging
>>>>> polygons that have adjecent edges, and drop those that are
>>>>> contained within others.
>>>>>
>>>>> I have created to arrays of polygons: one of all unprocessed, one
>>>>> empty. For each unprocessed polygon, I try to compare it the
>>>>> processed, dropping the unprocessed or merging it, as appropriate.
>>>>>
>>>>> This seems frr from ideal. This must be a common task, but being
>>>>> new to JTS and topology in general, I'm not sure if I should be
>>>>> able to find a method to do this for me, or if I should continue
>>>>> trying to do it my own way?
>>>>>
>>>
>>> _______________________________________________
>>> jts-devel mailing list
>>> [hidden email]
>>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database:
>> 270.14.2/2408 - Release Date: 10/01/09 18:23:00
>>
>>  
>
> _______________________________________________
> 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
|

Re: Book

Lee Goddard-3-3
Martin Davis wrote:
> No book yet unfortunately...  I did approach O'Reilly at one time, but
> nothing came of it.  It would be nice to have for sure...
Nice? Essential! This is such a powerful and well-supported library, it
deserves a book. O'Reilly are good (I'm from Perl), but there are
others: Wrox sprigns to mind.

 From watching the list for a while, you and Mike would seem to be a
good pair to write it, no?


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

Re: Book

Martin Davis
Mike?  You mean Michael Bedward?  It would certainly be motivating to
have a partner to write with...

And yeah, Wrox would be good, or there are some other publishers as well
I think.  JTS for Dummies?  JTS in Action?  Essential JTS?

I'm game if someone else is keen to collaborate...

Martin



Lee Goddard wrote:

> Martin Davis wrote:
>> No book yet unfortunately...  I did approach O'Reilly at one time,
>> but nothing came of it.  It would be nice to have for sure...
> Nice? Essential! This is such a powerful and well-supported library,
> it deserves a book. O'Reilly are good (I'm from Perl), but there are
> others: Wrox sprigns to mind.
>
> From watching the list for a while, you and Mike would seem to be a
> good pair to write it, no?
>
>
> _______________________________________________
> 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
|

Re: Book

Jeff Adams-4
"JTS For The Win"

On Thu, Oct 8, 2009 at 2:22 PM, Martin Davis <[hidden email]> wrote:
Mike?  You mean Michael Bedward?  It would certainly be motivating to have a partner to write with...

And yeah, Wrox would be good, or there are some other publishers as well I think.  JTS for Dummies?  JTS in Action?  Essential JTS?

I'm game if someone else is keen to collaborate...

Martin




Lee Goddard wrote:
Martin Davis wrote:
No book yet unfortunately...  I did approach O'Reilly at one time, but nothing came of it.  It would be nice to have for sure...
Nice? Essential! This is such a powerful and well-supported library, it deserves a book. O'Reilly are good (I'm from Perl), but there are others: Wrox sprigns to mind.

From watching the list for a while, you and Mike would seem to be a good pair to write it, no?


_______________________________________________
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



--
Jeff Adams
Avencia, Inc.
215-701-7717

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

Re: Book

Lee Goddard-3-3
In reply to this post by Martin Davis
Micheal, yes, sorry: Michael, Mike and even a Mick here at the moment.

Maybe not For Dummies, but the others, sure. Are Wiley still around?


Martin Davis wrote:

> Mike?  You mean Michael Bedward?  It would certainly be motivating to
> have a partner to write with...
>
> And yeah, Wrox would be good, or there are some other publishers as
> well I think.  JTS for Dummies?  JTS in Action?  Essential JTS?
>
> I'm game if someone else is keen to collaborate...
>
> Martin
>
>
>
> Lee Goddard wrote:
>> Martin Davis wrote:
>>> No book yet unfortunately...  I did approach O'Reilly at one time,
>>> but nothing came of it.  It would be nice to have for sure...
>> Nice? Essential! This is such a powerful and well-supported library,
>> it deserves a book. O'Reilly are good (I'm from Perl), but there are
>> others: Wrox sprigns to mind.
>>
>> From watching the list for a while, you and Mike would seem to be a
>> good pair to write it, no?
>>
>>


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