void NetProduction::initialize() { CreateLayers(); //Was moved from the constructor to the initialize to ensure that the xml file is written. weather = seekOne<Model*>("weather"); calendar = seekOne<Model*>("calendar"); lakeEnvironments = seekMany<LakeEnvironment*>("*"); OxygenConcentration = seekOne<Model*>("OxygenConcentration"); //LakeEnvironment = seekOne<Model*>("LakeEnvironment"); }
int OGRSXFDataSource::Open( const char * pszFilename, int bUpdateIn) { size_t nObjectsRead; int nFileHeaderSize; if (bUpdateIn) { return FALSE; } pszName = pszFilename; fpSXF = VSIFOpenL(pszName, "rb"); if ( fpSXF == NULL ) { CPLError(CE_Warning, CPLE_OpenFailed, "SXF open file %s failed", pszFilename); return FALSE; } //read header nFileHeaderSize = sizeof(SXFHeader); SXFHeader stSXFFileHeader; nObjectsRead = VSIFReadL(&stSXFFileHeader, nFileHeaderSize, 1, fpSXF); if (nObjectsRead != 1) { CPLError(CE_Failure, CPLE_None, "SXF head read failed"); CloseFile(); return FALSE; } //check version oSXFPassport.version = 0; if (stSXFFileHeader.nHeaderLength > 256) //if size == 400 then version >= 4 { oSXFPassport.version = stSXFFileHeader.nFormatVersion[2]; } else { oSXFPassport.version = stSXFFileHeader.nFormatVersion[1]; } if ( oSXFPassport.version < 3 ) { CPLError(CE_Failure, CPLE_NotSupported , "SXF File version not supported"); CloseFile(); return FALSE; } // read description if (ReadSXFDescription(fpSXF, oSXFPassport) != OGRERR_NONE) { CPLError(CE_Failure, CPLE_NotSupported, "SXF. Wrong description."); CloseFile(); return FALSE; } //read flags if (ReadSXFInformationFlags(fpSXF, oSXFPassport) != OGRERR_NONE) { CPLError(CE_Failure, CPLE_NotSupported, "SXF. Wrong state of the data."); CloseFile(); return FALSE; } if (oSXFPassport.informationFlags.bProjectionDataCompliance == false) { CPLError( CE_Failure, CPLE_NotSupported, "SXF. Data are not corresponde to the projection." ); CloseFile(); return FALSE; } //read spatial data if (ReadSXFMapDescription(fpSXF, oSXFPassport) != OGRERR_NONE) { CPLError(CE_Failure, CPLE_NotSupported, "SXF. Wrong state of the data."); CloseFile(); return FALSE; } if(oSXFPassport.informationFlags.bRealCoordinatesCompliance == false ) { CPLError( CE_Warning, CPLE_NotSupported, "SXF. Given material may be rotated in the conditional system of coordinates" ); } /*---------------- TRY READ THE RSC FILE HEADER -----------------------*/ CPLString soRSCRileName; const char* pszRSCRileName = CPLGetConfigOption("SXF_RSC_FILENAME", ""); if (CPLCheckForFile((char *)pszRSCRileName, NULL) == TRUE) { soRSCRileName = pszRSCRileName; } if(soRSCRileName.empty()) { pszRSCRileName = CPLResetExtension(pszFilename, "rsc"); if (CPLCheckForFile((char *)pszRSCRileName, NULL) == TRUE) { soRSCRileName = pszRSCRileName; } } if(soRSCRileName.empty()) { pszRSCRileName = CPLResetExtension(pszFilename, "RSC"); if (CPLCheckForFile((char *)pszRSCRileName, NULL) == TRUE) { soRSCRileName = pszRSCRileName; } } //1. Create layers from RSC file or create default set of layers from osm.rsc if (soRSCRileName.empty()) { CPLError(CE_Warning, CPLE_None, "RSC file for %s not exist", pszFilename); } else { VSILFILE* fpRSC; fpRSC = VSIFOpenL(soRSCRileName, "rb"); if (fpRSC == NULL) { CPLError(CE_Warning, CPLE_OpenFailed, "RSC file %s open failed", soRSCRileName.c_str()); } else { CPLDebug( "OGRSXFDataSource", "RSC Filename: %s", soRSCRileName.c_str() ); CreateLayers(fpRSC); VSIFCloseL(fpRSC); } } if (nLayers == 0)//create default set of layers { CreateLayers(); } FillLayers(); return TRUE; }