Ciao Christian, as I mentioned once reading/writing to stream is not really support in coverage io for geotools. Quick solution is to write to a temp file then read as a pure byte stream and send over the cable. Do the opposite on the other side.
It might be possible to quickly add support for reading/writing using streams but I am not sure I we will have time to do that anytime soon. Anyway I would suggest you open up a Jira for this. Notice that this would allow you to write/read a geotiff, as an instace, from a byte array. Simone. ------------------------------------------------------- Ing. Simone Giannecchini GeoSolutions S.A.S. Owner - Software Engineer Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob: +39 333 8128928 http://www.geo-solutions.it http://simboss.blogspot.com/ http://www.linkedin.com/in/simonegiannecchini ------------------------------------------------------- On Thu, Apr 23, 2009 at 3:39 PM, Martin Tomko <[email protected]> wrote: > Dear all, > I need to pass around the results of my coverage processing (a > Coverage2D, or a geotiff, both are acceptable) through an XML (as a > xsd:base64Binary). The coverages will be VERY small. > > In order to do that, I need to serialize the object (the coverage). I > have found some code doing something like that: > public static byte[] toBytes(Object object){ > java.io.ByteArrayOutputStream baos = new > java.io.ByteArrayOutputStream(); > try{ > java.io.ObjectOutputStream oos = new > java.io.ObjectOutputStream(baos); > oos.writeObject(object); > }catch(java.io.IOException ioe){ > } > return baos.toByteArray(); > } > > But it does not seem to work with coverages: > Exception in thread "main" java.lang.IllegalArgumentException: No > Serializers available for the ColorModel. > at > javax.media.jai.remote.SerializableRenderedImage.<init>(SerializableRenderedImage.java:507) > at > javax.media.jai.remote.SerializableRenderedImage.<init>(SerializableRenderedImage.java:390) > at > org.geotools.coverage.grid.GridCoverage2D.writeObject(GridCoverage2D.java:1034) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945) > at > java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461) > at > java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) > at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) > at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) > at ch.uzh.geo.tomko.service.VService.toBytes(VService.java:492) > > It seems that specific serializers are invoked for the rendered image. > Can anyone please point me to a solution? Note that my coverage > currently does not have a color model assigned (it has only 6 values - > In general I need it for DEMs etc...). I tried to set the coverage > ViewType to Geophysics or Rendered, but that did not help. > I need the actual values of the cells to be preserved in the output. > > Thank for any help, > Martin > > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
