Even better, if I could serialize a referenced envelope, which should be 
serializable already, that would be a quick workaround.
So in principle I should be able to create a TransportImage as you 
mention, with the two elements (Rendered Image, ReferencedEnvelope), and 
then to decode it I will deserialize, cast to TransportImage and extract 
everything, right?

Will give it a try, thanks! Still, a more generic solution would be 
preferable.
Martin

Christian Müller wrote:
> Another idea for a quick solution is to serialize a world file as well.
> A world file has only 6 lines, see here 
> http://en.wikipedia.org/wiki/World_file
> class TransportImage implements Serializable {
>    SerializabelRenderedImage theImage;
>    Double[] wordlFileLines;
> }
> That is all you need to construct a georeferenced image.
> Simone, what is the quickest way to create a Coverage2D having the 
> lines of a world file ?
>
>
>
> Martin Tomko writes:
>> Dear Simone,
>> I will try to provide a case for JIRA, somewhere around Monday, no 
>> time to do it before.
>> In the mean time - it is quite urgent for me to find a solution to 
>> pass the GridCoverrage2D around - could you please elaborate how you 
>> would serialize the coverage and consequently apply the styling? I 
>> only applied the styling (I have no need for it), because I was 
>> getting the error resulting from the lack of color model, or rather 
>> the inabiity to serialize it.
>> The approach mentioned by Christian and later Martin:
>> new SerializableRenderedImage(outcov.getRenderedImage())
>>  does seem to only serialize the rendered image. How would one 
>> serialize the GridCoverage directly? When I tried it, I got the 
>> errors resulting from the color model, as noted earlier.
>> Is there any way to serialize a GeoTiff - that would be a suitable 
>> alternative.
>> HOw are these things done in a WMS/WCS request - there must be some 
>> serialization happening, and it would probably provide a suitable 
>> alternative for me.
>> Thanks for any help,
>> Martin
>>
>> Simone Giannecchini wrote:
>>> Martin,
>>> you should serialize the coverage prior to the raster symbolizer in
>>> case you want to retain the original information of the data.
>>> Anyway, if you can provide an isolated test case for this
>>> serialization problem along with test data and create a jira for it
>>> that would be great, since it sounds like an improvement is needed
>>> inside the color map node of the raster symbolizer.
>>> Ciao,
>>> 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 5:42 PM, Martin Tomko 
>>> <[email protected]> wrote:
>>>  
>>>> Hi Martin,
>>>> that is exactly what I was trying to do before:
>>>> I get the following error:
>>>> Exception in thread "main" java.lang.RuntimeException:
>>>> org.geotools.renderer.lite.gridcoverage2d.LinearColorMapNon-serializable 
>>>>
>>>> parameter in this operation`s ParameterBlock.
>>>>    at
>>>> javax.media.jai.OperationNodeSupport.writeObject(OperationNodeSupport.java:746)
>>>>  
>>>>
>>>>    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.defaultWriteFields(ObjectOutputStream.java:1509)
>>>>  
>>>>
>>>>    at
>>>> java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416) 
>>>>
>>>>    at javax.media.jai.RenderedOp.writeObject(RenderedOp.java:3004)
>>>>    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 java.util.Hashtable.writeObject(Hashtable.java:824)
>>>>    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
>>>> javax.media.jai.PropertySourceImpl.writeMap(PropertySourceImpl.java:347) 
>>>>
>>>>    at
>>>> javax.media.jai.PropertySourceImpl.writeObject(PropertySourceImpl.java:361)
>>>>  
>>>>
>>>>    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.viewshedservice.ViewshedService.toBytesGC(ViewshedService.java:519)
>>>>  
>>>>
>>>> It seems to work if I extract the renderedimage:
>>>> new SerializableRenderedImage(covoverage.getRenderedImage())
>>>> But then, I am afraid, I am losing the coverage2D capabilities.
>>>> I am using the 2.5-snapshot. Seems like the serialization does nto 
>>>> work,
>>>> or my rendering is incorrect? (.LinearColorMapNon-serializable 
>>>> parameter
>>>> seems to imply that..)
>>>> I have a simple thing like this:
>>>> <FeatureTypeStyle>
>>>>         <FeatureTypeName>Feature</FeatureTypeName>
>>>>   <Rule>
>>>>    <RasterSymbolizer>
>>>>     <ColorMap type="ramp" extended="true">
>>>>      <ColorMapEntry color="#ffffff" quantity="-1.0"  opacity="1.0"/>
>>>>      <ColorMapEntry color="#000000" quantity="0.0"  opacity="1.0"/>
>>>>      <ColorMapEntry color="#ffff00" quantity="1.0" opacity="1.0"/>
>>>>      <ColorMapEntry color="#00ff00" quantity="2.0" opacity="1.0"/>
>>>>      <ColorMapEntry color="#00ffff" quantity="3.0" opacity="1.0"/>
>>>>      <ColorMapEntry color="#0000ff" quantity="4.0" opacity="1.0"/>
>>>>      <ColorMapEntry color="#ff00ff" quantity="5.0" opacity="1.0"/>
>>>>      <ColorMapEntry color="#ff0000" quantity="6.0" opacity="1.0"/>
>>>>     </ColorMap>
>>>>        <Opacity>1.0</Opacity>
>>>>             <ChannelSelection>
>>>>              <GrayChannel>
>>>>               <SourceChannelName>1</SourceChannelName>
>>>>              </GrayChannel>
>>>>     </ChannelSelection>
>>>>    </RasterSymbolizer>
>>>> thanks
>>>> Martin
>>>> Martin Desruisseaux wrote:
>>>>    
>>>>> Martin Tomko a écrit :
>>>>>      
>>>>>> Now, I noticed that this approach is *similar*to some test cases in
>>>>>> http://svn.geotools.org/trunk/modules/library/coverage/src/test/java/org/geotools/coverage/grid/GridCoverageTestBase.java
>>>>>>  
>>>>>>
>>>>>> but in these test cases it does not seem to be necessary to create
>>>>>> the new SerializableRenderedImage. Can anyone please comment on 
>>>>>> this?
>>>>>>         
>>>>> This test case is serializing GridCoverage2D, not RenderedImage. Like
>>>>> mentioned in my previous email, GridCoverage2D is already made
>>>>> serializable using the technic mentioned by Christian.
>>>>>
>>>>>      
>>>>>> What I need is the output of a Coverage (or Geotiff, anything that
>>>>>> will be contained aas one object and will contain georeferencing
>>>>>> information - at least the ReferencedEnvelope).
>>>>>> I need to pass the coverage to a remote service that will decode it.
>>>>>> The coverage has a ReferencedEnvelope, and that is what I need to be
>>>>>> passed with the raw data.
>>>>>> I have control over the decoding of the byte[] to an extent, so I 
>>>>>> can
>>>>>> have  a less standard way of decoding it.
>>>>>>         
>>>>> If you have a GridCoverage2D instance, you can do:
>>>>> // Writting
>>>>> ByteArrayOutputStream buffer = new ByteArrayOutputStream();
>>>>> ObjectOutputStream out = new ObjectOutputStream(buffer);
>>>>> out.writeObject(theCoverage);
>>>>> out.close();
>>>>> byte[] asArray = buffer.getArray();
>>>>>
>>>>> // Reading
>>>>> ObjectInputStream in = new ObjectInputStream(new
>>>>> ByteArrayInputStream(asArray));
>>>>> GridCoverage2D theCoverage = (GridCoverage2D) in.readObject();
>>>>> in.close();
>>>>>     Martin
>>>>>
>>>>>       
>>>> -- 
>>>> Martin Tomko
>>>> Postdoctoral Research Assistant
>>>> Geographic Information Systems Division
>>>> Department of Geography
>>>> University of Zurich - Irchel
>>>> Winterthurerstr. 190
>>>> CH-8057 Zurich, Switzerland
>>>> email:  [email protected]
>>>> site:   http://www.geo.uzh.ch/~mtomko
>>>> mob:    +41-788 629 558
>>>> tel:    +41-44-6355256
>>>> fax:    +41-44-6356848
>>>>
>>>> ------------------------------------------------------------------------------
>>>>  
>>>>
>>>> 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
>>>>     
>>>
>>>
>>>   
>>  
>>
>> -- 
>> Martin Tomko
>> Postdoctoral Research Assistant     Geographic Information Systems 
>> Division
>> Department of Geography
>> University of Zurich - Irchel
>> Winterthurerstr. 190
>> CH-8057 Zurich, Switzerland
>> email:     [email protected]
>> site:    http://www.geo.uzh.ch/~mtomko
>> mob:     +41-788 629 558
>> tel:     +41-44-6355256
>> fax:     +41-44-6356848
>>
>> ------------------------------------------------------------------------------
>>  
>>
>> Crystal Reports &#45; New Free Runtime and 30 Day Trial
>> Check out the new simplified licensign option that enables unlimited
>> royalty&#45;free distribution of the report engine for externally 
>> facing server and web deployment.
>> http://p.sf.net/sfu/businessobjects
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
>
>


-- 
Martin Tomko
Postdoctoral Research Assistant 
    
Geographic Information Systems Division
Department of Geography
University of Zurich - Irchel
Winterthurerstr. 190
CH-8057 Zurich, Switzerland

email:  [email protected]
site:   http://www.geo.uzh.ch/~mtomko
mob:    +41-788 629 558
tel:    +41-44-6355256
fax:    +41-44-6356848


------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to