Opened 13 years ago
Closed 13 years ago
#3893 closed defect (fixed)
Georaster loading throwing Invalid Metadata error and not loading
Reported by: | msmitherdc | Owned by: | ilucena |
---|---|---|---|
Priority: | normal | Milestone: | 1.8.1 |
Component: | GDAL_Raster | Version: | svn-trunk |
Severity: | major | Keywords: | georaster, oracle |
Cc: |
Description
I was at r20544 and did an svn up to r21395 and now I get
[lidar@lidarora1 rasters]$ gdal_translate -of georaster cincinnati_bare_earth_01.img geor:user/pass@tns,lidar_rasters,raster -co INSERT=" (3, 'Cincinnati, OH', 'BareEarth', sdo_geor.init() )" -co SRID=26916 Input file size is 16047, 21554 ERROR 1: ORA-01008: not all variables bound
0...10...20...30...40...50...60...70...80...90...100 - done. Ouput dataset: (geor:user/pass@tns,RDT_3$,3) on LIDAR.LIDAR_RASTERS,RASTER ERROR 1: ORA-13454: GeoRaster metadata is invalid ORA-06512: at "MDSYS.SDO_GEOR_INT", line 613 ORA-06512: at "MDSYS.SDO_GEOR", line 1374 ORA-06512: at line 21
Change History (8)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
comment:3 by , 13 years ago
Can you run gdal_translate in debugging mode and post the report? You can do that by adding "--debug on" to the command. Another question, are you sure you don't want to specify the RDT name on sdo_geor.init('NAME_OF_RDT') ?
comment:4 by , 13 years ago
Error ORA-01008 arises in GeoRasterWrapper.SetNoData in the new code for Oracle 11 and above, as a result of performance following PL/SQL the code:
OWStatement* poStmt = poConnection->CreateStatement( CPLSPrintf( "DECLARE\n" " GR1 sdo_georaster;\n" "BEGIN\n" " SELECT %s INTO GR1 FROM %s%s T WHERE %s FOR UPDATE;\n" "\n" " GR1.metadata := sys.xmltype.createxml(:1);\n" "\n" " SDO_GEOR.addNODATA( GR1, :2, :3 );\n" "\n" " UPDATE %s%s T SET %s = GR1 WHERE %s;\n" "\n" " EXECUTE IMMEDIATE\n" " 'SELECT T.%s.METADATA.getClobVal() FROM %s%s T \n" " WHERE T.%s.RASTERDATATABLE = UPPER(:1)\n" " AND T.%s.RASTERID = :2'\n" " INTO :metadata USING :rdt, :rid;\n" "END;", sColumn.c_str(), sSchema.c_str(), sTable.c_str(), sWhere.c_str(), sSchema.c_str(), sTable.c_str(), sColumn.c_str(), sWhere.c_str(), sColumn.c_str(), sSchema.c_str(), sTable.c_str(), sColumn.c_str(), sColumn.c_str() ) ); poStmt->WriteCLob( &phLocator, pszMetadata ); poStmt->Bind( &phLocator ); poStmt->Bind( &nLayer ); poStmt->Bind( szNoData ); poStmt->BindName( ":rdt", szRDT ); poStmt->BindName( ":rid", &nRID );
P.S. I don't know PL/SQL, therefore I do not know as to rectify this error.
comment:5 by , 13 years ago
It seems to me that this call to OCIDescriptorFree() is at the wrong time at the wrong place. Can you comment that line or move it to bellow the next ReadCLob() for a quick test?
http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/georaster/georaster_wrapper.cpp#L2433
2426 if( ! poStmt->Execute() ) 2427 { 2428 OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); 2429 delete poStmt; 2430 return false; 2431 } 2432 <<<< OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); 2434 2435 // ------------------------------------------------------------ 2436 // Read the XML metadata from db to memory with nodata updates 2437 // ------------------------------------------------------------ 2438 2439 char* pszXML = poStmt->ReadCLob( phLocator ); >>>> OCIDescriptorFree( phLocator, OCI_DTYPE_LOB ); 2440 2441 if( pszXML )
If you can't, no problem I am going to take a look on that later.
I believe that what happens was a bad case of "copy&paste" when I changed the method to update the XML metadata on FlushMetadata() and copied it to SetNoData().
Thanks,
Ivan Lucena
comment:6 by , 13 years ago
Error ORA-01008 arises because the variable :metadata, for this code isn't defined:
" EXECUTE IMMEDIATE\n" " 'SELECT T.%s.METADATA.getClobVal() FROM %s%s T \n" " WHERE T.%s.RASTERDATATABLE = UPPER(:1)\n" " AND T.%s.RASTERID = :2'\n" " INTO :metadata USING :rdt, :rid;\n"
If to comment out this code, error ORA-01008 disappears, but value NODATA not recorded, it can be checked up by means of function SDO_GEOR.getNODATA. If to comment out something that is taken from the function GeoRasterWrapper:: FlushMetadata (), and add a definition :metadata
poStmt->BindName( ":metadata", &phLocator );
Then using the SDO_GEOR.getNODATA can verify that the value NODATA successfully recorded.
Code with the described corrections:
OCILobLocator* phLocator = NULL; OWStatement* poStmt = poConnection->CreateStatement( CPLSPrintf( "DECLARE\n" " GR1 sdo_georaster;\n" "BEGIN\n" " SELECT %s INTO GR1 FROM %s%s T WHERE %s FOR UPDATE;\n" /*"\n" " GR1.metadata := sys.xmltype.createxml(:1);\n"*/ "\n" " SDO_GEOR.addNODATA( GR1, :1, :2 );\n" "\n" " UPDATE %s%s T SET %s = GR1 WHERE %s;\n" "\n" " EXECUTE IMMEDIATE\n" " 'SELECT T.%s.METADATA.getClobVal() FROM %s%s T \n" " WHERE T.%s.RASTERDATATABLE = UPPER(:1)\n" " AND T.%s.RASTERID = :2'\n" " INTO :metadata USING :rdt, :rid;\n" "END;", sColumn.c_str(), sSchema.c_str(), sTable.c_str(), sWhere.c_str(), sSchema.c_str(), sTable.c_str(), sColumn.c_str(), sWhere.c_str(), sColumn.c_str(), sSchema.c_str(), sTable.c_str(), sColumn.c_str(), sColumn.c_str() ) ); /*poStmt->WriteCLob( &phLocator, pszMetadata ); poStmt->Bind( &phLocator );*/ poStmt->Bind( &nLayer ); poStmt->Bind( szNoData ); poStmt->BindName( ":metadata", &phLocator ); poStmt->BindName( ":rdt", szRDT ); poStmt->BindName( ":rid", &nRID ); CPLFree( pszMetadata ); if( ! poStmt->Execute() )
P.S. I do not know how valid these corrections.
comment:7 by , 13 years ago
That is Good. But it misses the writing of the metadata so I think we would need two LobLocators, one for reading and one for writing. That seems to be working fine too, so I will committee the code shortly.
Thanks Mike.
comment:8 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Done.
Completed: At revision: r22307
IMHO. That error doesn't seems to be related to Metadata loading.
Could be that your INSERT options is incorrect? I would imagine that it should be like:
INSERT="(3, 'Cincinnati', 'OH', 'BareEarth', sdo_geor.init() )"
But I don't know the description of your lidar_raster table to be sure.