Not directly with the api. The easiest way would be to create another
graph generator, pull out all the objects from each edges in the
original graph and stick them into the new one.
Graph original = ...
BasicLineGraphGenerator graphGen = new BasicLineGraphGenerator();
for ( Iterator e = original.getEdges().iterator(); e.hasNext(); ) {
Edge edge = (Edge) e.next();
graphGen.add( e.getObject() );
}
Graph copy = graphGen.getGraph();
-Justin
Swan Jerry wrote:
>> The process is similar, just use a BasicLineGraphGenerator.
> Thanks - I'll be happy to start adding examples as appropriate.
>
> Is there a recommended way of performing a deep copy on a Graph? (Node
> and Edge don't seem to be Cloneable...)
>
> Jerry.
>
> -----Original Message-----
> From: Justin Deoliveira [mailto:[EMAIL PROTECTED]
> Sent: 11 April 2007 17:20
> To: Swan Jerry
> Cc: [email protected]
> Subject: Re: [Geotools-gt2-users] Simple graph question
>
> Hi Jerry,
>
> The process is similar, just use a BasicLineGraphGenerator. I have
> updated the page with an example.
>
> -Justin
>
> Swan Jerry wrote:
>> What's the simplest way to create a Feature from a LineSegment?
>>
>>> Any chance you want to help me out by adding this to the code sample
>> page?
>> Someone seems to have beaten me to it while I was on holiday ;-)
>>
>> Jerry.
>>
>> -----Original Message-----
>> From: Justin Deoliveira [mailto:[EMAIL PROTECTED]
>> Sent: 05 April 2007 15:52
>> To: Swan Jerry
>> Cc: [email protected]
>> Subject: Re: [Geotools-gt2-users] Simple graph question
>>
>> Hi Jerry,
>>
>> Once the graph is built each, edge#getObject() will hold the original
>> feature used to built it. So something like
>>
>> for ( Iterator e = graph.getEdges().iterator(); e.hasNext(); ) {
>> Edge edge = (Edge) e.next();
>> Feature feature = (Feature) e.getObject();
>> ..
>> }
>>
>> Good question Jerry. Any chance you want to help me out by adding this
>
>> to the code sample page?
>>
>> -Justin
>>
>> Swan Jerry wrote:
>>>> I have updated that page with a more recent example
>>> Thanks. Given a graph that has been constructed in this fashion, how
>>> should I convert it back into a FeatureCollection?
>>>
>>> I ask because the 'obvious' solution, i.e. using
>>> someFeatureCollection.addAll( graphGetNodes() ) and addAll(
>>> graph.getEdges() ), gives a ClassCastException from BasicNode to
>>> Feature.
>>>
>>> Jerry.
>>>
>>> -----Original Message-----
>>> From: Justin Deoliveira [mailto:[EMAIL PROTECTED]
>>> Sent: 04 April 2007 19:40
>>> To: Swan Jerry
>>> Cc: [email protected]
>>> Subject: Re: [Geotools-gt2-users] Simple graph question
>>>
>>> Hi Jerry,
>>>
>>> I have updated that page with a more recent example of how to build a
>
>>> graph from features on geotools 2.3.x and above.
>>>
>>> Note, i realized that there was a big that has been fixed on trunk,
>>> which i just back ported to 2.3.x. You can get around it though by
>>> using
>>> lineStringGen.getGraph() instead of featureGen.getGraph().
>>>
>>> If you are working from sources though just update and the example
>>> should be just fine.
>>>
>>> Let me know how it works for you.
>>>
>>> -Justin
>>>
>>> Swan Jerry wrote:
>>>> Given a FeatureCollection, I'd like to build an (undirected) graph
>>>> directly corresponding to its feature geometry, i.e. having a node
>>>> for each point.
>>>>
>>>> Would someone kindly recommend the simplest graph building strategy
>>>> for this?
>>>>
>>>> In particular, the example at
>>>> http://docs.codehaus.org/display/GEOTOOLS/Graphs doesn't appear to
>>>> be
>>>> current - AFAIK there's no org.geotools.graph.build.LineGraphBuilder
>>>> in GT2.3.0 (whearas there are of course
>>>> org.geotools.graph.build.line.BasicLineGraphBuilder etc).
>>>>
>>>> Thanks once more,
>>>>
>>>> Jerry.
>>>>
>>>> This message has been checked for viruses but the contents of an
>>>> attachment may still contain software viruses, which could damage
>>>> your
>>> computer system:
>>>> you are advised to perform your own checks. Email communications
>>>> with
>>>> the University of Nottingham may be monitored as permitted by UK
>>> legislation.
>>>> --------------------------------------------------------------------
>>>> -
>>>> -
>>>> --- Take Surveys. Earn Cash. Influence the Future of IT Join
>>>> SourceForge.net's Techsay panel and you'll get the chance to share
>>>> your opinions on IT & business topics through brief surveys-and earn
>
>>>> cash
>>>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=D
>>>> E V DEV _______________________________________________
>>>> Geotools-gt2-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>> --
>>> Justin Deoliveira
>>> The Open Planning Project
>>> [EMAIL PROTECTED]
>>>
>>> This message has been checked for viruses but the contents of an
>>> attachment may still contain software viruses, which could damage
>>> your
>> computer system:
>>> you are advised to perform your own checks. Email communications with
>
>>> the University of Nottingham may be monitored as permitted by UK
>> legislation.
>>> ---------------------------------------------------------------------
>>> -
>>> --- Take Surveys. Earn Cash. Influence the Future of IT Join
>>> SourceForge.net's Techsay panel and you'll get the chance to share
>>> your opinions on IT & business topics through brief surveys-and earn
>>> cash
>>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DE
>>> V DEV _______________________________________________
>>> Geotools-gt2-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>> --
>> Justin Deoliveira
>> The Open Planning Project
>> [EMAIL PROTECTED]
>>
>> This message has been checked for viruses but the contents of an
>> attachment may still contain software viruses, which could damage your
> computer system:
>> you are advised to perform your own checks. Email communications with
>> the University of Nottingham may be monitored as permitted by UK
> legislation.
>>
>> ----------------------------------------------------------------------
>> --- Take Surveys. Earn Cash. Influence the Future of IT Join
>> SourceForge.net's Techsay panel and you'll get the chance to share
>> your opinions on IT & business topics through brief surveys-and earn
>> cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEV
>> DEV _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
> --
> Justin Deoliveira
> The Open Planning Project
> http://topp.openplans.org
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses, which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users