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