FileGDB API for linux 学习系列之四,XML Schema of Geodatabase

从很早以前(至少从ArcGIS9.2包括9.2)ESRI的桌面产品就提供了将空间数据导成XML文件的功能,如下图,

image

可以选择只将数据库的schema的结构导出,也可以选择将数据也一并导出。到现在的FileGDB API继续沿用这一架构。在FileGDB API中提供了很多

操作Schema内容的函数,如:

操作Domain的函数:

                         CreateDomain(const std::string &domainDef) //创建域

                         AlterDomain(const std::string &domainDef) //改变域

                         DeleteDomain(const std::string &domainDef) //删除域

操作表的函数:

                          AddField(std::string &fieldDef) //添加字段

                          AlterField(std::string &fieldDef)//改变字段

                          DeleteField(std::string &fieldDef)//删除字段

操作子类的函数:

                          CreateSubtype(std::string  &subtypeDef) //创建子类

                          AlterSubtype(std::string &subtypeDef)//改变子类

                          DeleteSubtype(std::string &subtypeDef)//删除子类

等等,所有的牵扯到Schema中对象的定义,修改,删除等函数的参数,都是XML格式,当然这些XML格式并不能随便写,必须得按照ESRI的规范

进行书写,具体规范在FileGDB API的doc文件中的XML_Schema_of_Geodatabase-3.pdf中有详细的介绍。以下是常用的几种对象的定义规范:

1. 字段的定义

image 

以下是XML表示的Field例子:

<Field xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' 
xmlns:esri='http://www.esri.com/schemas/ArcGIS/10.1' xsi:type='esri:Field'>
  <Name>night
   
   Name>
  <Type>esriFieldTypeString
    
    Type>
  <IsNullable>true
     
     IsNullable>
  <Length>4
      
      Length>
  <Precision>0 
       Precision> <Scale>0 
        Scale> <AliasName>day 
         AliasName> <ModelName>night 
          ModelName> <DefaultValue xsi:type="xs:string">afternoon 
           DefaultValue>  
            Field>
其中Type元素定义了字段的类型,FileGDB API一共提供了13种数据类型,分别是

esriFieldTypeSmallInteger
esriFieldTypeInteger
esriFieldTypeSingle
esriFieldTypeDouble
esriFieldTypeString
esriFieldTypeDate
esriFieldTypeOID
esriFieldTypeGeometry
esriFieldTypeBlob
esriFieldTypeRaster
esriFieldTypeGUID
esriFieldTypeGlobalID
esriFieldTypeXML

2. 表的定义
image 
XML例子如下:

   
   xml version="1.0" encoding="UTF-8"?>
<esri:DataElement xmlns:esri='http://www.esri.com/schemas/ArcGIS/10.1' 
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xsi:type='esri:DETable'>
  <CatalogPath>/StreetInfo
   
   CatalogPath>
  <Name>StreetInfo
    
    Name>
  <MetadataRetrieved>true
     
     MetadataRetrieved>
  <Metadata xsi:type='esri:XmlPropertySet'>
    <XmlDoc>
      <?xml version="1.0"?>
      <metadata xml:lang="en"><Esri><CreaDate>20101215</CreaDate><CreaTime>13025800</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce></Esri></metadata>
    
      
      XmlDoc>
   
       Metadata> <DatasetType>esriDTTable 
        DatasetType> <Versioned>false 
         Versioned> <CanVersion>false 
          CanVersion> <ConfigurationKeyword> 
           ConfigurationKeyword> <HasOID>true 
            HasOID> <OIDFieldName>OBJECTID 
             OIDFieldName> <Fields xsi:type='esri:Fields'> <FieldArray xsi:type='esri:ArrayOfField'> <Field xsi:type='esri:Field'> <Name>OBJECTID 
              Name> <Type>esriFieldTypeOID 
               Type> <IsNullable>false 
                IsNullable> <Length>4 
                 Length> <Precision>0 
                  Precision> <Scale>0 
                   Scale> <Required>true 
                    Required> <Editable>false 
                     Editable> <DomainFixed>true 
                      DomainFixed> <AliasName>OBJECTID 
                       AliasName> <ModelName>OBJECTID 
                        ModelName>  
                         Field> <Field xsi:type='esri:Field'> <Name>Name 
                          Name> <Type>esriFieldTypeString 
                           Type> <IsNullable>true 
                            IsNullable> <Length>50 
                             Length> <Precision>0 
                              Precision> <Scale>0 
                               Scale> <AliasName>Name 
                                AliasName> <ModelName>Name 
                                 ModelName> <DefaultValue xsi:type='xs:string'> 
                                  DefaultValue>  
                                   Field> <Field xsi:type='esri:Field'> <Name>StreetType 
                                    Name> <Type>esriFieldTypeInteger 
                                     Type> <IsNullable>true 
                                      IsNullable> <Length>4 
                                       Length> <Precision>0 
                                        Precision> <Scale>0 
                                         Scale> <AliasName>StreetType 
                                          AliasName> <ModelName>StreetType 
                                           ModelName> <DefaultValue xsi:type='xs:double'>1 
                                            DefaultValue>  
                                             Field> <Field xsi:type='esri:Field'> <Name>Width 
                                              Name> <Type>esriFieldTypeDouble 
                                               Type> <IsNullable>true 
                                                IsNullable> <Length>8 
                                                 Length> <Precision>0 
                                                  Precision> <Scale>0 
                                                   Scale> <AliasName>Width 
                                                    AliasName> <ModelName>Width 
                                                     ModelName> <DefaultValue xsi:type='xs:double'>25.0 
                                                      DefaultValue>  
                                                       Field> <Field xsi:type='esri:Field'> <Name>LastPaved 
                                                        Name> <Type>esriFieldTypeDate 
                                                         Type> <IsNullable>true 
                                                          IsNullable> <Length>8 
                                                           Length> <Precision>0 
                                                            Precision> <Scale>0 
                                                             Scale> <AliasName>LastPaved 
                                                              AliasName> <ModelName>LastPaved 
                                                               ModelName> <DefaultValue xsi:type='xs:dateTime'>2000-01-01T00:00:00 
                                                                DefaultValue>  
                                                                 Field>  
                                                                  FieldArray>  
                                                                   Fields> <Indexes xsi:type='esri:Indexes'> <IndexArray xsi:type='esri:ArrayOfIndex'> <Index xsi:type='esri:Index'> <Name>FDO_OBJECTID 
                                                                    Name> <IsUnique>true 
                                                                     IsUnique> <IsAscending>true 
                                                                      IsAscending> <Fields xsi:type='esri:Fields'> <FieldArray xsi:type='esri:ArrayOfField'> <Field xsi:type='esri:Field'> <Name>OBJECTID 
                                                                       Name> <Type>esriFieldTypeOID 
                                                                        Type> <IsNullable>false 
                                                                         IsNullable> <Length>4 
                                                                          Length> <Precision>0 
                                                                           Precision> <Scale>0 
                                                                            Scale> <Required>true 
                                                                             Required> <Editable>false 
                                                                              Editable> <DomainFixed>true 
                                                                               DomainFixed> <AliasName>OBJECTID 
                                                                                AliasName> <ModelName>OBJECTID 
                                                                                 ModelName>  
                                                                                  Field>  
                                                                                   FieldArray>  
                                                                                    Fields>  
                                                                                     Index>  
                                                                                      IndexArray>  
                                                                                       Indexes> <CLSID>{7A566981-C114-11D2-8A28-006097AFF44E} 
                                                                                        CLSID> <EXTCLSID> 
                                                                                         EXTCLSID> <RelationshipClassNames xsi:type='esri:Names'> 
                                                                                          RelationshipClassNames> <AliasName>TestTable 
                                                                                           AliasName> <ModelName> 
                                                                                            ModelName> <HasGlobalID>false 
                                                                                             HasGlobalID> <GlobalIDFieldName> 
                                                                                              GlobalIDFieldName> <RasterFieldName> 
                                                                                               RasterFieldName> <ExtensionProperties xsi:type='esri:PropertySet'> <PropertyArray xsi:type='esri:ArrayOfPropertySetProperty'> 
                                                                                                PropertyArray>  
                                                                                                 ExtensionProperties> <ControllerMemberships xsi:type='esri:ArrayOfControllerMembership'> 
                                                                                                  ControllerMemberships>  
                                                                                                   esri:DataElement>

3. 索引的定义

image

XML例子表示:

<esri:Index xsi:type='esri:Index' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:esri='http://www.esri.com/schemas/ArcGIS/10.1'>
  <Name>StreetTypeIdx
   
   Name>
  <IsUnique>false
    
    IsUnique>
  <IsAscending>true
     
     IsAscending>
  <Fields xsi:type='esri:Fields'>
    <FieldArray xsi:type='esri:ArrayOfField'>
      <Field xsi:type='esri:Field'>
        <Name>StreetType
      
      Name>
        <Type>esriFieldTypeSmallInteger 
       Type> <IsNullable>false 
        IsNullable> <Length>2 
         Length> <Precision>0 
          Precision> <Scale>0 
           Scale> <Required>true 
            Required> <Editable>false 
             Editable> <DomainFixed>true 
              DomainFixed> <AliasName>StreetType 
               AliasName> <ModelName>StreetType 
                ModelName>  
                 Field>  
                  FieldArray>  
                   Fields>  
                    esri:Index>

SubType的XML的结构图:

image

XML的例子:

<esri:Subtype xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs=http://www.w3.org/2001/XMLSchema 
xmlns:esri="http://www.esri.com/schemas/ArcGIS/10.1" xsi:type="esri:Subtype">
  <SubtypeName>subtype three
   
   SubtypeName>
  <SubtypeCode>99
    
    SubtypeCode>
  <FieldInfos xsi:type="esri:ArrayOfSubtypeFieldInfo">
    <SubtypeFieldInfo xsi:type="esri:SubtypeFieldInfo">
      <FieldName>percentComplete
     
     FieldName>
      <DomainName>sampleRangeDomain
      
      DomainName>
      <DefaultValue xsi:type="xs:double">56 
       DefaultValue>  
        SubtypeFieldInfo>  
         FieldInfos>  
          esri:Subtype>

先举着这些例子吧,居然别的类型,可以查看pdf文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值