ogr/ogr_fromepsg.cpp
static int 
EPSGGetUOMLengthInfo( int nUOMLengthCode,
                      char **ppszUOMName,
                      double * pdfInMeters )

{
    char        **papszUnitsRecord;
    char        szSearchKey[24];
    int         iNameField;

#define UOM_FILENAME CSVFilename( "unit_of_measure.csv" )

/* -------------------------------------------------------------------- */
/*      We short cut meter to save work in the most common case.        */
/* -------------------------------------------------------------------- */
    if( nUOMLengthCode == 9001 )
    {
        if( ppszUOMName != NULL )
            *ppszUOMName = CPLStrdup( "metre" );
        if( pdfInMeters != NULL )
            *pdfInMeters = 1.0;

        return TRUE;
    }

/* -------------------------------------------------------------------- */
/*      Search the units database for this unit.  If we don't find      */
/*      it return failure.                                              */
/* -------------------------------------------------------------------- */
    sprintf( szSearchKey, "%d", nUOMLengthCode );
    papszUnitsRecord =
        CSVScanFileByName( UOM_FILENAME, "UOM_CODE", szSearchKey, CC_Integer );

    if( papszUnitsRecord == NULL )
        return FALSE;

/* -------------------------------------------------------------------- */
/*      Get the name, if requested.                                     */
/* -------------------------------------------------------------------- */
    if( ppszUOMName != NULL )
    {
        iNameField = CSVGetFileFieldId( UOM_FILENAME, "UNIT_OF_MEAS_NAME" );
        *ppszUOMName = CPLStrdup( CSLGetField(papszUnitsRecord, iNameField) );
    }
    
/* -------------------------------------------------------------------- */
/*      Get the A and B factor fields, and create the multiplicative    */
/*      factor.                                                         */
/* -------------------------------------------------------------------- */
    if( pdfInMeters != NULL )
    {
        int     iBFactorField, iCFactorField;
        
        iBFactorField = CSVGetFileFieldId( UOM_FILENAME, "FACTOR_B" );
        iCFactorField = CSVGetFileFieldId( UOM_FILENAME, "FACTOR_C" );

        if( atof(CSLGetField(papszUnitsRecord, iCFactorField)) > 0.0 )
            *pdfInMeters = atof(CSLGetField(papszUnitsRecord, iBFactorField))
                / atof(CSLGetField(papszUnitsRecord, iCFactorField));
        else
            *pdfInMeters = 0.0;
    }
    
    return( TRUE );
}
/************************************************************************/
/*                        EPSGGetUOMLengthInfo()                        */
/*                                                                      */
/*      Note: This function should eventually also know how to          */
/*      lookup length aliases in the UOM_LE_ALIAS table.                */
/************************************************************************/
EPSGGetUOMLengthInfo()
Note: This function should eventually also know how to
lookup length aliases in the UOM_LE_ALIAS table.
EPSGGetUOMLengthInfo () Note : This function should eventually also know how to lookup length aliases in the UOM_LE_ALIAS table .
static int 
EPSGGetUOMLengthInfo( int nUOMLengthCode,
                      char **ppszUOMName,
                      double * pdfInMeters )
{
    char        **papszUnitsRecord;
    char        szSearchKey[24];
    int         iNameField;
#define UOM_FILENAME CSVFilename( "unit_of_measure.csv" )
    if( nUOMLengthCode == 9001 )
    {
        if( ppszUOMName != NULL )
            *ppszUOMName = CPLStrdup( "metre" );
        if( pdfInMeters != NULL )
            *pdfInMeters = 1.0;
        return TRUE;
    }
    sprintf( szSearchKey, "%d", nUOMLengthCode );
    papszUnitsRecord =
        CSVScanFileByName( UOM_FILENAME, "UOM_CODE", szSearchKey, CC_Integer );
    if( papszUnitsRecord == NULL )
        return FALSE;
    if( ppszUOMName != NULL )
    {
        iNameField = CSVGetFileFieldId( UOM_FILENAME, "UNIT_OF_MEAS_NAME" );
        *ppszUOMName = CPLStrdup( CSLGetField(papszUnitsRecord, iNameField) );
    }
    if( pdfInMeters != NULL )
    {
        int     iBFactorField, iCFactorField;
        iBFactorField = CSVGetFileFieldId( UOM_FILENAME, "FACTOR_B" );
        iCFactorField = CSVGetFileFieldId( UOM_FILENAME, "FACTOR_C" );
        if( atof(CSLGetField(papszUnitsRecord, iCFactorField)) > 0.0 )
            *pdfInMeters = atof(CSLGetField(papszUnitsRecord, iBFactorField))
                / atof(CSLGetField(papszUnitsRecord, iCFactorField));
        else
            *pdfInMeters = 0.0;
    }
    return( TRUE );
}
static int EPSGGetUOMLengthInfo ( int nUOMLengthCode , char * * ppszUOMName , double * pdfInMeters ) { char * * papszUnitsRecord ; char szSearchKey [ 24 ] ; int iNameField ; #define UOM_FILENAME  CSVFilename( "unit_of_measure.csv" ) if ( nUOMLengthCode == 9001 ) { if ( ppszUOMName != NULL ) * ppszUOMName = CPLStrdup ( " " ) ; if ( pdfInMeters != NULL ) * pdfInMeters = 1.0 ; return TRUE ; } sprintf ( szSearchKey , " " , nUOMLengthCode ) ; papszUnitsRecord = CSVScanFileByName ( UOM_FILENAME , " " , szSearchKey , CC_Integer ) ; if ( papszUnitsRecord == NULL ) return FALSE ; if ( ppszUOMName != NULL ) { iNameField = CSVGetFileFieldId ( UOM_FILENAME , " " ) ; * ppszUOMName = CPLStrdup ( CSLGetField ( papszUnitsRecord , iNameField ) ) ; } if ( pdfInMeters != NULL ) { int iBFactorField , iCFactorField ; iBFactorField = CSVGetFileFieldId ( UOM_FILENAME , " " ) ; iCFactorField = CSVGetFileFieldId ( UOM_FILENAME , " " ) ; if ( atof ( CSLGetField ( papszUnitsRecord , iCFactorField ) ) > 0.0 ) * pdfInMeters = atof ( CSLGetField ( papszUnitsRecord , iBFactorField ) ) / atof ( CSLGetField ( papszUnitsRecord , iCFactorField ) ) ; else * pdfInMeters = 0.0 ; } return ( TRUE ) ; }
EPSGGetUOMLengthInfo()
Note: This function should eventually also know how to
lookup length aliases in the UOM_LE_ALIAS table.
EPSGGetUOMLengthInfo () Note : This function should eventually also know how to lookup length aliases in the UOM_LE_ALIAS table .
/* -------------------------------------------------------------------- */ /*      We short cut meter to save work in the most common case.        */ /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ /*      Search the units database for this unit.  If we don't find      */ /*      it return failure.                                              */ /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ /*      Get the name, if requested.                                     */ /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ /*      Get the A and B factor fields, and create the multiplicative    */ /*      factor.                                                         */ /* -------------------------------------------------------------------- */