27 #include "../common/StringUtils.h" 28 #include "../common/UnitOfMeasure.h" 29 #include "../common/UnitsOfMeasureManager.h" 30 #include "../core/uri/URI.h" 31 #include "../core/uri/Utils.h" 32 #include "../dataaccess/dataset/DataSetType.h" 33 #include "../geometry/Coord2D.h" 34 #include "../geometry/Envelope.h" 35 #include "../geometry/Geometry.h" 36 #include "../ogr/Utils.h" 37 #include "../raster/BandProperty.h" 38 #include "../raster/Grid.h" 39 #include "../raster/RasterFactory.h" 40 #include "../raster/RasterProperty.h" 41 #include "../srs/SpatialReferenceSystemManager.h" 46 #include "../core/logger/Logger.h" 54 #include <gdalwarper.h> 56 #include <ogr_spatialref.h> 57 #include <ogrsf_frmts.h> 60 #include <boost/algorithm/string.hpp> 61 #include <boost/format.hpp> 62 #include <boost/filesystem/path.hpp> 63 #include <boost/filesystem/operations.hpp> 64 #include <boost/graph/graph_concepts.hpp> 65 #include <boost/scoped_array.hpp> 67 #define TL_B_PROP_DESC_KEY "TERRALIB_BAND_PROPERTY_GDAL_DESCRIPTION_KEY_TEXT" 68 #define TL_B_PROP_CATNAME_KEY "TERRALIB_BAND_PROPERTY_GDAL_CATEGORY_NAME_KEY_TEXT" 72 std::vector<std::string> words;
73 boost::split(words, name, boost::is_any_of(
":"), boost::token_compress_on);
80 if (driverName ==
"HDF4")
83 sdname = words[0] +
":" + words[1];
85 sdname = sdname +
":" + words[words.size() - 2] +
":" + words[words.size() - 1];
88 else if (driverName ==
"NITF")
92 sdname = words[0] +
":" + words[1];
94 else if (driverName ==
"netCDF")
97 sdname = words[0] +
":" + words[2];
104 for (
size_t i=0; i<words.size()-1;++i)
105 sdname = sdname +
":" + words[i];
118 if (!gds)
return nullptr;
119 if( multiResLevel != -1 )
121 if( gds->GetRasterCount() <= 0 )
return nullptr;
122 if( multiResLevel >= gds->GetRasterBand( 1 )->GetOverviewCount() )
return nullptr;
132 const char* projRef = gds->GetProjectionRef();
136 if ( ( projRef !=
nullptr ) && ( std::strlen( projRef ) > 0 ) )
138 char* projRef2 = (
char*)projRef;
139 char** projWKTPtr = &(projRef2);
140 OGRSpatialReference oSRS;
142 OGRErr ogrReturn = oSRS.importFromWkt( projWKTPtr );
144 if( ogrReturn == OGRERR_NONE )
152 unsigned int NRows = 0;
153 unsigned int nCols = 0;
155 if( multiResLevel == -1 )
157 nCols = (
unsigned int)gds->GetRasterXSize();
158 NRows = (
unsigned int)gds->GetRasterYSize();
162 nCols = (
unsigned int)gds->GetRasterBand( 1 )->GetOverview( multiResLevel )->GetXSize();
163 NRows = (
unsigned int)gds->GetRasterBand( 1 )->GetOverview( multiResLevel )->GetYSize();
171 if( gds->GetGeoTransform(gtp) == CE_Failure )
177 double gridAffineParams[ 6 ];
178 gridAffineParams[ 0 ] = gtp[ 1 ];
179 gridAffineParams[ 1 ] = gtp[ 2 ];
180 gridAffineParams[ 2 ] = gtp[ 0 ] + ( gtp[ 1 ] / 2.0 );
181 gridAffineParams[ 3 ] = gtp[ 4 ];
182 gridAffineParams[ 4 ] = gtp[ 5 ];
183 gridAffineParams[ 5 ] = gtp[ 3 ] + ( gtp[ 5 ] / 2.0 );
185 if( multiResLevel == -1 )
187 grid =
new te::rst::Grid(gridAffineParams, nCols, NRows, srid);
191 te::rst::Grid tempGrid(gridAffineParams, (
unsigned int)gds->GetRasterXSize(),
192 (
unsigned int)gds->GetRasterYSize(), srid);
209 if( gds->GetRasterCount() > 0 )
211 nBands = gds->GetRasterCount();
215 for (
int rasterIdx = 0; rasterIdx < nBands ; ++rasterIdx)
217 GDALRasterBand* rasterBand = gds->GetRasterBand( ( 1 + rasterIdx) );
223 const unsigned int bandIndex )
229 gband->GetBand()-1,
GetTeDataType(gband->GetRasterDataType()),
"") );
231 bprop->
m_idx = bandIndex;
238 GDALColorTable * gdalColorTablePtr = gband->GetColorTable();
240 if( gdalColorTablePtr )
242 switch( gdalColorTablePtr->GetPaletteInterpretation() )
273 for(
int cTableIdx = 0 ; cTableIdx < gdalColorTablePtr->GetColorEntryCount() ;
276 auxTLColorEntry.
c1 = (short)gdalColorTablePtr->GetColorEntry( cTableIdx )->c1;
277 auxTLColorEntry.
c2 = (short)gdalColorTablePtr->GetColorEntry( cTableIdx )->c2;
278 auxTLColorEntry.
c3 = (short)gdalColorTablePtr->GetColorEntry( cTableIdx )->c3;
279 auxTLColorEntry.
c4 = (short)gdalColorTablePtr->GetColorEntry( cTableIdx )->c4;
281 bprop->m_palette.push_back( auxTLColorEntry );
289 int noDataValueIsUsed = 0;
290 double nodataval = gband->GetNoDataValue(&noDataValueIsUsed);
291 if (noDataValueIsUsed)
292 bprop->m_noDataValue = nodataval;
296 bool categoryNamesLoaded =
false;
299 char** categoriesListPtr = gband->GetCategoryNames();
301 if( categoriesListPtr )
303 const int categoriesListSize = CSLCount( categoriesListPtr );
305 for(
int categoriesListIdx = 0 ; categoriesListIdx < categoriesListSize ;
306 ++categoriesListIdx )
308 bprop->m_categoryNames.push_back( std::string(
309 categoriesListPtr[ categoriesListIdx ] ) );
311 categoryNamesLoaded =
true;
318 bool descriptionLoaded =
false;
320 if( gband->GetDescription() )
322 bprop->m_description = std::string( gband->GetDescription() );
324 descriptionLoaded =
true;
330 char** metadataDomainListPtr = gband->GetMetadataDomainList();
332 char** metadataListPtr = gband->GetMetadata( ( metadataDomainListPtr ?
333 metadataDomainListPtr[ 0 ] :
nullptr ) );
335 if( metadataListPtr )
337 const int metadataListSize = CSLCount( metadataListPtr );
338 char* namePtr =
nullptr;
339 const char* valuePtr =
nullptr;
342 for(
int metadataListIdx = 0 ; metadataListIdx < metadataListSize ;
345 valuePtr = CPLParseNameValue( metadataListPtr[ metadataListIdx ],
350 if( descriptionLoaded ==
false )
352 bprop->m_description = std::string( valuePtr );
357 if( categoryNamesLoaded ==
false )
359 bprop->m_categoryNames.push_back( std::string( valuePtr ) );
364 bprop->m_metadata.push_back( std::pair<std::string, std::string>(
365 std::string( namePtr ), std::string( valuePtr ) ) );
372 if( metadataDomainListPtr ) CSLDestroy( metadataDomainListPtr );
377 std::string unitName = gband->GetUnitType();
378 if (!unitName.empty())
383 bprop->m_valuesOffset = gband->GetOffset(
nullptr);
384 bprop->m_valuesScale = gband->GetScale(
nullptr);
388 gband->GetBlockSize(&bprop->m_blkw, &bprop->m_blkh);
389 bprop->m_nblocksx = (gband->GetXSize() + bprop->m_blkw - 1) / bprop->m_blkw;
390 bprop->m_nblocksy = (gband->GetYSize() + bprop->m_blkh - 1) / bprop->m_blkh;
399 if( gband->GetStatistics(
false,
false, &min, &max, &mean, &stdDev ) == CE_None )
403 bprop->m_mean = mean;
404 bprop->m_stdDev = stdDev;
407 return bprop.release();
422 if( rst ==
nullptr )
return false;
426 if( gds ==
nullptr )
return false;
428 if( ( gds->GetAccess() != GA_ReadOnly ) && ( gds->GetAccess() != GA_Update ) )
433 int terralibBandsNumber = 0;
435 if( gds->GetRasterCount() > 0 )
442 int gdalBandIndex = 1;
443 for (
int terralibBandIndex = 0; terralibBandIndex < terralibBandsNumber; terralibBandIndex++)
445 if( multiResLevel == -1 )
457 if( multiResLevel < gds->GetRasterBand( gdalBandIndex )->GetOverviewCount() )
463 gds->GetRasterBand( gdalBandIndex )->GetOverview( multiResLevel )
469 while( ! bands.empty() )
471 delete( bands.back() );
487 GDALDataset* gds = (GDALDataset*) GDALOpen(strAccessInfo.c_str(), GA_ReadOnly);
493 std::vector<te::rst::BandProperty*> bprops;
497 std::map<std::string, std::string> rinfo;
508 GDALDataset* gds = (GDALDataset*) GDALOpen(strAccessInfo.c_str(), GA_ReadOnly);
519 const std::map<std::string, std::string>& optParams)
523 GDALDriverManager* dManPtr = GetGDALDriverManager();
525 GDALDriver* driverPtr = dManPtr->GetDriverByName(driverName.c_str());
528 throw Exception(
"Could not create raster because the underlying driver was not found!");
532 if (targetGDataType == GDT_Unknown)
533 throw Exception(
"Could not create raster because of unknown band data type!");
535 char** papszOptions =
nullptr;
537 std::map<std::string, std::string>::const_iterator it = optParams.begin();
539 std::map<std::string, std::string>::const_iterator it_end = optParams.end();
543 if(it->first ==
"URI" || it->first ==
"SOURCE")
550 papszOptions = CSLSetNameValue(papszOptions, it->first.c_str(), it->second.c_str());
555 GDALDataset* poDataset;
557 if (driverName ==
"JPEG" || driverName ==
"PNG")
559 GDALDriver* tmpDriverPtr = dManPtr->GetDriverByName(
"MEM");
561 poDataset = tmpDriverPtr->Create(name.c_str(),
564 static_cast<int>(bands.size()),
569 poDataset = driverPtr->Create(name.c_str(),
572 static_cast<int>(bands.size()),
577 CSLDestroy(papszOptions);
579 if(poDataset ==
nullptr)
580 throw Exception(
"Could not create raster!");
586 gtp[0] = gridAffineParams[2] - ( gridAffineParams[ 0 ] / 2.0 );
587 gtp[1] = gridAffineParams[0];
588 gtp[2] = gridAffineParams[1];
589 gtp[3] = gridAffineParams[5] - ( gridAffineParams[ 4 ] / 2.0 );
590 gtp[4] = gridAffineParams[3];
591 gtp[5] = gridAffineParams[4];
593 poDataset->SetGeoTransform(gtp);
595 OGRSpatialReference oSRS;
597 OGRErr osrsErrorReturn = oSRS.importFromEPSG(g->
getSRID());
598 CPLErr setProjErrorReturn = CE_Fatal;
600 if( osrsErrorReturn == OGRERR_NONE )
604 char* proj4Ptr =
nullptr;
606 osrsErrorReturn = oSRS.exportToProj4(&proj4Ptr);
608 if( osrsErrorReturn == OGRERR_NONE )
610 setProjErrorReturn = poDataset->SetProjection(proj4Ptr);
617 if( setProjErrorReturn != CE_None )
619 char* projWKTPtr =
nullptr;
621 osrsErrorReturn = oSRS.exportToWkt(&projWKTPtr);
623 if( osrsErrorReturn == OGRERR_NONE )
625 setProjErrorReturn = poDataset->SetProjection(projWKTPtr);
632 if( setProjErrorReturn != CE_None )
637 if( !proj4Str.empty() )
639 setProjErrorReturn = poDataset->SetProjection(proj4Str.c_str());
643 if( setProjErrorReturn != CE_None )
648 if( !wktStr.empty() )
650 setProjErrorReturn = poDataset->SetProjection(wktStr.c_str());
654 int nb =
static_cast<int>(bands.size());
656 for(
int dIdx = 0; dIdx < nb; ++dIdx)
658 GDALRasterBand* rasterBand = poDataset->GetRasterBand(1 + dIdx);
662 rasterBand->SetColorInterpretation(ci);
664 if (ci == GCI_PaletteIndex)
666 GDALColorTable* gCTablePtr =
new GDALColorTable(GPI_RGB);
667 GDALColorEntry gCEntry;
669 for (
unsigned int pIdx=0 ; pIdx < bands[dIdx]->m_palette.size(); ++pIdx)
671 gCEntry.c1 = (short)bands[dIdx]->m_palette[pIdx].c1;
672 gCEntry.c2 = (short)bands[dIdx]->m_palette[pIdx].c2;
673 gCEntry.c3 = (short)bands[dIdx]->m_palette[pIdx].c3;
674 gCEntry.c4 = (short)bands[dIdx]->m_palette[pIdx].c4;
675 gCTablePtr->SetColorEntry(pIdx, &gCEntry);
678 rasterBand->SetColorTable(gCTablePtr);
681 rasterBand->SetNoDataValue(bands[dIdx]->m_noDataValue);
682 rasterBand->SetOffset(bands[dIdx]->m_valuesOffset.real());
683 rasterBand->SetScale(bands[dIdx]->m_valuesScale.real());
687 bool categoryNamesSaved =
false;
690 char** categoryNamesListPtr =
nullptr;
692 for( std::size_t categoryNamesIdx = 0 ; categoryNamesIdx <
693 bands[ dIdx ]->m_categoryNames.size() ; ++categoryNamesIdx )
695 if( ! bands[ dIdx ]->m_categoryNames[ categoryNamesIdx ].empty() )
697 categoryNamesListPtr = CSLAddString( categoryNamesListPtr,
698 bands[ dIdx ]->m_categoryNames[ categoryNamesIdx ].c_str() );
702 if( categoryNamesListPtr )
704 if( rasterBand->SetCategoryNames( categoryNamesListPtr ) == CE_None )
706 categoryNamesSaved =
true;
709 CSLDestroy(categoryNamesListPtr);
715 if( ! bands[ dIdx ]->m_description.empty() )
717 rasterBand->SetDescription( bands[ dIdx ]->m_description.c_str() );
723 char** metadataListPtr =
nullptr;
728 ( ! bands[ dIdx ]->m_categoryNames.empty() )
730 ( categoryNamesSaved ==
false )
733 for( std::size_t categoryNamesIdx = 0 ; categoryNamesIdx <
734 bands[ dIdx ]->m_categoryNames.size() ; ++categoryNamesIdx )
736 if( ! bands[ dIdx ]->m_categoryNames[ categoryNamesIdx ].empty() )
738 metadataListPtr = CSLAddNameValue( metadataListPtr,
740 boost::lexical_cast< std::string >( categoryNamesIdx ) ).c_str(),
741 bands[ dIdx ]->m_categoryNames[ categoryNamesIdx ].c_str() );
748 if( ! bands[ dIdx ]->m_description.empty() )
750 metadataListPtr = CSLAddNameValue( metadataListPtr,
752 bands[ dIdx ]->m_description.c_str() );
757 for( std::size_t metadataIdx = 0 ; metadataIdx <
758 bands[ dIdx ]->m_metadata.size() ; ++metadataIdx )
761 ( bands[ dIdx ]->m_metadata[ metadataIdx ].first.empty() )
763 ( bands[ dIdx ]->m_metadata[ metadataIdx ].second.empty() )
766 metadataListPtr = CSLAddString( metadataListPtr,
767 ( bands[ dIdx ]->m_metadata[ metadataIdx ].first +
"=" +
768 bands[ dIdx ]->m_metadata[ metadataIdx ].second ).c_str() );
772 if( metadataListPtr )
774 char** metadataDomainListPtr = rasterBand->GetMetadataDomainList();
776 rasterBand->SetMetadata( metadataListPtr, ( metadataDomainListPtr ?
777 metadataDomainListPtr[ 0 ] :
nullptr ) );
778 CSLDestroy(metadataListPtr);
780 if( metadataDomainListPtr ) CSLDestroy( metadataDomainListPtr );
787 ( bands[dIdx]->m_min != std::numeric_limits<double>::max() )
789 ( bands[dIdx]->m_max != std::numeric_limits<double>::max() )
791 ( bands[dIdx]->m_mean != std::numeric_limits<double>::max() )
793 ( bands[dIdx]->m_stdDev != std::numeric_limits<double>::max() )
796 rasterBand->SetStatistics( bands[dIdx]->m_min, bands[dIdx]->m_max,
797 bands[dIdx]->m_mean, bands[dIdx]->m_stdDev );
806 const std::vector<te::rst::BandProperty*>&
bands,
807 const std::map<std::string, std::string>& optParams)
810 assert(bands.size() > 0);
818 GDALAccess gpolicy = GA_ReadOnly;
823 GDALDataset* gds = (GDALDataset*) GDALOpen(strAccessInfo.c_str(), gpolicy);
833 std::string connStr =
"PG:";
836 std::map<std::string, std::string>::const_iterator it = kvp.begin();
837 std::map<std::string, std::string>::const_iterator itend = kvp.end();
839 aux = connInfo.
host();
841 connStr +=
"host=" + aux;
843 aux = connInfo.
port();
845 connStr +=
" port=" + aux;
850 connStr +=
" dbname='" + aux;
854 aux = connInfo.
user();
857 connStr +=
" user='" + aux;
864 connStr +=
" password='" + aux;
869 it = kvp.find(
"schema");
870 if (it != itend && !it->second.empty())
872 connStr +=
" schema='" + it->second;
876 it = kvp.find(
"table");
877 if (it != itend && !it->second.empty())
878 connStr +=
" table=" + it->second;
880 it = kvp.find(
"where");
881 if (it != itend && !it->second.empty())
882 connStr +=
" where = " + it->second;
884 it = kvp.find(
"mode");
885 if (it != itend && !it->second.empty())
886 connStr +=
" mode=" + it->second;
893 OGRSpatialReference oSRS;
894 oSRS.importFromEPSG(srid);
895 char* coutWKT =
nullptr;
896 oSRS.exportToWkt(&coutWKT);
897 std::string outwkt(coutWKT);
898 return (!outwkt.empty());
911 if (hSrcDS ==
nullptr)
915 if (hDstDS ==
nullptr)
918 int nBands = GDALGetRasterCount(hSrcDS);
921 GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
922 psWarpOptions->hSrcDS = hSrcDS;
923 psWarpOptions->hDstDS = hDstDS;
924 psWarpOptions->nBandCount = nBands;
925 psWarpOptions->panSrcBands = (
int*)CPLMalloc(
sizeof(
int)*psWarpOptions->nBandCount);
926 psWarpOptions->panDstBands = (
int*)CPLMalloc(
sizeof(
int)*psWarpOptions->nBandCount);
927 for (
int b = 0;
b < psWarpOptions->nBandCount;
b++)
929 psWarpOptions->panSrcBands[
b] =
b+1;
930 psWarpOptions->panDstBands[
b] =
b+1;
934 psWarpOptions->pTransformerArg = GDALCreateGenImgProjTransformer(hSrcDS, GDALGetProjectionRef(hSrcDS),
935 hDstDS, GDALGetProjectionRef(hDstDS),
937 psWarpOptions->pfnTransformer = GDALGenImgProjTransform;
940 GDALWarpOperation oOperation;
941 oOperation.Initialize(psWarpOptions);
942 oOperation.WarpRegion(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));
945 GDALDestroyGenImgProjTransformer(psWarpOptions->pTransformerArg);
946 GDALDestroyWarpOptions(psWarpOptions);
954 boost::filesystem::path mpath(name.c_str());
957 if( ext[ 0 ] ==
'.' ) ext = ext.substr( 1, ext.size() - 1);
962 std::multimap< std::string, std::string >::const_iterator exttMapIt =
963 extensionsMap.find( ext );
965 if( exttMapIt == extensionsMap.end() )
967 return std::string();
971 return exttMapIt->second;
977 std::map<std::string, std::string>::const_iterator it = connInfo.find(
"URI");
979 if(it != connInfo.end())
982 it = connInfo.find(
"SOURCE");
984 if(it != connInfo.end())
987 throw Exception(
TE_TR(
"Invalid data source connection information!."));
994 GDALDriver* ogrDriver = GetGDALDriverManager()->GetDriverByName(
"Memory");
997 GDALDataset*
ds = ogrDriver->Create(
"ds_vectorize", 0, 0, 0, GDT_Unknown,
nullptr);
999 OGRLayer* ogrLayer = ds->CreateLayer(
"vectorization",
nullptr, wkbMultiPolygon,
nullptr);
1001 ogrLayer->CreateField(
new OGRFieldDefn(
"id", OFTInteger));
1004 if (GDALPolygonize(band,
nullptr , ogrLayer, 0,
nullptr,
nullptr,
nullptr) == CE_Failure)
1008 for (
int g = 0; g < ogrLayer->GetFeatureCount(); g++)
1018 std::vector<int> bandList;
1020 bandList.push_back(1);
1022 std::vector<OGRGeometryH> ogrGeometries;
1024 std::vector<double> burnValues;
1028 for (std::size_t g = 0; g < geometries.size(); g++)
1030 burnValues.push_back(bvalue % 255);
1032 bvalue = bvalue >= 127? bvalue - 126: bvalue > 255? 0: bvalue + 127;
1037 GDALRasterizeGeometries(outraster, static_cast<int>(bandList.size()), &(bandList[0]),
static_cast<unsigned int>(ogrGeometries.size()), &(ogrGeometries[0]),
nullptr,
nullptr, &(burnValues[0]),
nullptr,
nullptr,
nullptr);
1042 std::size_t firstIdx = uri.find(
":" );
1044 if( firstIdx < uri.size() )
1046 std::size_t secondIdx = uri.find(
":", firstIdx + 1 );
1048 if( secondIdx < uri.size() )
1067 std::size_t firstIdx = subDataSetName.find(
":" );
1069 if( firstIdx < subDataSetName.size() )
1071 std::size_t secondIdx = subDataSetName.find(
":", firstIdx + 1 );
1073 if( secondIdx < subDataSetName.size() )
1075 return subDataSetName.substr( secondIdx + 1, subDataSetName.size() - firstIdx - 1);
1079 return subDataSetName;
1084 return subDataSetName;
1089 return subDataSetName;
1095 static boost::mutex getStaticMutexStaticMutex;
1096 return getStaticMutexStaticMutex;
1101 static std::map< std::string, DriverMetadata > driversMetadataMap;
1103 if(driversMetadataMap.empty() )
1105 GDALDriverManager* driverManagerPtr = GetGDALDriverManager();
1107 int driversCount = driverManagerPtr->GetDriverCount();
1108 const char* valuePtr =
nullptr;
1110 for(
int driverIndex = 0 ; driverIndex < driversCount ; ++driverIndex )
1112 GDALDriver* driverPtr = driverManagerPtr->GetDriver(driverIndex);
1119 CPLStringList metaInfo( driverPtr->GetMetadata(), false );
1120 CPLStringList metaDomainList( driverPtr->GetMetadataDomainList(), true );
1122 valuePtr = metaInfo.FetchNameValue( GDAL_DMD_EXTENSIONS );
1128 valuePtr = metaInfo.FetchNameValue( GDAL_DMD_LONGNAME );
1131 valuePtr = metaInfo.FetchNameValue( GDAL_DMD_SUBDATASETS );
1132 if( ( valuePtr !=
nullptr ) && ( std::strcmp(
"YES", valuePtr ) == 0 ) )
1141 valuePtr = metaInfo.FetchNameValue( GDAL_DCAP_RASTER );
1142 if( ( valuePtr !=
nullptr ) && ( std::strcmp(
"YES", valuePtr ) == 0 ) )
1151 valuePtr = metaInfo.FetchNameValue( GDAL_DCAP_VECTOR );
1152 if( ( valuePtr !=
nullptr ) && ( std::strcmp(
"YES", valuePtr ) == 0 ) )
1161 valuePtr = metaInfo.FetchNameValue( GDAL_DCAP_CREATE );
1162 if( ( valuePtr !=
nullptr ) && ( std::strcmp(
"YES", valuePtr ) == 0 ) )
1176 return driversMetadataMap;
1180 const bool creationSupport )
1182 std::multimap< std::string, std::string > extensionsMap;
1184 if(extensionsMap.empty() )
1188 for( std::map< std::string, DriverMetadata >::const_iterator it = driversMetadata.begin() ;
1189 it != driversMetadata.end() ; ++it )
1192 ( ! it->second.m_extensions.empty() )
1194 it->second.m_isRaster
1196 ( creationSupport ? it->second.m_supportCreation :
true )
1199 for( std::size_t extensionsIdx = 0 ; extensionsIdx < it->second.m_extensions.size() ;
1202 extensionsMap.insert( std::pair< std::string, std::string >(
1209 return extensionsMap;
1213 const bool creationSupport )
1215 std::multimap< std::string, std::string > extensionsMap;
1217 if(extensionsMap.empty() )
1221 for( std::map< std::string, DriverMetadata >::const_iterator it = driversMetadata.begin() ;
1222 it != driversMetadata.end() ; ++it )
1225 ( ! it->second.m_extensions.empty() )
1227 it->second.m_isVector
1229 ( creationSupport ? it->second.m_supportCreation :
true )
1232 for( std::size_t extensionsIdx = 0 ; extensionsIdx < it->second.m_extensions.size() ;
1235 extensionsMap.insert( std::pair< std::string, std::string >(
1242 return extensionsMap;
1246 const bool creationSupport )
1249 creationSupport ) );
1251 creationSupport ) );
1253 std::multimap< std::string, std::string >::const_iterator it =
1254 rastersExtensionsMap.begin();
1255 std::multimap< std::string, std::string >::const_iterator itEnd =
1256 rastersExtensionsMap.end();
1258 while( it != itEnd )
1260 extensionsMap.insert( std::pair< std::string, std::string >( it->first, it->second ) );
1264 return extensionsMap;
GDALDataset * getGDALDataset() const
Returns the raster GDAL handler.
GDALColorInterp GetGDALColorInterpretation(te::rst::ColorInterp ci)
It translates a TerraLib ColorInterpretation to a GDAL ColorInterpretation.
TEGDALEXPORT void Vectorize(GDALRasterBand *band, std::vector< te::gm::Geometry * > &geometries)
Vectorizes a given raster band, using GDALPolygonize function.
HSL indexed palette interpretation.
unsigned int getNumberOfRows() const
Returns the grid number of rows.
Palette indexes color interpretation.
std::multimap< std::string, std::string > GetGDALAllDriversUCaseExt2DriversMap(const bool creationSupport)
Returns a map of all GDAL supported Upper-case ( vector and raster ) extensions to their respective d...
std::size_t m_idx
The band index.
std::string path() const
Retrieving the path.
void GDALErrorHandler(CPLErr eErrClass, int errNo, const char *msg)
GDALDataType GetGDALDataType(int tet)
It translates a TerraLib DataType to a GDAL DataType.
TEOGREXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry.
void GetBands(te::gdal::Raster *rst, std::vector< te::gdal::Band * > &bands)
Gets the list of bands from a GDAL dataset.
std::map< std::string, DriverMetadata > & GetGDALDriversMetadata()
Returns metadata from all registered GDAL drivers (key: driver name).
te::rst::ColorInterp GetTeColorInterpretation(GDALColorInterp gci)
It translates a GDAL ColorInterpretation to a TerraLib ColorInterpretation.
TEGDALEXPORT void GetBandProperties(GDALDataset *gds, std::vector< te::rst::BandProperty * > &bprops)
Gets the list of bands definition from a GDAL dataset.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
A raster band description.
RGB indexed palette interpretation.
This class represents Raster data.
int getSRID() const
Returns the grid spatial reference system identifier.
Base exception class for plugin module.
Gray indexed palette interpretation.
short c4
alpha or blackband.
te::rst::BandProperty * GetBandProperty(GDALRasterBand *gband, const unsigned int bandIndex)
Gets the properties of a single band from a GDAL dataset.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
std::string password() const
Retrieving the password information.
static te::dt::Date ds(2010, 01, 01)
This is a class that represents a GDAL Raster.
#define TE_TR(message)
It marks a string in order to get translated.
std::string query() const
Retrieving the query.
This class represents raster band description.
int GetTeDataType(GDALDataType gt)
It translates a GDAL DataType to a TerraLib DataType.
unsigned int unsigned int nCols
AccessPolicy
Supported data access policies (can be used as bitfield).
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
GDALDataset * CreateRaster(te::rst::Grid *g, const std::vector< te::rst::BandProperty * > &bands, const std::map< std::string, std::string > &optParams)
Creates a raster data using GDAL.
GDALDataset * GetRasterHandle(std::string strAccessInfo, te::common::AccessPolicy policy=te::common::RAccess)
Get a handle to a raster file.
te::gm::Envelope * GetExtent(std::string strAccessInfo)
Gets the extent of a raster data decoded by GDAL.
std::string MakePGConnectionStr(const te::core::URI &connInfo)
Returns a PostGIS connection string from the URI connection information. The connection string is to ...
static UnitsOfMeasureManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
const double * getGeoreference() const
Returns a list of 6 coefficients describing an affine transformation to georeference a grid...
std::string GetParentDataSetName(const std::string &subDataSetName)
It returns the parent dataset name from a Sub DataSet name.
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
std::string port() const
Retrieving the port.
std::string host() const
Retrieving the host.
std::string GetDriverName(const std::string &dsName)
It returns the GDAL driver name associated to a data source name.
A class for representing an Uniform Resource Identifier (URI).
bool IsSubDataSet(const std::string &uri)
Returns true if the given URI is related to a sub-dataset.
bool ReprojectRaster(te::rst::Raster const *const rin, te::rst::Raster *rout)
Reprojects a raster to another SRS.
short c1
gray, red, cyan or hue.
std::multimap< std::string, std::string > GetGDALVectorDriversUCaseExt2DriversMap(const bool creationSupport)
Returns a map of all GDAL supported Upper-case vector extensions to their respective driver names...
This file contains utility functions used to manipulate data from a URI.
#define TL_B_PROP_DESC_KEY
bool RecognizesSRID(unsigned int srid)
It returns true if GDAL recognizes the given SRS id.
std::string GetGDALConnectionInfo(const std::map< std::string, std::string > &connInfo)
It returns a GDAL connection string from the given map.
TECOREEXPORT std::map< std::string, std::string > Expand(const std::string &query_str)
Split a query string into its components.
#define TL_B_PROP_CATNAME_KEY
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
short c3
blue, yellow, or saturation.
#define TE_LOG_ERROR(message)
Use this tag in order to log a message to the TerraLib default logger with the ERROR level...
An structure to represent a color tuple.
TEGDALEXPORT void Rasterize(std::vector< te::gm::Geometry * > geometries, GDALDataset *outraster)
Rasterizes a given vector of geometries, using GDALRasterizeGeometries function.
CMYK indexed palette interpretation.
UnitOfMeasurePtr find(unsigned int id) const
Returns a unit of measure identified by its identificaton.
TECOREEXPORT std::string URIDecode(const std::string &srcUri)
Decodes an encoded URI. The algorithm implementation is based on http://www.codeguru.com/cpp/cpp/algorithms/strings/article.php/c12759/URI-Encoding-and-Decoding.htm.
It gives access to values in one band (dimension) of a raster.
TEGDALEXPORT boost::mutex & getStaticMutex()
Returns a reference to a static mutex initialized when this module is initialized.
A rectified grid is the spatial support for raster data.
An exception class for the GDAL module.
std::string GetSubDataSetName(const std::string &name, const std::string &driverName)
It returns the Sub DataSet name from the given name or the same name.
TEGDALEXPORT te::rst::Grid * GetGrid(GDALDataset *gds)
Gets the grid definition from a GDAL dataset.
short c2
green, magenta, or lightness.
std::string user() const
Retrieving the user information.
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
std::multimap< std::string, std::string > GetGDALRasterDriversUCaseExt2DriversMap(const bool creationSupport)
Returns a map of all GDAL supported Upper-case raster extensions to their respective driver names...
te::rst::RasterProperty * GetRasterProperty(std::string strAccessInfo)
Gets the complete description from a GDAL dataset.