Can you post the metadata of your georaster object so I can try to reproduce your problem? To get the metadata, run the following in sqlplus:
set long 10000
set pagesize 1000
select t.georaster.metadata from JBA_MEGARASTER_1012 t where id = 1;
After reading your code, I think the float value reading (ult_raw.substr call) might have some problem. I modified your code a little and ran against the buffer value given in your post (buf = '789C63608002666913066400E2238BC1F8F830BA7E280000C523042B). I don't have any error. Here is the code and result:
set serveroutput on;
FLT number := 0;
vals varchar2(32000) := null;
MAXV number := null;
cdl := 32;
cdl := cdl / 8;
buf := hextoraw('789C63608002666913066400E2238BC1F8F830BA7E280000C523042B');
amt := 28;
i := 1;
while i < amt loop
r := utl_raw.substr(buf, i, cdl);
if cdl = 8 then
VAL := UTL_RAW.CAST_TO_BINARY_DOUBLE(R);
elsif flt = 1 then
val := utl_raw.cast_to_binary_float(r);
val := utl_raw.cast_to_binary_integer(r);
if MAXV is null or MAXV < VAL then
MAXV := VAL;
IF i = 1 THEN
VALS := VALS || VAL;
VALS := VALS ||'|'|| VAL;
i := i+cdl;
dbms_output.put_line('Max value: ' || maxv);
Max value: 2116550656
You mentioned that the 7 values you got from getRasterSubset is not correct. That doesn't look right to me either. Could you print out the win2 value after calling the getRasterSubset? Also please print out the metadata as I instructed in the previous post. Thanks.
WIN2 = '161148,76364,161152,76368'
The metadata =
<polynomialModel rowOff="0" columnOff="0" xOff="0" yOff="0" zOff="0" rowScale="1" columnScale="1" xScale="1" yScale="1" zScale="1">
<pPolynomial pType="1" nVars="2" order="1" nCoefficients="3">
<polynomialCoefficients>195880.5 -0 -0.2</polynomialCoefficients>
<qPolynomial pType="1" nVars="0" order="0" nCoefficients="1">
<rPolynomial pType="1" nVars="2" order="1" nCoefficients="3">
<polynomialCoefficients>-18337.5 0.2 -0</polynomialCoefficients>
<sPolynomial pType="1" nVars="0" order="0" nCoefficients="1">
Hey zzhang, sorry, I didnt spot this at the end of page 1.
Thanks again (to everyone helping) for all this help, it is much appreciated, I wasn't getting anywhere on my own.
r4 is the variable I use to store the utl_raw.substr from the "buf" varchar2 which is basically the blob returned from getRasterSubSet.
When I define it as "r4 raw(4);" I get an error saying it is not big enough to store the result of utl_raw.substr, which I am taking in 4 byte chunks (so why isnt it big enough).
If I define it as "r4 raw(5);", it is fine.
The source compression is "DEFLATE", I tried adding 'compression=NONE' as the storageParam argument, but I got all zeros.
What do you think?
When I add compression=NONE to the getrastersubset function the buffer line I get back is:
The reason you have to use "r4 raw(5)" is because you have " r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl+1);" where substr gets data of length (cdl+1) which is 5. If you use "r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);", you should be fine. The code I post earlier is even simpler.
I think that was the bug, now I'm getting the value I expect!
I'm going to do more tests, but that is looking pretty good!
Ensure the storageParameter has "compression=NONE" and is passed into the getRasterSubset function call. When the length of the lob is obtained from "len := dbms_lob.getlength(lb);", please check if len == ROW_COUNT * COL_COUNT * cdl, (cdl is the cell depth in bytes). They should be equal after "compression=NONE" option. For example, for WIN2 = '161148,76364,161152,76368', the len should be 64 bytes. The 28 bytes buffer posted earlier could be the compressed data returned by getRasterSubset.
That's right the compressed response was 28, but the uncompressed was 100, I thought there was a problem with the compression, because when I set compression=NONE I got all zeros, but when I fixed the substr length, it started working fine.
I ran a few other tests and everything looks good, I think I've finally got this one working.
I will rewrite my code to be more straight forward and then I'll post it so people can see what the final version looks like.
Thanks again everyone for all your help!