<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello Jacob<br>
<br>
Le 02/08/13 17:58, Jacob Beeusaert a écrit :<br>
<blockquote
cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com"
type="cite">I am having some issues using Graphics2D to draw a
GridCoverage using the GridCoverageBuilder. I've written a Test
for the behaviour. Hopefully someone can help me understand what
is going on.</blockquote>
<br>
I had a look to the test. I didn't checked deeply, but I would
suggest to follow different steps:<br>
<br>
<blockquote
cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com"
type="cite">
<div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span
style="color: rgb(147, 26, 104); "></span><span
style="color: rgb(0, 0, 0); "><span class="Apple-tab-span"
style="white-space: pre; "></span></span>// Will use
sample value in the range -10000 inclusive to 10000 exclusive.
<div style="margin: 0px; ">builder.setSampleRange(-10000,
10000);</div>
</div>
</div>
</blockquote>
<br>
I would suggest to avoid negative sample values, as they are not
supported by IndexColorModel. While the library tries to workaround
this limitation, there is more risk of unexpected results and it
often consume more memory. I rather suggest:<br>
<br>
<pre>builder.setSampleRange(1, 20000);</pre>
<br>
and replace:<br>
<br>
<blockquote
cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com"
type="cite">
<div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco; ">
<div style="margin: 0px; ">elevation.setLinearTransform(0.01,
0);</div>
<div style="margin: 0px; ">elevation.addNodataValue(<span
style="color: rgb(57, 51, 255); ">"No data"</span>,
10000);</div>
</div>
</div>
</blockquote>
<br>
by:<br>
<br>
<pre>elevation.setLinearTransform(0.01, -500);
elevation.addNodataValue("No data", 0);
</pre>
<br>
While not essential, using "0" for "no-data" also reduce the risk of
unexpected results and allows a few optimization in the library.<br>
<br>
On the following question:<br>
<br>
<blockquote
cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com"
type="cite">
<div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span
style="color: rgb(0, 0, 0); "><span class="Apple-tab-span"
style="white-space: pre; "></span></span>//How to define
the grid value of the stuff we will draw? setColor??</div>
</div>
</blockquote>
<br>
I would not recommend to use ColorSpace or Graphics2D, since they
are for drawing visual objects rather than computing geophysical
values. Instead, I suggest:<br>
<br>
<pre>WritableRaster raster = image.getRaster();
raster.setSample(x, y, 0, value);
</pre>
<br>
Regards,<br>
<br>
Martin<br>
<br>
</body>
</html>