这篇教程C++ CPLAssert函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLAssert函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLAssert函数的具体用法?C++ CPLAssert怎么用?C++ CPLAssert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLAssert函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: DB2_V72_FIX_BYTE_ORDEROGRErr OGRGeometryCollection::importFromWkb( unsigned char * pabyData, int nSize ){ OGRwkbByteOrder eByteOrder; int nDataOffset; if( nSize < 9 && nSize != -1 ) return OGRERR_NOT_ENOUGH_DATA;/* -------------------------------------------------------------------- *//* Get the byte order byte. *//* -------------------------------------------------------------------- */ eByteOrder = DB2_V72_FIX_BYTE_ORDER((OGRwkbByteOrder) *pabyData); CPLAssert( eByteOrder == wkbXDR || eByteOrder == wkbNDR );/* -------------------------------------------------------------------- *//* Get the geometry feature type. For now we assume that *//* geometry type is between 0 and 255 so we only have to fetch *//* one byte. *//* -------------------------------------------------------------------- */#ifdef DEBUG OGRwkbGeometryType eGeometryType; if( eByteOrder == wkbNDR ) { eGeometryType = (OGRwkbGeometryType) pabyData[1]; } else { eGeometryType = (OGRwkbGeometryType) pabyData[4]; } CPLAssert( eGeometryType == wkbGeometryCollection || eGeometryType == wkbMultiPolygon || eGeometryType == wkbMultiLineString || eGeometryType == wkbMultiPoint );#endif /* -------------------------------------------------------------------- *//* Clear existing Geoms. *//* -------------------------------------------------------------------- */ empty(); /* -------------------------------------------------------------------- *//* Get the geometry count. *//* -------------------------------------------------------------------- */ memcpy( &nGeomCount, pabyData + 5, 4 ); if( OGR_SWAP( eByteOrder ) ) nGeomCount = CPL_SWAP32(nGeomCount); papoGeoms = (OGRGeometry **) OGRMalloc(sizeof(void*) * nGeomCount); nDataOffset = 9; if( nSize != -1 ) nSize -= nDataOffset;/* -------------------------------------------------------------------- *//* Get the Geoms. *//* -------------------------------------------------------------------- */ for( int iGeom = 0; iGeom < nGeomCount; iGeom++ ) { OGRErr eErr; eErr = OGRGeometryFactory:: createFromWkb( pabyData + nDataOffset, NULL, papoGeoms + iGeom, nSize ); if( eErr != OGRERR_NONE ) { nGeomCount = iGeom; return eErr; } if (papoGeoms[iGeom]->getCoordinateDimension() == 3) nCoordDimension = 3; if( nSize != -1 ) nSize -= papoGeoms[iGeom]->WkbSize(); nDataOffset += papoGeoms[iGeom]->WkbSize(); } return OGRERR_NONE;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:86,
示例2: cln_GetNextObjectOGRFeature *OGROGDILayer::GetNextRawFeature(){ ecs_Result *psResult; int i; OGRFeature *poFeature;/* -------------------------------------------------------------------- *//* Retrieve object from OGDI server and create new feature *//* -------------------------------------------------------------------- */ psResult = cln_GetNextObject(m_nClientID); if (! ECSSUCCESS(psResult)) { // We probably reached EOF... keep track of shape count. m_nTotalShapeCount = m_iNextShapeId - m_nFilteredOutShapes; return NULL; } poFeature = new OGRFeature(m_poFeatureDefn); poFeature->SetFID( m_iNextShapeId++ ); m_nFeaturesRead++;/* -------------------------------------------------------------------- *//* Process geometry *//* -------------------------------------------------------------------- */ if (m_eFamily == Point) { ecs_Point *psPoint = &(ECSGEOM(psResult).point); OGRPoint *poOGRPoint = new OGRPoint(psPoint->c.x, psPoint->c.y); poOGRPoint->assignSpatialReference(m_poSpatialRef); poFeature->SetGeometryDirectly(poOGRPoint); } else if (m_eFamily == Line) { ecs_Line *psLine = &(ECSGEOM(psResult).line); OGRLineString *poOGRLine = new OGRLineString(); poOGRLine->setNumPoints( psLine->c.c_len ); for( i=0; i < (int) psLine->c.c_len; i++ ) { poOGRLine->setPoint(i, psLine->c.c_val[i].x, psLine->c.c_val[i].y); } poOGRLine->assignSpatialReference(m_poSpatialRef); poFeature->SetGeometryDirectly(poOGRLine); } else if (m_eFamily == Area) { ecs_Area *psArea = &(ECSGEOM(psResult).area); OGRPolygon *poOGRPolygon = new OGRPolygon(); for(int iRing=0; iRing < (int) psArea->ring.ring_len; iRing++) { ecs_FeatureRing *psRing = &(psArea->ring.ring_val[iRing]); OGRLinearRing *poOGRRing = new OGRLinearRing(); poOGRRing->setNumPoints( psRing->c.c_len ); for( i=0; i < (int) psRing->c.c_len; i++ ) { poOGRRing->setPoint(i, psRing->c.c_val[i].x, psRing->c.c_val[i].y); } poOGRPolygon->addRingDirectly(poOGRRing); } // __TODO__ // When OGR supports polygon centroids then we should carry them here poOGRPolygon->assignSpatialReference(m_poSpatialRef); poFeature->SetGeometryDirectly(poOGRPolygon); } else if (m_eFamily == Text) { // __TODO__ // For now text is treated as a point and string is lost // ecs_Text *psText = &(ECSGEOM(psResult).text); OGRPoint *poOGRPoint = new OGRPoint(psText->c.x, psText->c.y); poOGRPoint->assignSpatialReference(m_poSpatialRef); poFeature->SetGeometryDirectly(poOGRPoint); } else { CPLAssert(FALSE); }/* -------------------------------------------------------------------- *//* Set attributes *//* -------------------------------------------------------------------- */ char *pszAttrList = ECSOBJECTATTR(psResult); for( int iField = 0; iField < m_poFeatureDefn->GetFieldCount(); iField++ ) { char *pszFieldStart; int nNameLen;//.........这里部分代码省略.........
开发者ID:samalone,项目名称:gdal-ios,代码行数:101,
示例3: DB2_V72_FIX_BYTE_ORDEROGRErr OGRLineString::importFromWkb( unsigned char * pabyData, int nSize ){ OGRwkbByteOrder eByteOrder; if( nSize < 21 && nSize != -1 ) return OGRERR_NOT_ENOUGH_DATA;/* -------------------------------------------------------------------- *//* Get the byte order byte. *//* -------------------------------------------------------------------- */ eByteOrder = DB2_V72_FIX_BYTE_ORDER((OGRwkbByteOrder) *pabyData); assert( eByteOrder == wkbXDR || eByteOrder == wkbNDR );/* -------------------------------------------------------------------- *//* Get the geometry feature type. For now we assume that *//* geometry type is between 0 and 255 so we only have to fetch *//* one byte. *//* -------------------------------------------------------------------- */ OGRwkbGeometryType eGeometryType; int bIs3D; if( eByteOrder == wkbNDR ) { eGeometryType = (OGRwkbGeometryType) pabyData[1]; bIs3D = pabyData[4] & 0x80 || pabyData[2] & 0x80; } else { eGeometryType = (OGRwkbGeometryType) pabyData[4]; bIs3D = pabyData[1] & 0x80 || pabyData[3] & 0x80; }#ifdef __WXOSX__ assert( eGeometryType == wkbLineString );#else CPLAssert( eGeometryType == wkbLineString );#endif/* -------------------------------------------------------------------- *//* Get the vertex count. *//* -------------------------------------------------------------------- */ int nNewNumPoints; memcpy( &nNewNumPoints, pabyData + 5, 4 ); if( OGR_SWAP( eByteOrder ) ) nNewNumPoints = CPL_SWAP32(nNewNumPoints); setNumPoints( nNewNumPoints ); if( bIs3D ) Make3D(); else Make2D();/* -------------------------------------------------------------------- *//* Get the vertex. *//* -------------------------------------------------------------------- */ int i; if( bIs3D ) { for( i = 0; i < nPointCount; i++ ) { memcpy( paoPoints + i, pabyData + 9 + i*24, 16 ); memcpy( padfZ + i, pabyData + 9 + 16 + i*24, 8 ); } } else { memcpy( paoPoints, pabyData + 9, 16 * nPointCount ); }/* -------------------------------------------------------------------- *//* Byte swap if needed. *//* -------------------------------------------------------------------- */ if( OGR_SWAP( eByteOrder ) ) { for( i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( &(paoPoints[i].x) ); CPL_SWAPDOUBLE( &(paoPoints[i].y) ); } if( bIs3D ) { for( i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( padfZ + i ); } } } return OGRERR_NONE;}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:95,
示例4: CPLAssertint OGRTABDataSource::Open( const char * pszName, int bTestOpen ){ VSIStatBuf stat; CPLAssert( m_pszName == NULL ); m_pszName = CPLStrdup( pszName );/* -------------------------------------------------------------------- *//* Is this a file or directory? *//* -------------------------------------------------------------------- */ if( VSIStat( pszName, &stat ) != 0 || (!VSI_ISDIR(stat.st_mode) && !VSI_ISREG(stat.st_mode)) ) { if( !bTestOpen ) { CPLError( CE_Failure, CPLE_OpenFailed, "%s is not a file or directory./n" "Unable to open as a Mapinfo dataset./n", pszName ); } return FALSE; }/* -------------------------------------------------------------------- *//* If it is a file, try to open as a Mapinfo file. *//* -------------------------------------------------------------------- */ if( VSI_ISREG(stat.st_mode) ) { IMapInfoFile *poFile; poFile = IMapInfoFile::SmartOpen( pszName, bTestOpen ); if( poFile == NULL ) return FALSE; m_nLayerCount = 1; m_papoLayers = (IMapInfoFile **) CPLMalloc(sizeof(void*)); m_papoLayers[0] = poFile; m_pszDirectory = CPLStrdup( CPLGetPath(pszName) ); }/* -------------------------------------------------------------------- *//* Otherwise, we need to scan the whole directory for files *//* ending in .tab or .mif. *//* -------------------------------------------------------------------- */ else { char **papszFileList = CPLReadDir( pszName ); m_pszDirectory = CPLStrdup( pszName ); for( int iFile = 0; papszFileList != NULL && papszFileList[iFile] != NULL; iFile++ ) { IMapInfoFile *poFile; const char *pszExtension = CPLGetExtension(papszFileList[iFile]); char *pszSubFilename; if( !EQUAL(pszExtension,"tab") && !EQUAL(pszExtension,"mif") ) continue; pszSubFilename = CPLStrdup( CPLFormFilename( m_pszDirectory, papszFileList[iFile], NULL )); poFile = IMapInfoFile::SmartOpen( pszSubFilename, bTestOpen ); CPLFree( pszSubFilename ); if( poFile == NULL ) { CSLDestroy( papszFileList ); return FALSE; } m_nLayerCount++; m_papoLayers = (IMapInfoFile **) CPLRealloc(m_papoLayers,sizeof(void*)*m_nLayerCount); m_papoLayers[m_nLayerCount-1] = poFile; } CSLDestroy( papszFileList ); if( m_nLayerCount == 0 ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_OpenFailed, "No mapinfo files found in directory %s./n", m_pszDirectory ); return FALSE; } } return TRUE;}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:98,
示例5: GetStatevoid NASReader::SetFeaturePropertyDirectly( const char *pszElement, char *pszValue ){ GMLFeature *poFeature = GetState()->m_poFeature; CPLAssert( poFeature != NULL );/* -------------------------------------------------------------------- *//* Does this property exist in the feature class? If not, add *//* it. *//* -------------------------------------------------------------------- */ GMLFeatureClass *poClass = poFeature->GetClass(); int iProperty; for( iProperty=0; iProperty < poClass->GetPropertyCount(); iProperty++ ) { if( EQUAL(poClass->GetProperty( iProperty )->GetSrcElement(), pszElement ) ) break; } if( iProperty == poClass->GetPropertyCount() ) { if( poClass->IsSchemaLocked() ) { CPLDebug("NAS","Encountered property missing from class schema."); CPLFree(pszValue); return; } CPLString osFieldName; if( strchr(pszElement,'|') == NULL ) osFieldName = pszElement; else { osFieldName = strrchr(pszElement,'|') + 1; if( poClass->GetPropertyIndex(osFieldName) != -1 ) osFieldName = pszElement; } // Does this conflict with an existing property name? while( poClass->GetProperty(osFieldName) != NULL ) { osFieldName += "_"; } GMLPropertyDefn *poPDefn = new GMLPropertyDefn(osFieldName,pszElement); if( EQUAL(CPLGetConfigOption( "GML_FIELDTYPES", ""), "ALWAYS_STRING") ) poPDefn->SetType( GMLPT_String ); poClass->AddProperty( poPDefn ); }/* -------------------------------------------------------------------- *//* We want to handle <lage> specially to ensure it is zero *//* filled, and treated as a string depspite the numeric *//* content. https://trac.wheregroup.com/PostNAS/ticket/9 *//* -------------------------------------------------------------------- */ if( strcmp(poClass->GetProperty(iProperty)->GetName(),"lage") == 0 ) { if( strlen(pszValue) < 5 ) { CPLString osValue = "00000"; osValue += pszValue; poFeature->SetPropertyDirectly( iProperty, CPLStrdup(osValue + osValue.size() - 5) ); CPLFree(pszValue); } else poFeature->SetPropertyDirectly( iProperty, pszValue ); if( !poClass->IsSchemaLocked() ) { poClass->GetProperty(iProperty)->SetWidth( 5 ); poClass->GetProperty(iProperty)->SetType( GMLPT_String ); } return; }/* -------------------------------------------------------------------- *//* Set the property *//* -------------------------------------------------------------------- */ poFeature->SetPropertyDirectly( iProperty, pszValue );/* -------------------------------------------------------------------- *//* Do we need to update the property type? *//* -------------------------------------------------------------------- */ if( !poClass->IsSchemaLocked() ) { // Special handling for punktkennung per NAS #12 if( strcmp(poClass->GetProperty(iProperty)->GetName(), "punktkennung") == 0) { poClass->GetProperty(iProperty)->SetWidth( 15 ); poClass->GetProperty(iProperty)->SetType( GMLPT_String ); } // Special handling for artDerFlurstuecksgrenze per http://trac.osgeo.org/gdal/ticket/4255//.........这里部分代码省略.........
开发者ID:afarnham,项目名称:gdal,代码行数:101,
示例6: CPLGetConfigOption//.........这里部分代码省略......... if( !FindFile( szTargetFile, pszDirectory, bReportErr, &fp ) ) return FALSE;/* -------------------------------------------------------------------- *//* Skip the line defining the column titles. *//* -------------------------------------------------------------------- */ pszLine = ReadLine( fp ); if( !EQUAL(pszLine, "/"Code/",/"Attribute/",/"Acronym/",/"Attributetype/",/"Class/"") ) { CPLError( CE_Failure, CPLE_AppDefined, "s57attributes columns don't match expected format!/n" ); return FALSE; } /* -------------------------------------------------------------------- *//* Prepare arrays for the per-attribute information. *//* -------------------------------------------------------------------- */ nAttrMax = MAX_ATTRIBUTES-1; papszAttrNames = (char **) CPLCalloc(sizeof(char *),MAX_ATTRIBUTES); papszAttrAcronym = (char **) CPLCalloc(sizeof(char *),MAX_ATTRIBUTES); //papapszAttrValues = (char ***) CPLCalloc(sizeof(char **),MAX_ATTRIBUTES); pachAttrType = (char *) CPLCalloc(sizeof(char),MAX_ATTRIBUTES); pachAttrClass = (char *) CPLCalloc(sizeof(char),MAX_ATTRIBUTES); panAttrIndex = (int *) CPLCalloc(sizeof(int),MAX_ATTRIBUTES); /* -------------------------------------------------------------------- *//* Read and form string list. *//* -------------------------------------------------------------------- */ int iAttr; while( (pszLine = ReadLine(fp)) != NULL ) { char **papszTokens = CSLTokenizeStringComplex( pszLine, ",", TRUE, TRUE ); if( CSLCount(papszTokens) < 5 ) { CPLAssert( FALSE ); continue; } iAttr = atoi(papszTokens[0]); if( iAttr < 0 || iAttr >= nAttrMax || papszAttrNames[iAttr] != NULL ) { CPLDebug( "S57", "Duplicate definition for attribute %d:%s", iAttr, papszTokens[2] ); continue; } papszAttrNames[iAttr] = CPLStrdup(papszTokens[1]); papszAttrAcronym[iAttr] = CPLStrdup(papszTokens[2]); pachAttrType[iAttr] = papszTokens[3][0]; pachAttrClass[iAttr] = papszTokens[4][0]; CSLDestroy( papszTokens ); } if( fp != NULL ) VSIFClose( fp ); /* -------------------------------------------------------------------- *//* Build unsorted index of attributes. *//* -------------------------------------------------------------------- */ nAttrCount = 0; for( iAttr = 0; iAttr < nAttrMax; iAttr++ ) { if( papszAttrAcronym[iAttr] != NULL ) panAttrIndex[nAttrCount++] = iAttr; }/* -------------------------------------------------------------------- *//* Sort index by acronym. *//* -------------------------------------------------------------------- */ int bModified; do { bModified = FALSE; for( iAttr = 0; iAttr < nAttrCount-1; iAttr++ ) { if( strcmp(papszAttrAcronym[panAttrIndex[iAttr]], papszAttrAcronym[panAttrIndex[iAttr+1]]) > 0 ) { int nTemp; nTemp = panAttrIndex[iAttr]; panAttrIndex[iAttr] = panAttrIndex[iAttr+1]; panAttrIndex[iAttr+1] = nTemp; bModified = TRUE; } } } while( bModified ); return TRUE;}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例7: CPLAssertint OGRMySQLDataSource::FetchSRSId( OGRSpatialReference * poSRS ){ char **papszRow; MYSQL_RES *hResult=NULL; char szCommand[10000]; char *pszWKT = NULL; int nSRSId; if( poSRS == NULL ) return -1;/* -------------------------------------------------------------------- *//* Translate SRS to WKT. *//* -------------------------------------------------------------------- */ if( poSRS->exportToWkt( &pszWKT ) != OGRERR_NONE ) return -1; CPLAssert( strlen(pszWKT) < sizeof(szCommand) - 500 );/* -------------------------------------------------------------------- *//* Try to find in the existing table. *//* -------------------------------------------------------------------- */ sprintf( szCommand, "SELECT srid FROM spatial_ref_sys WHERE srtext = '%s'", pszWKT ); if( !mysql_query( GetConn(), szCommand ) ) hResult = mysql_store_result( GetConn() ); if (!mysql_num_rows(hResult)) { CPLDebug("MYSQL", "No rows exist currently exist in spatial_ref_sys"); mysql_free_result( hResult ); hResult = NULL; } papszRow = NULL; if( hResult != NULL ) papszRow = mysql_fetch_row( hResult ); if( papszRow != NULL && papszRow[0] != NULL ) { nSRSId = atoi(papszRow[0]); if( hResult != NULL ) mysql_free_result( hResult ); hResult = NULL; CPLFree(pszWKT); return nSRSId; } // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != NULL ) mysql_free_result( hResult ); hResult = NULL;/* -------------------------------------------------------------------- *//* Get the current maximum srid in the srs table. *//* -------------------------------------------------------------------- */ sprintf( szCommand, "SELECT MAX(srid) FROM spatial_ref_sys"); if( !mysql_query( GetConn(), szCommand ) ) { hResult = mysql_store_result( GetConn() ); papszRow = mysql_fetch_row( hResult ); } if( papszRow != NULL && papszRow[0] != NULL ) { nSRSId = atoi(papszRow[0]) + 1; } else nSRSId = 1; if( hResult != NULL ) mysql_free_result( hResult ); hResult = NULL;/* -------------------------------------------------------------------- *//* Try adding the SRS to the SRS table. *//* -------------------------------------------------------------------- */ sprintf( szCommand, "INSERT INTO spatial_ref_sys (srid,srtext) VALUES (%d,'%s')", nSRSId, pszWKT ); if( !mysql_query( GetConn(), szCommand ) ) hResult = mysql_store_result( GetConn() ); // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != NULL ) mysql_free_result( hResult ); hResult = NULL; CPLFree(pszWKT); return nSRSId;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:99,
示例8: memcpy//.........这里部分代码省略......... GDALRasterBand * poBaseMask = poBaseBand != nullptr ? poBaseBand->GetMaskBand() : nullptr; const int nOverviewCount = poBaseMask != nullptr ? poBaseMask->GetOverviewCount() : 0; GDALDataset* poMaskDSTemp = nullptr; for( int iOver = 0; iOver < nOverviewCount; iOver++ ) { GDALRasterBand * const poOverBand = poBaseMask->GetOverview( iOver ); if( poOverBand == nullptr ) continue; if( poOverBand->GetXSize() == poDS->GetRasterXSize() && poOverBand->GetYSize() == poDS->GetRasterYSize() ) { poMaskDSTemp = poOverBand->GetDataset(); break; } } if( poMaskDSTemp != poDS ) { poMaskDS = poMaskDSTemp; bCheckedForMask = true; bOwnMaskDS = false; return poMaskDS != nullptr; } }/* -------------------------------------------------------------------- *//* Are we even initialized? If not, we apparently don't want *//* to support overviews and masks. *//* -------------------------------------------------------------------- */ if( poDS == nullptr ) return FALSE;/* -------------------------------------------------------------------- *//* Check for .msk file. *//* -------------------------------------------------------------------- */ bCheckedForMask = true; if( pszBasename == nullptr ) pszBasename = poDS->GetDescription(); // Don't bother checking for masks of masks. if( EQUAL(CPLGetExtension(pszBasename),"msk") ) return FALSE; if( !GDALCanFileAcceptSidecarFile(pszBasename) ) return FALSE; CPLString osMskFilename; osMskFilename.Printf( "%s.msk", pszBasename ); std::vector<char> achMskFilename; achMskFilename.resize(osMskFilename.size() + 1); memcpy(&(achMskFilename[0]), osMskFilename.c_str(), osMskFilename.size() + 1); bool bExists = CPL_TO_BOOL( CPLCheckForFile( &achMskFilename[0], papszSiblingFiles ) ); osMskFilename = &achMskFilename[0];#if !defined(WIN32) if( !bExists && !papszSiblingFiles ) { osMskFilename.Printf( "%s.MSK", pszBasename ); memcpy(&(achMskFilename[0]), osMskFilename.c_str(), osMskFilename.size() + 1); bExists = CPL_TO_BOOL( CPLCheckForFile( &achMskFilename[0], papszSiblingFiles ) ); osMskFilename = &achMskFilename[0]; }#endif if( !bExists ) return FALSE;/* -------------------------------------------------------------------- *//* Open the file. *//* -------------------------------------------------------------------- */ poMaskDS = GDALDataset::Open( osMskFilename, GDAL_OF_RASTER | (poDS->GetAccess() == GA_Update ? GDAL_OF_UPDATE : 0), nullptr, nullptr, papszInitSiblingFiles ); CPLAssert( poMaskDS != poDS ); if( poMaskDS == nullptr ) return FALSE; bOwnMaskDS = true; return TRUE;}
开发者ID:OSGeo,项目名称:gdal,代码行数:101,
示例9: CleanOverviews//.........这里部分代码省略......... for( int i = 0; i < nOverviews; i++ ) { if( !abValidLevel[i] || !abRequireRefresh[i] ) continue; for( int j = 0; j < poBand->GetOverviewCount(); j++ ) { if( abAlreadyUsedOverviewBand[j] ) continue; GDALRasterBand * poOverview = poBand->GetOverview( j ); if( poOverview == nullptr ) continue; int bHasNoData = FALSE; double noDataValue = poBand->GetNoDataValue(&bHasNoData); if( bHasNoData ) poOverview->SetNoDataValue(noDataValue); const int nOvFactor = GDALComputeOvFactor(poOverview->GetXSize(), poBand->GetXSize(), poOverview->GetYSize(), poBand->GetYSize()); if( nOvFactor == panOverviewList[i] || nOvFactor == GDALOvLevelAdjust2( panOverviewList[i], poBand->GetXSize(), poBand->GetYSize() )) { abAlreadyUsedOverviewBand[j] = true; CPLAssert(nNewOverviews < poBand->GetOverviewCount()); papoOverviewBands[nNewOverviews++] = poOverview; break; } } } if( nNewOverviews > 0 ) { const double dfOffset = dfAreaNewOverviews / dfAreaRefreshedOverviews; const double dfScale = 1.0 - dfOffset; pScaledProgress = GDALCreateScaledProgress( dfOffset + dfScale * iBand / nBands, dfOffset + dfScale * (iBand+1) / nBands, pfnProgress, pProgressData ); eErr = GDALRegenerateOverviews( GDALRasterBand::ToHandle(poBand), nNewOverviews, reinterpret_cast<GDALRasterBandH*>(papoOverviewBands), pszResampling, GDALScaledProgress, pScaledProgress ); GDALDestroyScaledProgress( pScaledProgress ); } }/* -------------------------------------------------------------------- *//* Cleanup *//* -------------------------------------------------------------------- */ CPLFree( papoOverviewBands ); CPLFree( panNewOverviewList ); CPLFree( pahBands );/* -------------------------------------------------------------------- *//* If we have a mask file, we need to build its overviews too. */
开发者ID:OSGeo,项目名称:gdal,代码行数:67,
示例10: CPLAssertvoid OGRCompoundCurve::EndPoint(OGRPoint *p) const{ CPLAssert(oCC.nCurveCount > 0); oCC.papoCurves[oCC.nCurveCount-1]->EndPoint(p);}
开发者ID:drownedout,项目名称:datamap,代码行数:5,
示例11: CPLError//.........这里部分代码省略......... break; if (eReqDT == GDT_Int16) { WriteFloat(fp, 1); /* scale */ WriteFloat(fp, 0); /* offset */ for(k=0;k<nReqYSize;k++) { int nLastVal = ((short*)pTileBuffer)[(nReqYSize - k - 1) * nReqXSize + 0]; GByte nWordSize = 1; for(l=1;l<nReqXSize;l++) { int nVal = ((short*)pTileBuffer)[(nReqYSize - k - 1) * nReqXSize + l]; int nDiff = nVal - nLastVal; if (nDiff < -32768 || nDiff > 32767) { nWordSize = 4; break; } if (nDiff < -128 || nDiff > 127) nWordSize = 2; nLastVal = nVal; } VSIFWriteL(&nWordSize, 1, 1, fp); nLastVal = ((short*)pTileBuffer)[(nReqYSize - k - 1) * nReqXSize + 0]; WriteInt(fp, nLastVal); for(l=1;l<nReqXSize;l++) { int nVal = ((short*)pTileBuffer)[(nReqYSize - k - 1) * nReqXSize + l]; int nDiff = nVal - nLastVal; if (nWordSize == 1) { CPLAssert(nDiff >= -128 && nDiff <= 127); char chDiff = (char)nDiff; VSIFWriteL(&chDiff, 1, 1, fp); } else if (nWordSize == 2) { CPLAssert(nDiff >= -32768 && nDiff <= 32767); WriteShort(fp, (short)nDiff); } else { WriteInt(fp, nDiff); } nLastVal = nVal; } } } else { float fMinVal = ((float*)pTileBuffer)[0]; float fMaxVal = fMinVal; for(k=1;k<nReqYSize*nReqXSize;k++) { float fVal = ((float*)pTileBuffer)[k]; if (fVal < fMinVal) fMinVal = fVal; if (fVal > fMaxVal) fMaxVal = fVal; } float fIntRange = (fMaxVal - fMinVal) / fVertPres; float fScale = (fMinVal == fMaxVal) ? 1 : (fMaxVal - fMinVal) / fIntRange; float fOffset = fMinVal; WriteFloat(fp, fScale); /* scale */ WriteFloat(fp, fOffset); /* offset */
开发者ID:0004c,项目名称:node-gdal,代码行数:67,
示例12: CPLAssertint OGRMySQLDataSource::Open( const char * pszNewName, int bUpdate, int bTestOpen ){ CPLAssert( nLayers == 0 );/* -------------------------------------------------------------------- *//* Verify MySQL prefix. *//* -------------------------------------------------------------------- */ if( !EQUALN(pszNewName,"MYSQL:",6) ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_AppDefined, "%s does not conform to MySQL naming convention," " MYSQL:dbname[, user=..][,password=..][,host=..][,port=..][tables=table;table;...]", pszNewName ); return FALSE; } /* -------------------------------------------------------------------- *//* Use options process to get .my.cnf file contents. *//* -------------------------------------------------------------------- */ int nPort = 0, i; char **papszTableNames=NULL; std::string oHost, oPassword, oUser, oDB; char *apszArgv[2] = { (char*) "org", NULL }; char **papszArgv = apszArgv; int nArgc = 1; const char *client_groups[] = {"client", "ogr", NULL }; my_init(); // I hope there is no problem with calling this multiple times! load_defaults( "my", client_groups, &nArgc, &papszArgv ); for( i = 0; i < nArgc; i++ ) { if( EQUALN(papszArgv[i],"--user=",7) ) oUser = papszArgv[i] + 7; else if( EQUALN(papszArgv[i],"--host=",7) ) oHost = papszArgv[i] + 7; else if( EQUALN(papszArgv[i],"--password=",11) ) oPassword = papszArgv[i] + 11; else if( EQUALN(papszArgv[i],"--port=",7) ) nPort = atoi(papszArgv[i] + 7); } // cleanup free_defaults( papszArgv );/* -------------------------------------------------------------------- *//* Parse out connection information. *//* -------------------------------------------------------------------- */ char **papszItems = CSLTokenizeString2( pszNewName+6, ",", CSLT_HONOURSTRINGS ); if( CSLCount(papszItems) < 1 ) { CSLDestroy( papszItems ); CPLError( CE_Failure, CPLE_AppDefined, "MYSQL: request missing databasename." ); return FALSE; } oDB = papszItems[0]; for( i = 1; papszItems[i] != NULL; i++ ) { if( EQUALN(papszItems[i],"user=",5) ) oUser = papszItems[i] + 5; else if( EQUALN(papszItems[i],"password=",9) ) oPassword = papszItems[i] + 9; else if( EQUALN(papszItems[i],"host=",5) ) oHost = papszItems[i] + 5; else if( EQUALN(papszItems[i],"port=",5) ) nPort = atoi(papszItems[i] + 5); else if( EQUALN(papszItems[i],"tables=",7) ) { papszTableNames = CSLTokenizeStringComplex( papszItems[i] + 7, ";", FALSE, FALSE ); } else CPLError( CE_Warning, CPLE_AppDefined, "'%s' in MYSQL datasource definition not recognised and ignored.", papszItems[i] ); } CSLDestroy( papszItems );/* -------------------------------------------------------------------- *//* Try to establish connection. *//* -------------------------------------------------------------------- */ hConn = mysql_init( NULL ); if( hConn == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "mysql_init() failed." ); }/* -------------------------------------------------------------------- *//* Set desired options on the connection: charset and timeout. *//* -------------------------------------------------------------------- *///.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例13: VRTCreateCopystatic GDALDataset *VRTCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, int bStrict, char ** papszOptions, CPL_UNUSED GDALProgressFunc pfnProgress, CPL_UNUSED void * pProgressData ){ VRTDataset *poVRTDS = NULL; (void) bStrict; (void) papszOptions; CPLAssert( NULL != poSrcDS );/* -------------------------------------------------------------------- *//* If the source dataset is a virtual dataset then just write *//* it to disk as a special case to avoid extra layers of *//* indirection. *//* -------------------------------------------------------------------- */ if( poSrcDS->GetDriver() != NULL && EQUAL(poSrcDS->GetDriver()->GetDescription(),"VRT") ) { /* -------------------------------------------------------------------- */ /* Convert tree to a single block of XML text. */ /* -------------------------------------------------------------------- */ char *pszVRTPath = CPLStrdup(CPLGetPath(pszFilename)); ((VRTDataset *) poSrcDS)->UnsetPreservedRelativeFilenames(); CPLXMLNode *psDSTree = ((VRTDataset *) poSrcDS)->SerializeToXML( pszVRTPath ); char *pszXML = CPLSerializeXMLTree( psDSTree ); CPLDestroyXMLNode( psDSTree ); CPLFree( pszVRTPath ); /* -------------------------------------------------------------------- */ /* Write to disk. */ /* -------------------------------------------------------------------- */ GDALDataset* pCopyDS = NULL; if( 0 != strlen( pszFilename ) ) { VSILFILE *fpVRT = NULL; fpVRT = VSIFOpenL( pszFilename, "wb" ); if (fpVRT == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot create %s", pszFilename); CPLFree( pszXML ); return NULL; } VSIFWriteL( pszXML, 1, strlen(pszXML), fpVRT ); VSIFCloseL( fpVRT ); pCopyDS = (GDALDataset *) GDALOpen( pszFilename, GA_Update ); } else { /* No destination file is given, so pass serialized XML directly. */ pCopyDS = (GDALDataset *) GDALOpen( pszXML, GA_Update ); } CPLFree( pszXML ); return pCopyDS; }/* -------------------------------------------------------------------- *//* Create the virtual dataset. *//* -------------------------------------------------------------------- */ poVRTDS = (VRTDataset *) VRTDataset::Create( pszFilename, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), 0, GDT_Byte, NULL ); if (poVRTDS == NULL) return NULL;/* -------------------------------------------------------------------- *//* Do we have a geotransform? *//* -------------------------------------------------------------------- */ double adfGeoTransform[6]; if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None ) { poVRTDS->SetGeoTransform( adfGeoTransform ); }/* -------------------------------------------------------------------- *//* Copy projection *//* -------------------------------------------------------------------- */ poVRTDS->SetProjection( poSrcDS->GetProjectionRef() );/* -------------------------------------------------------------------- *//* Emit dataset level metadata. *///.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例14: CPLAssertCPLErr EpsilonRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, void * pImage){ EpsilonDataset* poGDS = (EpsilonDataset*) poDS; //CPLDebug("EPSILON", "IReadBlock(nBand=%d,nBlockXOff=%d,nBlockYOff=%d)", // nBand, nBlockXOff, nBlockYOff); int nBlocksPerRow = (poGDS->nRasterXSize + nBlockXSize - 1) / nBlockXSize; int nBlock = nBlockXOff + nBlockYOff * nBlocksPerRow; BlockDesc* psDesc = &poGDS->pasBlocks[nBlock];#ifdef DEBUG int nBlocksPerColumn = (poGDS->nRasterYSize + nBlockYSize - 1) / nBlockYSize; CPLAssert(psDesc->x == nBlockXOff * nBlockXSize); CPLAssert(psDesc->y == nBlockYOff * nBlockYSize); CPLAssert(psDesc->w == (nBlockXOff < nBlocksPerRow - 1) ? nBlockXSize : poGDS->nRasterXSize - psDesc->x); CPLAssert(psDesc->h == (nBlockYOff < nBlocksPerColumn - 1) ? nBlockYSize : poGDS->nRasterYSize - psDesc->y);#endif poGDS->Seek(psDesc->offset); if (!poGDS->GetNextBlockData()) { memset(pImage, 0, nBlockXSize * nBlockYSize); return CE_Failure; } eps_block_header hdr; if (eps_read_block_header (poGDS->pabyBlockData, poGDS->nBlockDataSize, &hdr) != EPS_OK) { CPLError(CE_Warning, CPLE_AppDefined, "cannot read block header"); memset(pImage, 0, nBlockXSize * nBlockYSize); return CE_Failure; } if (hdr.chk_flag == EPS_BAD_CRC || hdr.crc_flag == EPS_BAD_CRC) { CPLError(CE_Warning, CPLE_AppDefined, "bad CRC"); memset(pImage, 0, nBlockXSize * nBlockYSize); return CE_Failure; } int w = (hdr.block_type == EPS_GRAYSCALE_BLOCK) ? hdr.gs.w : hdr.tc.w; int h = (hdr.block_type == EPS_GRAYSCALE_BLOCK) ? hdr.gs.h : hdr.tc.h; int i; if (poGDS->nBands == 1) { unsigned char ** pTempData = (unsigned char **) CPLMalloc(h * sizeof(unsigned char*)); for(i=0;i<h;i++) pTempData[i] = ((GByte*)pImage) + i * nBlockXSize; if (w != nBlockXSize || h != nBlockYSize) memset(pImage, 0, nBlockXSize * nBlockYSize); if (eps_decode_grayscale_block (pTempData, poGDS->pabyBlockData, &hdr) != EPS_OK) { CPLFree(pTempData); memset(pImage, 0, nBlockXSize * nBlockYSize); return CE_Failure; } CPLFree(pTempData); } else { if (poGDS->pabyRGBData == NULL) { poGDS->pabyRGBData = (GByte*) VSIMalloc3(nBlockXSize, nBlockYSize, 3); if (poGDS->pabyRGBData == NULL) { memset(pImage, 0, nBlockXSize * nBlockYSize); return CE_Failure; } } if (poGDS->nBufferedBlock == nBlock) { memcpy(pImage, poGDS->pabyRGBData + (nBand - 1) * nBlockXSize * nBlockYSize, nBlockXSize * nBlockYSize); return CE_None; } unsigned char ** pTempData[3]; int iBand; for(iBand=0;iBand<3;iBand++) { pTempData[iBand] = (unsigned char **) CPLMalloc(h * sizeof(unsigned char*)); for(i=0;i<h;i++) pTempData[iBand][i] = poGDS->pabyRGBData + iBand * nBlockXSize * nBlockYSize + i * nBlockXSize;//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例15: CPLAssertint OGRShapeDataSource::Open( const char * pszNewName, int bUpdate, int bTestOpen, int bForceSingleFileDataSource ){ VSIStatBufL stat; CPLAssert( nLayers == 0 ); pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate; bSingleFileDataSource = bForceSingleFileDataSource;/* -------------------------------------------------------------------- *//* If bSingleFileDataSource is TRUE we don't try to do anything else. *//* This is only utilized when the OGRShapeDriver::Create() *//* method wants to create a stub OGRShapeDataSource for a *//* single shapefile. The driver will take care of creating the *//* file by calling CreateLayer(). *//* -------------------------------------------------------------------- */ if( bSingleFileDataSource ) return TRUE; /* -------------------------------------------------------------------- *//* Is the given path a directory or a regular file? *//* -------------------------------------------------------------------- */ if( VSIStatExL( pszNewName, &stat, VSI_STAT_EXISTS_FLAG | VSI_STAT_NATURE_FLAG ) != 0 || (!VSI_ISDIR(stat.st_mode) && !VSI_ISREG(stat.st_mode)) ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_AppDefined, "%s is neither a file or directory, Shape access failed./n", pszNewName ); return FALSE; } /* -------------------------------------------------------------------- *//* Build a list of filenames we figure are Shape files. *//* -------------------------------------------------------------------- */ if( VSI_ISREG(stat.st_mode) ) { if( !OpenFile( pszNewName, bUpdate, bTestOpen ) ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open shapefile %s./n" "It may be corrupt or read-only file accessed in update mode./n", pszNewName ); return FALSE; } bSingleFileDataSource = TRUE; return TRUE; } else { char **papszCandidates = CPLReadDir( pszNewName ); int iCan, nCandidateCount = CSLCount( papszCandidates ); int bMightBeOldCoverage = FALSE; for( iCan = 0; iCan < nCandidateCount; iCan++ ) { char *pszFilename; const char *pszCandidate = papszCandidates[iCan]; if( EQUAL(pszCandidate,"ARC") ) bMightBeOldCoverage = TRUE; if( strlen(pszCandidate) < 4 || !EQUAL(pszCandidate+strlen(pszCandidate)-4,".shp") ) continue; pszFilename = CPLStrdup(CPLFormFilename(pszNewName, pszCandidate, NULL)); if( !OpenFile( pszFilename, bUpdate, bTestOpen ) && !bTestOpen ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open shapefile %s./n" "It may be corrupt or read-only file accessed in update mode./n", pszFilename ); CPLFree( pszFilename ); return FALSE; } CPLFree( pszFilename ); } // Try and .dbf files without apparent associated shapefiles. for( iCan = 0; iCan < nCandidateCount; iCan++ ) { char *pszFilename; const char *pszCandidate = papszCandidates[iCan]; const char *pszLayerName; int iLayer, bGotAlready = FALSE;//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例16: CPLDebugint OGRGMELayer::FetchDescribe(){ CPLString osRequest = "tables/" + osTableId; CPLHTTPResult *psDescribe = poDS->MakeRequest(osRequest); if (psDescribe == NULL) return FALSE; CPLDebug("GME", "table doc = %s/n", psDescribe->pabyData); json_object *table_doc = OGRGMEParseJSON((const char *) psDescribe->pabyData); CPLHTTPDestroyResult(psDescribe); osTableName = OGRGMEGetJSONString(table_doc, "name"); poFeatureDefn = new OGRFeatureDefn(osTableName); poFeatureDefn->Reference(); json_object *schema_doc = json_object_object_get(table_doc, "schema"); json_object *columns_doc = json_object_object_get(schema_doc, "columns"); array_list *column_list = json_object_get_array(columns_doc); CPLString osLastGeomColumn; int field_count = array_list_length(column_list); for( int i = 0; i < field_count; i++ ) { OGRwkbGeometryType eFieldGeomType = wkbNone; json_object *field_obj = (json_object*) array_list_get_idx(column_list, i); const char* name = OGRGMEGetJSONString(field_obj, "name"); OGRFieldDefn oFieldDefn(name, OFTString); const char *type = OGRGMEGetJSONString(field_obj, "type"); if (EQUAL(type, "integer")) oFieldDefn.SetType(OFTInteger); else if (EQUAL(type, "double")) oFieldDefn.SetType(OFTReal); else if (EQUAL(type, "boolean")) oFieldDefn.SetType(OFTInteger); else if (EQUAL(type, "string")) oFieldDefn.SetType(OFTString); else if (EQUAL(type, "string")) { if (EQUAL(name, "gx_id")) { iGxIdField = i; } oFieldDefn.SetType(OFTString); } else if (EQUAL(type, "points")) eFieldGeomType = wkbPoint; else if (EQUAL(type, "linestrings")) eFieldGeomType = wkbLineString; else if (EQUAL(type, "polygons")) eFieldGeomType = wkbPolygon; else if (EQUAL(type, "mixedGeometry")) eFieldGeomType = wkbGeometryCollection; if (eFieldGeomType == wkbNone) { poFeatureDefn->AddFieldDefn(&oFieldDefn); } else { CPLAssert(EQUAL(osGeomColumnName,"")); osGeomColumnName = oFieldDefn.GetNameRef(); poFeatureDefn->SetGeomType(eFieldGeomType); poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poSRS); } } json_object_put(table_doc); return TRUE;}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:77,
示例17: if//.........这里部分代码省略......... x[i] = -M_PI; else if (bCheckWithInvertProj) { x[i] = y[i] = HUGE_VAL; y0 = HUGE_VAL; continue; } else { do { x[i] += 2 * M_PI; } while( x[i] < -M_PI ); } } // Optimization for the case where we are provided a whole line of same northing if( i > 0 && y[i] == y0 ) y[i] = y[0]; else y[i] = M_PI / 2 - 2. * atan(exp(-y[i] * REVERSE_SPHERE_RADIUS)); } } bTransformDone = true; } else if( bIdentityTransform ) bTransformDone = true;/* -------------------------------------------------------------------- *//* Do the transformation (or not...) using PROJ.4. *//* -------------------------------------------------------------------- */ if( !bTransformDone && pjctx == NULL ) { /* The mutex has already been created */ CPLAssert(hPROJMutex != NULL); CPLAcquireMutex(hPROJMutex, 1000.0); } if( bTransformDone ) err = 0; else if (bCheckWithInvertProj) { /* For some projections, we cannot detect if we are trying to reproject */ /* coordinates outside the validity area of the projection. So let's do */ /* the reverse reprojection and compare with the source coordinates */ if (nCount > nMaxCount) { nMaxCount = nCount; padfOriX = (double*) CPLRealloc(padfOriX, sizeof(double)*nCount); padfOriY = (double*) CPLRealloc(padfOriY, sizeof(double)*nCount); padfOriZ = (double*) CPLRealloc(padfOriZ, sizeof(double)*nCount); padfTargetX = (double*) CPLRealloc(padfTargetX, sizeof(double)*nCount); padfTargetY = (double*) CPLRealloc(padfTargetY, sizeof(double)*nCount); padfTargetZ = (double*) CPLRealloc(padfTargetZ, sizeof(double)*nCount); } memcpy(padfOriX, x, sizeof(double)*nCount); memcpy(padfOriY, y, sizeof(double)*nCount); if (z) { memcpy(padfOriZ, z, sizeof(double)*nCount); } err = pfn_pj_transform( psPJSource, psPJTarget, nCount, 1, x, y, z ); if (err == 0) { memcpy(padfTargetX, x, sizeof(double)*nCount); memcpy(padfTargetY, y, sizeof(double)*nCount); if (z)
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:67,
示例18: CPLErrorOGRFeature *OGRGMLLayer::GetNextFeature(){ if (bWriter) { CPLError(CE_Failure, CPLE_NotSupported, "Cannot read features when writing a GML file"); return NULL; } if( poDS->GetLastReadLayer() != this ) { if( poDS->GetReadMode() != INTERLEAVED_LAYERS ) ResetReading(); poDS->SetLastReadLayer(this); }/* ==================================================================== *//* Loop till we find and translate a feature meeting all our *//* requirements. *//* ==================================================================== */ while( true ) { GMLFeature *poGMLFeature = NULL; OGRGeometry *poGeom = NULL; poGMLFeature = poDS->PeekStoredGMLFeature(); if (poGMLFeature != NULL) poDS->SetStoredGMLFeature(NULL); else { poGMLFeature = poDS->GetReader()->NextFeature(); if( poGMLFeature == NULL ) return NULL; // We count reading low level GML features as a feature read for // work checking purposes, though at least we didn't necessary // have to turn it into an OGRFeature. m_nFeaturesRead++; }/* -------------------------------------------------------------------- *//* Is it of the proper feature class? *//* -------------------------------------------------------------------- */ if( poGMLFeature->GetClass() != poFClass ) { if( poDS->GetReadMode() == INTERLEAVED_LAYERS || (poDS->GetReadMode() == SEQUENTIAL_LAYERS && iNextGMLId != 0) ) { CPLAssert(poDS->PeekStoredGMLFeature() == NULL); poDS->SetStoredGMLFeature(poGMLFeature); return NULL; } else { delete poGMLFeature; continue; } }/* -------------------------------------------------------------------- *//* Extract the fid: *//* -Assumes the fids are non-negative integers with an optional *//* prefix *//* -If a prefix differs from the prefix of the first feature from *//* the poDS then the fids from the poDS are ignored and are *//* assigned serially thereafter *//* -------------------------------------------------------------------- */ GIntBig nFID = -1; const char * pszGML_FID = poGMLFeature->GetFID(); if( bInvalidFIDFound ) { nFID = iNextGMLId++; } else if( pszGML_FID == NULL ) { bInvalidFIDFound = true; nFID = iNextGMLId++; } else if( iNextGMLId == 0 ) { int j = 0; int i = static_cast<int>(strlen( pszGML_FID ))-1; while( i >= 0 && pszGML_FID[i] >= '0' && pszGML_FID[i] <= '9' && j<20) i--, j++; /* i points the last character of the fid */ if( i >= 0 && j < 20 && pszFIDPrefix == NULL) { pszFIDPrefix = (char *) CPLMalloc(i+2); pszFIDPrefix[i+1] = '/0'; strncpy(pszFIDPrefix, pszGML_FID, i+1); } /* pszFIDPrefix now contains the prefix or NULL if no prefix is found */ if( j < 20 && sscanf(pszGML_FID+i+1, CPL_FRMT_GIB, &nFID)==1) { if( iNextGMLId <= nFID ) iNextGMLId = nFID + 1; }//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例19: sizeofbool OGRPGeoDriver::FindDriverLib(){ // Default name and path of driver library const char* aszDefaultLibName[] = { "libmdbodbc.so", "libmdbodbc.so.0" /* for Ubuntu 8.04 support */ }; const int nLibNames = sizeof(aszDefaultLibName) / sizeof(aszDefaultLibName[0]); const char* libPath[] = { "/usr/lib", "/usr/local/lib" }; const int nLibPaths = sizeof(libPath) / sizeof(libPath[0]); CPLString strLibPath(""); const char* pszDrvCfg = CPLGetConfigOption("MDBDRIVER_PATH", NULL); if ( NULL != pszDrvCfg ) { // Directory or file path strLibPath = pszDrvCfg; VSIStatBuf sStatBuf = { 0 }; if ( VSIStat( pszDrvCfg, &sStatBuf ) == 0 && VSI_ISDIR( sStatBuf.st_mode ) ) { // Find default library in custom directory const char* pszDriverFile = CPLFormFilename( pszDrvCfg, aszDefaultLibName[0], NULL ); CPLAssert( 0 != pszDriverFile ); strLibPath = pszDriverFile; } if ( LibraryExists( strLibPath.c_str() ) ) { // Save custom driver path osDriverFile = strLibPath; return true; } } // Try to find library in default path for ( int i = 0; i < nLibPaths; i++ ) { for ( int j = 0; j < nLibNames; j++ ) { const char* pszDriverFile = CPLFormFilename( libPath[i], aszDefaultLibName[j], NULL ); CPLAssert( 0 != pszDriverFile ); if ( LibraryExists( pszDriverFile ) ) { // Save default driver path osDriverFile = pszDriverFile; return true; } } } CPLError(CE_Failure, CPLE_AppDefined, "PGeo: MDB Tools driver not found!/n"); // Driver not found! return false;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:62,
示例20: CPLGetXMLValueint GDALMultiDomainMetadata::XMLInit( CPLXMLNode *psTree, int /* bMerge */ ){ CPLXMLNode *psMetadata = nullptr;/* ==================================================================== *//* Process all <Metadata> elements, each for one domain. *//* ==================================================================== */ for( psMetadata = psTree->psChild; psMetadata != nullptr; psMetadata = psMetadata->psNext ) { if( psMetadata->eType != CXT_Element || !EQUAL(psMetadata->pszValue,"Metadata") ) continue; const char *pszDomain = CPLGetXMLValue( psMetadata, "domain", "" ); const char *pszFormat = CPLGetXMLValue( psMetadata, "format", "" ); // Make sure we have a CPLStringList for this domain, // without wiping out an existing one. if( GetMetadata( pszDomain ) == nullptr ) SetMetadata( nullptr, pszDomain ); const int iDomain = CSLFindString( papszDomainList, pszDomain ); CPLAssert( iDomain != -1 ); CPLStringList *poMDList = papoMetadataLists[iDomain];/* -------------------------------------------------------------------- *//* XML format subdocuments. *//* -------------------------------------------------------------------- */ if( EQUAL(pszFormat,"xml") ) { // Find first non-attribute child of current element. CPLXMLNode *psSubDoc = psMetadata->psChild; while( psSubDoc != nullptr && psSubDoc->eType == CXT_Attribute ) psSubDoc = psSubDoc->psNext; char *pszDoc = CPLSerializeXMLTree( psSubDoc ); poMDList->Clear(); poMDList->AddStringDirectly( pszDoc ); }/* -------------------------------------------------------------------- *//* Name value format. *//* <MDI key="...">value_Text</MDI> *//* -------------------------------------------------------------------- */ else { for( CPLXMLNode *psMDI = psMetadata->psChild; psMDI != nullptr; psMDI = psMDI->psNext ) { if( !EQUAL(psMDI->pszValue,"MDI") || psMDI->eType != CXT_Element || psMDI->psChild == nullptr || psMDI->psChild->psNext == nullptr || psMDI->psChild->eType != CXT_Attribute || psMDI->psChild->psChild == nullptr ) continue; char* pszName = psMDI->psChild->psChild->pszValue; char* pszValue = psMDI->psChild->psNext->pszValue; if( pszName != nullptr && pszValue != nullptr ) poMDList->SetNameValue( pszName, pszValue ); } } } return CSLCount(papszDomainList) != 0;}
开发者ID:OSGeo,项目名称:gdal,代码行数:72,
示例21: OGRGMEGeometryToGeoJSONjson_object* OGRGMEGeometryToGeoJSON(OGRGeometry* poGeometry){ if ( NULL == poGeometry ) return NULL; json_object* pjoGeometry = json_object_new_object(); CPLAssert( NULL != pjoGeometry ); /* -------------------------------------------------------------------- */ /* Build "type" member of GeoJSOn "geometry" object */ /* and "coordinates" member of GeoJSOn "geometry" object. */ /* -------------------------------------------------------------------- */ const char* pszType = NULL; OGRwkbGeometryType eType = poGeometry->getGeometryType(); json_object* pjoCoordinates = NULL; if( wkbGeometryCollection == eType || wkbGeometryCollection25D == eType ) { pszType = "GeometryCollection"; json_object *pjoGeometries = OGRGMEGeometryCollectionToGeoJSON(static_cast<OGRGeometryCollection*>(poGeometry)); if ( pjoGeometries ) { json_object *pjoType = json_object_new_string(pszType); json_object_object_add( pjoGeometry, "type", pjoType ); json_object_object_add( pjoGeometry, "geometries", pjoGeometries ); } else { json_object_put(pjoGeometry); pjoGeometry = NULL; } } else { if( wkbPoint == eType || wkbPoint25D == eType ) { pszType = "Point"; pjoCoordinates = OGRGMEPointToGeoJSON( static_cast<OGRPoint*>(poGeometry) ); } if( wkbMultiPoint == eType || wkbMultiPoint25D == eType ) { pszType = "MultiPoint"; pjoCoordinates = OGRGMEMultiPointToGeoJSON( static_cast<OGRMultiPoint*>(poGeometry) ); } else if( wkbLineString == eType || wkbLineString25D == eType ) { pszType = "LineString"; pjoCoordinates = OGRGMELineStringToGeoJSON( static_cast<OGRLineString*>(poGeometry) ); } else if( wkbMultiLineString == eType || wkbMultiLineString25D == eType ) { pszType = "MultiLineString"; pjoCoordinates = OGRGMEMultiLineStringToGeoJSON( static_cast<OGRMultiLineString*>(poGeometry) ); } else if( wkbPolygon == eType || wkbPolygon25D == eType ) { pszType = "Polygon"; pjoCoordinates = OGRGMEPolygonToGeoJSON( static_cast<OGRPolygon*>(poGeometry) ); } else if( wkbMultiPolygon == eType || wkbMultiPolygon25D == eType ) { pszType = "MultiPolygon"; pjoCoordinates = OGRGMEMultiPolygonToGeoJSON( static_cast<OGRMultiPolygon*>(poGeometry) ); } else { CPLDebug( "GME", "Unsupported geometry type detected. Geometry is IGNORED." ); } if ( pjoCoordinates && pszType ) { json_object *pjoType = json_object_new_string(pszType); json_object_object_add( pjoGeometry, "type", pjoType ); json_object_object_add( pjoGeometry, "coordinates", pjoCoordinates); } else { json_object_put(pjoGeometry); pjoGeometry = NULL; } } return pjoGeometry;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:73,
示例22: CPLAssertint SDTSRasterReader::GetBlock( CPL_UNUSED int nXOffset, int nYOffset, void * pData ){ CPLAssert( nXOffset == 0 );/* -------------------------------------------------------------------- *//* Analyse the datatype. *//* -------------------------------------------------------------------- */ CPLAssert( EQUAL(szFMT,"BI16") || EQUAL(szFMT,"BFP32") ); int nBytesPerValue; if( EQUAL(szFMT,"BI16") ) nBytesPerValue = 2; else nBytesPerValue = 4; DDFRecord *poRecord = NULL; for( int iTry = 0; iTry < 2; iTry++ ) { /* -------------------------------------------------------------------- */ /* Read through till we find the desired record. */ /* -------------------------------------------------------------------- */ CPLErrorReset(); while( (poRecord = oDDFModule.ReadRecord()) != NULL ) { if( poRecord->GetIntSubfield( "CELL", 0, "ROWI", 0 ) == nYOffset + nYStart ) { break; } } if( CPLGetLastErrorType() == CE_Failure ) return FALSE; /* -------------------------------------------------------------------- */ /* If we didn't get what we needed just start over. */ /* -------------------------------------------------------------------- */ if( poRecord == NULL ) { if (iTry == 0) oDDFModule.Rewind(); else { CPLError( CE_Failure, CPLE_AppDefined, "Cannot read scanline %d. Raster access failed./n", nYOffset ); return FALSE; } } else { break; } }/* -------------------------------------------------------------------- *//* Validate the records size. Does it represent exactly one *//* scanline? *//* -------------------------------------------------------------------- */ DDFField *poCVLS = poRecord->FindField( "CVLS" ); if( poCVLS == NULL ) return FALSE; if( poCVLS->GetRepeatCount() != nXSize ) { CPLError( CE_Failure, CPLE_AppDefined, "Cell record is %d long, but we expected %d, the number/n" "of pixels in a scanline. Raster access failed./n", poCVLS->GetRepeatCount(), nXSize ); return FALSE; }/* -------------------------------------------------------------------- *//* Does the CVLS field consist of exactly 1 B(16) field? *//* -------------------------------------------------------------------- */ if( poCVLS->GetDataSize() < nBytesPerValue * nXSize || poCVLS->GetDataSize() > nBytesPerValue * nXSize + 1 ) { CPLError( CE_Failure, CPLE_AppDefined, "Cell record is not of expected format. Raster access " "failed./n" ); return FALSE; }/* -------------------------------------------------------------------- *//* Copy the data to the application buffer, and byte swap if *//* required. *//* -------------------------------------------------------------------- */ memcpy( pData, poCVLS->GetData(), nXSize * nBytesPerValue );#ifdef CPL_LSB if( nBytesPerValue == 2 ) { for( int i = 0; i < nXSize; i++ ) { reinterpret_cast<GInt16 *>( pData )[i] = CPL_MSBWORD16(//.........这里部分代码省略.........
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,
示例23: swq_expr_node//.........这里部分代码省略......... break; case SWQ_SUBTRACT: poRet->float_value = sub_node_values[0]->float_value - sub_node_values[1]->float_value; break; case SWQ_MULTIPLY: poRet->float_value = sub_node_values[0]->float_value * sub_node_values[1]->float_value; break; case SWQ_DIVIDE: if( sub_node_values[1]->float_value == 0 ) poRet->float_value = INT_MAX; else poRet->float_value = sub_node_values[0]->float_value / sub_node_values[1]->float_value; break; case SWQ_MODULUS: { GIntBig nRight = (GIntBig) sub_node_values[1]->float_value; poRet->field_type = SWQ_INTEGER; if (nRight == 0) poRet->int_value = INT_MAX; else poRet->int_value = ((GIntBig) sub_node_values[0]->float_value) % nRight; break; } default: CPLAssert( FALSE ); delete poRet; poRet = NULL; break; } }/* -------------------------------------------------------------------- *//* integer/boolean operations. *//* -------------------------------------------------------------------- */ else if( SWQ_IS_INTEGER(sub_node_values[0]->field_type) || sub_node_values[0]->field_type == SWQ_BOOLEAN ) { poRet = new swq_expr_node(0); poRet->field_type = node->field_type; if( node->nOperation != SWQ_ISNULL ) { for( int i = 0; i < node->nSubExprCount; i++ ) { if( sub_node_values[i]->is_null ) { if( poRet->field_type == SWQ_BOOLEAN ) { poRet->int_value = FALSE; return poRet; } else if( SWQ_IS_INTEGER(poRet->field_type) ) { poRet->int_value = 0; poRet->is_null = 1; return poRet; } }
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:67,
注:本文中的CPLAssert函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLAtof函数代码示例 C++ CPACC_FULL函数代码示例 |