⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmlfeatureclass.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{    if( m_bHaveExtents )    {        *pdfXMin = m_dfXMin;        *pdfXMax = m_dfXMax;        *pdfYMin = m_dfYMin;        *pdfYMax = m_dfYMax;    }    return m_bHaveExtents;}/************************************************************************//*                         InitializeFromXML()                          *//************************************************************************/int GMLFeatureClass::InitializeFromXML( CPLXMLNode *psRoot ){/* -------------------------------------------------------------------- *//*      Do some rudimentary checking that this is a well formed         *//*      node.                                                           *//* -------------------------------------------------------------------- */    if( psRoot == NULL         || psRoot->eType != CXT_Element         || !EQUAL(psRoot->pszValue,"GMLFeatureClass") )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "GMLFeatureClass::InitializeFromXML() called on %s node!",                  psRoot->pszValue );        return FALSE;    }    if( CPLGetXMLValue( psRoot, "Name", NULL ) == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "GMLFeatureClass has no <Name> element." );        return FALSE;    }/* -------------------------------------------------------------------- *//*      Collect base info.                                              *//* -------------------------------------------------------------------- */    CPLFree( m_pszName );    m_pszName = CPLStrdup( CPLGetXMLValue( psRoot, "Name", NULL ) );        SetElementName( CPLGetXMLValue( psRoot, "ElementPath", m_pszName ) );    const char *pszGPath = CPLGetXMLValue( psRoot, "GeometryElementPath", "" );        if( strlen( pszGPath ) > 0 )        SetGeometryElement( pszGPath );/* -------------------------------------------------------------------- *//*      Collect dataset specific info.                                  *//* -------------------------------------------------------------------- */    CPLXMLNode *psDSI = CPLGetXMLNode( psRoot, "DatasetSpecificInfo" );    if( psDSI != NULL )    {        const char *pszValue;        pszValue = CPLGetXMLValue( psDSI, "FeatureCount", NULL );        if( pszValue != NULL )            SetFeatureCount( atoi(pszValue) );        // Eventually we should support XML subtrees.        pszValue = CPLGetXMLValue( psDSI, "ExtraInfo", NULL );        if( pszValue != NULL )            SetExtraInfo( pszValue );        if( CPLGetXMLValue( psDSI, "ExtentXMin", NULL ) != NULL             && CPLGetXMLValue( psDSI, "ExtentXMax", NULL ) != NULL            && CPLGetXMLValue( psDSI, "ExtentYMin", NULL ) != NULL            && CPLGetXMLValue( psDSI, "ExtentYMax", NULL ) != NULL )        {            SetExtents( atof(CPLGetXMLValue( psDSI, "ExtentXMin", "0.0" )),                        atof(CPLGetXMLValue( psDSI, "ExtentXMax", "0.0" )),                        atof(CPLGetXMLValue( psDSI, "ExtentYMin", "0.0" )),                        atof(CPLGetXMLValue( psDSI, "ExtentYMax", "0.0" )) );        }    }    /* -------------------------------------------------------------------- *//*      Collect property definitions.                                   *//* -------------------------------------------------------------------- */    for( CPLXMLNode *psThis = psRoot->psChild;         psThis != NULL; psThis = psThis->psNext )    {        if( EQUAL(psThis->pszValue, "PropertyDefn") )        {            const char *pszName = CPLGetXMLValue( psThis, "Name", NULL );            const char *pszType = CPLGetXMLValue( psThis, "Type", "Untyped" );            GMLPropertyDefn *poPDefn;            if( pszName == NULL )            {                CPLError( CE_Failure, CPLE_AppDefined,                           "GMLFeatureClass %s has a PropertyDefn without a <Name>..",                          m_pszName );                return FALSE;            }            poPDefn = new GMLPropertyDefn(                 pszName, CPLGetXMLValue( psThis, "ElementPath", NULL ) );                        if( EQUAL(pszType,"Untyped") )                poPDefn->SetType( GMLPT_Untyped );            else if( EQUAL(pszType,"String") )                poPDefn->SetType( GMLPT_String );            else if( EQUAL(pszType,"Integer") )                poPDefn->SetType( GMLPT_Integer );            else if( EQUAL(pszType,"Real") )                poPDefn->SetType( GMLPT_Real );            else if( EQUAL(pszType,"Complex") )                poPDefn->SetType( GMLPT_Complex );            else            {                CPLError( CE_Failure, CPLE_AppDefined,                           "Unrecognised property type %s.",                           pszType );                return FALSE;            }            AddProperty( poPDefn );        }    }    return TRUE;}/************************************************************************//*                           SerializeToXML()                           *//************************************************************************/CPLXMLNode *GMLFeatureClass::SerializeToXML(){    CPLXMLNode  *psRoot;    int         iProperty;/* -------------------------------------------------------------------- *//*      Set feature class and core information.                         *//* -------------------------------------------------------------------- */    psRoot = CPLCreateXMLNode( NULL, CXT_Element, "GMLFeatureClass" );    CPLCreateXMLElementAndValue( psRoot, "Name", GetName() );    CPLCreateXMLElementAndValue( psRoot, "ElementPath", GetElementName() );    if( GetGeometryElement() != NULL && strlen(GetGeometryElement()) > 0 )        CPLCreateXMLElementAndValue( psRoot, "GeometryElementPath",                                      GetGeometryElement() );/* -------------------------------------------------------------------- *//*      Write out dataset specific information.                         *//* -------------------------------------------------------------------- */    CPLXMLNode *psDSI;    if( m_bHaveExtents || m_nFeatureCount != -1 || m_pszExtraInfo != NULL )    {        psDSI = CPLCreateXMLNode( psRoot, CXT_Element, "DatasetSpecificInfo" );        if( m_nFeatureCount != -1 )        {            char szValue[128];            sprintf( szValue, "%d", m_nFeatureCount );            CPLCreateXMLElementAndValue( psDSI, "FeatureCount", szValue );        }        if( m_bHaveExtents )        {            char szValue[128];            sprintf( szValue, "%.5f", m_dfXMin );            CPLCreateXMLElementAndValue( psDSI, "ExtentXMin", szValue );            sprintf( szValue, "%.5f", m_dfXMax );            CPLCreateXMLElementAndValue( psDSI, "ExtentXMax", szValue );            sprintf( szValue, "%.5f", m_dfYMin );            CPLCreateXMLElementAndValue( psDSI, "ExtentYMin", szValue );            sprintf( szValue, "%.5f", m_dfYMax );            CPLCreateXMLElementAndValue( psDSI, "ExtentYMax", szValue );        }        if( m_pszExtraInfo )            CPLCreateXMLElementAndValue( psDSI, "ExtraInfo", m_pszExtraInfo );    }    /* -------------------------------------------------------------------- *//*      emit property information.                                      *//* -------------------------------------------------------------------- */    for( iProperty = 0; iProperty < GetPropertyCount(); iProperty++ )    {        GMLPropertyDefn *poPDefn = GetProperty( iProperty );        CPLXMLNode *psPDefnNode;        const char *pszTypeName;        psPDefnNode = CPLCreateXMLNode( psRoot, CXT_Element, "PropertyDefn" );        CPLCreateXMLElementAndValue( psPDefnNode, "Name",                                      poPDefn->GetName() );        CPLCreateXMLElementAndValue( psPDefnNode, "ElementPath",                                      poPDefn->GetSrcElement() );        switch( poPDefn->GetType() )        {          case GMLPT_Untyped:            pszTypeName = "Untyped";            break;                      case GMLPT_String:            pszTypeName = "String";            break;                      case GMLPT_Integer:            pszTypeName = "Integer";            break;                      case GMLPT_Real:            pszTypeName = "Real";            break;                      case GMLPT_Complex:            pszTypeName = "Complex";            break;        }        CPLCreateXMLElementAndValue( psPDefnNode, "Type", pszTypeName );    }    return psRoot;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -