int OGRMDBDataSource::Open( const char * pszNewName, int bUpdate, int bTestOpen ) { CPLAssert( nLayers == 0 ); pszName = CPLStrdup( pszNewName ); if (!env.Init()) return FALSE; poDB = OGRMDBDatabase::Open(&env, pszNewName); if (!poDB) return FALSE; poDB->FetchTableNames(); /* Is it a ESRI Personal Geodatabase ? */ OGRMDBTable* poGDB_GeomColumns = poDB->GetTable("GDB_GeomColumns"); if (poGDB_GeomColumns && !CSLTestBoolean(CPLGetConfigOption("MDB_RAW", "OFF"))) { int nRet = OpenGDB(poGDB_GeomColumns); delete poGDB_GeomColumns; return nRet; } delete poGDB_GeomColumns; /* Is it a Geomedia warehouse ? */ OGRMDBTable* poGAliasTable = poDB->GetTable("GAliasTable"); if (poGAliasTable && !CSLTestBoolean(CPLGetConfigOption("MDB_RAW", "OFF"))) { int nRet = OpenGeomediaWarehouse(poGAliasTable); delete poGAliasTable; return nRet; } delete poGAliasTable; /* Well, no, just a regular MDB */ int nTables = (int) poDB->apoTableNames.size(); for(int i=0;i<nTables;i++) { OGRMDBTable* poTable = poDB->GetTable(poDB->apoTableNames[i]); if (poTable == NULL) continue; OGRMDBLayer* poLayer = new OGRMDBLayer( this, poTable ); if( poLayer->BuildFeatureDefn() != CE_None ) { delete poLayer; continue; } papoLayers = (OGRMDBLayer**)CPLRealloc(papoLayers, (nLayers+1) * sizeof(OGRMDBLayer*)); papoLayers[nLayers++] = poLayer; } return TRUE; }
/*! \brief VFKReaderSQLite constructor */ VFKReaderSQLite::VFKReaderSQLite(const char *pszFilename) : VFKReader(pszFilename) { const char *pszDbNameConf; CPLString pszDbName; CPLString osCommand; VSIStatBufL sStatBuf; bool bNewDb; /* open tmp SQLite DB (re-use DB file if already exists) */ pszDbNameConf = CPLGetConfigOption("OGR_VFK_DB_NAME", NULL); if (pszDbNameConf) { pszDbName = pszDbNameConf; } else { pszDbName.Printf("%s.db", m_pszFilename); } if (CSLTestBoolean(CPLGetConfigOption("OGR_VFK_DB_SPATIAL", "YES"))) m_bSpatial = TRUE; /* build geometry from DB */ else m_bSpatial = FALSE; /* store also geometry in DB */ bNewDb = TRUE; if (VSIStatL(pszDbName, &sStatBuf ) == 0) { if (CSLTestBoolean(CPLGetConfigOption("OGR_VFK_DB_OVERWRITE", "NO"))) { bNewDb = TRUE; /* overwrite existing DB */ VSIUnlink(pszDbName); } else { bNewDb = FALSE; /* re-use exising DB */ } } else { CPLError(CE_Warning, CPLE_AppDefined, "SQLite DB not found. Reading VFK data may take some time..."); } CPLDebug("OGR-VFK", "New DB: %s Spatial: %s", bNewDb ? "yes" : "no", m_bSpatial ? "yes" : "no"); if (SQLITE_OK != sqlite3_open(pszDbName, &m_poDB)) { CPLError(CE_Failure, CPLE_AppDefined, "Creating SQLite DB failed"); } else { char* pszErrMsg = NULL; sqlite3_exec(m_poDB, "PRAGMA synchronous = OFF", NULL, NULL, &pszErrMsg); sqlite3_free(pszErrMsg); } if (bNewDb) { /* new DB, create support metadata tables */ osCommand = "CREATE TABLE 'vfk_blocks' " "(file_name text, table_name text, num_records integer, " "num_geometries integer, table_defn text)"; ExecuteSQL(osCommand.c_str()); } }
OGRLayer * OGRGPXDataSource::CreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ) { GPXGeometryType gpxGeomType; if (eType == wkbPoint || eType == wkbPoint25D) { if (EQUAL(pszLayerName, "track_points")) gpxGeomType = GPX_TRACK_POINT; else if (EQUAL(pszLayerName, "route_points")) gpxGeomType = GPX_ROUTE_POINT; else gpxGeomType = GPX_WPT; } else if (eType == wkbLineString || eType == wkbLineString25D) { const char *pszForceGPXTrack = CSLFetchNameValue( papszOptions, "FORCE_GPX_TRACK"); if (pszForceGPXTrack && CSLTestBoolean(pszForceGPXTrack)) gpxGeomType = GPX_TRACK; else gpxGeomType = GPX_ROUTE; } else if (eType == wkbMultiLineString || eType == wkbMultiLineString25D) { const char *pszForceGPXRoute = CSLFetchNameValue( papszOptions, "FORCE_GPX_ROUTE"); if (pszForceGPXRoute && CSLTestBoolean(pszForceGPXRoute)) gpxGeomType = GPX_ROUTE; else gpxGeomType = GPX_TRACK; } else if (eType == wkbUnknown) { CPLError(CE_Failure, CPLE_NotSupported, "Cannot create GPX layer %s with unknown geometry type", pszLayerName); return NULL; } else { CPLError( CE_Failure, CPLE_NotSupported, "Geometry type of `%s' not supported in GPX.\n", OGRGeometryTypeToName(eType) ); return NULL; } nLayers++; papoLayers = (OGRGPXLayer **) CPLRealloc(papoLayers, nLayers * sizeof(OGRGPXLayer*)); papoLayers[nLayers-1] = new OGRGPXLayer( pszName, pszLayerName, gpxGeomType, this, TRUE ); return papoLayers[nLayers-1]; }
FILE *VSIFOpen( const char * pszFilename, const char * pszAccess ) { FILE *fp = NULL; int nError; #if defined(WIN32) && !defined(WIN32CE) if( CSLTestBoolean( CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) ) { wchar_t *pwszFilename = CPLRecodeToWChar( pszFilename, CPL_ENC_UTF8, CPL_ENC_UCS2 ); wchar_t *pwszAccess = CPLRecodeToWChar( pszAccess, CPL_ENC_UTF8, CPL_ENC_UCS2 ); fp = _wfopen( pwszFilename, pwszAccess ); CPLFree( pwszFilename ); CPLFree( pwszAccess ); } else #endif fp = fopen( (char *) pszFilename, (char *) pszAccess ); nError = errno; VSIDebug3( "VSIFOpen(%s,%s) = %p", pszFilename, pszAccess, fp ); errno = nError; return( fp ); }
VSIVirtualHandle* VSICurlStreamingFSHandler::Open( const char *pszFilename, const char *pszAccess ) { if (strchr(pszAccess, 'w') != NULL || strchr(pszAccess, '+') != NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Only read-only mode is supported for /vsicurl_streaming"); return NULL; } VSICurlStreamingHandle* poHandle = new VSICurlStreamingHandle( this, pszFilename + strlen("/vsicurl_streaming/")); /* If we didn't get a filelist, check that the file really exists */ if (!poHandle->Exists()) { delete poHandle; poHandle = NULL; } if( CSLTestBoolean( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ) ) return VSICreateCachedFile( poHandle ); else return poHandle; }
char* OGRGetXML_UTF8_EscapedString(const char* pszString) { char *pszEscaped; if (!CPLIsUTF8(pszString, -1) && CSLTestBoolean(CPLGetConfigOption("OGR_FORCE_ASCII", "YES"))) { static int bFirstTime = TRUE; if (bFirstTime) { bFirstTime = FALSE; CPLError(CE_Warning, CPLE_AppDefined, "%s is not a valid UTF-8 string. Forcing it to ASCII.\n" "If you still want the original string and change the XML file encoding\n" "afterwards, you can define OGR_FORCE_ASCII=NO as configuration option.\n" "This warning won't be issued anymore", pszString); } else { CPLDebug("OGR", "%s is not a valid UTF-8 string. Forcing it to ASCII", pszString); } char* pszTemp = CPLForceToASCII(pszString, -1, '?'); pszEscaped = CPLEscapeString( pszTemp, -1, CPLES_XML ); CPLFree(pszTemp); } else pszEscaped = CPLEscapeString( pszString, -1, CPLES_XML ); return pszEscaped; }
VSIVirtualHandle * VSIUnixStdioFilesystemHandler::Open( const char *pszFilename, const char *pszAccess ) { FILE *fp = VSI_FOPEN64( pszFilename, pszAccess ); int nError = errno; VSIDebug3( "VSIUnixStdioFilesystemHandler::Open(\"%s\",\"%s\") = %p", pszFilename, pszAccess, fp ); if( fp == NULL ) { errno = nError; return NULL; } VSIUnixStdioHandle *poHandle = new VSIUnixStdioHandle(this, fp); errno = nError; /* -------------------------------------------------------------------- */ /* If VSI_CACHE is set we want to use a cached reader instead */ /* of more direct io on the underlying file. */ /* -------------------------------------------------------------------- */ if( (EQUAL(pszAccess,"r") || EQUAL(pszAccess,"rb")) && CSLTestBoolean( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ) ) { return VSICreateCachedFile( poHandle ); } else { return poHandle; } }
void OGRSXFDataSource::SetVertCS(const long iVCS, SXFPassport& passport) { if (!CSLTestBoolean(CPLGetConfigOption("SXF_SET_VERTCS", "NO"))) return; const long nEPSG = aoVCS[iVCS]; if (nEPSG == 0) { CPLError(CE_Warning, CPLE_NotSupported, "SXF. Vertical coordinate system (SXF index %ld) not supported", iVCS); return; } OGRSpatialReference* sr = new OGRSpatialReference(); OGRErr eImportFromEPSGErr = sr->importFromEPSG(nEPSG); if (eImportFromEPSGErr != OGRERR_NONE) { CPLError( CE_Warning, CPLE_None, "SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) import from EPSG error", iVCS, nEPSG); return; } if (sr->IsVertical() != 1) { CPLError( CE_Warning, CPLE_None, "SXF. Coordinate system (SXF index %ld, EPSG %ld) is not Vertical", iVCS, nEPSG); return; } //passport.stMapDescription.pSpatRef->SetVertCS("Baltic", "Baltic Sea"); OGRErr eSetVertCSErr = passport.stMapDescription.pSpatRef->SetVertCS(sr->GetAttrValue("VERT_CS"), sr->GetAttrValue("VERT_DATUM")); if (eSetVertCSErr != OGRERR_NONE) { CPLError(CE_Warning, CPLE_None, "SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) set error", iVCS, nEPSG); return; } }
CPLErr GDALDefaultOverviews::CleanOverviews() { // Anything to do? if( poODS == NULL ) return CE_None; // Delete the overview file(s). GDALDriver *poOvrDriver; poOvrDriver = poODS->GetDriver(); GDALClose( poODS ); poODS = NULL; CPLErr eErr; if( poOvrDriver != NULL ) eErr = poOvrDriver->Delete( osOvrFilename ); else eErr = CE_None; // Reset the saved overview filename. if( !EQUAL(poDS->GetDescription(),":::VIRTUAL:::") ) { int bUseRRD = CSLTestBoolean(CPLGetConfigOption("USE_RRD","NO")); if( bUseRRD ) osOvrFilename = CPLResetExtension( poDS->GetDescription(), "aux" ); else osOvrFilename.Printf( "%s.ovr", poDS->GetDescription() ); } else osOvrFilename = ""; return eErr; }
OGRErr OGRPGDumpLayer::CreateFeature( OGRFeature *poFeature ) { if( NULL == poFeature ) { CPLError( CE_Failure, CPLE_AppDefined, "NULL pointer to OGRFeature passed to CreateFeature()." ); return OGRERR_FAILURE; } nFeatures ++; // We avoid testing the config option too often. if( bUseCopy == USE_COPY_UNSET ) bUseCopy = CSLTestBoolean( CPLGetConfigOption( "PG_USE_COPY", "NO") ); if( !bUseCopy ) { return CreateFeatureViaInsert( poFeature ); } else { if ( !bCopyActive ) { /* This is a heuristics. If the first feature to be copied has a */ /* FID set (and that a FID column has been identified), then we will */ /* try to copy FID values from features. Otherwise, we will not */ /* do and assume that the FID column is an autoincremented column. */ StartCopy(poFeature->GetFID() != OGRNullFID); } return CreateFeatureViaCopy( poFeature ); } }
int VSIWin32FilesystemHandler::Stat( const char * pszFilename, VSIStatBufL * pStatBuf, int nFlags ) { (void) nFlags; #if (defined(WIN32) && _MSC_VER >= 1310) || __MSVCRT_VERSION__ >= 0x0601 if( CSLTestBoolean( CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) ) { int nResult; wchar_t *pwszFilename = CPLRecodeToWChar( pszFilename, CPL_ENC_UTF8, CPL_ENC_UCS2 ); nResult = _wstat64( pwszFilename, pStatBuf ); CPLFree( pwszFilename ); return nResult; } else #endif { return( VSI_STAT64( pszFilename, pStatBuf ) ); } }
int OGRGPSBabelWriteDataSource::Create( const char * pszName, char **papszOptions ) { GDALDriver* poGPXDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName("GPX"); if (poGPXDriver == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "GPX driver is necessary for GPSBabel write support"); return FALSE; } if (!EQUALN(pszName, "GPSBABEL:", 9)) { const char* pszOptionGPSBabelDriverName = CSLFetchNameValue(papszOptions, "GPSBABEL_DRIVER"); if (pszOptionGPSBabelDriverName != NULL) pszGPSBabelDriverName = CPLStrdup(pszOptionGPSBabelDriverName); else { CPLError(CE_Failure, CPLE_AppDefined, "GPSBABEL_DRIVER dataset creation option expected"); return FALSE; } pszFilename = CPLStrdup(pszName); } else { const char* pszSep = strchr(pszName + 9, ':'); if (pszSep == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Wrong syntax. Expected GPSBabel:driver_name[,options]*:file_name"); return FALSE; } pszGPSBabelDriverName = CPLStrdup(pszName + 9); *(strchr(pszGPSBabelDriverName, ':')) = '\0'; pszFilename = CPLStrdup(pszSep+1); } /* A bit of validation to avoid command line injection */ if (!OGRGPSBabelDataSource::IsValidDriverName(pszGPSBabelDriverName)) return FALSE; const char* pszOptionUseTempFile = CSLFetchNameValue(papszOptions, "USE_TEMPFILE"); if (pszOptionUseTempFile == NULL) pszOptionUseTempFile = CPLGetConfigOption("USE_TEMPFILE", NULL); if (pszOptionUseTempFile && CSLTestBoolean(pszOptionUseTempFile)) osTmpFileName = CPLGenerateTempFilename(NULL); else osTmpFileName.Printf("/vsimem/ogrgpsbabeldatasource_%p", this); poGPXDS = poGPXDriver->Create(osTmpFileName.c_str(), 0, 0, 0, GDT_Unknown, papszOptions); if (poGPXDS == NULL) return FALSE; this->pszName = CPLStrdup(pszName); return TRUE; }
char* GML_ExtractSrsNameFromGeometry(char** papszGeometryList) { if (papszGeometryList != NULL && *papszGeometryList != NULL && papszGeometryList[1] == NULL) { const char* pszSRSName = strstr(*papszGeometryList, "srsName=\""); if (pszSRSName) { pszSRSName += strlen("srsName=\""); char* pszRet; if (strncmp(pszSRSName, "EPSG:", 5) == 0 && CSLTestBoolean(CPLGetConfigOption("GML_CONSIDER_EPSG_AS_URN", "NO"))) { pszRet = CPLStrdup(CPLSPrintf("urn:ogc:def:crs:EPSG::%s", pszSRSName+5)); } else if (strncmp(pszSRSName, "http://www.opengis.net/gml/srs/epsg.xml#", strlen("http://www.opengis.net/gml/srs/epsg.xml#")) == 0) { pszRet = CPLStrdup(CPLSPrintf("EPSG:%s", pszSRSName + strlen("http://www.opengis.net/gml/srs/epsg.xml#"))); } else { pszRet = CPLStrdup(pszSRSName); } char* pszEndQuote = strchr(pszRet, '"'); if (pszEndQuote) *pszEndQuote = 0; return pszRet; } } return NULL; }
OGRSEGP1Layer::OGRSEGP1Layer( const char* pszFilename, VSILFILE* fp, int nLatitudeCol ) { this->fp = fp; this->nLatitudeCol = nLatitudeCol; nNextFID = 0; bEOF = FALSE; poSRS = NULL; poFeatureDefn = new OGRFeatureDefn( CPLGetBasename(pszFilename) ); SetDescription( poFeatureDefn->GetName() ); poFeatureDefn->Reference(); poFeatureDefn->SetGeomType( wkbPoint ); for(int i=0;i<(int)(sizeof(SEGP1Fields)/sizeof(SEGP1Fields[0]));i++) { OGRFieldDefn oField( SEGP1Fields[i].pszName, SEGP1Fields[i].eType ); poFeatureDefn->AddFieldDefn( &oField ); } bUseEastingNorthingAsGeometry = CSLTestBoolean(CPLGetConfigOption("SEGP1_USE_EASTING_NORTHING", "NO")); ResetReading(); }
static void* OGRSQLiteRegisterRegExpFunction( #ifndef HAVE_PCRE CPL_UNUSED #endif sqlite3* hDB) { #ifdef HAVE_PCRE /* For debugging purposes mostly */ if( !CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_REGEXP", "YES")) ) return NULL; /* Check if we really need to define our own REGEXP function */ int rc = sqlite3_exec(hDB, "SELECT 'a' REGEXP 'a'", NULL, NULL, NULL); if( rc == SQLITE_OK ) { CPLDebug("SQLITE", "REGEXP already available"); return NULL; } cache_entry *cache = (cache_entry*) CPLCalloc(CACHE_SIZE, sizeof(cache_entry)); sqlite3_create_function(hDB, "REGEXP", 2, SQLITE_UTF8, cache, OGRSQLiteREGEXPFunction, NULL, NULL); /* To clear the error flag */ sqlite3_exec(hDB, "SELECT 1", NULL, NULL, NULL); return cache; #else // HAVE_PCRE return NULL; #endif // HAVE_PCRE }
int VSIWin32FilesystemHandler::Rename( const char *oldpath, const char *newpath ) { #if (defined(WIN32) && _MSC_VER >= 1310) || __MSVCRT_VERSION__ >= 0x0601 if( CSLTestBoolean( CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) ) { int nResult; wchar_t *pwszOldPath = CPLRecodeToWChar( oldpath, CPL_ENC_UTF8, CPL_ENC_UCS2 ); wchar_t *pwszNewPath = CPLRecodeToWChar( newpath, CPL_ENC_UTF8, CPL_ENC_UCS2 ); nResult = _wrename( pwszOldPath, pwszNewPath ); CPLFree( pwszOldPath ); CPLFree( pwszNewPath ); return nResult; } else #endif { return rename( oldpath, newpath ); } }
FILE *VSIFOpen( const char * pszFilename, const char * pszAccess ) { FILE *fp = NULL; #if defined(WIN32) if( CSLTestBoolean( CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) ) { wchar_t *pwszFilename = CPLRecodeToWChar( pszFilename, CPL_ENC_UTF8, CPL_ENC_UCS2 ); wchar_t *pwszAccess = CPLRecodeToWChar( pszAccess, CPL_ENC_UTF8, CPL_ENC_UCS2 ); fp = _wfopen( pwszFilename, pwszAccess ); CPLFree( pwszFilename ); CPLFree( pwszAccess ); } else #endif fp = fopen( (char *) pszFilename, (char *) pszAccess ); #ifdef VSI_DEBUG // Capture the error from fopen to avoid being overwritten by errors // from VSIDebug3. const int nError = errno; VSIDebug3( "VSIFOpen(%s,%s) = %p", pszFilename, pszAccess, fp ); errno = nError; #endif return fp; }
OGRErr OGRPGDumpLayer::CreateFeature( OGRFeature *poFeature ) { if( NULL == poFeature ) { CPLError( CE_Failure, CPLE_AppDefined, "NULL pointer to OGRFeature passed to CreateFeature()." ); return OGRERR_FAILURE; } nFeatures ++; // We avoid testing the config option too often. if( bUseCopy == USE_COPY_UNSET ) bUseCopy = CSLTestBoolean( CPLGetConfigOption( "PG_USE_COPY", "NO") ); if( !bUseCopy ) { return CreateFeatureViaInsert( poFeature ); } else { if ( !bCopyActive ) StartCopy(); return CreateFeatureViaCopy( poFeature ); } }
OGRUKOOAP190Layer::OGRUKOOAP190Layer( const char* pszFilename, VSILFILE* fp ) { this->fp = fp; nNextFID = 0; bEOF = FALSE; poSRS = NULL; nYear = 0; poFeatureDefn = new OGRFeatureDefn( CPLGetBasename(pszFilename) ); SetDescription( poFeatureDefn->GetName() ); poFeatureDefn->Reference(); poFeatureDefn->SetGeomType( wkbPoint ); for(int i=0;i<(int)(sizeof(UKOOAP190Fields)/sizeof(UKOOAP190Fields[0]));i++) { OGRFieldDefn oField( UKOOAP190Fields[i].pszName, UKOOAP190Fields[i].eType ); poFeatureDefn->AddFieldDefn( &oField ); } bUseEastingNorthingAsGeometry = CSLTestBoolean(CPLGetConfigOption("UKOOAP190_USE_EASTING_NORTHING", "NO")); ParseHeaders(); poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poSRS); }
int OGRCouchDBDataSource::IsOK(json_object* poAnswerObj, const char* pszErrorMsg) { if ( poAnswerObj == NULL || !json_object_is_type(poAnswerObj, json_type_object) ) { CPLError(CE_Failure, CPLE_AppDefined, "%s", pszErrorMsg); return FALSE; } json_object* poOK = json_object_object_get(poAnswerObj, "ok"); if ( !poOK ) { IsError(poAnswerObj, pszErrorMsg); return FALSE; } const char* pszOK = json_object_get_string(poOK); if ( !pszOK || !CSLTestBoolean(pszOK) ) { CPLError(CE_Failure, CPLE_AppDefined, "%s", pszErrorMsg); return FALSE; } return TRUE; }
OGRMSSQLSpatialDataSource::OGRMSSQLSpatialDataSource() { pszName = NULL; pszCatalog = NULL; papoLayers = NULL; nLayers = 0; nKnownSRID = 0; panSRID = NULL; papoSRS = NULL; nGeometryFormat = MSSQLGEOMETRY_NATIVE; bUseGeometryColumns = CSLTestBoolean(CPLGetConfigOption("MSSQLSPATIAL_USE_GEOMETRY_COLUMNS", "YES")); bListAllTables = CSLTestBoolean(CPLGetConfigOption("MSSQLSPATIAL_LIST_ALL_TABLES", "NO")); }
static void GDALDestructor(void) { if( bGDALDestroyAlreadyCalled ) return; if( !CSLTestBoolean(CPLGetConfigOption("GDAL_DESTROY", "YES")) ) return; GDALDestroy(); }
void VSICurlStreamingHandle::DownloadInThread() { VSICurlSetOptions(hCurlHandle, pszURL); static int bHasCheckVersion = FALSE; static int bSupportGZip = FALSE; if (!bHasCheckVersion) { bSupportGZip = strstr(curl_version(), "zlib/") != NULL; bHasCheckVersion = TRUE; } if (bSupportGZip && CSLTestBoolean(CPLGetConfigOption("CPL_CURL_GZIP", "YES"))) { curl_easy_setopt(hCurlHandle, CURLOPT_ENCODING, "gzip"); } if (pabyHeaderData == NULL) pabyHeaderData = (GByte*) CPLMalloc(HEADER_SIZE + 1); nHeaderSize = 0; nBodySize = 0; nHTTPCode = 0; curl_easy_setopt(hCurlHandle, CURLOPT_HEADERDATA, this); curl_easy_setopt(hCurlHandle, CURLOPT_HEADERFUNCTION, VSICurlStreamingHandleReceivedBytesHeader); curl_easy_setopt(hCurlHandle, CURLOPT_WRITEDATA, this); curl_easy_setopt(hCurlHandle, CURLOPT_WRITEFUNCTION, VSICurlStreamingHandleReceivedBytes); char szCurlErrBuf[CURL_ERROR_SIZE+1]; szCurlErrBuf[0] = '\0'; curl_easy_setopt(hCurlHandle, CURLOPT_ERRORBUFFER, szCurlErrBuf ); CURLcode eRet = curl_easy_perform(hCurlHandle); curl_easy_setopt(hCurlHandle, CURLOPT_WRITEDATA, NULL); curl_easy_setopt(hCurlHandle, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(hCurlHandle, CURLOPT_HEADERDATA, NULL); curl_easy_setopt(hCurlHandle, CURLOPT_HEADERFUNCTION, NULL); AcquireMutex(); if (!bAskDownloadEnd && eRet == 0 && !bHastComputedFileSize) { poFS->AcquireMutex(); CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(pszURL); cachedFileProp->fileSize = fileSize = nBodySize; cachedFileProp->bHastComputedFileSize = bHastComputedFileSize = TRUE; if (ENABLE_DEBUG) CPLDebug("VSICURL", "File size = " CPL_FRMT_GUIB, fileSize); poFS->ReleaseMutex(); } bDownloadInProgress = FALSE; bDownloadStopped = TRUE; /* Signal to the consumer that the download has ended */ CPLCondSignal(hCondProducer); ReleaseMutex(); }
void *CPLCreateZip( const char *pszZipFilename, char **papszOptions ) { (void) papszOptions; int bAppend = CSLTestBoolean(CSLFetchNameValueDef(papszOptions, "APPEND", "FALSE")); return cpl_zipOpen( pszZipFilename, bAppend ? APPEND_STATUS_ADDINZIP : APPEND_STATUS_CREATE); }
/** * \fn OGRwkbGeometryType OGRFeatureDefn::GetGeomType(); * * \brief Fetch the geometry base type. * * Note that some drivers are unable to determine a specific geometry * type for a layer, in which case wkbUnknown is returned. A value of * wkbNone indicates no geometry is available for the layer at all. * Many drivers do not properly mark the geometry * type as 25D even if some or all geometries are in fact 25D. A few (broken) * drivers return wkbPolygon for layers that also include wkbMultiPolygon. * * Starting with GDAL 1.11, this method returns GetGeomFieldDefn(0)->GetType(). * * This method is the same as the C function OGR_FD_GetGeomType(). * * @return the base type for all geometry related to this definition. */ OGRwkbGeometryType OGRFeatureDefn::GetGeomType() { if( GetGeomFieldCount() == 0 ) return wkbNone; OGRwkbGeometryType eType = GetGeomFieldDefn(0)->GetType(); if( eType == (wkbUnknown | wkb25DBitInternalUse) && CSLTestBoolean(CPLGetConfigOption("QGIS_HACK", "NO")) ) eType = wkbUnknown; return eType; }
OGRGMLLayer::OGRGMLLayer( const char * pszName, int bWriterIn, OGRGMLDataSource *poDSIn ) { iNextGMLId = 0; nTotalGMLCount = -1; bInvalidFIDFound = FALSE; pszFIDPrefix = NULL; bFaceHoleNegative = FALSE; poDS = poDSIn; if ( EQUALN(pszName, "ogr:", 4) ) poFeatureDefn = new OGRFeatureDefn( pszName+4 ); else poFeatureDefn = new OGRFeatureDefn( pszName ); SetDescription( poFeatureDefn->GetName() ); poFeatureDefn->Reference(); poFeatureDefn->SetGeomType( wkbNone ); bWriter = bWriterIn; bSameSRS = FALSE; /* -------------------------------------------------------------------- */ /* Reader's should get the corresponding GMLFeatureClass and */ /* cache it. */ /* -------------------------------------------------------------------- */ if( !bWriter ) poFClass = poDS->GetReader()->GetClass( pszName ); else poFClass = NULL; hCacheSRS = GML_BuildOGRGeometryFromList_CreateCache(); /* Compatibility option. Not advertized, because hopefully won't be needed */ /* Just put here in provision... */ bUseOldFIDFormat = CSLTestBoolean(CPLGetConfigOption("GML_USE_OLD_FID_FORMAT", "FALSE")); /* Must be in synced in OGR_G_CreateFromGML(), OGRGMLLayer::OGRGMLLayer() and GMLReader::GMLReader() */ bFaceHoleNegative = CSLTestBoolean(CPLGetConfigOption("GML_FACE_HOLE_NEGATIVE", "NO")); }
int OGRXLSDataSource::Open( const char * pszFilename, int bUpdateIn) { if (bUpdateIn) { return FALSE; } #ifdef _WIN32 if( CSLTestBoolean( CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) ) pszName = CPLRecode( pszFilename, CPL_ENC_UTF8, CPLString().Printf( "CP%d", GetACP() ) ); else pszName = CPLStrdup( pszFilename ); #else pszName = CPLStrdup( pszFilename ); #endif // -------------------------------------------------------------------- // Does this appear to be a .xls file? // -------------------------------------------------------------------- /* Open only for getting info. To get cell values, we have to use freexl_open */ if (freexl_open_info (pszName, &xlshandle) != FREEXL_OK) return FALSE; unsigned int nSheets = 0; if (freexl_get_info (xlshandle, FREEXL_BIFF_SHEET_COUNT, &nSheets) != FREEXL_OK) return FALSE; for(unsigned short i=0; i<(unsigned short)nSheets; i++) { freexl_select_active_worksheet(xlshandle, i); const char* pszSheetname = NULL; if (freexl_get_worksheet_name(xlshandle, i, &pszSheetname) != FREEXL_OK) return FALSE; unsigned int nRows = 0; unsigned short nCols = 0; if (freexl_worksheet_dimensions(xlshandle, &nRows, &nCols) != FREEXL_OK) return FALSE; /* Skip empty sheets */ if (nRows == 0) continue; papoLayers = (OGRLayer**) CPLRealloc(papoLayers, (nLayers + 1) * sizeof(OGRLayer*)); papoLayers[nLayers ++] = new OGRXLSLayer(this, pszSheetname, i, (int)nRows, nCols); } freexl_close(xlshandle); xlshandle = NULL; return TRUE; }
OGRShapeDataSource::OGRShapeDataSource() { pszName = NULL; papoLayers = NULL; nLayers = 0; bSingleFileDataSource = FALSE; poPool = new OGRLayerPool(); b2GBLimit = CSLTestBoolean(CPLGetConfigOption("SHAPE_2GB_LIMIT", "FALSE")); papszOpenOptions = NULL; }
bool isEmbedded() { if (isAssocClass) for (NodeVector::const_iterator it = oFields.begin(); it != oFields.end(); ++it) { if (*it == NULL) continue; if (CSLTestBoolean(CPLGetXMLValue( *it, "EmbeddedTransfer", "FALSE" ))) return true; } return false; }
OGRLayer * OGRJMLDataset::ICreateLayer( const char * pszLayerName, CPL_UNUSED OGRSpatialReference *poSRS, CPL_UNUSED OGRwkbGeometryType eType, char ** papszOptions ) { if (!bWriteMode || poLayer != NULL) return NULL; int bAddRGBField = CSLTestBoolean( CSLFetchNameValueDef(papszOptions, "CREATE_R_G_B_FIELD", "YES")); int bAddOGRStyleField = CSLTestBoolean( CSLFetchNameValueDef(papszOptions, "CREATE_OGR_STYLE_FIELD", "NO")); int bClassicGML = CSLTestBoolean( CSLFetchNameValueDef(papszOptions, "CLASSIC_GML", "NO")); poLayer = new OGRJMLWriterLayer( pszLayerName, this, fp, bAddRGBField, bAddOGRStyleField, bClassicGML); return poLayer; }