📄 ogrdodssequencelayer.cpp
字号:
break; case dods_uint16_c: { GUInt16 nIntVal; void *pValPtr = &nIntVal; poFieldVar->buf2val( &pValPtr ); panIntList[iSubIndex] = nIntVal; } break; case dods_int32_c: { GInt32 nIntVal; void *pValPtr = &nIntVal; poFieldVar->buf2val( &pValPtr ); panIntList[iSubIndex] = nIntVal; } break; case dods_uint32_c: { GUInt32 nIntVal; void *pValPtr = &nIntVal; poFieldVar->buf2val( &pValPtr ); panIntList[iSubIndex] = nIntVal; } break; case dods_float32_c: padfDblList[iSubIndex] = dynamic_cast<Float32 *>(poFieldVar)->value(); break; case dods_float64_c: padfDblList[iSubIndex] = dynamic_cast<Float64 *>(poFieldVar)->value(); break; case dods_str_c: case dods_url_c: { string *poStrVal = NULL; poFieldVar->buf2val( (void **) &poStrVal ); papszStrList[iSubIndex] = CPLStrdup( poStrVal->c_str() ); delete poStrVal; } break; default: break; } }/* -------------------------------------------------------------------- *//* Apply back to feature. *//* -------------------------------------------------------------------- */ if( poOFD->GetType() == OFTIntegerList ) { poFeature->SetField( iField, nSubSeqCount, panIntList ); CPLFree(panIntList); } else if( poOFD->GetType() == OFTRealList ) { poFeature->SetField( iField, nSubSeqCount, padfDblList ); CPLFree(padfDblList); } else if( poOFD->GetType() == OFTStringList ) { poFeature->SetField( iField, papszStrList ); CSLDestroy( papszStrList ); } } /* ==================================================================== *//* Fetch the geometry. *//* ==================================================================== */ if( oXField.bValid && oYField.bValid ) { int iXField = poFeature->GetFieldIndex( oXField.pszFieldName ); int iYField = poFeature->GetFieldIndex( oYField.pszFieldName ); int iZField = -1; if( oZField.bValid ) iZField = poFeature->GetFieldIndex(oZField.pszFieldName);/* -------------------------------------------------------------------- *//* If we can't find the values in attributes then use the more *//* general mechanism to fetch the value. *//* -------------------------------------------------------------------- */ if( iXField == -1 || iYField == -1 || (oZField.bValid && iZField == -1) ) { poFeature->SetGeometryDirectly( new OGRPoint( GetFieldValueAsDouble( &oXField, iSubSeq ), GetFieldValueAsDouble( &oYField, iSubSeq ), GetFieldValueAsDouble( &oZField, iSubSeq ) ) ); }/* -------------------------------------------------------------------- *//* If the fields are list values, then build a linestring. *//* -------------------------------------------------------------------- */ else if( poFeature->GetFieldDefnRef(iXField)->GetType() == OFTRealList && poFeature->GetFieldDefnRef(iYField)->GetType() == OFTRealList ) { const double *padfX, *padfY, *padfZ = NULL; int nPointCount, i; OGRLineString *poLS = new OGRLineString(); padfX = poFeature->GetFieldAsDoubleList( iXField, &nPointCount ); padfY = poFeature->GetFieldAsDoubleList( iYField, &nPointCount ); if( iZField != -1 ) padfZ = poFeature->GetFieldAsDoubleList(iZField,&nPointCount); poLS->setPoints( nPointCount, (double *) padfX, (double *) padfY, (double *) padfZ ); // Make a pass clearing out NaN or Inf values. for( i = 0; i < nPointCount; i++ ) { double dfX = poLS->getX(i); double dfY = poLS->getY(i); double dfZ = poLS->getZ(i); int bReset = FALSE; if( OGRDODSIsDoubleInvalid( &dfX ) ) { dfX = 0.0; bReset = TRUE; } if( OGRDODSIsDoubleInvalid( &dfY ) ) { dfY = 0.0; bReset = TRUE; } if( OGRDODSIsDoubleInvalid( &dfZ ) ) { dfZ = 0.0; bReset = TRUE; } if( bReset ) poLS->setPoint( i, dfX, dfY, dfZ ); } poFeature->SetGeometryDirectly( poLS ); }/* -------------------------------------------------------------------- *//* Otherwise build a point. *//* -------------------------------------------------------------------- */ else { poFeature->SetGeometryDirectly( new OGRPoint( poFeature->GetFieldAsDouble( iXField ), poFeature->GetFieldAsDouble( iYField ), poFeature->GetFieldAsDouble( iZField ) ) ); } } return poFeature;}/************************************************************************//* GetFeatureCount() *//************************************************************************/int OGRDODSSequenceLayer::GetFeatureCount( int bForce ){ if( !bDataLoaded && !bForce ) return -1; ProvideDataDDS(); return nRecordCount;}/************************************************************************//* ProvideDataDDS() *//************************************************************************/int OGRDODSSequenceLayer::ProvideDataDDS(){ if( bDataLoaded ) return poTargetVar != NULL; int bResult = OGRDODSLayer::ProvideDataDDS(); if( !bResult ) return bResult; // If we are in nested sequence mode, we now need to properly set // the poTargetVar based on the current step in the supersequence. poSuperSeq = FindSuperSequence( poTargetVar );/* ==================================================================== *//* Figure out the record count. *//* ==================================================================== *//* -------------------------------------------------------------------- *//* For simple sequences without a supersequence just return the *//* count of elements. *//* -------------------------------------------------------------------- */ if( poSuperSeq == NULL ) nRecordCount = dynamic_cast<Sequence *>(poTargetVar)->number_of_rows();/* -------------------------------------------------------------------- *//* Otherwise we have to count up all the target sequence *//* instances for each of the super sequence items. *//* -------------------------------------------------------------------- */ else { int iSuper; nSuperSeqCount = poSuperSeq->number_of_rows(); panSubSeqSize = (int *) calloc(sizeof(int),nSuperSeqCount); nRecordCount = 0; for( iSuper = 0; iSuper < nSuperSeqCount; iSuper++ ) { Sequence *poSubSeq = dynamic_cast<Sequence *>( poSuperSeq->var_value( iSuper, pszSubSeqPath ) ); panSubSeqSize[iSuper] = poSubSeq->number_of_rows(); nRecordCount += poSubSeq->number_of_rows(); } } return poTargetVar != NULL;}/* IEEE Constants: http://www.psc.edu/general/software/packages/ieee/ieee.htmlSingle Precision: S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF 0 1 8 9 31The value V represented by the word may be determined as follows: * If E=255 and F is nonzero, then V=NaN ("Not a number") * If E=255 and F is zero and S is 1, then V=-Infinity * If E=255 and F is zero and S is 0, then V=Infinity * If 0<E<255 then V=(-1)**S * 2 ** (E-127) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. * If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-126) * (0.F) These are "unnormalized" values. * If E=0 and F is zero and S is 1, then V=-0 * If E=0 and F is zero and S is 0, then V=0 In particular, 0 00000000 00000000000000000000000 = 0 1 00000000 00000000000000000000000 = -0 0 11111111 00000000000000000000000 = Infinity 1 11111111 00000000000000000000000 = -Infinity 0 11111111 00000100000000000000000 = NaN 1 11111111 00100010001001010101010 = NaN 0 10000000 00000000000000000000000 = +1 * 2**(128-127) * 1.0 = 2 0 10000001 10100000000000000000000 = +1 * 2**(129-127) * 1.101 = 6.5 1 10000001 10100000000000000000000 = -1 * 2**(129-127) * 1.101 = -6.5 0 00000001 00000000000000000000000 = +1 * 2**(1-127) * 1.0 = 2**(-126) 0 00000000 10000000000000000000000 = +1 * 2**(-126) * 0.1 = 2**(-127) 0 00000000 00000000000000000000001 = +1 * 2**(-126) * 0.00000000000000000000001 = 2**(-149) (Smallest positive value)Double Precision:The IEEE double precision floating point standard representation requires a 64 bit word, which may be represented as numbered from 0 to 63, left to right. The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the final 52 bits are the fraction 'F': S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0 1 11 12 63The value V represented by the word may be determined as follows: * If E=2047 and F is nonzero, then V=NaN ("Not a number") * If E=2047 and F is zero and S is 1, then V=-Infinity * If E=2047 and F is zero and S is 0, then V=Infinity * If 0<E<2047 then V=(-1)**S * 2 ** (E-1023) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. * If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-1022) * (0.F) These are "unnormalized" values. * If E=0 and F is zero and S is 1, then V=-0 * If E=0 and F is zero and S is 0, then V=0 *//************************************************************************//* OGRDODSIsFloatInvalid() *//* *//* For now we are really just checking if the value is NaN, Inf *//* or -Inf. *//************************************************************************/int OGRDODSIsFloatInvalid( const float * pfValToCheck ){ const unsigned char *pabyValToCheck = (unsigned char *) pfValToCheck;#if CPL_IS_LSB == 0 if( (pabyValToCheck[0] & 0x7f) == 0x7f && (pabyValToCheck[1] & 0x80) == 0x80 ) return TRUE; else return FALSE;#else if( pabyValToCheck[3] & 0x7f == 0x7f && pabyValToCheck[2] & 0x80 == 0x80 ) return TRUE; else return FALSE;#endif}/************************************************************************//* OGRDODSIsDoubleInvalid() *//* *//* For now we are really just checking if the value is NaN, Inf *//* or -Inf. *//************************************************************************/int OGRDODSIsDoubleInvalid( const double * pdfValToCheck ){ const unsigned char *pabyValToCheck = (unsigned char *) pdfValToCheck;#if CPL_IS_LSB == 0 if( pabyValToCheck[0] & 0x7f == 0x7f && pabyValToCheck[1] & 0xf0 == 0xf0 ) return TRUE; else return FALSE;#else if( (pabyValToCheck[7] & 0x7f) == 0x7f && (pabyValToCheck[6] & 0xf0) == 0xf0 ) return TRUE; else return FALSE;#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -