Have look at these methods:

public void testFeatureCollectionWrite() throws Exception { StringWriter writer 
= new StringWriter(); fjson.writeFeatureCollection(collection(), writer); 
assertEquals(strip(collectionText()), writer.toString()); } public void 
testFeatureCollectionRead() throws Exception { FeatureCollection actual = 
fjson.readFeatureCollection(reader(strip(collectionText()))); 
assertNotNull(actual); FeatureCollection expected = collection(); 
assertEquals(expected.size(), actual.size()); Iterator a = actual.iterator(); 
Iterator e = expected.iterator(); while(e.hasNext()) { assertTrue(a.hasNext()); 
assertEqualsLax((SimpleFeature)e.next(), (SimpleFeature) a.next()); } 
actual.close(a); expected.close(e); }
The work with a java Writer; use your http connection and wrap it up as a 
writer on one end; and a reader on the other; and use these two methods as 
shown above:
- readFeatureCollection( reader )
- writeFeatureCollection( featureCollection, writer )

Or send a string over the wire (using whatever remoting software you are happy 
with ) and use a StringWriter as shown in the test case to generate your string 
on one side; and a StringReader on the other end.

-- 
Jody Garnett

On Monday, 25 April 2011 at 12:09 AM, mounir younes wrote: 
> I just read this 
> 
> http://svn.osgeo.org/geotools/trunk/modules/unsupported/geojson/src/test/java/org/geotools/geojson/FeatureJSONTest.java
> 
> but did not really understand how i could send the collection over the 
> network. 
> 
> Can someone help ?
> 
> 
> On Sun, Apr 24, 2011 at 4:47 PM, Jody Garnett <[email protected]> wrote:
> > Oh; and when looking at unsupported module - I would skip looking for 
> > documentation and just go straight to the test cases and read those :-)
> > 
> > Report back with what you find out to the user list; and I can add to the 
> > user guide for the next person. 
> > -- 
> > Jody Garnett
> > 
> > On Sunday, 24 April 2011 at 11:02 PM, mounir younes wrote: 
> > > Could you provide me with more explanation about this please ? where can 
> > > I find appropriate knowledge about it? it didn't find it in the 
> > > unsupported part in the user guide
> > > 
> > >  On Sun, Apr 24, 2011 at 3:58 PM, mounir younes <[email protected]> 
> > > wrote:
> > > > Thank you andrea :D and sorry for the "need help fast" comment ! i just 
> > > > though that when someone reads it he replies asap :D thx again
> > > > 
> > > > 
> > > >  On Sun, Apr 24, 2011 at 3:39 PM, Andrea Aime 
> > > > <[email protected]> wrote:
> > > > >  On Sun, Apr 24, 2011 at 2:01 PM, mounir younes 
> > > > > <[email protected]> wrote:
> > > > > > Hello everyone ! I need to send a feature collection over the 
> > > > > > network ! I
> > > > > > created a class (which holds the feature source) and it implements
> > > > > > serializable.
> > > > > >
> > > > > > The thing is that when I read the object back at the client I get 
> > > > > > this error
> > > > > >
> > > > > > java.io.WriteAbortedException: writing aborted;
> > > > > > java.io.NotSerializableException:
> > > > > > org.geotools.feature.DefaultFeatureCollection
> > > > > >
> > > > > > Which should mean that DefaultFeatureCollection is not serializable 
> > > > > > what
> > > > > > should I do ? should I get the FeatureCollection code and modify it 
> > > > > > to
> > > > > > implement serializable? If yes, where could I get its code from ? 
> > > > > > svn?
> > > > > > (link) ? can someone help? I need help fast! I don't have a lot of 
> > > > > > time :)
> > > > > 
> > > > > Premise: if you want to get help on a given deadline you should get 
> > > > > those
> > > > >  support contract with various support levels that guarantee a 
> > > > > response
> > > > >  within N hours.
> > > > >  This mailing list is providing help on a volunteer basis, so people 
> > > > > help
> > > > >  when they feel to and have time, "I want help fast" "This is urgent" 
> > > > > or
> > > > >  the many variants of this message are annoying.
> > > > > 
> > > > >  That said, nothing in the Feature hierarchy implements Serializable, 
> > > > > if you make
> > > > >  a Serializable collection you'll find that feature themselves are not
> > > > >  serializable.
> > > > > 
> > > > >  Use a format that is meant for the network, such as GML or GeoJSON,
> > > > >  to send over a feature collection.
> > > > > 
> > > > >  I'd suggest you have a look at the gt-geojson module, it's still not 
> > > > > supported
> > > > >  but should give you decent performance without tying the two ends 
> > > > > talking
> > > > >  to be written using the same version of Geotools or, for what is 
> > > > > worth, both
> > > > >  being written in Java.
> > > > > 
> > > > >  Cheers
> > > > >  Andrea
> > > > > 
> > > > >  --
> > > > >  -------------------------------------------------------
> > > > >  Ing. Andrea Aime
> > > > >  GeoSolutions S.A.S.
> > > > >  Tech lead
> > > > > 
> > > > >  Via Poggio alle Viti 1187
> > > > >  55054 Massarosa (LU)
> > > > >  Italy
> > > > > 
> > > > >  phone: +39 0584 962313
> > > > >  fax: +39 0584 962313
> > > > > 
> > > > > http://www.geo-solutions.it
> > > > > http://geo-solutions.blogspot.com/
> > > > > http://www.youtube.com/user/GeoSolutionsIT
> > > > > http://www.linkedin.com/in/andreaaime
> > > > > http://twitter.com/geowolf
> > > > > 
> > > > >  -------------------------------------------------------
> > > > > 
> > > > 
> > > ------------------------------------------------------------------------------
> > > Fulfilling the Lean Software Promise
> > > Lean software platforms are now widely adopted and the benefits have been 
> > >  demonstrated beyond question. Learn why your peers are replacing JEE 
> > > containers with lightweight application servers - and what you can gain 
> > > from the move. http://p.sf.net/sfu/vmware-sfemails
> > > _______________________________________________
> > > Geotools-gt2-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> > > 
> > 
> 
------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to