here - osgeo download server

302
Feature Data Objects (FDO) Developer’s Guide March 2008

Upload: others

Post on 09-Feb-2022

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: here - OSGeo Download Server

Feature Data Objects (FDO)

Developerrsquos Guide

March 2008

copy 2008 Autodesk Inc All Rights Reserved Except as otherwise permitted by Autodesk Inc this publication or parts thereof may not bereproduced in any form by any method for any purpose Certain materials included in this publication are reprinted with the permission of the copyright holder TrademarksThe following are registered trademarks or trademarks of Autodesk Inc in the USA and other countries 3DEC (designlogo) 3December3Decembercom 3ds Max ADI Alias Alias (swirl designlogo) AliasStudio Alias|Wavefront (designlogo) ATC AUGI AutoCAD AutoCADLearning Assistance AutoCAD LT AutoCAD Simulator AutoCAD SQL Extension AutoCAD SQL Interface Autodesk Autodesk Envision AutodeskInsight Autodesk Intent Autodesk Inventor Autodesk Map Autodesk MapGuide Autodesk Streamline AutoLISP AutoSnap AutoSketchAutoTrack Backdraft Built with ObjectARX (logo) Burn Buzzsaw CAiCE Can You Imagine Character Studio Cinestream Civil 3D CleanerCleaner Central ClearScale Colour Warper Combustion Communication Specification Constructware Content Explorer CreategtwhatsgtNextgt(designlogo) Dancing Baby (image) DesignCenter Design Doctor Designers Toolkit DesignKids DesignProf DesignServer DesignStudioDesign|Studio (designlogo) Design Web Format DWF DWG DWG (logo) DWG Extreme DWG TrueConvert DWG TrueView DXF EcotectExposure Extending the Design Team FBX Filmbox FMDesktop Freewheel GDX Driver Gmax Green Building Studio Heads-up DesignHeidi HumanIK IDEA Server i-drop ImageModeler iMOUT Incinerator Inventor Inventor LT Kaydara Kaydara (designlogo) KynapseKynogon LandXplorer LocationLogic Lustre Matchmover Maya Mechanical Desktop MotionBuilder Movimento Mudbox NavisWorksObjectARX ObjectDBX Open Reality Opticore Opticore Opus PolarSnap PortfolioWall Powered with Autodesk Technology ProductstreamProjectPoint ProMaterials RasterDWG Reactor RealDWG Real-time Roto REALVIZ Recognize Render Queue RetimerReveal Revit ShowcaseShowMotion SketchBook SteeringWheels Stitcher StudioTools Topobase Toxik TrustedDWG ViewCube Visual Visual Construction VisualDrainage Visual Landscape Visual Survey Visual Toolbox Visual LISP Voice Reality Volo Vtour Wiretap and WiretapCentral The following are registered trademarks or trademarks of Autodesk Canada Co in the USA andor Canada and other countries BackburnerDiscreet Fire Flame Flint Frost Inferno Multi-Master Editing River Smoke Sparks Stone and Wire The following are registered trademarks or trademarks of Moldflow Corp in the USA andor other countries Moldflow MPA MPA (designlogo)Moldflow Plastics Advisers MPI MPI (designlogo) Moldflow Plastics Insight MPX MPX (designlogo) Moldflow Plastics XpertAll other brand names product names or trademarks belong to their respective holders DisclaimerTHIS PUBLICATION AND THE INFORMATION CONTAINED HEREIN IS MADE AVAILABLE BY AUTODESK INC AS IS AUTODESK INC DISCLAIMSALL WARRANTIES EITHER EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY ORFITNESS FOR A PARTICULAR PURPOSE REGARDING THESE MATERIALS

Published By Autodesk Inc111 Mclnnis ParkwaySan Rafael CA 94903 USA

Contents

Chapter 1 About This Guide 1Audience and Purpose 1How This Guide Is Organized 1Whatrsquos New 3

Chapter 2 Introduction 5What Is the FDO API 5

From the Perspective of the Client Application User 5From the Perspective of the Client Application Engineer 5

Getting Started 6FDO Architecture and Providers 7What Is a Provider 9Developing Applications 11

Chapter 3 FDO Concepts 13Data Concepts 13Operational Concepts 18

Chapter 4 Development Practices 21Memory Management 21Collections 23Exception Handling 23

iii

Exception Messages 24Managing FdoPtr Behaviors 25

Chapter 5 Establishing a Connection 27Connection Semantics 27Establishing a Connection 29

Chapter 6 FDO Capabilities 35FDO Capabilities 35

Introduction 35Provider Type 36Command 37Connection 43Expression 47Filter 74Geometry 77Raster 78Schema 79

Expressible as Boolean 82Not Expressible as a Boolean 83

Chapter 7 Schema Management 85Schema Package 85Schema Mappings 87Schema Overrides 88Working with Schemas 88FDOFeatureClass 90FDOClass 90Non-Feature Class Issues 91Modifying Models 94Schema Element States 94Rollback Mechanism 95FDO XML Format 95Creating and Editing a GML Schema File 101Schema Management Examples 111

Chapter 8 Data Maintenance 119Data Maintenance Operations 119

Inserting Values 119Updating Values 125Deleting Values 126

Related Class Topics 127

iv | Contents

Chapter 9 Performing Queries 129Creating a Query 129Query Example 130

Chapter 10 Long Transaction Processing 135What Is Long Transaction Processing 135Supported Interfaces 136

Chapter 11 Filter and Expression Languages 139Filters 139Expressions 140Filter and Expression Text 140Language Issues 141

Provider-Specific Constraints on Filter and Expression Text 141Filter Grammar 141Expression Grammar 143Filter and Expression Keywords 144Data Types 144

Identifier 144Parameter 144String 144Integer 145Double 145DateTime 145

Operators 146Special Character 147Geometry Value 147

Chapter 12 The Geometry API 151Introduction 151FGF and WKB 151FGF Binary Specification 152FGF Text 158Abstract and Concrete Classes 158Geometry Types 159Mapping Between Geometry and Geometric Types 160Spatial Context 161Specify Dimensionality When Creating Geometries Using String

Specifications 161Inserting Geometry Values 162

Chapter 13 FDO Cookbook 163Introduction 163

Contents | v

Recommendations 163Registry 163Connection 164Capabilities 168Data Store 171User Management 173Spatial Context 175Basic Schema Operations 178Insert Data 181Select Data 182Select Aggregate Data 183Delete Data 184Schema Overrides 184Xml SerializeDeserialize 194

C 1 9 4Geometry 196

Construction 196C Namespaces 197C Geometry Scaffolding Classes 197C Geometries Constructed using

IDirectPositionImpl 200C Geometries Constructed Using Geometry

Subcomponents 201C Aggregate Geometries 202C Geometries from Text Specifications 204

Deconstruction 204

Appendix A OSGeo FDO Provider for ArcSDE 211What Is FDO Provider for ArcSDE 211FDO Provider for ArcSDE Software Requirements 211

Installed Components 211External Dependencies 212

FDO Provider for ArcSDE Limitations 212ArcSDE Limitations 212

Relative to ArcObjects API and ArcGIS Server API 213Curved Segments 213

Locking and Versioning 213Table Creation 214Identity Row ID Column and Enable Row Locking 214Disable Row Locking and Enable Versioning 215

FDO Provider for ArcSDE Connection 216Data Type Mappings 217Creating a Feature Schema 218Logical to Physical Schema Mapping 223Physical to Logical Schema Mapping 223FDO Provider for ArcSDE Capabilities 227

vi | Contents

Appendix B OSGeo FDO Provider for MySQL 233What Is FDO Provider for MySQL 233Logical to Physical Schema Mapping 234Physical to Logical Schema Mapping 235FDO Provider for MySQL Capabilities 237

Appendix C OSGeo FDO Provider for ODBC 243What Is FDO Provider for ODBC 243Physical to Logical Schema Mappings 244FDO Provider for ODBC Capabilities 249

Appendix D OSGeo FDO Provider for SDF 255What Is FDO Provider for SDF 255FDO Provider for SDF Capabilities 256

Appendix E OSGeo FDO Provider for SHP 263What Is FDO Provider for SHP 263Creating SHP Files for the Logical to Physical Schema Mapping 264Creating SHP Files for the Physical to Logical Schema Mapping 265Logical to Physical Schema Mapping 267Physical to Logical Schema Mapping 267FDO Provider for SHP Capabilities 269

Appendix F OSGeo FDO Provider for SQL Server Spatial 275Logical to Physical Schema Mapping 275Physical to Logical Schema Mapping 276

Appendix G OSGeo FDO Provider for WFS 279What Is FDO Provider for WFS 279FDO Provider for WFS Capabilities 280

Appendix H OSGeo FDO Provider for WMS 285What Is FDO Provider for WMS 285FDO Provider for WMS Capabilities 286

Index 291

Contents | vii

viii

About This Guide

The FDO Developerrsquos Guide introduces the Feature Data Objects (FDO) application programminginterface (API) and explains how to use its customization and development features

NOTE For detailed information about installing the FDO SDK and getting started usingthe FDO API see The Essential FDO (FET_TheEssentialFDO)

Audience and PurposeThis guide is intended to be used by developers of FDO applications It introducesthe FDO API explains the role of a feature provider and provides detailedinformation and examples about how to code your application

How This Guide Is OrganizedThis guide consists of the following chapters and appendixes

Introduction provides an overview of the FDO API and the function of FDOfeature providers

FDO Concepts on page 13 describes the key data and operational conceptsupon which FDO is constructed

Development Practices on page 21 discusses the best practices to followwhen using FDO for application development

Establishing a Connection on page 27 describes how to establish aconnection to an FDO provider

1

1

Capabilities discusses the Capabilities API which is used to determine thecapabilities of a particular provider

Schema Management on page 85 describes how to create and work withschemas and presents the issues related to schema management

Data Maintenance on page 119 provides information about using the FDOAPI to maintain the data

Performing Queries on page 129 describes how to create and performqueries

Long Transaction Processing on page 135 discusses long transactions (LT)and how to implement LT processing in your application

Filter and Expression Languages on page 139 discusses the use of filterexpressions to specify to an FDO provider how to identify a subset of theobjects of an FDO data store

The Geometry API on page 151 discusses the various Geometry types andformats and describes how to work with the Geometry API to developFDO-based applications

OSGeo FDO Provider for ArcSDE on page 211 discusses development issuesthat apply when using FDO Provider for ESRIreg ArcSDEreg

OSGeo FDO Provider for MySQL on page 233 discusses development issuesthat apply when using FDO Provider for MySQL

OSGeo FDO Provider for ODBC on page 243 discusses development issuesthat apply when using FDO Provider for ODBC

OSGeo FDO Provider for SDF on page 255 discusses development issuesthat apply when using FDO Provider for SDF

OSGeo FDO Provider for SHP on page 263 discusses development issuesthat apply when using FDO Provider for SHP (Shape)

OSGeo FDO Provider for WFS on page 279 discusses development issuesthat apply when using FDO Provider for WFS

OSGeo FDO Provider for WMS on page 285 discusses development issuesthat apply when using FDO Provider for WMS

Expression Functions outlines the signatures and implementation detailsfor the enhanced expression functions

2 | Chapter 1 About This Guide

Whatrsquos NewThis section summarizes the changes and enhancements you will find in thisversion of FDO

Enhanced Set of Expression Functions

The enhanced set includes aggregate conversion date mathematical numericstring and geometry functions All functions are supported by all providerswith the exception of the Raster WFS and WMS providers

For more information and implementation details about the expressionfunction signatures the RDBMS-specific built-in support for some of thefunctions and the provider-specific support see the appendix ExpressionFunctions

Whatrsquos New | 3

4

Introduction

You can use the APIs in the FDO API to manipulate define and analyze geospatial information

This chapter introduces application development with the FDO API and explains the role ofa feature provider

What Is the FDO API

From the Perspective of the Client Application User

The FDO API is a set of APIs used for creating managing and examininginformation enabling Autodesk GIS products to seamlessly share spatial andnon-spatial information with minimal effort

FDO is intended to provide consistent access to feature data whether it comesfrom a CAD-based data source or from a relational data store that supports richclassification To achieve this FDO supports a model that can readily supportthe capabilities of each data source allowing consumer applications functionalityto be tailored to match that of the data source For example some data sourcesmay support spatial queries while others do not Also a flexible metadata modelis required in FDO allowing clients to adapt to the underlying feature schemaexposed by each data source

From the Perspective of the Client ApplicationEngineer

The FDO API provides a common general purpose abstraction layer for accessinggeospatial data from a variety of data sources The API is in part an interface

2

5

specification of the abstraction layer A provider such as OSGeo FDO Providerfor MySQL is an implementation of the interface for a specific type of datasource (for example for a MySQL relational database) The API supports thestandard data store manipulation operations such as querying updatingversioning locking and others It also supports analysis

The API includes an extensive set of methods that return information aboutthe capabilities of the underlying data source For example one methodindicates whether the data source supports the creation of multiple schemasand another indicates whether the data source supports schema modification

A core set of services for providers is also available in the API such as providerregistration schema management filter and expression construction andXML serialization and deserialization

The API uses an object-oriented model for the construction of feature schemaA feature is a class and its attributes including its geometry are a propertyof the class The instantiation of a feature class a Feature Data Object (FDO)can contain other FDOs

Getting StartedFor detailed information to help you install and get started using Feature DataObjects (FDO) see The Essential FDO It provides details about connecting toand configuring providers data store management (createdelete) user IDs(create grant permissions) and spatial context

6 | Chapter 2 Introduction

FDO Architecture and ProvidersThe following diagram shows the high-level overview architecture of the FDOAPI and included FDO providers

FDO Architecture and Providers | 7

FDO Architecture and Providers

FDO Packages

FDO is assembled in conceptual packages of similar functionality Thisconceptual packaging is reflected in the substructure of the FDO SDK ldquoincludesrdquofolder For more information about the structure see The Essential FDO

FDO commands provider-specific commands and connections and capabilitiesprovide access to native data stores through each different FDO providerSchema management (through XML) client services and filters and expressionsare provider-independent packages that tie into the FDO API Each of theseare explained in more detail in subsequent sections

8 | Chapter 2 Introduction

The FDO API consists of classes grouped within the following packages

Commands package Contains a collection of classes that provide thecommands allowing the application to select and update features definenew types of feature classes lock features and perform analysis on featuresEach Command object executes a specific type of command against theunderlying data store In addition FDO providers expose one or moreCommand objects

ConnectionsCapabilities Contains a collection of classes that establishand manage the connection to the underlying data store Connectionobjects implement the FdoIConnection interface Capabilities API providesthe code for retrieving the various FDO provider capability categories suchas connection or schema capabilities You can use this this API to determinethe capabilities of a particular provider

Filters and Expression package Contains a collection of classes that definefilters and expression in FDO which are used to identify a subset of objectsof an FDO data store

Client Services package Contains a collection of classes that define theclient services in FDO that for example enable support for dynamiccreation of connection objects given a provider name

Schema package and FDO XML Contains a collection of classes thatprovides a logical mechanism for specifying how to represent geospatialfeatures The FDO feature schema is based somewhat on a subset of theOpenGIS and ISO feature models FDO feature schemas can be written toan XML file The FdoFeatureSchema and FdoFeatureSchemaCollectionclasses support the FdoXmlSerializable interface

In addition FDO is integrated with the Geometry API which includes theclasses that support specific Autodesk applications and APIs including FDO

For more information about each of the FDO packages see FDO API ReferenceHelp and subsequent chapters in this guide

Provider API(s) complete the FDO API configuration Each provider has aseparate API reference Help

What Is a ProviderA provider is a specific implementation of the FDO API It is the softwarecomponent that provides access to data in a particular data store

What Is a Provider | 9

For this release the providers that are included are as follows

NOTE For more information see the Open Source Geospatial Foundation websiteat wwwOSGeoorg

OsGeo FDO Provider for ArcSDE Readwrite access to feature data in anESRI ArcSDE-based data store (that is with an underlying Oracle or SQLServer database) Supports describing schema and inserting selectingupdating and deleting feature data in existing schemas does not supportcreating or deleting schemas

OsGeo FDO Provider for MySQL Readwrite access to feature data in aMySQL-based data store Supports spatial data types and spatial queryoperations A custom API can gather information transmit exceptions listdata stores and create connection objects MySQL architecture supportsvarious storage engines characteristics and capabilities

OsGeo FDO Provider for ODBC Readwrite access to feature data in anODBC-based data store Supports XYZ feature objects and can define featureclasses for any relational database table with X Y and optionally Zcolumns does not support creating or deleting schema Object locationsare stored in separate properties in the object definition

OsGeo FDO Provider for SDF Read-write access to feature data in anSDF-based data store Autodeskrsquos geospatial file format SDF supportsmultiple featuresattributes provides high performance for large data setsand interoperability with other Autodesk products and spatial indexingThe SDF provider a valid alternative to database storage Note that thisrelease of the SDF provider supports version 30 of the SDF file format

OsGeo FDO Provider for SHP Readwrite access to existing spatial andattribute data in an ESRI SHP-based data store which consists of separateshape files for geometry index and attributes Each SHP and its associatedDBF file is treated as a feature class with a single geometry property Thisis a valid alternative to database storage but does not support locking

OsGeo FDO Provider for WFS Read-only access to feature data in an OGCWFS-based data store Supports clientserver environment and retrievesgeospatial data encoded in GML from one or more Web Feature Servicessites Clientserver communication is encoded in XML with the exceptionof feature geometries which are encoded in GML Note that there is nopublic API documentation for this provider all functionality is accessiblevia the base FDO API

10 | Chapter 2 Introduction

OsGeo FDO Provider for WMS Read-only access to feature data in an OGCWMS-based data store Web Map Service (WMS) produces maps of spatiallyreferenced data dynamically from geographic information which aregenerally rendered in PNG GIF or JPEG or as vector-based Scalable VectorGraphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats

FDO supports retrieval and update of spatial and non-spatial GIS feature datathrough a rich classification model that is based on OpenGIS and ISOstandards

An overview of the relationships between providers data sources data storesand schemas is presented in the FDO Architecture and Providers graphic

For more detailed information about the providers see the appropriateappendix in this document Data sources and data stores are discussed in theEstablishing a Connection on page 27 chapter Schema concepts are discussedin the Schema Management on page 85 chapter

Developing ApplicationsYou will need to perform several major tasks in using the FDO API to developa custom application Each of these tasks breaks down into a number of moredetailed coding issues

The major development tasks are

Working with the Build Environment

Establishing a Connection

Schema Management

Data Maintenance

Creating Queries

Using Custom Commands (Provider-Specific)

These tasks are explored in detail in the chapters that follow

Developing Applications | 11

12

FDO Concepts

Before you can work properly with the FDO API you need to have a good understanding ofits basic underlying concepts This chapter defines the essential constructs and dynamicsthat comprise the FDO API The definitions of these constructs and dynamics are groupedinto two interdependent categories

Data Concepts Definitions of the data constructs that comprise the FDO API

Operational Concepts Definitions of the operations that are used to manage andmanipulate the data

Data ConceptsAll concepts that are defined in this section relate to the data that FDO isdesigned to manage and manipulate

What Is a Feature

A feature is an abstraction of a natural or man-made real world object It isrelated directly or indirectly to geographic locations A spatial feature has oneor more geometric properties For example a road feature might be representedby a line and a hydrant might be represented by a point A non-spatial featuredoes not have geometry but can be related to a spatial feature which does Forexample a road feature may contain a sidewalk feature that is defined as notcontaining a geometry

What Is a Schema

A schema is a logical description of the data types used to model real-worldobjects A schema is not the actual data instances (that is not a particular roador land parcel) rather it is metadata A schema is a model of the types of data

3

13

that would be found in a data store For example a schema which models thelayout of city streets has a class called Road and this class has a property calledName The definition of Road and its associated classes constitute the schema

What Is a Schema Override

A schema override comprises instructions to override the default schemamappings For example an RDBMS-type FDO provider could map a featureclass to a table of the same name by default A schema override might mapthe class to a differently named table for example by mapping the poleclass to the telco_pole table

What is a Schema Mapping

A Schema Mapping is a correspondence between a Schema Element and aphysical object in a data store For example OSGeo FDO Provider for MySQLmaps each Feature Class onto a table in the MySQL database where the datastore resides The physical structure of data stores for each FDO provider canvary greatly so the types of Schema Mappings can also vary between providersEach provider defines a set of default schema mappings For example OSGeoFDO Provider for MySQL maps a class to a table of the same name by defaultThese defaults can be overridden by specifying Schema Overrides

What Are Elements of a Schema

A schema consists of a collection of schema elements In the FDO API schemaelements are related to one another by derivation and by aggregation Anelement of a schema defines a particular type of data such as a feature classor a property or an association For example a feature class definition for aroad includes the class name (for example Road) and the class properties (forexample Name NumberLanes PavementType and Geometry)

What Is a Class Type

A class type is a specialization of the base FDO class definition(FdoClassDefinition) It is used to represent the complex properties of spatialand non-spatial features

What is a Feature Class

A feature class is a schema element that describes a type of real-world objectIt includes a class name and property definitions including zero or moregeometric properties It describes the type of data that would be included inobject instances of that type

14 | Chapter 3 FDO Concepts

What Is a Property

A property is a single attribute of a class and a class is defined by one or moreproperty definitions For example a Road feature class may have propertiescalled Name NumberLanes or Location A property has a particular typewhich can be a simple type such as a string or number or a complex typedefined by a class such as an Address type which itself is defined by a set ofproperties such as StreetNumber StreetName or StreetType

There are five kinds of properties association properties data propertiesgeometric properties object properties and raster properties

Individual properties are defined in the following sections

What Is an Association Property

The FdoAssociationPropertyDefinition class is used to model a peer-to-peerrelationship between two classes This relationship is defined at schemacreation time and instantiated at object creation time The association propertysupports various cardinality settings cascading locks and differing deleterules An FDO filter can be based on association properties andFdoIFeatureReader can handle associated objects through the GetObject()method

What Is a Data Property

A data property is a non-spatial property An instance of a data propertycontains a value whose type is either boolean byte datetime decimal singledouble Int16 Int32 Int64 string binary large object or character large object

What Is Dimensionality

Dimensionality and the concept of dimension has two different meaningsin the discussion of geometry and geometric property

The first is called shape dimensionality and it is defined by theFdoGeometricType enumeration The four shapes are point (0 dimensions)curve (1 dimensions) surface (2 dimensions) and solid (3 dimensions)

The other is called ordinate dimensionality and it is defined by theFdoDimensionality enumeration There are four ordinate dimensions XYXYZ XYM and XYZM M stands for measure

Data Concepts | 15

What Is a Geometric Property

An instance of a geometric property contains an object that represents ageometry value The definition of the geometric property may restrict anobject to represent a geometry that always has the same shape such as a pointor it could allow different object instances to have different dimensions Forexample one geometric property object could represent a point and anothercould represent a line Any combination of shapes is permissible in thespecification of the geometric types that a geometry property definitionpermits The default geometric property specifies that an object could representa geometry that is any one of the four shapes

With respect to ordinate dimensionality all instances of a geometric propertymust have the same ordinate dimension The default is XY

Geometric property definitions have two attributes regarding ordinatedimensionality HasElevation for Z and HasMeasure for M

What is a Geometry

A geometry is represented using geometric constructs either defined as listsof one or more XY or XYZ points or defined parametrically for example asa circular arc While geometry typically is two- or three-dimensional it mayalso contain the measurement dimension (M) to provide the basis for dynamicsegments

The geometry types are denoted by the FdoGeometryType enumeration anddescribe the following

Point

LineString (one or more connected line segments defined by positions atthe vertices)

CurveString (a collection of connected circular arc segments and linearsegments)

Polygon (a surface bound by one outer ring and zero or more interior ringsthe rings are closed connected line segments defined by positions at thevertices)

CurvePolygon (a surface bound by one outer ring and zero or more interiorrings the rings are closed connected curve segments)

MultiPoint (multiple points which may be disjoint)

MultiLineString (multiple LineStrings which may be disjoint)

16 | Chapter 3 FDO Concepts

MultiCurveString (multiple CurveStrings which may be disjoint)

MultiPolygon (multiple Polygons which may be disjoint)

MultiCurvePolygon (multiple CurvePolygons which may be disjoint)

MultiGeometry (a heterogenous collection of geometries which may bedisjoint)

Most geometry types are defined using either curve segments or a series ofconnected line segments Curve segments are used where non-linear curvesmay appear The following curve segment types are supported

CircularArcSegment (circular arc defined by three positions on the arc)

LineStringSegment ( a series of connected line segments defined bypositions are the vertices)

There are currently no geometries of type ldquosolidrdquo (3D shape dimensionality)supported

The FdoIConnectionGetGeometryCapabilities() method can be used to querywhich geometry types and ordinate dimensionalities are supported by aparticular provider

What Is an Object Property

An object property is a complex property type that can be used within a classand an object property itself is defined by a class definition For examplethe Address type example described previously in the Property definition Anobject property may define a single instance for each class object instance (forexample an address property of a land parcel) or may represent a list ofinstances of that class type per instance of the owning class (for exampleinspection records as a complex property of an electrical device feature class)

What is a Raster Property

A raster property defines the information needed to process a raster imagefor example the number of bits of information per pixel the size in pixels ofthe X dimension and the size in pixels of the Y dimension needed to processa raster image

Data Concepts | 17

What Is a Spatial Context

A spatial context describes the general metadata or parameters within whichgeometry for a collection of features resides In particular the spatial contextincludes the definition of the coordinate system spheroid parameters unitsspatial extents and so on for a collection of geometries owned by features

Spatial context can be described as the ldquocoordinate system plus identityrdquo Anygeometries that are to be spatially related must be in a common spatial context

The identity component is required in order to support separate workspacessuch as schematic diagrams which are non-georeferenced Also it supportsgeoreferenced cases For example two users might create drawings using somedefault spatial parameters (for example rectangular and 10000x10000)although each drawing had nothing to do with the other If the drawings wereput into a common database the users could preserve not only the spatialparameters but also the container aspect of their data using spatial context

For more information about spatial context see Spatial Context on page 161

What is a Data Store

A data store is a repository of an integrated set of objects The objects in a datastore are modeled either by classes or feature classes defined within one ormore schemas For example a data store may contain data for both a LandUseschema and a TelcoOutsidePlant schema Some data stores can represent datain only one schema while other data stores can represent data in manyschemas (for example RDBMS-based data stores such as MySQL)

Operational ConceptsThe concepts that are defined in this section relate to the FDO operations usedto manage and manipulate data

What Is a Command

In FDO the application uses a command to select and update features definenew types of feature classes lock features version features and perform someanalysis of features Each Command object executes a specific type of commandagainst the underlying data store Interfaces define the semantics of eachcommand allowing them to be well-defined and strongly typed Because FDOuses a standard set of commands providers can extend existing commandsand add new commands specific to that provider Feature commands execute

18 | Chapter 3 FDO Concepts

against a particular connection and may execute within the scope of atransaction

An FDO command is a particular FDO interface that is used by the applicationto invoke an operation against a data store A command may retrieve datafrom a data store (for example a Select command) may update data in a datastore (for example an Update or Delete command) may perform some analysis(for example an Activate Spatial Context command) or may cause some otherchange in a data store or session (for example a Begin Transaction command)

What Is an Expression

An expression is a construct that an application can use to build up a filterAn expression is a clause of a filter or larger expression For example ldquoLanesgt=4 and PavementType = Asphaltrdquo takes two expressions and combines themto create a filter

For more information about using expressions with FDO see Filter andExpression Languages on page 139

What Is a Filter

A filter is a construct that an application specifies to an FDO provider toidentify a subset of objects of an FDO data store For example a filter may beused to identify all Road type features that have 2 lanes and that are within200 metres of a particular location Many FDO commands use filter parametersto specify the objects to which the command applies For example a Selectcommand uses a filter to identify the objects that the application wants toretrieve Similarly a Delete command uses a filter to identify the objects thatthe application wants to delete from the data store

For more information about using filters with FDO see Filter and ExpressionLanguages on page 139

What Is Locking

A user can use locking to gain update control of an object in the data store tothe exclusion of other users There are two general types of locksmdashtransactionlocks and persistent locks Transaction locks are temporary and endure onlyfor the duration of the transaction (see What Is a Transaction on page 20)

Persistent locks applied to objects by a user remain with the object until eitherthat user removes those locks or the locks are removed by another user withthe appropriate authority

Operational Concepts | 19

What Is a Transaction

A transaction changes the data store in some way The way these changesaffect the data store is determined by the transactionrsquos properties For examplethe Atomic property specifies that either all changes happen or non happenIn transaction processing the data store treats a series of commands as a singleatomic unit of change to that data store Either all changes generated by thecommands are successful or the whole set is cancelled A transaction is a singleatomic unit of changes to a data store The application terminates a transactionwith either a ldquocommitrdquo which applies the set of changes or a ldquorollbackrdquowhich cancels the set of changes Further the data store may automaticallyroll back a transaction if it detects a severe error in any of the commandswithin the transaction A transaction has the following properties

Atomic Either all changes generated by the commands within a transactionhappen or none happen

Consistent The transaction leaves the data store in a consistent stateregarding any constraints or other data integrity rules

Isolated Changes being made within a transaction by one user are notvisible to other users until after that transaction is committed

Durable After a transaction is completed successfully the changes arepersistent in the data store on disk and cannot be lost if the program orprocessor fails

What Is a Long Transaction

A long transaction (LT) is an administration unit used to group conditionalchanges to objects Depending on the situation such a unit might containconditional changes to one or to many objects Long transactions are used tomodify as-built data in the database without permanently changing the as-builtdata Long transactions can be used to apply revisions or alternates to anobject

What Is a Root Long Transaction

A root long transaction is a long transaction that represents permanent dataAny long transaction has a root long transaction as an ancestor in its longtransaction dependency graph

20 | Chapter 3 FDO Concepts

Development Practices

This chapter explains several practices to follow when working with the FDO API and providesexamples of how to follow these practices

Memory ManagementSome FDO functions (for example the Create methods) allocate memory whenthey are called This memory needs to be freed to prevent memory leaks Alldestructors on FDO classes are protected so you must call a Release() functionto destroy them (thus freeing their allocated memory) Each class inherits fromthe FdoIDisposable class which defines the Release() method and the AddRef()method

In addition these classes are reference counted and the count is increased (byAddRef()) when you retrieve them through a Get function After finishing withthe object you need to release it (just as with COM objects) The object isdestroyed only when the reference count hits 0 Two macros are defined to helpin the use of the Release() and AddRef() methods

FDO_SAFE_RELEASE (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_RELEASE calls the release() methodof the object pointed to by the ldquoptrrdquo argument and then sets the local pointerto the object to NULL The macro definition is define FDO_SAFE_RELEASE(x)

if (x) (x)-gtRelease() (x) = NULL

FdoFeatureClass pBase = myClass-gtGetBaseClass()

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

4

21

FDO_SAFE_ADDREF (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_ADDREF calls the AddRef()method of the object pointed to by the ldquoptrrdquo argument The macro definitionis define FDO_SAFE_ADDREF(x) ((x = NULL) (x)-gtAddRef() (x)

(NULL))

return FDO_SAFE_ADDREF(value)returns NULL if value equals NULL orincrements the reference count of the object that value points to andreturns value

m_list[index] = FDO_SAFE_ADDREF(value) assigns NULL to the arrayentry if value is NULL or increments the reference count of the object thatvalue points to and assigns value to the array entry

FdoPtr

An FdoPtr smart pointer is provided to help manage memory You wrap anFDO object in a FdoPtr The requirement is that the objectrsquos type must inheritfrom FdoIDisposable The object is then released automatically when theFdoPtr goes out of scope The following code illustrates how to use FdoPtr

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

No need to call FDO_SAFE_RELEASE

Before it is destroyed pBase calls Release() on the FdoFeature

Class object

NOTE If for some reason you wanted to use FDO_SAFE_RELEASE on an FdoPtryou would have to use an FdoPtr method to get a pointer to the object that FdoPtrwraps and pass that pointer to FDO_SAFE_RELEASE

You can use FdoPtr for your own classes by inheriting from the abstract classFdoIDisposable and providing an implementation for the Dispose() method(typically delete this)

FdoPtr Typedefs

Typedefs are provided that define identifiers representing Fdo classes wrappedbyFdoPtr An example is typedef FdoPtrltFdoClassgt FdoClassP

22 | Chapter 4 Development Practices

CollectionsYou can use FDO collection template classes to store your own objects Therequirements for your collection class and the class used to instantiate thetemplate are the same as those for wrapping a class in a FdoPtr

Exception HandlingIn the FDO API FdoCommandException class is the exception type thrownfrom classes in the Commands package and FdoConnectionException classis the exception type thrown from classes in the Connections package Bothof these exception types derive from a language-level exception class that isenvironment-specific

All exceptions are derived from the FdoException class To catch and processspecific exception types nest catch statements as in the following example

try

code

catch (FdoCommandException ex)

process message

catch (FdoException ex)

process message

In some cases underneath an FDO command the FDO level throws anFdoException The FDO command then traps the FdoException and wraps itin an FdoCommandException (or FdoSchemaException for a schemacommand) In this case several messages are returned by one exception Thefollowing example shows how to process multiple messages from oneexception

catch ( FdoSchemaException ex )

Loop through all the schema messages

FdoException currE = ex

while ( currE )

CW2A msg(currE-gtGetExceptionMessage())

acutPrintf (FdoConnectionException sn msg)

currE = currE-gtGetCause()

Collections | 23

An application function may need to catch and then re-throw exceptions inorder to clean up memory However the need to do this can be eliminatedby using FdoPtr The following example cleans up memory on error

FdoFeatureClass pBase = NULL

try

pBase = myClass-gtGetBaseClass()

catch ()

FDO_SAFE_RELEASE(pBase)

throw

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

The catch and rethrow is unnecessary when FdoPtr is used

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

Exception MessagesException messages are localized On Windows the localized strings are inresource-only DLLs and on Linux they are in catalogs The message DLLs arein the bin folder the DLL name contains Message or Msg The catalog filesare in the usrlocalfdo-320nls directory the names of these files ends in catNLS stands for National Language Support

On Linux set the NLSPATH environment variable so that the runtime codecan locate the message catalogs For example exportNLSPATH=usrlocalfdo-320nlsN

On Windows you do not have do anything special to enable the runtime codeto locate the message DLLs

The contents of the exception message files are indexed When you call oneof the FdoExceptionNLSGetMessage methods declared in Exceptionh youprovide a message number argument You may also provide a default messagestring argument In the event that the exception message resource file cannotbe found the default message is subsituted instead If the default messagestring is not provided and the resource file cannot be found the messagenumber is used as the exception message Not finding the resource file canonly happend on Linux and only if the NLSPATH envrionment variable is notset

24 | Chapter 4 Development Practices

The following two examples when called on Linux with the NLSPATHenvironment variable not set show the use of the default message and themessage number in the exception message

The following is an example of using the default string throwFdoSchemaExceptionCreate(NlsMsgGet1(FDORDBMS_333 Class 1$lsnot

found value-gtGetText()))

The following is an example of not setting the default string and using themessage number instead FdoSchemaException pNewException =

FdoSchemaExceptionCreate(

FdoSmErrorNLSGetMessage(FDO_NLSID(FDOSM_221)

pFeatSchema-gtGetName()) pException)

Managing FdoPtr BehaviorsThe topics in this section describe several ways that you can manager FdoPtrbehavior For more information about managing FdoPtr behavior see therelated topics ldquoFdoPtr ltTgt Class Template Referencerdquo and ldquoFdoIDisposableClass Referencerdquo in the FDO Reference Help and The Essential FDO

Chain Calls

Do not chain calls If you do returned pointers will not be released Forexample given an FdoClassDefinition pclassDef

psz = pclassDef -gtGetProperties()-gtGetItem(0)-gtGetName())

The above code would result in two memory leaks Instead use

FdoPropertyDefinitionCollection pprops = pclassDef -gt GetProper

ties()

FdoPropertyDefinition ppropDef = pprops-gtGetItem(0)

psz = propDef-gtGetName()

ppropDef-gtRelease()

pprops-gtRelease()

or (with FdoPtr)

FdoPtrltFdoPropertyDefinitionCollectiongt pprops = pclassDef-gt Get

Properties()

FdoPtrltFdoPropertyDefinitiongt ppropDef = pprops-gt GetItem(0)

psz = propDef-gtGetName()

or (also with FdoPtr)

Managing FdoPtr Behaviors | 25

psz = FdoPtr ltFdoPropertyDefinitiongt (FdoPtr ltFdoPropertyDefini

tionCollectiongt(pclassDef-gtGetProperties())-gt GetItem(0))-gtGet

Name()

Assigning Return Pointer of an FDO Function Call to a Non-SmartPointer

If you are assigning the return pointer of an FDO function call to a non-smartpointer then you should assign that pointer to a FdoPtr For example

FdoLineString P = gfCreateLineString()

FdoPtr ltFdoLineStringgt p2 = FDO_SAFE_ADDREF(p)

26 | Chapter 4 Development Practices

Establishing aConnection

This chapter explains how to establish a connection to an FDO provider and provides aconnection example

Connection SemanticsData Sources and Data Stores

The FDO API uses connection semantics to implement access to feature schemadata The term data store is used to refer to a collection of zero or more objectswhich instantiate class definitions belonging to one or more FDO feature schemaThe connection is to a data store because that is where data objects are storedThe underlying data source technologies used to hold data stores can berelational databases such as a MySQL database or a file-based solution suchas an SDF file

The mapping of a data store to data source technology can be one-to-one ormany-to-one For example it is

One-to-one when the connection is made by way of the OSGeo FDO Providerfor ArcSDE and the ArcSDE server is using an Oracle database

Many-to-one when the data source is a MySQL database and the connectionis made by way of the OSGeo FDO Provider for MySQL (in this case the datastore is like a container within a container)

When many-to-one mapping is possible a connection can be made in one ortwo steps For more information see Establishing a Connection on page 29 andThe Essential FDO

5

27

The underlying data source technologies differ in the connection parametersused for connecting to a particular provider The values for these parametersare generated during the installation and configuration of the containertechnologies For more information about these values and the process ofinstalling and configuring the associated data source technologies see theappropriate appendix in this document and The Essential FDO

Providers

You connect to a data store by way of a provider

The FDO API contains a registry interface that you can use to register orderegister a provider See the class FdoProviderRegistry inIncFdoClientServicesProviderRegistryh

The providers are registered during the initialization of the FDO SDK In orderto connect to a provider you will need the name of the provider in a particularformat ltCompanyFoundationOriginatorgtltProvidergtltVersiongt TheltCompanyFoundationOriginatorgt and ltProvidergt values are invariable Forspecific values see The Essential FDO

In order to connect you will need the full name including the ltVersiongtvalue You can retrieve the full name from the registry and display the set ofprovider names in a connection menu list If for whatever reason youderegister a provider save the registry information for that provider in caseyou want to reregister it again The provider object returned by the registryhas a Set() method to allow you to change values However the only valueyou can safely change is the display name Sample code for using the providerregistry is located in Establishing a Connection on page 29

The registry contains the following information about a provider

Name The unique name of the feature provider This name should be ofthe form ltCompanyFoundationOriginatorgtltProvidergtltVersiongt forexample AutodeskOracle30 or OSGeoMySQL30

DisplayName A user-friendly display name of the feature provider Theinitial values of this property for the pre-registered providers are ldquoAutodeskFDO Provider for Oraclerdquo ldquoOSGeo FDO Provider for SDFrdquo etc or theequivalent in the language of the country where the application is beingused

Description A brief description of the feature provider For example thethe OsGeo FDO Provider for SDF description is ldquoReadwrite access toAutodesks spatial database format a file-based personal geodatabase thatsupports multiple featuresattributes spatial indexing and file-lockingrdquo

28 | Chapter 5 Establishing a Connection

Version The version of the feature provider The version number stringhas the form ltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgtfor example 3000

FDOVersion The version of the feature data objects specification to whichthe feature provider conforms The version number string has the formltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgt for example3010

libraryPath The FULL library path including the library name of theprovider for example ltFDO SDK Install LocationgtbinFdoRdbmsdll

isManaged A flag indicating whether the provider is a managed orunmanaged NET provider

Establishing a ConnectionAs mentioned in a previous section Connection Semantics on page 27 theFDO API uses a provider to connect to a data store and its underlying datasource technology These data source technologies must be installed andconfigured Certain values generated during data source installation andconfiguration are used as arguments during the connection process Becausethe FDO API does not provide any methods to automate the collection andpresentation of these configuration values either the application developermust request the user to input these configuration values during theconnection process or the application developer can provide an applicationconfiguration interface which would populate the application with thecontainer configuration values and thus allow the user to choose them fromlists

NOTE For more information about connecting see The Essential FDO

A connection can be made in either one or two steps

One-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method once the returned stateis FdoConnectionState_Open no additional information is needed

Two-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method the returned state isFdoConnectionState_Pending additional information is needed to completethe connection In this case the first call to Open() has resulted in theretrieval of a list of values for a property that becomes a required property

Establishing a Connection | 29

for the second call to the Open() method After the user has selected oneof the values in the list the second call to Open() should result inFdoConnectionState_Open

Connecting to a data store by way of the MySQL or the ArcSDE provider forexample can be done in either one or two steps In the first step the datastore parameter is not required If the user does not give the data storeparameter a value the FDO will retrieve the list of data store values from thedata source so that the user can choose from them during the second stepOtherwise the user can give the data store a value in the first step andassuming that the value is valid the connection will be completed in onestep

For the purpose of this example letrsquos assume that the user has installed MySQLon his local machine During the installation he was prompted to assign apassword to the system administrator account whose name is lsquorootrsquo He setthe password to lsquotestrsquo

The following steps are preliminary to establishing a connection

1 Get the list of providers

FdoPtrltFdoProviderRegistrygt registry = (FdoProviderRegistry

)FdoFeatureAccessManagerGetProviderRegistry()

FdoProviderCollection providers = registry-gtGetProviders()

2 Get the display names for all of the providers in the registry An exampleof a display name might be OSGeo FDO Provider for MySQL

FdoStringP displayName

FdoStringP internalName

FdoPtrltFdoProvidergt provider

int count = providers-gtGetCount()

for(int i = 0 i lt count i++)

provider = providers-gtGetItem(i)

internalName = provider-gtGetName()

displayName = provider-gtGetDisplayName()

add displayName to your list

3 Use the display names to create a menu list from which the user willselect from when making a connection

After the user initiates a provider display name from the connection menudo the following

30 | Chapter 5 Establishing a Connection

1 Loop through the providers in the registry until you match the displayname selected by the user from the connection menu with a providerdisplay name in the registry and retrieve the internal name for thatprovider An example of an internal could be OSGeoMySQL32

FdoStringP internalName = provider-gtGetName()

2 Get an instance of the connection manager

FdoPtrltFdoConnectionManagergt connectMgr = (FdoConnectionManager

)FdoFeatureAccessManagerGetConnectionManager()

3 Call the managerrsquos CreateConnection() method using the provider internalname as an argument to obtain a connection object

FdoPtrltFdoIConnectiongt fdoConnection = connectMgr-gtCreateConnec

tion(LrdquoOsGeoMySQL32rdquo)

4 Obtain a connection info object by calling the connection objectrsquosGetConnectionInfo() method

FdoPtrltFdoIConnectionInfogt info = fdoConnection-gtGetConnection

Info()

5 Obtain a connection property dictionary object by calling the connectioninfo objectrsquos GetConnection Properties() method and use this dictionaryto construct a dialog box requesting connection information from theuser

FdoPtrltFdoIConnectionPropertyDictionarygt ConnDict = info-gtGetCon

nectionProperties()

6 Get a list of connection property names from the dictionary and use thislist to get information about the property The following code loopsthrough the dictionary getting all of the possible information

NOTE An attempt to get the values of an enumerable property is made onlyif the property is required

FdoInt32 count = 0

FdoString names = NULL

FdoStringP name

FdoStringP localname

FdoStringP val

FdoStringP defaultVal

bool isRequired = false

bool isProtected = false

bool isFilename = false

bool isFilepath = false

Establishing a Connection | 31

bool isDatastorename = false

bool isEnumerable = false

FdoInt32 enumCount = 0

FdoString enumNames = NULL

FdoStringP enumName

names = ConnDict-gtGetPropertyNames(count)

for(int i = 0 i lt count i++)

name = names[i]

val = dict-gtGetProperty(name)

defaultVal = dict-gtGetPropertyDefault(name)

localname = dict-gtGetLocalizedName(name)

isRequired = dict-gtIsPropertyRequired(name)

isProtected = dict-gtIsPropertyProtected(name)

isFilename = dict-gtIsPropertyFileName(name)

isFilepath = dict-gtIsPropertyFilePath(name)

isDatastorename = dict-gtIsPropertyDatastoreName(name)

isEnumerable = dict-gtIsPropertyEnumerable(name)

if (isEnumerable)

if (isRequired)

enumNames = dict-gtEnumeratePropertyValues(name enumCount)

for(int j = 0 j lt enumCount j++)

enumName = enumNames[j]

7 Use the GetLocalizedName method to obtain the name of the propertyto present to the user Calls to dictionary methods need the value of theinternal name in the string array returned by GetPropertyNames() Sowhen the user selects the localized name in the menu the program mustmap the localized name to the internal name

8 Use the IsPropertyRequired method to determine whether to mark theline as either required or optional the dialog box handler should notpermit the user to click OK in the dialog box unless a required field hasa value

9 Use the IsPropertyProtected method to determine whether the dialogbox handler should process the field value as protected data for examplea password

10 Use the IsPropertyEnumerable and IsRequired methods to determinewhether to call the EnumeratePropertyValues method to get a list of validvalues

32 | Chapter 5 Establishing a Connection

NOTE Call the EnumeratePropertyValues method only if both methods returntrue Otherwise be prepared to catch an exception if there is no pendingconnection The assumption is that a connection exists and the program isretrieving values from the data store

As shown in the code lines above the EnumeratePropertyValues method takesa property name and an updates integer argument and returns a string arrayThe updates integer will say how many values are in the returned array Presentthe list of choices to the user

If the property is not enumerable present the values returned by either theGetProperty or GetPropertyDefault methods to the user

Now that the user has seen the set of properties in the dictionary she canset the required properties A property is set by calling the dictionaryrsquosSetProperty method The MySQL connection property names are UsernamePassword Service and DataStore The dictionary tells us that UsernamePassword and Service are required properties and that DataStore is not requiredLetrsquos connect to the MySQL as root

ConnDict-gtSetProperty(LrdquoUsernamerdquo Lrdquorootrdquo)

ConnDict-gtSetProperty(LrdquoPasswordrdquo Lrdquotestrdquo)

ConnDict-gtSetProperty(LrdquoServicerdquo Lrdquolocalhostrdquo)

NOTE fdoconnection-gtGetConnectionString() returnsUsername=rootPassword=testService=localhostfdoconnection-gtSetConnectionString(LrdquoUsername=rootPassword=testService=localhostrdquo)

would set the connection properties to the same values as the three calls aboveto the connection dictionaryrsquos SetProperty() method

Open the connection

FdoConnectionState state = fdoConnection-gtOpen()

The value of state is FdoConnectionState_Pending An examination of theconnection dictionary will reveal that the DataStore property is now required

When the user checks the command capabilities he discovers that he cancreate a data store

Establishing a Connection | 33

FdoPtrltFdoICommandCapabilitiesgt commandCapabilities = fdoConnec

tion-gtGetCommandCapabilities()

bool bSupportsCreateDatastore = false

FdoInt32 numCommands

FdoIn32 commands = commandCapabilities-gtGetCommands(numCommands)

for(int i = 0 i lt numCommands i++)

switch(commands[i])

case FdoCommandType_CreateDataStore bSupportsCreateDatastore

= true

He can use the pending connection to MySQL to create the datastore Use theconnection object to create the FdoICreateDataStore command object Usethe command object to create the FdoIDataStorePropertyDictionary objectand find out from this object what properties you must define Use thedictionary object to set the required properties and then execute the commandto create the lsquofdo_userrsquo data store The only required property is DataStore

NOTE The FdoIDataPropertyDictionary and the FdoIConnectionPropertyDictionaryclasses are both derived from FdoIPropertyDictionary The code used above toaccess the FdoIConnectionPropertyDictionary object works for theFdoIDataPropertyDictionary

FdoPtrltFdoICreateDataStoregt createDataStoreCmd = dynam

ic_castltFdoICreateDataStore gt (fdoConnection-gtCreateCommand(Fdo

CommandType_CreateDataStore))

FdoPtrltFdoIDataStorePropertyDictionarygt createDsDict = createData

StoreCmd-gtGetDataStoreProperties()

createDsDict-gtSetProperty(LrdquoDataStorerdquo Lrdquofdo_userrdquo)

createDataStoreCmd-gtExecute()

Now use the connection property dictionary to set the DataStore property tolsquofdo_userrsquo and call the Open() method on the connection object This methodshould return FdoConnectionState_Open

34 | Chapter 5 Establishing a Connection

FDO Capabilities

FDO Capabilities

Introduction

The FDO capabilities are statically defined They are accessed through aconnection object in the closed state The following code illustrates how to geta connection object in the closed state

If you are using C you will find the capability definitions in theOSGeoFDOConnectionsCapabilities namespace If you are using C++ youwill find the headers in the FdoConnectionsCapabilties directory

In C you access them using the OSGeoFDOConnectionsIConnection objectIn C++ you access them using the IConnection object whose header is in theFdoConnections directory

The information in the capabilities tables reflects the state of the FDO providercapabilities as of the commercial release of Map 3D 2009

For the most part FDO defines capabilities in three ways booleans enumerationsor integers representing enumerated values and collections One schemacapability is defined as a string and two other schema capabilities as integersFor example the Command capability SupportsParameters is a boolean andthe Command capability Commands is a set of integers whose meaning isdefined by the C CommandType enumeration and the C++ FdoCommandTypeenumeration Function capabilities are defined as collections of functionsignatures The C type isOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionThe C++ type is FdoReadOnlySignatureDefinitionCollection The latter is

6

35

defined in FdoConnectionsCapabilitiesSignatureDefinitionh Each booleanenumeration and signature value is shown in the tables

In general where a number of capabilities are supported by the same set ofproviders the capabilities are aggregated into one line in the table This ruleis modified in the function category tables in the Expression section

In some cases for example the CLIP raster function there is only one signatureAt the other end of the spectrum is the Concat string function which hasalmost 100 signatures The same set of providers supports an enormous numberof functions and so the rule for presenting aggregations of capabilities had tobe modfied for functions The rule for functions is to present all of thesignatures for one function on a line in the table A handful of functions hadso many signatures that their presentation had to be split over two lines

Provider Type

A provider can be one of four types Database Server File Web Server orUnknown The type information is available from the connection object inthe closed state The ldquoUnknownrdquo type indicates that the provider can connectto more than one type of data store technology The ODBC and OGR providerscan connect either to a file-based or RDBMS-based data store technologywhich is not known until the connection is in the open state

In C the ProviderDatastoreType enumeration is in theOSGeoFDOConnections namespace The ProviderDatastoreType property isaccessible through the OSGeoFDOConnectionsIConnection object(connectionConnectionInfoProviderDatastoreType)

In C++ the FdoProviderDatastoreType enumeration is defined in theltFdoConnectionsProviderDatastoreTypehgt header file TheFdoProviderDatastoreType value is accessible through the IConnection object(connection-gtGetConnectionInfo()-gtGetProviderDatastoreType())

TypeProvider

DatabaseServerOSGeoArcSDE33

DatabaseServerOSGeoKingOracle33

DatabaseServerOSGeoMySQL33

36 | Chapter 6 FDO Capabilities

TypeProvider

DatabaseServerOSGeoPostGIS33

DatabaseServerOSGeoSQLServerSpatial33

FileOSGeoGdal33

FileOSGeoSDF33

FileOSGeoSHP33

WebServerOSGeoWFS33

WebServerOSGeoWMS33

UnknownOSGeoODBC33

UnknownOSGeoOGR33

NOTE A provider name with OSGeo at the beginning indicates that the provideris available as open source from httpfdoosgeoorg

Command

In C you access theOSGeoFDOConnectionsCapabilitiesICommandCapabilities using theIConnection object (connectionCommandCapabilities)

In C++ you access the FdoICommandCapabilities using the IConnection object(connection-gtGetCommandCapabilities())

DescriptionCommand

Locks feature instances of a given class that match thespecified criteria

AcquireLock

Command | 37

DescriptionCommand

Activates a long transaction so that features can be ver-sioned

ActivateLongTransaction

Activates a specified spatial contextActivateSpatialContext

Creates or updates a feature schema within the datastore Optionally a provider-specificmapping of featureschema elements to physical storage can be specified

ApplySchema

Commits all of the data within a leaf long transaction(one that does not have descendent long transactions)

CommitLongTransaction

to the parent long transaction and removes the longtransaction Requires access commit and remove priv-ileges to the long transaction and the access privilegeto the parent long transaction

Creates anew provider specific datastoreCreateDataStore

Creates a long transaction as a child of the currentlyactive long transaction

CreateLongTransaction

Creates a new spatial context Input to the commandincludes the name description coordinate system ex-tent type and extent for the new context

CreateSpatialContext

Deactivates the active long transaction and automaticallyactivates the root long transaction If the root long

DeactivateLongTransaction

transaction is the active one the deactivation has noeffect

Deletes the instances of a given class that match thespecified criteria The instances can be at global scopeor contained within an object collection

Delete

Describe a single schema or all schemas available fromtheconnection

DescribeSchema

38 | Chapter 6 FDO Capabilities

DescriptionCommand

Describes the logical to physical schema mappings forone or all feature schemas available from the connection

DescribeSchemaMapping

Remove a data storeDestroyDataStore

Destroys a schema definition including all class defini-tions relationship definitions and instance data within

DestroySchema

it If elements in other schemas referto the schema tobe destroyed execution will fail

Destroys an existing spatial context which destroys alldata stored in that context

DestroySpatialContext

Gets a list of all objects that are currently locked by aparticular user

GetLockedObjects

Gets lock information for the feature instances of a givenclass that match the specified filter

GetLockInfo

Gets a list of all lock ownersGetLockOwners

Gets one specific long transaction or all available longtransactions

GetLongTransactions

Enumerates the existing measurement unitsGetMeasureUnits

Gets all spatial contexts or just the active oneGetSpatialContexts

inserts a new instance of a given class The instance canbe at global scope or contained within an object collec-tion

Insert

Gets a list of datastores at a particular serverListDataStores

Create a spatial index for the specified spatial contextOracleCreateSpatialIndex

Command | 39

DescriptionCommand

Drop the specified spatial indexOracleDestroySpatialIndex

Enumerate the existing spatial indexesOracleGetSpatialIndexes

Releases locks from feature instances of a given class thatmatch the specified criteria

ReleaseLock

Removes all of the data within a long transaction andremoves the long transaction as well Requires access

RollbackLongTransaction

commit and remove privileges to the long transactionand the access privilege to the parent long transaction

creates a new SDF+ file with a specified location and filename and a given spatial coordinate system This com-

SDFCreateSDFFile

mand has been superceded by the CreateDataStorecommand

Supports the selection and ordering of feature instancesof a given class according to the specified criteria Theresults of the select are written to an SDF file

SDFExtended_Select

Queries for features of a given class that match the spe-cified criteria

Select

Queries for features of a given class that match the spe-cified criteria The criteria can specify that feature values

SelectAggregates

from multiple instances be aggregated be distinct orbe grouped

Supports the execution of a SQL statement against anunderlying RDBMS Two execute methods are provided

SQLCommand

to distinguish between statements that return table dataversus those that execute non query type operations

Modifies instances of a given class that match the spe-cified criteria The instance can be at global scope orcontained within an object collection

Update

40 | Chapter 6 FDO Capabilities

DescriptionCommand

Gets the image formats supported by the connectionWMSGetImageFormats

Gets the layer styles available for the specified featureclass

WMSGetFeatureClassStyles

Gets the CRS names available for the specified featureclass

WMSFeatureClassCRS-Names

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports the use of distinct in SelectAggreg-ates commands

SupportsSelectDistinct

Indicates whether or not a provider sup-ports the use of expressions for propertiesin Select and SelectAggregate commands

SupportsSelectExpressions

Indicates whether or not a provider sup-ports the use of functions in Select and

SupportsSelectFunctions

SelectAggregates command Only aggreg-ate functions can be used in the SelectAg-gregates command

Indicates whether or not a provider sup-ports the use of grouping criteria in theSelectAggregates command

SupportsSelectGrouping

Indicates whether or not a provider sup-ports ordering in the Select and SelectAg-gregates command

SupportsSelectOrdering

Command | 41

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports parameter substitution

SupportsParameters

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++Select DescribeSchema GetSpatialContexts

++++++++-+++SelectAggregates

+++-++-+++++SupportsSelectFunctions

++--++-+++++SupportsSelectDistinct Insert Update Delete

++-+++-++++-SupportsSelectExpressions

----++-+-+++CreateSpatialContext

-++-+-++-+--DescribeSchemaMapping

-+-----+++++SQLCommand

----++-++++-ApplySchema

-----+-++++-CreateDataStore

-+-----++++-SupportsSelectOrdering

-------+++-+ListDataStores

-+-----+-++-SupportsSelectGrouping

-----+-+++--DestroyDataStore

42 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

----+--+-+--DestroySchema

--------+-++SupportsParameters

-------+-+-+DestroySpatialContext

----++------SDFCreateSDFFile

-------+---+ActivateSpatialContext

-------+----OracleGetSpatialIndexes OracleCreateSpatialIndex Or-acleDestroySpatialIndex

-----+------SDFExtended_Select

--+---------WMSFeatureClassCRSNames WMSGetImageFormatsWMSGetFeatureClassStyles

-----------+AcquireLock CreateLongTransaction DeactivateLongTrans-action RollbackLongTransaction CommitLongTransactionGetLockOwners ReleaseLock GetLongTransactions Get-LockedObjects ActivateLongTransaction GetLockInfo

Connection

In C you access theOSGeoFDOConnectionsCapabilitiesIConnectionCapabilities using theIConnection object (connectionConnectionCapabilities)

Connection | 43

In C++ you access the FdoIConnectionCapabilities using the IConnectionobject (connection-gtGetConnectionCapabilities())

DescriptionCapability

Indicates that only this user can modify this object in thislong transaction No user not even the user locking the

LockType_AllLongTransactionExclusive

object can modify the object in any long transaction createdas a descendent of the one containing the object beinglocked When not in a long transaction situation (for ex-ample if only a root long transaction exists) the lock be-haves like an Exclusive lock

Indicates that only this user can modify this object In a longtransaction situation any user can modify the object in any

LockType_Exclusive

other long transaction including the root long transactionif it is not the current long transaction

Indicates that only this user can modify this object in thelong transaction containing the object or any long transac-

LockType_LongTransactionExclusive

tion created as a descendent of that one When not in along transaction situation (for example if only a root longtransaction exists) the lock behaves like an Exclusive lock

Indicates a shared lock typeLockType_Shared

Indicates that a transaction lock should be applied to anobject

LockType_Transaction

Indicates whether or not a provider can specify on a closedconnection an XML source to be used to configure the datastore

SupportsConfiguration

Indicates that the spatial extent of the context is dynamicand changes as data is added and removed from the con-text

SpatialContextExtentType_Dynamic

Indicates that the spatial extent of the context is static andmust be specified when the context is created

SpatialContextExtentType_Static

44 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the specifica-tion of a coordinate system during the creation of a spatial

SupportsCSysWKTFromCSysName

context using only the coordinate system name The pro-vider maps the name to the WKT internally

Indicates whether or not a provider supports the forcedwrite of cached data associated with a connection to thetarget data store

SupportsFlush

Indicates whether or not a provider supports the set oflocking commands acquire get locked objects get lockowners get lock info and release

SupportsLocking

Indicates whether or not a provider supports the set of longtransaction commands activate commit create deactivateand get

SupportsLongTransactions

Indicates that the data store can contain multiple spatialcontexts but the provider does not necessarily support thecreate spatial context command

SupportsMultipleSpatialContexts

Indicates whether or not a provider supports the SQL com-mand

SupportsSQL

Indicates whether or not a provider supports the creationof a transaction associated with a connection to a data store

SupportsTransactions

Indicates that the provider supports a single thread perconnection Multiple concurrent threads cannot access the

ThreadCapability_PerConnectionThreaded

same connection object and only one command can beexecuting per connection Multiple connections can beactive concurrently as long as each is executing on its ownthread

Indicates that the provider supports a single thread percommand Multiple concurrent threads cannot access the

ThreadCapability_PerCommandThreaded

same command object however multiple commands canbe executing concurrently against a single connection

Connection | 45

DescriptionCapability

Indicates that the provider is not thread safeThreadCapability_SingleThreaded

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-++++-++++++SpatialContextExtentType_Static

++++++-+++-+ThreadCapability_PerConnectionThreaded

--+++-++++++SupportsMultipleSpatialContexts

-+-----+++++SupportsSQL

-++-+-+---+-SupportsConfiguration

-------++--+SupportsTransactions

----------++LockType_Exclusive

+----+------SpatialContextExtentType_Dynamic

----++------SupportsFlush

--------+-+-LockType_Transaction

----------+-LockType_AllLongTransactionExclusive LockType_LongTrans-actionExclusive ThreadCapability_PerCommandThreadedLockType_Shared

-----------+SupportsLocking SupportsCSysWKTFromCSysName Sup-portsLongTransactions

------+-----ThreadCapability_SingleThreaded

46 | Chapter 6 FDO Capabilities

Expression

In C you access theOSGeoFDOConnectionsCapabilitiesIExpressionCapabilities and theOSGeoFDOConnectionsCapabilitiesFunctionDefinitionCollectionusingthe IConnection object connectionExpressionCapabilities andconnectionExpressionCapabilitiesFunctions respectively EachOSGeoFDOConnectionsCapabilitiesFunctionDefinition in the collectionhas has aOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionwhich is accessed by functionDefSignatures

In C++ you access the FdoIExpressionCapabilities and theFdoFunctionDefinitionCollection using the IConnection objectconnection-gtGetExpressionCapabilities()expression_capabilities-gtGetFunctions() respectively EachFdoFunctionDefinition in the collection has anFdoReadOnlySignatureDefinitionCollection which is accessed byfunctionDef-gtGetSignatures()

The functions can be broadly divided into two groups according to the modeof their implementation The largest group contains the functions whoseunderlying implementation is based on the Expression Builder The first releaseof the Expression Builder component is in FDO 33 The remaining functionsare those whose implementation was not touched by the introduction of theExpression Builder component

The functions whose implementation is based on the Expression Builder arefurther categorized for UI purposes into 7 groups aggregate conversion dategeometry math numeric and string These UI categories are used in thisdocument to group the presentation of the functions

General Capabilities

DescriptionCapability

Indicates whether or not the provider supports basicarithmetic expressions for example + - negate andstring concatenation

ExpressionType_Basic

Indicates whether or not the provider supports functionevaluations

ExpressionType_Function

Expression | 47

DescriptionCapability

Indicates whether or not the provider supports parametersubstitution An expression can be constructed using

ExpressionType_Parameter

named parameters and values bound to the parameter ata later time This allows the constructed expression to bereused

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ExpressionType_Function

++-+++-+++++ExpressionType_Basic

-------+-+--ExpressionType_Parameter

Argument and Return Types

Tthe following tables specify the function name arguments and the type ofthe return value An argument is optional if it is enclosed in square bracketsAn argument may be a literal such as ldquoALLrdquo or ldquoDISTINCTrdquo or a featureproperty name Where the argument value is a feature property name thetype of the feature property is specified The set of valid alternatives for anargument value is indicated by enclosing the set of ORrsquod property types orliteral values in parentheses For brevityrsquos sake a lsquonumericrsquo property typeindicates the set of numeric property types namely Byte | Decimal | Double| Int16 | Int32 | Int 64 | Single The other property types BLOB BooleanCLOB DateTime Geometry and String are indicated directly in the argumentspecification

Some functions have more than one return type The general rule is that thereturn type matches the argument type

48 | Chapter 6 FDO Capabilities

Aggregate Expression Functions

These functions can be used with the SelectAggregates command

DescriptionFunctionName

Returnsa double which is the average of the values identified by theprovided expression Avg ([ALL | DISTINCT ] numeric)

Avg

Returns an Int64 which is the number of rows returned by a queryidentified by the provided expression Count ([ALL | DISTINCT ]bool | DateTime | numeric | string | blob | clob | geometry)

Count

Returns a DateTime numeric or string in agreement with the typeof the argument which is the maximum value of the provided expres-sion Max ([ALL | DISTINCT ] DateTime | numeric | string)

Max

Represents an inverse distribution function that assumes a continuousdistribution model It takes a numeric or date-time value and returns

Median

a Double which is the middle value or an interpolated value thatwould be the middle value once the values are sorted Median (nu-meric)

Returns a DateTime numeric or string in agreement with the typeof the argument which is the minimum value of the provided expres-sion Min ([ALL | DISTINCT ] DateTime | numeric | string)

Min

Returns a Double which is the sample standard deviation of theprovided expression Stddev ([ALL | DISTINCT ] numeric)

Stddev

Returns a Double which is the sum of the values identified by theprovided expression Sum ([ALL | DISTINCT ] numeric)

Sum

Returns a byte array which yields the spatial extent of a set of geo-metries The argument is the name of geometry property SpatialEx-

Spatial Extent

tent (ltgeometriesgt) For example given these geometries POINT(11) LINESTRING(01 21) and POLYGON((01 21 12 01)) it returnsPOLYGON((01 21 22 02 01))

Expression | 49

NOTE The median is selected or calculated by doing the following

1 Sort the sample in ascending order

2 Calculate the Row of Interest (roi) using the forumula roi = (1 +((ltsample_sizegt - 1) 2))

3 Compare three values roi Ceil(roi) and Floor(roi) If they are equal themedian is the value in the Row Of Interest If they are not equal themedian is calculated by averaging the values in the rows preceding andsucceeding the Row of Interest

NOTE The value returned by the StdDev function is known as the sample standarddeviation and represents an estimate of the standard deviation of a populationbased on a random sample of that population See the Wikipedia entry for furtherdiscussion and a definition of the formula for sample standard deviationhttpenwikipediaorgwikiStandard_deviation

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++-+++++Double Avg(Double)

++--++-+++++Int64 Count(Int64)

++--++-+++++Double Max(Double)

++--++-+++++Double Min(Double)

++--++-+++++Double Sum(Double)

-+-+++-+-+++BLOB SpatialExtents(BLOB)

-+--++-+-+-+Double Avg(Byte) Double Avg(Decimal) Double Avg(Int16)Double Avg(Int32) Double Avg(Int64) Double Avg(Single)Double Avg(StringByte) Double Avg(StringDecimal) DoubleAvg(StringDouble) Double Avg(StringInt16) Double

50 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Avg(StringInt32) Double Avg(StringInt64) DoubleAvg(StringSingle)

-+--++-+-+-+Int64 Count(BLOB) Int64 Count(Boolean) Int64 Count(Byte)Int64 Count(CLOB) Int64 Count(DateTime) Int64Count(Decimal) Int64 Count(Double) Int64 Count(Int16) Int64Count(Int32) Int64 Count(Single) Int64 Count(String) Int64Count(StringBoolean) Int64 Count(StringByte) Int64Count(StringDateTime) Int64 Count(StringDecimal) Int64Count(StringDouble) Int64 Count(StringInt16) Int64Count(StringInt32) Int64 Count(StringInt64) Int64Count(StringSingle) Int64 Count(StringString)

-+--++-+-+-+Byte Max(Byte) Byte Max(StringByte) DateTime Max(Date-Time) DateTime Max(StringDateTime) Decimal Max(Decimal)Decimal Max(StringDecimal) Double Max(StringDouble) Int16Max(Int16) Int16 Max(StringInt16) Int32 Max(Int32) Int32Max(StringInt32) Int64 Max(Int64) Int64 Max(StringInt64)Single Max(Single) Single Max(StringSingle) StringMax(String) String Max(StringString)

-+--++-+-+-+Double Median(Byte) Double Median(Decimal) Double Medi-an(Double) Double Median(Int16) Double Median(Int32)Double Median(Int64) Double Median(Single)

-+--++-+-+-+Byte Min(Byte) Byte Min(StringByte) DateTime Min(DateTime)DateTime Min(StringDateTime) Decimal Min(Decimal)Decimal Min(StringDecimal) Double Min(StringDouble) Int16Min(Int16) Int16 Min(StringInt16) Int32 Min(Int32) Int32Min(StringInt32) Int64 Min(Int64) Int64 Min(StringInt64)Single Min(Single) Single Min(StringSingle) String Min(String)String Min(StringString)

-+--++-+-+-+Double Stddev(Byte) Double Stddev(Decimal) DoubleStddev(Double) Double Stddev(Int16) Double Stddev(Int32)Double Stddev(Int64) Double Stddev(Single) Double

Expression | 51

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Stddev(StringByte) Double Stddev(StringDecimal) DoubleStddev(StringDouble) Double Stddev(StringInt16) DoubleStddev(StringInt32) Double Stddev(StringInt64) DoubleStddev(StringSingle)

-+--++-+-+-+Double Sum(Byte) Double Sum(Decimal) Double Sum(Int16)Double Sum(Int32) Double Sum(Int64) Double Sum(Single)Double Sum(StringByte) Double Sum(StringDecimal) DoubleSum(StringDouble) Double Sum(StringInt16) DoubleSum(StringInt32) Double Sum(StringInt64) DoubleSum(StringSingle)

Conversion Expression Functions

DescriptionFunction Name

Evaluates two expressions and returns the first one if it does notevaluate to NULL the second otherwise The signatures without

NullValue

function name are Boolean(BooleanBoolean) Byte(ByteByte)DateTime(DateTimeDateTime) Decimal(DecimalDecimal)Double(DecimalDouble) Decimal(DecimalInt16 | Int32)Double(DecimalInt64) Single(DecimalSingle)Double(DoubleDecimal | Double | Int16 | Int32 | Int64 | Single)Double(Int16Decimal | Double) Int16(Int16Int16)Int32(Int16Int32) Int64(Int16Int64) Single(Int16Single)Double(Int32Decimal | Double) Int32(Int32Int16 | Int32)Int64(Int32Int64) Double(Int32Single)Double(Int64Decimal |Double | Single) Int64(Int64Int16 | Int32 | Int64)Double(SingleDecimal | Double | Int32 | Int64) Single(SingleInt16| Single) String(StringDecimal | Double | Int16 | Int32 | Int64 |Single | String)

Converts a string with datetime information to a date ToDate(date_string [ format_string]) The default format_string is ldquoDDMON YYYY h24 mm ssrdquo

ToDate

52 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Converts a numeric or string expression to a double ToDouble(numeric | string)

ToDouble

Converts a numeric or string expression to a float ToFloat (numeric| string)

ToFloat

Converts a numeric or string expression to an int32 ToInt32 (nu-meric | string)

ToInt32

Converts a numeric or string expression to an int64 ToInt64 (nu-meric | string)

ToInt64

Converts a numeric or date expression to a string ToString(numer-ic) ToString (DateTime [ format_string]) The default format_stringis ldquoDD-MON-YYYY h24mmssrdquo

ToString

The ToDate function takes a string value representing date andor timeinformation and converts it to a date object The optional format specificationparameter defines the format used in the string to represent the date usingthe abbreviations described in the following table For example for a stringcontaining the date April 2 1998 the format specification should containMonth DD YYYY

The ToString function takes a date value and creates a representation of it ina string The optional format specification parameter allows the user to definethe structure of the string to be created using the abbreviations described inthe following table

DescriptionAbbrevi-ation

Indicates that a year is defined as a two digit number (example 07)YY

Indicates that a year is defined as a four digit number (example 2007)YYYY

Indicates that a month is defined by its name all in uppercase letters (example APRIL)MONTH

Indicates that a month is defined by its name all in lowercase letters (example april)month

Expression | 53

DescriptionAbbrevi-ation

Indicates that a month is defined by its name with the first letter being an uppercaseletter (example April)

Month

Indicates that a month is defined by its abbreviation all in uppercase letters (exampleAPR)

MON

Indicates that a month is defined by its abbreviation all in lowercase letters (exampleapr)

mon

Indicates that a month is defined by its number (example 04)MM

Indicates that a day is defined by its number (example 04)DD

Indicates that a hour is defined by its number in the range [0-24]hh24

Indicates that a hour is defined by its number in the range [1-12]hh12

Represents a default representation of an hour Defaults to hh24hh

Indicates a minute definitionmm

Indicates a second definitionss

Indicates a millisecond definitionms

The meridiem Only considered if used with the time range [1-12] (format hh12)am | pm

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Boolean NullValue(BooleanBoolean) Byte NullValue(ByteByte)DateTime NullValue(DateTimeDateTime) Decimal Null-Value(DecimalDecimal) Decimal NullValue(DecimalInt16)

54 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Decimal NullValue(DecimalInt32) Double NullValue(Decim-alDouble) Double NullValue(DecimalInt64) Double Null-Value(DoubleDecimal) Double NullValue(DoubleDouble)Double NullValue(DoubleInt16) Double NullValue(DoubleInt32)Double NullValue(DoubleInt64) Double Null-Value(DoubleSingle) Double NullValue(Int16Decimal) DoubleNullValue(Int16Double) Double NullValue(Int32Decimal)Double NullValue(Int32Double) Double NullValue(Int32Single)Double NullValue(Int64Decimal) Double Null-Value(Int64Double) Double NullValue(Int64Single) DoubleNullValue(SingleDecimal) Double NullValue(SingleDouble)Double NullValue(SingleInt32) Double NullValue(SingleInt64)Int16 NullValue(Int16Int16) Int32 NullValue(Int16Int32) Int32NullValue(Int32Int16) Int32 NullValue(Int32Int32) Int64 Null-Value(Int16Int64) Int64 NullValue(Int32Int64) Int64 Null-Value(Int64Int16) Int64 NullValue(Int64Int32) Int64 Null-Value(Int64Int64) Single NullValue(DecimalSingle) SingleNullValue(Int16Single) Single NullValue(SingleInt16) SingleNullValue(SingleSingle) String NullValue(StringDecimal) StringNullValue(StringDouble) String NullValue(StringInt16) StringNullValue(StringInt32) String NullValue(StringInt64) StringNullValue(StringSingle) String NullValue(StringString)

-+--++-+-+-+DateTime ToDate(String) DateTime ToDate(StringString)

-+--++-+-+-+Double ToDouble(Byte) Double ToDouble(Decimal) DoubleToDouble(Double) Double ToDouble(Int16) Double To-Double(Int32) Double ToDouble(Int64) Double To-Double(Single) Double ToDouble(String)

-+--++-+-+-+Single ToFloat(Byte) Single ToFloat(Decimal) Single To-Float(Double) Single ToFloat(Int16) Single ToFloat(Int32) SingleToFloat(Int64) Single ToFloat(Single) Single ToFloat(String)

Expression | 55

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Int32 ToInt32(Byte) Int32 ToInt32(Decimal) Int32ToInt32(Double) Int32 ToInt32(Int16) Int32 ToInt32(Int32)Int32 ToInt32(Int64) Int32 ToInt32(Single) Int32 ToInt32(String)

-+--++-+-+-+Int64 ToInt64(Byte) Int64 ToInt64(Decimal) Int64ToInt64(Double) Int64 ToInt64(Int16) Int64 ToInt64(Int32)Int64 ToInt64(Int64) Int64 ToInt64(Single) Int64 ToInt64(String)

-+--++-+-+-+String ToString(Byte) String ToString(DateTime) String To-String(DateTimeString) String ToString(Decimal) String To-String(Double) String ToString(Int16) String ToString(Int32)String ToString(Int64) String ToString(Single)

Date Expression Functions

DescriptionFunction Name

Adds a specified number of months to agiven date expression and returns a Date-Time AddMonths (date_time numeric)

AddMonths

Returns the current date CurrentDate ()CurrentDate

Extracts a specified portion of a date andreturns a DateTime Extract (YEAR|

Extract

MONTH | DAY | HOUR | MINUTE |SECOND date_time)

Calculates the number of months betweentwo provide date expressions and returns

MonthsBetween

56 | Chapter 6 FDO Capabilities

DescriptionFunction Name

a Double MonthsBetween (date_timedate_time)

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+DateTime AddMonths(DateTimeByte) DateTimeAddMonths(DateTimeDecimal) DateTime AddMonths(Date-TimeDouble) DateTime AddMonths(DateTimeInt16) DateTimeAddMonths(DateTimeInt32) DateTime AddMonths(Date-TimeInt64) DateTime AddMonths(DateTimeSingle)

-+--++-+-+-+DateTime CurrentDate()

-+--++-+-+-+DateTime Extract(StringDateTime)

-+--++-+-+-+Double MonthsBetween(DateTimeDateTime)

Geometry Expression Functions

DescriptionFunction Name

Returns a Double which is the area of ageometry Area2D (ltgeometrygt)

Area2D

Returns a Double which is the length of ageometry Length2D (ltgeometrygt)

Length2D

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Area2D(BLOB)

Expression | 57

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Length2D(BLOB)

Mathematical Expression Functions

DescriptionFunction Name

Returns the absolute value of a numeric expression Abs (numeric)The return type is the same as the argument type

Abs

Returns a Double which is the arc cosine of a numeric expressionAcos (numeric)

Acos

Returns a Double which is the arc sine of a numeric expressionAsin (numeric)

Asin

Returns a Double which is the arc tangent of a numeric expressionAtan (numeric)

Atan

Returns a Double which is the arc tangent based on two numericexpressions Atan2 (numeric numeric)

Atan2

Returns a Double which is the cosine of a numeric expression Cos(numeric)

Cos

Returns a Double which is e raised to the power of a numeric ex-pression Exp (numeric)

Exp

Returns a Double which is the natural logarithm of a numeric ex-pression Ln (numeric)

Ln

Returns a Double which is the logarithm of a numeric expressionusing the provided base Log (base_numeric numeric)

Log

58 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Returns the remainder of the division of two numeric expressionsMod (numeric divisior_numeric) The implementation alogirthm

Mod

is Mod (m n) = (sign(m) (abs(m) - (abs(n) Floor(mn)))))mod(154) returns 3 mod(150) returns 15 mod(1162) returns16 mod(11621) returns 11 mod(-154) returns -3 mod(-150)returns -15 The return signatures without the function name areByte(ByteByte | Int16 | Int32 | Int64) Double(ByteDecimal |Double) Single(ByteSingle) Double(Decimal | DoubleByte |Decimal | Double | Int16 | Int32 | Int64 | Single) Int16(Int16Byte| Int16 | Int32 | Int64) Double(Int16Decimal | Double)Single(Int16Single) Int32(Int32Byte) Double(Int32Decimal |Double) Int16(Int32Int16) Int32(Int32Int32 | Int64)Single(Int32Single) Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single) Double(SingleDecimal | Double)

Returns a Double which is the result of a numeric expression raisedto the power of another numeric expression Power (numericpower_numeric)

Power

Returns the remainder of the division of two numeric expressionsRemainder (numeric divisor_numeric) The implementation al-

Remainder

gorithm is Remainder (mn) = (sign(m) (abs(m) - (abs(n) Round(mn)))) remainder(156) returns 3 remainder(155) returns0 remainder(154) returns -1 remainder(1162) returns -04 re-mainder(11621) returns -1 remainder(-154) returns 1 The sig-natures without function name are Int16(ByteByte | Int16)Double(ByteDecimal | Double) Int32(ByteInt32)Int64(ByteInt64) Single(ByteSingle) Double(Decimal |DoubleByte | Decimal | Double | Int16 | Int32 | Int64 | Single)Int16(Int16Byte | Int16 | Int32 | Int32) Double(Int16Decimal |Double) Single(Int16Single) Int32(Int32Byte | Int32 | Int64)Double(Int32Decimal | Double) Int16(Int32Int16)Single(Int32Single)Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single))

Expression | 59

DescriptionFunction Name

Returns a Double which is the sine of a numeric expression Sin(numeric)

Sin

Returns a Double which is the square root of a numeric expressionSqrt (numeric)

Sqrt

Returns a Double which is the tangent of a numeric expressionTan (numeric)

Tan

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Byte Abs(Byte) Decimal Abs(Decimal) Double Abs(Double)Int16 Abs(Int16) Int32 Abs(Int32) Int64 Abs(Int64) SingleAbs(Single)

-+--++-+-+-+Double Acos(Byte) Double Acos(Decimal) Double Acos(Double)Double Acos(Int16) Double Acos(Int32) Double Acos(Int64)Double Acos(Single)

-+--++-+-+-+Double Asin(Byte) Double Asin(Decimal) Double Asin(Double)Double Asin(Int16) Double Asin(Int32) Double Asin(Int64)Double Asin(Single)

-+--++-+-+-+Double Atan(Byte) Double Atan(Decimal) Double Atan(Double)Double Atan(Int16) Double Atan(Int32) Double Atan(Int64)Double Atan(Single)

-+--++-+-+-+Double Atan2(ByteByte) Double Atan2(ByteDecimal) DoubleAtan2(ByteDouble) Double Atan2(ByteInt16) DoubleAtan2(ByteInt32) Double Atan2(ByteInt64) DoubleAtan2(ByteSingle) Double Atan2(DecimalByte) DoubleAtan2(DecimalDecimal) Double Atan2(DecimalDouble) DoubleAtan2(DecimalInt16) Double Atan2(DecimalInt32) DoubleAtan2(DecimalInt64) Double Atan2(DecimalSingle) Double

60 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Atan2(DoubleByte) Double Atan2(DoubleDecimal) DoubleAtan2(DoubleDouble) Double Atan2(DoubleInt16) DoubleAtan2(DoubleInt32) Double Atan2(DoubleInt64) DoubleAtan2(DoubleSingle) Double Atan2(Int16Byte) DoubleAtan2(Int16Decimal) Double Atan2(Int16Double) DoubleAtan2(Int16Int16) Double Atan2(Int16Int32) DoubleAtan2(Int16Int64) Double Atan2(Int16Single) DoubleAtan2(Int32Byte) Double Atan2(Int32Decimal) DoubleAtan2(Int32Double) Double Atan2(Int32Int16) DoubleAtan2(Int32Int32) Double Atan2(Int32Int64) DoubleAtan2(Int32Single) Double Atan2(Int64Byte) DoubleAtan2(Int64Decimal) Double Atan2(Int64Double) DoubleAtan2(Int64Int16) Double Atan2(Int64Int32) DoubleAtan2(Int64Int64) Double Atan2(Int64Single) DoubleAtan2(SingleByte) Double Atan2(SingleDecimal) DoubleAtan2(SingleDouble) Double Atan2(SingleInt16) DoubleAtan2(SingleInt32) Double Atan2(SingleInt64) DoubleAtan2(SingleSingle)

-+--++-+-+-+Double Cos(Byte) Double Cos(Decimal) Double Cos(Double)Double Cos(Int16) Double Cos(Int32) Double Cos(Int64)Double Cos(Single)

-+--++-+-+-+Double Exp(Byte) Double Exp(Decimal) Double Exp(Double)Double Exp(Int16) Double Exp(Int32) Double Exp(Int64)Double Exp(Single)

-+--++-+-+-+Double Ln(Byte) Double Ln(Decimal) Double Ln(Double)Double Ln(Int16) Double Ln(Int32) Double Ln(Int64) DoubleLn(Single)

-+--++-+-+-+Double Log(ByteByte) Double Log(ByteDecimal) DoubleLog(ByteDouble) Double Log(ByteInt16) DoubleLog(ByteInt32) Double Log(ByteInt64) DoubleLog(ByteSingle) Double Log(DecimalByte) DoubleLog(DecimalDecimal) Double Log(DecimalDouble) Double

Expression | 61

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Log(DecimalInt16) Double Log(DecimalInt32) DoubleLog(DecimalInt64) Double Log(DecimalSingle) DoubleLog(DoubleByte) Double Log(DoubleDecimal) DoubleLog(DoubleDouble) Double Log(DoubleInt16) DoubleLog(DoubleInt32) Double Log(DoubleInt64) DoubleLog(DoubleSingle) Double Log(Int16Byte) DoubleLog(Int16Decimal) Double Log(Int16Double) DoubleLog(Int16Int16) Double Log(Int16Int32) DoubleLog(Int16Int64) Double Log(Int16Single) DoubleLog(Int32Byte) Double Log(Int32Decimal) DoubleLog(Int32Double) Double Log(Int32Int16) DoubleLog(Int32Int32) Double Log(Int32Int64) DoubleLog(Int32Single) Double Log(Int64Byte) DoubleLog(Int64Decimal) Double Log(Int64Double) DoubleLog(Int64Int16) Double Log(Int64Int32) DoubleLog(Int64Int64) Double Log(Int64Single) DoubleLog(SingleByte) Double Log(SingleDecimal) DoubleLog(SingleDouble) Double Log(SingleInt16) DoubleLog(SingleInt32) Double Log(SingleInt64) DoubleLog(SingleSingle)

-+--++-+-+-+Byte Mod(ByteByte) Byte Mod(ByteInt16) ByteMod(ByteInt32) Byte Mod(ByteInt64) DoubleMod(ByteDecimal) Double Mod(ByteDouble) DoubleMod(DecimalByte) Double Mod(DecimalDecimal) DoubleMod(DecimalDouble) Double Mod(DecimalInt16) DoubleMod(DecimalInt32) Double Mod(DecimalInt64) DoubleMod(DecimalSingle) Double Mod(DoubleByte) DoubleMod(DoubleDecimal) Double Mod(DoubleDouble) DoubleMod(DoubleInt16) Double Mod(DoubleInt32) DoubleMod(DoubleInt64) Double Mod(DoubleSingle) DoubleMod(Int16Decimal) Double Mod(Int16Double) DoubleMod(Int32Decimal) Double Mod(Int32Double) DoubleMod(Int64Decimal) Double Mod(Int64Double) DoubleMod(SingleDecimal) Double Mod(SingleDouble) Int16Mod(Int16Byte) Int16 Mod(Int16Int16) Int16Mod(Int16Int32) Int16 Mod(Int16Int64) Int16

62 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Mod(Int32Int16) Int16 Mod(Int64Int16) Int32Mod(Int32Byte) Int32 Mod(Int32Int32) Int32Mod(Int32Int64) Int32 Mod(Int64Int32) Int64Mod(Int64Byte) Int64 Mod(Int64Int64) SingleMod(ByteSingle) Single Mod(Int16Single) SingleMod(Int32Single) Single Mod(Int64Single) SingleMod(SingleByte) Single Mod(SingleInt16) SingleMod(SingleInt32) Single Mod(SingleInt64) SingleMod(SingleSingle)

-+--++-+-+-+Double Power(ByteByte) Double Power(ByteDecimal) DoublePower(ByteDouble) Double Power(ByteInt16) DoublePower(ByteInt32) Double Power(ByteInt64) DoublePower(ByteSingle) Double Power(DecimalByte) DoublePower(DecimalDecimal) Double Power(DecimalDouble) DoublePower(DecimalInt16) Double Power(DecimalInt32) DoublePower(DecimalInt64) Double Power(DecimalSingle) DoublePower(DoubleByte) Double Power(DoubleDecimal) DoublePower(DoubleDouble) Double Power(DoubleInt16) DoublePower(DoubleInt32) Double Power(DoubleInt64) DoublePower(DoubleSingle) Double Power(Int16Byte) DoublePower(Int16Decimal) Double Power(Int16Double) DoublePower(Int16Int16) Double Power(Int16Int32) DoublePower(Int16Int64) Double Power(Int16Single) DoublePower(Int32Byte) Double Power(Int32Decimal) DoublePower(Int32Double) Double Power(Int32Int16) DoublePower(Int32Int32) Double Power(Int32Int64) DoublePower(Int32Single) Double Power(Int64Byte) DoublePower(Int64Decimal) Double Power(Int64Double) DoublePower(Int64Int16) Double Power(Int64Int32) DoublePower(Int64Int64) Double Power(Int64Single) DoublePower(SingleByte) Double Power(SingleDecimal) DoublePower(SingleDouble) Double Power(SingleInt16) DoublePower(SingleInt32) Double Power(SingleInt64) DoublePower(SingleSingle)

Expression | 63

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Remainder(ByteDecimal) Double Re-mainder(ByteDouble) Double Remainder(DecimalByte) DoubleRemainder(DecimalDecimal) Double Remainder(Decim-alDouble) Double Remainder(DecimalInt16) Double Re-mainder(DecimalInt32) Double Remainder(DecimalInt64)Double Remainder(DecimalSingle) Double Re-mainder(DoubleByte) Double Remainder(DoubleDecimal)Double Remainder(DoubleDouble) Double Re-mainder(DoubleInt16) Double Remainder(DoubleInt32)Double Remainder(DoubleInt64) Double Re-mainder(DoubleSingle) Double Remainder(Int16Decimal)Double Remainder(Int16Double) Double Re-mainder(Int32Decimal) Double Remainder(Int32Double)Double Remainder(Int64Decimal) Double Re-mainder(Int64Double) Double Remainder(SingleDecimal)Double Remainder(SingleDouble) Int16 Remainder(ByteByte)Int16 Remainder(ByteInt16) Int16 Remainder(Int16Byte) Int16Remainder(Int16Int16) Int16 Remainder(Int16Int32) Int16Remainder(Int16Int64) Int16 Remainder(Int32Int16) Int16Remainder(Int64Int16) Int32 Remainder(ByteInt32) Int32 Re-mainder(Int32Byte) Int32 Remainder(Int32Int32) Int32 Re-mainder(Int32Int64) Int32 Remainder(Int64Int32) Int64 Re-mainder(ByteInt64) Int64 Remainder(Int64Byte) Int64 Re-mainder(Int64Int64) Single Remainder(ByteSingle) Single Re-mainder(Int16Single) Single Remainder(Int32Single) SingleRemainder(Int64Single) Single Remainder(SingleByte) SingleRemainder(SingleInt16) Single Remainder(SingleInt32) SingleRemainder(SingleInt64) Single Remainder(SingleSingle)

-+--++-+-+-+Double Sin(Byte) Double Sin(Decimal) Double Sin(Double)Double Sin(Int16) Double Sin(Int32) Double Sin(Int64) DoubleSin(Single)

-+--++-+-+-+Double Sqrt(Byte) Double Sqrt(Decimal) Double Sqrt(Double)Double Sqrt(Int16) Double Sqrt(Int32) Double Sqrt(Int64)Double Sqrt(Single)

64 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Tan(Byte) Double Tan(Decimal) Double Tan(Double)Double Tan(Int16) Double Tan(Int32) Double Tan(Int64)Double Tan(Single)

Numeric Expression Functions

DescriptionFunction Name

Returns the smallest integer greater than or equal to a numeric ex-pression The return type is the same as the argument type Where

Ceil

the argument is a Decimal Double or Single the returned value isan integral number Ceil(numeric)

Returns the largest integer less than or equal to a numeric expres-sion The return type is the same as the argument type Where the

Floor

argument is a Decimal Double or Single the returned value is anintegral number Floor (numeric)

Returns the rounded value of a numeric expression The return typeis the same as the type of the first argument Round (numeric [number_of_decimals_numeric])

Round

Returns and Int32 which is -1 if the provided numeric expressionevaluates to a value less than 0 0 if the expression evaluates to 0

Sign

and 1 if the expression evaluates to a value bigger than 0 Sign(numeric)

Truncates a numeric or date expression The return type is the sameas the type of the first argument Trunc (date_time YEAR | MONTH

Trunc

Expression | 65

DescriptionFunction Name

| DAY | HOUR | MINUTE) Trunc (numeric [ number_of_decim-als_numeric])

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+++Int64 Ceil(Int64)

-+--++-+-+++Int64 Floor(Int64)

-+--++-+-+-+Byte Ceil(Byte) Decimal Ceil(Decimal) Double Ceil(Double)Int16 Ceil(Int16) Int32 Ceil(Int32) Single Ceil(Single)

-+--++-+-+-+Byte Floor(Byte) Decimal Floor(Decimal) DoubleFloor(Double) Int16 Floor(Int16) Int32 Floor(Int32) SingleFloor(Single)

-+--++-+-+-+Byte Round(Byte) Byte Round(ByteByte) ByteRound(ByteDecimal) Byte Round(ByteDouble) ByteRound(ByteInt16) Byte Round(ByteInt32) ByteRound(ByteInt64) Byte Round(ByteSingle) DecimalRound(Decimal) Decimal Round(DecimalByte) DecimalRound(DecimalDecimal) Decimal Round(DecimalDouble)Decimal Round(DecimalInt16) Decimal Round(Decim-alInt32) Decimal Round(DecimalInt64) DecimalRound(DecimalSingle) Double Round(Double) DoubleRound(DoubleByte) Double Round(DoubleDecimal) DoubleRound(DoubleDouble) Double Round(DoubleInt16) DoubleRound(DoubleInt32) Double Round(DoubleInt64) DoubleRound(DoubleSingle) Int16 Round(Int16) Int16Round(Int16Byte) Int16 Round(Int16Decimal) Int16Round(Int16Double) Int16 Round(Int16Int16) Int16Round(Int16Int32) Int16 Round(Int16Int64) Int16Round(Int16Single) Int32 Round(Int32) Int32Round(Int32Byte) Int32 Round(Int32Decimal) Int32Round(Int32Double) Int32 Round(Int32Int16) Int32

66 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Round(Int32Int32) Int32 Round(Int32Int64) Int32Round(Int32Single) Int64 Round(Int64) Int64Round(Int64Byte) Int64 Round(Int64Decimal) Int64Round(Int64Double) Int64 Round(Int64Int16) Int64Round(Int64Int32) Int64 Round(Int64Int64) Int64Round(Int64Single) Single Round(Single) SingleRound(SingleByte) Single Round(SingleDecimal) SingleRound(SingleDouble) Single Round(SingleInt16) SingleRound(SingleInt32) Single Round(SingleInt64) SingleRound(SingleSingle)

-+--++-+-+-+Int32 Sign(Byte) Int32 Sign(Decimal) Int32 Sign(Double)Int32 Sign(Int16) Int32 Sign(Int32) Int32 Sign(Int64) Int32Sign(Single)

-+--++-+-+-+Byte Trunc(Byte) Byte Trunc(ByteByte) ByteTrunc(ByteDecimal) Byte Trunc(ByteDouble) ByteTrunc(ByteInt16) Byte Trunc(ByteInt32) ByteTrunc(ByteInt64) Byte Trunc(ByteSingle) DateTimeTrunc(DateTimeString) Decimal Trunc(Decimal) DecimalTrunc(DecimalByte) Decimal Trunc(DecimalDecimal)Decimal Trunc(DecimalDouble) Decimal Trunc(Decim-alInt16) Decimal Trunc(DecimalInt32) DecimalTrunc(DecimalInt64) Decimal Trunc(DecimalSingle) DoubleTrunc(Double) Double Trunc(DoubleByte) DoubleTrunc(DoubleDecimal) Double Trunc(DoubleDouble)Double Trunc(DoubleInt16) Double Trunc(DoubleInt32)Double Trunc(DoubleInt64) Double Trunc(DoubleSingle)Int16 Trunc(Int16) Int16 Trunc(Int16Byte) Int16Trunc(Int16Decimal) Int16 Trunc(Int16Double) Int16Trunc(Int16Int16) Int16 Trunc(Int16Int32) Int16Trunc(Int16Int64) Int16 Trunc(Int16Single) Int32Trunc(Int32) Int32 Trunc(Int32Byte) Int32Trunc(Int32Decimal) Int32 Trunc(Int32Double) Int32Trunc(Int32Int16) Int32 Trunc(Int32Int32) Int32Trunc(Int32Int64) Int32 Trunc(Int32Single) Int64Trunc(Int64) Int64 Trunc(Int64Byte) Int64

Expression | 67

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Trunc(Int64Decimal) Int64 Trunc(Int64Double) Int64Trunc(Int64Int16) Int64 Trunc(Int64Int32) Int64Trunc(Int64Int64) Int64 Trunc(Int64Single) SingleTrunc(Single) Single Trunc(SingleByte) SingleTrunc(SingleDecimal) Single Trunc(SingleDouble) SingleTrunc(SingleInt16) Single Trunc(SingleInt32) SingleTrunc(SingleInt64) Single Trunc(SingleSingle)

String Expression Functions

All of these functions return a string

DescriptionFunction Name

Returns the concatenation of two string expressions Concat(boolean | date | numeric | string boolean | date | numeric |string)

Concat

Returns an Int64 which is the position of a substring in a stringexpression Instr(stringstring)

Instr

Returns an Int64 which is the length of a string expressionLength(string)

Length

Converts all uppercase letters in a string expression into lowercaseletters string Lower (string)

Lower

Pads a string expression to the left to a predefined string lengthstring Lpad (string TotalLengthOfResult [ pad-string]) If used withtwo parameters only the pad-string is a single space character

Lpad

Removes leading blanks from a string expression string Ltrim(string)

Ltrim

68 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Pads a string expression to the right to a predefined string lengthstring Rpad (string TotalLengthOfResult [ pad-string]) If used

Rpad

with two parameters only the pad-string is a single space character

Removes trailing blanks from a string expression string Rtrim(string)

Rtrim

Returns a string which is the phonetic representation of a stringexpression See the entry in Wikipedia for more information ht-

Soundex

tpenwikipediaorgwikiSoundex Soundex (string) Soun-dex(lsquoeightrsquo) returns ldquoE230rdquo and Soundex(lsquoexpressionrsquo) returnsldquoE216rdquo

Extracts a substring from a string expression string Substr (stringstart_pos [ length])

Substr

Replaces a set of letters in a string Translate (string from_set_stringto_set_string) If string is ldquoSQLPlus Users Guiderdquo and

Translate

from_set_string is thatis lsquospaceasteriskforward slashsingle quotesingle quotersquo and the to_set_string is___ that islsquounderscoreunderscoreunderscorersquo then the returned stringis lsquoSQL_PLus_Users_Guidersquo Translate looks for each character inthe from_set_string in the string argument and replaces it with thecorresponding character from the to_set_string In this case twospaces are replace by underscores and an asterisk is replaced by nunderscore There is no forward slash in the target string to be re-placed and there is no replacement character in the to_set_stringcorresponding to the single apostrophe character in thefrom_set_string When there is no replacement character in theto_set_string corresponding to a character in the from_set_stringthe character in the from_set_string is removed wherever it is foundin the target string

Removes leading andor trailing blanks from a string expressionTrim ([BOTH | LEADING | TRAILING ] string)

Trim

Expression | 69

DescriptionFunction Name

Converts all lowercase letters in a string expression into uppercaseletters Upper (string)

Upper

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+++++String Concat(StringString)

-+--++-+-+-+String Concat(BooleanBoolean) String Concat(BooleanByte)String Concat(BooleanDateTime) String Concat(BooleanDecim-al) String Concat(BooleanDouble) String Concat(BooleanInt16)String Concat(BooleanInt32) String Concat(BooleanInt64) StringConcat(BooleanSingle) String Concat(BooleanString) StringConcat(ByteBoolean) String Concat(ByteByte) String Con-cat(ByteDateTime) String Concat(ByteDecimal) String Con-cat(ByteDouble) String Concat(ByteInt16) String Con-cat(ByteInt32) String Concat(ByteInt64) String Con-cat(ByteSingle) String Concat(ByteString) String Concat(Date-TimeBoolean) String Concat(DateTimeByte) String Concat(Dat-eTimeDateTime) String Concat(DateTimeDecimal) StringConcat(DateTimeDouble) String Concat(DateTimeInt16) StringConcat(DateTimeInt32) String Concat(DateTimeInt64) StringConcat(DateTimeSingle) String Concat(DateTimeString) StringConcat(DecimalBoolean) String Concat(DecimalByte) StringConcat(DecimalDateTime) String Concat(DecimalDecimal)String Concat(DecimalDouble) String Concat(DecimalInt16)String Concat(DecimalInt32) String Concat(DecimalInt64)String Concat(DecimalSingle) String Concat(DecimalString)String Concat(DoubleBoolean) String Concat(DoubleDateTime)String Concat(DoubleDecimal) String Concat(DoubleDouble)String Concat(DoubleInt16) String Concat(DoubleInt32) StringConcat(DoubleInt64) String Concat(DoubleSingle) StringConcat(DoubleString) String Concat(Int16Boolean) StringConcat(Int16Byte) String Concat(Int16DateTime) String Con-cat(Int16Decimal) String Concat(Int16Double) String Con-cat(Int16Int16) String Concat(Int16Int32) String Con-cat(Int16Int64) String Concat(Int16Single) String Con-

70 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

cat(Int16String) String Concat(Int32Boolean) String Con-cat(Int32Byte) String Concat(Int32DateTime) String Con-cat(Int32Decimal) String Concat(Int32Double) String Con-cat(Int32Int16) String Concat(Int32Int32) String Con-cat(Int32Int64) String Concat(Int32Single) String Con-cat(Int32String) String Concat(Int64Boolean) String Con-cat(Int64Byte) String Concat(Int64DateTime) String Con-cat(Int64Decimal) String Concat(Int64Double) String Con-cat(Int64Int16) String Concat(Int64Int32) String Con-cat(Int64Int64) String Concat(Int64Single) String Con-cat(Int64String) String Concat(SingleBoolean) String Con-cat(SingleByte) String Concat(SingleDateTime) String Con-cat(SingleDecimal) String Concat(SingleDouble) String Con-cat(SingleInt16) String Concat(SingleInt32) String Con-cat(SingleInt64) String Concat(SingleSingle) String Con-cat(SingleString) String Concat(StringBoolean) String Con-cat(StringByte) String Concat(StringDateTime) String Con-cat(StringDecimal) String Concat(StringDouble) String Con-cat(StringInt16) String Concat(StringInt32) String Con-cat(StringInt64) String Concat(StringSingle)

-+--++-+-+-+Int64 Instr(StringString)

-+--++-+-+-+Int64 Length(String)

-+--++-+-+-+String Lower(String)

-+--++-+-+-+String Lpad(StringByte) String Lpad(StringByteString) StringLpad(StringDecimal) String Lpad(StringDecimalString) StringLpad(StringDouble) String Lpad(StringDoubleString) StringLpad(StringInt16) String Lpad(StringInt16String) StringLpad(StringInt32) String Lpad(StringInt32String) StringLpad(StringInt64) String Lpad(StringInt64String) StringLpad(StringSingle) String Lpad(StringSingleString)

-+--++-+-+-+String Ltrim(String)

Expression | 71

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+String Rpad(StringByte) String Rpad(StringByteString) StringRpad(StringDecimal) String Rpad(StringDecimalString) StringRpad(StringDouble) String Rpad(StringDoubleString) StringRpad(StringInt16) String Rpad(StringInt16String) StringRpad(StringInt32) String Rpad(StringInt32String) StringRpad(StringInt64) String Rpad(StringInt64String) StringRpad(StringSingle) String Rpad(StringSingleString)

-+--++-+-+-+String Rtrim(String)

-+--++-+-+-+String Soundex(String)

-+--++-+-+-+String Substr(StringByte) String Substr(StringByteByte) StringSubstr(StringByteDecimal) String Substr(StringByteDouble)String Substr(StringByteInt16) String Substr(StringByteInt32)String Substr(StringByteInt64) String Substr(StringByteSingle)String Substr(StringDecimal) String Substr(StringDecimalByte)String Substr(StringDecimalDecimal) String Substr(StringDecim-alDouble) String Substr(StringDecimalInt16) String Sub-str(StringDecimalInt32) String Substr(StringDecimalInt64)String Substr(StringDecimalSingle) String Substr(StringDouble)String Substr(StringDoubleByte) String Sub-str(StringDoubleDecimal) String Substr(StringDoubleDouble)String Substr(StringDoubleInt16) String Sub-str(StringDoubleInt32) String Substr(StringDoubleInt64) StringSubstr(StringDoubleSingle) String Substr(StringInt16) StringSubstr(StringInt16Byte) String Substr(StringInt16Decimal)String Substr(StringInt16Double) String Sub-str(StringInt16Int16) String Substr(StringInt16Int32) StringSubstr(StringInt16Int64) String Substr(StringInt16Single)String Substr(StringInt32) String Substr(StringInt32Byte) StringSubstr(StringInt32Decimal) String Substr(StringInt32Double)String Substr(StringInt32Int16) String Substr(StringInt32Int32)String Substr(StringInt32Int64) String Substr(StringInt32Single)String Substr(StringInt64) String Substr(StringInt64Byte) StringSubstr(StringInt64Decimal) String Substr(StringInt64Double)

72 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

String Substr(StringInt64Int16) String Substr(StringInt64Int32)String Substr(StringInt64Int64) String Substr(StringInt64Single)String Substr(StringSingle) String Substr(StringSingleByte)String Substr(StringSingleDecimal) String Sub-str(StringSingleDouble) String Substr(StringSingleInt16) StringSubstr(StringSingleInt32) String Substr(StringSingleInt64)String Substr(StringSingleSingle)

-+--++-+-+-+String Translate(StringStringString)

-+--++-+-+-+String Trim(String) String Trim(StringString)

-+--++-+-+-+String Upper(String)

----------+-String Lower(StringString)

----------+-String Upper(StringString)

Miscellaneous Expression Functions

The following functions were not affected by the introduction of the ExpressionBuilder component in FDO 33

DescriptionFunction Name

Returns a geometry that is the subset of the geometry argumentdefined by the polygon specified by the coordinate argumentsCLIP(BLOBDoubleDoubleDoubleDouble)

CLIP

Returns a geometry MOSAIC(BLOB)MOSAIC

Returns a geometry RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

RESAMPLE

Expression | 73

DescriptionFunction Name

Returns a geometry SpatialExtent(BLOB)SpatialExtent

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----BLOB CLIP(BLOBDoubleDoubleDoubleDouble)

--+---+-----BLOB RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

--+---------BLOB SpatialExtents(BLOB)

------+-----BLOB MOSAIC(BLOB)

Filter

In C you access theOSGeoFDOConnectionsCapabilitiesIFilterCapabilities using theIConnection object (connectionFilterCapabilities)

In C++ you access the FdoIFilterCapabilities using the IConnection object(connection-gtGetFilterCapabilities())

DescriptionCapability

Tests if the value of a specified data property is within a givenset of literal values

ConditionType_In

Tests if one expression is equal not equal greater than lessthan greater than or equal to or less than or equal to anotherexpression

ConditionType_Comparison

Tests whether the value of a geometric property is within orbeyond a specified distance of a literal geometric value

ConditionType_Distance

74 | Chapter 6 FDO Capabilities

DescriptionCapability

Tests whether the value of a specified data property matchesa specified pattern

ConditionType_Like

Tests whether the value of a specified data property is nullConditionType_Null

Tests whether the value of a geometric property and a literalgeometric value satisfy the spatial relationship implied by theoperation

ConditionType_Spatial

Tests whether the geometric property value lies beyond aspecified distance of a literal geometric value

DistanceOperations_Beyond

Tests whetherthe geometric property value lies within a spe-cified distance of a literal geometric value

DistanceOperations_Within

Tests whetherthe geometric property value spatially containsthe literal geometric value

SpatialOperations_Contains

Tests whether the geometric property value is covered by theinterior and boundary of the given geometry

SpatialOperations_CoveredBy

Tests whetherthe geometric property value spatially crossesthe given geometry

SpatialOperations_Crosses

Tests whether the geometric property value is spatially disjointfrom the given geometry

SpatialOperations_Disjoint

Tests whether the envelope of the referenced geometricproperty value spatially intersects the given geometry

SpatialOperations_EnvelopeIntersects

Tests whether the geometric property value is spatially equalto the given geometry

SpatialOperations_Equals

Tests whether the geometric property value is inside the in-terior of the given geometry not touching the boundary

SpatialOperations_Inside

Filter | 75

DescriptionCapability

Tests whether the geometric property value spatially intersectsthe given geometry

SpatialOperations_Intersects

Tests whether the geometric property value spatially overlapsthe given geometry

SpatialOperations_Overlaps

Tests whether the geometric property value spatially touchesthe given geometry

SpatialOperations_Touches

Tests whether the geometric property value is spatially withinthe given geometry

SpatialOperations_Within

Tests whether the spatial and distance operations can be ap-plied between two geometric properties Returns false if spatial

SupportsNonLiteralGeometricOperations

and distance operations can be applied only between a geo-metric property and a literal geometry Returns true if spatialand distance operations can be applied

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++++++++SpatialOperations_EnvelopeIntersects ConditionType_In Condi-tionType_Spatial

-+--++++++++SpatialOperations_Intersects

++--++-+++++ConditionType_Null ConditionType_Comparison Condition-Type_Like

-+--+++++-++SpatialOperations_Inside

-+--+++-+-++SpatialOperations_Within

-------+++-+ConditionType_Distance

76 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-----+--+-++SpatialOperations_Disjoint SpatialOperations_Contains

--------+-++SpatialOperations_CoveredBy SpatialOperations_Crosses Spa-tialOperations_Touches SpatialOperations_Equals SpatialOper-ations_Overlaps

--------+--+DistanceOperations_Beyond DistanceOperations_Within

---+--------SupportsNonLiteralGeometricOperations

------------SupportsGeodesicDistance

Geometry

In C you access theOSGeoFDOConnectionsCapabilitiesIGeometryCapabilities using theIConnection object (connectionGeometryCapabilities)

In C++ you access the FdoIGeometryCapabilities using the IConnectionobject (connection-gtGetGeometryCapabilities())

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++FdoDimensionality_XY

+-++++-+++++GeometryType_Polygon GeometryComponentType_Linear-Ring

++-+++-+++++GeometryType_Point

Geometry | 77

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

+--+++-+++++GeometryType_MultiLineString GeometryType_MultiPointGeometryType_LineString

+--+-+-+++++GeometryType_MultiPolygon

+--+++-+--++GeometryComponentType_LineStringSegment

---+++--+-++FdoDimensionality_M FdoDimensionality_Z

+--+-+-+--+-GeometryComponentType_Ring

+--+-+--+-+-GeometryType_MultiGeometry

---+-+-+--+-GeometryType_CurvePolygon GeometryComponentType_Cir-cularArcSegment GeometryType_CurveString Geometry-Type_MultiCurvePolygon GeometryType_MultiCurveString

Raster

In C you access theOSGeoFDOConnectionsCapabilitiesIRasterCapabilities using theIConnection object (connectionRasterCapabilities)

In C++ you access the FdoIRasterCapabilities using the IConnection object(connection-gtGetRasterCapabilities())

DescriptionCapability

Indicates whether or not a provider supports the retrieval andmanipulation of image data

SupportsRaster

Indicates whether or not a provider supports the reduction ofthe amount of detail and data in the image

SupportsSubsampling

78 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the compositionof multiple raster images

SupportsStitching

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----SupportsRaster SupportsSubsampling

------------SupportsStitching

Schema

In C you access theOSGeoFDOConnectionsCapabilitiesISchemaCapabilities using theIConnection object (connectionSchemaCapabilities)

In C++ you access the FdoISchemaCapabilities using the IConnection object(connection-gtGetSchemaCapabilities())

DescriptionCapability

Indicates whether or not a provider supports auto gener-ation of values for the data types represented by the as-terisk Boolean Byte DateTime and Decimal

AutoGenerated_

Indicates whether or not a provider supports the Classtype which does not have a Geometry property

ClassType_Class

Indicates whether or not a provider supports the Classtype which does have a Geometry property

ClassType_FeatureClass

Indicates whether or not a provider supports the spe-cificdata type that replaces the BLOB Boolean Byte

DataType_

Schema | 79

DescriptionCapability

CLOB DateTime Decimal Double Int16 Int32 Int64Single or String

Indicates whether or not a provider supports the use ofthe property types represented by the asterisk as identity

IdentityProperty_

properties BLOB Boolean Byte DateTime DecimalDouble Int16 Int32 Int64 Single and String

Indicates whether or not a provider supports decimals upto the specified number of digits in length

MaximumDecimalPrecision

Indicates whether or not a provider supports decimalswith up to the specified number of digits to the right ofthe decimal point

MaximumDecimalScale

The set of characters which cannot be used in schemaelement names

ReservedCharactersForName

Indicates whether or not a provider supports the associ-ation property

SupportsAssociationProperties

Indicates whether or not a provider supports the automat-ic generation of id property values

SupportsAutoIdGeneration

Indicates whether or not a provider supports multipleidentity properties per class

SupportsCompositeId

Indicates whether or not a provider supports unique valueconstraints on a set of columns

SupportsCompositeUniqueValueConstraints

Indicates whether or not a provider supports the automat-ic generation of ID values that are unique for the entiredatastore rather than just for a particular class

SupportsDataStoreScopeUniqueIdGeneration

Indicates whether or not a provider supports the specific-ation of default values for property definitions

SupportsDefaultValue

80 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the settingof minimums that the input data must greater than andmaximums that the input data must be less than

SupportsExclusiveValueRangeConstraints

Indicates whether or not a provider supports the settingof minimums that the input data must greater than or

SupportsInclusiveValueRangeConstraints

equal to and maximums that the input data must be lessthan or equal to

Indicates whether or not a provider supports class hier-archies in the feature schema

SupportsInheritance

Indicates whether or not a provider supports the definitionof more than one feature schema in the data store

SupportsMultipleSchemas

Indicates whether or not a provider allows property valuesto be null

SupportsNullValueConstraints

Indicates whether or not a provider supports objectproperties A class instance can contain an instance ofanother class

SupportsObjectProperties

Indicates whether or not a provider supports the modific-ation of a schema after its intitial creation

SupportsSchemaModification

Indicates whether or not a provider supports the overrid-ing of the default rules for mapping feature schemas toprovider-specific physical schemas

SupportsSchemaOverrides

Indicates whether or not a provider supports requiringthat a column contain unique values

SupportsUniqueValueConstraints

Indicates whether or not a provider supports requiringthat a column contain values that belong to a value con-straints list

SupportsValueConstraintsList

Schema | 81

Expressible as Boolean

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ClassType_FeatureClass DataType_String

++-+++-+++++IdentityProperty_Int32 DataType_Int32 DataType_DateTimeClassType_Class

++-+-+-+++++DataType_Double

--++-+++++++IdentityProperty_String

-+-+-+-+++++DataType_Int16 DataType_Single IdentityProperty_Int16

-+--++-+++++SupportsAutoIdGeneration SupportsNullValueConstraints

-++-+-+++++-SupportsSchemaOverrides

-+-+++-++++-DataType_Decimal DataType_Boolean

++--++--+-++AutoGenerated_Int32

-+++-+++-+--SupportsInheritance

-+-+-+-++++-DataType_Byte IdentityProperty_Int64 DataType_Int64

---+-+-+++++IdentityProperty_Double IdentityProperty_DateTime Identi-tyProperty_Single

-+-+--++-+++SupportsMultipleSchemas

-+-+-+-+++--SupportsCompositeId

82 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+ReservedCharactersForName

----++-++++-SupportsSchemaModification

-+--+--+++-+MaximumDecimalPrecision MaximumDecimalScale

---+-+-++++-IdentityProperty_Boolean IdentityProperty_Decimal Identi-tyProperty_Byte

-------+++-+SupportsCompositeUniqueValueConstraints SupportsUnique-ValueConstraints

-+-----+++--AutoGenerated_Int64 SupportsDefaultValue

---+-+-+-+--SupportsAssociationProperties

--+---+----+DataType_BLOB

---+---+-+--SupportsObjectProperties

-------+-+--SupportsDataStoreScopeUniqueIdGeneration

-----+-+----SupportsValueConstraintsList SupportsExclusiveValueRangeCon-straints SupportsInclusiveValueRangeConstraints

Not Expressible as a Boolean

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

3838ArcSDE

Schema | 83

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

6565MySQL

10001000nullPostGIS

3838SQLServerSpa-tial

nullnullSDF

255255SHP

2828ODBC

84 | Chapter 6 FDO Capabilities

Schema Management

This chapter describes how to create and work with schemas and explains some issues relatedto schema management For example you can use the FDO feature schema to specify howto represent geospatial features

Schema PackageThe FDO feature schema provides a logical mechanism for specifying how torepresent geospatial features FDO providers are responsible for mapping thefeature schema to some underlying physical data store The FDO feature schemais based somewhat on a subset of the OpenGIS and ISO feature models Itsupports both non-spatial features and spatial features

The Schema package contains a collection of classes that define the logicalfeature schema These classes can be used to set up a feature schema and tointerrogate the metadata from a provider using an object-oriented structureThe logical feature schema provides a logical view of geospatial feature data thatis fully independent from the underlying storage schema All data operationsin FDO are performed against the classes and relationships defined by the logicalfeature schema For example different class types in the feature schema are usedto describe different types of geospatial objects and spatial features

Base Properties

All classes in the feature schema support the concept of base properties whichare properties that are pre-defined either by the FDO API or by a specific FDOfeature provider For example all classes in the schema have two base propertiesClassName and SchemaName These properties can be used to query across aninheritance hierarchy or to process the results of heterogeneous queries FDO

7

85

feature providers can also predefine base properties The following baseproperties are predefined by the FDO API

DescriptionRequiredProperty Name

Name of the schema to which objects of the classbelong read-only string

YSchemaName

Name of the class that defines the object read-onlystring

YClassName

Revision number of the object read-only 64-bit in-teger

NRevisionNumber

NOTE Some providers may use this property tosupport optimistic locking

Cross-Schema References

Some FDO feature providers may support multiple schemas For these providersthe feature schema supports the concept of cross-schema references for classesThis means that a class in one schema may derive from a class in anotherschema relate to a class in another schema or contain an object propertydefinition that is based on a class in another schema

Parenting in the Schema Classes

The feature schema object model defined in the FDO API supports fullnavigation through parenting That is once a schema element is added to anFdoFeatureSchema class it can navigate the object hierarchy upward to theroot FdoFeatureSchema and from there to any other element in the featureschema This parenting support is fully defined in the FdoSchemaElementabstract base class

When inserting features that have object collections the parent object instancemust be identified when inserting the child objects (for example a parentclass ldquoRoadrdquo has an object property called ldquosidewalksrdquo of type ldquoSidewalkrdquo)For more information see Data Maintenance on page 119

Physical Mappings

Each feature provider maps the logical feature schema to an underlyingphysical data store Some feature providers may provide some level of control

86 | Chapter 7 Schema Management

over how the logical schema gets mapped to the underlying physical storageFor example an RDBMS-based feature provider may allow table and columnnames to be specified for classes and properties Since this is entirelyprovider-dependent the FDO API simply provides abstract classes for passingphysical schema and class mappings to the provider(FdoPhysicalSchemaMapping FdoPhysicalClassMappingFdoPhysicalPropertyMapping and FdoPhysicalElementMapping respectively)The implementation of these abstract classes is up to each feature provider

Schema MappingsWhen a provider connects to a data source that it did not create and does adescribe schema command it will map FDO data types to the physical entitescontained in the data source This mapping is called the default schemamapping or alternatively the physical to logical schema mapping

When reverse engineering an existing schema FDO uses the following rulesto select the column(s) to use as the identity property

1 Use the primary key

2 Use a unique index

3 Treat the data as read-only

NOTE When reverse engineering a view FDO will apply rules 1 and 2 to the viewand then if necessary to the base tables

NOTE If FDO detects more than one unique index it calculates a weight for eachindex and selects the lightest one The weight of each index is the sum of theweights of its columns Column weight depends on column type as follows Indexeswith Blobs or Clobs are not chosen If FDO picks a multi-column index as theunique index it creates an identity property for each column in the index

1 for Boolean or Byte

2 for Int16

4 for Int32

8 for Int64 Decimal Double or Float

50 for DateTime

length for String

Schema Mappings | 87

After you use FDO to create a feature schema you can use external means toaccess the data store to inspect what native data types FDO uses for its logicaltypes This mapping is called the logical to physical schema mapping

The following mappings have been documented in the provider appendices

physical to logical schema mappings for ODBC connections to a MicrosoftAccess database an Excel spreadsheet and a text file

physical to logical and logical to physical schema mappings for OracleMySQL Sql Server and Sql Server Spatial

The mechanism for overriding the default schema mapping is described inthe next topic Sample code is located in the FDO Cookbook chapter of thisdocument

Schema OverridesUsing schema overrides FDO applications can customize the mappingsbetween Feature (logical) Schemas and the Physical Schema of the providerdata store

Schema overrides are provider-specific because different FDO providers supportFDO data stores with widely different physical formats Therefore the typesof schema mappings in these overrides also vary between providers Forexample an RDBMS-type provider might provide a mapping to index a set ofcolumns in a class table However other providers would not necessarily beable to work with the concept of an index For information about schemaoverrides support by a specific provider see the appropriate appendix in thisdocument and The Essential FDO

NOTE Some providers support only default schema mappings

Working with SchemasThere are three primary operations involved with schema management

Creating a schema

Describing a schema

Modifying a schema

88 | Chapter 7 Schema Management

Creating a Schema

The following basic steps are required to create a schema (some steps areoptional some may be done in an alternate order to achieve the same result)

Use the FdoFeatureSchemaCreate(ldquoSchemaNamerdquo ldquoFeatureSchemaDescriptionrdquo) method to create a schema

Use the FdoFeatureSchemaGetClasses() method to return a class collection

Use the FdoClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) orFdoFeatureClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) method to createFdoClass or FdoFeatureClass type objects

Use the FdoClassCollectionAdd(class) method to add FdoClass orFdoFeatureClass objects to the class collection

Use the FdoGeometricPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoGeometryProperty

Use the FdoDataPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo) methodto create FdoDataProperty

Use the FdoObjectPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoObjectProperty

Use the FdoClassDefinitionGetProperties() and Add(property) methodsto add property to class definition

Use the FdoIApplySchemaCommandSetFeatureSchema(feature schema)method to set the schema object for the IFdoApplySchemaCommand

Use the FdoAssociationPropertydefinition class to represent the associationbetween two classes The class of the associated class must already bedefined in the feature schema and cannot be abstract

Use the FdoIApplySchemaCommandExecute() method to execute changesto the feature schema

For an example of schema creation see Example Creating a Feature Schemaon page 111

Use the FdoClassDefinitionGetIdentityProperties() and Add(Property Object)methods to set the property as FdoClass or FdoFeatureClass Identifier FDOallows multiple Identifiers for both types of classes although Identifiers haveslight differences in both cases

Working with Schemas | 89

FDOFeatureClassFdoFeatureClass is a class that defines features In the case of GIS they wouldoften be spatial features having some sort of geometry associated with themIn most providers FdoFeatureClass requires a unique identifier to distinguishthe features

However there are identifiers only if no base class exists If the base class hasan identifier the child class does not have one You cannot set an identifierto the child class Any class definition that has a base class cannot also haveany identity properties because it inherits from the base class

Therefore you cannot send an identifier when a feature class is a child sinceit always inherits the identifier from the base class

FDOClassThis class is used for non-spatial data It can act as a stand-alone class whereit would have no association with any other class or if the FdoClass is beingused as an ObjectProperty it can be used to define properties of some otherFdoClass or FdoFeatureClass

ObjectProperty Types

ObjectProperties have the following types

Value

Collection

OrderedCollection

The Value ObjectProperty type has a relationship of one-to-one providing asingle value for each property

The Collection and OrderedCollection ObjectProperty types have aone-to-many relationship where many ObjectProperties may be associatedwith one property Ordered Collections can be stored in an ascending ordescending order

90 | Chapter 7 Schema Management

At least one Identifier will be required if the FdoClass is to be used as astand-alone Class

All Identifiers for FdoDataType_Int64 must not be Read-Only since noneof these will be an auto-generated property value

If creating multiple Identifiers all Identifiers must be set to NOT NULL

Non-Feature Class IssuesA non-feature class in FDO can be created as a stand-alone class a containedclass or both As a contained class it defines a property of another class orfeature class (see FdoFeatureClass and FdoClassType Global Enum) How thisnon-feature class is created affects the way the data is inserted queried andupdated

Stand-alone Class

This type of class stores non-feature data (for example manufacturers) TheFdoClassType_Class must be created with one or more identity properties (seeFdoObjectPropertyDefinition) which is required in order that the class has aphysical container (that is a table in the RDBMS) associated with it If theclass is created without specifying an IdentityProperty only the definition isstored in the metadata which prevents any direct data inserts

Contained Class

This type of class stores non-feature data that defines a property of anotherclass or feature class (for example Sidewalk could be a property of a Roadfeature class the Sidewalk class defines the RoadSidewalk property) In thiscase the FdoClassType_Class does not need to be created with one or moreidentity properties although it can be

Class With IdentityProperty Used as ObjectProperty

This type of class reacts like a stand-alone class however with this type it ispossible to do direct data inserts It can also be populated through a containerclass (for example RoadSidewalk) since it defines an object property (seeFdoObjectPropertyDefinition) If this class is queried directly only the datainserted into the class as a stand-alone is returned The data associated withthe ObjectProperty can only be queried through the container class (forexample RoadSidewalk)

Non-Feature Class Issues | 91

Class Without a Defined IdentityProperty Used as ObjectProperty

Because this class has no defined IdentityProperty it can only be populatedthrough the container class (for example RoadSidewalk) since it definesObjectProperty This class cannot be queried directly The data associated withthe object property can only be queried through the container class (forexample RoadSidewalk) As an object property it is defined as one of thefollowing

Value type property Does not need any identifier since it has a one-to-onerelationship with the container class

Collection type property Requires a local identifier which is an identifierdefined when creating the ObjectProperty object

Ordered Collection type property Requires a local identifier which is anidentifier defined when creating the ObjectProperty object

When defining either a Collection or Ordered Collection type ObjectPropertyyou must set an IdentityProperty attribute for that object property ThisObjectClassIdentityProperty acts only as a local identifier compared to theIdentityProperty set at the class level As a local identifier it acts to uniquelyidentify each item within each collection (for example if the local identifierfor RoadSidewalk is Side there can be multiple sidewalks with Side=rdquoLeftrdquobut only one per Road)

Describing a Schema

Use the FdoIDescribeSchemaExecute function to retrieve anFdoFeatureSchemaCollection in order to obtain any information about existingschema(s) The FdoFeatureSchemaCollection consists of all FdoFeatureSchemasin the data store and can be used to obtain information about any schemaobject including FdoFeatureSchema FdoClass FdoFeatureClass and theirrespective properties The following functions return the main collectionsrequired to obtain information about all schema objects

FdoFeatureSchemaGetClasses method obtains FdoClass andFdoFeatureClasses

FdoClassDefinitionGetProperties method obtains aFdoPropertyDefinitionCollection

FdoClassDefinitionGetBaseProperties method obtains aFdoPropertyDefinitionCollection of the properties inherited from the baseclasses

92 | Chapter 7 Schema Management

NOTE Even if your schema has no base classes (inheritance) all classes will inheritsome properties from system classes

Use these functions throughout the application to obtain any informationabout schema objects For example in order to insert data into a class youmust use these functions to determine what data type is required Descriptionof the data is separate from actions

The example in the following link is a simple function that shows how to useFdoIDescribeSchema and loop through the schema and class containers tosearch for duplicate class names It searches all schemas to ensure that theclass name does not exist in any schema in the data store Class names mustbe unique across the entire FDO database

For a schema description example see Example Describing a Schema andWriting It to an XML File on page 114 NO LABEL

FDO Schema Element Class Diagram

Non-Feature Class Issues | 93

Modifying ModelsAdd schema elements to a model by inserting them into the appropriatecollection

Elements are removed from the model by using either of the followingmethods

Call the FdoSchemaElementDelete() method This flags the element fordeletion when the changes are accepted (generally throughFdoIApplySchema) but the element remains a member of all collectionsuntil that time

Remove the element from the appropriate collection via theFdoSchemaCollectionRemove() or FdoSchemaCollectionRemoveAt()methods This immediately disassociates the element from the collection

Schema Element StatesAll elements within the model maintain a state flag This flag can be retrievedby calling FdoSchemaElementGetElementState() but it cannot be directlyset Instead its state changes in reaction to the changes made to the model

Unchanged When a schema model is retrieved via FdoIDescribeSchemaall elements are initially marked Unchanged

Detached Removing an element from an owning collection sets its stateto Detached

Deleted Calling the Delete() method on an element sets its state to Deleted

Added Placing an element within a collection marks the element as Added

Modified When adding or removing a sub-element such as a propertyelement from a class the class element state will be changed to Modified

Additionally when an element that is contained by another element is changedin any way the containing element is also marked as Modified So for exampleif a new value is added to the SchemaAttributeDictionary of the ldquoClass3rdquoelement in our model both the ldquoClass3rdquo FdoClass object and theFdoFeatureSchema object would be marked as Modified

94 | Chapter 7 Schema Management

The state flags are maintained until the changes are accepted that is whenIApplySchema is executed At that time all elements marked Deleted arereleased and all other elements are set to Unchanged

NOTE When you remove an element from an owning collection its state is markedas Detached All collections currently in FDO are owning collections except forone the collections FdoClassDefinitionGetIdentityProperties()

Rollback MechanismThe FdoFeatureSchema contains a mechanism that allows you to ldquoroll backrdquomodel changes to the last accepted state For example a model retrieved viaFdoIDescribeSchema can have classes added attributes deleted or names anddefault values changed All of these changes are thrown out and the modelreturned to its unmodified state by calling FdoFeatureSchemaRejectChanges()

The converse of this operation is the FdoFeatureSchemaAcceptChanges()method which removes all of the elements with a status of Deleted and setsthe state flag of all other elements to Unchanged Generally this method isonly invoked by FDO provider code after it has processed anFdoIApplySchemaExecute() command Normal FDO clients should not callthis method directly

FDO XML FormatFDO feature schemas can be written to an XML file The FdoFeatureSchemaand FdoFeatureSchemaCollection classes support the FdoXmlSerializableinterface The sample code shows an FdoFeatureSchema object calling theWriteXml() method to generate an XML file containing the feature schemacreated by the sample code

FDO feature schemas can also be read from an XML file TheFdoFeatureSchemaCollection class supports the FdoXmlDeserializable interfaceThe sample code shows an FdoFeatureSchemaCollection object calling theReadXml() method to read a set of feature schemas into memory from an XMLfile The code shows the desired schema being retrieved from the collectionand applied to the data store

The XML format used by FDO is a subset of the Geography Markup Language(GML) standardized by the Open GIS Consortium (OGC) One thing shownin the sample code is a round-trip conversion from FDO feature schema toGML schema back to FDO feature schema To accomplish this round-trip the

Rollback Mechanism | 95

ReadXml() method supports a superset of the GML that is written by theWriteXml() method

The following table specifies the mapping of FDO feature schema elementsto GML elements and attributes This mapping is sufficient to understand theXML file generated from the schema defined by the sample code It alsoprovides a guide for writing a GML schema file by hand This file can then beread in and applied to a data store For more information see ExampleCreating a Schema Read In from an XML File on page 114

Another form of round-trip translation would be from a GML schema producedby another vendorrsquos tool to an FDO feature schema and then back to a GMLschema However the resemblance the of resulting GML schema to the originalGML schema might vary from only roughly equivalent to being exactly thesame

Map FDO Element to GML Schema Fragment

GML Schema FragmentFDO Element

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaN

amegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgisdschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFea

tureSchemaNamegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

see ltMetaDatagt

optional xsimport element to enable schema validation

ltxsimport namespace=httpfdoosgeoorgschema

schemaLocation=ltFDO SDK Install LocationgtdocsXmlS

chemaFdoDocumentxsdgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

FeatureSchema

96 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxsfield xpath=rdquordquogt

ltxsfield xpath=rdquoltidentityPropertyltngtNamegtrdquo

ltxskeygt

ltxselementgt

ClassDefinition(with identity prop-erties)

ltxselement see ClassDefinition (with identity proper

ties)ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

see FeatureClassGeometryProperty

gt

see ltMetaDatagt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

gt

ltxssequencegt

list of properties see DataProperty Geometric

Property

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

FeatureClass

FDO XML Format | 97

GML Schema FragmentFDO Element

lt-- these attributes belong to the xscomplexType element

--gt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

FeatureClass Geo-metryProperty

lt--

minOccurs attribute generated only if value is 1

default attribute generated only if a default value exists

fdoreadOnly attribute generated only if value is true

--gt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxssimpleTypegt

see DataType String or DataType Decimal

ltxssimpleTypegt

ltxselementgt

DataProperty(decimal or string)

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxselementgt

DataProperty (oth-er type)

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

DataType String

98 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxsrestriction base=rdquoxsdecimalrdquogt

ltxstotalDigits value=rdquoltprecisiongtrdquogt

ltxsfractionDigits value=rdquoltscalegtrdquogt

ltxsrestrictiongt

DataType Decimal

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquogmlAbstractGeometryTyperdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

see ltMetaDatagt

ltxselementgt

GeometricProperty(not a defining Fea-tureClass Geo-metryProperty)

FDO XML Format | 99

GML Schema FragmentFDO Element

lt-- the pattern referenced in the xsschema element for

FeatureSchema--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeatureS

chemaCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xselement element for

DataProperty --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoDataProp

ertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt--

the pattern referenced in the xselement element for a

non-feature-defining

GeometricProperty

--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xscomplexType element

for FeatureClass --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeature

ClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

MetaData

Map FDO Datatype to GML Type

GML TypeFDO Datatype

xsbooleanBoolean

fdoByteByte

xsdateTimeDateTime

100 | Chapter 7 Schema Management

GML TypeFDO Datatype

xsdoubleDouble

fdoInt16Int16

fdoInt32Int32

fdoInt64Int64

xsfloatSingle

xsbase64BinaryBLOB

xsstringCLOB

Creating and Editing a GML Schema FileThe sample in this section illustrates the creation of a GML schema filecontaining the definition of an FDO feature schema that contains one featureThe name of this file will have the standard XML schema extension namexsd This means that it contains only one schema and that the root elementis xsschema The ReadXml() method will take a filename argument whoseextension is either xsd or xml In the latter case the file could contain manyschema definitions If it does each schema is contained in an xsschemaelement and all xsschema elements are contained in the fdoDataStoreelement If there is only one schema in the xml file then the fdoDataStoreelement is not used and the root element is xsschema

You may want to validate the schema that you create To do so you mustinclude the optional xsimport line specified in the GML schema fragmentfor FeatureSchema

The sample feature implements a table definition for the Buildings feature inthe Open GIS Consortium document 98-046r1 This table definition isexpressed in an XML format on page 14 of the document and is reproducedas follows

Creating and Editing a GML Schema File | 101

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtbuildingsltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtaddressltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtpositionltnamegt

lttypegtPOINTlttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtfootprintltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

Add GML for the FDO Feature Schema

Start with the skeleton GML for an FDO Feature Schema with the ltMetaDatagtreference replaced by the valid pattern

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaNamegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFeatureSchema

Namegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgt

description arg to static FdoFeatureSchemaCreate()

ltxsdocumentationgt

ltxsannotationgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

102 | Chapter 7 Schema Management

For ltcustomer_urlgt substitute ldquofdo_customerrdquo For ltFeatureSchemaNamegtsubstitute ldquoOGC980461FSrdquo and for description arg substitute ldquoOGCSimple Features Specification for SQLrdquo

Add GML for an FDO Feature Class

Start with the GML that is already written and add the skeleton for an FDOFeature Class which includes the skeleton for a class definition with identityproperties The ltMetaDatagt is replaced with the valid pattern

Creating and Editing a GML Schema File | 103

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoFeatureClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

104 | Chapter 7 Schema Management

gt

ltxssequencegt

list of properties see DataProperty GeometricProperty

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For ltclassNamegt substitute ldquobuildingsrdquo

Set the value of the xselement abstract attribute to false

For ltidentityPropertyNamegt substitute ldquofidrdquo A data property whose nameis ldquofidrdquo will be added

Set the value of the xscomplexType abstract attribute to false

For ltgeometryPropertyNamegt substitute ldquofootprintrdquo

For ltlist of FdoGeometricTypesgt substitute ldquosurfacerdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoFeatureClassCreate() substitute ldquoOGC 98-046r1buildingsrdquo

For lturigt substitute ldquohttpfdoosgeoorgschemardquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoa polygon defines a building perimeterrdquo

This class has no base class so set the value of the xsextension base attributeto lsquogmlAbstractFeatureTypersquo

Add GML for Property Definitions

An integer data property whose name is ldquofidrdquo will be added This property isalready identified as an identity property in the xskey element A string dataproperty whose name is ldquonamerdquo and a geometry property whose name isldquopositionrdquo will also be added

Creating and Editing a GML Schema File | 105

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquoalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquoltpropertyNamegtrdquo

106 | Chapter 7 Schema Management

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

Creating and Editing a GML Schema File | 107

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For the first data property ltpropertyNamegt substitute ldquofidrdquo

For the first data property ltdataTypegt substitute ldquofdoint32rdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquofidrdquo to false

Set the content for xsdocumentation for ldquofidrdquo to ldquofeature idrdquo

For the second data property ltpropertyNamegt substitute ldquoaddressrdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquonamerdquo to false

Set the content for xsdocumentation for ldquoaddressrdquo to ldquoaddress of thebuildingrdquo

For ltlengthgt substitute ldquo64rdquo

For the geometry property ltpropertyNamegt substitute ldquopositionrdquo

For ltlist of FdoGeometricTypesgt substitute ldquopointrdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoposition of the buildingrdquo

The Final Result

After all the required substitutions the GML for the schema containing theBuildings feature is as follows

108 | Chapter 7 Schema Management

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquofidrdquo

Creating and Editing a GML Schema File | 109

type=rdquofdoint32rdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtfeature id

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoaddressrdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtaddress of the building

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquo64rdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquopositionrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquopositionrdquo

fdogeometricTypes=rdquopointrdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtposition of the buildingltxsdocu

mentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

110 | Chapter 7 Schema Management

Schema Management ExamplesExample Creating a Feature Schema

The following sample code creates an FdoFeatureSchema object calledldquoSampleFeatureSchemardquo The schema contains one class which has threeproperties The class and its properties conform to the table definition for theLakes feature in the Open GIS Consortium document 98-046r1 This tabledefinition is expressed in an XML format on page 10 of the document and isreproduced as follows

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtlakesltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstgraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtnameltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtshoreltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

The table definition whose name is ldquolakesrdquo is mapped to an FdoFeatureClassobject called ldquoSampleFeatureClassrdquo The column definition whose name isldquofidrdquo is mapped to an FdoDataPropertyDefinition object calledldquoSampleIdentityDataPropertyrdquo The column definition whose name is ldquonamerdquois mapped to an FdoDataPropertyDefinition object calledldquoSampleNameDataPropertyrdquo The column definition whose name is ldquoshorerdquois mapped to an FdoGeometricPropertyDefinition object calledldquoSampleGeometricPropertyrdquo

Schema Management Examples | 111

Create the ApplySchema command

FdoPtrltFdoIApplySchemagt sampleApplySchema

sampleApplySchema = (FdoIApplySchema )

connection-gtCreateCommand(FdoCommandType_ApplySchema)

Create the feature schema

FdoPtrltFdoFeatureSchemagt sampleFeatureSchema

sampleFeatureSchema = FdoFeatureSchemaCreate(LSampleFeatureS

chema LSample Feature Schema Description)

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

create a feature class ie a class containing a geometric

property set some class level properties

FdoPtrltFdoFeatureClassgt sampleFeatureClass

sampleFeatureClass = FdoFeatureClassCreate(LSampleFeatureClass

LSample Feature Class Description)

sampleFeatureClass-gtSetIsAbstract(false)

get a pointer to the feature classs property collection

this pointer is used to add data and other properties to the

class

FdoPtrltFdoPropertyDefinitionCollectiongt sampleFeatureClassProper

ties

sampleFeatureClassProperties = sampleFeatureClass-gtGetProperties()

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

get a pointer to the feature classs identity property collec

tion

this property is used to add identity properties to the feature

class

FdoPtrltFdoDataPropertyDefinitionCollectiongt sampleFeatureClassId

entityProperties

sampleFeatureClassIdentityProperties = sampleFeatureClass-

gtGetIdentityProperties()

create a data property that is of type Int32 and identifies

the feature uniquely

FdoPtrltFdoDataPropertyDefinitiongt sampleIdentityDataProperty

sampleIdentityDataProperty = FdoDataPropertyDefinitionCre

ate(LSampleIdentityDataProperty LSample Identity Data Property

Description)

sampleIdentityDataProperty-gtSetDataType(FdoDataType_Int32)

112 | Chapter 7 Schema Management

sampleIdentityDataProperty-gtSetReadOnly(false)

sampleIdentityDataProperty-gtSetNullable(false)

sampleIdentityDataProperty-gtSetIsAutoGenerated(false)

add the identity property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleIdentityDataProperty)

sampleFeatureClassIdentityProperties-gtAdd(sampleIdentityDataProp

erty)

create a data property that is of type String and names the

feature

FdoPtrltFdoDataPropertyDefinitiongt sampleNameDataProperty

sampleNameDataProperty = FdoDataPropertyDefinitionCreate(LSam

pleNameDataProperty LSample Name Data Property Description)

sampleNameDataProperty-gtSetDataType(FdoDataType_String)

sampleNameDataProperty-gtSetLength(64)

sampleNameDataProperty-gtSetReadOnly(false)

sampleNameDataProperty-gtSetNullable(false)

sampleNameDataProperty-gtSetIsAutoGenerated(false)

add the name property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleNameDataProperty)

create a geometric property

FdoPtrltFdoGeometricPropertyDefinitiongt sampleGeometricProperty

sampleGeometricProperty = FdoGeometricPropertyDefinitionCre

ate(LSampleGeometricProperty LSample Geometric Property Descrip

tion)

sampleGeometricProperty-gtSetGeometryTypes(FdoGeometricType_Sur

face)

sampleGeometricProperty-gtSetReadOnly(false)

sampleGeometricProperty-gtSetHasMeasure(false)

sampleGeometricProperty-gtSetHasElevation(false)

add the geometric property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleGeometricProperty)

identify it as a geometry property

sampleFeatureClass-gtSetGeometryProperty(sampleGeometricProperty)

add the feature class to the schema

sampleClassCollection-gtAdd(sampleFeatureClass)

point the ApplySchema command at the newly created feature

schema and execute

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

Schema Management Examples | 113

Example Describing a Schema and Writing It to an XML File

The following sample code demonstrates describing a schema and writing itto an XML file

create the DescribeSchema command

FdoPtrltFdoIDescribeSchemagt sampleDescribeSchema

sampleDescribeSchema = (FdoIDescribeSchema )

connection-gtCreateCommand(FdoCommandType_DescribeSchema)

executing the DescribeSchema command returns a feature

schema collection that is the set of feature schema which

reside in the DataStore

FdoPtrltFdoFeatureSchemaCollectiongt sampleFeatureSchemaCollection

sampleFeatureSchemaCollection = sampleDescribeSchema-gtExecute()

find the target feature schema in the collection write it

to an xml file and clear the collection

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleFeatureSchema-gtWriteXml(LSampleFeatureSchemaxml)

sampleFeatureSchemaCollection-gtClear()

Example Destroying a Schema

The following sample code demonstrates destroying a schema

create the DestroySchema command

FdoPtrltFdoIDestroySchemagt sampleDestroySchema

sampleDestroySchema = (FdoIDestroySchema )

connection-gtCreateCommand(FdoCommandType_DestroySchema)

destroy the schema

sampleDestroySchema-gtSetSchemaName(LSampleFeatureSchema)

sampleDestroySchema-gtExecute()

Example Creating a Schema Read In from an XML File

The following sample code demonstrates creating a schema read in from anXML file

sampleFeatureSchemaCollection-gtReadXml(LSampleFeatureSchemaxml)

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

sampleFeatureSchemaCollection-gtClear()

114 | Chapter 7 Schema Management

SampleFeatureSchemaxml

The following sample XML schema is the contents of the file written out bythe WriteXml method belonging to the FdoFeatureSchema class object thatwas created in the preceding sample code

Schema Management Examples | 115

ltxml version=10 encoding=UTF-8 gt

ltxsschema xmlnsxs=httpwwww3org2001XMLSchema

targetNamespace=httpfdo_customerSampleFeatureSchema

xmlnsfdo=httpfdoosgeoorgschema

xmlnsgml=httpwwwopengisnetgml

xmlnsSampleFeatureSchema=httpfdo_customer

SampleFeatureSchema

elementFormDefault=qualified

attributeFormDefault=unqualifiedgt

ltxsannotationgt

ltxsdocumentationgtSample Feature Schema Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsannotationgt

ltxselement name=SampleFeatureClass

type=SampleFeatureSchemaSampleFeatureClassType

abstract=false substitutionGroup=gml_Featuregt

ltxskey name=SampleFeatureClassKeygt

ltxsselector xpath=SampleFeatureClass gt

ltxsfield xpath=SampleIdentityDataProperty gt

ltxskeygt

ltxselementgt

ltxscomplexType name=SampleFeatureClassType

abstract=false

fdogeometryName=SampleGeometricProperty

fdohasMeasure=false

fdohasElevation=false

fdosrsName=SC_0

fdogeometricTypes=surfacegt

ltxsannotationgt

ltxsdocumentationgtSample Feature Class Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsdocumentationgtSample Geometric Property Descrip

tionltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=gmlAbstractFeatureTypegt

ltxssequencegt

ltxselement name=SampleIdentityDataProperty

default=

type=fdoint32gt

ltxsannotationgt

116 | Chapter 7 Schema Management

ltxsdocumentationgt

Sample Identity Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=SampleNameDataProperty

default=gt

ltxsannotationgt

ltxsdocumentationgt

Sample Name Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=xsstringgt

ltxsmaxLength value=64 gt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

Schema Management Examples | 117

118

Data Maintenance

This chapter provides information about using the FDO API to maintain data

Data Maintenance OperationsThe primary operations associated with data maintenance are

Inserting

Updating

Deleting

Transactions

Locking

NOTE Discussion of Transactions and Locking is deferred to a future release of thisdocument

Inserting Values

Preconditions

In a previous chapter we created a feature schema and added a feature class toit The feature class had three properties an integer data property a string dataproperty and a geometric property We applied this feature schema to the datastore We are now ready to create feature data objects which are instances ofthe feature class and insert them into the data store

8

119

Property Values in General

We can now create feature data objects which are instances of the featureclass by defining a set of property values corresponding to the propertiesdefined for the class and then inserting them into the data store

An FDO class correspondends roughly to a table definition in a relationaldatabase and a property of a class corresponds roughly to a column definitionin a table Adding the property values corresponds roughly to adding a rowin the table

The main distinction between a data value or geometry value and a propertyvalue is the order in which they are created A data value or geometry valueobject is created first and is then used to create a property value object Theproperty value object is then added to the value collection object belongingto the Insert command object Then the command is executed

An insert operation consists of the following steps

1 Create the insert command object (type FdoIInsert) this object can bereused for multiple insert operations

2 Point the insert command object at the feature class to which you areadding values (call the SetFeatureClassName(ltclassNamegt) method)

3 From the insert command object obtain a pointer using theGetPropertyValues() method to a value collection object (typeFdoPropertyValueCollection) You will add property values to the insertcommand object by adding values to the collection object

4 Create a data value (type FdoDataValue) or geometry value (typeFdoGeometryValue) object Creating the data value is straightforwardyou pass the string or integer value to a static Create() method Creatingthe geometry value is described in Geometry Property Values on page 121

5 Create a property value (type FdoPropertyValue) object which involvespassing the data value or geometry value object as an argument to a staticCreate() method

6 Add the property value object to the value collection object

7 Execute the Insert command

Data Property Values

A data value object contains data whose type is one of the following

Boolean

120 | Chapter 8 Data Maintenance

Byte

DateTime

Decimal

Double

Int16

Int32

Int64

Single (another floating point type)

String

Binary large object (BLOB)

Character large object (CLOB)

The data value object is added to the data property value object The dataproperty value object is added to the property value collection belonging tothe Insert command

Geometry Property Values

A geometry property value object contains a geometry in the form of a bytearray A geometry can be relatively simple for example a point (a single pairof ordinates) or quite complex for example a polygon (one or more arraysof ordinates) In the latter case a number of geometry objects are created andthen combined together to form the target geometry Finally the targetgeometry is converted to a byte array and incorporated into the geometryproperty value object

Creating a geometry value object consists of the following steps

1 Create a geometry value object (type FdoGeometryValue) using a staticCreate() method

2 Create a geometry factory object (type FdoAgfGeometryFactory) using astatic GetInstance() method This object is used to create the geometryobject or objects which comprise the target geometry

3 Create the required geometry object or objects using the appropriateCreateltgeometrygt method() belonging to the geometry factory object

Inserting Values | 121

4 Use the geometry factory object to convert the target geometry object toa byte array

5 Incorporate the byte array into the geometry property value object

Example Inserting an Integer a String and a Geometry Value

The following sample code shows how to insert an integer a string and ageometry value

122 | Chapter 8 Data Maintenance

create the insert command

FdoPtrltFdoIInsertgt sampleInsert

sampleInsert = (FdoIInsert )

connection-gtCreateCommand(FdoCommandType_Insert)

index returned by the operation which adds a value to the value

collection

FdoInt32 valueCollectionIndex = 0

point the Insert command to the target class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleInsert-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

get the pointer to the value collection used to add properties

to the Insert command

FdoPtrltFdoPropertyValueCollectiongt samplePropertyValues

samplePropertyValues = sampleInsert-gtGetPropertyValues()

create an FdoDataValue for the identity property value

FdoPtrltFdoDataValuegt sampleIdentityDataValue

sampleIdentityDataValue = FdoDataValueCreate(101)

add the FdoDataValue to the identity property value

FdoPtrltFdoPropertyValuegt sampleIdentityPropertyValue

sampleIdentityPropertyValue =

FdoPropertyValueCreate(LSampleIdentityDataProperty

sampleIdentityDataValue)

add the identity property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleIdentityPropertyValue)

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LBlue Lake)

add the FdoDataValue to the name property value

FdoPtrltFdoPropertyValuegt sampleNamePropertyValue

sampleNamePropertyValue =

FdoPropertyValueCreate(LSampleNameDataProperty

sampleNameDataValue)

add the name property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleNamePropertyValue)

create an FdoGeometryValue for the geometry property value

this polygon represents a lake which has an island

the outer shoreline of the lake is defined as a linear ring

the shoreline of the island is defined as a linear ring

the outer shoreline is the external boundary of the polygon

Inserting Values | 123

the island shoreline is an internal linear ring

a polygon geometry can have zero or more internal rings

FdoPtrltFdoGeometryValuegt sampleGeometryValue

sampleGeometryValue = FdoGeometryValueCreate()

create an instance of a geometry factory used to create the

geometry objects

FdoPtrltFdoFgfGeometryFactorygt sampleGeometryFactory

sampleGeometryFactory = FdoFgfGeometryFactoryGetInstance()

define the external boundary of the polygon the shoreline of

Blue Lake

FdoPtrltFdoILinearRinggt exteriorRingBlueLake

FdoInt32 numBlueLakeShorelineOrdinates = 10

double blueLakeExteriorRingOrdinates[] = 520 180 660 230

730 90 480 60 520 180

exteriorRingBlueLake = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numBlueLakeShorelineOrdinates

blueLakeExteriorRingOrdinates)

define the shoreline of Goose Island which is on Blue Lake

this is the sole member of the list of interior rings

FdoPtrltFdoILinearRinggt linearRingGooseIsland

FdoInt32 numGooseIslandShorelineOrdinates = 10

double gooseIslandLinearRingOrdinates[] = 590 180 670 180

670 130 590 130 590 180

linearRingGooseIsland = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numGooseIslandShorelineOrdinates

gooseIslandLinearRingOrdinates)

add the Goose Island linear ring to the list of interior rings

FdoPtrltFdoLinearRingCollectiongt interiorRingsBlueLake

interiorRingsBlueLake = FdoLinearRingCollectionCreate()

interiorRingsBlueLake-gtAdd(linearRingGooseIsland)

create the Blue Lake polygon

FdoPtrltFdoIPolygongt blueLake

blueLake =

sampleGeometryFactory-gtCreatePolygon(exteriorRingBlueLake

interiorRingsBlueLake)

convert the Blue Lake polygon into a byte array

and set the geometry value to this byte array

FdoByteArray geometryByteArray =

sampleGeometryFactory-gtGetAgf(blueLake)

sampleGeometryValue-gtSetGeometry(geometryByteArray)

add the Blue Lake FdoGeometryValue to the geometry property

value

FdoPtrltFdoPropertyValuegt sampleGeometryPropertyValue

124 | Chapter 8 Data Maintenance

sampleGeometryPropertyValue =

FdoPropertyValueCreate(LSampleGeometryProperty

sampleGeometryValue)

add the geometry property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleGeometryPropertyValue)

do the insertion

the command returns an FdoIFeatureReader

FdoPtrltFdoIFeatureReader sampleFeatureReader

sampleFeatureReader = sampleInsert-gtExecute()

Updating Values

After inserting (see Inserting Values on page 119) you can update the valuesThe update operation involves identifying a feature class (ldquotablerdquo) a featureclass object (ldquorowrdquo) and an object property (ldquocolumn in a rowrdquo) to be changedand supplying a new value for the object property to replace the old

First create an FdoIUpdate command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class object whose properties we want to updateand use the command objectrsquos SetFilter() method to attach the command toit Filters are discussed in Filter and Expression Languages on page 139

One of the data properties in the example SampleFeatureClass class definitionis an identity property whose name is ldquoSampleIdentityDataPropertyrdquo andwhose type is fdoInt32 This means that its value uniquely identifies thefeature class object that is the ldquorowrdquo Use the name of the identity propertyin the filter In the Insert operation the value of the identity property was setto be lsquo101rsquo The value of the filter that is needed is ldquo(SampleIdentityDataProperty = 101 )rdquo

Finally create a property value which contains the new value attach it tothe command object and then execute the command

Example Updating Property Values

The following is an example of updating property values

Updating Values | 125

FdoPtrltFdoIUpdategt sampleUpdate

sampleUpdate =

(FdoIUpdate )connection-gtCreateCommand(FdoCommandType_Update)

FdoInt32 numUpdated = 0

point the Update command at the target feature class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleUpdate-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

set the filter to identify which set of properties to update

sampleUpdate-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

get the pointer to the value collection used to add properties

to the Update command

we are reusing the samplePropertyValues object that we used

for the insert operation

samplePropertyValues = sampleUpdate-gtGetPropertyValues()

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LGreen Lake)

set the name and value of the property value

sampleNamePropertyValue-gtSetName(LSampleNameDataProperty)

sampleNamePropertyValue-gtSetValue(sampleNameDataValue)

add the name property value to the property value collection

owned by the Update command

samplePropertyValues-gtAdd(sampleNamePropertyValue)

execute the command

numUpdated = sampleUpdate-gtExecute()

Deleting Values

In addition to inserting (see Inserting Values on page 119) and updating (seeUpdating Values on page 125) values you can delete the values The deletionoperation involves identifying a feature class (ldquotablerdquo) whose feature classobjects (ldquorowsrdquo) are to be deleted

First create an FdoIDelete command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class objects that you want to delete and use thecommand objectrsquos SetFilter() method to attach the filter to it You can use thesame filter that was specified in the preceding section Updating Values onpage 125 Finally execute the command

126 | Chapter 8 Data Maintenance

Example Deleting Property Values

FdoPtrltFdoIDeletegt sampleDelete

sampleDelete =

(FdoIDelete )connection-gtCreateCommand(FdoCommandType_Delete)

FdoInt32 numDeleted = 0

sampleDelete-gt

SetFeatureClassName(LSampleFeatureSchemaSampleFeatureClass)

sampleDelete-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

numDeleted = sampleDelete-gtExecute()

Related Class TopicsThe following classes are used in the preceding Data Maintenance examples

FdoIInsert

FdoPropertyValueCollection

FdoDataValue

FdoPropertyValue

FdoGeometryValue

FdoFgfGeometryFactory

FdoILinearRing

FdoLinearRingCollection

FdoIPolygon

FdoByteArray

FdoIDelete

FdoIUpdate

For more information see FDO API Reference Help

Related Class Topics | 127

128

Performing Queries

This chapter describes how to create and perform queries In the FDO API you can use queriesto retrieve specific features from a data store

Creating a QueryYou create and perform queries using the FdoISelect class which is a memberof the Feature sub-package of the Commands package Queries are used toretrieve features from the data store and are executed against one class at atime The class is specified using the SetFeatureClassName() method inFdoIFeatureCommand The SetFeatureClassName can be used with feature andnon-feature classes

FdoISelect supports the use of filters to limit the scope of features returned bythe command This is done through one of the SetFilter methods available inthe FdoIFeatureCommand class The filter is similar to the SQL WHERE clausewhich specifies the search conditions that are applied to one or more classproperties

Search conditions include spatial and non-spatial conditions Non-spatial queriescreate a condition against a data property such as an integer or string Basiccomparisons (= lt gt gt= lt= =) pattern matching (like) and lsquoInrsquo comparisonscan be specified Spatial queries create a spatial condition against a geometryproperty Spatial conditions are enumerated in FdoSpatialCondition andFdoDistanceCondition

The feature reader (FdoIFeatureReader) is used to retrieve the results of a queryfor feature and non-feature classes To retrieve the features from the readeriterate through the reader using the FdoIFeatureReaderReadNext method()

9

129

Query ExampleIn the Data Maintenance chapter we created an instance of theFdoFeatureClass SampleFeatureClass and assigned values to its integer stringand geometry properties (see Example Inserting an Integer a String and aGeometry Value on page 122) The sample code in the following query exampleselects this instance and retrieves the values of its properties Specifically thesample code does the following

1 Creates the select command and

2 Points the select command at the target FdoFeatureClassSampleFeatureClass and

3 Creates a filter to identify which instance of SampleFeatureClass to selectand

4 Points the select command at the filter and

5 Executes the command which returns an FdoIFeatureReader object and

6 Loops through the feature reader object which contains one or morequery results depending on the filter arguments In the sample codeprovided there is only one result

7 Finally the code extracts the property values from each query result

130 | Chapter 9 Performing Queries

we have one FdoFeatureClass object in the DataStore

create a query that returns this object

create the select command

FdoPtrltFdoISelectgt sampleSelect

sampleSelect = (FdoISelect )

connection-gtCreateCommand(FdoCommandType_Select)

point the select command at the target FdoFeatureClass

SampleFeatureClass

sampleSelect-gtSetFeatureClassName(LSampleFeatureClass)

create the filter by

1 creating an FdoIdentifier object containing the name of

the identity property

FdoPtrltFdoIdentifiergt queryPropertyName

queryPropertyName =

FdoIdentifierCreate(LSampleIdentityDataProperty)

2 creating an FdoDataValue object containing the value of the

identity property

FdoPtrltFdoDataValuegt queryPropertyValue

queryPropertyValue = FdoDataValueCreate(101)

3 calling FdoComparisonConditionCreate() passing in the

the queryPropertyName an enumeration constant signifying an

equals comparison operation and the queryPropertyValue

FdoPtrltFdoFiltergt filter

filter = FdoComparisonConditionCreate(queryPropertyName

FdoComparisonOperations_EqualTo queryPropertyValue)

point the select command at the filter

sampleSelect-gtSetFilter(filter)

execute the select command

FdoPtrltFdoIFeatureReadergt queryResults

queryResults = sampleSelect-gtExecute()

declare variables needed to capture query results

FdoPtrltFdoClassDefinitiongt classDef

FdoPtrltFdoPropertyDefinitionCollectiongt properties

FdoInt32 numProperties = 0

FdoPropertyDefinition propertyDef

FdoPropertyType propertyType

FdoDataType dataType

FdoDataPropertyDefinition dataPropertyDef

FdoString propertyName = NULL

FdoPtrltFdoByteArraygt byteArray

FdoIGeometry geometry = NULL

FdoGeometryType geometryType = FdoGeometryType_None

FdoIPolygon polygon = NULL

Query Example | 131

FdoILinearRing exteriorRing = NULL

FdoILinearRing interiorRing = NULL

FdoIDirectPosition position = NULL

FdoInt32 dimensionality = FdoDimensionality_XY

FdoInt32 numPositions = 0

FdoInt32 numInteriorRings = 0

loop through the query results

while (queryResults-gtReadNext())

get the feature class object and its properties

classDef = queryResults-gtGetClassDefinition()

properties = classDef-gtGetProperties()

loop through the properties

numProperties = properties-gtGetCount()

for(int i = 0 i lt numProperties i++)

propertyDef = properties-gtGetItem(i)

get the property name and property type

propertyName = propertyDef-gtGetName()

propertyType = propertyDef-gtGetPropertyType()

switch (propertyType)

itrsquos a data property

case FdoPropertyType_DataProperty

dataPropertyDef =

dynamic_castltFdoDataPropertyDefinition gt

(propertyDef)

dataType = dataPropertyDef-gtGetDataType()

switch (dataType)

case FdoDataType_Boolean

break

case FdoDataType_Int32

break

case FdoDataType_String

break

default

break

itrsquos a geometric property

convert the byte array to a geometry

and determine the derived type of the geometry

case FdoPropertyType_GeometricProperty

byteArray = queryResults-gtGetGeometry(propertyName)

geometry =

sampleGeometryFactory-gtCreateGeometryFromAgf

(byteArray)

132 | Chapter 9 Performing Queries

geometryType = geometry-gtGetDerivedType()

resolve the derived type into a list of ordinates

switch (geometryType)

case FdoGeometryType_None

break

case FdoGeometryType_Point

break

case FdoGeometryType_LineString

break

case FdoGeometryType_Polygon

polygon = dynamic_castltFdoIPolygon gt(geometry)

exteriorRing = polygon-gtGetExteriorRing()

dimensionality = exteriorRing-

gtGetDimensionality()

numPositions = exteriorRing-gtGetCount()

double X Y Z M

for(int i=0 iltnumPositions i++)

position = exteriorRing-gtGetItem(i)

if (dimensionality amp FdoDimensionality_Z ampamp

dimensionality amp FdoDimensionality_M)

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

M = position-gtGetM()

else if (dimensionality amp FdoDimensionality_Z

ampamp (dimensionality amp FdoDimensionality_M))

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

else

X = position-gtGetX()

Y = position-gtGetY()

numInteriorRings = polygon-

gtGetInteriorRingCount()

for(int i=0 iltnumInteriorRings i++)

interiorRing = polygon-gtGetInteriorRing(i)

do same for interior ring as exterior ring

break

case FdoGeometryType_MultiPoint

break

Query Example | 133

case FdoGeometryType_MultiLineString

break

case FdoGeometryType_MultiPolygon

break

case FdoGeometryType_MultiGeometry

break

case FdoGeometryType_CurveString

break

case FdoGeometryType_CurvePolygon

break

case FdoGeometryType_MultiCurveString

break

case FdoGeometryType_MultiCurvePolygon

break

default

break

default

134 | Chapter 9 Performing Queries

Long TransactionProcessing

This chapter defines long transactions (LT) and long transaction interfaces and explains howto implement LT processing in your application

NOTE For this release the providers that support long transaction processing are AutodeskFDO Provider for Oracle and OSGeo FDO Provider for ArcSDE

What Is Long Transaction ProcessingA long transaction (LT) is an administration unit that is used to groupconditional changes to objects Depending on the situation such a unit cancontain conditional changes to one or to many objects Long transactions areused to modify as-built data in the database without permanently changing theas-built data Long transactions can be used to apply revisions or alternates toan object

A root long transaction is a long transaction that represents permanent dataand that has descendents Any long transaction has a root long transaction asan ancestor in its long transaction dependency graph A leaf long transactiondoes not have descendents

For more information about Oracle-specific long transaction versions andlocking see Locking and Long Transactions

10

135

Supported InterfacesIn the current release of FDO the following long transaction interfaces aresupported

FDOIActivateLongTransaction

FDOIDeactivateLongTransaction

FDOIRollbackLongTransaction

FDOICommitLongTransaction

FDOICreateLongTransaction

FDOIGetLongTransaction

These interfaces are summarized below For more information about theirusage supported methods associated enumerations and readers see the FDOAPI Reference Help

FDOIActivateLongTransaction

The FdoIActivateLongTransaction interface defines theActivateLongTransaction command which activates a long transaction wherefeature manipulation and locking commands operate on it Input to theactivate long transaction command is the long transaction name The Executeoperation activates the identified long transaction

FDOIDeactivateLongTransaction

The FdoIDeactivateLongTransaction interface defines theDeactivateLongTransaction command which deactivates the active longtransaction where feature manipulation and locking commands operate onit If the active long transaction is the root long transaction then no longtransaction will be deactivated

FDOIRollbackLongTransaction

The FdoIRollbackLongTransaction interface defines theRollbackLongTransaction command which allows a user to execute rollbackoperations on a long transaction Two different rollback operations areavailable Full and Partial

136 | Chapter 10 Long Transaction Processing

The operation is executed on all data within a long transaction and on all itsdescendents The data is removed from the database and all versions involvedin the process deleted

NOTE If the currently active long transaction is the same as the one beingcommitted or rolled back then if the commit or rollback succeeds the providerresets the current active long transaction to be the root long transaction If it doesnot succeed the active long transaction is left alone and current If the currentlyactive long transaction is not the same as the one being committed or rolled backthen it is not affected

FDOICommitLongTransaction

The FdoICommitLongTransaction interface defines theCommitLongTransaction command which allows a user to execute commitoperations on a long transaction Two different commit operations areavailable Full and Partial

The commit operation can be performed on a leaf long transaction only Along transaction is a leaf long transaction if it does not have descendents

FDOICreateLongTransaction

The FdoICreateLongTransaction interface defines the CreateLongTransactioncommand which creates a long transaction that is based on the currentlyactive long transaction There is always an active long transaction If the userhas not activated a user-defined long transaction then the root longtransaction is active

Input to the CreateLongTransaction command includes a name and descriptionfor the new long transaction The long transaction name submitted to thecommand has to be unique If it is not unique an exception is thrown

FDOIGetLongTransactions

The FdoIGetLongTransactions interface defines the GetLongTransactionscommand which allows the user to retrieve long transaction information Ifa long transaction name is submitted the command returns the informationfor the named long transaction only If no long transaction name is giventhe command retrieves the names of all available long transactions

For each returned long transaction the user has the option to retrieve a listof descendents andor ancestors

Supported Interfaces | 137

138

Filter and ExpressionLanguages

This chapter discusses the use of filters and filter expressions You can use filters and expressionsto specify to an FDO provider how to identify a subset of the objects in a data store

For more information and implementation details about the expression functions signaturesthe RDBMS-specific built-in support for some of the functions and the provider-specificsupport see the appendix Expression Functions

FiltersFDO uses filters through its commands (including provider-specific commands)to select certain features and exclude others

A filter is a construct that an application specifies to an FDO provider to identifya subset of objects of an FDO data store For example a filter may be used toidentify all Road type features that have 2 lanes and that are within 200 metresof a particular location Many FDO commands use filter parameters to specifythe objects to which the command applies For example a select commandtakes a filter to identify the objects that the application wants to retrieve or adelete command takes a filter to identify the objects that the application wantsto delete from the data store

When a command executes the filter is evaluated for each feature instance andthat instance is included in the scope of the command only if the filter evaluatesto True Filters may be specified either as text or as an expression tree Featureproviders declare their level of support for filters through the filter capabilitiesmetadata Query builders should configure themselves based on the filtercapabilities metadata in order to provide users with a robust user interface Formore information see What Is an Expression on page 19

11

139

ExpressionsFDO uses expressions through its commands (including provider-specificcommands) to specify input values in order to filter features In generalcommands in FDO do not support the SQL command language (the oneexception is the optional SQLCommand) However to facilitate ease of usefor application developers expressions in FDO can be specified using a textualnotation that is based syntactically on expressions and SQL WHERE clausesIn FDO expressions are not intended to work against tables and columns butagainst feature classes properties and relationships For example an expressionto select roads with four or more lanes might look like this

Lanes gt= 4

An expression is a construct that an application can use to build up a filterIn other words an expression is a clause of a filter or larger expression Forexample ldquoLanes gt=4 and PavementType = Asphaltrdquo takes two expressionsand combines them to create a filter

Filter and Expression TextIn general commands in FDO do not support the SQL command language(the one exception is the optional SQLCommand) However to facilitate easeof use for application developers expressions and filters in FDO can be specifiedusing a textual notation that is based syntactically on expressions and SQLWHERE clauses The biggest difference between this approach and SQL is thatthese clauses are not intended to work against tables and columns but againstfeature classes properties and relationships For example a filter to selectroads with four or more lanes might look like

Lanes gt= 4

Similarly a filter to select all PipeNetworks that have at least one Pipe in theproposed state might look like

Pipesstate = proposed

Furthermore a filter to select all existing parcels whose owner contains thetext ldquoSmithrdquo might look like

state = existing and owner like Smith

Finally a filter to select all parcels that are either affected or encroached uponby some change might look like

140 | Chapter 11 Filter and Expression Languages

state in (affected encroached)

Language IssuesThere are a number of language issues to be considered when working withclasses in the Filter Expression and Geometry packages

Provider-specific constraints on text

Filter grammar

Expression grammar

Filter and Expression keywords

Data types

Operators

Special characters

Geometry value

Provider-Specific Constraints on Filter andExpression Text

Some providers may have reserved words that require special rules when usedwith filters and expressions For more information see Oracle Reserved WordsUsed with Filter and Expression Text

Filter Grammar

The rules for entering filter expressions are described in the following sectionsusing BNF notation For more information about BNF notation seehttpcuiunigechdb-researchEnseignementanalyseinfoAboutBNFhtml

The FdoFilterParse() method supports the following filter grammar

Language Issues | 141

ltFiltergt = ( Filter )

| ltLogicalOperatorgt

| ltSearchConditiongt

ltLogicalOperatorgt = ltBinaryLogicalOperatorgt

| ltUnaryLogicalOperatorgt

ltBinaryLogicalOperatorgt =

ltFiltergt ltBinaryLogicalOperationsgt ltFiltergt

ltSearchConditiongt = ltInConditiongt

| ltComparisonConditiongt

| ltGeometricConditiongt

| ltNullConditiongt

ltInConditiongt = ltIdentifiergt IN ( ValueExpressionCollection

)

ltValueExpressionCollectiongt = ltValueExpressiongt

| ltValueExpressionCollectiongt ltValueExpressiongt

ltComparisonConditiongt =

ltExpressiongt ltComparisonOperationsgt ltExpressiongt

ltGeometricConditiongt = ltDistanceConditiongt

| ltSpatialConditiongt

ltDistanceConditiongt =

ltIdentifiergt ltDistanceOperationsgt ltExpressiongt ltdistancegt

ltNullConditiongt = ltIdentifiergt NULL

ltSpatialConditiongt =

ltIdentifiergt ltSpatialOperationsgt ltExpressiongt

ltUnaryLogicalOperatorgt = NOT ltFiltergt

ltBinaryLogicalOperationsgt = AND | OR

ltComparisionOperationsgt =

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

LIKE Like

ltDistanceOperationsgt = BEYOND | WITHINDISTANCE

ltdistancegt = DOUBLE | INTEGER

ltSpatialOperationsgt = CONTAINS | CROSSES | DISJOINT

| EQUALS | INTERSECTS | OVERLAPS | TOUCHES | WITHIN | COVEREDBY |

INSIDE

142 | Chapter 11 Filter and Expression Languages

Expression Grammar

The FdoExpressionParse() method supports the following expression grammar

ltExpressiongt = ( Expression )

| ltUnaryExpressiongt

| ltBinaryExpressiongt

| ltFunctiongt

| ltIdentifiergt

| ltValueExpressiongt

ltBinaryExpressiongt =

ltExpressiongt + ltExpressiongt

| ltExpressiongt - ltExpressiongt

| ltExpressiongt ltExpressiongt

| ltExpressiongt ltExpressiongt

ltDataValuegt =

TRUE

| FALSE

| DATETIME

| DOUBLE

| INTEGER

| STRING

| BLOB

| CLOB

| NULL

ltFunctiongt = ltIdentifiergt ( ltExpressionCollectiongt )

ltExpressionCollectiongt =

| ltExpressiongt

| ltExpressionCollectiongt ltExpressiongt

ltGeometryValuegt = GEOMFROMTEXT ( STRING )

ltIdentifiergt = IDENTIFIER

ltValueExpressiongt = ltLiteralValuegt | ltParametergt

ltLiteralValuegt = ltGeometryValuegt | ltDataValuegt

ltParametergt = PARAMETER | STRING

ltUnaryExpressiongt = - ltExpressiongt

Expression Operator Precedence

The precedence is shown in YACC notation that is the highest precedenceoperators are at the bottom

left Add Subtract

left Multiply Divide

left Negate

Expression Grammar | 143

Filter and Expression Keywords

The following case-insensitive keywords are reserved in the language that isthey cannot be used as identifier or function names

AND BEYOND COMPARE CONTAINS COVEREDBY CROSSES DATE

DISJOINT DISTANCE EQUALS FALSE GeomFromText IN INSIDE

INTERSECTS LIKE NOT NULL OR OVERLAPS RELATE SPATIAL TIME

TIMESTAMP TOUCHES TRUE WITHIN WITHINDISTANCE

Data Types

The available data types are described in this section

Identifier

An identifier can be any alphanumeric sequence of characters other than akeyword Identifiers can be enclosed in double quotes to allow specialcharacters and white space If you need to include a double quote characterinside an identifier double the character for example abcdef

Parameter

Parameters are defined by a colon followed by alphanumeric characters TheFDO filter language extends SQL to allow for a literal string to follow the colonto allow blanks (and other possibilities) for example Enter Name

Determine whether parameters are supported by the FDO Provider you areusing by checking SupportParameters on the Connection interface

String

Strings are literal constants enclosed in single quotes The FDO filter languagealso supports the special characters (left and right single quotes) that MicrosoftWord uses to automatically replace the single quote character typed from thekeyboard If you need to include a single quote character inside a string youcan double the character for example aaabbb

144 | Chapter 11 Filter and Expression Languages

Integer

Integers allow only decimal characters with an optional unary minus signUnary plus is not supported

(-)[0-9]

Double

Floating point numbers have a decimal point can be signed (-) and includean optional exponent (e[0-9])

NOTE If an integer is out of the 32-bit precision range it is converted to floatingpoint

Examples

-34

12345678901234567

12e13

DateTime

Date and time are parsed using the standard SQL literal strings

DATE YYYY-MM-DD

TIME HHMMSS[sss]

TIMESTAMP YYYY-MM-DD HHMMSS[sss]

For example

DATE 1971-12-24

TIMESTAMP 2003-10-23 110002

NOTE The BLOB and CLOB strings are currently not supported If you need tosupport binary input use parameters

Data Types | 145

Operators

The following operators are special characters common to SQL and mostprogramming languages

BinaryOperations

These binary operations are available

+ Add (for compatibility with SQL string concatenation may also be definedusing ldquo||rdquo)

- Subtract

Multiply

Divide

UnaryOperations

These unary operation are available

- Negate

Comparison Operations

These comparison operations are available

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

Operator Precedence

The following precedence is shown from highest to lowest

Negate NOT

Multiply Divide

Add Subtract

146 | Chapter 11 Filter and Expression Languages

EQ NE GT GE LT LE

AND

OR

Special Character

The following special characters are used in ExpressionCollections andValueExpressions to define function arguments and IN conditions

( Left Parenthesis

Comma

) Right Parenthesis

The Colon () is used in defining parameters and the Dot () can be includedin real numbers and identifiers

Geometry Value

Geometry values are handled using a function call GeomFromText(FGF Textstring) as is typical in an SQL query

The Autodesk extension to WKT referred to as FGF Text is a superset of WKT(that is you can enter WKT as valid FGF Text strings) Dimensionality isoptional It can be XY XYM XYZ or XYZM If it is not specified it is assumedto be XY For more information about FGF Text see FGF Text on page 158

NOTE Extra ordinates are ignored rather than generating an error during FGFtext parsing For example in the string ldquoPOINT (10 11 12)rdquo the lsquo12rsquo is ignoredbecause the dimensionality is assumed to be XY

The following is the grammar definition for FGF Text

ltFGF Textgt = POINT ltDimensionalitygt ltPointEntitygt

| LINESTRING ltDimensionalitygt ltLineStringgt

| POLYGON ltDimensionalitygt ltPolygongt

| CURVESTRING ltDimensionalitygt ltCurveStringgt

| CURVEPOLYGON ltDimensionalitygt ltCurvePolygongt

| MULTIPOINT ltDimensionalitygt ltMultiPointgt

Special Character | 147

| MULTILINESTRING ltDimensionalitygt ltMultiLineStringgt

| MULTIPOLYGON ltDimensionalitygt ltMultiPolygongt

| MULTICURVESTRING ltDimensionalitygt ltMultiCurveStringgt

| MULTICURVEPOLYGON ltDimensionalitygt ltMultiCurvePolygongt

| GEOMETRYCOLLECTION ltGeometryCollectiongt

ltPointEntitygt = ( ltPointgt )

ltLineStringgt = ( ltPointCollectiongt )

ltPolygongt = ( ltLineStringCollectiongt )

ltMultiPointgt = ( ltPointCollectiongt )

ltMultiLineStringgt = ( ltLineStringCollectiongt )

ltMultiPolygongt = ( ltPolygonCollectiongt )

ltGeometryCollection ( ltFGF Collection Textgt )

ltCurveStringgt = ( ltPointgt ( ltCurveSegmentCollectiongt ) )

ltCurvePolygongt = ( ltCurveStringCollectiongt )

ltMultiCurveStringgt = ( ltCurveStringCollectiongt )

ltMultiCurvePolygongt = ( ltCurvePolygonCollectiongt )

ltDimensionalitygt = default to XY

| XY

| XYZ

| XYM

| XYZM

ltPointgt = DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE DOUBLE

ltPointCollectiongt = ltPointgt

| ltPointCollection ltPointgt

ltLineStringCollectiongt = ltLineStringgt

| ltLineStringCollectiongt ltLineStringgt

ltPolygonCollectiongt = ltPolygongt

148 | Chapter 11 Filter and Expression Languages

| ltPolygonCollectiongt ltPolygongt

ltFGF Collection Textgt = ltFGF Textgt

| ltFGF Collection Textgt ltFGF Textgt

ltCurveSegmentgt = CIRCULARARCSEGMENT ( ltPointgt ltPointgt )

| LINESTRINGSEGMENT ( ltPointCollectiongt )

ltCurveSegmentCollectiongt = ltCurveSegmentgt

| ltCurveSegmentCollectiongt ltCurveSegmentgt

ltCurveStringCollectiongt = ltCurveStringgt

| ltCurveStringCollectiongt ltCurveStringgt

ltCurvePolygonCollectiongt = ltCurvePolygongt

| ltCurvePolygonCollectiongt ltCurvePolygongt

The only other token type is DOUBLE representing a double precision floatingpoint values Integer (non-decimal point) input is converted to DOUBLE inthe lexical analyzer

Examples of the Autodesk extensions include

POINT XY (10 11) equivalent to POINT (10 11)

POINT XYZ (10 11 12)

POINT XYM (10 11 12)

POINT XYZM (10 11 12 12)

GEOMETRYCOLLECTION (POINT xyz (10 11 12)POINT XYM (30 20 18)LINESTRING XYZM(1 2 3 4 3 5 15 3 20 20))

CURVESTRING (0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40))))

CURVESTRING (0 0 (CIRCULARARCSEGMENT (11 11 12 12)LINESTRINGSEGMENT (10 10 20 20 30 40)))

CURVESTRING (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 30 40)))

CURVESTRING XYZ (0 0 0 (LINESTRINGSEGMENT (10 10 1 20 20 1 30 401)))

MULTICURVESTRING ((0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40)))(00 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 20 20 30 40))))

Geometry Value | 149

CURVEPOLYGON ((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20) ARC(20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 40 40 90 90))))

MULTICURVEPOLYGON (((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90))))((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90)))))

150 | Chapter 11 Filter and Expression Languages

The Geometry API

This chapter describes the FdoGeometry API (hereafter called the ldquoGeometry APIrdquo) and explainsthe various geometry types and formats

IntroductionThe Geometry API supports specific Autodesk applications and APIs includingFDO (Feature Data Objects) This API consists of the following components

a Geometry Type package (all through fully encapsulated interfaces)

an Abstract Geometry Factory

a Concrete Geometry Factory for FGF

You can work with the Geometry API in several different ways

FGF (Feature Geometry Format)

FGF Text

Abstract Geometry Factory

FGF and WKBWKB is a memory layout used to store geometry features This format was createdby the OpenGIS organization to allow the efficient exchange of geometry databetween different components in an FDO system Most pieces of the originalspecification defining the WKB format are in the document 99-050pdf theOpenGIS Simple feature specification for OLECOM that can be found atwwwopengisorg

12

151

FGF is an extended version of the Well Known Binary (WKB) format The twoformats differ in the following ways

WKB defines a byte order of the data in every piece of geometry This isstored as a byte field which may change the memory alignment fromword to byte In FGF only one memory alignment type is supported whichis the same alignment type used by the NET framework and Windowsthe encoding uses the little-endian byte order format As a result the byteflag does not need to be stored

WKB is defined as a 2D format only This is insufficient to represent 3Dpoints polylines and polygons In FGF the dimension flag has been addedIn particular a flag is included for each geometry piece to indicate whetherthe geometry is 2D 3D or even 4D (storing a measure value as used bydynamic segmentation

FGF includes geometry types that are not yet covered by any WKBspecification

FGF Binary SpecificationIn this section the memory layout of each simple geometry type is describedThe format is based on the OGC specification which is built on the memorylayout of a C++ struct All arrays have a computable size and are inline theydo not point to a different location in memory This format allows streamingof geometry data

First the different data types their size and memory layout are discussed

152 | Chapter 12 The Geometry API

double == 8byte IEEE double number in little endian encoding

int == 4 byte integer in little endian encoding

the type of the geometry

enum GeometryType int

None = 0

Point = 1

LineString = 2

Polygon = 3

MultiPoint = 4

MultiLineString = 5

MultiPolygon = 6

MultiGeometry = 7

CurveString = 10

CurvePolygon = 11

MultiCurveString = 12

MultiCurvePolygon = 13

Coordinate Types

This is a bit field for example xym == coordinateDimensionalityXY |CoordinateDimensionalityM The following sequence defines the type ofcoordinates used for this object

enum CoordinateDimensionality FdoInt32

XY = 0

Z = 1

M = 2

Basic Geometry

The following sequence establishes the basic pure geometry

struct Geometry

int geomType

CoordinateDimensionality type

FGF Binary Specification | 153

Notation Definition

The following sequence defines a notation used to specify geometries withina byte stream

154 | Chapter 12 The Geometry API

Define a notation within this specification

int PositionSize(geometry)

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM ||

geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityZ)

return 3

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM | CoordinateDimensionalityZ)

return 4

return 2

struct Point Geometry

int geomType == GeometryTypePoint

CoordinateDimensionality type all types allowed

double[] coords size = PositionSize(this)

struct LineString

int geomType

CoordinateDimensionality type

int numPts gt0

double[] coords size = numPts PositionSize(this)

struct MultiPoint

int geomType

int numPoints gt 0

Point[] points size = numPoints

struct MultiLineString

int geomType

int numLineStrings gt= 0

LineString[] lineStrings size = numLineStrings

building block for polygons not geometry by itself

struct LinearRing

int numPts gt0

double[] coords size = numPts PositionSize(polygon)

FGF Binary Specification | 155

struct Polygon

int geomType

CoordinateDimensionality type

int numRings gt= 1 as there has to be at least one ring

LinearRing[] lineStrings size = numRings

struct MultiPolygon

int geomType

int numPolygons gt= 0

Polygon[] polygons size = numPolygons

struct MultiGeometry

int geomType

int numGeom gt= 0

Geometry[] geometry size = numGeom

enum CurveElementType int

LineString = 1

CircularArc = 2

struct CurveStringElement

int CurveElementType

struct LinearCurveStringElement

int CurveElementType

int length

double[] coords size = thislength PositionSize (this)

struct CircularArcCurveStringElement

int CurveElementType == CurveElmentTypeArc

double[] coords size = 2 PositionSize(this)

struct CurveString

int geomType

156 | Chapter 12 The Geometry API

CoordinateDimensionality type all types allowed

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct Ring

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct MultiCurveString

int geomType

int numCurveStrings gt= 0

CurveString[] curveStrings size = numCurveStrings

struct CurvePolygon

int geomType

CoordinateDimensionality type

int numRings gt=1 as there has to be at least one ring

Ring[] rings size = numRings

struct MultiCurvePolygon

int geomType

int numPolygons gt=0

CurvePolygon[] polygons size = numElements

In the following example a polygon is formatted within a byte arrayrepresenting the stream according to the FGF specification

FGF Binary Specification | 157

T = 3 stands for GeometryType == GeometryTypePolygon

CT = 0 stands for CoordinateDimensionality == CoordinateDimensionalityXY

NR = 2 stands for number of rings = 2

NP =3 stands for number of points = 3

FGF TextFGF Text is the textual analogue to the binary FGF format It is a superset ofthe OGC WKT format XY dimensionality is the default and is optional FGFText can be used to represent any geometry value in the Geometry API whetheror not it originates from the FGF geometry factory Conversions are done withthe following methods

FdoGeometryFactoryAbstract CreateGeometry(FdoString text)

FdoIGeometry GetText()rdquo

A BNF for the FGF textual specification is contained in the topic GeometryValue on page 147

Abstract and Concrete ClassesThe Geometry API is almost completely abstract It provides an object-orientedinterface to geometry values All objects in the Geometry API have factorymethods in the FdoGeometryFactorytAbstract class One defaultimplementation is provided based on FGF in-memory binary storage It isaccessible via the concrete class FdoFgfGeometryFactory

NOTE The FdoFgfGeometryFactory employes object pooling for many of the datatypes in the API While many methods appear to be executing ldquoCreaterdquo or ldquoGetrdquoactions they are in fact accessing object pools thus avoiding costly operationson the memory heap

All of the other classes in the Geometry API with the exception of two relateto the main abstract type FdoIGeometry They either derive from it or arecomponents of it

158 | Chapter 12 The Geometry API

The two exception concrete classes are

FdoDirectPositionImpl a small helper class implementingFdoIDirectPosition

FdoEnvelopeImpl a small helper class implementing FdoIEnvelope

Geometries in FGF format can be exchanged between software componentswithout depending on the Geometry API itself because they are not genuinegeometry ldquoobjectsrdquo FGF content is based on byte arrays It is handled througha simple FdoByteArray class that is not specific to geometry

Geometry TypesThe Geometry types comprise the Global Enum FdoGeometryType Thefollowing are Geometry types

0 FdoGeometryType_None Indicates no specific type used for ldquounknownrdquoldquodo not carerdquo or an incompletely constructed Geometry object

NOTE FdoGeometryType_ None does not represent an instantiable type An FDOclient should not expect an FDO provider to list support for it in its capabilities

1 FdoGeometryType_Point Point type (FdoIPoint)

2 FdoGeometryType_LineString LineString type (FdoILineString)

3 FdoGeometryType_Polygon Polygon type (FdoIPolygon)

4 FdoGeometryType_MultiPoint MultiPoint type (FdoIMultiPoint)

5 FdoGeometryType_MultiLineString MultiLineString type(FdoIMultiLineString)

6 FdoGeometryType_MultiPolygon MultiPolygon type (FdoIMultiPolygon)

7 FdoGeometryType_MultiGeometry MultiGeometry type(FdoIMultiGeometry)

10 FdoGeometryType_CurveString CurveString type (FdoICurveString)

11 FdoGeometryType_CurvePolygon CurvePolygon type(FdoICurvePolygon)

Geometry Types | 159

12 FdoGeometryType_MultiCurveString MultiCurveString type(FdoIMultiCurveString)

13 FdoGeometryType_MultiCurvePolygon MultiCurvePolygon type(FdoIMultiCurvePolygon

Mapping Between Geometry and GeometricTypes

The FDO API GeometricType enumeration of GeometricProperty gives theclient application some knowledge of which geometry types comprise thegeometric property so that it can present the user with an intelligent editorfor selecting styles for rendering the geometry In particular GeometricTyperelates to shape dimensionality of geometries allowed in FDO geometricproperties The nearest analogues in the Geometry API are

FdoDimensionality which pertains to ordinate (not shape) dimensionalityof geometry values

FdoGeometryType which has types whose abstract base types map toGeometric Type

The GeometricType enumeration is as follows

Point = 0x01 Point Type Geometry

Curve = 0x02 Line and Curve Type Geometry

Surface = 0x04 Surface (or Area) Type Geometry

Solid = 0x08 Solid Type Geometry

NOTE The enumeration defines a bit mask and the GetGeometricTypes andSetGeometricTypes methods take and return an integer This is to allow a geometryproperty to be of more than one type For example the callgeometricPropertySetGeometricTypes(Point | Surface)

would allow the geometric property to represent either point type geometry orsurface type geometry (polygons)

160 | Chapter 12 The Geometry API

Spatial ContextSpatial Context is a coordinate system with an identity Any geometries thatare to be spatially related must be in a common spatial context

Providing an identify for each coordinate system supports separate workspacessuch as schematic diagrams which are non-georeferenced However thereare also georeferenced cases In general two users may create drawings usingthe same default spatial parameters (for example rectangular and10000x10000) that have nothing to do with each other If their drawingsare to be put into a common database the spatial context capability of FDOpreserves the container aspect of the data along wih the spatial parameters

The FDO Spatial Context Commands are part of the FDO API They supportcontrol over Spatial Contexts in the following ways

Metadata control Creates and deletes Spatial Contexts

Active Spatial Context A session setting to specify which Spatial Contextto use by default while storingretrieving geometries and performing spatialqueries

There is a default Spatial Context for each database Its attributes (such ascoordinate system) are specified when the database is created This SpatialContext is the active one in any FDO session until a Spatial Context Commandis used to change this state The default Spatial Contextrsquos identifier numberis 0 (zero)

Spatial contexts have two tolerance attributes XYTolerance and ZToleranceThe tolerances are in distance units that depend on the coordinate system inuse Geodetic coordinate systems typically have ldquoon the groundrdquo linear distanceunits instead of the angular (that is degrees minutes or seconds) units usedfor positional ordinates The meter is the most common unit Mostnon-geodetic systems are rectilinear and use the same unit for positionalordinates and distances for example meters or feet

Specify Dimensionality When CreatingGeometries Using String Specifications

When creating a 3D geometry from string specifications you must specify theDimensionality argument XYZ explicitly because the default dimensionalityis XY and the geometry factory code will only process the first two ordinates

Spatial Context | 161

The following code successfully creates pointOne as a 3D point whereaspointTwo is created as a 2D point

FdoFgfGeometryFactory geometryFactory = FdoFgfGeometryFact

oryGetInstance()

FdoIPoint pointOne

pointOne = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT XYZ (1 2 3)rsquo)rdquo))

FdoPoint pointTwo

pointTwo = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT (1 2 3)rsquo)rdquo))

xmlFeatureFlags = FdoXmlFeatureFlagsCreate( None FdoXmlFlagsEr

rorLevel_Normal True FdoXmlFeatureFlagsConflictOption_Add )

Inserting Geometry ValuesFor information about geometry property values see Geometry Property Valueson page 121

See Example Inserting an Integer a String and a Geometry Value on page122 for a code example that shows how to insert a Geometry value

162 | Chapter 12 The Geometry API

FDO Cookbook

IntroductionThis chapter contains code samples of common operations

Some operations like connection must discuss differences among providersReferences are made to both Autodesk proprietary providers and open sourceproviders Providers whose name begins with ldquoAutodeskrdquo are available only incommercial releases of Autodesk products Providers whose name begins withldquoOSGeordquo are available in releases of open source software at httpfdoosgeoorgSome of the open source providers are also available in commercial releases ofAutodesk products

Recommendations

After iterating through readers such IFeatureReader IDataReaderISQLDataReader or DbUserReader call the Close() or Dispose() method Notdoing so may cause unhandled exceptions at some future time Be sure toenclose the statement that returns a reader in a try block so that you canclose the reader in the catch block

RegistryThe registry contains the list of providers that are available in a particular FDOinstallation FDO initializes the registry using the contents of the providersxmlfile that is co-located with the FDO binaries

13

163

The FeatureProviderRegistryFeatureProviderName elements in theprovidersxml file contain fully qualified provider names A fully qualifiedprovider name has four parts which are separated by dot (lsquorsquo) characters Theparts areltdomaingtltshortNamegtltmajorReleaseNumbergtltminorReleaseNumbergtThere are two domains Autodesk and OSGeo The former indicates proprietaryand the latter open source software

Use Cases

Get a fully qualified provider name in order to create a a connection Thefully qualified name contains version numbers so having a dictionary thatmaps generic provider names to the currently loaded fully qualified nameis useful

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager andProviderCollection

OSGeoFDO for IProviderRegistry

IProviderRegistry registry = FeatureAccessManagerGetProviderRe

gistry()

ProviderCollection providers = registryGetProviders()

Map provider short name to fully qualified name

Dictionaryltstring stringgt providerAbbrToFullName = new Diction

aryltstring stringgt()

string shortName = null

foreach (Provider provider in providers)

shortName = providerNameSplit()[1]

providerAbbrToFullName[shortName] = providerName

ConnectionThe connection object contains a connection string property that containsthe connection parameter names and values The connection string propertycan be set by using a connection property dictionary or by assigning a

164 | Chapter 13 FDO Cookbook

connection string directly to it The property dictionaryrsquos methods tell youthe names of the connection parameters their current values and theiroptionality

Some parameters must always be set for a connection to succeed for examplethe OSGeoSDF File parameter and the AutodeskOracle Username Passwordand Service parameters Some parameters need not be set if you accept thedefault value For example the SDF ReadOnly parameter has a default settingof false The Oracle DataStore parameter need not be set if your objective isto obtain the names of the available data stores within the data source In thiscase connecting with Username Password and Service parameters results ina pending connection You can then query the DataStore parameter to getthe list of available data stores set the DataStore parameter to the value ofone of the list members and open the connection again but this time to afully operational state If you already know the name of the data store thatyou want you can set its value at the outset and open the connection fullywithout the intervening step

The following table sets out the names of the connection parameters for eachprovider

Connection ParametersProvider

Username Password Service DataStoreAutodeskOracle

DefaultRasterFileLocationAutodeskRaster

Username Password Service DataStoreAutodeskSqlServer

Server Instance Username Password DatastoreOsGeoArcSDE

DefaultRasterFileLocationOSGeoGdal

Username Password Service OracleSchema KingFdoClassOSGeoKingOracle

Username Password Service DataStoreOSGeoMySQL

UserId Password DataSourceName ConnectionStringGenerateDefaultGeometryProperty

OSGeoODBC

DataSource ReadOnlyOSGeoOGR

Connection | 165

Connection ParametersProvider

Username Password Service DataStoreOSGeoPostGIS

File ReadOnlyOSGeoSDF

DefaultFileLocationOSGeoSHP

Username Password Service DataStoreOSGeoSQLServerSpatial

FeatureServer Username PasswordOSGeoWFS

FeatureServer Username Password DefaultImageHeightOSGeoWMS

Use Cases

Create a connection to get the provider capabilities See the Capabilitieson page 168 topic

Get a list of the connection parameters

Determine the optionality of a parameter

Set the value of a parameter

Open and close connections

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager

OSGeoFDO for IConnectionManager

OSGeoFDOConnections for IConnectionImp IConnectionInfoIConnectionPropertyDictionary ConnectionState

Create a Connection

The connection is created in the closed state

166 | Chapter 13 FDO Cookbook

IConnectionManager connMgr = FeatureAccessManagerGetConnectionMan

ager()

string fullName = providerAbbrToFullName[ldquoOraclerdquo]

IConnectionImp conn = connMgrCreateConnection(fullName) as ICon

nectionImp

Determine the Names of the Parameters

Before a connection can be opened the connection parameters must beidentified and given values You can query a connection to identify theseparameters The code block shows the retrieval of the connection parameternames into a string array

IConnectionInfo connInfo = connectionConnectionInfo

IConnectionPropertyDictionary properties = connInfoConnectionProp

erties

string[] names = propertiesPropertyNames

Determine the Optionality of a Parameter

The code block shows determining the optionality of the first connectionparameter

Boolean isRequired = propertiesIsPropertyRequired(names[0])

Set a Parameter

The code block shows the setting of the Username parameter

propertiesSetProperty(ldquoUsernamerdquo ldquoEXISTINGUSERrdquo)

Get the Connection String

The code block shows getting the connection string value from the connection

string connectionString = connectionConnectionString

Open and Close a Connection

The code block shows opening and closing a connection Valid connectionstates are Busy Closed Open and Pending

ConnectionState connState = connectionOpen()

ConnectionState connState = connectionClose()

Connection | 167

CapabilitiesThe following code samples are a representative listing of the capabilitymethods in each category For a complete listing consult the API referencedocumentation

The capabilities for a provider are statically defined You create a connectionobject for the provider and use this object to query the capabilities Theconnection does not have to be open

Some capabilities are defined as booleans for example support for theDISTINCT operator in a SQL SELECT statement Sample code for this is shownin the Command section Some capabilities are defined by arrays of enumeratedtype values for example the feature commands The presence of the capabilityis determined by testing each value in the array for its equality with one ofthe values in the enumerated type range sample code that tests for thepresence of the create data store command is shown in the Command section

The schema capabilities include a string type that defines the characters thatmay not appear in a schema name and two integer types that define themaximum decimal precision and scale

Use Cases

Get the capabilities of a provider

Write code that executes if the provider currently in use supports it

C

The following namespaces and types are used

OSGeoFDOCommands for CommandType

OSGeoFDOCommandsLocking for LockType

OSGeoFDOCommandsSpatialContext for SpatialContextExtentType

OSGeoFDOCommon for GeometryComponentType GeometryType

OSGeoFDOConnectionsCapabilities for ICommandCapabiltiesIConnectionCapabilities IExpressionCapabilities IFilterCapabilitiesIGeometryCapabilities IRasterCapabilities ISchemaCapabilitiesFunctionDefinitionCollection FunctionDefinitionReadOnlySignatureDefinitionCollection SignatureDefinition

168 | Chapter 13 FDO Cookbook

ReadOnlyArgumentDefinitionCollection ArgumentDefinitionThreadCapability

OSGeoFDOExpression for ExpressionType

OSGeoFDOFilter for ConditionType DistanceOperationsSpatialOperations

OSGeoFDOSchema for ClassType DataType PropertyType

Command

ICommandCapabilities cmdCapabilities = connCommandCapabilities

int[] commands = cmdCapabilitiesCommands

Boolean supportsSelectDistinct = cmdCapabilitiesSupportsSelectDis

tinct()

CommandType cmdType = (CommandType)commands[0]

Boolean supportsCreateDataStore = false

for (int i = 0 i lt commandsGetLength(0) i++)

if (commands[i] == (int)CommandTypeCommandType_CreateDataStore)

supportsCreateDataStore = true

Connection

IConnectionCapabilities connCapabilities = connConnectionCapabil

ities

LockType[] lockTypes = connCapabilitiesLockTypes

SpatialContextExtentType[] spatialContextExtentTypes = connCapab

ilitiesSpatialContextTypes

ThreadCapability threadCapability = connCapabilitiesThreadCapab

ility

Boolean supportsConfiguration = connCapabilitiesSupportsConfigur

ation()

Capabilities | 169

Expression

IExpressionCapabilities exprCapabilities = connectionExpression

Capabilities

ExpressionType[] expressionTypes = exprCapabilitiesExpression

Types

FunctionDefinitionCollection functions = exprCapabilitiesFunc

tions

FunctionDefinition function = functions[0]

ReadOnlySignatureDefinitionCollection signatureDefs = functionSig

natures

SignatureDefinition signatureDef = signatureDefs[0]

PropertyType returnPropertyType = signatureDefReturnPropertyType

if (returnPropertyType == PropertyTypePropertyType_DataProperty)

DataType returnDataType = signatureDefReturnType

ReadOnlyArgumentDefinitionCollection arguments = signatureDefAr

guments

ArgumentDefinition argDef = arguments[0]

PropertyType argPropertyType = argDefPropertyType

if (argPropertyType == PropertyTypePropertyType_DataProperty)

DataType argDataType = argDefDataType

Filter

IFilterCapabilities filterCapabilities = connFilterCapabilities

Boolean supportsGeodesicDistance = filterCapabilitiesSupports

GeodesicDistance()

ConditionType[] conditionTypes = filterCapabilitiesConditionTypes

DistanceOperations[] distanceOperations = filterCapabilitiesDis

tanceOperations

SpatialOperations[] spatialOperations = filterCapabilitiesSpatia

lOperations

170 | Chapter 13 FDO Cookbook

Geometry

IGeometryCapabilities geometryCapabilities = connGeometryCapabil

ities

GeometryType[] geometryTypes = geometryCapabilitiesGeometryTypes

GeometryComponentType[] geometryComponentTypes = geometryCapabil

itiesGeometryComponentTypes

int dimensionalities = geometryCapabilitiesDimensionalities

Boolean HasZ = (dimensionalities amp 1) == 1

Boolean HasM = (dimensionalities amp 2) == 2

NOTE The dimensionalities integer contains bit-field definitions XY is 0 becauseall spatial data has at least an X and Y coordinate Z is 1 and M is 2 Use bitwiseAND (amp) to combine and bitwise OR (|) to separate

Raster

IRasterCapabilities rasterCapabilities = connRasterCapabilities

Boolean supportsRaster = rasterCapabilitiesSupportsRaster()

Schema

ISchemaCapabilities schemaCapabilities = connSchemaCapabilities

DataType[] dataTypes = schemaCapabilitiesDataTypes

ClassType[] classTypes = schemaCapabilitiesClassTypes

string reservedCharactersForName = schemaCapabilitiesReservedChar

actersForName

int maximumDecimalPrecision = schemaCapabilitiesMaximumDecimalPre

cision

DataType[] supportedAutoGeneratedTypes = schemaCapabilitiesSuppor

tedAutoGeneratedTypes

DataType[] supportedIdentityPropertyTypes = schemaCapabilitiesSup

portedIdentityPropertyTypes

Boolean supportsAutoIdGeneration = schemaCapabilitiesSupportsAut

oIdGeneration

Data StoreThe Sql Server SQL Server Spatial Oracle MySQL PostGIS and SDF providerssupport the following data store commands create destroy and with theexception of SDF list SDF is a file-based provider and the rest areRDBMS-based

Data Store | 171

By default the Sql Server Oracle MySQL and SDF providers create data storesthat contain FDO metadata By default the SQL Server Spatial provider createsa data store that does not contain the FDO metadata To make this providercreate a data store that does contain the FDO metadata you must set theIDataStorePropertyDictionary property IsFdoEnabled to true The PostGISprovider creates a data store without the FDO metadata

A provider uses the FDO metadata to

Assign a default spatial context to a Geometric Property Definition duringschema creation

When connected to the SDF Provider the CreateDataStore command createsan SDF file and the DestroyDataStore command deletes it There cannot bemultiple data stores in an SDF file and so there is no need for the list commandUnlike the RDBMS-based providers you do not have to open a pendingconnection in order to create and execute the CreateDataStore commandBefore executing the DestroyDataStore command close the connection

For the RDBMS-based providers creating a data store means creating a containerwithin a database There can be many data stores within a database and thelist command lists them

To create a data store in one of these RDBMS-based providers you open apending connection using an administrator account name and password andthen execute the CreateDataStore command Once you have created the datastore you close the administrator connection and open a normal userconnection This time you give a value to the DataStore connection parameterand open the connection to a fully operational state Before executing theDestroyDataStore command close the connection unset the DataStoreconnection parameter and reopen it using the administrator account nameand password in the pending state

C

The following namespaces are used

OSGeoFDOCommandsDataStore

OSGeoFDOCommands

172 | Chapter 13 FDO Cookbook

ICreateDataStore createDS = connCreateCommand(CommandTypeCom

mandType_CreateDataStore) as ICreateDataStore

IDataStorePropertyDictionary properties = createDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

createDSExecute()

IListDataStores listDS = connCreateCommand(CommandTypeCommand

Type_ListDataStores) as IListDataStores

IDataStoreReader reader = listDSExecute()

IDestroyDataStore destroyDS = connCreateCommand(CommandTypeCom

mandType_DestroyDataStore) as IDestroyDataStore

IDataStorePropertyDictionary properties = destroyDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

destroyDSExecute()

User ManagementThe providers may be categorized into five groups with respect to usermanagement The grouping criteria is the method used to create the username

The first group consists of the AutodeskOracle provider which has access toan FDO API for user management

The second group consists of MySQL SqlServer and SQLServerSpatial Theseproviders support the SQLCommand which can be used to create users

The third group consists of ODBC A username and password may be quiredto connect depending on the back-end data store On XP you use the ODBCData Source Administrator tool to configure the username

The third group consists of the web server providers WFS and WMS Ausername and password may be required depending on the site

The fourth group consists of the file-based providers which do not require ausername and password

The FDO User Management API

The AutodeskOracle provider has access to an FDO API for user managementBefore you can add a user you must have added the f_user_role to the databaseas described in the Preparations topic at the beginning of this chapter Duringthe add user operation the f_user_role is assigned to the new user You must

User Management | 173

open a pending connection using an administrator account name and passwordto add or drop a user

C

The AutodeskFdoFdoUtilitiesUserMgr namespace is used

IUserManagerImp userMgr = new IUserManagerImp(connection)

userMgrAddUser(AUserName APassword)

DbUserReader reader = userMgrGetDbUsers()

userMgrDropUser(AUserName)

The SQLCommand Method for User Management

List usersDrop a userAdd a userProvider

SELECT user FROM mysqluserWHERE user = lsquoAUserNamersquo

DROP USER lsquoAUser-Namersquo

CREATE USER lsquoAUserNamersquoIDENTIFIED BY lsquoAPasswordrsquo

MySQL

GRANT ALL ON TO lsquoAUs-erNamersquo

SELECT name FROM sysserv-er_principals WHERE name =lsquoAUserNamersquo

EXEC sp_droploginloginame = lsquoAUser-Namersquo

CREATE LOGIN AUserNameWITH password = lsquoAPass-wordrsquo EXEC sp_addsrvrole-

SqlServer andSQLServerSpa-tial

member loginame = lsquoAUs-erNamersquo rolename =lsquosysadminrsquo

C

The code samples use the SQL syntax supported by MySQL in the stringspassed to the FDO API command calls

The following namespaces are used

OSGeoFDOCommandsSQL

OSGeoFDOCommands

174 | Chapter 13 FDO Cookbook

create a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = create user AUserName identified by

APassword

int returnVal = sqlCommandExecuteNonQuery()

sqlCommandSQLStatement = grant all on to AUserName

returnVal = sqlCommandExecuteNonQuery()

drop a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = drop user AUserName

int returnVal = sqlCommandExecuteNonQuery()

list users

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = select user from mysqluser where user

= AUserName

ISQLDataReader reader = sqlCommandExecuteReader()

readerClose()

Spatial ContextA spatial context specifies a coordinate system and an extent for a set ofgeometries The spatial context object has a Name property The value of theName property is assigned to the SpatialContextAssociation property of theGeometricPropertyDefinition object that defines a feature or non-featuregeometry belonging to a feature class In this way a coordinate system andextent is associated with geometry values inserted into the data store as partof instances of the class Example code showing this association is containedin the Basic Schema Operations on page 178 topic

NOTE It is worth emphasizing that each geometric property definiton in a featureclass definition can have a different spatial context This mechanism replaces thatof the active spatial context

The data stores created by the Oracle Sql Server MySQL and optionally theSQL Server Spatial providers contain metadata that supports the assignmentof a default spatial context to a Geometric Property Definition during schema

Spatial Context | 175

creation in the event that the user has not explicitly assigned one The attributevalues of the default spatial context are set out in the following table

ValueAttribute

DefaultName

ltno valuegtCoordinateSystem

ltno valuegtCoordinateSystemWkt

SpatialContextExtentType_StaticExtentType

POLYGON((-2000000 -2000000 2000000 -20000002000000 2000000 -2000000 2000000 -2000000 -2000000))

Extent

C

The code samples show how to create a spatial context and how to get thespatial contexts from a data store

The following namespaces are used

OSGeoFDOCommandsSpatialContext

OSGeoFDOGeometry

OSGeoFDOConnections

176 | Chapter 13 FDO Cookbook

get the spatial contexts from a data store

IGetSpatialContexts getSpatialContexts = connectionCreateCom

mand(CommandTypeCommandType_GetSpatialContexts) as IGetSpatialCon

texts

ISpatialContextReader reader = getSpatialContextsExecute()

string name = null

string coordSys = null

string wellKnownText = null

string desc = null

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IGeometry geom = null

string extent = null

SpatialContextExtentType extentType

double xyTolerance

double zTolerance

while (readerReadNext())

name = readerGetName()

coordSys = readerGetCoordinateSystem()

wellKnownText = readerGetCoordinateSystemWkt()

desc = readerGetDescription()

geom = geomFactoryCreateGeometryFromFgf(readerGetExtent())

extent = geomText

extentType = readerGetExtentType()

xyTolerance = readerGetXYTolerance()

zTolerance = readerGetZTolerance()

readerDispose()

Spatial Context | 177

create a spatial context whose coordinate system is WGS84 and

whose extent is the maximum

create the extent

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

ICreateSpatialContext createSpatialContext = connectionCreateCom

mand(CommandTypeCommandType_CreateSpatialContext) as ICreateSpa

tialContext

createSpatialContextCoordinateSystem =

createSpatialContextCoordinateSystemWkt = wgs84Wkt

createSpatialContextDescription = This Coordinate System is used

for GPS

a static extent is defined once and never changed

a dynamic extent grows to accommodate the geometries added to

the data store

createSpatialContextExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

createSpatialContextExtent = extent

the value of Name is assigned to the SpatialContextAssociation

attribute of a GeometricPropertyDefinition object during the

creation of the logical feature schema

in this way a coordinate system and extent is associated with

the geoemtries

createSpatialContextName = WGS84 Spatial Context

createSpatialContextExecute()

Basic Schema OperationsAll providers allow you to describe a schema but only SDF SHP MySQLPostGIS SqlServer SQLServerSpatial KingOracle and Oracle allow you toapply and destroy a schema

178 | Chapter 13 FDO Cookbook

C

The code samples show how to describe apply and destroy a schema

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommands

OSGeoFDOSchema

describe a schema

IDescribeSchema descSchema = connCreateCommand(CommandTypeCom

mandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

FeatureSchema schema = schemas[0]

ClassCollection classes = schemaClasses

Class featureClass = classes[0]

PropertyDefinitionCollection properties = featureClassProperties

PropertyDefinition property = properties[0]

PropertyType propertyType = propertyPropertyType

if (propertyType == PropertyTypePropertyType_DataProperty)

DataPropertyDefinition dataPropDef = property as DataPropertyDefin

ition

DataType dataType = dataPropDefDataType

Basic Schema Operations | 179

create and apply a schema

FeatureSchema schema = new FeatureSchema(AnApplicationSchema

This schema contains one feature class)

FeatureClass featClass = new FeatureClass(AFeatureClass This

feature class contains one identity property one data property and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(ID

This is the identity property)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = true

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition int32Prop = new DataPropertyDefini

tion(Int32Prop This is an Int32 property)

int32PropDataType = DataTypeDataType_Int32

propertiesAdd(int32Prop)

add the feature geometry

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(FeatGeomProp This is the feature geometry)

associate this geometric property with a spatial context

you must have already added the named context to the data store

if this property is not set it is assigned the default spatial

context

see the Spatial Context topic to read a description of the de

fault spatial context

featGeomPropSpatialContextAssociation = XY-M Spatial Context

by default this geometric property can contain geometries that

may be classified as point curve surface or solid

also by default this geometric property cannot contain geomet

ries that have a Z ordinate or a measure attribute

propertiesAdd(featGeomProp)

without the following line you would be adding a non-feature

geometry

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

apply the schema

180 | Chapter 13 FDO Cookbook

IApplySchema applySchema = connCreateCommand(CommandTypeCommand

Type_ApplySchema) as IApplySchema

applySchemaFeatureSchema = schema

applySchemaExecute()

destroy the schema

IDestroySchema destroySchema = connCreateCommand(CommandTypeCom

mandType_DestroySchema) as IDestroySchema

destroySchemaSchemaName = AnApplicationSchema

destroySchemaExecute()

Insert DataAll providers except Gdal Raster WFS and WMS allow you to insert data

C

The code sample shows how to insert a feature consisting of a data value anda geometry value

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOGeometry

Insert Data | 181

Identifier className = new Identifier(FeatureClass)

IInsert insert = connCreateCommand(CommandTypeCommandType_Insert)

as IInsert

insertFeatureClassName = className

PropertyValueCollection values = insertPropertyValues

add the Int32 value to the insert command

int32Value = new Int32Value(5)

int32PropVal = new PropertyValue(Int32Prop int32Value)

valuesAdd(int32PropVal)

add the feature geometry to the insert command

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

DirectPositionImpl position1 = new DirectPositionImpl(10 10)

IPoint point = geomFactoryCreatePoint(position1)

GeometryValue geomVal = new GeometryValue(geomFactoryGet

Fgf(point))

PropertyValue geomPropVal = new PropertyValue(FeatGeomProp

geomVal)

valuesAdd(geomPropVal)

insert the feature

IFeatureReader reader = insertExecute()

readerClose()

Select DataAll providers allow you to select data

C

In the following code sample the filter is set to retrieve values for each featurein the database Without adding a computed identifier to the select commandrsquosproperty collection the select command would return all of the propertyvalues for each feature in the database In this example the computed identifiercontains a function expression that converts the DateTime value in theDateTimeProp property to a string and returns the string So the select returnsa set of DateTime strings

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

182 | Chapter 13 FDO Cookbook

OSGeoFDOFilter

Identifier className = new Identifier(FeatureClass)

ISelect select = connCreateCommand(CommandTypeCommandType_Select)

as ISelect

selectFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectFilter = filter

ComputedIdentifier computedId = ExpressionParse((ToString(Date

TimeProp) as computedId)) as ComputedIdentifier

selectPropertyNamesAdd(computedId)

IFeatureReader reader = selectExecute()

readerClose()

Select Aggregate DataAll providers except the PostGIS provider allow you to select aggregate data

C

In the following code sample the filter is set to retrieve values for each featurein the database The computed identifier contains a function expression thattakes the average of all of the values in the property whose name is Int32Propand returns a double

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

Select Aggregate Data | 183

Identifier className = new Identifier(FeatureClass)

ISelectAggregates selectAggregates = connCreateCommand(Command

TypeCommandType_SelectAggregates) as ISelectAggregates

selectAggregatesFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectAggregatesFilter = filter

ComputedIdentifier computedId = ExpressionParse((Avg(Int32Prop)

as computedId)) as ComputedIdentifier

selectAggregatesPropertyNamesAdd(computedId)

IDataReader reader = selectAggregatesExecute()

readerClose()

Delete DataAll providers except Gdal Raster WFS and WMS allow you to delete data

C

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

delete all of the data

ID is the name of the identity property

Filter filter = FilterParse(ID gt= 0)

Identifier className = new Identifier(FeatureClass)

IDelete delete = connCreateCommand(CommandTypeCommandType_Delete)

as IDelete

deleteFeatureClassName = className

deleteFilter = filter

int numDeleted = deleteExecute()

Schema OverridesWhen FDO connects to a datastore with an existing schema and describes theschema it maps the native data types to FDO data types to create a default

184 | Chapter 13 FDO Cookbook

physical to logical schema mapping You can create a schema mapping thatoverrides the default FDO mapping This schema override must be appliedevery time that you connect to the data store Use the providerrsquos SchemaOverride API to write a program that defines the overrides and writes themto an XML configuration file Thereafter before opening the connection tothe provider set the connection objectsrsquos configuration property to point tothe XML configuration file

The key elements to a schema override are an FDO feature schema and amapping of column names in the existing table to property names in the FDOfeature schema The ODBC provider supports the mapping of two columnnames in an existing table to a 2D FDO point geometry property and optionallysupports the mapping of three columns to a 3D point geometry property Inthe event that the mapping includes an FDO geometry property a spatialcontext definition should be provided

The description given here is based on sample code written to define a schemaoverride for a table in a Microsoft Access database The following table showsthe name of the column in the Access database which is the same as thedefault FDO property name the FDO property name assigned by the schemaoverride a description of the contents of the column the FDO data typeassigned by the default schema mapping and the FDO data type assigned bythe schema override

The default schema mapping of the CITY_ID and POPULATION columns areoverriden to assign them different data types than the default ones and togive them different names A change in case counts as a change in name Thedefault schema mapping of the LATITUDE and LONGITUDE columns areoverriden because they are combined into a single property that has a differentname and a different type than the defaults The default schema mapping ofthe NAME COUNTRY and CAPITAL columns are overriden to assign themdifferent names than the defaults The default schema mapping of the URLcolumn is not overriden and retains its default type and name

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

Int64Int16consecutive sequence of integersfrom 1 to lt 1000

IdCITY_ID

StringStringNamesNameNAME

StringStringNamesCountryCOUNTRY

Schema Overrides | 185

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

StringStringlsquoNrsquo or lsquoYrsquoCaptialCAPITAL

Not over-riden

StringnullNot over-riden

URL

Int32Doublepositive integers lt 17000000PopulationPOPULATION

GeometryDoublepositive and negative decimalsGeometryLATITUDE

GeometryDoublepositive and negative decimalsGeometryLONGITUDE

First a conceptual view of how to create the XML configuration file for aschema override is presented and then a code view is presented The overrideincludes a geometry property and so a spatial context is defined as well

1 Open the XML file

2 Create a spatial context for the geometry and write it to the XML file

3 Create the FDO feature schema and write it to the XML file

4 Create a connection to the provider and get a reference to theconnectionrsquos physical schema mapping

5 Use the reference to the connectionrsquos physical schema mapping and theSchema Override API to create the schema override whereby the logicalfields in the feature schema are associated with columns in the databasetable

6 Write the schema override to the XML file

7 Close the XML file

C

The following namespaces are used

OSGeoFDOCommonIo

OSGeoFDOCommonXml

186 | Chapter 13 FDO Cookbook

OSGeoFDOGeometry

OSGeoFDOSchema

Create the XML Schema Override Configuration File

Open the XML File

IoFileStream writeFileStream = new IoFileStream(Citiesxml w)

XmlWriter writer = new XmlWriter(writeFileStream)

Create a Spatial Context and Write It to the XML File

XmlSpatialContextFlags flags = new XmlSpatialContextFlags()

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(writer flags)

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

spatialContextWriterCoordinateSystem = WGS 84

spatialContextWriterCoordinateSystemWkt = GEOGCS [ Longitude

Latitude (WGS 84) DATUM [WGS 84 SPHEROID [WGS 84

6378137 298257223563]] PRIMEM [ Greenwich 0000000 ] UNIT

Decimal Degree 001745329251994330]]

spatialContextWriterDescription = This Coordinate System is used

for GPS

spatialContextWriterExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

spatialContextWriterExtent = extent

spatialContextWriterName = WGS84

spatialContextWriterXYTolerance = 0001

the next line writes the XML declaration the opening tag for

the fdoDataStore element

and the gmlDerivedCRS element to the XML file

spatialContextWriterWriteSpatialContext()

Schema Overrides | 187

Create the Feature Schema and Write It to the XML File

188 | Chapter 13 FDO Cookbook

FeatureSchema schema = new FeatureSchema(World Logical feature

schema)

FeatureClass featClass = new FeatureClass(Cities This feature

class contains one identity property many data properties and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(Id

This is the unique id number for the city)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = false

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition nameProp = new DataPropertyDefini

tion(Name This is the name of the City)

namePropDataType = DataTypeDataType_String

namePropLength = 64

propertiesAdd(nameProp)

DataPropertyDefinition countryProp = new DataPropertyDefini

tion(Country This is country that contains the city)

countryPropDataType = DataTypeDataType_String

countryPropLength = 64

propertiesAdd(countryProp)

DataPropertyDefinition populationProp = new DataPropertyDefini

tion(Population This is the population of the city)

populationPropDataType = DataTypeDataType_Int32

propertiesAdd(populationProp)

DataPropertyDefinition capitalProp = new DataPropertyDefini

tion(Capital This is Y or N to say whether the city is the

capital of the country)

capitalPropDataType = DataTypeDataType_String

capitalPropLength = 1

propertiesAdd(capitalProp)

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(Geometry This is the feature geometry)

featGeomPropGeometryTypes = (int)GeometricTypeGeometric

Type_Point

featGeomPropHasElevation = false

featGeomPropHasMeasure = false

propertiesAdd(featGeomProp)

Schema Overrides | 189

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

the next line writes the xsschema element to the XML file

schemaWriteXml(writer)

190 | Chapter 13 FDO Cookbook

Create the Physical Schema Mapping and Write It to the XML File

Schema Overrides | 191

set the connection to point

at the Microsoft Access database file

whose Data Source Name (DSN) has been

defined using the Data Sources (ODBC)

Windows XP administrative tool

connectionConnectionString = DataSourceName= + dataSourceName

get a reference to the PhysicalSchemaMapping object contained

in the connection

PhysicalSchemaMapping connectionSchemaMapping = connectionCreateS

chemaMapping()

use that reference to create an override physical schema mapping

the override definition associates columns in the columns of

the Access database with property names in the FDO feature schema

OvPhysicalSchemaMapping mapping = new OvPhysicalSchemaMapping(con

nectionSchemaMapping false)

mappingName = World

OvClassCollection overrideClasses = mappingClasses

OvClassDefinition overrrideClassDef = new OvClassDefinition(Cit

ies)

OvPropertyDefinitionCollection overrideProperties = overrride

ClassDefProperties

associate the table in the Access database with the override

class definition

OvTable table = new OvTable(Cities)

overrrideClassDefTable = table

associate the columns in the table in the Access database with

the properties in the FDO feature schema

OvColumn column = null

OvGeometricPropertyDefinition overridGeomProp = new OvGeometric

PropertyDefinition(Geometry)

overridGeomPropGeometricColumnType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricColumnTypeOvGeometricColumnType_Double

overridGeomPropGeometricContentType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricContentTypeOvGeometricContentType_Ordin

ates

overridGeomPropXColumnName = LONGITUDE

overridGeomPropYColumnName = LATITUDE

overridePropertiesAdd(overridGeomProp)

OvDataPropertyDefinition overrideIdProp = new OvDataPropertyDefin

ition(Id)

column = new OvColumn(CITY_ID) overrideIdPropColumn = column

overridePropertiesAdd(overrideIdProp)

192 | Chapter 13 FDO Cookbook

OvDataPropertyDefinition overrideNameProp = new OvDataPropertyDefin

ition(Name)

column = new OvColumn(NAME)

overrideNamePropColumn = column

overridePropertiesAdd(overrideNameProp)

OvDataPropertyDefinition overrideCountryProp = new OvDataProperty

Definition(Country)

column = new OvColumn(COUNTRY)

overrideCountryPropColumn = column

overridePropertiesAdd(overrideCountryProp)

OvDataPropertyDefinition overridePopulationProp = new OvDataProp

ertyDefinition(Population)

column = new OvColumn(POPULATION)

overridePopulationPropColumn = column

overridePropertiesAdd(overridePopulationProp)

OvDataPropertyDefinition overrideCapitalProp = new OvDataProperty

Definition(Capital)

column = new OvColumn(CAPITAL)

overrideCapitalPropColumn = column

overridePropertiesAdd(overrideCapitalProp)

overrideClassesAdd(overrideClassDef)

write the override definition to the XML file

XmlFlags flags = new XmlFlags()

the next line writes the SchemaMapping element to the XML file

mappingWriteXml(writer flags)

mappingDispose()

Write the Closing Tag and Close the XML File

the next line writes the closing tag of the fdoDataStore ele

ment to the XML file

writerWriteEndElement()

writerClose()

writerDispose()

writeFileStreamClose()

writeFileStreamDispose()

Configure a Connection to Use the Schema Override

The connection object contains a property whose value points to the XMLconfiguration file

Schema Overrides | 193

IConnection connection = connMgrCreateConnection(providerName)

IoFileStream configurationFileStream = new IoFileStream(Cit

iesxml r)

connectionConfiguration = configurationFileStream

connectionConnectionString = DataSourceName= + dataSourceName

connectionOpen()

Xml SerializeDeserializeThis code sample serializes the spatial context and feature schema of a datastore to an xml file and then deserializes it in another data store

C

This is the C code

Namespaces

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommonIo

OSGeoFDOCommonXml

OSGeoFDOSchema

OSGeoFDOXml

194 | Chapter 13 FDO Cookbook

Serialize

open the xml file

XmlWriter xmlWriter = new XmlWriter(xmlFilename)

serial the spatial contexts

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(xmlWriter)

XmlSpatialContextSerializerXmlSerialize(connection spatialContex

tWriter)

serialize the feature schemas

IDescribeSchema descSchema = connectionCreateCommand(Command

TypeCommandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

schemasWriteXml(xmlWriter)

clean up

spatialContextWriterDispose()

xmlWriterDispose()

C | 195

Deserialize

deserialize the spatial contexts

IoFileStream fileStream = new IoFileStream(xmlFilename r)

XmlReader xmlReader = new XmlReader(fileStream)

XmlSpatialContextReader xScReader = new XmlSpatialContextReader(xm

lReader)

XmlSpatialContextSerializerXmlDeserialize(connection xScReader)

fileStreamReset()

deserialize the schema

FeatureSchemaCollection schemas = new FeatureSchemaCollec

tion(null)

schemasReadXml(fileStream)

IApplySchema applySchema = connectionCreateCommand(CommandTypeCom

mandType_ApplySchema) as IApplySchema

FeatureSchema schema = null

for (int i = 0 i lt schemasCount i++)

schema = schemasget_Item(i)

applySchemaFeatureSchema = schema

applySchemaExecute()

fileStreamReset()

clean up

xmlReaderDispose()

fileStreamClose()

GeometryThe geometry code samples are divided into two parts The first is constructinggeometries The second is deconstructing them that is extracting informationfrom the geometry objects

Construction

Geometries can be constructed using a set of scaffolding classes which includesa geometry factory class or they can be constructed using the geometry factoryclass from text specifications The syntax for the text specifications is describedin the Geometry Value section in the Filter and Expression Languages chapter

196 | Chapter 13 FDO Cookbook

What follows here is a description of geometry construction using thescaffolding classes

Some geometries are constructed using a two step procedure First createcoordinates and then create the geometry Some geometries require anintermediate step Use the coordinates to create subcomponents and then usethe subcomponents to create the geometry The construction of somegeometries requires the use of helper collection classes Some of these classesare collections of geometries and some are collections of geometrysubcomponents

Simple geometries like point and line are constructed directly from coordinatesComplex geometries like curved lines and polygons are constructed fromgeometry subcomponents like arc and line segments and rings In generalsubcomponents are constructed from coordinates The exception is the ringwhich is constructed from arc and line segments The glue is the helpercollection classes for coordinates segments and rings

A geometry object may consist of homogeneous or heterogeneous aggregationsof points lines and polygons The glue is helper collection classes for pointslines and polygons

C Namespaces

The following namespaces are used

OSGeoFDOCommon

OSGeoFDOGeometry

C Geometry Scaffolding Classes

The scaffolding classes used to construct the simple complex and aggregategeometries are the following

the IDirectionPosition class used to construct positions (coordinates)

the FgfGeometryFactory class used to construct the geometrysubcomponents and geometries

the geometry subcomponent classes ILineStringSegmentICircularArcSegment ILinearRing and IRing

Construction | 197

the helper collection classes PointCollection LineStringCollectionCurveSegmentCollection LinearRingCollection RingCollectionPolygonCollection CurvePolygonCollection and GeometryCollection

IDirectPositionImpl

The IDirectPosition is the basic building block of geometries Use its constructorto define a coordinate Use instances of it to define the IPoint and ILineStringgeometries or to define the geometry subcompoonents ILinearRingICircularArcSegment and ILineStringSegment

DirectPositionImpl pos00 = new DirectPositionImpl(00 00)

FgfGeometryFactory

Use an instance of this class to do the following

create geometry subcomponents used to construct IGeometry-based objects

create IGeometry-based objects

convert IGeometry-based objects into binary-formatted geometries usedfor data store inserts

convert binary-formatted geometries retrieved during data store queriesinto IGeometry-based objects

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

Geometry Subcomponents

The following subcomponents are used in the construction of geometries andgeometry subcomponents

The ICircularArcSegment and ILineStringSegment subcomponents are usedto construct the ICurveString geometry and the IRing geometrysubcomponent

The ILinearRing subcomponent is used to contruct the IPolygon geometry

The IRing subcomponent is used to construct the ICurvePolygon geometry

198 | Chapter 13 FDO Cookbook

ICircularArcSegment

The creation of an instances uses IDirectPositionImpl objects whichrespectively define a start position a mid point and an end position for thearc

ICircularArcSegment as012122 = geomFactoryCreateCircularArcSeg

ment(pos01 pos21 pos22)

ILineStringSegment

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos23)

positionsAdd(pos30)

positionsAdd(pos33)

ILineStringSegment ls233033 = geomFactoryCreateLineStringSeg

ment(positions)

positionsClear()

ILinearRing

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos01)

positionsAdd(pos21)

positionsAdd(pos12)

positionsAdd(pos01)

ILinearRing lr01211201 = geomFactoryCreateLinearRing(positions)

positionsClear()

IRing

An IRing is constructed using a CurveSegmentCollection This collection cancontain ICircularArcSegment and ILineStringSegment objects

curveSegmentsAdd(as1340n20)

curveSegmentsAdd(lsn2013)

IRing rAs1340n20Lsn2013 = geomFactoryCreateRing(curveSegments)

curveSegmentsClear()

Construction | 199

Collection Classes

The following collection classes are used during the construction of the variousgeometries

Contains IDirectPositionImpl ojbects

DirectPositionCollection positions = new DirectPositionCollec

tion()

Contains IPoint objects

PointCollection points = new PointCollection()

Contains ILineString objects

LineStringCollection lines = new LineStringCollection()

Contains ICircularArcSegment and ILineStringSegment objects

CurveSegmentCollection curveSegments = new CurveSegmentCollec

tion()

Contains ICurveString objects

CurveStringCollection curves = new CurveStringCollection()

Contains ILinearRing objects

LinearRingCollection linearRings = new LinearRingCollection()

Contains IRing objects

RingCollection curveRings = new RingCollection()

Contains IPolygon objects

PolygonCollection linearPolygons = new PolygonCollection()

Contains ICurvePolygon objects

CurvePolygonCollection curvePolygons = new CurvePolygonCollec

tion()

GeometryCollection geometries = new GeometryCollection()

C Geometries Constructed usingIDirectPositionImpl

These geometries are IPoint and ILineString

IPoint

The creation of an instances uses an IDirectionPositionImpl object

IPoint pt00 = geomFactoryCreatePoint(pos00)

200 | Chapter 13 FDO Cookbook

ILineString

The creation of an instances uses a DirectPositionCollection object which iscomposed of IDirectionPositionImpl object

positionsAdd(pos01)

positionsAdd(pos21)

ILineString line0121 = geomFactoryCreateLineString(positions)

positionsClear()

C Geometries Constructed Using GeometrySubcomponents

These geometries are ICurveString IPolygon and ICurvePolygon

ICurveString

The creation of an instance uses a CurveSegmentCollection object whichcontains an ICircularArcSegment object and an ILineStringSegment object

ICurveString composed of a circular arc segment and a line

string segment

curveSegmentsAdd(as022223)

curveSegmentsAdd(ls233033)

ICurveString csAs022223Ls233033 = geomFactoryCreateCur

veString(curveSegments)

curveSegmentsClear()

IPolygon

The creation of an instance uses an ILinearRing object for the exterior ringand a LinearRingCollection object composed of ILinearRing objects for theinterior rings

IPolygon with one exterior ring and no interior rings

IPolygon polyEr01211201 = geomFactoryCreatePolygon(lr01211201

null)

IPolygon with one exterior ring and one interior ring

linearRingsAdd(lr01211201)

polyEr13n204013Ir01211201 = geomFactoryCreatePolygon(lr13n204013

linearRings)

linearRingsClear()

Construction | 201

ICurvePolygon

The creation of an instance uses an IRing object for the exterior ring and aRingCollection object composed of an IRing object for the interior rings

ICurvePolygon with one exterior ring rAs1340n20Lsn2013 which

is composed of an arc segment and a line segment

and one interior ring rLs0121Ls2112Ls1201 which is a triangle

made of three line segments

curveRingsAdd(rLs0121Ls2112Ls1201)

ICurve Polygon curvPolyErAs1340n20Lsn2013IrLs0121Ls2112Ls1201 =

geomFactoryCreateCurvePolygon(rAs1340n20Lsn2013 curveRings)

curveRingsClear()

C Aggregate Geometries

The aggregate geometries are IMultiPoint IMultiLineString IMultiCurveStringIMultiPolygon IMultiCurvePolygon and IMultiGeometry

IMultiPoint

The creation of an instance uses a PointCollection object

pointsAdd(pt00)

pointsAdd(pt11)

IMultiPoint pt00pt11 = geomFactoryCreateMultiPoint(points)

pointsClear()

IMultiLineString

The creation of an instance uses a LineStringCollection object

linesAdd(line0121)

linesAdd(line0222)

IMultiLineString line0121line0222 = geomFactoryCreateMultiLineS

tring(lines)

linesClear()

IMultiCurveString

The creation of an instance uses a CurveStringCollection object

202 | Chapter 13 FDO Cookbook

curvesAdd(csAs012122)

curvesAdd(csAs022223Ls233033)

IMultiCurveString aMultiCurvePolygon = geomFactoryCreateMultiCur

veString(curves)

curvesClear()

IMultiPolygon

The creation of an instance uses a PolygonCollection object

linearPolygonsAdd(polygonNum1)

linearPolygonsAdd(polygonNum2)

IMultiPolygon aMultiPolygon = geomFactoryCreateMultiPolygon(lin

earPolygons)

linearPolygonsClear()

IMultiCurvePolygon

The creation of an instance uses a CurvePolygonCollection object

curvePolygonsAdd(curvePolygonNum1)

curvePolygonsAdd(curvePolygonNum2)

IMultiCurvePolygon aMultiCurvePolygon = geomFactoryCreateMultiC

urvePolygon(curvePolygons)

curvePolygonsClear()

IMultiGeometry

The creation of an instance uses a GeometryCollection object

geometriesAdd(aPoint)

geometriesAdd(aMultiPoint)

geometriesAdd(aLineString)

geometriesAdd(aMultiLineString)

geometriesAdd(aCurveString)

geometriesAdd(aMultiCurveString)

geometriesAdd(aPolygon)

geometriesAdd(aMultiPolygon)

geometriesAdd(aCurvePolygon)

geometriesAdd(aMultiCurvePolygon)

IMultiGeometry aMultiGeometry = geomFactoryCreateMultiGeometry(geo

metries)

geometriesClear()

Construction | 203

C Geometries from Text Specifications

You can use the geometry factoryrsquos CreateGeometry method to creategeometries from text specifications Herersquos an IPoint example

IPoint pt11 = geomFactoryCreatePoint(pos11)

IPoint aSecondPt11 = geomFactoryCreateGeometry(pt11Text) as

IPoint

aThirdPt11 = geomFactoryCreateGeometry(POINT (1 1)) as IPoint

Deconstruction

Deconstruction means getting information such as dimensionality envelopetext specification geometry geometry subcomponents and positions(coordinates) The following table specifies the information available fromthe classes

Position means coordinate values Dimensionality values are XY XYZ XYMor XYZM Envelope means bounding rectangle The envelope for an aggregategeometry contains all of the included geometries Text means FGF well-knowntext specification IsClosed is a boolean specifying whether or not the startand end coordinates are identical

Information availableClass

position dimensionalityIDirectPosition

position dimensionality envelope textIPoint

dimensionality envelope text IPointIMultiPoint

position dimensionality envelope textILineString

dimensionality envelope text ILineStrinIMultiLineString

IsClosed position dimensionality envelopeILineStringSegment

IsClosed position dimensionality envelopeICircularArcSegment

204 | Chapter 13 FDO Cookbook

Information availableClass

position dimensionality envelope text ICircularArcSegment ILineStringSegmentICurveString

dimensionality envelope text ICurveStringIMultiCurveString

position dimensionality envelopeILinearRing

dimensionality envelope text ILinearRingIPolygon

dimensionality envelope text IPolygonIMultiPolygon

position dimensionality ICircularArcSegment ILineStringSegmentIRing

dimensionality envelope text IRingICurvePolygon

dimensionality envelope text ICurvePolygonIMultiCurvePolygon

dimensionality envelope text IPoint IMultiPoint ILineString IMultiLineStringICurveString IMultiCurveString IPolygon IMultiPolygon ICurvePolygon IMulti-CurvePolygon

IMultiGeometry

Coordinates

IDirectPosition aPosition

double X = aPositionX

double Y = aPositionY

double Z

double M

int dim = aPositionDimensionality

if ((dim amp 1) == 1)

Z = aPositionZ

if ((dim amp 2) == 2)

M = aPositionM

Deconstruction | 205

IDirectPosition (IPoint ILineString ICircularArcSegmentILineStringSegment ILinearRing)

IPoint aPoint

IDirectPosition position = aPointPosition

ILineString line

IDirectPosition aPosition = null

IDirectPosition startPosition = lineStartPosition

IDirectPosition endPosition = lineEndPosition

for (int i = 0 i lt lineCount i++)

aPosition = lineget_Item(i)

ICircularArcSegment arcSegment

IDirectPosition startPosition = arcSegmentStartPosition

IDirectPosition midPoint = arcSegmentMidPoint

IDirectPosition endPosition = arcSegmentEndPosition

ILineStringSegment lineSegment

IDirectPosition startPosition = lineSegmentStartPosition

IDirectPosition endPosition = lineSegmentEndPosition

DirectPositionCollection positions = lineSegmentPositions

foreach(IDirectPosition position in positions)

ICurveString curve

IDirectPosition startPosition = curveStartPosition

IDirectPosition endPosition = curveEndPosition

ILinearRing linearRing

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

ILinearRing ring

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

Dimensionality Envelope and Text

int dimensionality = aPointDimensionality

IEnvelope envelope = aPointEnvelope

string text = aPointText

206 | Chapter 13 FDO Cookbook

IsClosed (ICircularArcSegment and ILineStringSegment)

ICircularArcSegment arcSegment

bool isClosed = arcSegmentIsClosed

ILineStringSegment lineSegment

bool isClosed = lineSegmentIsClosed

IPoint and IMultiPoint

IMultiPoint aMultiPoint

IPoint aPoint = null

for (int i = 0 i lt aMultiPointCount i++)

aPoint = aMultiPointget_Item(i)

ILineString and IMultiLineString

IMultiLineString aMultiLineString

ILineString line = null

for (int i = 0 i lt aMultiLineStringCount i++)

line = aMultiLineStringget_Item(i)

ICurveString and IMultiCurveString

IMultiCurveString aMultiCurveString

ICurveString curve = null

for (int i = 0 i lt aMultiCurveStringCount i++)

curve = aMultiCurveStringget_Item(i)

Deconstruction | 207

ICircularArcSegment and ILineStringSegment (ICurveString andIRing)

ICurveString aCurveString

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt aCurveStringCount i++)

curveSegment = aCurveStringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

IRing ring

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt ringCount i++)

curveSegment = ringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

ILinearRing (IPolygon)

IPolygon aPolygon

ILinearRing anExteriorRing = aPolygonExteriorRing

ILinearRing anInteriorRing = null

for (int i = 0 i lt aPolygonInteriorRingCount i++)

anInteriorRing = aPolygonGetInteriorRing(i)

208 | Chapter 13 FDO Cookbook

IPolygon and IMultiPolygon

IMultiPolygon aMultiPolygon

IPolygon aPolygon = null

for (int i = 0 i lt aMultiPolygonCount i++)

aPolygon = aMultiPolygonget_Item(i)

IRing (ICurvePolygon)

ICurvePolygon aCurvePolygon

IRing anExteriorRing = aCurvePolygonExteriorRing

IRing anInteriorRing = null

for (int i = 0 i lt count i++)

anInteriorRing = aCurvePolygonget_InteriorRing(i)

ICurvePolygon and IMultiCurvePolygon

IMultiCurvePolygon aMultiCurvePolygon

ICurvePolygon aCurvePolygon = null

for (int i = 0 i lt aMultiCurvePolygonCount i++)

aCurvePolygon = aMultiCurvePolygonget_Item(i)

Deconstruction | 209

IMultiGeometry

IMultiGeometry aMultiGeometry

IGeometry geom = null

GeometryType geomType

IPoint pt = null

IMultiPoint mpt = null

ILineString line = null

IMultiLineString mline = null

ICurveString curve = null

IMultiCurveString mcurve = null

IPolygon poly = null

IMultiPolygon mpoly = null

ICurvePolygon curvPoly = null

IMultiCurvePolygon mCurvPoly = null

for (int i = 0 i lt aMultiGeometryCount i++)

geom = aMultiGeometryget_Item(i)

geomType = geomDerivedType

switch (geomType)

case GeometryTypeGeometryType_Point pt = geom as IPoint break

case GeometryTypeGeometryType_MultiPoint mpt = geom as IMulti

Point break

case GeometryTypeGeometryType_LineString line = geom as ILin

eString break

case GeometryTypeGeometryType_MultiLineString mline = geom as

IMultiLineString break

case GeometryTypeGeometryType_CurveString curve = geom as

ICurveString break

case GeometryTypeGeometryType_MultiCurveString mcurve = geom

as IMultiCurveString break

case GeometryTypeGeometryType_Polygon poly = geom as IPolygon

break

case GeometryTypeGeometryType_MultiPolygon mpoly = geom as

IMultiPolygon break

case GeometryTypeGeometryType_CurvePolygon curvPoly = geom as

ICurvePolygon break

case GeometryTypeGeometryType_MultiCurvePolygon mCurvPoly =

geom as IMultiCurvePolygon break

default break

210 | Chapter 13 FDO Cookbook

OSGeo FDO Provider forArcSDE

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ArcSDE

What Is FDO Provider for ArcSDEThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store A provider is a specific implementation of theFDO API that provides access to data in a particular data store ESRIreg ArcSDEreg

(Spatial Database Engine) is part of the ArcGIS 9 system ArcSDE manages theexchange of information between an (ArcGIS 9 Desktop) application and arelational database management system FDO Provider for ArcSDE provides FDOwith access to an ArcSDE 9-based data store which in this case must be Oracle9i (9206)

FDO Provider for ArcSDE SoftwareRequirements

Installed Components

FDO Provider for ArcSDE dynamically linked libraries are installed with the FDOSDK They are located in ltFDO SDK Install LocationgtFDObin You do nothave to do anything to make these DLLs visible

A

211

External Dependencies

The operation of FDO Provider for ArcSDE is dependent on the presence ofArcSDE 9 and a supported data source such as Oracle 9i in the networkenvironment The host machine running FDO Provider for ArcSDE must alsohave the required DLLs present which are available by installing either anArcGIS 91 Desktop application or the ArcSDE SDK For example the requiredDLLs are present if either ArcViewreg ArcEditorreg or ArcInforeg are installed Formore information about ArcGIS 91 Desktop applications and the ArcSDE SDKrefer to the ESRI documentation

Specifically in order for FDO Provider for ArcSDE to run three dynamicallylinked libraries sde91dll sg91dll and pe91dll are required and you mustensure that the PATH environment variable references the local foldercontaining these DLLs For example in Microsoft Windows if ArcGIS 91Desktop is installed to CProgram FilesArcGIS then the required ArcSDEbinaries are located at CProgram FilesArcGISArcSDEbin Similarly if theArcSDE SDK is installed to the default location then the required ArcSDEbinaries are located at CArcGisArcSDEbin The absence of thisconfiguration may cause the following exception message The ArcSDE runtimewas not found

FDO Provider for ArcSDE LimitationsThe FDO Provider for ArcSDE is based on a subset of the ArcSDE API Thissubset does not include the following

Raster functionality

Native ArcSDE metadata

The annotation data with the exception of the ANNO_TEXT column

ArcSDE LimitationsFDO Provider for ArcSDE must abide by limitations of the ArcSDE technologyto which it connects This section discusses these limitations

212 | Appendix A OSGeo FDO Provider for ArcSDE

Relative to ArcObjects API and ArcGIS Server API

The ArcSDE API does not support the following advanced functionality foundin the ArcObjects API and the newer ArcGIS Server API

Advanced geometries such as Bezier curves and ellipses

Relationships

Topology

Networks

Analysis

Linear referencing

Curved Segments

If ArcSDE encounters curved segments it will automatically tessellate themThis means that if you create a geometry containing an arc segment in anArcSDE table using ArcObjects API and then you try to read that geometryback using the ArcSDE API you will get a series of line segments thatapproximate the original arc segment That is you get an approximation ofthe original geometry

Locking and Versioning

ArcSDE permits row locks or table versioning provided that the ID columnwhich uniquely identifies the row is maintained by ArcSDE If there is no IDcolumn or the ID column is maintained by the user ArcSDE does not permitrow locking or table versioning to be enabled

NOTE In ArcSDE you can either lock rows in a table or version a table but youcannot do both at the same time To do either you must alter the tablersquosregistration

The following sections illustrate these three steps

1 The creation of a table

Relative to ArcObjects API and ArcGIS Server API | 213

2 The alteration of the table registration to identify one of the columndefinitions as the row ID column and to enable row locking

3 The alteration of the table registration to disable row locking and toenable versioning

Table Creation

The command is

sdetable -o create -t hassdemaintainedrowid -d name string(20)

fid integer(9) -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The Row Lock has no value and the value of Dependent Objects is None

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column

Row ID Column Type

Row Lock

Minimum Row ID

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Identity Row ID Column and Enable Row Locking

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -c fid -C sde -L

on -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

214 | Appendix A OSGeo FDO Provider for ArcSDE

NOTE The Row ID Column value is FID the Row ID Column Type value is SDEMaintained and the Row Lock value is Enable

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Enable

Minimum Row ID 1

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Disable Row Locking and Enable Versioning

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -L off -V MULTI -u

t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The ldquoRow Lockrdquo is ldquoNot Enablerdquo and ldquoDependent Objectsrdquo is ldquoMultiversionTablerdquo

Locking and Versioning | 215

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Not Enable

Minimum Row ID 1

Dependent Objects Multiversion Table

Dependent Object Names A18111 D18111

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

FDO Provider for ArcSDE ConnectionThis information supplements the Establishing a Connection chapter Youconnect to an ArcSDE data store indirectly through the ArcSDE server Theunderlying data source for the data store is a database such as Oracle TheArcSDE server is connected to the data source and mediates the requests thatyou send it

You can connect to FDO Provider for ArcSDE in one step if you already knowthe name of the data store that you want to use Otherwise you must connectin two steps

The minimum required connection properties for the initial call to Open()are server instance username and password Multiple users can access thedata store However access is password-protected The server property is thename of the machine hosting the ArcSDE server The instance property actsas an index into an entry in the services file An entry contains port andprotocol information used to connect to the ArcSDE server On a Windowsmachine the services file is located in CWINDOWSsystem32driversetcAssuming that the instance name is ldquoesri_sderdquo an entry would look somethinglike this ldquoesri_sde 5151tcp ArcSDE Server Listening Portrdquo

An ArcSDE data source may contain more than one data store For the firstcall to Open() a data store name is optional If successful the first call toOpen() results in the data store parameter becoming a required parameter anda list of the names of the data stores in the data source becoming availableYou must choose a data store and call Open() again

216 | Appendix A OSGeo FDO Provider for ArcSDE

If the data source supports multiple data stores the list returned by the firstcall to Open() will contain a list of all of the data stores resident in the datasource Otherwise the list will contain one entry ldquoDefault Data Storerdquo

If you know the name of the data store you can provide it for the first call toOpen() and make the connection in one step

Data Type MappingsThis section shows the mappings from FDO data types to ArcSDE data typesto Oracle data types

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDataType_Boolean

Not supportedNot supportedFdoDataType_Byte

DATEdateFdoDataType_DateTime

Not supportedNot supportedFdoDataType_Decimal

NUMBER(388)double(388)FdoDataType_Double

NUMBER(4)integer(4)FdoDataType_Int16

NUMBER(10)integer(10)FdoDataType_Int32

Not supportedNot supportedFdoDataType_Int64

NUMBER(62)float(62) typicalFdoDataType_SingleNUMBER(n8)float(0ltnlt=6 oltmltDBMSLimit)) possible

VARCHAR2(ltlengthgt)string(ltlengthgt)FdoDataType_String

LONG RAWblobFdoDataType_BLOB

Not supportedNot supportedFdoDataType_CLOB

Data Type Mappings | 217

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDatatype_UniqueID

Creating a Feature SchemaThis section describes the creation of the SampleFeatureSchema which is theexample feature schema described in the Schema Management chapter It alsodescribes the creation of the OGC980461FS schema which is the schemadefined in the OpenGIS project document 98-046r1

FDO Provider for ArcSDE does not support the creation or destruction offeature schema (that is does not support the FdoIApplySchema andFdoIDestroySchema commands) However it does support theFdoIDescribeSchema command The intended use of FDO Provider for ArcSDEis to operate on already existing feature schemas FDO Provider for ArcSDEsupports inserting selecting updating and deleting data in existing schemas

You can use FDO Provider for ArcSDE to operate on a new feature schemaHowever you must create the schema using ArcSDE tools In particular youuse the sdetable and sdelayer commands which can be used to create a schemain any of the data store technologies used by ArcSDE This part of thedescription is generic Other parts of the description are specific to Oracle andto Windows XP because Oracle is the data store technology and Windows XPis the operating system for this exercise

First you must create an Oracle username for the feature schema (that is thename of the Oracle user is the name of the feature schema) To do this youconnect as system administrator to the Oracle instance used by the ArcSDEserver The following command creates the user and grants to that user theprivileges necessary for the ArcSDE tool commands to succeed

grant connectresource to ltschemaNamegt identified by ltpasswordgt

Secondly you must log in to the host where the ArcSDE server is runningArcSDE tools are on the host machine where the ArcSDE server resides

TIP NetMeeting can be used to remotely login to where the ArcSDE Server isrunning and launch a command window (that is in the Run dialog box entercmd) The ArcSDE tool commands can be executed through the command windowDo not use CWINDOWSSYSTEM32COMMANDCOM because the line bufferis too short to contain the entire text of some of the SDE tool command strings

218 | Appendix A OSGeo FDO Provider for ArcSDE

Finally execute the sdetable and sdelayer commands in a command windowto create each of the classes Since you are executing these commands on thehost where the ArcSDE server is located you can omit the server name optionIf the ArcSDE server is connected to only one data store you can omit theservice option For more information about all of the ArcSDE commandsconsult the ArcSDE Developer Help Guide

SampleFeatureSchema

In this sample a feature schema called SampleFeatureSchema is created whichcontains one feature class called SampleFeatureClass This feature class hasthe following three properties

An Int32 called SampleIdentityDataProperty

A string called SampleNameDataProperty

A polygon geometry called SampleGeometricProperty

First use the sdetable -o create command to add the integer and stringproperties to SampleFeatureClass Then use the sdetable -o alter_reg commandto identify the SampleIdentityDataProperty as an identity property Finallyuse the sdelayer -o add command to add the geometric property toSampleFeatureClass This assumes that only one ArcSDE server service isrunning so that the -i option is optional The -i option takes a service nameas an argument

The sdetable -o create command can be invoked as follows

sdetable -o create -t SampleFeatureClass -d ldquoSampleIdentityData

Property INTEGER(10) SampleNameDataProperty STRING(64)rdquo -u

SampleFeatureSchema -p test

The -o option takes the command option name The -d option takes thecolumn definitions which is a quoted list of column namecolumn type pairsdelimited by commas The -u option takes an Oracle database user namewhich becomes the feature schema name The -p option takes a password

The sdetable -o alter_reg command is invoked as follows

sdetable -o alter_reg -t SampleFeatureClass -c SampleIdentityData

Property -C USER -u SampleFeatureSchema -p test

The -c option identifies the column name that will be the identity propertyThe -C option indicates whether SDE is supposed to generate the value orobtain it from the user You will be prompted to confirm that you want toalter the registration of the table

Creating a Feature Schema | 219

The sdelayer command is invoked as follows

sdelayer -o add -l SampleFeatureClassSampleGeometricProperty -E

0010050 -e a -u SampleFeatureSchema -p test

The -o option takes the command option name The -l option identifies thetable and column The -E option identifies the extents the arguments areltxminyminxmaxymaxgt The -e option identifies the geometry type withlsquoarsquo indicating an area shape

OGC980461FS

This schema contains the ten classes defined in the OpenGIS Project Document980946r1 The types of the properties belonging to the classes is similar tothat of SampleFeatureClass namely an integer a string and a geometry Onedifference is that the geometry in three of the classes is multipart Two ofthem have MULTIPOLYGON geometries and one of them has aMULTILINESTRING geometry A multipart geometry is indicated by addinga lsquo+rsquo to the entity argument to the -e option in the sdelayer command AMULTIPOLYGON geometry is indicated by ldquo-e a+rdquo and a MULTILINESTRINGgeometry is indicated by ldquo-e l+rdquo

An ArcSDE table cannot have two geometries This restriction impacts thedefinition of the buildings class which has a POLYGON and a POINTgeometry We have chosen to add the POINT geometry The OpenGIS 98-046r1document defines one query that references building objects and the POINTgeometry supports this query

NOTE The use of -E option in the sdelayer command defines the extents Thearguments are ltxminyminxmaxymaxgt The values provided below ensure thatyou will not receive any ldquoordinate out of boundsrdquo errors when inserting the98046r1 data

220 | Appendix A OSGeo FDO Provider for ArcSDE

ArcSDE Commands That Define the OGC980461FS Classes

Creating a Feature Schema | 221

sdetable -o create -t lakes -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t lakes -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l lakesshore -E 0010050 -e a -u OGC980461FS

-p test

sdetable -o create -t road_segments -d fid integer(10) name

string(64) aliases string(64) num_lanes integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t road_segments -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l road_segmentscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t divided_routes -d fid integer(10) name

string(64) num_lanes integer(10) -u OGC980461FS -p test

sdetable -o alter_reg -t divided_routes -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l divided_routescenterlines -E 0010050 -e l+

-u OGC980461FS -p test

sdetable -o create -t forests -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t forests -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l forestsboundary -E 0010050 -e a+ -u

OGC980461FS -p test

sdetable -o create -t bridges -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t bridges -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l bridgesposition -E 0010050 -e p -u

OGC980461FS -p test

sdetable -o create -t streams -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t streams -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l streamscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t buildings -d fid integer(10) address

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t buildings -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l buildingsposition -E 0010050 -e p -u

OGC980461FS -p test

222 | Appendix A OSGeo FDO Provider for ArcSDE

sdetable -o create -t ponds -d fid integer(10) name string(64)

type string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t ponds -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l pondsshores -E 0010050 -e a+ -u OGC980461FS

-p test

sdetable -o create -t named_places -d fid integer(10) name

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t named_places -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l named_placesboundary -E 0010050 -e a -u

OGC980461FS -p test

sdetable -o create -t map_neatlines -d fid integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t map_neatlines -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l map_neatlinesneatline -E 0010050 -e a -u

OGC980461FS -p test

Logical to Physical Schema MappingThis mapping does not apply because the ArcSDE provider does not supportthe ApplySchema command

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data types TheArcSDE provider talks to the ArcSDE server The server uses either Oracle orSql Server as the back-end data store technology So two schema mappins aredescribed here

Oracle 10gR2 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter The class name is the name of the tablecreated using the sdetable command The property names are the columnnames

Logical to Physical Schema Mapping | 223

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoSrdquo means that the storage typeused for the geometry is Oracle Spatial The -G argument ldquo26910rdquo is the SRID ofa coordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N The sqlplus command select cs_name from mdsyscs_srs where srid =

26910 returns NAD83 UTM zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde -u existinguser -p test -G 26910 -P 32 -t S

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int16NUMBER(4)SE_INT16 4SMINT4COL

UnmappedCHAR(38)SE_UUID 38ID

Int16NUMBER(4)SE_INT16 4INT16COL

224 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int32NUMBER(38)SE_INT32 10INT32COL

SingleNUMBER(62)SE_FLOAT32 6 2FLOAT32COL

DoubleNUMBER(154)SE_FLOAT64 7 2FLOAT64COL

Int32NUMBER(10)SEINT32 10INT10

SingleNUMBER(44)SE_FLOAT32 4 4FLOAT4_4

DoubleNUMBER(72)SE_FLOAT64 7 2DOUBLE7_2

StringVARCHAR2(64)SE_STRING 64STRING64

BLOBBLOBSE_BLOB 0BLOBCOL

UnmappedCLOBSE_CLOB 0CLOBCOL

StringNVARCHAR2(255)SE_NSTRING 255NSTRINGCOL

UnmappedNCLOBSE_NCLOB 0NCLOBCOL

DateTimeDATESE_DATE 0DATECOL

GeometryMDSYSSDO_GEOMETRYSE_SHAPE 0FEATGEOM

Int32NUMBER(38)SE_INT32 10OBJECTID

NOTE The OBJECTID column was not specified in the -d arguments of the sdetablecommand

Sql Server 2005 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter prefixed by ldquoSDE_rdquo The class name is the

Physical to Logical Schema Mapping | 225

name of the table created using the sdetable command The property namesare the column names

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoBrdquo means that the storage typeused for the geometry is Esri Binary The -G argument ldquo26910rdquo is the SRID of acoordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde_ss

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde_ss -u existinguser -p test -G 26910 -P 32 -t B

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int16smallintSE_INT16 4SMINT4COL

UnmappeduniqueidentifierSE_UUID 38ID

Int16smallintSE_INT16 4INT16COL

226 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int32intSE_INT32 10INT32COL

SinglerealSE_FLOAT32 6 2FLOAT32COL

DoublefloatSE_FLOAT64 7 2FLOAT64COL

Int32intSEINT32 10INT10

Singlenumeric(44)SE_FLOAT32 4 4FLOAT4_4

Singlenumeric(72)SE_FLOAT64 7 2DOUBLE7_2

Stringvarchar(64)SE_STRING 64STRING64

BLOBimageSE_BLOB 0BLOBCOL

UnmappedtextSE_CLOB 0CLOBCOL

Stringnvarchar(255)SE_NSTRING 255NSTRINGCOL

UnmappedntextSE_NCLOB 0NCLOBCOL

DateTimedateSE_DATE 0DATECOL

GeometryintSE_SHAPE 0FEATGEOM

FDO Provider for ArcSDE CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

FDO Provider for ArcSDE Capabilities | 227

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

locking

exclusive locking type

transactions

long transactions

SQL

multiple spatial contexts

specifying coordinate systems by name or ID without specifying WKT

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

228 | Appendix A OSGeo FDO Provider for ArcSDE

The following capabilities are supported

class and feature class class types

DateTime data type with a maximum length of 12 bytes

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 4294967296

BLOB data type with a maximum length of 4294967296

Int32 auto-generated data type

Identity properties of type DateTime Double Int16 Int32 Single Stringand BLOB

Name size limitation of 123 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 65 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 160 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 32 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite unique value constraints

Multiple schemas

Null value constraints

Unique value constraints

FDO Provider for ArcSDE Capabilities | 229

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ActivateSpatialContext

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLComnmand

FdoCommandType_AcquireLock

FdoCommandType_GetLockInfo

FdoCommandType_GetLockedObjects

FdoCommandType_GetLockOwners

FdoCommandType_ReleaseLock

FdoCommandType_ActivateLongTransaction

FdoCommandType_DeactivateLongTransaction

FdoCommandType_CommitLongTransaction

FdoCommandType_CreateLongTransaction

FdoCommandType_GetLongTransactions

230 | Appendix A OSGeo FDO Provider for ArcSDE

FdoCommandType_RollbackLongTransaction

FdoCommandType_ListDataStores

The following capabilities are supported

command parameterization

simple functions in Select and SelectAggregate commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

the Beyond and Within distance operations

spatial operations of type Contains Crosses Disjoint Equals IntersectsOverlaps Touches Within CoveredBy Inside and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic expressions are supported

The following functions are supported

Double Sum(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Int64 Count(lttypegt value) where lttypegt is one of Boolean Double SingleDecimal Byte DateTime Int16 Int32 Int64 String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

FDO Provider for ArcSDE Capabilities | 231

Double Avg(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double Max(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double StdDev(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

232 | Appendix A OSGeo FDO Provider for ArcSDE

OSGeo FDO Provider forMySQL

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor MySQL

What Is FDO Provider for MySQLThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for MySQL provides FDO withaccess to a MySQL-based data store

The FDO Provider for MySQL API provides custom commands that arespecifically designed to work with the FDO API For example using thesecommands you can do the following

Gather information about a provider

Transmit client services exceptions

Get lists of accessible data stores

Create connection objects

Create and execute spatial queries

The MySQL architecture supports different storage engines Choose an engineas needed depending on its characteristics and capabilities such as the following

MyISAM is a disk-based storage engine It does not support transactions

InnoDB is a disk-based storage engine It has full ACID transaction capability

B

233

Memory (Heap) is a storage engine utilizing only RAM It is very fast

NDB is the MySQL Cluster storage engine

MERGE is a variation of MyISAM A MERGE table is a collection of identicalMyISAM tables which means that all tables have the same columnscolumn types indexes and so on

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for MySQL API Reference Help(MySQL_Provider_APIchm)

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in thecommandrsquos class collection The mapping of logical FDO data types to nativetypes is described here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the numberof digits to the right of the decimal point The maximum number of digits in thenative type is 64

NOTE The definition of the FDO String data type requires that the length propertybe set

Native Data TypeFDO Data Type

tinyint(4)Boolean

tinyint(3) unsignedByte

datetimeDateTime

decimal(204)Decimal (precision = 20 scale = 4)

doubleDouble

smallint(6)Int16

234 | Appendix B OSGeo FDO Provider for MySQL

Native Data TypeFDO Data Type

int(11)Int32

bigint(20)Int64

doubleSingle

varchar(64)String (length is 64)

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The name of the schema is the concatenation of lsquoFdorsquo and the name of thedatabase This is the database created using the lsquoCREATE DATABASErsquo commandand containing the existing table(s) The table names are the class names andthe column names are the property names

NOTE The length of a bit field is in the range 1-64 A row in a column of typebit(64) can hold 64 bit values

NOTE The following native types are not mapped to FDO data types float floatunsigned real unsigned double unsigned binary varbinary tinyblob blobmediumblob longblob tinytext mediumtext and longtext

FDO Data TypeDefaultsNative Type

Booleanlength = 1bit(

Bytebit(2)

Int64bit(64)

Int16length = 4tinyint

Physical to Logical Schema Mapping | 235

FDO Data TypeDefaultsNative Type

Bytelength = 3tinyint unsigned

Int16length = 6smallint

Int32length = 5smallint unsigned

Int32length = 9mediumint

Int32length = 8mediumint unsigned

Int32length = 11int

Int64length = 10int unsigned

Int64length = 20bigint

Int64length = 20bigint unsigned

Doublereal

Doubledouble

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric unsigned

DateTimedate

DateTimedatetime

DateTimetimestamp

Int32year

236 | Appendix B OSGeo FDO Provider for MySQL

FDO Data TypeDefaultsNative Type

String (length = 192)char(64)

String (length = 192)varchar(64)

Stringenum

Stringset

FDO Provider for MySQL CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

transactions

FDO Provider for MySQL Capabilities | 237

SQL

multiple spatial contexts

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 95 digits (maximum decimalprecision of 65 and maximum decimal scale of 30)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 2147483647

Int64 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Datastore

238 | Appendix B OSGeo FDO Provider for MySQL

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Composite unique value constraints

Datastore scope unique ID generation

Default value

Exclusive value range constraints

Inclusive value range constraints

Inheritance

Multiple schemas

Null value constraints

Object properties

Unique value constraints

Schema modification

Schema overrides

Unique value constraints

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()

FDO Provider for MySQL Capabilities | 239

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

FdoCommandType_ListDataStores

FdoCommandType_DescribeSchemaMapping

FdoCommandType_SQLComnmand

FdoRdbmsCommandType_CreateSpatialIndex

FdoRdbmsCommandType_DestroySpatialIndex

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

240 | Appendix B OSGeo FDO Provider for MySQL

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

spatial operations of type Intersects and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic function and parameter expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Decimal Double SingleInt16 Int32 or Int64

Decimal Ceil(lttypegt value) where lttypegt is one of Decimal or Double

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single or String

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

FDO Provider for MySQL Capabilities | 241

Byte Min(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

Double Sum(lttypegt value) where lttypegt is one of Decimal Double Int16Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

242 | Appendix B OSGeo FDO Provider for MySQL

OSGeo FDO Provider forODBC

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ODBC

What Is FDO Provider for ODBCThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for ODBC provides FDO withaccess to an ODBC-based data store

The FDO Provider for ODBC can access simple x y z feature objects that canrun in a multi-platform environment including Windows Linux and UNIX

The FDO Provider for ODBC has the following characteristics

The FDO Provider for ODBC supports the definition of one or more featureclasses in terms of any relational database table that contains an X Y andoptionally Z columns

Metadata which maps the table name and X Y and optionally Z columnsto a feature class is maintained outside the database in a configuration fileThis information in conjunction with the table structure in the databaseprovides the definition of the feature class

The x y and z locations of objects are stored in separate properties in theprimary object definition of a feature but are accessible through a singleclass property lsquoGeometryrsquo

C

243

Read-only access is provided to pre-existing data defined and populatedthrough 3rd party applications (that is FDO Provider for ODBC will notbe responsible for defining the physical schema of the data store nor forpopulating the object data)

The schema configuration of the data store is provided to the FDO Providerfor ODBC through an optional XML file containing the Geographic MarkupLanguage (GML) definition of the schema that maps lsquotablesrsquo and lsquocolumnsrsquoin the data store to feature classes and property mappings in the FDO datamodel

NOTE Microsoft Excel (must have at least one named range do not use DATABASEor other reserved words as a range name)

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for ODBC API Reference Help (ODBC_Provider_APIchm)

Physical to Logical Schema MappingsMappings of data in three data sources a Microsoft Access database (an accdbfile) an Excel spreadsheet (xlsx file) and a text file to FDO data types areshown

Microsoft Access

Use the ODBC provider to connect to a Microsoft Access database

The schema name is ldquoFdordquo There is only one database per file so there canbe only one schema The table names are used for class names Column namesare used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are AutoNumberReplication ID NumberReplication ID and OLE objectThe mapping of the rest of the native data types is in the following table

244 | Appendix C OSGeo FDO Provider for ODBC

NOTE The AutoNumber Number and DateTime native types are sub-typed Ifa column named X and a column named Y both typed NumberDouble arepresent they are mapped to an FDO geometric property whose type is Point andwhose spatial context association property is ldquoDefaultrdquo

FDO TypeNative TypeSubType

Int32AutoNumberLong Integer

Notmapped

AutoNumberReplication ID

StringText

StringMemo

ByteNumberByte

Int16NumberInteger

Int32NumberLong Integer

SingleNumberSingle

DoubleNumberDouble

DecimalNumberDecimal

Notmapped

NumberReplication ID

DateTimeDateTimeGeneral Date

DateTimeDateTimeLong Date

DateTimeDateTimeMedium Date

DateTimeDateTimeShort Date

Physical to Logical Schema Mappings | 245

FDO TypeNative TypeSubType

DateTimeDateTimeLong Time

DateTimeDateTimeMedium Time

DateTimeDateTimeShort Time

DecimalCurrency

BooleanYesNo

Notmapped

OLE object

StringHyperlink

StringAttachment

Microsoft Excel

Use the ODBC provider to connect to an Excel file

The schema name is ldquoFdordquo There is only one schema per file The range namesare used for class names Column names are used for property names A columnname is a text entry in a cell that is at the top of a column as defined by theboundaries of the named range

If a column named X and a column named Y are present they are mappedto an FDO geometric property whose type is Point and whose spatial contextassociation property is ldquoDefaultrdquo

Three approaches were used to explore the mapping The first approach lookedat the effect of cell content the second approach looked at the effect of cellformat the third approach looked at the effect of both

The first approach involved copying data from a Microsoft Access databaseinto an Excel spreadsheet The copy operation created a named range thatincluded all of the copied data The name for the range came from the Accessdatabase By default all of the Excel cells have a format type of ldquoGeneralrdquo The

246 | Appendix C OSGeo FDO Provider for ODBC

accompanying table shows the mapping of sample cell content to FDO datatype

FDO TypeCell Content

Double2

Double6452067

StringRussia

Stringltemptygt

StringN

NOTE All of the data in each column was consistent The column containing ldquo2rdquocontained only positive integers The column containing ldquo6452067rdquo containedonly similar numbers including negative values The column containing the lsquoNrsquocontained only single characters that were either lsquoNrsquo or lsquoYrsquo The column containingldquoRussiardquo contained only names The column containing an empty cell containedonly empty cells

The second approach involved setting up a named range consisting of 9columns by 2 rows The cells of the first row are formatted as ldquoGeneralrdquo andcontain column labels The cells of the second row are formatted respectivelyldquoGeneralrdquo ldquoNumberrdquo ldquoCurrencyrdquo ldquoAccountingrdquo ldquoDaterdquo ldquoTimerdquoldquoPercentagerdquo ldquoFractionrdquo ldquoScientificrdquo and ldquoTextrdquo No cell in the second rowhas content The accompanying table shows the mapping of cell format toFDO data type

FDO TypeExcel Cell Format

StringGeneral

DoubleNumber

DecimalCurrency

DecimalAccounting

Physical to Logical Schema Mappings | 247

FDO TypeExcel Cell Format

DateTimeDate

DateTimeTime

DoublePercentage

DoubleFraction

DoubleScientific

StringText

The intent of the third approach is to understand how the mapping wouldbe affected by content that violated the cellrsquos format or was inconsistent withthe data in the rest of the column

Inserting ldquohererdquo in the cells formatted as Number Currency AccountingDate Time Percentage Fraction and Scientific caused them to be mapped toString

Inserting -1225 in the cell formatted as Currency caused no change in themapping to Decimal

Inserting 1225 in the cell formatted as Date caused no change in the mappingto DateTime Excel converted 1225 to ldquo1121900 60000 AMrdquo

Inserting ldquohererdquo in one of the cells in the column of integers copied from theAccess database resulted in no change to the mapping to Double This maybe a bug

Text File

Use the ODBC provider to connect to a text file You must first create a DSNusing the XP Data Sources (ODBC) administrative tool The DSN maps to adirectory not a file Each file in the directory is mapped to an FDO class

248 | Appendix C OSGeo FDO Provider for ODBC

NOTE When selecting the directory for the DSN you will notice a listing of thefiles recognized as text files by the driver It will recognize Vim backup files forexample Citiestxt~ as text files The execution of a describe schema commandon a directory containing a Vim backup file caused an exception whose messageis ldquoRDBMS [Microsoft][ODBC Text Driver] Cannot update Database or object isread-onlyrdquo Removal of the Vim backup file prevented this exception

The schema name is ldquoFdordquo There is only one schema per directory The classname is the name of the file for example ldquoCities_txtrdquo The property namesare taken from the first line in the file Here are the first two lines from acomma-delimited text file The property names are ldquoCITY_IDrdquo ldquoNAMErdquo etcThe table shows the mapping of the sample text to FDO data type

CITY_IDNAMECOUNTRYPOPULATIONCAPITALLATITUDELON

GITUDEURLFOUNDED

1MurmanskRussia468000N689633087172008 00000

FDO Data TypeSample Text

Int32468000

StringRussia

Double6896

Stringltemptygt

NOTE Changing ldquoLATITUDErdquo to ldquoYrdquo and ldquoLONGITUDErdquo to ldquoXrdquo causes these twofields to be mapped to a geometric property called ldquoGeometryrdquo whose spatialcontext association is to a spatial context called ldquoDefaultrdquo

FDO Provider for ODBC CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

FDO Provider for ODBC Capabilities | 249

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

SQL

XML configuration

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 56 digits (maximum decimalprecision of 28 and maximum decimal scale of 28)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

250 | Appendix C OSGeo FDO Provider for ODBC

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Auto-generated data types Int16 and Int64

Identity properties of type Boolean Byte and DateTime

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite ID

Default value

Inheritance

Multiple schemas

Null value constraints

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaning

FDO Provider for ODBC Capabilities | 251

of the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLCommand

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Intersects Within Inside and EnvelopeIntersects

252 | Appendix C OSGeo FDO Provider for ODBC

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The full range of expression functions are supported as set out in theCapabilities chapter

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZ is supported The Point geometry types is supported

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for ODBC Capabilities | 253

254

OSGeo FDO Provider forSDF

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SDF

What Is FDO Provider for SDFThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SDF is a standalone fileformat that supports GIS data

The FDO Provider for SDF uses Autodesks spatial database format which is afile-based personal geodatabase that supports multiple featuresattributes spatialindexing interoperability file-locking and high performance for large datasets

The SDF file format has the following characteristics

SDF files can be read on different platforms

The SDF file has its own spatial indexing

SDF files can store geometric and non-geometric data with minimumoverhead

Although it does not support concurrency control (locking) the SDF fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SDF API Reference Help (SDF_Provider_APIchm)

D

255

FDO Provider for SDF CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per command threaded

dynamic spatial content extent type

Write

Flush

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

256 | Appendix D OSGeo FDO Provider for SDF

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Int32 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Exclusive value range constraints

FDO Provider for SDF Capabilities | 257

Inclusive value range constraints

Inheritance

Null value constraints

Schema modification

Value constraints list

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

SdfCommandType_ExtendedSelect

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

258 | Appendix D OSGeo FDO Provider for SDF

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Contains Disjoint Inside Intersects Withinand EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty geomValue)

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBGeometricProperty AssociationProperty

Double Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

FDO Provider for SDF Capabilities | 259

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeometry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

260 | Appendix D OSGeo FDO Provider for SDF

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SDF Capabilities | 261

262

OSGeo FDO Provider forSHP

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SHP

What Is FDO Provider for SHPThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SHP provides FDO withaccess to an SHP-based data store

The FDO Provider for SHP uses a standalone file format that supports GIS dataThe FDO Provider for SHP (Shape) has the following characteristics

Read-only access is provided to pre-existing spatial and attribute data froman Environmental Systems Research Institute (ESRI) Shape file (SHP)

The FDO Provider for SHP can run in a multi-platform environmentincluding Windows and Linux

A Shape file consists of three separate files SHP (shape geometry) SHX (shapeindex) and DBF (shape attributes in dBASE format)

The FDO Provider for SHP accesses the information in each of the threeseparate files and treats each SHP and its associated DBF file as a featureclass with a single geometry property and optionally with data attributeproperties

Schema configuration of the data store is provided to the FDO Provider forSHP through an XML file containing the Geographic Markup Language

E

263

(GML) definition of the schema that maps SHP and DBF data in the datastore to feature classes and property mappings in the FDO data model

Although it does not support concurrency control (locking) the SHP fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SHP API Reference Help (SHP_Provider_APIchm)

Creating SHP Files for the Logical to PhysicalSchema Mapping

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The shape files used for the purpose of mapping FDO logical types to shapenative types were created using the following method The path argument isthe path to a filename whose pattern is ltbasegtshp The type argument specifiesthe type of the shape filersquos geometry for example ShapLibShapeTypePointExecution of the method creates the named ltbasegtshp file as well as altbasegtshx file

using MapTools

public bool CreateShpFile(string path ShapeLibShapeType type)

IntPtr hShp = ShapeLibSHPCreate(path type)

if (hShpEquals(IntPtrZero)) return false

else

ShapeLibSHPClose(hShp)

return true

The FDO ApplySchema creates the ltbasegtdbf and ltbasegtcpg It will alsocreate the ltbasegtprj file if a spatial context has been created and the nameof the coordinate system referenced by the spatial context definition has beenassigned to the feature geometric property definitionrsquos spatial contextassociation property

264 | Appendix E OSGeo FDO Provider for SHP

Creating SHP Files for the Physical to LogicalSchema Mapping

To do the physical to logical schema mapping requires shp files containingall possible shp data types Two approaches for creating such shp files havebeen used The first approach is to use the ArcSDE sde2shp command toconvert an ArcSDE schema to a shapefile schema The second approach is touse the ShapeLib C library to create the shapefiles

sde2shp

This command converts the contents of an ArcSDE data store into a set ofshape files The conversion is guided by a text specification that maps anArcSDE column name to a tuple consisting of a shape table column name ashape column type identifier a column width and optionally the number ofdeciaml places

The source ArcSDE data store for this exercise is that specified in the ArcSDEappendix in the topic about physical to logical schema mapping The datastore contained a table called ldquoExistingTablerdquo This table containing a geometrycolumn called ldquofeatgeomrdquo The featgeom column allows only point geometriesto be stored A shape geometry can only be of one type So for the conversionto work the ArcSDE geometry column has to be restricted to contain onlyone geometry type The source ArcSDE data store contained no data TheArcSDE geometry was created with a coordinate system specified

The syntax of the command follows sde2shp -o init -l

ExistingTablefeatgeom -f points -a file=pointstxt -t point -i

esri_sde_ss -u sde -p fdotest The -f argument becomes the root name ofthe shape files that are created by the command (pointsshp pointsshxpointsdbf pointsidx and pointsprj) The -t argument is the shape geometrytype The -i argument is the name of the ArcSDE server instance the symbolicname is mapped to a TCP port in theCWINDOWSsystem32driversetcservices file The -u and -p argumentsidentify a username and password in the data store The -a argument identifiesthe file used to specify the conversion of the non-geometry columnconversions

The contents of the pointstxt conversion file are as follows

Creating SHP Files for the Physical to Logical Schema Mapping | 265

smInt4Col smInt4 N 4

int16Col int16Col N 4

int32Col int32Col N 10

float32Col float32C N 6 2

float64Col float64C N 15 4

int10 Int10 N 10

float4_4 float4_4 N 4 3

double7_4 doubl7_2 N 7 2

string64 str64 C 64

nStringCol nStrCol C 254

dateCol dateCol D 8

NOTE Initial values for column widths and number of decimal places were takenfrom the output of the sdetable -o describe command These values were changedover the course of several executions of the sde2shp in response to warning anderror messages issued by the sde2shp command

ShapeLib

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The ltbasegtshp and ltbasegtshx files are created by the ShapeLibSHPCreatemethod

The ltbasegtprj file is created by using a text editor to create the file andinserting the WKT string specification for the coordinate system

The ltbasegtdbf file is created by the following code

IntPtr dbfFile = MapToolsShapeLibDBFCre

ate(Pointspointsdbf)

int logicalColNum = MapToolsShapeLibDBFAddField(dbfFile Logic

alCol ShapeLibDBFFieldTypeFTLogical 1 0)

int strColNum = MapToolsShapeLibDBFAddField(dbfFile StrCol

ShapeLibDBFFieldTypeFTString 64 0)

int dateColNum = MapToolsShapeLibDBFAddField(dbfFile DateCol

ShapeLibDBFFieldTypeFTDate 8 0)

int integer20_0Num = MapToolsShapeLibDBFAddField(dbfFile In

teger20 ShapeLibDBFFieldTypeFTInteger 20 0)

int double18_4Num = MapToolsShapeLibDBFAddField(dbfFile

Double18_4 ShapeLibDBFFieldTypeFTDouble 18 4)

MapToolsShapeLibDBFClose(dbfFile)

266 | Appendix E OSGeo FDO Provider for SHP

Logical to Physical Schema MappingThe SHP provider supports the DestroySchema and ApplySchema commandsSo it is possible to create shape files whose schema has been defined usingFDO and then map the logical FDO data types to the shape native types Thismapping is described here The creation of the shape file used for this purposeis described in this appendix

Native Type Column Width Decimal PlacesFDO Type

L 1Boolean

D 8DateTime

N gt0 gt0Decimal

N 11Int32

C gt0String

Physical to Logical Schema MappingWhen FDO describes the schema of an existing shapefile that was not createdby the ApplySchema command it maps native data types to FDO data typesTwo shapfiles have been mapped One shapfile has been created using theArcSDE command sde2shp The creation of the source ArcSDE schema isdescribed in the appendix for the ArcSDE provider The other shapfile hasbeen created using a NET wrapper for the ShapeLib C Library These twomethods for creating shapefiles are described in this appendix

The schema name is ldquoDefaultrdquo The class name is the root name of the fileFor example if the filename is ldquopointsshprdquo the class name is ldquopointsrdquo Theattribute property names are the dBASE column names The geometry propertyname is ldquoGeometryrdquo The value of the feature classrsquos SpatialContextAssociationproperty is the name of the coordinate system specified in the prj file Forexample if the coordinate system specification in the prj has the patternldquoPROJCS[]rdquo the value of the SpatialContextAssociation proerty is the valueof the ltnamegt parameter in the pattern ldquoPROJCS[ltnamegt]rdquo

Logical to Physical Schema Mapping | 267

sde2shp

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat came from the conversion of an ArcSDE schema is in the following table

FDO Data TypeNative Type Column Width DecimalPlaces

DecimalN 4

DecimalN 10

DecimalN 6 2

DecimalN 15 4

DecimalN 4 3

DecimalN 7 2

StringC

DateTimeD

ShapeLib

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat was created by a ShapeLib program is in the following table

FDO Data TypeNative Type Column Width Decimal Places

BooleanL 1

StringC 64

DateTimeD 8

DecimalN 20 0

268 | Appendix E OSGeo FDO Provider for SHP

FDO Data TypeNative Type Column Width Decimal Places

DecimalN 18 4

FDO Provider for SHP CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

multiple spatial contexts

Write

Multi-user write

Flush

FDO Provider for SHP Capabilities | 269

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 255 digits (maximum decimalprecision of 255 and maximum decimal scale of 255)

Int32 data type with a maximum length of 4 bytes

String data type with a maximum length of 255

Int32 auto-generated data type

Identity properties of type Int32

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 7 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 11 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 0 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Multiple schemas

Null value constraints

270 | Appendix E OSGeo FDO Provider for SHP

Schema modification

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

FDO Provider for SHP Capabilities | 271

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Within Inside Intersects EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleSingle Int16 Int32 or Int64

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

272 | Appendix E OSGeo FDO Provider for SHP

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

GeometricProperty SpatialContexts(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SHP Capabilities | 273

274

OSGeo FDO Provider forSQL Server Spatial

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in the commandrsquosclass collection The mapping of logical FDO data types to native types isdescribed here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the number ofdigits to the right of the decimal point The maximum number of digits in the nativetype is 38

NOTE The definition of the FDO String data type requires that the length propertybe set

Native TypeFDO Data Type

bitBoolean

tinyintByte

datetimeDateTime

decimal(204)Decimal (precision property is set to 20and scale property is set to 4)

F

275

Native TypeFDO Data Type

floatDouble

smallintInt16

intInt32

bigintInt64

realSingle

nvarchar(64)String (length property set to 64)

geographygeometry with a geodetic coordinate sys-tem

geometrygeometry with a Euclidean coordinate sys-tem

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The database name is used for the feature schema name The table names areused for class names Column names are used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are date datetim2(7) datetimeoffset(7) hierarchyid sql_variatn time(7)and xml The mapping of the rest of the native data types is in the followingtable

276 | Appendix F OSGeo FDO Provider for SQL Server Spatial

NOTE The geography and geometric native types map to the geometric propertytype FDO properties are classified as data geometric object association or rasterOnly the data properties are further classified

FDO TypeNative Type

Int64bigint

BLOBbinary(50)

Booleanbit

Stringchar(10)

DateTimedatetime

Decimaldecimal(180)

Doublefloat

Geometricgeography

Geometricgeometry

BLOBimage

Int32int

Decimalmoney

Stringnchar(10)

Stringntext

Decimalnumeric(180)

Stringnvarchar(50)

Physical to Logical Schema Mapping | 277

FDO TypeNative Type

Stringnvarchar(MAX)

Singlereal

DateTimesmalldatetime

Int16smallint

Decimalsmallmoney

Stringtext

DateTimetimestamp

Bytetinyint

Stringuniqueidentifier

BLOBvarbinary(50)

Stringvarchar(50)

BLOBvarbinary(MAX)

278 | Appendix F OSGeo FDO Provider for SQL Server Spatial

OSGeo FDO Provider forWFS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WFS

What Is FDO Provider for WFSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WFS provides FDO withaccess to a WFS-based data store

An OGC Web Feature Service (WFS) provides access to geographic features thatare stored in an opaque data store in a clientserver environment A client usesWFS to retrieve geospatial data that is encoded in Geography Markup Language(GML) from a single or multiple Web Feature Service The communicationbetween client and server is encoded in XML If the WFS response includesfeature geometries it is encoded in Geography Markup Language (GML) whichis specified in the OpenGIS Geographic Markup Language ImplementationSpecification

Using FDO Provider for WFS data manipulation operations you can do thefollowing

Query features based on spatial and non-spatial constraints

Create new feature instances

Delete feature instances

Update feature instances

G

279

Lock feature instances

For more information see The Essential FDO (FET_TheEssentialFDOpdf)

NOTE There is no public API documentation for the FDO Provider for WFSfunctionality is available through the main FDO API

FDO Provider for WFS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threaded

static spatial content extent type

multiple spatial contexts

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()

280 | Appendix G OSGeo FDO Provider for WFS

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of unknown bytes

Byte data type with a maximum length of unknown bytes

DateTime data type with a maximum length of unknown bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of unknown bytes

Int16 data type with a maximum length of unknown bytes

Int32 data type with a maximum length of unknown bytes

Int64 data type with a maximum length unknown 8 bytes

Single data type with a maximum length of unknown bytes

String data type with a maximum length of unknown

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name (null)

Composite ID

FDO Provider for WFS Capabilities | 281

Multiple schemas

Object properties

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_GetSpatialContexts

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

use of expressions for properties in Select and SelectAggregates commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

282 | Appendix G OSGeo FDO Provider for WFS

Basic expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeoemtry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

FDO Provider for WFS Capabilities | 283

No Raster capabilities are supported

284 | Appendix G OSGeo FDO Provider for WFS

OSGeo FDO Provider forWMS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WMS

What Is FDO Provider for WMSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WMS provides FDO withaccess to a WMS-based data store

An Open Geospatial Consortium (OGC) Web Map Service (WMS) producesmaps of spatially referenced data dynamically from geographic informationThis international standard defines a map to be a portrayal of geographicinformation as a digital image file suitable for display on a computer screen Amap is not the data itself Maps by WMS are generally rendered in a pictorialformat such as PNG GIF or JPEG or occasionally as vector-based graphicalelements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile(WebCGM) formats

The FDO Provider for WMS has the following characteristics

The FDO Provider for WMS serves up map information originating from anOGC Basic Web Map Service that provides pictorially formatted images suchas PNG GIF or JPEG

WMS map data is exposed through an FDO feature schema whose classescontain an FDO Raster property definition The FDO schema exposed fromthe FDO Provider for WMS conforms to a pre-defined FDO schema that is

H

285

specific to WMS and that acts as the basis for all FDO interaction withWMS data regardless of the originating source of the WMS images

WMS data manipulation operations are limited to querying features basedon spatial and non-spatial constraints Schema manipulation operationsare not supported

The FDO Provider for WMS can run in a multi-platform environmentincluding Windows and Linux

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for WMS API Reference Help (WMS_Provider_APIchm)

FDO Provider for WMS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

286 | Appendix H OSGeo FDO Provider for WMS

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

String data type with a maximum length of unknown

BLOB data type with a maximum length of unknown bytes

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Inheritance

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FDO Provider for WMS Capabilities | 287

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_GetSpatialContexts

The following capabilities are supported

simple functions in Select and SelectAggregate commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No filter capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Function expressions are supported

The following functions are supported

BLOB RESAMPLE(BLOB raster Double minX Double minY Double maxXDouble maxY Int32 height Int32 width)

BLOB CLIP(BLOB raster Double minX Double minY Double maxX DoublemaxY)

GeometricProperty SpatialExtents(BLOB raster)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaning

288 | Appendix H OSGeo FDO Provider for WMS

of the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Polygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

The Raster capability is supported The following raster data models aresupported

Bitonal1-bitpixelUnsigned Integer

Gray8-bitpixelUnsigned Integer

RGB24-bitpixelUnsigned Integer

RGBA32-bitpixelUnsigned Integer

Palette8-bitpixelUnsigned Integer

FDO Provider for WMS Capabilities | 289

290

Index

A

AGF 152API

defined 5FDO 5

application development 11architecture and packages 8ArcSDE

limitations 212ArcSDE Provider 211

Capabilities 227 237 249 256 269 280 286

Software Requirements 211association property 15Autodesk Geometry Format (AGF) 152

B

behaviors GisPtr 25BinaryOperations 146

C

calls chain 25capabilities

FDO Provider for ArcSDE 227 237 249 256 269 280 286

classcontained 91feature 14IdentityProperty and

ObjectProperty 91ndash92standalone 91

Class Diagram FDO Schema Element 93class type 14collection classes 23comparison operations 146connection

ArcSDE 216establishing 29

semantics 27constraints expression text 141constraints filter text 141constraints provider-specific 141Contained Class 91context spatial 18

D

data concepts 13data property

defined 15data sources and data stores 27data store 18

defined 18FDO Provider for ArcSDE 211FDO Provider for MySQL 233FDO Provider for ODBC 243FDO Provider for SDF 255FDO Provider for SHP 263FDO Provider for WMS 285filtering 19 139locking 19querying 129schemas and the 85transactions 20

data stores data sources and 27data type

DATETIME 145DOUBLE 145IDENTIFIER 144INTEGER 145PARAMETER 144STRING 144

data type mappings 217data types 144DataStore

FDO Provider for ArcSDE 211develop applications 11dimensionality defined 15

Index | 291

E

edit a GML schema file 101element states schema 94elements of a schema 14example

creating a schema 111creating a schema read in from an

XML file 114deleting property values 127describing a schema 114destroying a schema 114inserting an Integer a string and a

Geometry Value 122query 130schema management 111updating property values 125

expression grammar 143expression text 140Expression defined 19expressions 140

F

factory abstract geometry 159FDO

architecture and packages 8FDO API

defined 5FDO concepts

commands 18data store 18expression 19feature class 14filter 19geometry property 16locking 19object property 17property 15spatial context 18transactions 20

FDO In General 161FDO Provider for ArcSDE

capabilities 227 237 249 256 269 280 286

connection 216

defined 211software requirements 211

FDO Provider for MySQLdefined 233

FDO Provider for ODBCdefined 243

FDO Provider for SDF 255defined 255

FDO Provider for SDF defined 255FDO Provider for SHP

defined 263FDO Provider for WMS

defined 285FDO schema element class diagram 93FDO XML format 95FDOClass 90FDOFeatureClass 90FDOIActivateLongTransaction 136FDOICommitLongTransaction 137FDOICreateLongTransaction 137FDOIDeactivateLongTransaction 136FDOIGetLongTransactions 137FDOIRollbackLongTransaction 136feature class 14feature schema creating a 218filter

grammar 141Filter 139

defined 19filter text 140filters 19

G

geometric types mapping betweenGeometry and 160

geometry 16Geometry

basic or pure 152properties 16types 159value 147working with 151

geometry and geometric types mappingbetween 160

Geometry API 151

292 | Index

GIS_SAFE_RELEASE (ptr) 21ndash22GisPtr 22GML schema file creating and

editing 101

H

handler exception 23

K

keywords filter and expression 144

L

locking 19ArcSDE limitations 213defined 19

long transactiondefined 135leaf 135root 20 135ndash136

M

mappingsdata type 217physical 86

memory management 21models modifying 94

N

non-feature class issues 91non-smart ptr 26

O

object propertydefined 17

ObjectProperty types 90OGC WKT 151operations comparison 146operations data maintenance 119

operator precedence 146operators 146overrides

schema 88

P

packageconnections 27Schema 85

packages FDO 8parent in the schema classes 86properties

base 85Geometry 16

propertyassociation 15data 15defined 15object 17Raster 17

property definitions adding GMLfor 105

property values 120data 120geometry 121

Provider for ArcSDEconnection 216defined 211

Provider for MySQLdefined 233

Provider for ODBCdefined 243

Provider for SHPdefined 263

provider defined 9

Q

querycreating 129example 130

Index | 293

R

raster propertydefined 17

references cross-schema 86requirements

FDO Provider for ArcSDE 211rollback mechanism schema 95root long transaction defined 20

S

SampleFeatureSchemaxml 115schema

defined 13schema elements 14

schema management 111schema mapping defined 14schema overrides 14schema create 89 218schemas

describing 92element states 94modifying models 94rollback mechanism 95working with 88

SDFFDO Provider for 255

software requirements 211spatial context 161spatial context defined 18special characters 147

standalone class 91states schema element 94supported interfaces LT 136

T

text expression 140text filter 140transaction long 20types

Geometry 159ObjectProperty 90

U

UnaryOperations 146

V

valuesdeleting 126updating 125

W

WKT 151

X

XML Format FDO 95

294 | Index

  • Contents
  • About This Guide
    • Audience and Purpose
    • How This Guide Is Organized
    • Whatrsquos New
      • Introduction
        • What Is the FDO API
          • From the Perspective of the Client Application User
          • From the Perspective of the Client Application Engineer
            • Getting Started
            • FDO Architecture and Providers
            • What Is a Provider
            • Developing Applications
              • FDO Concepts
                • Data Concepts
                • Operational Concepts
                  • Development Practices
                    • Memory Management
                    • Collections
                    • Exception Handling
                    • Exception Messages
                    • Managing FdoPtr Behaviors
                      • Establishing a Connection
                        • Connection Semantics
                        • Establishing a Connection
                          • FDO Capabilities
                            • FDO Capabilities
                              • Introduction
                              • Provider Type
                              • Command
                              • Connection
                              • Expression
                              • Filter
                              • Geometry
                              • Raster
                              • Schema
                                • Expressible as Boolean
                                • Not Expressible as a Boolean
                                  • Schema Management
                                    • Schema Package
                                    • Schema Mappings
                                    • Schema Overrides
                                    • Working with Schemas
                                    • FDOFeatureClass
                                    • FDOClass
                                    • Non-Feature Class Issues
                                    • Modifying Models
                                    • Schema Element States
                                    • Rollback Mechanism
                                    • FDO XML Format
                                    • Creating and Editing a GML Schema File
                                    • Schema Management Examples
                                      • Data Maintenance
                                        • Data Maintenance Operations
                                          • Inserting Values
                                          • Updating Values
                                          • Deleting Values
                                            • Related Class Topics
                                              • Performing Queries
                                                • Creating a Query
                                                • Query Example
                                                  • Long Transaction Processing
                                                    • What Is Long Transaction Processing
                                                    • Supported Interfaces
                                                      • Filter and Expression Languages
                                                        • Filters
                                                        • Expressions
                                                        • Filter and Expression Text
                                                        • Language Issues
                                                          • Provider-Specific Constraints on Filter and Expression Text
                                                          • Filter Grammar
                                                          • Expression Grammar
                                                          • Filter and Expression Keywords
                                                          • Data Types
                                                            • Identifier
                                                            • Parameter
                                                            • String
                                                            • Integer
                                                            • Double
                                                            • DateTime
                                                              • Operators
                                                              • Special Character
                                                              • Geometry Value
                                                                  • The Geometry API
                                                                    • Introduction
                                                                    • FGF and WKB
                                                                    • FGF Binary Specification
                                                                    • FGF Text
                                                                    • Abstract and Concrete Classes
                                                                    • Geometry Types
                                                                    • Mapping Between Geometry and Geometric Types
                                                                    • Spatial Context
                                                                    • Specify Dimensionality When Creating Geometries Using String Specifications
                                                                    • Inserting Geometry Values
                                                                      • FDO Cookbook
                                                                        • Introduction
                                                                        • Recommendations
                                                                        • Registry
                                                                        • Connection
                                                                        • Capabilities
                                                                        • Data Store
                                                                        • User Management
                                                                        • Spatial Context
                                                                        • Basic Schema Operations
                                                                        • Insert Data
                                                                        • Select Data
                                                                        • Select Aggregate Data
                                                                        • Delete Data
                                                                        • Schema Overrides
                                                                        • Xml SerializeDeserialize
                                                                          • C
                                                                            • Geometry
                                                                              • Construction
                                                                                • C Namespaces
                                                                                • C Geometry Scaffolding Classes
                                                                                • C Geometries Constructed using IDirectPositionImpl
                                                                                • C Geometries Constructed Using Geometry Subcomponents
                                                                                • C Aggregate Geometries
                                                                                • C Geometries from Text Specifications
                                                                                  • Deconstruction
                                                                                      • OSGeo FDO Provider for ArcSDE
                                                                                        • What Is FDO Provider for ArcSDE
                                                                                        • FDO Provider for ArcSDE Software Requirements
                                                                                          • Installed Components
                                                                                          • External Dependencies
                                                                                            • FDO Provider for ArcSDE Limitations
                                                                                            • ArcSDE Limitations
                                                                                              • Relative to ArcObjects API and ArcGIS Server API
                                                                                                • Curved Segments
                                                                                                  • Locking and Versioning
                                                                                                    • Table Creation
                                                                                                    • Identity Row ID Column and Enable Row Locking
                                                                                                    • Disable Row Locking and Enable Versioning
                                                                                                        • FDO Provider for ArcSDE Connection
                                                                                                        • Data Type Mappings
                                                                                                        • Creating a Feature Schema
                                                                                                        • Logical to Physical Schema Mapping
                                                                                                        • Physical to Logical Schema Mapping
                                                                                                        • FDO Provider for ArcSDE Capabilities
                                                                                                          • OSGeo FDO Provider for MySQL
                                                                                                            • What Is FDO Provider for MySQL
                                                                                                            • Logical to Physical Schema Mapping
                                                                                                            • Physical to Logical Schema Mapping
                                                                                                            • FDO Provider for MySQL Capabilities
                                                                                                              • OSGeo FDO Provider for ODBC
                                                                                                                • What Is FDO Provider for ODBC
                                                                                                                • Physical to Logical Schema Mappings
                                                                                                                • FDO Provider for ODBC Capabilities
                                                                                                                  • OSGeo FDO Provider for SDF
                                                                                                                    • What Is FDO Provider for SDF
                                                                                                                    • FDO Provider for SDF Capabilities
                                                                                                                      • OSGeo FDO Provider for SHP
                                                                                                                        • What Is FDO Provider for SHP
                                                                                                                        • Creating SHP Files for the Logical to Physical Schema Mapping
                                                                                                                        • Creating SHP Files for the Physical to Logical Schema Mapping
                                                                                                                        • Logical to Physical Schema Mapping
                                                                                                                        • Physical to Logical Schema Mapping
                                                                                                                        • FDO Provider for SHP Capabilities
                                                                                                                          • OSGeo FDO Provider for SQL Server Spatial
                                                                                                                            • Logical to Physical Schema Mapping
                                                                                                                            • Physical to Logical Schema Mapping
                                                                                                                              • OSGeo FDO Provider for WFS
                                                                                                                                • What Is FDO Provider for WFS
                                                                                                                                • FDO Provider for WFS Capabilities
                                                                                                                                  • OSGeo FDO Provider for WMS
                                                                                                                                    • What Is FDO Provider for WMS
                                                                                                                                    • FDO Provider for WMS Capabilities
                                                                                                                                      • Index
Page 2: here - OSGeo Download Server

copy 2008 Autodesk Inc All Rights Reserved Except as otherwise permitted by Autodesk Inc this publication or parts thereof may not bereproduced in any form by any method for any purpose Certain materials included in this publication are reprinted with the permission of the copyright holder TrademarksThe following are registered trademarks or trademarks of Autodesk Inc in the USA and other countries 3DEC (designlogo) 3December3Decembercom 3ds Max ADI Alias Alias (swirl designlogo) AliasStudio Alias|Wavefront (designlogo) ATC AUGI AutoCAD AutoCADLearning Assistance AutoCAD LT AutoCAD Simulator AutoCAD SQL Extension AutoCAD SQL Interface Autodesk Autodesk Envision AutodeskInsight Autodesk Intent Autodesk Inventor Autodesk Map Autodesk MapGuide Autodesk Streamline AutoLISP AutoSnap AutoSketchAutoTrack Backdraft Built with ObjectARX (logo) Burn Buzzsaw CAiCE Can You Imagine Character Studio Cinestream Civil 3D CleanerCleaner Central ClearScale Colour Warper Combustion Communication Specification Constructware Content Explorer CreategtwhatsgtNextgt(designlogo) Dancing Baby (image) DesignCenter Design Doctor Designers Toolkit DesignKids DesignProf DesignServer DesignStudioDesign|Studio (designlogo) Design Web Format DWF DWG DWG (logo) DWG Extreme DWG TrueConvert DWG TrueView DXF EcotectExposure Extending the Design Team FBX Filmbox FMDesktop Freewheel GDX Driver Gmax Green Building Studio Heads-up DesignHeidi HumanIK IDEA Server i-drop ImageModeler iMOUT Incinerator Inventor Inventor LT Kaydara Kaydara (designlogo) KynapseKynogon LandXplorer LocationLogic Lustre Matchmover Maya Mechanical Desktop MotionBuilder Movimento Mudbox NavisWorksObjectARX ObjectDBX Open Reality Opticore Opticore Opus PolarSnap PortfolioWall Powered with Autodesk Technology ProductstreamProjectPoint ProMaterials RasterDWG Reactor RealDWG Real-time Roto REALVIZ Recognize Render Queue RetimerReveal Revit ShowcaseShowMotion SketchBook SteeringWheels Stitcher StudioTools Topobase Toxik TrustedDWG ViewCube Visual Visual Construction VisualDrainage Visual Landscape Visual Survey Visual Toolbox Visual LISP Voice Reality Volo Vtour Wiretap and WiretapCentral The following are registered trademarks or trademarks of Autodesk Canada Co in the USA andor Canada and other countries BackburnerDiscreet Fire Flame Flint Frost Inferno Multi-Master Editing River Smoke Sparks Stone and Wire The following are registered trademarks or trademarks of Moldflow Corp in the USA andor other countries Moldflow MPA MPA (designlogo)Moldflow Plastics Advisers MPI MPI (designlogo) Moldflow Plastics Insight MPX MPX (designlogo) Moldflow Plastics XpertAll other brand names product names or trademarks belong to their respective holders DisclaimerTHIS PUBLICATION AND THE INFORMATION CONTAINED HEREIN IS MADE AVAILABLE BY AUTODESK INC AS IS AUTODESK INC DISCLAIMSALL WARRANTIES EITHER EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY ORFITNESS FOR A PARTICULAR PURPOSE REGARDING THESE MATERIALS

Published By Autodesk Inc111 Mclnnis ParkwaySan Rafael CA 94903 USA

Contents

Chapter 1 About This Guide 1Audience and Purpose 1How This Guide Is Organized 1Whatrsquos New 3

Chapter 2 Introduction 5What Is the FDO API 5

From the Perspective of the Client Application User 5From the Perspective of the Client Application Engineer 5

Getting Started 6FDO Architecture and Providers 7What Is a Provider 9Developing Applications 11

Chapter 3 FDO Concepts 13Data Concepts 13Operational Concepts 18

Chapter 4 Development Practices 21Memory Management 21Collections 23Exception Handling 23

iii

Exception Messages 24Managing FdoPtr Behaviors 25

Chapter 5 Establishing a Connection 27Connection Semantics 27Establishing a Connection 29

Chapter 6 FDO Capabilities 35FDO Capabilities 35

Introduction 35Provider Type 36Command 37Connection 43Expression 47Filter 74Geometry 77Raster 78Schema 79

Expressible as Boolean 82Not Expressible as a Boolean 83

Chapter 7 Schema Management 85Schema Package 85Schema Mappings 87Schema Overrides 88Working with Schemas 88FDOFeatureClass 90FDOClass 90Non-Feature Class Issues 91Modifying Models 94Schema Element States 94Rollback Mechanism 95FDO XML Format 95Creating and Editing a GML Schema File 101Schema Management Examples 111

Chapter 8 Data Maintenance 119Data Maintenance Operations 119

Inserting Values 119Updating Values 125Deleting Values 126

Related Class Topics 127

iv | Contents

Chapter 9 Performing Queries 129Creating a Query 129Query Example 130

Chapter 10 Long Transaction Processing 135What Is Long Transaction Processing 135Supported Interfaces 136

Chapter 11 Filter and Expression Languages 139Filters 139Expressions 140Filter and Expression Text 140Language Issues 141

Provider-Specific Constraints on Filter and Expression Text 141Filter Grammar 141Expression Grammar 143Filter and Expression Keywords 144Data Types 144

Identifier 144Parameter 144String 144Integer 145Double 145DateTime 145

Operators 146Special Character 147Geometry Value 147

Chapter 12 The Geometry API 151Introduction 151FGF and WKB 151FGF Binary Specification 152FGF Text 158Abstract and Concrete Classes 158Geometry Types 159Mapping Between Geometry and Geometric Types 160Spatial Context 161Specify Dimensionality When Creating Geometries Using String

Specifications 161Inserting Geometry Values 162

Chapter 13 FDO Cookbook 163Introduction 163

Contents | v

Recommendations 163Registry 163Connection 164Capabilities 168Data Store 171User Management 173Spatial Context 175Basic Schema Operations 178Insert Data 181Select Data 182Select Aggregate Data 183Delete Data 184Schema Overrides 184Xml SerializeDeserialize 194

C 1 9 4Geometry 196

Construction 196C Namespaces 197C Geometry Scaffolding Classes 197C Geometries Constructed using

IDirectPositionImpl 200C Geometries Constructed Using Geometry

Subcomponents 201C Aggregate Geometries 202C Geometries from Text Specifications 204

Deconstruction 204

Appendix A OSGeo FDO Provider for ArcSDE 211What Is FDO Provider for ArcSDE 211FDO Provider for ArcSDE Software Requirements 211

Installed Components 211External Dependencies 212

FDO Provider for ArcSDE Limitations 212ArcSDE Limitations 212

Relative to ArcObjects API and ArcGIS Server API 213Curved Segments 213

Locking and Versioning 213Table Creation 214Identity Row ID Column and Enable Row Locking 214Disable Row Locking and Enable Versioning 215

FDO Provider for ArcSDE Connection 216Data Type Mappings 217Creating a Feature Schema 218Logical to Physical Schema Mapping 223Physical to Logical Schema Mapping 223FDO Provider for ArcSDE Capabilities 227

vi | Contents

Appendix B OSGeo FDO Provider for MySQL 233What Is FDO Provider for MySQL 233Logical to Physical Schema Mapping 234Physical to Logical Schema Mapping 235FDO Provider for MySQL Capabilities 237

Appendix C OSGeo FDO Provider for ODBC 243What Is FDO Provider for ODBC 243Physical to Logical Schema Mappings 244FDO Provider for ODBC Capabilities 249

Appendix D OSGeo FDO Provider for SDF 255What Is FDO Provider for SDF 255FDO Provider for SDF Capabilities 256

Appendix E OSGeo FDO Provider for SHP 263What Is FDO Provider for SHP 263Creating SHP Files for the Logical to Physical Schema Mapping 264Creating SHP Files for the Physical to Logical Schema Mapping 265Logical to Physical Schema Mapping 267Physical to Logical Schema Mapping 267FDO Provider for SHP Capabilities 269

Appendix F OSGeo FDO Provider for SQL Server Spatial 275Logical to Physical Schema Mapping 275Physical to Logical Schema Mapping 276

Appendix G OSGeo FDO Provider for WFS 279What Is FDO Provider for WFS 279FDO Provider for WFS Capabilities 280

Appendix H OSGeo FDO Provider for WMS 285What Is FDO Provider for WMS 285FDO Provider for WMS Capabilities 286

Index 291

Contents | vii

viii

About This Guide

The FDO Developerrsquos Guide introduces the Feature Data Objects (FDO) application programminginterface (API) and explains how to use its customization and development features

NOTE For detailed information about installing the FDO SDK and getting started usingthe FDO API see The Essential FDO (FET_TheEssentialFDO)

Audience and PurposeThis guide is intended to be used by developers of FDO applications It introducesthe FDO API explains the role of a feature provider and provides detailedinformation and examples about how to code your application

How This Guide Is OrganizedThis guide consists of the following chapters and appendixes

Introduction provides an overview of the FDO API and the function of FDOfeature providers

FDO Concepts on page 13 describes the key data and operational conceptsupon which FDO is constructed

Development Practices on page 21 discusses the best practices to followwhen using FDO for application development

Establishing a Connection on page 27 describes how to establish aconnection to an FDO provider

1

1

Capabilities discusses the Capabilities API which is used to determine thecapabilities of a particular provider

Schema Management on page 85 describes how to create and work withschemas and presents the issues related to schema management

Data Maintenance on page 119 provides information about using the FDOAPI to maintain the data

Performing Queries on page 129 describes how to create and performqueries

Long Transaction Processing on page 135 discusses long transactions (LT)and how to implement LT processing in your application

Filter and Expression Languages on page 139 discusses the use of filterexpressions to specify to an FDO provider how to identify a subset of theobjects of an FDO data store

The Geometry API on page 151 discusses the various Geometry types andformats and describes how to work with the Geometry API to developFDO-based applications

OSGeo FDO Provider for ArcSDE on page 211 discusses development issuesthat apply when using FDO Provider for ESRIreg ArcSDEreg

OSGeo FDO Provider for MySQL on page 233 discusses development issuesthat apply when using FDO Provider for MySQL

OSGeo FDO Provider for ODBC on page 243 discusses development issuesthat apply when using FDO Provider for ODBC

OSGeo FDO Provider for SDF on page 255 discusses development issuesthat apply when using FDO Provider for SDF

OSGeo FDO Provider for SHP on page 263 discusses development issuesthat apply when using FDO Provider for SHP (Shape)

OSGeo FDO Provider for WFS on page 279 discusses development issuesthat apply when using FDO Provider for WFS

OSGeo FDO Provider for WMS on page 285 discusses development issuesthat apply when using FDO Provider for WMS

Expression Functions outlines the signatures and implementation detailsfor the enhanced expression functions

2 | Chapter 1 About This Guide

Whatrsquos NewThis section summarizes the changes and enhancements you will find in thisversion of FDO

Enhanced Set of Expression Functions

The enhanced set includes aggregate conversion date mathematical numericstring and geometry functions All functions are supported by all providerswith the exception of the Raster WFS and WMS providers

For more information and implementation details about the expressionfunction signatures the RDBMS-specific built-in support for some of thefunctions and the provider-specific support see the appendix ExpressionFunctions

Whatrsquos New | 3

4

Introduction

You can use the APIs in the FDO API to manipulate define and analyze geospatial information

This chapter introduces application development with the FDO API and explains the role ofa feature provider

What Is the FDO API

From the Perspective of the Client Application User

The FDO API is a set of APIs used for creating managing and examininginformation enabling Autodesk GIS products to seamlessly share spatial andnon-spatial information with minimal effort

FDO is intended to provide consistent access to feature data whether it comesfrom a CAD-based data source or from a relational data store that supports richclassification To achieve this FDO supports a model that can readily supportthe capabilities of each data source allowing consumer applications functionalityto be tailored to match that of the data source For example some data sourcesmay support spatial queries while others do not Also a flexible metadata modelis required in FDO allowing clients to adapt to the underlying feature schemaexposed by each data source

From the Perspective of the Client ApplicationEngineer

The FDO API provides a common general purpose abstraction layer for accessinggeospatial data from a variety of data sources The API is in part an interface

2

5

specification of the abstraction layer A provider such as OSGeo FDO Providerfor MySQL is an implementation of the interface for a specific type of datasource (for example for a MySQL relational database) The API supports thestandard data store manipulation operations such as querying updatingversioning locking and others It also supports analysis

The API includes an extensive set of methods that return information aboutthe capabilities of the underlying data source For example one methodindicates whether the data source supports the creation of multiple schemasand another indicates whether the data source supports schema modification

A core set of services for providers is also available in the API such as providerregistration schema management filter and expression construction andXML serialization and deserialization

The API uses an object-oriented model for the construction of feature schemaA feature is a class and its attributes including its geometry are a propertyof the class The instantiation of a feature class a Feature Data Object (FDO)can contain other FDOs

Getting StartedFor detailed information to help you install and get started using Feature DataObjects (FDO) see The Essential FDO It provides details about connecting toand configuring providers data store management (createdelete) user IDs(create grant permissions) and spatial context

6 | Chapter 2 Introduction

FDO Architecture and ProvidersThe following diagram shows the high-level overview architecture of the FDOAPI and included FDO providers

FDO Architecture and Providers | 7

FDO Architecture and Providers

FDO Packages

FDO is assembled in conceptual packages of similar functionality Thisconceptual packaging is reflected in the substructure of the FDO SDK ldquoincludesrdquofolder For more information about the structure see The Essential FDO

FDO commands provider-specific commands and connections and capabilitiesprovide access to native data stores through each different FDO providerSchema management (through XML) client services and filters and expressionsare provider-independent packages that tie into the FDO API Each of theseare explained in more detail in subsequent sections

8 | Chapter 2 Introduction

The FDO API consists of classes grouped within the following packages

Commands package Contains a collection of classes that provide thecommands allowing the application to select and update features definenew types of feature classes lock features and perform analysis on featuresEach Command object executes a specific type of command against theunderlying data store In addition FDO providers expose one or moreCommand objects

ConnectionsCapabilities Contains a collection of classes that establishand manage the connection to the underlying data store Connectionobjects implement the FdoIConnection interface Capabilities API providesthe code for retrieving the various FDO provider capability categories suchas connection or schema capabilities You can use this this API to determinethe capabilities of a particular provider

Filters and Expression package Contains a collection of classes that definefilters and expression in FDO which are used to identify a subset of objectsof an FDO data store

Client Services package Contains a collection of classes that define theclient services in FDO that for example enable support for dynamiccreation of connection objects given a provider name

Schema package and FDO XML Contains a collection of classes thatprovides a logical mechanism for specifying how to represent geospatialfeatures The FDO feature schema is based somewhat on a subset of theOpenGIS and ISO feature models FDO feature schemas can be written toan XML file The FdoFeatureSchema and FdoFeatureSchemaCollectionclasses support the FdoXmlSerializable interface

In addition FDO is integrated with the Geometry API which includes theclasses that support specific Autodesk applications and APIs including FDO

For more information about each of the FDO packages see FDO API ReferenceHelp and subsequent chapters in this guide

Provider API(s) complete the FDO API configuration Each provider has aseparate API reference Help

What Is a ProviderA provider is a specific implementation of the FDO API It is the softwarecomponent that provides access to data in a particular data store

What Is a Provider | 9

For this release the providers that are included are as follows

NOTE For more information see the Open Source Geospatial Foundation websiteat wwwOSGeoorg

OsGeo FDO Provider for ArcSDE Readwrite access to feature data in anESRI ArcSDE-based data store (that is with an underlying Oracle or SQLServer database) Supports describing schema and inserting selectingupdating and deleting feature data in existing schemas does not supportcreating or deleting schemas

OsGeo FDO Provider for MySQL Readwrite access to feature data in aMySQL-based data store Supports spatial data types and spatial queryoperations A custom API can gather information transmit exceptions listdata stores and create connection objects MySQL architecture supportsvarious storage engines characteristics and capabilities

OsGeo FDO Provider for ODBC Readwrite access to feature data in anODBC-based data store Supports XYZ feature objects and can define featureclasses for any relational database table with X Y and optionally Zcolumns does not support creating or deleting schema Object locationsare stored in separate properties in the object definition

OsGeo FDO Provider for SDF Read-write access to feature data in anSDF-based data store Autodeskrsquos geospatial file format SDF supportsmultiple featuresattributes provides high performance for large data setsand interoperability with other Autodesk products and spatial indexingThe SDF provider a valid alternative to database storage Note that thisrelease of the SDF provider supports version 30 of the SDF file format

OsGeo FDO Provider for SHP Readwrite access to existing spatial andattribute data in an ESRI SHP-based data store which consists of separateshape files for geometry index and attributes Each SHP and its associatedDBF file is treated as a feature class with a single geometry property Thisis a valid alternative to database storage but does not support locking

OsGeo FDO Provider for WFS Read-only access to feature data in an OGCWFS-based data store Supports clientserver environment and retrievesgeospatial data encoded in GML from one or more Web Feature Servicessites Clientserver communication is encoded in XML with the exceptionof feature geometries which are encoded in GML Note that there is nopublic API documentation for this provider all functionality is accessiblevia the base FDO API

10 | Chapter 2 Introduction

OsGeo FDO Provider for WMS Read-only access to feature data in an OGCWMS-based data store Web Map Service (WMS) produces maps of spatiallyreferenced data dynamically from geographic information which aregenerally rendered in PNG GIF or JPEG or as vector-based Scalable VectorGraphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats

FDO supports retrieval and update of spatial and non-spatial GIS feature datathrough a rich classification model that is based on OpenGIS and ISOstandards

An overview of the relationships between providers data sources data storesand schemas is presented in the FDO Architecture and Providers graphic

For more detailed information about the providers see the appropriateappendix in this document Data sources and data stores are discussed in theEstablishing a Connection on page 27 chapter Schema concepts are discussedin the Schema Management on page 85 chapter

Developing ApplicationsYou will need to perform several major tasks in using the FDO API to developa custom application Each of these tasks breaks down into a number of moredetailed coding issues

The major development tasks are

Working with the Build Environment

Establishing a Connection

Schema Management

Data Maintenance

Creating Queries

Using Custom Commands (Provider-Specific)

These tasks are explored in detail in the chapters that follow

Developing Applications | 11

12

FDO Concepts

Before you can work properly with the FDO API you need to have a good understanding ofits basic underlying concepts This chapter defines the essential constructs and dynamicsthat comprise the FDO API The definitions of these constructs and dynamics are groupedinto two interdependent categories

Data Concepts Definitions of the data constructs that comprise the FDO API

Operational Concepts Definitions of the operations that are used to manage andmanipulate the data

Data ConceptsAll concepts that are defined in this section relate to the data that FDO isdesigned to manage and manipulate

What Is a Feature

A feature is an abstraction of a natural or man-made real world object It isrelated directly or indirectly to geographic locations A spatial feature has oneor more geometric properties For example a road feature might be representedby a line and a hydrant might be represented by a point A non-spatial featuredoes not have geometry but can be related to a spatial feature which does Forexample a road feature may contain a sidewalk feature that is defined as notcontaining a geometry

What Is a Schema

A schema is a logical description of the data types used to model real-worldobjects A schema is not the actual data instances (that is not a particular roador land parcel) rather it is metadata A schema is a model of the types of data

3

13

that would be found in a data store For example a schema which models thelayout of city streets has a class called Road and this class has a property calledName The definition of Road and its associated classes constitute the schema

What Is a Schema Override

A schema override comprises instructions to override the default schemamappings For example an RDBMS-type FDO provider could map a featureclass to a table of the same name by default A schema override might mapthe class to a differently named table for example by mapping the poleclass to the telco_pole table

What is a Schema Mapping

A Schema Mapping is a correspondence between a Schema Element and aphysical object in a data store For example OSGeo FDO Provider for MySQLmaps each Feature Class onto a table in the MySQL database where the datastore resides The physical structure of data stores for each FDO provider canvary greatly so the types of Schema Mappings can also vary between providersEach provider defines a set of default schema mappings For example OSGeoFDO Provider for MySQL maps a class to a table of the same name by defaultThese defaults can be overridden by specifying Schema Overrides

What Are Elements of a Schema

A schema consists of a collection of schema elements In the FDO API schemaelements are related to one another by derivation and by aggregation Anelement of a schema defines a particular type of data such as a feature classor a property or an association For example a feature class definition for aroad includes the class name (for example Road) and the class properties (forexample Name NumberLanes PavementType and Geometry)

What Is a Class Type

A class type is a specialization of the base FDO class definition(FdoClassDefinition) It is used to represent the complex properties of spatialand non-spatial features

What is a Feature Class

A feature class is a schema element that describes a type of real-world objectIt includes a class name and property definitions including zero or moregeometric properties It describes the type of data that would be included inobject instances of that type

14 | Chapter 3 FDO Concepts

What Is a Property

A property is a single attribute of a class and a class is defined by one or moreproperty definitions For example a Road feature class may have propertiescalled Name NumberLanes or Location A property has a particular typewhich can be a simple type such as a string or number or a complex typedefined by a class such as an Address type which itself is defined by a set ofproperties such as StreetNumber StreetName or StreetType

There are five kinds of properties association properties data propertiesgeometric properties object properties and raster properties

Individual properties are defined in the following sections

What Is an Association Property

The FdoAssociationPropertyDefinition class is used to model a peer-to-peerrelationship between two classes This relationship is defined at schemacreation time and instantiated at object creation time The association propertysupports various cardinality settings cascading locks and differing deleterules An FDO filter can be based on association properties andFdoIFeatureReader can handle associated objects through the GetObject()method

What Is a Data Property

A data property is a non-spatial property An instance of a data propertycontains a value whose type is either boolean byte datetime decimal singledouble Int16 Int32 Int64 string binary large object or character large object

What Is Dimensionality

Dimensionality and the concept of dimension has two different meaningsin the discussion of geometry and geometric property

The first is called shape dimensionality and it is defined by theFdoGeometricType enumeration The four shapes are point (0 dimensions)curve (1 dimensions) surface (2 dimensions) and solid (3 dimensions)

The other is called ordinate dimensionality and it is defined by theFdoDimensionality enumeration There are four ordinate dimensions XYXYZ XYM and XYZM M stands for measure

Data Concepts | 15

What Is a Geometric Property

An instance of a geometric property contains an object that represents ageometry value The definition of the geometric property may restrict anobject to represent a geometry that always has the same shape such as a pointor it could allow different object instances to have different dimensions Forexample one geometric property object could represent a point and anothercould represent a line Any combination of shapes is permissible in thespecification of the geometric types that a geometry property definitionpermits The default geometric property specifies that an object could representa geometry that is any one of the four shapes

With respect to ordinate dimensionality all instances of a geometric propertymust have the same ordinate dimension The default is XY

Geometric property definitions have two attributes regarding ordinatedimensionality HasElevation for Z and HasMeasure for M

What is a Geometry

A geometry is represented using geometric constructs either defined as listsof one or more XY or XYZ points or defined parametrically for example asa circular arc While geometry typically is two- or three-dimensional it mayalso contain the measurement dimension (M) to provide the basis for dynamicsegments

The geometry types are denoted by the FdoGeometryType enumeration anddescribe the following

Point

LineString (one or more connected line segments defined by positions atthe vertices)

CurveString (a collection of connected circular arc segments and linearsegments)

Polygon (a surface bound by one outer ring and zero or more interior ringsthe rings are closed connected line segments defined by positions at thevertices)

CurvePolygon (a surface bound by one outer ring and zero or more interiorrings the rings are closed connected curve segments)

MultiPoint (multiple points which may be disjoint)

MultiLineString (multiple LineStrings which may be disjoint)

16 | Chapter 3 FDO Concepts

MultiCurveString (multiple CurveStrings which may be disjoint)

MultiPolygon (multiple Polygons which may be disjoint)

MultiCurvePolygon (multiple CurvePolygons which may be disjoint)

MultiGeometry (a heterogenous collection of geometries which may bedisjoint)

Most geometry types are defined using either curve segments or a series ofconnected line segments Curve segments are used where non-linear curvesmay appear The following curve segment types are supported

CircularArcSegment (circular arc defined by three positions on the arc)

LineStringSegment ( a series of connected line segments defined bypositions are the vertices)

There are currently no geometries of type ldquosolidrdquo (3D shape dimensionality)supported

The FdoIConnectionGetGeometryCapabilities() method can be used to querywhich geometry types and ordinate dimensionalities are supported by aparticular provider

What Is an Object Property

An object property is a complex property type that can be used within a classand an object property itself is defined by a class definition For examplethe Address type example described previously in the Property definition Anobject property may define a single instance for each class object instance (forexample an address property of a land parcel) or may represent a list ofinstances of that class type per instance of the owning class (for exampleinspection records as a complex property of an electrical device feature class)

What is a Raster Property

A raster property defines the information needed to process a raster imagefor example the number of bits of information per pixel the size in pixels ofthe X dimension and the size in pixels of the Y dimension needed to processa raster image

Data Concepts | 17

What Is a Spatial Context

A spatial context describes the general metadata or parameters within whichgeometry for a collection of features resides In particular the spatial contextincludes the definition of the coordinate system spheroid parameters unitsspatial extents and so on for a collection of geometries owned by features

Spatial context can be described as the ldquocoordinate system plus identityrdquo Anygeometries that are to be spatially related must be in a common spatial context

The identity component is required in order to support separate workspacessuch as schematic diagrams which are non-georeferenced Also it supportsgeoreferenced cases For example two users might create drawings using somedefault spatial parameters (for example rectangular and 10000x10000)although each drawing had nothing to do with the other If the drawings wereput into a common database the users could preserve not only the spatialparameters but also the container aspect of their data using spatial context

For more information about spatial context see Spatial Context on page 161

What is a Data Store

A data store is a repository of an integrated set of objects The objects in a datastore are modeled either by classes or feature classes defined within one ormore schemas For example a data store may contain data for both a LandUseschema and a TelcoOutsidePlant schema Some data stores can represent datain only one schema while other data stores can represent data in manyschemas (for example RDBMS-based data stores such as MySQL)

Operational ConceptsThe concepts that are defined in this section relate to the FDO operations usedto manage and manipulate data

What Is a Command

In FDO the application uses a command to select and update features definenew types of feature classes lock features version features and perform someanalysis of features Each Command object executes a specific type of commandagainst the underlying data store Interfaces define the semantics of eachcommand allowing them to be well-defined and strongly typed Because FDOuses a standard set of commands providers can extend existing commandsand add new commands specific to that provider Feature commands execute

18 | Chapter 3 FDO Concepts

against a particular connection and may execute within the scope of atransaction

An FDO command is a particular FDO interface that is used by the applicationto invoke an operation against a data store A command may retrieve datafrom a data store (for example a Select command) may update data in a datastore (for example an Update or Delete command) may perform some analysis(for example an Activate Spatial Context command) or may cause some otherchange in a data store or session (for example a Begin Transaction command)

What Is an Expression

An expression is a construct that an application can use to build up a filterAn expression is a clause of a filter or larger expression For example ldquoLanesgt=4 and PavementType = Asphaltrdquo takes two expressions and combines themto create a filter

For more information about using expressions with FDO see Filter andExpression Languages on page 139

What Is a Filter

A filter is a construct that an application specifies to an FDO provider toidentify a subset of objects of an FDO data store For example a filter may beused to identify all Road type features that have 2 lanes and that are within200 metres of a particular location Many FDO commands use filter parametersto specify the objects to which the command applies For example a Selectcommand uses a filter to identify the objects that the application wants toretrieve Similarly a Delete command uses a filter to identify the objects thatthe application wants to delete from the data store

For more information about using filters with FDO see Filter and ExpressionLanguages on page 139

What Is Locking

A user can use locking to gain update control of an object in the data store tothe exclusion of other users There are two general types of locksmdashtransactionlocks and persistent locks Transaction locks are temporary and endure onlyfor the duration of the transaction (see What Is a Transaction on page 20)

Persistent locks applied to objects by a user remain with the object until eitherthat user removes those locks or the locks are removed by another user withthe appropriate authority

Operational Concepts | 19

What Is a Transaction

A transaction changes the data store in some way The way these changesaffect the data store is determined by the transactionrsquos properties For examplethe Atomic property specifies that either all changes happen or non happenIn transaction processing the data store treats a series of commands as a singleatomic unit of change to that data store Either all changes generated by thecommands are successful or the whole set is cancelled A transaction is a singleatomic unit of changes to a data store The application terminates a transactionwith either a ldquocommitrdquo which applies the set of changes or a ldquorollbackrdquowhich cancels the set of changes Further the data store may automaticallyroll back a transaction if it detects a severe error in any of the commandswithin the transaction A transaction has the following properties

Atomic Either all changes generated by the commands within a transactionhappen or none happen

Consistent The transaction leaves the data store in a consistent stateregarding any constraints or other data integrity rules

Isolated Changes being made within a transaction by one user are notvisible to other users until after that transaction is committed

Durable After a transaction is completed successfully the changes arepersistent in the data store on disk and cannot be lost if the program orprocessor fails

What Is a Long Transaction

A long transaction (LT) is an administration unit used to group conditionalchanges to objects Depending on the situation such a unit might containconditional changes to one or to many objects Long transactions are used tomodify as-built data in the database without permanently changing the as-builtdata Long transactions can be used to apply revisions or alternates to anobject

What Is a Root Long Transaction

A root long transaction is a long transaction that represents permanent dataAny long transaction has a root long transaction as an ancestor in its longtransaction dependency graph

20 | Chapter 3 FDO Concepts

Development Practices

This chapter explains several practices to follow when working with the FDO API and providesexamples of how to follow these practices

Memory ManagementSome FDO functions (for example the Create methods) allocate memory whenthey are called This memory needs to be freed to prevent memory leaks Alldestructors on FDO classes are protected so you must call a Release() functionto destroy them (thus freeing their allocated memory) Each class inherits fromthe FdoIDisposable class which defines the Release() method and the AddRef()method

In addition these classes are reference counted and the count is increased (byAddRef()) when you retrieve them through a Get function After finishing withthe object you need to release it (just as with COM objects) The object isdestroyed only when the reference count hits 0 Two macros are defined to helpin the use of the Release() and AddRef() methods

FDO_SAFE_RELEASE (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_RELEASE calls the release() methodof the object pointed to by the ldquoptrrdquo argument and then sets the local pointerto the object to NULL The macro definition is define FDO_SAFE_RELEASE(x)

if (x) (x)-gtRelease() (x) = NULL

FdoFeatureClass pBase = myClass-gtGetBaseClass()

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

4

21

FDO_SAFE_ADDREF (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_ADDREF calls the AddRef()method of the object pointed to by the ldquoptrrdquo argument The macro definitionis define FDO_SAFE_ADDREF(x) ((x = NULL) (x)-gtAddRef() (x)

(NULL))

return FDO_SAFE_ADDREF(value)returns NULL if value equals NULL orincrements the reference count of the object that value points to andreturns value

m_list[index] = FDO_SAFE_ADDREF(value) assigns NULL to the arrayentry if value is NULL or increments the reference count of the object thatvalue points to and assigns value to the array entry

FdoPtr

An FdoPtr smart pointer is provided to help manage memory You wrap anFDO object in a FdoPtr The requirement is that the objectrsquos type must inheritfrom FdoIDisposable The object is then released automatically when theFdoPtr goes out of scope The following code illustrates how to use FdoPtr

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

No need to call FDO_SAFE_RELEASE

Before it is destroyed pBase calls Release() on the FdoFeature

Class object

NOTE If for some reason you wanted to use FDO_SAFE_RELEASE on an FdoPtryou would have to use an FdoPtr method to get a pointer to the object that FdoPtrwraps and pass that pointer to FDO_SAFE_RELEASE

You can use FdoPtr for your own classes by inheriting from the abstract classFdoIDisposable and providing an implementation for the Dispose() method(typically delete this)

FdoPtr Typedefs

Typedefs are provided that define identifiers representing Fdo classes wrappedbyFdoPtr An example is typedef FdoPtrltFdoClassgt FdoClassP

22 | Chapter 4 Development Practices

CollectionsYou can use FDO collection template classes to store your own objects Therequirements for your collection class and the class used to instantiate thetemplate are the same as those for wrapping a class in a FdoPtr

Exception HandlingIn the FDO API FdoCommandException class is the exception type thrownfrom classes in the Commands package and FdoConnectionException classis the exception type thrown from classes in the Connections package Bothof these exception types derive from a language-level exception class that isenvironment-specific

All exceptions are derived from the FdoException class To catch and processspecific exception types nest catch statements as in the following example

try

code

catch (FdoCommandException ex)

process message

catch (FdoException ex)

process message

In some cases underneath an FDO command the FDO level throws anFdoException The FDO command then traps the FdoException and wraps itin an FdoCommandException (or FdoSchemaException for a schemacommand) In this case several messages are returned by one exception Thefollowing example shows how to process multiple messages from oneexception

catch ( FdoSchemaException ex )

Loop through all the schema messages

FdoException currE = ex

while ( currE )

CW2A msg(currE-gtGetExceptionMessage())

acutPrintf (FdoConnectionException sn msg)

currE = currE-gtGetCause()

Collections | 23

An application function may need to catch and then re-throw exceptions inorder to clean up memory However the need to do this can be eliminatedby using FdoPtr The following example cleans up memory on error

FdoFeatureClass pBase = NULL

try

pBase = myClass-gtGetBaseClass()

catch ()

FDO_SAFE_RELEASE(pBase)

throw

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

The catch and rethrow is unnecessary when FdoPtr is used

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

Exception MessagesException messages are localized On Windows the localized strings are inresource-only DLLs and on Linux they are in catalogs The message DLLs arein the bin folder the DLL name contains Message or Msg The catalog filesare in the usrlocalfdo-320nls directory the names of these files ends in catNLS stands for National Language Support

On Linux set the NLSPATH environment variable so that the runtime codecan locate the message catalogs For example exportNLSPATH=usrlocalfdo-320nlsN

On Windows you do not have do anything special to enable the runtime codeto locate the message DLLs

The contents of the exception message files are indexed When you call oneof the FdoExceptionNLSGetMessage methods declared in Exceptionh youprovide a message number argument You may also provide a default messagestring argument In the event that the exception message resource file cannotbe found the default message is subsituted instead If the default messagestring is not provided and the resource file cannot be found the messagenumber is used as the exception message Not finding the resource file canonly happend on Linux and only if the NLSPATH envrionment variable is notset

24 | Chapter 4 Development Practices

The following two examples when called on Linux with the NLSPATHenvironment variable not set show the use of the default message and themessage number in the exception message

The following is an example of using the default string throwFdoSchemaExceptionCreate(NlsMsgGet1(FDORDBMS_333 Class 1$lsnot

found value-gtGetText()))

The following is an example of not setting the default string and using themessage number instead FdoSchemaException pNewException =

FdoSchemaExceptionCreate(

FdoSmErrorNLSGetMessage(FDO_NLSID(FDOSM_221)

pFeatSchema-gtGetName()) pException)

Managing FdoPtr BehaviorsThe topics in this section describe several ways that you can manager FdoPtrbehavior For more information about managing FdoPtr behavior see therelated topics ldquoFdoPtr ltTgt Class Template Referencerdquo and ldquoFdoIDisposableClass Referencerdquo in the FDO Reference Help and The Essential FDO

Chain Calls

Do not chain calls If you do returned pointers will not be released Forexample given an FdoClassDefinition pclassDef

psz = pclassDef -gtGetProperties()-gtGetItem(0)-gtGetName())

The above code would result in two memory leaks Instead use

FdoPropertyDefinitionCollection pprops = pclassDef -gt GetProper

ties()

FdoPropertyDefinition ppropDef = pprops-gtGetItem(0)

psz = propDef-gtGetName()

ppropDef-gtRelease()

pprops-gtRelease()

or (with FdoPtr)

FdoPtrltFdoPropertyDefinitionCollectiongt pprops = pclassDef-gt Get

Properties()

FdoPtrltFdoPropertyDefinitiongt ppropDef = pprops-gt GetItem(0)

psz = propDef-gtGetName()

or (also with FdoPtr)

Managing FdoPtr Behaviors | 25

psz = FdoPtr ltFdoPropertyDefinitiongt (FdoPtr ltFdoPropertyDefini

tionCollectiongt(pclassDef-gtGetProperties())-gt GetItem(0))-gtGet

Name()

Assigning Return Pointer of an FDO Function Call to a Non-SmartPointer

If you are assigning the return pointer of an FDO function call to a non-smartpointer then you should assign that pointer to a FdoPtr For example

FdoLineString P = gfCreateLineString()

FdoPtr ltFdoLineStringgt p2 = FDO_SAFE_ADDREF(p)

26 | Chapter 4 Development Practices

Establishing aConnection

This chapter explains how to establish a connection to an FDO provider and provides aconnection example

Connection SemanticsData Sources and Data Stores

The FDO API uses connection semantics to implement access to feature schemadata The term data store is used to refer to a collection of zero or more objectswhich instantiate class definitions belonging to one or more FDO feature schemaThe connection is to a data store because that is where data objects are storedThe underlying data source technologies used to hold data stores can berelational databases such as a MySQL database or a file-based solution suchas an SDF file

The mapping of a data store to data source technology can be one-to-one ormany-to-one For example it is

One-to-one when the connection is made by way of the OSGeo FDO Providerfor ArcSDE and the ArcSDE server is using an Oracle database

Many-to-one when the data source is a MySQL database and the connectionis made by way of the OSGeo FDO Provider for MySQL (in this case the datastore is like a container within a container)

When many-to-one mapping is possible a connection can be made in one ortwo steps For more information see Establishing a Connection on page 29 andThe Essential FDO

5

27

The underlying data source technologies differ in the connection parametersused for connecting to a particular provider The values for these parametersare generated during the installation and configuration of the containertechnologies For more information about these values and the process ofinstalling and configuring the associated data source technologies see theappropriate appendix in this document and The Essential FDO

Providers

You connect to a data store by way of a provider

The FDO API contains a registry interface that you can use to register orderegister a provider See the class FdoProviderRegistry inIncFdoClientServicesProviderRegistryh

The providers are registered during the initialization of the FDO SDK In orderto connect to a provider you will need the name of the provider in a particularformat ltCompanyFoundationOriginatorgtltProvidergtltVersiongt TheltCompanyFoundationOriginatorgt and ltProvidergt values are invariable Forspecific values see The Essential FDO

In order to connect you will need the full name including the ltVersiongtvalue You can retrieve the full name from the registry and display the set ofprovider names in a connection menu list If for whatever reason youderegister a provider save the registry information for that provider in caseyou want to reregister it again The provider object returned by the registryhas a Set() method to allow you to change values However the only valueyou can safely change is the display name Sample code for using the providerregistry is located in Establishing a Connection on page 29

The registry contains the following information about a provider

Name The unique name of the feature provider This name should be ofthe form ltCompanyFoundationOriginatorgtltProvidergtltVersiongt forexample AutodeskOracle30 or OSGeoMySQL30

DisplayName A user-friendly display name of the feature provider Theinitial values of this property for the pre-registered providers are ldquoAutodeskFDO Provider for Oraclerdquo ldquoOSGeo FDO Provider for SDFrdquo etc or theequivalent in the language of the country where the application is beingused

Description A brief description of the feature provider For example thethe OsGeo FDO Provider for SDF description is ldquoReadwrite access toAutodesks spatial database format a file-based personal geodatabase thatsupports multiple featuresattributes spatial indexing and file-lockingrdquo

28 | Chapter 5 Establishing a Connection

Version The version of the feature provider The version number stringhas the form ltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgtfor example 3000

FDOVersion The version of the feature data objects specification to whichthe feature provider conforms The version number string has the formltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgt for example3010

libraryPath The FULL library path including the library name of theprovider for example ltFDO SDK Install LocationgtbinFdoRdbmsdll

isManaged A flag indicating whether the provider is a managed orunmanaged NET provider

Establishing a ConnectionAs mentioned in a previous section Connection Semantics on page 27 theFDO API uses a provider to connect to a data store and its underlying datasource technology These data source technologies must be installed andconfigured Certain values generated during data source installation andconfiguration are used as arguments during the connection process Becausethe FDO API does not provide any methods to automate the collection andpresentation of these configuration values either the application developermust request the user to input these configuration values during theconnection process or the application developer can provide an applicationconfiguration interface which would populate the application with thecontainer configuration values and thus allow the user to choose them fromlists

NOTE For more information about connecting see The Essential FDO

A connection can be made in either one or two steps

One-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method once the returned stateis FdoConnectionState_Open no additional information is needed

Two-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method the returned state isFdoConnectionState_Pending additional information is needed to completethe connection In this case the first call to Open() has resulted in theretrieval of a list of values for a property that becomes a required property

Establishing a Connection | 29

for the second call to the Open() method After the user has selected oneof the values in the list the second call to Open() should result inFdoConnectionState_Open

Connecting to a data store by way of the MySQL or the ArcSDE provider forexample can be done in either one or two steps In the first step the datastore parameter is not required If the user does not give the data storeparameter a value the FDO will retrieve the list of data store values from thedata source so that the user can choose from them during the second stepOtherwise the user can give the data store a value in the first step andassuming that the value is valid the connection will be completed in onestep

For the purpose of this example letrsquos assume that the user has installed MySQLon his local machine During the installation he was prompted to assign apassword to the system administrator account whose name is lsquorootrsquo He setthe password to lsquotestrsquo

The following steps are preliminary to establishing a connection

1 Get the list of providers

FdoPtrltFdoProviderRegistrygt registry = (FdoProviderRegistry

)FdoFeatureAccessManagerGetProviderRegistry()

FdoProviderCollection providers = registry-gtGetProviders()

2 Get the display names for all of the providers in the registry An exampleof a display name might be OSGeo FDO Provider for MySQL

FdoStringP displayName

FdoStringP internalName

FdoPtrltFdoProvidergt provider

int count = providers-gtGetCount()

for(int i = 0 i lt count i++)

provider = providers-gtGetItem(i)

internalName = provider-gtGetName()

displayName = provider-gtGetDisplayName()

add displayName to your list

3 Use the display names to create a menu list from which the user willselect from when making a connection

After the user initiates a provider display name from the connection menudo the following

30 | Chapter 5 Establishing a Connection

1 Loop through the providers in the registry until you match the displayname selected by the user from the connection menu with a providerdisplay name in the registry and retrieve the internal name for thatprovider An example of an internal could be OSGeoMySQL32

FdoStringP internalName = provider-gtGetName()

2 Get an instance of the connection manager

FdoPtrltFdoConnectionManagergt connectMgr = (FdoConnectionManager

)FdoFeatureAccessManagerGetConnectionManager()

3 Call the managerrsquos CreateConnection() method using the provider internalname as an argument to obtain a connection object

FdoPtrltFdoIConnectiongt fdoConnection = connectMgr-gtCreateConnec

tion(LrdquoOsGeoMySQL32rdquo)

4 Obtain a connection info object by calling the connection objectrsquosGetConnectionInfo() method

FdoPtrltFdoIConnectionInfogt info = fdoConnection-gtGetConnection

Info()

5 Obtain a connection property dictionary object by calling the connectioninfo objectrsquos GetConnection Properties() method and use this dictionaryto construct a dialog box requesting connection information from theuser

FdoPtrltFdoIConnectionPropertyDictionarygt ConnDict = info-gtGetCon

nectionProperties()

6 Get a list of connection property names from the dictionary and use thislist to get information about the property The following code loopsthrough the dictionary getting all of the possible information

NOTE An attempt to get the values of an enumerable property is made onlyif the property is required

FdoInt32 count = 0

FdoString names = NULL

FdoStringP name

FdoStringP localname

FdoStringP val

FdoStringP defaultVal

bool isRequired = false

bool isProtected = false

bool isFilename = false

bool isFilepath = false

Establishing a Connection | 31

bool isDatastorename = false

bool isEnumerable = false

FdoInt32 enumCount = 0

FdoString enumNames = NULL

FdoStringP enumName

names = ConnDict-gtGetPropertyNames(count)

for(int i = 0 i lt count i++)

name = names[i]

val = dict-gtGetProperty(name)

defaultVal = dict-gtGetPropertyDefault(name)

localname = dict-gtGetLocalizedName(name)

isRequired = dict-gtIsPropertyRequired(name)

isProtected = dict-gtIsPropertyProtected(name)

isFilename = dict-gtIsPropertyFileName(name)

isFilepath = dict-gtIsPropertyFilePath(name)

isDatastorename = dict-gtIsPropertyDatastoreName(name)

isEnumerable = dict-gtIsPropertyEnumerable(name)

if (isEnumerable)

if (isRequired)

enumNames = dict-gtEnumeratePropertyValues(name enumCount)

for(int j = 0 j lt enumCount j++)

enumName = enumNames[j]

7 Use the GetLocalizedName method to obtain the name of the propertyto present to the user Calls to dictionary methods need the value of theinternal name in the string array returned by GetPropertyNames() Sowhen the user selects the localized name in the menu the program mustmap the localized name to the internal name

8 Use the IsPropertyRequired method to determine whether to mark theline as either required or optional the dialog box handler should notpermit the user to click OK in the dialog box unless a required field hasa value

9 Use the IsPropertyProtected method to determine whether the dialogbox handler should process the field value as protected data for examplea password

10 Use the IsPropertyEnumerable and IsRequired methods to determinewhether to call the EnumeratePropertyValues method to get a list of validvalues

32 | Chapter 5 Establishing a Connection

NOTE Call the EnumeratePropertyValues method only if both methods returntrue Otherwise be prepared to catch an exception if there is no pendingconnection The assumption is that a connection exists and the program isretrieving values from the data store

As shown in the code lines above the EnumeratePropertyValues method takesa property name and an updates integer argument and returns a string arrayThe updates integer will say how many values are in the returned array Presentthe list of choices to the user

If the property is not enumerable present the values returned by either theGetProperty or GetPropertyDefault methods to the user

Now that the user has seen the set of properties in the dictionary she canset the required properties A property is set by calling the dictionaryrsquosSetProperty method The MySQL connection property names are UsernamePassword Service and DataStore The dictionary tells us that UsernamePassword and Service are required properties and that DataStore is not requiredLetrsquos connect to the MySQL as root

ConnDict-gtSetProperty(LrdquoUsernamerdquo Lrdquorootrdquo)

ConnDict-gtSetProperty(LrdquoPasswordrdquo Lrdquotestrdquo)

ConnDict-gtSetProperty(LrdquoServicerdquo Lrdquolocalhostrdquo)

NOTE fdoconnection-gtGetConnectionString() returnsUsername=rootPassword=testService=localhostfdoconnection-gtSetConnectionString(LrdquoUsername=rootPassword=testService=localhostrdquo)

would set the connection properties to the same values as the three calls aboveto the connection dictionaryrsquos SetProperty() method

Open the connection

FdoConnectionState state = fdoConnection-gtOpen()

The value of state is FdoConnectionState_Pending An examination of theconnection dictionary will reveal that the DataStore property is now required

When the user checks the command capabilities he discovers that he cancreate a data store

Establishing a Connection | 33

FdoPtrltFdoICommandCapabilitiesgt commandCapabilities = fdoConnec

tion-gtGetCommandCapabilities()

bool bSupportsCreateDatastore = false

FdoInt32 numCommands

FdoIn32 commands = commandCapabilities-gtGetCommands(numCommands)

for(int i = 0 i lt numCommands i++)

switch(commands[i])

case FdoCommandType_CreateDataStore bSupportsCreateDatastore

= true

He can use the pending connection to MySQL to create the datastore Use theconnection object to create the FdoICreateDataStore command object Usethe command object to create the FdoIDataStorePropertyDictionary objectand find out from this object what properties you must define Use thedictionary object to set the required properties and then execute the commandto create the lsquofdo_userrsquo data store The only required property is DataStore

NOTE The FdoIDataPropertyDictionary and the FdoIConnectionPropertyDictionaryclasses are both derived from FdoIPropertyDictionary The code used above toaccess the FdoIConnectionPropertyDictionary object works for theFdoIDataPropertyDictionary

FdoPtrltFdoICreateDataStoregt createDataStoreCmd = dynam

ic_castltFdoICreateDataStore gt (fdoConnection-gtCreateCommand(Fdo

CommandType_CreateDataStore))

FdoPtrltFdoIDataStorePropertyDictionarygt createDsDict = createData

StoreCmd-gtGetDataStoreProperties()

createDsDict-gtSetProperty(LrdquoDataStorerdquo Lrdquofdo_userrdquo)

createDataStoreCmd-gtExecute()

Now use the connection property dictionary to set the DataStore property tolsquofdo_userrsquo and call the Open() method on the connection object This methodshould return FdoConnectionState_Open

34 | Chapter 5 Establishing a Connection

FDO Capabilities

FDO Capabilities

Introduction

The FDO capabilities are statically defined They are accessed through aconnection object in the closed state The following code illustrates how to geta connection object in the closed state

If you are using C you will find the capability definitions in theOSGeoFDOConnectionsCapabilities namespace If you are using C++ youwill find the headers in the FdoConnectionsCapabilties directory

In C you access them using the OSGeoFDOConnectionsIConnection objectIn C++ you access them using the IConnection object whose header is in theFdoConnections directory

The information in the capabilities tables reflects the state of the FDO providercapabilities as of the commercial release of Map 3D 2009

For the most part FDO defines capabilities in three ways booleans enumerationsor integers representing enumerated values and collections One schemacapability is defined as a string and two other schema capabilities as integersFor example the Command capability SupportsParameters is a boolean andthe Command capability Commands is a set of integers whose meaning isdefined by the C CommandType enumeration and the C++ FdoCommandTypeenumeration Function capabilities are defined as collections of functionsignatures The C type isOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionThe C++ type is FdoReadOnlySignatureDefinitionCollection The latter is

6

35

defined in FdoConnectionsCapabilitiesSignatureDefinitionh Each booleanenumeration and signature value is shown in the tables

In general where a number of capabilities are supported by the same set ofproviders the capabilities are aggregated into one line in the table This ruleis modified in the function category tables in the Expression section

In some cases for example the CLIP raster function there is only one signatureAt the other end of the spectrum is the Concat string function which hasalmost 100 signatures The same set of providers supports an enormous numberof functions and so the rule for presenting aggregations of capabilities had tobe modfied for functions The rule for functions is to present all of thesignatures for one function on a line in the table A handful of functions hadso many signatures that their presentation had to be split over two lines

Provider Type

A provider can be one of four types Database Server File Web Server orUnknown The type information is available from the connection object inthe closed state The ldquoUnknownrdquo type indicates that the provider can connectto more than one type of data store technology The ODBC and OGR providerscan connect either to a file-based or RDBMS-based data store technologywhich is not known until the connection is in the open state

In C the ProviderDatastoreType enumeration is in theOSGeoFDOConnections namespace The ProviderDatastoreType property isaccessible through the OSGeoFDOConnectionsIConnection object(connectionConnectionInfoProviderDatastoreType)

In C++ the FdoProviderDatastoreType enumeration is defined in theltFdoConnectionsProviderDatastoreTypehgt header file TheFdoProviderDatastoreType value is accessible through the IConnection object(connection-gtGetConnectionInfo()-gtGetProviderDatastoreType())

TypeProvider

DatabaseServerOSGeoArcSDE33

DatabaseServerOSGeoKingOracle33

DatabaseServerOSGeoMySQL33

36 | Chapter 6 FDO Capabilities

TypeProvider

DatabaseServerOSGeoPostGIS33

DatabaseServerOSGeoSQLServerSpatial33

FileOSGeoGdal33

FileOSGeoSDF33

FileOSGeoSHP33

WebServerOSGeoWFS33

WebServerOSGeoWMS33

UnknownOSGeoODBC33

UnknownOSGeoOGR33

NOTE A provider name with OSGeo at the beginning indicates that the provideris available as open source from httpfdoosgeoorg

Command

In C you access theOSGeoFDOConnectionsCapabilitiesICommandCapabilities using theIConnection object (connectionCommandCapabilities)

In C++ you access the FdoICommandCapabilities using the IConnection object(connection-gtGetCommandCapabilities())

DescriptionCommand

Locks feature instances of a given class that match thespecified criteria

AcquireLock

Command | 37

DescriptionCommand

Activates a long transaction so that features can be ver-sioned

ActivateLongTransaction

Activates a specified spatial contextActivateSpatialContext

Creates or updates a feature schema within the datastore Optionally a provider-specificmapping of featureschema elements to physical storage can be specified

ApplySchema

Commits all of the data within a leaf long transaction(one that does not have descendent long transactions)

CommitLongTransaction

to the parent long transaction and removes the longtransaction Requires access commit and remove priv-ileges to the long transaction and the access privilegeto the parent long transaction

Creates anew provider specific datastoreCreateDataStore

Creates a long transaction as a child of the currentlyactive long transaction

CreateLongTransaction

Creates a new spatial context Input to the commandincludes the name description coordinate system ex-tent type and extent for the new context

CreateSpatialContext

Deactivates the active long transaction and automaticallyactivates the root long transaction If the root long

DeactivateLongTransaction

transaction is the active one the deactivation has noeffect

Deletes the instances of a given class that match thespecified criteria The instances can be at global scopeor contained within an object collection

Delete

Describe a single schema or all schemas available fromtheconnection

DescribeSchema

38 | Chapter 6 FDO Capabilities

DescriptionCommand

Describes the logical to physical schema mappings forone or all feature schemas available from the connection

DescribeSchemaMapping

Remove a data storeDestroyDataStore

Destroys a schema definition including all class defini-tions relationship definitions and instance data within

DestroySchema

it If elements in other schemas referto the schema tobe destroyed execution will fail

Destroys an existing spatial context which destroys alldata stored in that context

DestroySpatialContext

Gets a list of all objects that are currently locked by aparticular user

GetLockedObjects

Gets lock information for the feature instances of a givenclass that match the specified filter

GetLockInfo

Gets a list of all lock ownersGetLockOwners

Gets one specific long transaction or all available longtransactions

GetLongTransactions

Enumerates the existing measurement unitsGetMeasureUnits

Gets all spatial contexts or just the active oneGetSpatialContexts

inserts a new instance of a given class The instance canbe at global scope or contained within an object collec-tion

Insert

Gets a list of datastores at a particular serverListDataStores

Create a spatial index for the specified spatial contextOracleCreateSpatialIndex

Command | 39

DescriptionCommand

Drop the specified spatial indexOracleDestroySpatialIndex

Enumerate the existing spatial indexesOracleGetSpatialIndexes

Releases locks from feature instances of a given class thatmatch the specified criteria

ReleaseLock

Removes all of the data within a long transaction andremoves the long transaction as well Requires access

RollbackLongTransaction

commit and remove privileges to the long transactionand the access privilege to the parent long transaction

creates a new SDF+ file with a specified location and filename and a given spatial coordinate system This com-

SDFCreateSDFFile

mand has been superceded by the CreateDataStorecommand

Supports the selection and ordering of feature instancesof a given class according to the specified criteria Theresults of the select are written to an SDF file

SDFExtended_Select

Queries for features of a given class that match the spe-cified criteria

Select

Queries for features of a given class that match the spe-cified criteria The criteria can specify that feature values

SelectAggregates

from multiple instances be aggregated be distinct orbe grouped

Supports the execution of a SQL statement against anunderlying RDBMS Two execute methods are provided

SQLCommand

to distinguish between statements that return table dataversus those that execute non query type operations

Modifies instances of a given class that match the spe-cified criteria The instance can be at global scope orcontained within an object collection

Update

40 | Chapter 6 FDO Capabilities

DescriptionCommand

Gets the image formats supported by the connectionWMSGetImageFormats

Gets the layer styles available for the specified featureclass

WMSGetFeatureClassStyles

Gets the CRS names available for the specified featureclass

WMSFeatureClassCRS-Names

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports the use of distinct in SelectAggreg-ates commands

SupportsSelectDistinct

Indicates whether or not a provider sup-ports the use of expressions for propertiesin Select and SelectAggregate commands

SupportsSelectExpressions

Indicates whether or not a provider sup-ports the use of functions in Select and

SupportsSelectFunctions

SelectAggregates command Only aggreg-ate functions can be used in the SelectAg-gregates command

Indicates whether or not a provider sup-ports the use of grouping criteria in theSelectAggregates command

SupportsSelectGrouping

Indicates whether or not a provider sup-ports ordering in the Select and SelectAg-gregates command

SupportsSelectOrdering

Command | 41

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports parameter substitution

SupportsParameters

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++Select DescribeSchema GetSpatialContexts

++++++++-+++SelectAggregates

+++-++-+++++SupportsSelectFunctions

++--++-+++++SupportsSelectDistinct Insert Update Delete

++-+++-++++-SupportsSelectExpressions

----++-+-+++CreateSpatialContext

-++-+-++-+--DescribeSchemaMapping

-+-----+++++SQLCommand

----++-++++-ApplySchema

-----+-++++-CreateDataStore

-+-----++++-SupportsSelectOrdering

-------+++-+ListDataStores

-+-----+-++-SupportsSelectGrouping

-----+-+++--DestroyDataStore

42 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

----+--+-+--DestroySchema

--------+-++SupportsParameters

-------+-+-+DestroySpatialContext

----++------SDFCreateSDFFile

-------+---+ActivateSpatialContext

-------+----OracleGetSpatialIndexes OracleCreateSpatialIndex Or-acleDestroySpatialIndex

-----+------SDFExtended_Select

--+---------WMSFeatureClassCRSNames WMSGetImageFormatsWMSGetFeatureClassStyles

-----------+AcquireLock CreateLongTransaction DeactivateLongTrans-action RollbackLongTransaction CommitLongTransactionGetLockOwners ReleaseLock GetLongTransactions Get-LockedObjects ActivateLongTransaction GetLockInfo

Connection

In C you access theOSGeoFDOConnectionsCapabilitiesIConnectionCapabilities using theIConnection object (connectionConnectionCapabilities)

Connection | 43

In C++ you access the FdoIConnectionCapabilities using the IConnectionobject (connection-gtGetConnectionCapabilities())

DescriptionCapability

Indicates that only this user can modify this object in thislong transaction No user not even the user locking the

LockType_AllLongTransactionExclusive

object can modify the object in any long transaction createdas a descendent of the one containing the object beinglocked When not in a long transaction situation (for ex-ample if only a root long transaction exists) the lock be-haves like an Exclusive lock

Indicates that only this user can modify this object In a longtransaction situation any user can modify the object in any

LockType_Exclusive

other long transaction including the root long transactionif it is not the current long transaction

Indicates that only this user can modify this object in thelong transaction containing the object or any long transac-

LockType_LongTransactionExclusive

tion created as a descendent of that one When not in along transaction situation (for example if only a root longtransaction exists) the lock behaves like an Exclusive lock

Indicates a shared lock typeLockType_Shared

Indicates that a transaction lock should be applied to anobject

LockType_Transaction

Indicates whether or not a provider can specify on a closedconnection an XML source to be used to configure the datastore

SupportsConfiguration

Indicates that the spatial extent of the context is dynamicand changes as data is added and removed from the con-text

SpatialContextExtentType_Dynamic

Indicates that the spatial extent of the context is static andmust be specified when the context is created

SpatialContextExtentType_Static

44 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the specifica-tion of a coordinate system during the creation of a spatial

SupportsCSysWKTFromCSysName

context using only the coordinate system name The pro-vider maps the name to the WKT internally

Indicates whether or not a provider supports the forcedwrite of cached data associated with a connection to thetarget data store

SupportsFlush

Indicates whether or not a provider supports the set oflocking commands acquire get locked objects get lockowners get lock info and release

SupportsLocking

Indicates whether or not a provider supports the set of longtransaction commands activate commit create deactivateand get

SupportsLongTransactions

Indicates that the data store can contain multiple spatialcontexts but the provider does not necessarily support thecreate spatial context command

SupportsMultipleSpatialContexts

Indicates whether or not a provider supports the SQL com-mand

SupportsSQL

Indicates whether or not a provider supports the creationof a transaction associated with a connection to a data store

SupportsTransactions

Indicates that the provider supports a single thread perconnection Multiple concurrent threads cannot access the

ThreadCapability_PerConnectionThreaded

same connection object and only one command can beexecuting per connection Multiple connections can beactive concurrently as long as each is executing on its ownthread

Indicates that the provider supports a single thread percommand Multiple concurrent threads cannot access the

ThreadCapability_PerCommandThreaded

same command object however multiple commands canbe executing concurrently against a single connection

Connection | 45

DescriptionCapability

Indicates that the provider is not thread safeThreadCapability_SingleThreaded

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-++++-++++++SpatialContextExtentType_Static

++++++-+++-+ThreadCapability_PerConnectionThreaded

--+++-++++++SupportsMultipleSpatialContexts

-+-----+++++SupportsSQL

-++-+-+---+-SupportsConfiguration

-------++--+SupportsTransactions

----------++LockType_Exclusive

+----+------SpatialContextExtentType_Dynamic

----++------SupportsFlush

--------+-+-LockType_Transaction

----------+-LockType_AllLongTransactionExclusive LockType_LongTrans-actionExclusive ThreadCapability_PerCommandThreadedLockType_Shared

-----------+SupportsLocking SupportsCSysWKTFromCSysName Sup-portsLongTransactions

------+-----ThreadCapability_SingleThreaded

46 | Chapter 6 FDO Capabilities

Expression

In C you access theOSGeoFDOConnectionsCapabilitiesIExpressionCapabilities and theOSGeoFDOConnectionsCapabilitiesFunctionDefinitionCollectionusingthe IConnection object connectionExpressionCapabilities andconnectionExpressionCapabilitiesFunctions respectively EachOSGeoFDOConnectionsCapabilitiesFunctionDefinition in the collectionhas has aOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionwhich is accessed by functionDefSignatures

In C++ you access the FdoIExpressionCapabilities and theFdoFunctionDefinitionCollection using the IConnection objectconnection-gtGetExpressionCapabilities()expression_capabilities-gtGetFunctions() respectively EachFdoFunctionDefinition in the collection has anFdoReadOnlySignatureDefinitionCollection which is accessed byfunctionDef-gtGetSignatures()

The functions can be broadly divided into two groups according to the modeof their implementation The largest group contains the functions whoseunderlying implementation is based on the Expression Builder The first releaseof the Expression Builder component is in FDO 33 The remaining functionsare those whose implementation was not touched by the introduction of theExpression Builder component

The functions whose implementation is based on the Expression Builder arefurther categorized for UI purposes into 7 groups aggregate conversion dategeometry math numeric and string These UI categories are used in thisdocument to group the presentation of the functions

General Capabilities

DescriptionCapability

Indicates whether or not the provider supports basicarithmetic expressions for example + - negate andstring concatenation

ExpressionType_Basic

Indicates whether or not the provider supports functionevaluations

ExpressionType_Function

Expression | 47

DescriptionCapability

Indicates whether or not the provider supports parametersubstitution An expression can be constructed using

ExpressionType_Parameter

named parameters and values bound to the parameter ata later time This allows the constructed expression to bereused

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ExpressionType_Function

++-+++-+++++ExpressionType_Basic

-------+-+--ExpressionType_Parameter

Argument and Return Types

Tthe following tables specify the function name arguments and the type ofthe return value An argument is optional if it is enclosed in square bracketsAn argument may be a literal such as ldquoALLrdquo or ldquoDISTINCTrdquo or a featureproperty name Where the argument value is a feature property name thetype of the feature property is specified The set of valid alternatives for anargument value is indicated by enclosing the set of ORrsquod property types orliteral values in parentheses For brevityrsquos sake a lsquonumericrsquo property typeindicates the set of numeric property types namely Byte | Decimal | Double| Int16 | Int32 | Int 64 | Single The other property types BLOB BooleanCLOB DateTime Geometry and String are indicated directly in the argumentspecification

Some functions have more than one return type The general rule is that thereturn type matches the argument type

48 | Chapter 6 FDO Capabilities

Aggregate Expression Functions

These functions can be used with the SelectAggregates command

DescriptionFunctionName

Returnsa double which is the average of the values identified by theprovided expression Avg ([ALL | DISTINCT ] numeric)

Avg

Returns an Int64 which is the number of rows returned by a queryidentified by the provided expression Count ([ALL | DISTINCT ]bool | DateTime | numeric | string | blob | clob | geometry)

Count

Returns a DateTime numeric or string in agreement with the typeof the argument which is the maximum value of the provided expres-sion Max ([ALL | DISTINCT ] DateTime | numeric | string)

Max

Represents an inverse distribution function that assumes a continuousdistribution model It takes a numeric or date-time value and returns

Median

a Double which is the middle value or an interpolated value thatwould be the middle value once the values are sorted Median (nu-meric)

Returns a DateTime numeric or string in agreement with the typeof the argument which is the minimum value of the provided expres-sion Min ([ALL | DISTINCT ] DateTime | numeric | string)

Min

Returns a Double which is the sample standard deviation of theprovided expression Stddev ([ALL | DISTINCT ] numeric)

Stddev

Returns a Double which is the sum of the values identified by theprovided expression Sum ([ALL | DISTINCT ] numeric)

Sum

Returns a byte array which yields the spatial extent of a set of geo-metries The argument is the name of geometry property SpatialEx-

Spatial Extent

tent (ltgeometriesgt) For example given these geometries POINT(11) LINESTRING(01 21) and POLYGON((01 21 12 01)) it returnsPOLYGON((01 21 22 02 01))

Expression | 49

NOTE The median is selected or calculated by doing the following

1 Sort the sample in ascending order

2 Calculate the Row of Interest (roi) using the forumula roi = (1 +((ltsample_sizegt - 1) 2))

3 Compare three values roi Ceil(roi) and Floor(roi) If they are equal themedian is the value in the Row Of Interest If they are not equal themedian is calculated by averaging the values in the rows preceding andsucceeding the Row of Interest

NOTE The value returned by the StdDev function is known as the sample standarddeviation and represents an estimate of the standard deviation of a populationbased on a random sample of that population See the Wikipedia entry for furtherdiscussion and a definition of the formula for sample standard deviationhttpenwikipediaorgwikiStandard_deviation

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++-+++++Double Avg(Double)

++--++-+++++Int64 Count(Int64)

++--++-+++++Double Max(Double)

++--++-+++++Double Min(Double)

++--++-+++++Double Sum(Double)

-+-+++-+-+++BLOB SpatialExtents(BLOB)

-+--++-+-+-+Double Avg(Byte) Double Avg(Decimal) Double Avg(Int16)Double Avg(Int32) Double Avg(Int64) Double Avg(Single)Double Avg(StringByte) Double Avg(StringDecimal) DoubleAvg(StringDouble) Double Avg(StringInt16) Double

50 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Avg(StringInt32) Double Avg(StringInt64) DoubleAvg(StringSingle)

-+--++-+-+-+Int64 Count(BLOB) Int64 Count(Boolean) Int64 Count(Byte)Int64 Count(CLOB) Int64 Count(DateTime) Int64Count(Decimal) Int64 Count(Double) Int64 Count(Int16) Int64Count(Int32) Int64 Count(Single) Int64 Count(String) Int64Count(StringBoolean) Int64 Count(StringByte) Int64Count(StringDateTime) Int64 Count(StringDecimal) Int64Count(StringDouble) Int64 Count(StringInt16) Int64Count(StringInt32) Int64 Count(StringInt64) Int64Count(StringSingle) Int64 Count(StringString)

-+--++-+-+-+Byte Max(Byte) Byte Max(StringByte) DateTime Max(Date-Time) DateTime Max(StringDateTime) Decimal Max(Decimal)Decimal Max(StringDecimal) Double Max(StringDouble) Int16Max(Int16) Int16 Max(StringInt16) Int32 Max(Int32) Int32Max(StringInt32) Int64 Max(Int64) Int64 Max(StringInt64)Single Max(Single) Single Max(StringSingle) StringMax(String) String Max(StringString)

-+--++-+-+-+Double Median(Byte) Double Median(Decimal) Double Medi-an(Double) Double Median(Int16) Double Median(Int32)Double Median(Int64) Double Median(Single)

-+--++-+-+-+Byte Min(Byte) Byte Min(StringByte) DateTime Min(DateTime)DateTime Min(StringDateTime) Decimal Min(Decimal)Decimal Min(StringDecimal) Double Min(StringDouble) Int16Min(Int16) Int16 Min(StringInt16) Int32 Min(Int32) Int32Min(StringInt32) Int64 Min(Int64) Int64 Min(StringInt64)Single Min(Single) Single Min(StringSingle) String Min(String)String Min(StringString)

-+--++-+-+-+Double Stddev(Byte) Double Stddev(Decimal) DoubleStddev(Double) Double Stddev(Int16) Double Stddev(Int32)Double Stddev(Int64) Double Stddev(Single) Double

Expression | 51

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Stddev(StringByte) Double Stddev(StringDecimal) DoubleStddev(StringDouble) Double Stddev(StringInt16) DoubleStddev(StringInt32) Double Stddev(StringInt64) DoubleStddev(StringSingle)

-+--++-+-+-+Double Sum(Byte) Double Sum(Decimal) Double Sum(Int16)Double Sum(Int32) Double Sum(Int64) Double Sum(Single)Double Sum(StringByte) Double Sum(StringDecimal) DoubleSum(StringDouble) Double Sum(StringInt16) DoubleSum(StringInt32) Double Sum(StringInt64) DoubleSum(StringSingle)

Conversion Expression Functions

DescriptionFunction Name

Evaluates two expressions and returns the first one if it does notevaluate to NULL the second otherwise The signatures without

NullValue

function name are Boolean(BooleanBoolean) Byte(ByteByte)DateTime(DateTimeDateTime) Decimal(DecimalDecimal)Double(DecimalDouble) Decimal(DecimalInt16 | Int32)Double(DecimalInt64) Single(DecimalSingle)Double(DoubleDecimal | Double | Int16 | Int32 | Int64 | Single)Double(Int16Decimal | Double) Int16(Int16Int16)Int32(Int16Int32) Int64(Int16Int64) Single(Int16Single)Double(Int32Decimal | Double) Int32(Int32Int16 | Int32)Int64(Int32Int64) Double(Int32Single)Double(Int64Decimal |Double | Single) Int64(Int64Int16 | Int32 | Int64)Double(SingleDecimal | Double | Int32 | Int64) Single(SingleInt16| Single) String(StringDecimal | Double | Int16 | Int32 | Int64 |Single | String)

Converts a string with datetime information to a date ToDate(date_string [ format_string]) The default format_string is ldquoDDMON YYYY h24 mm ssrdquo

ToDate

52 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Converts a numeric or string expression to a double ToDouble(numeric | string)

ToDouble

Converts a numeric or string expression to a float ToFloat (numeric| string)

ToFloat

Converts a numeric or string expression to an int32 ToInt32 (nu-meric | string)

ToInt32

Converts a numeric or string expression to an int64 ToInt64 (nu-meric | string)

ToInt64

Converts a numeric or date expression to a string ToString(numer-ic) ToString (DateTime [ format_string]) The default format_stringis ldquoDD-MON-YYYY h24mmssrdquo

ToString

The ToDate function takes a string value representing date andor timeinformation and converts it to a date object The optional format specificationparameter defines the format used in the string to represent the date usingthe abbreviations described in the following table For example for a stringcontaining the date April 2 1998 the format specification should containMonth DD YYYY

The ToString function takes a date value and creates a representation of it ina string The optional format specification parameter allows the user to definethe structure of the string to be created using the abbreviations described inthe following table

DescriptionAbbrevi-ation

Indicates that a year is defined as a two digit number (example 07)YY

Indicates that a year is defined as a four digit number (example 2007)YYYY

Indicates that a month is defined by its name all in uppercase letters (example APRIL)MONTH

Indicates that a month is defined by its name all in lowercase letters (example april)month

Expression | 53

DescriptionAbbrevi-ation

Indicates that a month is defined by its name with the first letter being an uppercaseletter (example April)

Month

Indicates that a month is defined by its abbreviation all in uppercase letters (exampleAPR)

MON

Indicates that a month is defined by its abbreviation all in lowercase letters (exampleapr)

mon

Indicates that a month is defined by its number (example 04)MM

Indicates that a day is defined by its number (example 04)DD

Indicates that a hour is defined by its number in the range [0-24]hh24

Indicates that a hour is defined by its number in the range [1-12]hh12

Represents a default representation of an hour Defaults to hh24hh

Indicates a minute definitionmm

Indicates a second definitionss

Indicates a millisecond definitionms

The meridiem Only considered if used with the time range [1-12] (format hh12)am | pm

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Boolean NullValue(BooleanBoolean) Byte NullValue(ByteByte)DateTime NullValue(DateTimeDateTime) Decimal Null-Value(DecimalDecimal) Decimal NullValue(DecimalInt16)

54 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Decimal NullValue(DecimalInt32) Double NullValue(Decim-alDouble) Double NullValue(DecimalInt64) Double Null-Value(DoubleDecimal) Double NullValue(DoubleDouble)Double NullValue(DoubleInt16) Double NullValue(DoubleInt32)Double NullValue(DoubleInt64) Double Null-Value(DoubleSingle) Double NullValue(Int16Decimal) DoubleNullValue(Int16Double) Double NullValue(Int32Decimal)Double NullValue(Int32Double) Double NullValue(Int32Single)Double NullValue(Int64Decimal) Double Null-Value(Int64Double) Double NullValue(Int64Single) DoubleNullValue(SingleDecimal) Double NullValue(SingleDouble)Double NullValue(SingleInt32) Double NullValue(SingleInt64)Int16 NullValue(Int16Int16) Int32 NullValue(Int16Int32) Int32NullValue(Int32Int16) Int32 NullValue(Int32Int32) Int64 Null-Value(Int16Int64) Int64 NullValue(Int32Int64) Int64 Null-Value(Int64Int16) Int64 NullValue(Int64Int32) Int64 Null-Value(Int64Int64) Single NullValue(DecimalSingle) SingleNullValue(Int16Single) Single NullValue(SingleInt16) SingleNullValue(SingleSingle) String NullValue(StringDecimal) StringNullValue(StringDouble) String NullValue(StringInt16) StringNullValue(StringInt32) String NullValue(StringInt64) StringNullValue(StringSingle) String NullValue(StringString)

-+--++-+-+-+DateTime ToDate(String) DateTime ToDate(StringString)

-+--++-+-+-+Double ToDouble(Byte) Double ToDouble(Decimal) DoubleToDouble(Double) Double ToDouble(Int16) Double To-Double(Int32) Double ToDouble(Int64) Double To-Double(Single) Double ToDouble(String)

-+--++-+-+-+Single ToFloat(Byte) Single ToFloat(Decimal) Single To-Float(Double) Single ToFloat(Int16) Single ToFloat(Int32) SingleToFloat(Int64) Single ToFloat(Single) Single ToFloat(String)

Expression | 55

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Int32 ToInt32(Byte) Int32 ToInt32(Decimal) Int32ToInt32(Double) Int32 ToInt32(Int16) Int32 ToInt32(Int32)Int32 ToInt32(Int64) Int32 ToInt32(Single) Int32 ToInt32(String)

-+--++-+-+-+Int64 ToInt64(Byte) Int64 ToInt64(Decimal) Int64ToInt64(Double) Int64 ToInt64(Int16) Int64 ToInt64(Int32)Int64 ToInt64(Int64) Int64 ToInt64(Single) Int64 ToInt64(String)

-+--++-+-+-+String ToString(Byte) String ToString(DateTime) String To-String(DateTimeString) String ToString(Decimal) String To-String(Double) String ToString(Int16) String ToString(Int32)String ToString(Int64) String ToString(Single)

Date Expression Functions

DescriptionFunction Name

Adds a specified number of months to agiven date expression and returns a Date-Time AddMonths (date_time numeric)

AddMonths

Returns the current date CurrentDate ()CurrentDate

Extracts a specified portion of a date andreturns a DateTime Extract (YEAR|

Extract

MONTH | DAY | HOUR | MINUTE |SECOND date_time)

Calculates the number of months betweentwo provide date expressions and returns

MonthsBetween

56 | Chapter 6 FDO Capabilities

DescriptionFunction Name

a Double MonthsBetween (date_timedate_time)

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+DateTime AddMonths(DateTimeByte) DateTimeAddMonths(DateTimeDecimal) DateTime AddMonths(Date-TimeDouble) DateTime AddMonths(DateTimeInt16) DateTimeAddMonths(DateTimeInt32) DateTime AddMonths(Date-TimeInt64) DateTime AddMonths(DateTimeSingle)

-+--++-+-+-+DateTime CurrentDate()

-+--++-+-+-+DateTime Extract(StringDateTime)

-+--++-+-+-+Double MonthsBetween(DateTimeDateTime)

Geometry Expression Functions

DescriptionFunction Name

Returns a Double which is the area of ageometry Area2D (ltgeometrygt)

Area2D

Returns a Double which is the length of ageometry Length2D (ltgeometrygt)

Length2D

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Area2D(BLOB)

Expression | 57

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Length2D(BLOB)

Mathematical Expression Functions

DescriptionFunction Name

Returns the absolute value of a numeric expression Abs (numeric)The return type is the same as the argument type

Abs

Returns a Double which is the arc cosine of a numeric expressionAcos (numeric)

Acos

Returns a Double which is the arc sine of a numeric expressionAsin (numeric)

Asin

Returns a Double which is the arc tangent of a numeric expressionAtan (numeric)

Atan

Returns a Double which is the arc tangent based on two numericexpressions Atan2 (numeric numeric)

Atan2

Returns a Double which is the cosine of a numeric expression Cos(numeric)

Cos

Returns a Double which is e raised to the power of a numeric ex-pression Exp (numeric)

Exp

Returns a Double which is the natural logarithm of a numeric ex-pression Ln (numeric)

Ln

Returns a Double which is the logarithm of a numeric expressionusing the provided base Log (base_numeric numeric)

Log

58 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Returns the remainder of the division of two numeric expressionsMod (numeric divisior_numeric) The implementation alogirthm

Mod

is Mod (m n) = (sign(m) (abs(m) - (abs(n) Floor(mn)))))mod(154) returns 3 mod(150) returns 15 mod(1162) returns16 mod(11621) returns 11 mod(-154) returns -3 mod(-150)returns -15 The return signatures without the function name areByte(ByteByte | Int16 | Int32 | Int64) Double(ByteDecimal |Double) Single(ByteSingle) Double(Decimal | DoubleByte |Decimal | Double | Int16 | Int32 | Int64 | Single) Int16(Int16Byte| Int16 | Int32 | Int64) Double(Int16Decimal | Double)Single(Int16Single) Int32(Int32Byte) Double(Int32Decimal |Double) Int16(Int32Int16) Int32(Int32Int32 | Int64)Single(Int32Single) Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single) Double(SingleDecimal | Double)

Returns a Double which is the result of a numeric expression raisedto the power of another numeric expression Power (numericpower_numeric)

Power

Returns the remainder of the division of two numeric expressionsRemainder (numeric divisor_numeric) The implementation al-

Remainder

gorithm is Remainder (mn) = (sign(m) (abs(m) - (abs(n) Round(mn)))) remainder(156) returns 3 remainder(155) returns0 remainder(154) returns -1 remainder(1162) returns -04 re-mainder(11621) returns -1 remainder(-154) returns 1 The sig-natures without function name are Int16(ByteByte | Int16)Double(ByteDecimal | Double) Int32(ByteInt32)Int64(ByteInt64) Single(ByteSingle) Double(Decimal |DoubleByte | Decimal | Double | Int16 | Int32 | Int64 | Single)Int16(Int16Byte | Int16 | Int32 | Int32) Double(Int16Decimal |Double) Single(Int16Single) Int32(Int32Byte | Int32 | Int64)Double(Int32Decimal | Double) Int16(Int32Int16)Single(Int32Single)Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single))

Expression | 59

DescriptionFunction Name

Returns a Double which is the sine of a numeric expression Sin(numeric)

Sin

Returns a Double which is the square root of a numeric expressionSqrt (numeric)

Sqrt

Returns a Double which is the tangent of a numeric expressionTan (numeric)

Tan

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Byte Abs(Byte) Decimal Abs(Decimal) Double Abs(Double)Int16 Abs(Int16) Int32 Abs(Int32) Int64 Abs(Int64) SingleAbs(Single)

-+--++-+-+-+Double Acos(Byte) Double Acos(Decimal) Double Acos(Double)Double Acos(Int16) Double Acos(Int32) Double Acos(Int64)Double Acos(Single)

-+--++-+-+-+Double Asin(Byte) Double Asin(Decimal) Double Asin(Double)Double Asin(Int16) Double Asin(Int32) Double Asin(Int64)Double Asin(Single)

-+--++-+-+-+Double Atan(Byte) Double Atan(Decimal) Double Atan(Double)Double Atan(Int16) Double Atan(Int32) Double Atan(Int64)Double Atan(Single)

-+--++-+-+-+Double Atan2(ByteByte) Double Atan2(ByteDecimal) DoubleAtan2(ByteDouble) Double Atan2(ByteInt16) DoubleAtan2(ByteInt32) Double Atan2(ByteInt64) DoubleAtan2(ByteSingle) Double Atan2(DecimalByte) DoubleAtan2(DecimalDecimal) Double Atan2(DecimalDouble) DoubleAtan2(DecimalInt16) Double Atan2(DecimalInt32) DoubleAtan2(DecimalInt64) Double Atan2(DecimalSingle) Double

60 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Atan2(DoubleByte) Double Atan2(DoubleDecimal) DoubleAtan2(DoubleDouble) Double Atan2(DoubleInt16) DoubleAtan2(DoubleInt32) Double Atan2(DoubleInt64) DoubleAtan2(DoubleSingle) Double Atan2(Int16Byte) DoubleAtan2(Int16Decimal) Double Atan2(Int16Double) DoubleAtan2(Int16Int16) Double Atan2(Int16Int32) DoubleAtan2(Int16Int64) Double Atan2(Int16Single) DoubleAtan2(Int32Byte) Double Atan2(Int32Decimal) DoubleAtan2(Int32Double) Double Atan2(Int32Int16) DoubleAtan2(Int32Int32) Double Atan2(Int32Int64) DoubleAtan2(Int32Single) Double Atan2(Int64Byte) DoubleAtan2(Int64Decimal) Double Atan2(Int64Double) DoubleAtan2(Int64Int16) Double Atan2(Int64Int32) DoubleAtan2(Int64Int64) Double Atan2(Int64Single) DoubleAtan2(SingleByte) Double Atan2(SingleDecimal) DoubleAtan2(SingleDouble) Double Atan2(SingleInt16) DoubleAtan2(SingleInt32) Double Atan2(SingleInt64) DoubleAtan2(SingleSingle)

-+--++-+-+-+Double Cos(Byte) Double Cos(Decimal) Double Cos(Double)Double Cos(Int16) Double Cos(Int32) Double Cos(Int64)Double Cos(Single)

-+--++-+-+-+Double Exp(Byte) Double Exp(Decimal) Double Exp(Double)Double Exp(Int16) Double Exp(Int32) Double Exp(Int64)Double Exp(Single)

-+--++-+-+-+Double Ln(Byte) Double Ln(Decimal) Double Ln(Double)Double Ln(Int16) Double Ln(Int32) Double Ln(Int64) DoubleLn(Single)

-+--++-+-+-+Double Log(ByteByte) Double Log(ByteDecimal) DoubleLog(ByteDouble) Double Log(ByteInt16) DoubleLog(ByteInt32) Double Log(ByteInt64) DoubleLog(ByteSingle) Double Log(DecimalByte) DoubleLog(DecimalDecimal) Double Log(DecimalDouble) Double

Expression | 61

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Log(DecimalInt16) Double Log(DecimalInt32) DoubleLog(DecimalInt64) Double Log(DecimalSingle) DoubleLog(DoubleByte) Double Log(DoubleDecimal) DoubleLog(DoubleDouble) Double Log(DoubleInt16) DoubleLog(DoubleInt32) Double Log(DoubleInt64) DoubleLog(DoubleSingle) Double Log(Int16Byte) DoubleLog(Int16Decimal) Double Log(Int16Double) DoubleLog(Int16Int16) Double Log(Int16Int32) DoubleLog(Int16Int64) Double Log(Int16Single) DoubleLog(Int32Byte) Double Log(Int32Decimal) DoubleLog(Int32Double) Double Log(Int32Int16) DoubleLog(Int32Int32) Double Log(Int32Int64) DoubleLog(Int32Single) Double Log(Int64Byte) DoubleLog(Int64Decimal) Double Log(Int64Double) DoubleLog(Int64Int16) Double Log(Int64Int32) DoubleLog(Int64Int64) Double Log(Int64Single) DoubleLog(SingleByte) Double Log(SingleDecimal) DoubleLog(SingleDouble) Double Log(SingleInt16) DoubleLog(SingleInt32) Double Log(SingleInt64) DoubleLog(SingleSingle)

-+--++-+-+-+Byte Mod(ByteByte) Byte Mod(ByteInt16) ByteMod(ByteInt32) Byte Mod(ByteInt64) DoubleMod(ByteDecimal) Double Mod(ByteDouble) DoubleMod(DecimalByte) Double Mod(DecimalDecimal) DoubleMod(DecimalDouble) Double Mod(DecimalInt16) DoubleMod(DecimalInt32) Double Mod(DecimalInt64) DoubleMod(DecimalSingle) Double Mod(DoubleByte) DoubleMod(DoubleDecimal) Double Mod(DoubleDouble) DoubleMod(DoubleInt16) Double Mod(DoubleInt32) DoubleMod(DoubleInt64) Double Mod(DoubleSingle) DoubleMod(Int16Decimal) Double Mod(Int16Double) DoubleMod(Int32Decimal) Double Mod(Int32Double) DoubleMod(Int64Decimal) Double Mod(Int64Double) DoubleMod(SingleDecimal) Double Mod(SingleDouble) Int16Mod(Int16Byte) Int16 Mod(Int16Int16) Int16Mod(Int16Int32) Int16 Mod(Int16Int64) Int16

62 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Mod(Int32Int16) Int16 Mod(Int64Int16) Int32Mod(Int32Byte) Int32 Mod(Int32Int32) Int32Mod(Int32Int64) Int32 Mod(Int64Int32) Int64Mod(Int64Byte) Int64 Mod(Int64Int64) SingleMod(ByteSingle) Single Mod(Int16Single) SingleMod(Int32Single) Single Mod(Int64Single) SingleMod(SingleByte) Single Mod(SingleInt16) SingleMod(SingleInt32) Single Mod(SingleInt64) SingleMod(SingleSingle)

-+--++-+-+-+Double Power(ByteByte) Double Power(ByteDecimal) DoublePower(ByteDouble) Double Power(ByteInt16) DoublePower(ByteInt32) Double Power(ByteInt64) DoublePower(ByteSingle) Double Power(DecimalByte) DoublePower(DecimalDecimal) Double Power(DecimalDouble) DoublePower(DecimalInt16) Double Power(DecimalInt32) DoublePower(DecimalInt64) Double Power(DecimalSingle) DoublePower(DoubleByte) Double Power(DoubleDecimal) DoublePower(DoubleDouble) Double Power(DoubleInt16) DoublePower(DoubleInt32) Double Power(DoubleInt64) DoublePower(DoubleSingle) Double Power(Int16Byte) DoublePower(Int16Decimal) Double Power(Int16Double) DoublePower(Int16Int16) Double Power(Int16Int32) DoublePower(Int16Int64) Double Power(Int16Single) DoublePower(Int32Byte) Double Power(Int32Decimal) DoublePower(Int32Double) Double Power(Int32Int16) DoublePower(Int32Int32) Double Power(Int32Int64) DoublePower(Int32Single) Double Power(Int64Byte) DoublePower(Int64Decimal) Double Power(Int64Double) DoublePower(Int64Int16) Double Power(Int64Int32) DoublePower(Int64Int64) Double Power(Int64Single) DoublePower(SingleByte) Double Power(SingleDecimal) DoublePower(SingleDouble) Double Power(SingleInt16) DoublePower(SingleInt32) Double Power(SingleInt64) DoublePower(SingleSingle)

Expression | 63

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Remainder(ByteDecimal) Double Re-mainder(ByteDouble) Double Remainder(DecimalByte) DoubleRemainder(DecimalDecimal) Double Remainder(Decim-alDouble) Double Remainder(DecimalInt16) Double Re-mainder(DecimalInt32) Double Remainder(DecimalInt64)Double Remainder(DecimalSingle) Double Re-mainder(DoubleByte) Double Remainder(DoubleDecimal)Double Remainder(DoubleDouble) Double Re-mainder(DoubleInt16) Double Remainder(DoubleInt32)Double Remainder(DoubleInt64) Double Re-mainder(DoubleSingle) Double Remainder(Int16Decimal)Double Remainder(Int16Double) Double Re-mainder(Int32Decimal) Double Remainder(Int32Double)Double Remainder(Int64Decimal) Double Re-mainder(Int64Double) Double Remainder(SingleDecimal)Double Remainder(SingleDouble) Int16 Remainder(ByteByte)Int16 Remainder(ByteInt16) Int16 Remainder(Int16Byte) Int16Remainder(Int16Int16) Int16 Remainder(Int16Int32) Int16Remainder(Int16Int64) Int16 Remainder(Int32Int16) Int16Remainder(Int64Int16) Int32 Remainder(ByteInt32) Int32 Re-mainder(Int32Byte) Int32 Remainder(Int32Int32) Int32 Re-mainder(Int32Int64) Int32 Remainder(Int64Int32) Int64 Re-mainder(ByteInt64) Int64 Remainder(Int64Byte) Int64 Re-mainder(Int64Int64) Single Remainder(ByteSingle) Single Re-mainder(Int16Single) Single Remainder(Int32Single) SingleRemainder(Int64Single) Single Remainder(SingleByte) SingleRemainder(SingleInt16) Single Remainder(SingleInt32) SingleRemainder(SingleInt64) Single Remainder(SingleSingle)

-+--++-+-+-+Double Sin(Byte) Double Sin(Decimal) Double Sin(Double)Double Sin(Int16) Double Sin(Int32) Double Sin(Int64) DoubleSin(Single)

-+--++-+-+-+Double Sqrt(Byte) Double Sqrt(Decimal) Double Sqrt(Double)Double Sqrt(Int16) Double Sqrt(Int32) Double Sqrt(Int64)Double Sqrt(Single)

64 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Tan(Byte) Double Tan(Decimal) Double Tan(Double)Double Tan(Int16) Double Tan(Int32) Double Tan(Int64)Double Tan(Single)

Numeric Expression Functions

DescriptionFunction Name

Returns the smallest integer greater than or equal to a numeric ex-pression The return type is the same as the argument type Where

Ceil

the argument is a Decimal Double or Single the returned value isan integral number Ceil(numeric)

Returns the largest integer less than or equal to a numeric expres-sion The return type is the same as the argument type Where the

Floor

argument is a Decimal Double or Single the returned value is anintegral number Floor (numeric)

Returns the rounded value of a numeric expression The return typeis the same as the type of the first argument Round (numeric [number_of_decimals_numeric])

Round

Returns and Int32 which is -1 if the provided numeric expressionevaluates to a value less than 0 0 if the expression evaluates to 0

Sign

and 1 if the expression evaluates to a value bigger than 0 Sign(numeric)

Truncates a numeric or date expression The return type is the sameas the type of the first argument Trunc (date_time YEAR | MONTH

Trunc

Expression | 65

DescriptionFunction Name

| DAY | HOUR | MINUTE) Trunc (numeric [ number_of_decim-als_numeric])

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+++Int64 Ceil(Int64)

-+--++-+-+++Int64 Floor(Int64)

-+--++-+-+-+Byte Ceil(Byte) Decimal Ceil(Decimal) Double Ceil(Double)Int16 Ceil(Int16) Int32 Ceil(Int32) Single Ceil(Single)

-+--++-+-+-+Byte Floor(Byte) Decimal Floor(Decimal) DoubleFloor(Double) Int16 Floor(Int16) Int32 Floor(Int32) SingleFloor(Single)

-+--++-+-+-+Byte Round(Byte) Byte Round(ByteByte) ByteRound(ByteDecimal) Byte Round(ByteDouble) ByteRound(ByteInt16) Byte Round(ByteInt32) ByteRound(ByteInt64) Byte Round(ByteSingle) DecimalRound(Decimal) Decimal Round(DecimalByte) DecimalRound(DecimalDecimal) Decimal Round(DecimalDouble)Decimal Round(DecimalInt16) Decimal Round(Decim-alInt32) Decimal Round(DecimalInt64) DecimalRound(DecimalSingle) Double Round(Double) DoubleRound(DoubleByte) Double Round(DoubleDecimal) DoubleRound(DoubleDouble) Double Round(DoubleInt16) DoubleRound(DoubleInt32) Double Round(DoubleInt64) DoubleRound(DoubleSingle) Int16 Round(Int16) Int16Round(Int16Byte) Int16 Round(Int16Decimal) Int16Round(Int16Double) Int16 Round(Int16Int16) Int16Round(Int16Int32) Int16 Round(Int16Int64) Int16Round(Int16Single) Int32 Round(Int32) Int32Round(Int32Byte) Int32 Round(Int32Decimal) Int32Round(Int32Double) Int32 Round(Int32Int16) Int32

66 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Round(Int32Int32) Int32 Round(Int32Int64) Int32Round(Int32Single) Int64 Round(Int64) Int64Round(Int64Byte) Int64 Round(Int64Decimal) Int64Round(Int64Double) Int64 Round(Int64Int16) Int64Round(Int64Int32) Int64 Round(Int64Int64) Int64Round(Int64Single) Single Round(Single) SingleRound(SingleByte) Single Round(SingleDecimal) SingleRound(SingleDouble) Single Round(SingleInt16) SingleRound(SingleInt32) Single Round(SingleInt64) SingleRound(SingleSingle)

-+--++-+-+-+Int32 Sign(Byte) Int32 Sign(Decimal) Int32 Sign(Double)Int32 Sign(Int16) Int32 Sign(Int32) Int32 Sign(Int64) Int32Sign(Single)

-+--++-+-+-+Byte Trunc(Byte) Byte Trunc(ByteByte) ByteTrunc(ByteDecimal) Byte Trunc(ByteDouble) ByteTrunc(ByteInt16) Byte Trunc(ByteInt32) ByteTrunc(ByteInt64) Byte Trunc(ByteSingle) DateTimeTrunc(DateTimeString) Decimal Trunc(Decimal) DecimalTrunc(DecimalByte) Decimal Trunc(DecimalDecimal)Decimal Trunc(DecimalDouble) Decimal Trunc(Decim-alInt16) Decimal Trunc(DecimalInt32) DecimalTrunc(DecimalInt64) Decimal Trunc(DecimalSingle) DoubleTrunc(Double) Double Trunc(DoubleByte) DoubleTrunc(DoubleDecimal) Double Trunc(DoubleDouble)Double Trunc(DoubleInt16) Double Trunc(DoubleInt32)Double Trunc(DoubleInt64) Double Trunc(DoubleSingle)Int16 Trunc(Int16) Int16 Trunc(Int16Byte) Int16Trunc(Int16Decimal) Int16 Trunc(Int16Double) Int16Trunc(Int16Int16) Int16 Trunc(Int16Int32) Int16Trunc(Int16Int64) Int16 Trunc(Int16Single) Int32Trunc(Int32) Int32 Trunc(Int32Byte) Int32Trunc(Int32Decimal) Int32 Trunc(Int32Double) Int32Trunc(Int32Int16) Int32 Trunc(Int32Int32) Int32Trunc(Int32Int64) Int32 Trunc(Int32Single) Int64Trunc(Int64) Int64 Trunc(Int64Byte) Int64

Expression | 67

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Trunc(Int64Decimal) Int64 Trunc(Int64Double) Int64Trunc(Int64Int16) Int64 Trunc(Int64Int32) Int64Trunc(Int64Int64) Int64 Trunc(Int64Single) SingleTrunc(Single) Single Trunc(SingleByte) SingleTrunc(SingleDecimal) Single Trunc(SingleDouble) SingleTrunc(SingleInt16) Single Trunc(SingleInt32) SingleTrunc(SingleInt64) Single Trunc(SingleSingle)

String Expression Functions

All of these functions return a string

DescriptionFunction Name

Returns the concatenation of two string expressions Concat(boolean | date | numeric | string boolean | date | numeric |string)

Concat

Returns an Int64 which is the position of a substring in a stringexpression Instr(stringstring)

Instr

Returns an Int64 which is the length of a string expressionLength(string)

Length

Converts all uppercase letters in a string expression into lowercaseletters string Lower (string)

Lower

Pads a string expression to the left to a predefined string lengthstring Lpad (string TotalLengthOfResult [ pad-string]) If used withtwo parameters only the pad-string is a single space character

Lpad

Removes leading blanks from a string expression string Ltrim(string)

Ltrim

68 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Pads a string expression to the right to a predefined string lengthstring Rpad (string TotalLengthOfResult [ pad-string]) If used

Rpad

with two parameters only the pad-string is a single space character

Removes trailing blanks from a string expression string Rtrim(string)

Rtrim

Returns a string which is the phonetic representation of a stringexpression See the entry in Wikipedia for more information ht-

Soundex

tpenwikipediaorgwikiSoundex Soundex (string) Soun-dex(lsquoeightrsquo) returns ldquoE230rdquo and Soundex(lsquoexpressionrsquo) returnsldquoE216rdquo

Extracts a substring from a string expression string Substr (stringstart_pos [ length])

Substr

Replaces a set of letters in a string Translate (string from_set_stringto_set_string) If string is ldquoSQLPlus Users Guiderdquo and

Translate

from_set_string is thatis lsquospaceasteriskforward slashsingle quotesingle quotersquo and the to_set_string is___ that islsquounderscoreunderscoreunderscorersquo then the returned stringis lsquoSQL_PLus_Users_Guidersquo Translate looks for each character inthe from_set_string in the string argument and replaces it with thecorresponding character from the to_set_string In this case twospaces are replace by underscores and an asterisk is replaced by nunderscore There is no forward slash in the target string to be re-placed and there is no replacement character in the to_set_stringcorresponding to the single apostrophe character in thefrom_set_string When there is no replacement character in theto_set_string corresponding to a character in the from_set_stringthe character in the from_set_string is removed wherever it is foundin the target string

Removes leading andor trailing blanks from a string expressionTrim ([BOTH | LEADING | TRAILING ] string)

Trim

Expression | 69

DescriptionFunction Name

Converts all lowercase letters in a string expression into uppercaseletters Upper (string)

Upper

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+++++String Concat(StringString)

-+--++-+-+-+String Concat(BooleanBoolean) String Concat(BooleanByte)String Concat(BooleanDateTime) String Concat(BooleanDecim-al) String Concat(BooleanDouble) String Concat(BooleanInt16)String Concat(BooleanInt32) String Concat(BooleanInt64) StringConcat(BooleanSingle) String Concat(BooleanString) StringConcat(ByteBoolean) String Concat(ByteByte) String Con-cat(ByteDateTime) String Concat(ByteDecimal) String Con-cat(ByteDouble) String Concat(ByteInt16) String Con-cat(ByteInt32) String Concat(ByteInt64) String Con-cat(ByteSingle) String Concat(ByteString) String Concat(Date-TimeBoolean) String Concat(DateTimeByte) String Concat(Dat-eTimeDateTime) String Concat(DateTimeDecimal) StringConcat(DateTimeDouble) String Concat(DateTimeInt16) StringConcat(DateTimeInt32) String Concat(DateTimeInt64) StringConcat(DateTimeSingle) String Concat(DateTimeString) StringConcat(DecimalBoolean) String Concat(DecimalByte) StringConcat(DecimalDateTime) String Concat(DecimalDecimal)String Concat(DecimalDouble) String Concat(DecimalInt16)String Concat(DecimalInt32) String Concat(DecimalInt64)String Concat(DecimalSingle) String Concat(DecimalString)String Concat(DoubleBoolean) String Concat(DoubleDateTime)String Concat(DoubleDecimal) String Concat(DoubleDouble)String Concat(DoubleInt16) String Concat(DoubleInt32) StringConcat(DoubleInt64) String Concat(DoubleSingle) StringConcat(DoubleString) String Concat(Int16Boolean) StringConcat(Int16Byte) String Concat(Int16DateTime) String Con-cat(Int16Decimal) String Concat(Int16Double) String Con-cat(Int16Int16) String Concat(Int16Int32) String Con-cat(Int16Int64) String Concat(Int16Single) String Con-

70 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

cat(Int16String) String Concat(Int32Boolean) String Con-cat(Int32Byte) String Concat(Int32DateTime) String Con-cat(Int32Decimal) String Concat(Int32Double) String Con-cat(Int32Int16) String Concat(Int32Int32) String Con-cat(Int32Int64) String Concat(Int32Single) String Con-cat(Int32String) String Concat(Int64Boolean) String Con-cat(Int64Byte) String Concat(Int64DateTime) String Con-cat(Int64Decimal) String Concat(Int64Double) String Con-cat(Int64Int16) String Concat(Int64Int32) String Con-cat(Int64Int64) String Concat(Int64Single) String Con-cat(Int64String) String Concat(SingleBoolean) String Con-cat(SingleByte) String Concat(SingleDateTime) String Con-cat(SingleDecimal) String Concat(SingleDouble) String Con-cat(SingleInt16) String Concat(SingleInt32) String Con-cat(SingleInt64) String Concat(SingleSingle) String Con-cat(SingleString) String Concat(StringBoolean) String Con-cat(StringByte) String Concat(StringDateTime) String Con-cat(StringDecimal) String Concat(StringDouble) String Con-cat(StringInt16) String Concat(StringInt32) String Con-cat(StringInt64) String Concat(StringSingle)

-+--++-+-+-+Int64 Instr(StringString)

-+--++-+-+-+Int64 Length(String)

-+--++-+-+-+String Lower(String)

-+--++-+-+-+String Lpad(StringByte) String Lpad(StringByteString) StringLpad(StringDecimal) String Lpad(StringDecimalString) StringLpad(StringDouble) String Lpad(StringDoubleString) StringLpad(StringInt16) String Lpad(StringInt16String) StringLpad(StringInt32) String Lpad(StringInt32String) StringLpad(StringInt64) String Lpad(StringInt64String) StringLpad(StringSingle) String Lpad(StringSingleString)

-+--++-+-+-+String Ltrim(String)

Expression | 71

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+String Rpad(StringByte) String Rpad(StringByteString) StringRpad(StringDecimal) String Rpad(StringDecimalString) StringRpad(StringDouble) String Rpad(StringDoubleString) StringRpad(StringInt16) String Rpad(StringInt16String) StringRpad(StringInt32) String Rpad(StringInt32String) StringRpad(StringInt64) String Rpad(StringInt64String) StringRpad(StringSingle) String Rpad(StringSingleString)

-+--++-+-+-+String Rtrim(String)

-+--++-+-+-+String Soundex(String)

-+--++-+-+-+String Substr(StringByte) String Substr(StringByteByte) StringSubstr(StringByteDecimal) String Substr(StringByteDouble)String Substr(StringByteInt16) String Substr(StringByteInt32)String Substr(StringByteInt64) String Substr(StringByteSingle)String Substr(StringDecimal) String Substr(StringDecimalByte)String Substr(StringDecimalDecimal) String Substr(StringDecim-alDouble) String Substr(StringDecimalInt16) String Sub-str(StringDecimalInt32) String Substr(StringDecimalInt64)String Substr(StringDecimalSingle) String Substr(StringDouble)String Substr(StringDoubleByte) String Sub-str(StringDoubleDecimal) String Substr(StringDoubleDouble)String Substr(StringDoubleInt16) String Sub-str(StringDoubleInt32) String Substr(StringDoubleInt64) StringSubstr(StringDoubleSingle) String Substr(StringInt16) StringSubstr(StringInt16Byte) String Substr(StringInt16Decimal)String Substr(StringInt16Double) String Sub-str(StringInt16Int16) String Substr(StringInt16Int32) StringSubstr(StringInt16Int64) String Substr(StringInt16Single)String Substr(StringInt32) String Substr(StringInt32Byte) StringSubstr(StringInt32Decimal) String Substr(StringInt32Double)String Substr(StringInt32Int16) String Substr(StringInt32Int32)String Substr(StringInt32Int64) String Substr(StringInt32Single)String Substr(StringInt64) String Substr(StringInt64Byte) StringSubstr(StringInt64Decimal) String Substr(StringInt64Double)

72 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

String Substr(StringInt64Int16) String Substr(StringInt64Int32)String Substr(StringInt64Int64) String Substr(StringInt64Single)String Substr(StringSingle) String Substr(StringSingleByte)String Substr(StringSingleDecimal) String Sub-str(StringSingleDouble) String Substr(StringSingleInt16) StringSubstr(StringSingleInt32) String Substr(StringSingleInt64)String Substr(StringSingleSingle)

-+--++-+-+-+String Translate(StringStringString)

-+--++-+-+-+String Trim(String) String Trim(StringString)

-+--++-+-+-+String Upper(String)

----------+-String Lower(StringString)

----------+-String Upper(StringString)

Miscellaneous Expression Functions

The following functions were not affected by the introduction of the ExpressionBuilder component in FDO 33

DescriptionFunction Name

Returns a geometry that is the subset of the geometry argumentdefined by the polygon specified by the coordinate argumentsCLIP(BLOBDoubleDoubleDoubleDouble)

CLIP

Returns a geometry MOSAIC(BLOB)MOSAIC

Returns a geometry RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

RESAMPLE

Expression | 73

DescriptionFunction Name

Returns a geometry SpatialExtent(BLOB)SpatialExtent

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----BLOB CLIP(BLOBDoubleDoubleDoubleDouble)

--+---+-----BLOB RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

--+---------BLOB SpatialExtents(BLOB)

------+-----BLOB MOSAIC(BLOB)

Filter

In C you access theOSGeoFDOConnectionsCapabilitiesIFilterCapabilities using theIConnection object (connectionFilterCapabilities)

In C++ you access the FdoIFilterCapabilities using the IConnection object(connection-gtGetFilterCapabilities())

DescriptionCapability

Tests if the value of a specified data property is within a givenset of literal values

ConditionType_In

Tests if one expression is equal not equal greater than lessthan greater than or equal to or less than or equal to anotherexpression

ConditionType_Comparison

Tests whether the value of a geometric property is within orbeyond a specified distance of a literal geometric value

ConditionType_Distance

74 | Chapter 6 FDO Capabilities

DescriptionCapability

Tests whether the value of a specified data property matchesa specified pattern

ConditionType_Like

Tests whether the value of a specified data property is nullConditionType_Null

Tests whether the value of a geometric property and a literalgeometric value satisfy the spatial relationship implied by theoperation

ConditionType_Spatial

Tests whether the geometric property value lies beyond aspecified distance of a literal geometric value

DistanceOperations_Beyond

Tests whetherthe geometric property value lies within a spe-cified distance of a literal geometric value

DistanceOperations_Within

Tests whetherthe geometric property value spatially containsthe literal geometric value

SpatialOperations_Contains

Tests whether the geometric property value is covered by theinterior and boundary of the given geometry

SpatialOperations_CoveredBy

Tests whetherthe geometric property value spatially crossesthe given geometry

SpatialOperations_Crosses

Tests whether the geometric property value is spatially disjointfrom the given geometry

SpatialOperations_Disjoint

Tests whether the envelope of the referenced geometricproperty value spatially intersects the given geometry

SpatialOperations_EnvelopeIntersects

Tests whether the geometric property value is spatially equalto the given geometry

SpatialOperations_Equals

Tests whether the geometric property value is inside the in-terior of the given geometry not touching the boundary

SpatialOperations_Inside

Filter | 75

DescriptionCapability

Tests whether the geometric property value spatially intersectsthe given geometry

SpatialOperations_Intersects

Tests whether the geometric property value spatially overlapsthe given geometry

SpatialOperations_Overlaps

Tests whether the geometric property value spatially touchesthe given geometry

SpatialOperations_Touches

Tests whether the geometric property value is spatially withinthe given geometry

SpatialOperations_Within

Tests whether the spatial and distance operations can be ap-plied between two geometric properties Returns false if spatial

SupportsNonLiteralGeometricOperations

and distance operations can be applied only between a geo-metric property and a literal geometry Returns true if spatialand distance operations can be applied

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++++++++SpatialOperations_EnvelopeIntersects ConditionType_In Condi-tionType_Spatial

-+--++++++++SpatialOperations_Intersects

++--++-+++++ConditionType_Null ConditionType_Comparison Condition-Type_Like

-+--+++++-++SpatialOperations_Inside

-+--+++-+-++SpatialOperations_Within

-------+++-+ConditionType_Distance

76 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-----+--+-++SpatialOperations_Disjoint SpatialOperations_Contains

--------+-++SpatialOperations_CoveredBy SpatialOperations_Crosses Spa-tialOperations_Touches SpatialOperations_Equals SpatialOper-ations_Overlaps

--------+--+DistanceOperations_Beyond DistanceOperations_Within

---+--------SupportsNonLiteralGeometricOperations

------------SupportsGeodesicDistance

Geometry

In C you access theOSGeoFDOConnectionsCapabilitiesIGeometryCapabilities using theIConnection object (connectionGeometryCapabilities)

In C++ you access the FdoIGeometryCapabilities using the IConnectionobject (connection-gtGetGeometryCapabilities())

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++FdoDimensionality_XY

+-++++-+++++GeometryType_Polygon GeometryComponentType_Linear-Ring

++-+++-+++++GeometryType_Point

Geometry | 77

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

+--+++-+++++GeometryType_MultiLineString GeometryType_MultiPointGeometryType_LineString

+--+-+-+++++GeometryType_MultiPolygon

+--+++-+--++GeometryComponentType_LineStringSegment

---+++--+-++FdoDimensionality_M FdoDimensionality_Z

+--+-+-+--+-GeometryComponentType_Ring

+--+-+--+-+-GeometryType_MultiGeometry

---+-+-+--+-GeometryType_CurvePolygon GeometryComponentType_Cir-cularArcSegment GeometryType_CurveString Geometry-Type_MultiCurvePolygon GeometryType_MultiCurveString

Raster

In C you access theOSGeoFDOConnectionsCapabilitiesIRasterCapabilities using theIConnection object (connectionRasterCapabilities)

In C++ you access the FdoIRasterCapabilities using the IConnection object(connection-gtGetRasterCapabilities())

DescriptionCapability

Indicates whether or not a provider supports the retrieval andmanipulation of image data

SupportsRaster

Indicates whether or not a provider supports the reduction ofthe amount of detail and data in the image

SupportsSubsampling

78 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the compositionof multiple raster images

SupportsStitching

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----SupportsRaster SupportsSubsampling

------------SupportsStitching

Schema

In C you access theOSGeoFDOConnectionsCapabilitiesISchemaCapabilities using theIConnection object (connectionSchemaCapabilities)

In C++ you access the FdoISchemaCapabilities using the IConnection object(connection-gtGetSchemaCapabilities())

DescriptionCapability

Indicates whether or not a provider supports auto gener-ation of values for the data types represented by the as-terisk Boolean Byte DateTime and Decimal

AutoGenerated_

Indicates whether or not a provider supports the Classtype which does not have a Geometry property

ClassType_Class

Indicates whether or not a provider supports the Classtype which does have a Geometry property

ClassType_FeatureClass

Indicates whether or not a provider supports the spe-cificdata type that replaces the BLOB Boolean Byte

DataType_

Schema | 79

DescriptionCapability

CLOB DateTime Decimal Double Int16 Int32 Int64Single or String

Indicates whether or not a provider supports the use ofthe property types represented by the asterisk as identity

IdentityProperty_

properties BLOB Boolean Byte DateTime DecimalDouble Int16 Int32 Int64 Single and String

Indicates whether or not a provider supports decimals upto the specified number of digits in length

MaximumDecimalPrecision

Indicates whether or not a provider supports decimalswith up to the specified number of digits to the right ofthe decimal point

MaximumDecimalScale

The set of characters which cannot be used in schemaelement names

ReservedCharactersForName

Indicates whether or not a provider supports the associ-ation property

SupportsAssociationProperties

Indicates whether or not a provider supports the automat-ic generation of id property values

SupportsAutoIdGeneration

Indicates whether or not a provider supports multipleidentity properties per class

SupportsCompositeId

Indicates whether or not a provider supports unique valueconstraints on a set of columns

SupportsCompositeUniqueValueConstraints

Indicates whether or not a provider supports the automat-ic generation of ID values that are unique for the entiredatastore rather than just for a particular class

SupportsDataStoreScopeUniqueIdGeneration

Indicates whether or not a provider supports the specific-ation of default values for property definitions

SupportsDefaultValue

80 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the settingof minimums that the input data must greater than andmaximums that the input data must be less than

SupportsExclusiveValueRangeConstraints

Indicates whether or not a provider supports the settingof minimums that the input data must greater than or

SupportsInclusiveValueRangeConstraints

equal to and maximums that the input data must be lessthan or equal to

Indicates whether or not a provider supports class hier-archies in the feature schema

SupportsInheritance

Indicates whether or not a provider supports the definitionof more than one feature schema in the data store

SupportsMultipleSchemas

Indicates whether or not a provider allows property valuesto be null

SupportsNullValueConstraints

Indicates whether or not a provider supports objectproperties A class instance can contain an instance ofanother class

SupportsObjectProperties

Indicates whether or not a provider supports the modific-ation of a schema after its intitial creation

SupportsSchemaModification

Indicates whether or not a provider supports the overrid-ing of the default rules for mapping feature schemas toprovider-specific physical schemas

SupportsSchemaOverrides

Indicates whether or not a provider supports requiringthat a column contain unique values

SupportsUniqueValueConstraints

Indicates whether or not a provider supports requiringthat a column contain values that belong to a value con-straints list

SupportsValueConstraintsList

Schema | 81

Expressible as Boolean

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ClassType_FeatureClass DataType_String

++-+++-+++++IdentityProperty_Int32 DataType_Int32 DataType_DateTimeClassType_Class

++-+-+-+++++DataType_Double

--++-+++++++IdentityProperty_String

-+-+-+-+++++DataType_Int16 DataType_Single IdentityProperty_Int16

-+--++-+++++SupportsAutoIdGeneration SupportsNullValueConstraints

-++-+-+++++-SupportsSchemaOverrides

-+-+++-++++-DataType_Decimal DataType_Boolean

++--++--+-++AutoGenerated_Int32

-+++-+++-+--SupportsInheritance

-+-+-+-++++-DataType_Byte IdentityProperty_Int64 DataType_Int64

---+-+-+++++IdentityProperty_Double IdentityProperty_DateTime Identi-tyProperty_Single

-+-+--++-+++SupportsMultipleSchemas

-+-+-+-+++--SupportsCompositeId

82 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+ReservedCharactersForName

----++-++++-SupportsSchemaModification

-+--+--+++-+MaximumDecimalPrecision MaximumDecimalScale

---+-+-++++-IdentityProperty_Boolean IdentityProperty_Decimal Identi-tyProperty_Byte

-------+++-+SupportsCompositeUniqueValueConstraints SupportsUnique-ValueConstraints

-+-----+++--AutoGenerated_Int64 SupportsDefaultValue

---+-+-+-+--SupportsAssociationProperties

--+---+----+DataType_BLOB

---+---+-+--SupportsObjectProperties

-------+-+--SupportsDataStoreScopeUniqueIdGeneration

-----+-+----SupportsValueConstraintsList SupportsExclusiveValueRangeCon-straints SupportsInclusiveValueRangeConstraints

Not Expressible as a Boolean

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

3838ArcSDE

Schema | 83

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

6565MySQL

10001000nullPostGIS

3838SQLServerSpa-tial

nullnullSDF

255255SHP

2828ODBC

84 | Chapter 6 FDO Capabilities

Schema Management

This chapter describes how to create and work with schemas and explains some issues relatedto schema management For example you can use the FDO feature schema to specify howto represent geospatial features

Schema PackageThe FDO feature schema provides a logical mechanism for specifying how torepresent geospatial features FDO providers are responsible for mapping thefeature schema to some underlying physical data store The FDO feature schemais based somewhat on a subset of the OpenGIS and ISO feature models Itsupports both non-spatial features and spatial features

The Schema package contains a collection of classes that define the logicalfeature schema These classes can be used to set up a feature schema and tointerrogate the metadata from a provider using an object-oriented structureThe logical feature schema provides a logical view of geospatial feature data thatis fully independent from the underlying storage schema All data operationsin FDO are performed against the classes and relationships defined by the logicalfeature schema For example different class types in the feature schema are usedto describe different types of geospatial objects and spatial features

Base Properties

All classes in the feature schema support the concept of base properties whichare properties that are pre-defined either by the FDO API or by a specific FDOfeature provider For example all classes in the schema have two base propertiesClassName and SchemaName These properties can be used to query across aninheritance hierarchy or to process the results of heterogeneous queries FDO

7

85

feature providers can also predefine base properties The following baseproperties are predefined by the FDO API

DescriptionRequiredProperty Name

Name of the schema to which objects of the classbelong read-only string

YSchemaName

Name of the class that defines the object read-onlystring

YClassName

Revision number of the object read-only 64-bit in-teger

NRevisionNumber

NOTE Some providers may use this property tosupport optimistic locking

Cross-Schema References

Some FDO feature providers may support multiple schemas For these providersthe feature schema supports the concept of cross-schema references for classesThis means that a class in one schema may derive from a class in anotherschema relate to a class in another schema or contain an object propertydefinition that is based on a class in another schema

Parenting in the Schema Classes

The feature schema object model defined in the FDO API supports fullnavigation through parenting That is once a schema element is added to anFdoFeatureSchema class it can navigate the object hierarchy upward to theroot FdoFeatureSchema and from there to any other element in the featureschema This parenting support is fully defined in the FdoSchemaElementabstract base class

When inserting features that have object collections the parent object instancemust be identified when inserting the child objects (for example a parentclass ldquoRoadrdquo has an object property called ldquosidewalksrdquo of type ldquoSidewalkrdquo)For more information see Data Maintenance on page 119

Physical Mappings

Each feature provider maps the logical feature schema to an underlyingphysical data store Some feature providers may provide some level of control

86 | Chapter 7 Schema Management

over how the logical schema gets mapped to the underlying physical storageFor example an RDBMS-based feature provider may allow table and columnnames to be specified for classes and properties Since this is entirelyprovider-dependent the FDO API simply provides abstract classes for passingphysical schema and class mappings to the provider(FdoPhysicalSchemaMapping FdoPhysicalClassMappingFdoPhysicalPropertyMapping and FdoPhysicalElementMapping respectively)The implementation of these abstract classes is up to each feature provider

Schema MappingsWhen a provider connects to a data source that it did not create and does adescribe schema command it will map FDO data types to the physical entitescontained in the data source This mapping is called the default schemamapping or alternatively the physical to logical schema mapping

When reverse engineering an existing schema FDO uses the following rulesto select the column(s) to use as the identity property

1 Use the primary key

2 Use a unique index

3 Treat the data as read-only

NOTE When reverse engineering a view FDO will apply rules 1 and 2 to the viewand then if necessary to the base tables

NOTE If FDO detects more than one unique index it calculates a weight for eachindex and selects the lightest one The weight of each index is the sum of theweights of its columns Column weight depends on column type as follows Indexeswith Blobs or Clobs are not chosen If FDO picks a multi-column index as theunique index it creates an identity property for each column in the index

1 for Boolean or Byte

2 for Int16

4 for Int32

8 for Int64 Decimal Double or Float

50 for DateTime

length for String

Schema Mappings | 87

After you use FDO to create a feature schema you can use external means toaccess the data store to inspect what native data types FDO uses for its logicaltypes This mapping is called the logical to physical schema mapping

The following mappings have been documented in the provider appendices

physical to logical schema mappings for ODBC connections to a MicrosoftAccess database an Excel spreadsheet and a text file

physical to logical and logical to physical schema mappings for OracleMySQL Sql Server and Sql Server Spatial

The mechanism for overriding the default schema mapping is described inthe next topic Sample code is located in the FDO Cookbook chapter of thisdocument

Schema OverridesUsing schema overrides FDO applications can customize the mappingsbetween Feature (logical) Schemas and the Physical Schema of the providerdata store

Schema overrides are provider-specific because different FDO providers supportFDO data stores with widely different physical formats Therefore the typesof schema mappings in these overrides also vary between providers Forexample an RDBMS-type provider might provide a mapping to index a set ofcolumns in a class table However other providers would not necessarily beable to work with the concept of an index For information about schemaoverrides support by a specific provider see the appropriate appendix in thisdocument and The Essential FDO

NOTE Some providers support only default schema mappings

Working with SchemasThere are three primary operations involved with schema management

Creating a schema

Describing a schema

Modifying a schema

88 | Chapter 7 Schema Management

Creating a Schema

The following basic steps are required to create a schema (some steps areoptional some may be done in an alternate order to achieve the same result)

Use the FdoFeatureSchemaCreate(ldquoSchemaNamerdquo ldquoFeatureSchemaDescriptionrdquo) method to create a schema

Use the FdoFeatureSchemaGetClasses() method to return a class collection

Use the FdoClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) orFdoFeatureClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) method to createFdoClass or FdoFeatureClass type objects

Use the FdoClassCollectionAdd(class) method to add FdoClass orFdoFeatureClass objects to the class collection

Use the FdoGeometricPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoGeometryProperty

Use the FdoDataPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo) methodto create FdoDataProperty

Use the FdoObjectPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoObjectProperty

Use the FdoClassDefinitionGetProperties() and Add(property) methodsto add property to class definition

Use the FdoIApplySchemaCommandSetFeatureSchema(feature schema)method to set the schema object for the IFdoApplySchemaCommand

Use the FdoAssociationPropertydefinition class to represent the associationbetween two classes The class of the associated class must already bedefined in the feature schema and cannot be abstract

Use the FdoIApplySchemaCommandExecute() method to execute changesto the feature schema

For an example of schema creation see Example Creating a Feature Schemaon page 111

Use the FdoClassDefinitionGetIdentityProperties() and Add(Property Object)methods to set the property as FdoClass or FdoFeatureClass Identifier FDOallows multiple Identifiers for both types of classes although Identifiers haveslight differences in both cases

Working with Schemas | 89

FDOFeatureClassFdoFeatureClass is a class that defines features In the case of GIS they wouldoften be spatial features having some sort of geometry associated with themIn most providers FdoFeatureClass requires a unique identifier to distinguishthe features

However there are identifiers only if no base class exists If the base class hasan identifier the child class does not have one You cannot set an identifierto the child class Any class definition that has a base class cannot also haveany identity properties because it inherits from the base class

Therefore you cannot send an identifier when a feature class is a child sinceit always inherits the identifier from the base class

FDOClassThis class is used for non-spatial data It can act as a stand-alone class whereit would have no association with any other class or if the FdoClass is beingused as an ObjectProperty it can be used to define properties of some otherFdoClass or FdoFeatureClass

ObjectProperty Types

ObjectProperties have the following types

Value

Collection

OrderedCollection

The Value ObjectProperty type has a relationship of one-to-one providing asingle value for each property

The Collection and OrderedCollection ObjectProperty types have aone-to-many relationship where many ObjectProperties may be associatedwith one property Ordered Collections can be stored in an ascending ordescending order

90 | Chapter 7 Schema Management

At least one Identifier will be required if the FdoClass is to be used as astand-alone Class

All Identifiers for FdoDataType_Int64 must not be Read-Only since noneof these will be an auto-generated property value

If creating multiple Identifiers all Identifiers must be set to NOT NULL

Non-Feature Class IssuesA non-feature class in FDO can be created as a stand-alone class a containedclass or both As a contained class it defines a property of another class orfeature class (see FdoFeatureClass and FdoClassType Global Enum) How thisnon-feature class is created affects the way the data is inserted queried andupdated

Stand-alone Class

This type of class stores non-feature data (for example manufacturers) TheFdoClassType_Class must be created with one or more identity properties (seeFdoObjectPropertyDefinition) which is required in order that the class has aphysical container (that is a table in the RDBMS) associated with it If theclass is created without specifying an IdentityProperty only the definition isstored in the metadata which prevents any direct data inserts

Contained Class

This type of class stores non-feature data that defines a property of anotherclass or feature class (for example Sidewalk could be a property of a Roadfeature class the Sidewalk class defines the RoadSidewalk property) In thiscase the FdoClassType_Class does not need to be created with one or moreidentity properties although it can be

Class With IdentityProperty Used as ObjectProperty

This type of class reacts like a stand-alone class however with this type it ispossible to do direct data inserts It can also be populated through a containerclass (for example RoadSidewalk) since it defines an object property (seeFdoObjectPropertyDefinition) If this class is queried directly only the datainserted into the class as a stand-alone is returned The data associated withthe ObjectProperty can only be queried through the container class (forexample RoadSidewalk)

Non-Feature Class Issues | 91

Class Without a Defined IdentityProperty Used as ObjectProperty

Because this class has no defined IdentityProperty it can only be populatedthrough the container class (for example RoadSidewalk) since it definesObjectProperty This class cannot be queried directly The data associated withthe object property can only be queried through the container class (forexample RoadSidewalk) As an object property it is defined as one of thefollowing

Value type property Does not need any identifier since it has a one-to-onerelationship with the container class

Collection type property Requires a local identifier which is an identifierdefined when creating the ObjectProperty object

Ordered Collection type property Requires a local identifier which is anidentifier defined when creating the ObjectProperty object

When defining either a Collection or Ordered Collection type ObjectPropertyyou must set an IdentityProperty attribute for that object property ThisObjectClassIdentityProperty acts only as a local identifier compared to theIdentityProperty set at the class level As a local identifier it acts to uniquelyidentify each item within each collection (for example if the local identifierfor RoadSidewalk is Side there can be multiple sidewalks with Side=rdquoLeftrdquobut only one per Road)

Describing a Schema

Use the FdoIDescribeSchemaExecute function to retrieve anFdoFeatureSchemaCollection in order to obtain any information about existingschema(s) The FdoFeatureSchemaCollection consists of all FdoFeatureSchemasin the data store and can be used to obtain information about any schemaobject including FdoFeatureSchema FdoClass FdoFeatureClass and theirrespective properties The following functions return the main collectionsrequired to obtain information about all schema objects

FdoFeatureSchemaGetClasses method obtains FdoClass andFdoFeatureClasses

FdoClassDefinitionGetProperties method obtains aFdoPropertyDefinitionCollection

FdoClassDefinitionGetBaseProperties method obtains aFdoPropertyDefinitionCollection of the properties inherited from the baseclasses

92 | Chapter 7 Schema Management

NOTE Even if your schema has no base classes (inheritance) all classes will inheritsome properties from system classes

Use these functions throughout the application to obtain any informationabout schema objects For example in order to insert data into a class youmust use these functions to determine what data type is required Descriptionof the data is separate from actions

The example in the following link is a simple function that shows how to useFdoIDescribeSchema and loop through the schema and class containers tosearch for duplicate class names It searches all schemas to ensure that theclass name does not exist in any schema in the data store Class names mustbe unique across the entire FDO database

For a schema description example see Example Describing a Schema andWriting It to an XML File on page 114 NO LABEL

FDO Schema Element Class Diagram

Non-Feature Class Issues | 93

Modifying ModelsAdd schema elements to a model by inserting them into the appropriatecollection

Elements are removed from the model by using either of the followingmethods

Call the FdoSchemaElementDelete() method This flags the element fordeletion when the changes are accepted (generally throughFdoIApplySchema) but the element remains a member of all collectionsuntil that time

Remove the element from the appropriate collection via theFdoSchemaCollectionRemove() or FdoSchemaCollectionRemoveAt()methods This immediately disassociates the element from the collection

Schema Element StatesAll elements within the model maintain a state flag This flag can be retrievedby calling FdoSchemaElementGetElementState() but it cannot be directlyset Instead its state changes in reaction to the changes made to the model

Unchanged When a schema model is retrieved via FdoIDescribeSchemaall elements are initially marked Unchanged

Detached Removing an element from an owning collection sets its stateto Detached

Deleted Calling the Delete() method on an element sets its state to Deleted

Added Placing an element within a collection marks the element as Added

Modified When adding or removing a sub-element such as a propertyelement from a class the class element state will be changed to Modified

Additionally when an element that is contained by another element is changedin any way the containing element is also marked as Modified So for exampleif a new value is added to the SchemaAttributeDictionary of the ldquoClass3rdquoelement in our model both the ldquoClass3rdquo FdoClass object and theFdoFeatureSchema object would be marked as Modified

94 | Chapter 7 Schema Management

The state flags are maintained until the changes are accepted that is whenIApplySchema is executed At that time all elements marked Deleted arereleased and all other elements are set to Unchanged

NOTE When you remove an element from an owning collection its state is markedas Detached All collections currently in FDO are owning collections except forone the collections FdoClassDefinitionGetIdentityProperties()

Rollback MechanismThe FdoFeatureSchema contains a mechanism that allows you to ldquoroll backrdquomodel changes to the last accepted state For example a model retrieved viaFdoIDescribeSchema can have classes added attributes deleted or names anddefault values changed All of these changes are thrown out and the modelreturned to its unmodified state by calling FdoFeatureSchemaRejectChanges()

The converse of this operation is the FdoFeatureSchemaAcceptChanges()method which removes all of the elements with a status of Deleted and setsthe state flag of all other elements to Unchanged Generally this method isonly invoked by FDO provider code after it has processed anFdoIApplySchemaExecute() command Normal FDO clients should not callthis method directly

FDO XML FormatFDO feature schemas can be written to an XML file The FdoFeatureSchemaand FdoFeatureSchemaCollection classes support the FdoXmlSerializableinterface The sample code shows an FdoFeatureSchema object calling theWriteXml() method to generate an XML file containing the feature schemacreated by the sample code

FDO feature schemas can also be read from an XML file TheFdoFeatureSchemaCollection class supports the FdoXmlDeserializable interfaceThe sample code shows an FdoFeatureSchemaCollection object calling theReadXml() method to read a set of feature schemas into memory from an XMLfile The code shows the desired schema being retrieved from the collectionand applied to the data store

The XML format used by FDO is a subset of the Geography Markup Language(GML) standardized by the Open GIS Consortium (OGC) One thing shownin the sample code is a round-trip conversion from FDO feature schema toGML schema back to FDO feature schema To accomplish this round-trip the

Rollback Mechanism | 95

ReadXml() method supports a superset of the GML that is written by theWriteXml() method

The following table specifies the mapping of FDO feature schema elementsto GML elements and attributes This mapping is sufficient to understand theXML file generated from the schema defined by the sample code It alsoprovides a guide for writing a GML schema file by hand This file can then beread in and applied to a data store For more information see ExampleCreating a Schema Read In from an XML File on page 114

Another form of round-trip translation would be from a GML schema producedby another vendorrsquos tool to an FDO feature schema and then back to a GMLschema However the resemblance the of resulting GML schema to the originalGML schema might vary from only roughly equivalent to being exactly thesame

Map FDO Element to GML Schema Fragment

GML Schema FragmentFDO Element

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaN

amegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgisdschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFea

tureSchemaNamegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

see ltMetaDatagt

optional xsimport element to enable schema validation

ltxsimport namespace=httpfdoosgeoorgschema

schemaLocation=ltFDO SDK Install LocationgtdocsXmlS

chemaFdoDocumentxsdgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

FeatureSchema

96 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxsfield xpath=rdquordquogt

ltxsfield xpath=rdquoltidentityPropertyltngtNamegtrdquo

ltxskeygt

ltxselementgt

ClassDefinition(with identity prop-erties)

ltxselement see ClassDefinition (with identity proper

ties)ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

see FeatureClassGeometryProperty

gt

see ltMetaDatagt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

gt

ltxssequencegt

list of properties see DataProperty Geometric

Property

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

FeatureClass

FDO XML Format | 97

GML Schema FragmentFDO Element

lt-- these attributes belong to the xscomplexType element

--gt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

FeatureClass Geo-metryProperty

lt--

minOccurs attribute generated only if value is 1

default attribute generated only if a default value exists

fdoreadOnly attribute generated only if value is true

--gt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxssimpleTypegt

see DataType String or DataType Decimal

ltxssimpleTypegt

ltxselementgt

DataProperty(decimal or string)

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxselementgt

DataProperty (oth-er type)

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

DataType String

98 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxsrestriction base=rdquoxsdecimalrdquogt

ltxstotalDigits value=rdquoltprecisiongtrdquogt

ltxsfractionDigits value=rdquoltscalegtrdquogt

ltxsrestrictiongt

DataType Decimal

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquogmlAbstractGeometryTyperdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

see ltMetaDatagt

ltxselementgt

GeometricProperty(not a defining Fea-tureClass Geo-metryProperty)

FDO XML Format | 99

GML Schema FragmentFDO Element

lt-- the pattern referenced in the xsschema element for

FeatureSchema--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeatureS

chemaCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xselement element for

DataProperty --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoDataProp

ertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt--

the pattern referenced in the xselement element for a

non-feature-defining

GeometricProperty

--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xscomplexType element

for FeatureClass --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeature

ClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

MetaData

Map FDO Datatype to GML Type

GML TypeFDO Datatype

xsbooleanBoolean

fdoByteByte

xsdateTimeDateTime

100 | Chapter 7 Schema Management

GML TypeFDO Datatype

xsdoubleDouble

fdoInt16Int16

fdoInt32Int32

fdoInt64Int64

xsfloatSingle

xsbase64BinaryBLOB

xsstringCLOB

Creating and Editing a GML Schema FileThe sample in this section illustrates the creation of a GML schema filecontaining the definition of an FDO feature schema that contains one featureThe name of this file will have the standard XML schema extension namexsd This means that it contains only one schema and that the root elementis xsschema The ReadXml() method will take a filename argument whoseextension is either xsd or xml In the latter case the file could contain manyschema definitions If it does each schema is contained in an xsschemaelement and all xsschema elements are contained in the fdoDataStoreelement If there is only one schema in the xml file then the fdoDataStoreelement is not used and the root element is xsschema

You may want to validate the schema that you create To do so you mustinclude the optional xsimport line specified in the GML schema fragmentfor FeatureSchema

The sample feature implements a table definition for the Buildings feature inthe Open GIS Consortium document 98-046r1 This table definition isexpressed in an XML format on page 14 of the document and is reproducedas follows

Creating and Editing a GML Schema File | 101

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtbuildingsltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtaddressltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtpositionltnamegt

lttypegtPOINTlttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtfootprintltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

Add GML for the FDO Feature Schema

Start with the skeleton GML for an FDO Feature Schema with the ltMetaDatagtreference replaced by the valid pattern

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaNamegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFeatureSchema

Namegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgt

description arg to static FdoFeatureSchemaCreate()

ltxsdocumentationgt

ltxsannotationgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

102 | Chapter 7 Schema Management

For ltcustomer_urlgt substitute ldquofdo_customerrdquo For ltFeatureSchemaNamegtsubstitute ldquoOGC980461FSrdquo and for description arg substitute ldquoOGCSimple Features Specification for SQLrdquo

Add GML for an FDO Feature Class

Start with the GML that is already written and add the skeleton for an FDOFeature Class which includes the skeleton for a class definition with identityproperties The ltMetaDatagt is replaced with the valid pattern

Creating and Editing a GML Schema File | 103

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoFeatureClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

104 | Chapter 7 Schema Management

gt

ltxssequencegt

list of properties see DataProperty GeometricProperty

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For ltclassNamegt substitute ldquobuildingsrdquo

Set the value of the xselement abstract attribute to false

For ltidentityPropertyNamegt substitute ldquofidrdquo A data property whose nameis ldquofidrdquo will be added

Set the value of the xscomplexType abstract attribute to false

For ltgeometryPropertyNamegt substitute ldquofootprintrdquo

For ltlist of FdoGeometricTypesgt substitute ldquosurfacerdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoFeatureClassCreate() substitute ldquoOGC 98-046r1buildingsrdquo

For lturigt substitute ldquohttpfdoosgeoorgschemardquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoa polygon defines a building perimeterrdquo

This class has no base class so set the value of the xsextension base attributeto lsquogmlAbstractFeatureTypersquo

Add GML for Property Definitions

An integer data property whose name is ldquofidrdquo will be added This property isalready identified as an identity property in the xskey element A string dataproperty whose name is ldquonamerdquo and a geometry property whose name isldquopositionrdquo will also be added

Creating and Editing a GML Schema File | 105

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquoalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquoltpropertyNamegtrdquo

106 | Chapter 7 Schema Management

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

Creating and Editing a GML Schema File | 107

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For the first data property ltpropertyNamegt substitute ldquofidrdquo

For the first data property ltdataTypegt substitute ldquofdoint32rdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquofidrdquo to false

Set the content for xsdocumentation for ldquofidrdquo to ldquofeature idrdquo

For the second data property ltpropertyNamegt substitute ldquoaddressrdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquonamerdquo to false

Set the content for xsdocumentation for ldquoaddressrdquo to ldquoaddress of thebuildingrdquo

For ltlengthgt substitute ldquo64rdquo

For the geometry property ltpropertyNamegt substitute ldquopositionrdquo

For ltlist of FdoGeometricTypesgt substitute ldquopointrdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoposition of the buildingrdquo

The Final Result

After all the required substitutions the GML for the schema containing theBuildings feature is as follows

108 | Chapter 7 Schema Management

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquofidrdquo

Creating and Editing a GML Schema File | 109

type=rdquofdoint32rdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtfeature id

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoaddressrdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtaddress of the building

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquo64rdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquopositionrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquopositionrdquo

fdogeometricTypes=rdquopointrdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtposition of the buildingltxsdocu

mentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

110 | Chapter 7 Schema Management

Schema Management ExamplesExample Creating a Feature Schema

The following sample code creates an FdoFeatureSchema object calledldquoSampleFeatureSchemardquo The schema contains one class which has threeproperties The class and its properties conform to the table definition for theLakes feature in the Open GIS Consortium document 98-046r1 This tabledefinition is expressed in an XML format on page 10 of the document and isreproduced as follows

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtlakesltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstgraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtnameltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtshoreltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

The table definition whose name is ldquolakesrdquo is mapped to an FdoFeatureClassobject called ldquoSampleFeatureClassrdquo The column definition whose name isldquofidrdquo is mapped to an FdoDataPropertyDefinition object calledldquoSampleIdentityDataPropertyrdquo The column definition whose name is ldquonamerdquois mapped to an FdoDataPropertyDefinition object calledldquoSampleNameDataPropertyrdquo The column definition whose name is ldquoshorerdquois mapped to an FdoGeometricPropertyDefinition object calledldquoSampleGeometricPropertyrdquo

Schema Management Examples | 111

Create the ApplySchema command

FdoPtrltFdoIApplySchemagt sampleApplySchema

sampleApplySchema = (FdoIApplySchema )

connection-gtCreateCommand(FdoCommandType_ApplySchema)

Create the feature schema

FdoPtrltFdoFeatureSchemagt sampleFeatureSchema

sampleFeatureSchema = FdoFeatureSchemaCreate(LSampleFeatureS

chema LSample Feature Schema Description)

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

create a feature class ie a class containing a geometric

property set some class level properties

FdoPtrltFdoFeatureClassgt sampleFeatureClass

sampleFeatureClass = FdoFeatureClassCreate(LSampleFeatureClass

LSample Feature Class Description)

sampleFeatureClass-gtSetIsAbstract(false)

get a pointer to the feature classs property collection

this pointer is used to add data and other properties to the

class

FdoPtrltFdoPropertyDefinitionCollectiongt sampleFeatureClassProper

ties

sampleFeatureClassProperties = sampleFeatureClass-gtGetProperties()

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

get a pointer to the feature classs identity property collec

tion

this property is used to add identity properties to the feature

class

FdoPtrltFdoDataPropertyDefinitionCollectiongt sampleFeatureClassId

entityProperties

sampleFeatureClassIdentityProperties = sampleFeatureClass-

gtGetIdentityProperties()

create a data property that is of type Int32 and identifies

the feature uniquely

FdoPtrltFdoDataPropertyDefinitiongt sampleIdentityDataProperty

sampleIdentityDataProperty = FdoDataPropertyDefinitionCre

ate(LSampleIdentityDataProperty LSample Identity Data Property

Description)

sampleIdentityDataProperty-gtSetDataType(FdoDataType_Int32)

112 | Chapter 7 Schema Management

sampleIdentityDataProperty-gtSetReadOnly(false)

sampleIdentityDataProperty-gtSetNullable(false)

sampleIdentityDataProperty-gtSetIsAutoGenerated(false)

add the identity property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleIdentityDataProperty)

sampleFeatureClassIdentityProperties-gtAdd(sampleIdentityDataProp

erty)

create a data property that is of type String and names the

feature

FdoPtrltFdoDataPropertyDefinitiongt sampleNameDataProperty

sampleNameDataProperty = FdoDataPropertyDefinitionCreate(LSam

pleNameDataProperty LSample Name Data Property Description)

sampleNameDataProperty-gtSetDataType(FdoDataType_String)

sampleNameDataProperty-gtSetLength(64)

sampleNameDataProperty-gtSetReadOnly(false)

sampleNameDataProperty-gtSetNullable(false)

sampleNameDataProperty-gtSetIsAutoGenerated(false)

add the name property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleNameDataProperty)

create a geometric property

FdoPtrltFdoGeometricPropertyDefinitiongt sampleGeometricProperty

sampleGeometricProperty = FdoGeometricPropertyDefinitionCre

ate(LSampleGeometricProperty LSample Geometric Property Descrip

tion)

sampleGeometricProperty-gtSetGeometryTypes(FdoGeometricType_Sur

face)

sampleGeometricProperty-gtSetReadOnly(false)

sampleGeometricProperty-gtSetHasMeasure(false)

sampleGeometricProperty-gtSetHasElevation(false)

add the geometric property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleGeometricProperty)

identify it as a geometry property

sampleFeatureClass-gtSetGeometryProperty(sampleGeometricProperty)

add the feature class to the schema

sampleClassCollection-gtAdd(sampleFeatureClass)

point the ApplySchema command at the newly created feature

schema and execute

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

Schema Management Examples | 113

Example Describing a Schema and Writing It to an XML File

The following sample code demonstrates describing a schema and writing itto an XML file

create the DescribeSchema command

FdoPtrltFdoIDescribeSchemagt sampleDescribeSchema

sampleDescribeSchema = (FdoIDescribeSchema )

connection-gtCreateCommand(FdoCommandType_DescribeSchema)

executing the DescribeSchema command returns a feature

schema collection that is the set of feature schema which

reside in the DataStore

FdoPtrltFdoFeatureSchemaCollectiongt sampleFeatureSchemaCollection

sampleFeatureSchemaCollection = sampleDescribeSchema-gtExecute()

find the target feature schema in the collection write it

to an xml file and clear the collection

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleFeatureSchema-gtWriteXml(LSampleFeatureSchemaxml)

sampleFeatureSchemaCollection-gtClear()

Example Destroying a Schema

The following sample code demonstrates destroying a schema

create the DestroySchema command

FdoPtrltFdoIDestroySchemagt sampleDestroySchema

sampleDestroySchema = (FdoIDestroySchema )

connection-gtCreateCommand(FdoCommandType_DestroySchema)

destroy the schema

sampleDestroySchema-gtSetSchemaName(LSampleFeatureSchema)

sampleDestroySchema-gtExecute()

Example Creating a Schema Read In from an XML File

The following sample code demonstrates creating a schema read in from anXML file

sampleFeatureSchemaCollection-gtReadXml(LSampleFeatureSchemaxml)

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

sampleFeatureSchemaCollection-gtClear()

114 | Chapter 7 Schema Management

SampleFeatureSchemaxml

The following sample XML schema is the contents of the file written out bythe WriteXml method belonging to the FdoFeatureSchema class object thatwas created in the preceding sample code

Schema Management Examples | 115

ltxml version=10 encoding=UTF-8 gt

ltxsschema xmlnsxs=httpwwww3org2001XMLSchema

targetNamespace=httpfdo_customerSampleFeatureSchema

xmlnsfdo=httpfdoosgeoorgschema

xmlnsgml=httpwwwopengisnetgml

xmlnsSampleFeatureSchema=httpfdo_customer

SampleFeatureSchema

elementFormDefault=qualified

attributeFormDefault=unqualifiedgt

ltxsannotationgt

ltxsdocumentationgtSample Feature Schema Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsannotationgt

ltxselement name=SampleFeatureClass

type=SampleFeatureSchemaSampleFeatureClassType

abstract=false substitutionGroup=gml_Featuregt

ltxskey name=SampleFeatureClassKeygt

ltxsselector xpath=SampleFeatureClass gt

ltxsfield xpath=SampleIdentityDataProperty gt

ltxskeygt

ltxselementgt

ltxscomplexType name=SampleFeatureClassType

abstract=false

fdogeometryName=SampleGeometricProperty

fdohasMeasure=false

fdohasElevation=false

fdosrsName=SC_0

fdogeometricTypes=surfacegt

ltxsannotationgt

ltxsdocumentationgtSample Feature Class Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsdocumentationgtSample Geometric Property Descrip

tionltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=gmlAbstractFeatureTypegt

ltxssequencegt

ltxselement name=SampleIdentityDataProperty

default=

type=fdoint32gt

ltxsannotationgt

116 | Chapter 7 Schema Management

ltxsdocumentationgt

Sample Identity Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=SampleNameDataProperty

default=gt

ltxsannotationgt

ltxsdocumentationgt

Sample Name Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=xsstringgt

ltxsmaxLength value=64 gt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

Schema Management Examples | 117

118

Data Maintenance

This chapter provides information about using the FDO API to maintain data

Data Maintenance OperationsThe primary operations associated with data maintenance are

Inserting

Updating

Deleting

Transactions

Locking

NOTE Discussion of Transactions and Locking is deferred to a future release of thisdocument

Inserting Values

Preconditions

In a previous chapter we created a feature schema and added a feature class toit The feature class had three properties an integer data property a string dataproperty and a geometric property We applied this feature schema to the datastore We are now ready to create feature data objects which are instances ofthe feature class and insert them into the data store

8

119

Property Values in General

We can now create feature data objects which are instances of the featureclass by defining a set of property values corresponding to the propertiesdefined for the class and then inserting them into the data store

An FDO class correspondends roughly to a table definition in a relationaldatabase and a property of a class corresponds roughly to a column definitionin a table Adding the property values corresponds roughly to adding a rowin the table

The main distinction between a data value or geometry value and a propertyvalue is the order in which they are created A data value or geometry valueobject is created first and is then used to create a property value object Theproperty value object is then added to the value collection object belongingto the Insert command object Then the command is executed

An insert operation consists of the following steps

1 Create the insert command object (type FdoIInsert) this object can bereused for multiple insert operations

2 Point the insert command object at the feature class to which you areadding values (call the SetFeatureClassName(ltclassNamegt) method)

3 From the insert command object obtain a pointer using theGetPropertyValues() method to a value collection object (typeFdoPropertyValueCollection) You will add property values to the insertcommand object by adding values to the collection object

4 Create a data value (type FdoDataValue) or geometry value (typeFdoGeometryValue) object Creating the data value is straightforwardyou pass the string or integer value to a static Create() method Creatingthe geometry value is described in Geometry Property Values on page 121

5 Create a property value (type FdoPropertyValue) object which involvespassing the data value or geometry value object as an argument to a staticCreate() method

6 Add the property value object to the value collection object

7 Execute the Insert command

Data Property Values

A data value object contains data whose type is one of the following

Boolean

120 | Chapter 8 Data Maintenance

Byte

DateTime

Decimal

Double

Int16

Int32

Int64

Single (another floating point type)

String

Binary large object (BLOB)

Character large object (CLOB)

The data value object is added to the data property value object The dataproperty value object is added to the property value collection belonging tothe Insert command

Geometry Property Values

A geometry property value object contains a geometry in the form of a bytearray A geometry can be relatively simple for example a point (a single pairof ordinates) or quite complex for example a polygon (one or more arraysof ordinates) In the latter case a number of geometry objects are created andthen combined together to form the target geometry Finally the targetgeometry is converted to a byte array and incorporated into the geometryproperty value object

Creating a geometry value object consists of the following steps

1 Create a geometry value object (type FdoGeometryValue) using a staticCreate() method

2 Create a geometry factory object (type FdoAgfGeometryFactory) using astatic GetInstance() method This object is used to create the geometryobject or objects which comprise the target geometry

3 Create the required geometry object or objects using the appropriateCreateltgeometrygt method() belonging to the geometry factory object

Inserting Values | 121

4 Use the geometry factory object to convert the target geometry object toa byte array

5 Incorporate the byte array into the geometry property value object

Example Inserting an Integer a String and a Geometry Value

The following sample code shows how to insert an integer a string and ageometry value

122 | Chapter 8 Data Maintenance

create the insert command

FdoPtrltFdoIInsertgt sampleInsert

sampleInsert = (FdoIInsert )

connection-gtCreateCommand(FdoCommandType_Insert)

index returned by the operation which adds a value to the value

collection

FdoInt32 valueCollectionIndex = 0

point the Insert command to the target class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleInsert-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

get the pointer to the value collection used to add properties

to the Insert command

FdoPtrltFdoPropertyValueCollectiongt samplePropertyValues

samplePropertyValues = sampleInsert-gtGetPropertyValues()

create an FdoDataValue for the identity property value

FdoPtrltFdoDataValuegt sampleIdentityDataValue

sampleIdentityDataValue = FdoDataValueCreate(101)

add the FdoDataValue to the identity property value

FdoPtrltFdoPropertyValuegt sampleIdentityPropertyValue

sampleIdentityPropertyValue =

FdoPropertyValueCreate(LSampleIdentityDataProperty

sampleIdentityDataValue)

add the identity property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleIdentityPropertyValue)

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LBlue Lake)

add the FdoDataValue to the name property value

FdoPtrltFdoPropertyValuegt sampleNamePropertyValue

sampleNamePropertyValue =

FdoPropertyValueCreate(LSampleNameDataProperty

sampleNameDataValue)

add the name property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleNamePropertyValue)

create an FdoGeometryValue for the geometry property value

this polygon represents a lake which has an island

the outer shoreline of the lake is defined as a linear ring

the shoreline of the island is defined as a linear ring

the outer shoreline is the external boundary of the polygon

Inserting Values | 123

the island shoreline is an internal linear ring

a polygon geometry can have zero or more internal rings

FdoPtrltFdoGeometryValuegt sampleGeometryValue

sampleGeometryValue = FdoGeometryValueCreate()

create an instance of a geometry factory used to create the

geometry objects

FdoPtrltFdoFgfGeometryFactorygt sampleGeometryFactory

sampleGeometryFactory = FdoFgfGeometryFactoryGetInstance()

define the external boundary of the polygon the shoreline of

Blue Lake

FdoPtrltFdoILinearRinggt exteriorRingBlueLake

FdoInt32 numBlueLakeShorelineOrdinates = 10

double blueLakeExteriorRingOrdinates[] = 520 180 660 230

730 90 480 60 520 180

exteriorRingBlueLake = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numBlueLakeShorelineOrdinates

blueLakeExteriorRingOrdinates)

define the shoreline of Goose Island which is on Blue Lake

this is the sole member of the list of interior rings

FdoPtrltFdoILinearRinggt linearRingGooseIsland

FdoInt32 numGooseIslandShorelineOrdinates = 10

double gooseIslandLinearRingOrdinates[] = 590 180 670 180

670 130 590 130 590 180

linearRingGooseIsland = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numGooseIslandShorelineOrdinates

gooseIslandLinearRingOrdinates)

add the Goose Island linear ring to the list of interior rings

FdoPtrltFdoLinearRingCollectiongt interiorRingsBlueLake

interiorRingsBlueLake = FdoLinearRingCollectionCreate()

interiorRingsBlueLake-gtAdd(linearRingGooseIsland)

create the Blue Lake polygon

FdoPtrltFdoIPolygongt blueLake

blueLake =

sampleGeometryFactory-gtCreatePolygon(exteriorRingBlueLake

interiorRingsBlueLake)

convert the Blue Lake polygon into a byte array

and set the geometry value to this byte array

FdoByteArray geometryByteArray =

sampleGeometryFactory-gtGetAgf(blueLake)

sampleGeometryValue-gtSetGeometry(geometryByteArray)

add the Blue Lake FdoGeometryValue to the geometry property

value

FdoPtrltFdoPropertyValuegt sampleGeometryPropertyValue

124 | Chapter 8 Data Maintenance

sampleGeometryPropertyValue =

FdoPropertyValueCreate(LSampleGeometryProperty

sampleGeometryValue)

add the geometry property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleGeometryPropertyValue)

do the insertion

the command returns an FdoIFeatureReader

FdoPtrltFdoIFeatureReader sampleFeatureReader

sampleFeatureReader = sampleInsert-gtExecute()

Updating Values

After inserting (see Inserting Values on page 119) you can update the valuesThe update operation involves identifying a feature class (ldquotablerdquo) a featureclass object (ldquorowrdquo) and an object property (ldquocolumn in a rowrdquo) to be changedand supplying a new value for the object property to replace the old

First create an FdoIUpdate command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class object whose properties we want to updateand use the command objectrsquos SetFilter() method to attach the command toit Filters are discussed in Filter and Expression Languages on page 139

One of the data properties in the example SampleFeatureClass class definitionis an identity property whose name is ldquoSampleIdentityDataPropertyrdquo andwhose type is fdoInt32 This means that its value uniquely identifies thefeature class object that is the ldquorowrdquo Use the name of the identity propertyin the filter In the Insert operation the value of the identity property was setto be lsquo101rsquo The value of the filter that is needed is ldquo(SampleIdentityDataProperty = 101 )rdquo

Finally create a property value which contains the new value attach it tothe command object and then execute the command

Example Updating Property Values

The following is an example of updating property values

Updating Values | 125

FdoPtrltFdoIUpdategt sampleUpdate

sampleUpdate =

(FdoIUpdate )connection-gtCreateCommand(FdoCommandType_Update)

FdoInt32 numUpdated = 0

point the Update command at the target feature class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleUpdate-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

set the filter to identify which set of properties to update

sampleUpdate-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

get the pointer to the value collection used to add properties

to the Update command

we are reusing the samplePropertyValues object that we used

for the insert operation

samplePropertyValues = sampleUpdate-gtGetPropertyValues()

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LGreen Lake)

set the name and value of the property value

sampleNamePropertyValue-gtSetName(LSampleNameDataProperty)

sampleNamePropertyValue-gtSetValue(sampleNameDataValue)

add the name property value to the property value collection

owned by the Update command

samplePropertyValues-gtAdd(sampleNamePropertyValue)

execute the command

numUpdated = sampleUpdate-gtExecute()

Deleting Values

In addition to inserting (see Inserting Values on page 119) and updating (seeUpdating Values on page 125) values you can delete the values The deletionoperation involves identifying a feature class (ldquotablerdquo) whose feature classobjects (ldquorowsrdquo) are to be deleted

First create an FdoIDelete command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class objects that you want to delete and use thecommand objectrsquos SetFilter() method to attach the filter to it You can use thesame filter that was specified in the preceding section Updating Values onpage 125 Finally execute the command

126 | Chapter 8 Data Maintenance

Example Deleting Property Values

FdoPtrltFdoIDeletegt sampleDelete

sampleDelete =

(FdoIDelete )connection-gtCreateCommand(FdoCommandType_Delete)

FdoInt32 numDeleted = 0

sampleDelete-gt

SetFeatureClassName(LSampleFeatureSchemaSampleFeatureClass)

sampleDelete-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

numDeleted = sampleDelete-gtExecute()

Related Class TopicsThe following classes are used in the preceding Data Maintenance examples

FdoIInsert

FdoPropertyValueCollection

FdoDataValue

FdoPropertyValue

FdoGeometryValue

FdoFgfGeometryFactory

FdoILinearRing

FdoLinearRingCollection

FdoIPolygon

FdoByteArray

FdoIDelete

FdoIUpdate

For more information see FDO API Reference Help

Related Class Topics | 127

128

Performing Queries

This chapter describes how to create and perform queries In the FDO API you can use queriesto retrieve specific features from a data store

Creating a QueryYou create and perform queries using the FdoISelect class which is a memberof the Feature sub-package of the Commands package Queries are used toretrieve features from the data store and are executed against one class at atime The class is specified using the SetFeatureClassName() method inFdoIFeatureCommand The SetFeatureClassName can be used with feature andnon-feature classes

FdoISelect supports the use of filters to limit the scope of features returned bythe command This is done through one of the SetFilter methods available inthe FdoIFeatureCommand class The filter is similar to the SQL WHERE clausewhich specifies the search conditions that are applied to one or more classproperties

Search conditions include spatial and non-spatial conditions Non-spatial queriescreate a condition against a data property such as an integer or string Basiccomparisons (= lt gt gt= lt= =) pattern matching (like) and lsquoInrsquo comparisonscan be specified Spatial queries create a spatial condition against a geometryproperty Spatial conditions are enumerated in FdoSpatialCondition andFdoDistanceCondition

The feature reader (FdoIFeatureReader) is used to retrieve the results of a queryfor feature and non-feature classes To retrieve the features from the readeriterate through the reader using the FdoIFeatureReaderReadNext method()

9

129

Query ExampleIn the Data Maintenance chapter we created an instance of theFdoFeatureClass SampleFeatureClass and assigned values to its integer stringand geometry properties (see Example Inserting an Integer a String and aGeometry Value on page 122) The sample code in the following query exampleselects this instance and retrieves the values of its properties Specifically thesample code does the following

1 Creates the select command and

2 Points the select command at the target FdoFeatureClassSampleFeatureClass and

3 Creates a filter to identify which instance of SampleFeatureClass to selectand

4 Points the select command at the filter and

5 Executes the command which returns an FdoIFeatureReader object and

6 Loops through the feature reader object which contains one or morequery results depending on the filter arguments In the sample codeprovided there is only one result

7 Finally the code extracts the property values from each query result

130 | Chapter 9 Performing Queries

we have one FdoFeatureClass object in the DataStore

create a query that returns this object

create the select command

FdoPtrltFdoISelectgt sampleSelect

sampleSelect = (FdoISelect )

connection-gtCreateCommand(FdoCommandType_Select)

point the select command at the target FdoFeatureClass

SampleFeatureClass

sampleSelect-gtSetFeatureClassName(LSampleFeatureClass)

create the filter by

1 creating an FdoIdentifier object containing the name of

the identity property

FdoPtrltFdoIdentifiergt queryPropertyName

queryPropertyName =

FdoIdentifierCreate(LSampleIdentityDataProperty)

2 creating an FdoDataValue object containing the value of the

identity property

FdoPtrltFdoDataValuegt queryPropertyValue

queryPropertyValue = FdoDataValueCreate(101)

3 calling FdoComparisonConditionCreate() passing in the

the queryPropertyName an enumeration constant signifying an

equals comparison operation and the queryPropertyValue

FdoPtrltFdoFiltergt filter

filter = FdoComparisonConditionCreate(queryPropertyName

FdoComparisonOperations_EqualTo queryPropertyValue)

point the select command at the filter

sampleSelect-gtSetFilter(filter)

execute the select command

FdoPtrltFdoIFeatureReadergt queryResults

queryResults = sampleSelect-gtExecute()

declare variables needed to capture query results

FdoPtrltFdoClassDefinitiongt classDef

FdoPtrltFdoPropertyDefinitionCollectiongt properties

FdoInt32 numProperties = 0

FdoPropertyDefinition propertyDef

FdoPropertyType propertyType

FdoDataType dataType

FdoDataPropertyDefinition dataPropertyDef

FdoString propertyName = NULL

FdoPtrltFdoByteArraygt byteArray

FdoIGeometry geometry = NULL

FdoGeometryType geometryType = FdoGeometryType_None

FdoIPolygon polygon = NULL

Query Example | 131

FdoILinearRing exteriorRing = NULL

FdoILinearRing interiorRing = NULL

FdoIDirectPosition position = NULL

FdoInt32 dimensionality = FdoDimensionality_XY

FdoInt32 numPositions = 0

FdoInt32 numInteriorRings = 0

loop through the query results

while (queryResults-gtReadNext())

get the feature class object and its properties

classDef = queryResults-gtGetClassDefinition()

properties = classDef-gtGetProperties()

loop through the properties

numProperties = properties-gtGetCount()

for(int i = 0 i lt numProperties i++)

propertyDef = properties-gtGetItem(i)

get the property name and property type

propertyName = propertyDef-gtGetName()

propertyType = propertyDef-gtGetPropertyType()

switch (propertyType)

itrsquos a data property

case FdoPropertyType_DataProperty

dataPropertyDef =

dynamic_castltFdoDataPropertyDefinition gt

(propertyDef)

dataType = dataPropertyDef-gtGetDataType()

switch (dataType)

case FdoDataType_Boolean

break

case FdoDataType_Int32

break

case FdoDataType_String

break

default

break

itrsquos a geometric property

convert the byte array to a geometry

and determine the derived type of the geometry

case FdoPropertyType_GeometricProperty

byteArray = queryResults-gtGetGeometry(propertyName)

geometry =

sampleGeometryFactory-gtCreateGeometryFromAgf

(byteArray)

132 | Chapter 9 Performing Queries

geometryType = geometry-gtGetDerivedType()

resolve the derived type into a list of ordinates

switch (geometryType)

case FdoGeometryType_None

break

case FdoGeometryType_Point

break

case FdoGeometryType_LineString

break

case FdoGeometryType_Polygon

polygon = dynamic_castltFdoIPolygon gt(geometry)

exteriorRing = polygon-gtGetExteriorRing()

dimensionality = exteriorRing-

gtGetDimensionality()

numPositions = exteriorRing-gtGetCount()

double X Y Z M

for(int i=0 iltnumPositions i++)

position = exteriorRing-gtGetItem(i)

if (dimensionality amp FdoDimensionality_Z ampamp

dimensionality amp FdoDimensionality_M)

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

M = position-gtGetM()

else if (dimensionality amp FdoDimensionality_Z

ampamp (dimensionality amp FdoDimensionality_M))

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

else

X = position-gtGetX()

Y = position-gtGetY()

numInteriorRings = polygon-

gtGetInteriorRingCount()

for(int i=0 iltnumInteriorRings i++)

interiorRing = polygon-gtGetInteriorRing(i)

do same for interior ring as exterior ring

break

case FdoGeometryType_MultiPoint

break

Query Example | 133

case FdoGeometryType_MultiLineString

break

case FdoGeometryType_MultiPolygon

break

case FdoGeometryType_MultiGeometry

break

case FdoGeometryType_CurveString

break

case FdoGeometryType_CurvePolygon

break

case FdoGeometryType_MultiCurveString

break

case FdoGeometryType_MultiCurvePolygon

break

default

break

default

134 | Chapter 9 Performing Queries

Long TransactionProcessing

This chapter defines long transactions (LT) and long transaction interfaces and explains howto implement LT processing in your application

NOTE For this release the providers that support long transaction processing are AutodeskFDO Provider for Oracle and OSGeo FDO Provider for ArcSDE

What Is Long Transaction ProcessingA long transaction (LT) is an administration unit that is used to groupconditional changes to objects Depending on the situation such a unit cancontain conditional changes to one or to many objects Long transactions areused to modify as-built data in the database without permanently changing theas-built data Long transactions can be used to apply revisions or alternates toan object

A root long transaction is a long transaction that represents permanent dataand that has descendents Any long transaction has a root long transaction asan ancestor in its long transaction dependency graph A leaf long transactiondoes not have descendents

For more information about Oracle-specific long transaction versions andlocking see Locking and Long Transactions

10

135

Supported InterfacesIn the current release of FDO the following long transaction interfaces aresupported

FDOIActivateLongTransaction

FDOIDeactivateLongTransaction

FDOIRollbackLongTransaction

FDOICommitLongTransaction

FDOICreateLongTransaction

FDOIGetLongTransaction

These interfaces are summarized below For more information about theirusage supported methods associated enumerations and readers see the FDOAPI Reference Help

FDOIActivateLongTransaction

The FdoIActivateLongTransaction interface defines theActivateLongTransaction command which activates a long transaction wherefeature manipulation and locking commands operate on it Input to theactivate long transaction command is the long transaction name The Executeoperation activates the identified long transaction

FDOIDeactivateLongTransaction

The FdoIDeactivateLongTransaction interface defines theDeactivateLongTransaction command which deactivates the active longtransaction where feature manipulation and locking commands operate onit If the active long transaction is the root long transaction then no longtransaction will be deactivated

FDOIRollbackLongTransaction

The FdoIRollbackLongTransaction interface defines theRollbackLongTransaction command which allows a user to execute rollbackoperations on a long transaction Two different rollback operations areavailable Full and Partial

136 | Chapter 10 Long Transaction Processing

The operation is executed on all data within a long transaction and on all itsdescendents The data is removed from the database and all versions involvedin the process deleted

NOTE If the currently active long transaction is the same as the one beingcommitted or rolled back then if the commit or rollback succeeds the providerresets the current active long transaction to be the root long transaction If it doesnot succeed the active long transaction is left alone and current If the currentlyactive long transaction is not the same as the one being committed or rolled backthen it is not affected

FDOICommitLongTransaction

The FdoICommitLongTransaction interface defines theCommitLongTransaction command which allows a user to execute commitoperations on a long transaction Two different commit operations areavailable Full and Partial

The commit operation can be performed on a leaf long transaction only Along transaction is a leaf long transaction if it does not have descendents

FDOICreateLongTransaction

The FdoICreateLongTransaction interface defines the CreateLongTransactioncommand which creates a long transaction that is based on the currentlyactive long transaction There is always an active long transaction If the userhas not activated a user-defined long transaction then the root longtransaction is active

Input to the CreateLongTransaction command includes a name and descriptionfor the new long transaction The long transaction name submitted to thecommand has to be unique If it is not unique an exception is thrown

FDOIGetLongTransactions

The FdoIGetLongTransactions interface defines the GetLongTransactionscommand which allows the user to retrieve long transaction information Ifa long transaction name is submitted the command returns the informationfor the named long transaction only If no long transaction name is giventhe command retrieves the names of all available long transactions

For each returned long transaction the user has the option to retrieve a listof descendents andor ancestors

Supported Interfaces | 137

138

Filter and ExpressionLanguages

This chapter discusses the use of filters and filter expressions You can use filters and expressionsto specify to an FDO provider how to identify a subset of the objects in a data store

For more information and implementation details about the expression functions signaturesthe RDBMS-specific built-in support for some of the functions and the provider-specificsupport see the appendix Expression Functions

FiltersFDO uses filters through its commands (including provider-specific commands)to select certain features and exclude others

A filter is a construct that an application specifies to an FDO provider to identifya subset of objects of an FDO data store For example a filter may be used toidentify all Road type features that have 2 lanes and that are within 200 metresof a particular location Many FDO commands use filter parameters to specifythe objects to which the command applies For example a select commandtakes a filter to identify the objects that the application wants to retrieve or adelete command takes a filter to identify the objects that the application wantsto delete from the data store

When a command executes the filter is evaluated for each feature instance andthat instance is included in the scope of the command only if the filter evaluatesto True Filters may be specified either as text or as an expression tree Featureproviders declare their level of support for filters through the filter capabilitiesmetadata Query builders should configure themselves based on the filtercapabilities metadata in order to provide users with a robust user interface Formore information see What Is an Expression on page 19

11

139

ExpressionsFDO uses expressions through its commands (including provider-specificcommands) to specify input values in order to filter features In generalcommands in FDO do not support the SQL command language (the oneexception is the optional SQLCommand) However to facilitate ease of usefor application developers expressions in FDO can be specified using a textualnotation that is based syntactically on expressions and SQL WHERE clausesIn FDO expressions are not intended to work against tables and columns butagainst feature classes properties and relationships For example an expressionto select roads with four or more lanes might look like this

Lanes gt= 4

An expression is a construct that an application can use to build up a filterIn other words an expression is a clause of a filter or larger expression Forexample ldquoLanes gt=4 and PavementType = Asphaltrdquo takes two expressionsand combines them to create a filter

Filter and Expression TextIn general commands in FDO do not support the SQL command language(the one exception is the optional SQLCommand) However to facilitate easeof use for application developers expressions and filters in FDO can be specifiedusing a textual notation that is based syntactically on expressions and SQLWHERE clauses The biggest difference between this approach and SQL is thatthese clauses are not intended to work against tables and columns but againstfeature classes properties and relationships For example a filter to selectroads with four or more lanes might look like

Lanes gt= 4

Similarly a filter to select all PipeNetworks that have at least one Pipe in theproposed state might look like

Pipesstate = proposed

Furthermore a filter to select all existing parcels whose owner contains thetext ldquoSmithrdquo might look like

state = existing and owner like Smith

Finally a filter to select all parcels that are either affected or encroached uponby some change might look like

140 | Chapter 11 Filter and Expression Languages

state in (affected encroached)

Language IssuesThere are a number of language issues to be considered when working withclasses in the Filter Expression and Geometry packages

Provider-specific constraints on text

Filter grammar

Expression grammar

Filter and Expression keywords

Data types

Operators

Special characters

Geometry value

Provider-Specific Constraints on Filter andExpression Text

Some providers may have reserved words that require special rules when usedwith filters and expressions For more information see Oracle Reserved WordsUsed with Filter and Expression Text

Filter Grammar

The rules for entering filter expressions are described in the following sectionsusing BNF notation For more information about BNF notation seehttpcuiunigechdb-researchEnseignementanalyseinfoAboutBNFhtml

The FdoFilterParse() method supports the following filter grammar

Language Issues | 141

ltFiltergt = ( Filter )

| ltLogicalOperatorgt

| ltSearchConditiongt

ltLogicalOperatorgt = ltBinaryLogicalOperatorgt

| ltUnaryLogicalOperatorgt

ltBinaryLogicalOperatorgt =

ltFiltergt ltBinaryLogicalOperationsgt ltFiltergt

ltSearchConditiongt = ltInConditiongt

| ltComparisonConditiongt

| ltGeometricConditiongt

| ltNullConditiongt

ltInConditiongt = ltIdentifiergt IN ( ValueExpressionCollection

)

ltValueExpressionCollectiongt = ltValueExpressiongt

| ltValueExpressionCollectiongt ltValueExpressiongt

ltComparisonConditiongt =

ltExpressiongt ltComparisonOperationsgt ltExpressiongt

ltGeometricConditiongt = ltDistanceConditiongt

| ltSpatialConditiongt

ltDistanceConditiongt =

ltIdentifiergt ltDistanceOperationsgt ltExpressiongt ltdistancegt

ltNullConditiongt = ltIdentifiergt NULL

ltSpatialConditiongt =

ltIdentifiergt ltSpatialOperationsgt ltExpressiongt

ltUnaryLogicalOperatorgt = NOT ltFiltergt

ltBinaryLogicalOperationsgt = AND | OR

ltComparisionOperationsgt =

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

LIKE Like

ltDistanceOperationsgt = BEYOND | WITHINDISTANCE

ltdistancegt = DOUBLE | INTEGER

ltSpatialOperationsgt = CONTAINS | CROSSES | DISJOINT

| EQUALS | INTERSECTS | OVERLAPS | TOUCHES | WITHIN | COVEREDBY |

INSIDE

142 | Chapter 11 Filter and Expression Languages

Expression Grammar

The FdoExpressionParse() method supports the following expression grammar

ltExpressiongt = ( Expression )

| ltUnaryExpressiongt

| ltBinaryExpressiongt

| ltFunctiongt

| ltIdentifiergt

| ltValueExpressiongt

ltBinaryExpressiongt =

ltExpressiongt + ltExpressiongt

| ltExpressiongt - ltExpressiongt

| ltExpressiongt ltExpressiongt

| ltExpressiongt ltExpressiongt

ltDataValuegt =

TRUE

| FALSE

| DATETIME

| DOUBLE

| INTEGER

| STRING

| BLOB

| CLOB

| NULL

ltFunctiongt = ltIdentifiergt ( ltExpressionCollectiongt )

ltExpressionCollectiongt =

| ltExpressiongt

| ltExpressionCollectiongt ltExpressiongt

ltGeometryValuegt = GEOMFROMTEXT ( STRING )

ltIdentifiergt = IDENTIFIER

ltValueExpressiongt = ltLiteralValuegt | ltParametergt

ltLiteralValuegt = ltGeometryValuegt | ltDataValuegt

ltParametergt = PARAMETER | STRING

ltUnaryExpressiongt = - ltExpressiongt

Expression Operator Precedence

The precedence is shown in YACC notation that is the highest precedenceoperators are at the bottom

left Add Subtract

left Multiply Divide

left Negate

Expression Grammar | 143

Filter and Expression Keywords

The following case-insensitive keywords are reserved in the language that isthey cannot be used as identifier or function names

AND BEYOND COMPARE CONTAINS COVEREDBY CROSSES DATE

DISJOINT DISTANCE EQUALS FALSE GeomFromText IN INSIDE

INTERSECTS LIKE NOT NULL OR OVERLAPS RELATE SPATIAL TIME

TIMESTAMP TOUCHES TRUE WITHIN WITHINDISTANCE

Data Types

The available data types are described in this section

Identifier

An identifier can be any alphanumeric sequence of characters other than akeyword Identifiers can be enclosed in double quotes to allow specialcharacters and white space If you need to include a double quote characterinside an identifier double the character for example abcdef

Parameter

Parameters are defined by a colon followed by alphanumeric characters TheFDO filter language extends SQL to allow for a literal string to follow the colonto allow blanks (and other possibilities) for example Enter Name

Determine whether parameters are supported by the FDO Provider you areusing by checking SupportParameters on the Connection interface

String

Strings are literal constants enclosed in single quotes The FDO filter languagealso supports the special characters (left and right single quotes) that MicrosoftWord uses to automatically replace the single quote character typed from thekeyboard If you need to include a single quote character inside a string youcan double the character for example aaabbb

144 | Chapter 11 Filter and Expression Languages

Integer

Integers allow only decimal characters with an optional unary minus signUnary plus is not supported

(-)[0-9]

Double

Floating point numbers have a decimal point can be signed (-) and includean optional exponent (e[0-9])

NOTE If an integer is out of the 32-bit precision range it is converted to floatingpoint

Examples

-34

12345678901234567

12e13

DateTime

Date and time are parsed using the standard SQL literal strings

DATE YYYY-MM-DD

TIME HHMMSS[sss]

TIMESTAMP YYYY-MM-DD HHMMSS[sss]

For example

DATE 1971-12-24

TIMESTAMP 2003-10-23 110002

NOTE The BLOB and CLOB strings are currently not supported If you need tosupport binary input use parameters

Data Types | 145

Operators

The following operators are special characters common to SQL and mostprogramming languages

BinaryOperations

These binary operations are available

+ Add (for compatibility with SQL string concatenation may also be definedusing ldquo||rdquo)

- Subtract

Multiply

Divide

UnaryOperations

These unary operation are available

- Negate

Comparison Operations

These comparison operations are available

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

Operator Precedence

The following precedence is shown from highest to lowest

Negate NOT

Multiply Divide

Add Subtract

146 | Chapter 11 Filter and Expression Languages

EQ NE GT GE LT LE

AND

OR

Special Character

The following special characters are used in ExpressionCollections andValueExpressions to define function arguments and IN conditions

( Left Parenthesis

Comma

) Right Parenthesis

The Colon () is used in defining parameters and the Dot () can be includedin real numbers and identifiers

Geometry Value

Geometry values are handled using a function call GeomFromText(FGF Textstring) as is typical in an SQL query

The Autodesk extension to WKT referred to as FGF Text is a superset of WKT(that is you can enter WKT as valid FGF Text strings) Dimensionality isoptional It can be XY XYM XYZ or XYZM If it is not specified it is assumedto be XY For more information about FGF Text see FGF Text on page 158

NOTE Extra ordinates are ignored rather than generating an error during FGFtext parsing For example in the string ldquoPOINT (10 11 12)rdquo the lsquo12rsquo is ignoredbecause the dimensionality is assumed to be XY

The following is the grammar definition for FGF Text

ltFGF Textgt = POINT ltDimensionalitygt ltPointEntitygt

| LINESTRING ltDimensionalitygt ltLineStringgt

| POLYGON ltDimensionalitygt ltPolygongt

| CURVESTRING ltDimensionalitygt ltCurveStringgt

| CURVEPOLYGON ltDimensionalitygt ltCurvePolygongt

| MULTIPOINT ltDimensionalitygt ltMultiPointgt

Special Character | 147

| MULTILINESTRING ltDimensionalitygt ltMultiLineStringgt

| MULTIPOLYGON ltDimensionalitygt ltMultiPolygongt

| MULTICURVESTRING ltDimensionalitygt ltMultiCurveStringgt

| MULTICURVEPOLYGON ltDimensionalitygt ltMultiCurvePolygongt

| GEOMETRYCOLLECTION ltGeometryCollectiongt

ltPointEntitygt = ( ltPointgt )

ltLineStringgt = ( ltPointCollectiongt )

ltPolygongt = ( ltLineStringCollectiongt )

ltMultiPointgt = ( ltPointCollectiongt )

ltMultiLineStringgt = ( ltLineStringCollectiongt )

ltMultiPolygongt = ( ltPolygonCollectiongt )

ltGeometryCollection ( ltFGF Collection Textgt )

ltCurveStringgt = ( ltPointgt ( ltCurveSegmentCollectiongt ) )

ltCurvePolygongt = ( ltCurveStringCollectiongt )

ltMultiCurveStringgt = ( ltCurveStringCollectiongt )

ltMultiCurvePolygongt = ( ltCurvePolygonCollectiongt )

ltDimensionalitygt = default to XY

| XY

| XYZ

| XYM

| XYZM

ltPointgt = DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE DOUBLE

ltPointCollectiongt = ltPointgt

| ltPointCollection ltPointgt

ltLineStringCollectiongt = ltLineStringgt

| ltLineStringCollectiongt ltLineStringgt

ltPolygonCollectiongt = ltPolygongt

148 | Chapter 11 Filter and Expression Languages

| ltPolygonCollectiongt ltPolygongt

ltFGF Collection Textgt = ltFGF Textgt

| ltFGF Collection Textgt ltFGF Textgt

ltCurveSegmentgt = CIRCULARARCSEGMENT ( ltPointgt ltPointgt )

| LINESTRINGSEGMENT ( ltPointCollectiongt )

ltCurveSegmentCollectiongt = ltCurveSegmentgt

| ltCurveSegmentCollectiongt ltCurveSegmentgt

ltCurveStringCollectiongt = ltCurveStringgt

| ltCurveStringCollectiongt ltCurveStringgt

ltCurvePolygonCollectiongt = ltCurvePolygongt

| ltCurvePolygonCollectiongt ltCurvePolygongt

The only other token type is DOUBLE representing a double precision floatingpoint values Integer (non-decimal point) input is converted to DOUBLE inthe lexical analyzer

Examples of the Autodesk extensions include

POINT XY (10 11) equivalent to POINT (10 11)

POINT XYZ (10 11 12)

POINT XYM (10 11 12)

POINT XYZM (10 11 12 12)

GEOMETRYCOLLECTION (POINT xyz (10 11 12)POINT XYM (30 20 18)LINESTRING XYZM(1 2 3 4 3 5 15 3 20 20))

CURVESTRING (0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40))))

CURVESTRING (0 0 (CIRCULARARCSEGMENT (11 11 12 12)LINESTRINGSEGMENT (10 10 20 20 30 40)))

CURVESTRING (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 30 40)))

CURVESTRING XYZ (0 0 0 (LINESTRINGSEGMENT (10 10 1 20 20 1 30 401)))

MULTICURVESTRING ((0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40)))(00 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 20 20 30 40))))

Geometry Value | 149

CURVEPOLYGON ((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20) ARC(20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 40 40 90 90))))

MULTICURVEPOLYGON (((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90))))((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90)))))

150 | Chapter 11 Filter and Expression Languages

The Geometry API

This chapter describes the FdoGeometry API (hereafter called the ldquoGeometry APIrdquo) and explainsthe various geometry types and formats

IntroductionThe Geometry API supports specific Autodesk applications and APIs includingFDO (Feature Data Objects) This API consists of the following components

a Geometry Type package (all through fully encapsulated interfaces)

an Abstract Geometry Factory

a Concrete Geometry Factory for FGF

You can work with the Geometry API in several different ways

FGF (Feature Geometry Format)

FGF Text

Abstract Geometry Factory

FGF and WKBWKB is a memory layout used to store geometry features This format was createdby the OpenGIS organization to allow the efficient exchange of geometry databetween different components in an FDO system Most pieces of the originalspecification defining the WKB format are in the document 99-050pdf theOpenGIS Simple feature specification for OLECOM that can be found atwwwopengisorg

12

151

FGF is an extended version of the Well Known Binary (WKB) format The twoformats differ in the following ways

WKB defines a byte order of the data in every piece of geometry This isstored as a byte field which may change the memory alignment fromword to byte In FGF only one memory alignment type is supported whichis the same alignment type used by the NET framework and Windowsthe encoding uses the little-endian byte order format As a result the byteflag does not need to be stored

WKB is defined as a 2D format only This is insufficient to represent 3Dpoints polylines and polygons In FGF the dimension flag has been addedIn particular a flag is included for each geometry piece to indicate whetherthe geometry is 2D 3D or even 4D (storing a measure value as used bydynamic segmentation

FGF includes geometry types that are not yet covered by any WKBspecification

FGF Binary SpecificationIn this section the memory layout of each simple geometry type is describedThe format is based on the OGC specification which is built on the memorylayout of a C++ struct All arrays have a computable size and are inline theydo not point to a different location in memory This format allows streamingof geometry data

First the different data types their size and memory layout are discussed

152 | Chapter 12 The Geometry API

double == 8byte IEEE double number in little endian encoding

int == 4 byte integer in little endian encoding

the type of the geometry

enum GeometryType int

None = 0

Point = 1

LineString = 2

Polygon = 3

MultiPoint = 4

MultiLineString = 5

MultiPolygon = 6

MultiGeometry = 7

CurveString = 10

CurvePolygon = 11

MultiCurveString = 12

MultiCurvePolygon = 13

Coordinate Types

This is a bit field for example xym == coordinateDimensionalityXY |CoordinateDimensionalityM The following sequence defines the type ofcoordinates used for this object

enum CoordinateDimensionality FdoInt32

XY = 0

Z = 1

M = 2

Basic Geometry

The following sequence establishes the basic pure geometry

struct Geometry

int geomType

CoordinateDimensionality type

FGF Binary Specification | 153

Notation Definition

The following sequence defines a notation used to specify geometries withina byte stream

154 | Chapter 12 The Geometry API

Define a notation within this specification

int PositionSize(geometry)

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM ||

geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityZ)

return 3

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM | CoordinateDimensionalityZ)

return 4

return 2

struct Point Geometry

int geomType == GeometryTypePoint

CoordinateDimensionality type all types allowed

double[] coords size = PositionSize(this)

struct LineString

int geomType

CoordinateDimensionality type

int numPts gt0

double[] coords size = numPts PositionSize(this)

struct MultiPoint

int geomType

int numPoints gt 0

Point[] points size = numPoints

struct MultiLineString

int geomType

int numLineStrings gt= 0

LineString[] lineStrings size = numLineStrings

building block for polygons not geometry by itself

struct LinearRing

int numPts gt0

double[] coords size = numPts PositionSize(polygon)

FGF Binary Specification | 155

struct Polygon

int geomType

CoordinateDimensionality type

int numRings gt= 1 as there has to be at least one ring

LinearRing[] lineStrings size = numRings

struct MultiPolygon

int geomType

int numPolygons gt= 0

Polygon[] polygons size = numPolygons

struct MultiGeometry

int geomType

int numGeom gt= 0

Geometry[] geometry size = numGeom

enum CurveElementType int

LineString = 1

CircularArc = 2

struct CurveStringElement

int CurveElementType

struct LinearCurveStringElement

int CurveElementType

int length

double[] coords size = thislength PositionSize (this)

struct CircularArcCurveStringElement

int CurveElementType == CurveElmentTypeArc

double[] coords size = 2 PositionSize(this)

struct CurveString

int geomType

156 | Chapter 12 The Geometry API

CoordinateDimensionality type all types allowed

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct Ring

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct MultiCurveString

int geomType

int numCurveStrings gt= 0

CurveString[] curveStrings size = numCurveStrings

struct CurvePolygon

int geomType

CoordinateDimensionality type

int numRings gt=1 as there has to be at least one ring

Ring[] rings size = numRings

struct MultiCurvePolygon

int geomType

int numPolygons gt=0

CurvePolygon[] polygons size = numElements

In the following example a polygon is formatted within a byte arrayrepresenting the stream according to the FGF specification

FGF Binary Specification | 157

T = 3 stands for GeometryType == GeometryTypePolygon

CT = 0 stands for CoordinateDimensionality == CoordinateDimensionalityXY

NR = 2 stands for number of rings = 2

NP =3 stands for number of points = 3

FGF TextFGF Text is the textual analogue to the binary FGF format It is a superset ofthe OGC WKT format XY dimensionality is the default and is optional FGFText can be used to represent any geometry value in the Geometry API whetheror not it originates from the FGF geometry factory Conversions are done withthe following methods

FdoGeometryFactoryAbstract CreateGeometry(FdoString text)

FdoIGeometry GetText()rdquo

A BNF for the FGF textual specification is contained in the topic GeometryValue on page 147

Abstract and Concrete ClassesThe Geometry API is almost completely abstract It provides an object-orientedinterface to geometry values All objects in the Geometry API have factorymethods in the FdoGeometryFactorytAbstract class One defaultimplementation is provided based on FGF in-memory binary storage It isaccessible via the concrete class FdoFgfGeometryFactory

NOTE The FdoFgfGeometryFactory employes object pooling for many of the datatypes in the API While many methods appear to be executing ldquoCreaterdquo or ldquoGetrdquoactions they are in fact accessing object pools thus avoiding costly operationson the memory heap

All of the other classes in the Geometry API with the exception of two relateto the main abstract type FdoIGeometry They either derive from it or arecomponents of it

158 | Chapter 12 The Geometry API

The two exception concrete classes are

FdoDirectPositionImpl a small helper class implementingFdoIDirectPosition

FdoEnvelopeImpl a small helper class implementing FdoIEnvelope

Geometries in FGF format can be exchanged between software componentswithout depending on the Geometry API itself because they are not genuinegeometry ldquoobjectsrdquo FGF content is based on byte arrays It is handled througha simple FdoByteArray class that is not specific to geometry

Geometry TypesThe Geometry types comprise the Global Enum FdoGeometryType Thefollowing are Geometry types

0 FdoGeometryType_None Indicates no specific type used for ldquounknownrdquoldquodo not carerdquo or an incompletely constructed Geometry object

NOTE FdoGeometryType_ None does not represent an instantiable type An FDOclient should not expect an FDO provider to list support for it in its capabilities

1 FdoGeometryType_Point Point type (FdoIPoint)

2 FdoGeometryType_LineString LineString type (FdoILineString)

3 FdoGeometryType_Polygon Polygon type (FdoIPolygon)

4 FdoGeometryType_MultiPoint MultiPoint type (FdoIMultiPoint)

5 FdoGeometryType_MultiLineString MultiLineString type(FdoIMultiLineString)

6 FdoGeometryType_MultiPolygon MultiPolygon type (FdoIMultiPolygon)

7 FdoGeometryType_MultiGeometry MultiGeometry type(FdoIMultiGeometry)

10 FdoGeometryType_CurveString CurveString type (FdoICurveString)

11 FdoGeometryType_CurvePolygon CurvePolygon type(FdoICurvePolygon)

Geometry Types | 159

12 FdoGeometryType_MultiCurveString MultiCurveString type(FdoIMultiCurveString)

13 FdoGeometryType_MultiCurvePolygon MultiCurvePolygon type(FdoIMultiCurvePolygon

Mapping Between Geometry and GeometricTypes

The FDO API GeometricType enumeration of GeometricProperty gives theclient application some knowledge of which geometry types comprise thegeometric property so that it can present the user with an intelligent editorfor selecting styles for rendering the geometry In particular GeometricTyperelates to shape dimensionality of geometries allowed in FDO geometricproperties The nearest analogues in the Geometry API are

FdoDimensionality which pertains to ordinate (not shape) dimensionalityof geometry values

FdoGeometryType which has types whose abstract base types map toGeometric Type

The GeometricType enumeration is as follows

Point = 0x01 Point Type Geometry

Curve = 0x02 Line and Curve Type Geometry

Surface = 0x04 Surface (or Area) Type Geometry

Solid = 0x08 Solid Type Geometry

NOTE The enumeration defines a bit mask and the GetGeometricTypes andSetGeometricTypes methods take and return an integer This is to allow a geometryproperty to be of more than one type For example the callgeometricPropertySetGeometricTypes(Point | Surface)

would allow the geometric property to represent either point type geometry orsurface type geometry (polygons)

160 | Chapter 12 The Geometry API

Spatial ContextSpatial Context is a coordinate system with an identity Any geometries thatare to be spatially related must be in a common spatial context

Providing an identify for each coordinate system supports separate workspacessuch as schematic diagrams which are non-georeferenced However thereare also georeferenced cases In general two users may create drawings usingthe same default spatial parameters (for example rectangular and10000x10000) that have nothing to do with each other If their drawingsare to be put into a common database the spatial context capability of FDOpreserves the container aspect of the data along wih the spatial parameters

The FDO Spatial Context Commands are part of the FDO API They supportcontrol over Spatial Contexts in the following ways

Metadata control Creates and deletes Spatial Contexts

Active Spatial Context A session setting to specify which Spatial Contextto use by default while storingretrieving geometries and performing spatialqueries

There is a default Spatial Context for each database Its attributes (such ascoordinate system) are specified when the database is created This SpatialContext is the active one in any FDO session until a Spatial Context Commandis used to change this state The default Spatial Contextrsquos identifier numberis 0 (zero)

Spatial contexts have two tolerance attributes XYTolerance and ZToleranceThe tolerances are in distance units that depend on the coordinate system inuse Geodetic coordinate systems typically have ldquoon the groundrdquo linear distanceunits instead of the angular (that is degrees minutes or seconds) units usedfor positional ordinates The meter is the most common unit Mostnon-geodetic systems are rectilinear and use the same unit for positionalordinates and distances for example meters or feet

Specify Dimensionality When CreatingGeometries Using String Specifications

When creating a 3D geometry from string specifications you must specify theDimensionality argument XYZ explicitly because the default dimensionalityis XY and the geometry factory code will only process the first two ordinates

Spatial Context | 161

The following code successfully creates pointOne as a 3D point whereaspointTwo is created as a 2D point

FdoFgfGeometryFactory geometryFactory = FdoFgfGeometryFact

oryGetInstance()

FdoIPoint pointOne

pointOne = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT XYZ (1 2 3)rsquo)rdquo))

FdoPoint pointTwo

pointTwo = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT (1 2 3)rsquo)rdquo))

xmlFeatureFlags = FdoXmlFeatureFlagsCreate( None FdoXmlFlagsEr

rorLevel_Normal True FdoXmlFeatureFlagsConflictOption_Add )

Inserting Geometry ValuesFor information about geometry property values see Geometry Property Valueson page 121

See Example Inserting an Integer a String and a Geometry Value on page122 for a code example that shows how to insert a Geometry value

162 | Chapter 12 The Geometry API

FDO Cookbook

IntroductionThis chapter contains code samples of common operations

Some operations like connection must discuss differences among providersReferences are made to both Autodesk proprietary providers and open sourceproviders Providers whose name begins with ldquoAutodeskrdquo are available only incommercial releases of Autodesk products Providers whose name begins withldquoOSGeordquo are available in releases of open source software at httpfdoosgeoorgSome of the open source providers are also available in commercial releases ofAutodesk products

Recommendations

After iterating through readers such IFeatureReader IDataReaderISQLDataReader or DbUserReader call the Close() or Dispose() method Notdoing so may cause unhandled exceptions at some future time Be sure toenclose the statement that returns a reader in a try block so that you canclose the reader in the catch block

RegistryThe registry contains the list of providers that are available in a particular FDOinstallation FDO initializes the registry using the contents of the providersxmlfile that is co-located with the FDO binaries

13

163

The FeatureProviderRegistryFeatureProviderName elements in theprovidersxml file contain fully qualified provider names A fully qualifiedprovider name has four parts which are separated by dot (lsquorsquo) characters Theparts areltdomaingtltshortNamegtltmajorReleaseNumbergtltminorReleaseNumbergtThere are two domains Autodesk and OSGeo The former indicates proprietaryand the latter open source software

Use Cases

Get a fully qualified provider name in order to create a a connection Thefully qualified name contains version numbers so having a dictionary thatmaps generic provider names to the currently loaded fully qualified nameis useful

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager andProviderCollection

OSGeoFDO for IProviderRegistry

IProviderRegistry registry = FeatureAccessManagerGetProviderRe

gistry()

ProviderCollection providers = registryGetProviders()

Map provider short name to fully qualified name

Dictionaryltstring stringgt providerAbbrToFullName = new Diction

aryltstring stringgt()

string shortName = null

foreach (Provider provider in providers)

shortName = providerNameSplit()[1]

providerAbbrToFullName[shortName] = providerName

ConnectionThe connection object contains a connection string property that containsthe connection parameter names and values The connection string propertycan be set by using a connection property dictionary or by assigning a

164 | Chapter 13 FDO Cookbook

connection string directly to it The property dictionaryrsquos methods tell youthe names of the connection parameters their current values and theiroptionality

Some parameters must always be set for a connection to succeed for examplethe OSGeoSDF File parameter and the AutodeskOracle Username Passwordand Service parameters Some parameters need not be set if you accept thedefault value For example the SDF ReadOnly parameter has a default settingof false The Oracle DataStore parameter need not be set if your objective isto obtain the names of the available data stores within the data source In thiscase connecting with Username Password and Service parameters results ina pending connection You can then query the DataStore parameter to getthe list of available data stores set the DataStore parameter to the value ofone of the list members and open the connection again but this time to afully operational state If you already know the name of the data store thatyou want you can set its value at the outset and open the connection fullywithout the intervening step

The following table sets out the names of the connection parameters for eachprovider

Connection ParametersProvider

Username Password Service DataStoreAutodeskOracle

DefaultRasterFileLocationAutodeskRaster

Username Password Service DataStoreAutodeskSqlServer

Server Instance Username Password DatastoreOsGeoArcSDE

DefaultRasterFileLocationOSGeoGdal

Username Password Service OracleSchema KingFdoClassOSGeoKingOracle

Username Password Service DataStoreOSGeoMySQL

UserId Password DataSourceName ConnectionStringGenerateDefaultGeometryProperty

OSGeoODBC

DataSource ReadOnlyOSGeoOGR

Connection | 165

Connection ParametersProvider

Username Password Service DataStoreOSGeoPostGIS

File ReadOnlyOSGeoSDF

DefaultFileLocationOSGeoSHP

Username Password Service DataStoreOSGeoSQLServerSpatial

FeatureServer Username PasswordOSGeoWFS

FeatureServer Username Password DefaultImageHeightOSGeoWMS

Use Cases

Create a connection to get the provider capabilities See the Capabilitieson page 168 topic

Get a list of the connection parameters

Determine the optionality of a parameter

Set the value of a parameter

Open and close connections

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager

OSGeoFDO for IConnectionManager

OSGeoFDOConnections for IConnectionImp IConnectionInfoIConnectionPropertyDictionary ConnectionState

Create a Connection

The connection is created in the closed state

166 | Chapter 13 FDO Cookbook

IConnectionManager connMgr = FeatureAccessManagerGetConnectionMan

ager()

string fullName = providerAbbrToFullName[ldquoOraclerdquo]

IConnectionImp conn = connMgrCreateConnection(fullName) as ICon

nectionImp

Determine the Names of the Parameters

Before a connection can be opened the connection parameters must beidentified and given values You can query a connection to identify theseparameters The code block shows the retrieval of the connection parameternames into a string array

IConnectionInfo connInfo = connectionConnectionInfo

IConnectionPropertyDictionary properties = connInfoConnectionProp

erties

string[] names = propertiesPropertyNames

Determine the Optionality of a Parameter

The code block shows determining the optionality of the first connectionparameter

Boolean isRequired = propertiesIsPropertyRequired(names[0])

Set a Parameter

The code block shows the setting of the Username parameter

propertiesSetProperty(ldquoUsernamerdquo ldquoEXISTINGUSERrdquo)

Get the Connection String

The code block shows getting the connection string value from the connection

string connectionString = connectionConnectionString

Open and Close a Connection

The code block shows opening and closing a connection Valid connectionstates are Busy Closed Open and Pending

ConnectionState connState = connectionOpen()

ConnectionState connState = connectionClose()

Connection | 167

CapabilitiesThe following code samples are a representative listing of the capabilitymethods in each category For a complete listing consult the API referencedocumentation

The capabilities for a provider are statically defined You create a connectionobject for the provider and use this object to query the capabilities Theconnection does not have to be open

Some capabilities are defined as booleans for example support for theDISTINCT operator in a SQL SELECT statement Sample code for this is shownin the Command section Some capabilities are defined by arrays of enumeratedtype values for example the feature commands The presence of the capabilityis determined by testing each value in the array for its equality with one ofthe values in the enumerated type range sample code that tests for thepresence of the create data store command is shown in the Command section

The schema capabilities include a string type that defines the characters thatmay not appear in a schema name and two integer types that define themaximum decimal precision and scale

Use Cases

Get the capabilities of a provider

Write code that executes if the provider currently in use supports it

C

The following namespaces and types are used

OSGeoFDOCommands for CommandType

OSGeoFDOCommandsLocking for LockType

OSGeoFDOCommandsSpatialContext for SpatialContextExtentType

OSGeoFDOCommon for GeometryComponentType GeometryType

OSGeoFDOConnectionsCapabilities for ICommandCapabiltiesIConnectionCapabilities IExpressionCapabilities IFilterCapabilitiesIGeometryCapabilities IRasterCapabilities ISchemaCapabilitiesFunctionDefinitionCollection FunctionDefinitionReadOnlySignatureDefinitionCollection SignatureDefinition

168 | Chapter 13 FDO Cookbook

ReadOnlyArgumentDefinitionCollection ArgumentDefinitionThreadCapability

OSGeoFDOExpression for ExpressionType

OSGeoFDOFilter for ConditionType DistanceOperationsSpatialOperations

OSGeoFDOSchema for ClassType DataType PropertyType

Command

ICommandCapabilities cmdCapabilities = connCommandCapabilities

int[] commands = cmdCapabilitiesCommands

Boolean supportsSelectDistinct = cmdCapabilitiesSupportsSelectDis

tinct()

CommandType cmdType = (CommandType)commands[0]

Boolean supportsCreateDataStore = false

for (int i = 0 i lt commandsGetLength(0) i++)

if (commands[i] == (int)CommandTypeCommandType_CreateDataStore)

supportsCreateDataStore = true

Connection

IConnectionCapabilities connCapabilities = connConnectionCapabil

ities

LockType[] lockTypes = connCapabilitiesLockTypes

SpatialContextExtentType[] spatialContextExtentTypes = connCapab

ilitiesSpatialContextTypes

ThreadCapability threadCapability = connCapabilitiesThreadCapab

ility

Boolean supportsConfiguration = connCapabilitiesSupportsConfigur

ation()

Capabilities | 169

Expression

IExpressionCapabilities exprCapabilities = connectionExpression

Capabilities

ExpressionType[] expressionTypes = exprCapabilitiesExpression

Types

FunctionDefinitionCollection functions = exprCapabilitiesFunc

tions

FunctionDefinition function = functions[0]

ReadOnlySignatureDefinitionCollection signatureDefs = functionSig

natures

SignatureDefinition signatureDef = signatureDefs[0]

PropertyType returnPropertyType = signatureDefReturnPropertyType

if (returnPropertyType == PropertyTypePropertyType_DataProperty)

DataType returnDataType = signatureDefReturnType

ReadOnlyArgumentDefinitionCollection arguments = signatureDefAr

guments

ArgumentDefinition argDef = arguments[0]

PropertyType argPropertyType = argDefPropertyType

if (argPropertyType == PropertyTypePropertyType_DataProperty)

DataType argDataType = argDefDataType

Filter

IFilterCapabilities filterCapabilities = connFilterCapabilities

Boolean supportsGeodesicDistance = filterCapabilitiesSupports

GeodesicDistance()

ConditionType[] conditionTypes = filterCapabilitiesConditionTypes

DistanceOperations[] distanceOperations = filterCapabilitiesDis

tanceOperations

SpatialOperations[] spatialOperations = filterCapabilitiesSpatia

lOperations

170 | Chapter 13 FDO Cookbook

Geometry

IGeometryCapabilities geometryCapabilities = connGeometryCapabil

ities

GeometryType[] geometryTypes = geometryCapabilitiesGeometryTypes

GeometryComponentType[] geometryComponentTypes = geometryCapabil

itiesGeometryComponentTypes

int dimensionalities = geometryCapabilitiesDimensionalities

Boolean HasZ = (dimensionalities amp 1) == 1

Boolean HasM = (dimensionalities amp 2) == 2

NOTE The dimensionalities integer contains bit-field definitions XY is 0 becauseall spatial data has at least an X and Y coordinate Z is 1 and M is 2 Use bitwiseAND (amp) to combine and bitwise OR (|) to separate

Raster

IRasterCapabilities rasterCapabilities = connRasterCapabilities

Boolean supportsRaster = rasterCapabilitiesSupportsRaster()

Schema

ISchemaCapabilities schemaCapabilities = connSchemaCapabilities

DataType[] dataTypes = schemaCapabilitiesDataTypes

ClassType[] classTypes = schemaCapabilitiesClassTypes

string reservedCharactersForName = schemaCapabilitiesReservedChar

actersForName

int maximumDecimalPrecision = schemaCapabilitiesMaximumDecimalPre

cision

DataType[] supportedAutoGeneratedTypes = schemaCapabilitiesSuppor

tedAutoGeneratedTypes

DataType[] supportedIdentityPropertyTypes = schemaCapabilitiesSup

portedIdentityPropertyTypes

Boolean supportsAutoIdGeneration = schemaCapabilitiesSupportsAut

oIdGeneration

Data StoreThe Sql Server SQL Server Spatial Oracle MySQL PostGIS and SDF providerssupport the following data store commands create destroy and with theexception of SDF list SDF is a file-based provider and the rest areRDBMS-based

Data Store | 171

By default the Sql Server Oracle MySQL and SDF providers create data storesthat contain FDO metadata By default the SQL Server Spatial provider createsa data store that does not contain the FDO metadata To make this providercreate a data store that does contain the FDO metadata you must set theIDataStorePropertyDictionary property IsFdoEnabled to true The PostGISprovider creates a data store without the FDO metadata

A provider uses the FDO metadata to

Assign a default spatial context to a Geometric Property Definition duringschema creation

When connected to the SDF Provider the CreateDataStore command createsan SDF file and the DestroyDataStore command deletes it There cannot bemultiple data stores in an SDF file and so there is no need for the list commandUnlike the RDBMS-based providers you do not have to open a pendingconnection in order to create and execute the CreateDataStore commandBefore executing the DestroyDataStore command close the connection

For the RDBMS-based providers creating a data store means creating a containerwithin a database There can be many data stores within a database and thelist command lists them

To create a data store in one of these RDBMS-based providers you open apending connection using an administrator account name and password andthen execute the CreateDataStore command Once you have created the datastore you close the administrator connection and open a normal userconnection This time you give a value to the DataStore connection parameterand open the connection to a fully operational state Before executing theDestroyDataStore command close the connection unset the DataStoreconnection parameter and reopen it using the administrator account nameand password in the pending state

C

The following namespaces are used

OSGeoFDOCommandsDataStore

OSGeoFDOCommands

172 | Chapter 13 FDO Cookbook

ICreateDataStore createDS = connCreateCommand(CommandTypeCom

mandType_CreateDataStore) as ICreateDataStore

IDataStorePropertyDictionary properties = createDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

createDSExecute()

IListDataStores listDS = connCreateCommand(CommandTypeCommand

Type_ListDataStores) as IListDataStores

IDataStoreReader reader = listDSExecute()

IDestroyDataStore destroyDS = connCreateCommand(CommandTypeCom

mandType_DestroyDataStore) as IDestroyDataStore

IDataStorePropertyDictionary properties = destroyDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

destroyDSExecute()

User ManagementThe providers may be categorized into five groups with respect to usermanagement The grouping criteria is the method used to create the username

The first group consists of the AutodeskOracle provider which has access toan FDO API for user management

The second group consists of MySQL SqlServer and SQLServerSpatial Theseproviders support the SQLCommand which can be used to create users

The third group consists of ODBC A username and password may be quiredto connect depending on the back-end data store On XP you use the ODBCData Source Administrator tool to configure the username

The third group consists of the web server providers WFS and WMS Ausername and password may be required depending on the site

The fourth group consists of the file-based providers which do not require ausername and password

The FDO User Management API

The AutodeskOracle provider has access to an FDO API for user managementBefore you can add a user you must have added the f_user_role to the databaseas described in the Preparations topic at the beginning of this chapter Duringthe add user operation the f_user_role is assigned to the new user You must

User Management | 173

open a pending connection using an administrator account name and passwordto add or drop a user

C

The AutodeskFdoFdoUtilitiesUserMgr namespace is used

IUserManagerImp userMgr = new IUserManagerImp(connection)

userMgrAddUser(AUserName APassword)

DbUserReader reader = userMgrGetDbUsers()

userMgrDropUser(AUserName)

The SQLCommand Method for User Management

List usersDrop a userAdd a userProvider

SELECT user FROM mysqluserWHERE user = lsquoAUserNamersquo

DROP USER lsquoAUser-Namersquo

CREATE USER lsquoAUserNamersquoIDENTIFIED BY lsquoAPasswordrsquo

MySQL

GRANT ALL ON TO lsquoAUs-erNamersquo

SELECT name FROM sysserv-er_principals WHERE name =lsquoAUserNamersquo

EXEC sp_droploginloginame = lsquoAUser-Namersquo

CREATE LOGIN AUserNameWITH password = lsquoAPass-wordrsquo EXEC sp_addsrvrole-

SqlServer andSQLServerSpa-tial

member loginame = lsquoAUs-erNamersquo rolename =lsquosysadminrsquo

C

The code samples use the SQL syntax supported by MySQL in the stringspassed to the FDO API command calls

The following namespaces are used

OSGeoFDOCommandsSQL

OSGeoFDOCommands

174 | Chapter 13 FDO Cookbook

create a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = create user AUserName identified by

APassword

int returnVal = sqlCommandExecuteNonQuery()

sqlCommandSQLStatement = grant all on to AUserName

returnVal = sqlCommandExecuteNonQuery()

drop a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = drop user AUserName

int returnVal = sqlCommandExecuteNonQuery()

list users

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = select user from mysqluser where user

= AUserName

ISQLDataReader reader = sqlCommandExecuteReader()

readerClose()

Spatial ContextA spatial context specifies a coordinate system and an extent for a set ofgeometries The spatial context object has a Name property The value of theName property is assigned to the SpatialContextAssociation property of theGeometricPropertyDefinition object that defines a feature or non-featuregeometry belonging to a feature class In this way a coordinate system andextent is associated with geometry values inserted into the data store as partof instances of the class Example code showing this association is containedin the Basic Schema Operations on page 178 topic

NOTE It is worth emphasizing that each geometric property definiton in a featureclass definition can have a different spatial context This mechanism replaces thatof the active spatial context

The data stores created by the Oracle Sql Server MySQL and optionally theSQL Server Spatial providers contain metadata that supports the assignmentof a default spatial context to a Geometric Property Definition during schema

Spatial Context | 175

creation in the event that the user has not explicitly assigned one The attributevalues of the default spatial context are set out in the following table

ValueAttribute

DefaultName

ltno valuegtCoordinateSystem

ltno valuegtCoordinateSystemWkt

SpatialContextExtentType_StaticExtentType

POLYGON((-2000000 -2000000 2000000 -20000002000000 2000000 -2000000 2000000 -2000000 -2000000))

Extent

C

The code samples show how to create a spatial context and how to get thespatial contexts from a data store

The following namespaces are used

OSGeoFDOCommandsSpatialContext

OSGeoFDOGeometry

OSGeoFDOConnections

176 | Chapter 13 FDO Cookbook

get the spatial contexts from a data store

IGetSpatialContexts getSpatialContexts = connectionCreateCom

mand(CommandTypeCommandType_GetSpatialContexts) as IGetSpatialCon

texts

ISpatialContextReader reader = getSpatialContextsExecute()

string name = null

string coordSys = null

string wellKnownText = null

string desc = null

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IGeometry geom = null

string extent = null

SpatialContextExtentType extentType

double xyTolerance

double zTolerance

while (readerReadNext())

name = readerGetName()

coordSys = readerGetCoordinateSystem()

wellKnownText = readerGetCoordinateSystemWkt()

desc = readerGetDescription()

geom = geomFactoryCreateGeometryFromFgf(readerGetExtent())

extent = geomText

extentType = readerGetExtentType()

xyTolerance = readerGetXYTolerance()

zTolerance = readerGetZTolerance()

readerDispose()

Spatial Context | 177

create a spatial context whose coordinate system is WGS84 and

whose extent is the maximum

create the extent

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

ICreateSpatialContext createSpatialContext = connectionCreateCom

mand(CommandTypeCommandType_CreateSpatialContext) as ICreateSpa

tialContext

createSpatialContextCoordinateSystem =

createSpatialContextCoordinateSystemWkt = wgs84Wkt

createSpatialContextDescription = This Coordinate System is used

for GPS

a static extent is defined once and never changed

a dynamic extent grows to accommodate the geometries added to

the data store

createSpatialContextExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

createSpatialContextExtent = extent

the value of Name is assigned to the SpatialContextAssociation

attribute of a GeometricPropertyDefinition object during the

creation of the logical feature schema

in this way a coordinate system and extent is associated with

the geoemtries

createSpatialContextName = WGS84 Spatial Context

createSpatialContextExecute()

Basic Schema OperationsAll providers allow you to describe a schema but only SDF SHP MySQLPostGIS SqlServer SQLServerSpatial KingOracle and Oracle allow you toapply and destroy a schema

178 | Chapter 13 FDO Cookbook

C

The code samples show how to describe apply and destroy a schema

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommands

OSGeoFDOSchema

describe a schema

IDescribeSchema descSchema = connCreateCommand(CommandTypeCom

mandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

FeatureSchema schema = schemas[0]

ClassCollection classes = schemaClasses

Class featureClass = classes[0]

PropertyDefinitionCollection properties = featureClassProperties

PropertyDefinition property = properties[0]

PropertyType propertyType = propertyPropertyType

if (propertyType == PropertyTypePropertyType_DataProperty)

DataPropertyDefinition dataPropDef = property as DataPropertyDefin

ition

DataType dataType = dataPropDefDataType

Basic Schema Operations | 179

create and apply a schema

FeatureSchema schema = new FeatureSchema(AnApplicationSchema

This schema contains one feature class)

FeatureClass featClass = new FeatureClass(AFeatureClass This

feature class contains one identity property one data property and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(ID

This is the identity property)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = true

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition int32Prop = new DataPropertyDefini

tion(Int32Prop This is an Int32 property)

int32PropDataType = DataTypeDataType_Int32

propertiesAdd(int32Prop)

add the feature geometry

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(FeatGeomProp This is the feature geometry)

associate this geometric property with a spatial context

you must have already added the named context to the data store

if this property is not set it is assigned the default spatial

context

see the Spatial Context topic to read a description of the de

fault spatial context

featGeomPropSpatialContextAssociation = XY-M Spatial Context

by default this geometric property can contain geometries that

may be classified as point curve surface or solid

also by default this geometric property cannot contain geomet

ries that have a Z ordinate or a measure attribute

propertiesAdd(featGeomProp)

without the following line you would be adding a non-feature

geometry

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

apply the schema

180 | Chapter 13 FDO Cookbook

IApplySchema applySchema = connCreateCommand(CommandTypeCommand

Type_ApplySchema) as IApplySchema

applySchemaFeatureSchema = schema

applySchemaExecute()

destroy the schema

IDestroySchema destroySchema = connCreateCommand(CommandTypeCom

mandType_DestroySchema) as IDestroySchema

destroySchemaSchemaName = AnApplicationSchema

destroySchemaExecute()

Insert DataAll providers except Gdal Raster WFS and WMS allow you to insert data

C

The code sample shows how to insert a feature consisting of a data value anda geometry value

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOGeometry

Insert Data | 181

Identifier className = new Identifier(FeatureClass)

IInsert insert = connCreateCommand(CommandTypeCommandType_Insert)

as IInsert

insertFeatureClassName = className

PropertyValueCollection values = insertPropertyValues

add the Int32 value to the insert command

int32Value = new Int32Value(5)

int32PropVal = new PropertyValue(Int32Prop int32Value)

valuesAdd(int32PropVal)

add the feature geometry to the insert command

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

DirectPositionImpl position1 = new DirectPositionImpl(10 10)

IPoint point = geomFactoryCreatePoint(position1)

GeometryValue geomVal = new GeometryValue(geomFactoryGet

Fgf(point))

PropertyValue geomPropVal = new PropertyValue(FeatGeomProp

geomVal)

valuesAdd(geomPropVal)

insert the feature

IFeatureReader reader = insertExecute()

readerClose()

Select DataAll providers allow you to select data

C

In the following code sample the filter is set to retrieve values for each featurein the database Without adding a computed identifier to the select commandrsquosproperty collection the select command would return all of the propertyvalues for each feature in the database In this example the computed identifiercontains a function expression that converts the DateTime value in theDateTimeProp property to a string and returns the string So the select returnsa set of DateTime strings

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

182 | Chapter 13 FDO Cookbook

OSGeoFDOFilter

Identifier className = new Identifier(FeatureClass)

ISelect select = connCreateCommand(CommandTypeCommandType_Select)

as ISelect

selectFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectFilter = filter

ComputedIdentifier computedId = ExpressionParse((ToString(Date

TimeProp) as computedId)) as ComputedIdentifier

selectPropertyNamesAdd(computedId)

IFeatureReader reader = selectExecute()

readerClose()

Select Aggregate DataAll providers except the PostGIS provider allow you to select aggregate data

C

In the following code sample the filter is set to retrieve values for each featurein the database The computed identifier contains a function expression thattakes the average of all of the values in the property whose name is Int32Propand returns a double

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

Select Aggregate Data | 183

Identifier className = new Identifier(FeatureClass)

ISelectAggregates selectAggregates = connCreateCommand(Command

TypeCommandType_SelectAggregates) as ISelectAggregates

selectAggregatesFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectAggregatesFilter = filter

ComputedIdentifier computedId = ExpressionParse((Avg(Int32Prop)

as computedId)) as ComputedIdentifier

selectAggregatesPropertyNamesAdd(computedId)

IDataReader reader = selectAggregatesExecute()

readerClose()

Delete DataAll providers except Gdal Raster WFS and WMS allow you to delete data

C

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

delete all of the data

ID is the name of the identity property

Filter filter = FilterParse(ID gt= 0)

Identifier className = new Identifier(FeatureClass)

IDelete delete = connCreateCommand(CommandTypeCommandType_Delete)

as IDelete

deleteFeatureClassName = className

deleteFilter = filter

int numDeleted = deleteExecute()

Schema OverridesWhen FDO connects to a datastore with an existing schema and describes theschema it maps the native data types to FDO data types to create a default

184 | Chapter 13 FDO Cookbook

physical to logical schema mapping You can create a schema mapping thatoverrides the default FDO mapping This schema override must be appliedevery time that you connect to the data store Use the providerrsquos SchemaOverride API to write a program that defines the overrides and writes themto an XML configuration file Thereafter before opening the connection tothe provider set the connection objectsrsquos configuration property to point tothe XML configuration file

The key elements to a schema override are an FDO feature schema and amapping of column names in the existing table to property names in the FDOfeature schema The ODBC provider supports the mapping of two columnnames in an existing table to a 2D FDO point geometry property and optionallysupports the mapping of three columns to a 3D point geometry property Inthe event that the mapping includes an FDO geometry property a spatialcontext definition should be provided

The description given here is based on sample code written to define a schemaoverride for a table in a Microsoft Access database The following table showsthe name of the column in the Access database which is the same as thedefault FDO property name the FDO property name assigned by the schemaoverride a description of the contents of the column the FDO data typeassigned by the default schema mapping and the FDO data type assigned bythe schema override

The default schema mapping of the CITY_ID and POPULATION columns areoverriden to assign them different data types than the default ones and togive them different names A change in case counts as a change in name Thedefault schema mapping of the LATITUDE and LONGITUDE columns areoverriden because they are combined into a single property that has a differentname and a different type than the defaults The default schema mapping ofthe NAME COUNTRY and CAPITAL columns are overriden to assign themdifferent names than the defaults The default schema mapping of the URLcolumn is not overriden and retains its default type and name

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

Int64Int16consecutive sequence of integersfrom 1 to lt 1000

IdCITY_ID

StringStringNamesNameNAME

StringStringNamesCountryCOUNTRY

Schema Overrides | 185

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

StringStringlsquoNrsquo or lsquoYrsquoCaptialCAPITAL

Not over-riden

StringnullNot over-riden

URL

Int32Doublepositive integers lt 17000000PopulationPOPULATION

GeometryDoublepositive and negative decimalsGeometryLATITUDE

GeometryDoublepositive and negative decimalsGeometryLONGITUDE

First a conceptual view of how to create the XML configuration file for aschema override is presented and then a code view is presented The overrideincludes a geometry property and so a spatial context is defined as well

1 Open the XML file

2 Create a spatial context for the geometry and write it to the XML file

3 Create the FDO feature schema and write it to the XML file

4 Create a connection to the provider and get a reference to theconnectionrsquos physical schema mapping

5 Use the reference to the connectionrsquos physical schema mapping and theSchema Override API to create the schema override whereby the logicalfields in the feature schema are associated with columns in the databasetable

6 Write the schema override to the XML file

7 Close the XML file

C

The following namespaces are used

OSGeoFDOCommonIo

OSGeoFDOCommonXml

186 | Chapter 13 FDO Cookbook

OSGeoFDOGeometry

OSGeoFDOSchema

Create the XML Schema Override Configuration File

Open the XML File

IoFileStream writeFileStream = new IoFileStream(Citiesxml w)

XmlWriter writer = new XmlWriter(writeFileStream)

Create a Spatial Context and Write It to the XML File

XmlSpatialContextFlags flags = new XmlSpatialContextFlags()

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(writer flags)

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

spatialContextWriterCoordinateSystem = WGS 84

spatialContextWriterCoordinateSystemWkt = GEOGCS [ Longitude

Latitude (WGS 84) DATUM [WGS 84 SPHEROID [WGS 84

6378137 298257223563]] PRIMEM [ Greenwich 0000000 ] UNIT

Decimal Degree 001745329251994330]]

spatialContextWriterDescription = This Coordinate System is used

for GPS

spatialContextWriterExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

spatialContextWriterExtent = extent

spatialContextWriterName = WGS84

spatialContextWriterXYTolerance = 0001

the next line writes the XML declaration the opening tag for

the fdoDataStore element

and the gmlDerivedCRS element to the XML file

spatialContextWriterWriteSpatialContext()

Schema Overrides | 187

Create the Feature Schema and Write It to the XML File

188 | Chapter 13 FDO Cookbook

FeatureSchema schema = new FeatureSchema(World Logical feature

schema)

FeatureClass featClass = new FeatureClass(Cities This feature

class contains one identity property many data properties and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(Id

This is the unique id number for the city)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = false

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition nameProp = new DataPropertyDefini

tion(Name This is the name of the City)

namePropDataType = DataTypeDataType_String

namePropLength = 64

propertiesAdd(nameProp)

DataPropertyDefinition countryProp = new DataPropertyDefini

tion(Country This is country that contains the city)

countryPropDataType = DataTypeDataType_String

countryPropLength = 64

propertiesAdd(countryProp)

DataPropertyDefinition populationProp = new DataPropertyDefini

tion(Population This is the population of the city)

populationPropDataType = DataTypeDataType_Int32

propertiesAdd(populationProp)

DataPropertyDefinition capitalProp = new DataPropertyDefini

tion(Capital This is Y or N to say whether the city is the

capital of the country)

capitalPropDataType = DataTypeDataType_String

capitalPropLength = 1

propertiesAdd(capitalProp)

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(Geometry This is the feature geometry)

featGeomPropGeometryTypes = (int)GeometricTypeGeometric

Type_Point

featGeomPropHasElevation = false

featGeomPropHasMeasure = false

propertiesAdd(featGeomProp)

Schema Overrides | 189

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

the next line writes the xsschema element to the XML file

schemaWriteXml(writer)

190 | Chapter 13 FDO Cookbook

Create the Physical Schema Mapping and Write It to the XML File

Schema Overrides | 191

set the connection to point

at the Microsoft Access database file

whose Data Source Name (DSN) has been

defined using the Data Sources (ODBC)

Windows XP administrative tool

connectionConnectionString = DataSourceName= + dataSourceName

get a reference to the PhysicalSchemaMapping object contained

in the connection

PhysicalSchemaMapping connectionSchemaMapping = connectionCreateS

chemaMapping()

use that reference to create an override physical schema mapping

the override definition associates columns in the columns of

the Access database with property names in the FDO feature schema

OvPhysicalSchemaMapping mapping = new OvPhysicalSchemaMapping(con

nectionSchemaMapping false)

mappingName = World

OvClassCollection overrideClasses = mappingClasses

OvClassDefinition overrrideClassDef = new OvClassDefinition(Cit

ies)

OvPropertyDefinitionCollection overrideProperties = overrride

ClassDefProperties

associate the table in the Access database with the override

class definition

OvTable table = new OvTable(Cities)

overrrideClassDefTable = table

associate the columns in the table in the Access database with

the properties in the FDO feature schema

OvColumn column = null

OvGeometricPropertyDefinition overridGeomProp = new OvGeometric

PropertyDefinition(Geometry)

overridGeomPropGeometricColumnType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricColumnTypeOvGeometricColumnType_Double

overridGeomPropGeometricContentType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricContentTypeOvGeometricContentType_Ordin

ates

overridGeomPropXColumnName = LONGITUDE

overridGeomPropYColumnName = LATITUDE

overridePropertiesAdd(overridGeomProp)

OvDataPropertyDefinition overrideIdProp = new OvDataPropertyDefin

ition(Id)

column = new OvColumn(CITY_ID) overrideIdPropColumn = column

overridePropertiesAdd(overrideIdProp)

192 | Chapter 13 FDO Cookbook

OvDataPropertyDefinition overrideNameProp = new OvDataPropertyDefin

ition(Name)

column = new OvColumn(NAME)

overrideNamePropColumn = column

overridePropertiesAdd(overrideNameProp)

OvDataPropertyDefinition overrideCountryProp = new OvDataProperty

Definition(Country)

column = new OvColumn(COUNTRY)

overrideCountryPropColumn = column

overridePropertiesAdd(overrideCountryProp)

OvDataPropertyDefinition overridePopulationProp = new OvDataProp

ertyDefinition(Population)

column = new OvColumn(POPULATION)

overridePopulationPropColumn = column

overridePropertiesAdd(overridePopulationProp)

OvDataPropertyDefinition overrideCapitalProp = new OvDataProperty

Definition(Capital)

column = new OvColumn(CAPITAL)

overrideCapitalPropColumn = column

overridePropertiesAdd(overrideCapitalProp)

overrideClassesAdd(overrideClassDef)

write the override definition to the XML file

XmlFlags flags = new XmlFlags()

the next line writes the SchemaMapping element to the XML file

mappingWriteXml(writer flags)

mappingDispose()

Write the Closing Tag and Close the XML File

the next line writes the closing tag of the fdoDataStore ele

ment to the XML file

writerWriteEndElement()

writerClose()

writerDispose()

writeFileStreamClose()

writeFileStreamDispose()

Configure a Connection to Use the Schema Override

The connection object contains a property whose value points to the XMLconfiguration file

Schema Overrides | 193

IConnection connection = connMgrCreateConnection(providerName)

IoFileStream configurationFileStream = new IoFileStream(Cit

iesxml r)

connectionConfiguration = configurationFileStream

connectionConnectionString = DataSourceName= + dataSourceName

connectionOpen()

Xml SerializeDeserializeThis code sample serializes the spatial context and feature schema of a datastore to an xml file and then deserializes it in another data store

C

This is the C code

Namespaces

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommonIo

OSGeoFDOCommonXml

OSGeoFDOSchema

OSGeoFDOXml

194 | Chapter 13 FDO Cookbook

Serialize

open the xml file

XmlWriter xmlWriter = new XmlWriter(xmlFilename)

serial the spatial contexts

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(xmlWriter)

XmlSpatialContextSerializerXmlSerialize(connection spatialContex

tWriter)

serialize the feature schemas

IDescribeSchema descSchema = connectionCreateCommand(Command

TypeCommandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

schemasWriteXml(xmlWriter)

clean up

spatialContextWriterDispose()

xmlWriterDispose()

C | 195

Deserialize

deserialize the spatial contexts

IoFileStream fileStream = new IoFileStream(xmlFilename r)

XmlReader xmlReader = new XmlReader(fileStream)

XmlSpatialContextReader xScReader = new XmlSpatialContextReader(xm

lReader)

XmlSpatialContextSerializerXmlDeserialize(connection xScReader)

fileStreamReset()

deserialize the schema

FeatureSchemaCollection schemas = new FeatureSchemaCollec

tion(null)

schemasReadXml(fileStream)

IApplySchema applySchema = connectionCreateCommand(CommandTypeCom

mandType_ApplySchema) as IApplySchema

FeatureSchema schema = null

for (int i = 0 i lt schemasCount i++)

schema = schemasget_Item(i)

applySchemaFeatureSchema = schema

applySchemaExecute()

fileStreamReset()

clean up

xmlReaderDispose()

fileStreamClose()

GeometryThe geometry code samples are divided into two parts The first is constructinggeometries The second is deconstructing them that is extracting informationfrom the geometry objects

Construction

Geometries can be constructed using a set of scaffolding classes which includesa geometry factory class or they can be constructed using the geometry factoryclass from text specifications The syntax for the text specifications is describedin the Geometry Value section in the Filter and Expression Languages chapter

196 | Chapter 13 FDO Cookbook

What follows here is a description of geometry construction using thescaffolding classes

Some geometries are constructed using a two step procedure First createcoordinates and then create the geometry Some geometries require anintermediate step Use the coordinates to create subcomponents and then usethe subcomponents to create the geometry The construction of somegeometries requires the use of helper collection classes Some of these classesare collections of geometries and some are collections of geometrysubcomponents

Simple geometries like point and line are constructed directly from coordinatesComplex geometries like curved lines and polygons are constructed fromgeometry subcomponents like arc and line segments and rings In generalsubcomponents are constructed from coordinates The exception is the ringwhich is constructed from arc and line segments The glue is the helpercollection classes for coordinates segments and rings

A geometry object may consist of homogeneous or heterogeneous aggregationsof points lines and polygons The glue is helper collection classes for pointslines and polygons

C Namespaces

The following namespaces are used

OSGeoFDOCommon

OSGeoFDOGeometry

C Geometry Scaffolding Classes

The scaffolding classes used to construct the simple complex and aggregategeometries are the following

the IDirectionPosition class used to construct positions (coordinates)

the FgfGeometryFactory class used to construct the geometrysubcomponents and geometries

the geometry subcomponent classes ILineStringSegmentICircularArcSegment ILinearRing and IRing

Construction | 197

the helper collection classes PointCollection LineStringCollectionCurveSegmentCollection LinearRingCollection RingCollectionPolygonCollection CurvePolygonCollection and GeometryCollection

IDirectPositionImpl

The IDirectPosition is the basic building block of geometries Use its constructorto define a coordinate Use instances of it to define the IPoint and ILineStringgeometries or to define the geometry subcompoonents ILinearRingICircularArcSegment and ILineStringSegment

DirectPositionImpl pos00 = new DirectPositionImpl(00 00)

FgfGeometryFactory

Use an instance of this class to do the following

create geometry subcomponents used to construct IGeometry-based objects

create IGeometry-based objects

convert IGeometry-based objects into binary-formatted geometries usedfor data store inserts

convert binary-formatted geometries retrieved during data store queriesinto IGeometry-based objects

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

Geometry Subcomponents

The following subcomponents are used in the construction of geometries andgeometry subcomponents

The ICircularArcSegment and ILineStringSegment subcomponents are usedto construct the ICurveString geometry and the IRing geometrysubcomponent

The ILinearRing subcomponent is used to contruct the IPolygon geometry

The IRing subcomponent is used to construct the ICurvePolygon geometry

198 | Chapter 13 FDO Cookbook

ICircularArcSegment

The creation of an instances uses IDirectPositionImpl objects whichrespectively define a start position a mid point and an end position for thearc

ICircularArcSegment as012122 = geomFactoryCreateCircularArcSeg

ment(pos01 pos21 pos22)

ILineStringSegment

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos23)

positionsAdd(pos30)

positionsAdd(pos33)

ILineStringSegment ls233033 = geomFactoryCreateLineStringSeg

ment(positions)

positionsClear()

ILinearRing

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos01)

positionsAdd(pos21)

positionsAdd(pos12)

positionsAdd(pos01)

ILinearRing lr01211201 = geomFactoryCreateLinearRing(positions)

positionsClear()

IRing

An IRing is constructed using a CurveSegmentCollection This collection cancontain ICircularArcSegment and ILineStringSegment objects

curveSegmentsAdd(as1340n20)

curveSegmentsAdd(lsn2013)

IRing rAs1340n20Lsn2013 = geomFactoryCreateRing(curveSegments)

curveSegmentsClear()

Construction | 199

Collection Classes

The following collection classes are used during the construction of the variousgeometries

Contains IDirectPositionImpl ojbects

DirectPositionCollection positions = new DirectPositionCollec

tion()

Contains IPoint objects

PointCollection points = new PointCollection()

Contains ILineString objects

LineStringCollection lines = new LineStringCollection()

Contains ICircularArcSegment and ILineStringSegment objects

CurveSegmentCollection curveSegments = new CurveSegmentCollec

tion()

Contains ICurveString objects

CurveStringCollection curves = new CurveStringCollection()

Contains ILinearRing objects

LinearRingCollection linearRings = new LinearRingCollection()

Contains IRing objects

RingCollection curveRings = new RingCollection()

Contains IPolygon objects

PolygonCollection linearPolygons = new PolygonCollection()

Contains ICurvePolygon objects

CurvePolygonCollection curvePolygons = new CurvePolygonCollec

tion()

GeometryCollection geometries = new GeometryCollection()

C Geometries Constructed usingIDirectPositionImpl

These geometries are IPoint and ILineString

IPoint

The creation of an instances uses an IDirectionPositionImpl object

IPoint pt00 = geomFactoryCreatePoint(pos00)

200 | Chapter 13 FDO Cookbook

ILineString

The creation of an instances uses a DirectPositionCollection object which iscomposed of IDirectionPositionImpl object

positionsAdd(pos01)

positionsAdd(pos21)

ILineString line0121 = geomFactoryCreateLineString(positions)

positionsClear()

C Geometries Constructed Using GeometrySubcomponents

These geometries are ICurveString IPolygon and ICurvePolygon

ICurveString

The creation of an instance uses a CurveSegmentCollection object whichcontains an ICircularArcSegment object and an ILineStringSegment object

ICurveString composed of a circular arc segment and a line

string segment

curveSegmentsAdd(as022223)

curveSegmentsAdd(ls233033)

ICurveString csAs022223Ls233033 = geomFactoryCreateCur

veString(curveSegments)

curveSegmentsClear()

IPolygon

The creation of an instance uses an ILinearRing object for the exterior ringand a LinearRingCollection object composed of ILinearRing objects for theinterior rings

IPolygon with one exterior ring and no interior rings

IPolygon polyEr01211201 = geomFactoryCreatePolygon(lr01211201

null)

IPolygon with one exterior ring and one interior ring

linearRingsAdd(lr01211201)

polyEr13n204013Ir01211201 = geomFactoryCreatePolygon(lr13n204013

linearRings)

linearRingsClear()

Construction | 201

ICurvePolygon

The creation of an instance uses an IRing object for the exterior ring and aRingCollection object composed of an IRing object for the interior rings

ICurvePolygon with one exterior ring rAs1340n20Lsn2013 which

is composed of an arc segment and a line segment

and one interior ring rLs0121Ls2112Ls1201 which is a triangle

made of three line segments

curveRingsAdd(rLs0121Ls2112Ls1201)

ICurve Polygon curvPolyErAs1340n20Lsn2013IrLs0121Ls2112Ls1201 =

geomFactoryCreateCurvePolygon(rAs1340n20Lsn2013 curveRings)

curveRingsClear()

C Aggregate Geometries

The aggregate geometries are IMultiPoint IMultiLineString IMultiCurveStringIMultiPolygon IMultiCurvePolygon and IMultiGeometry

IMultiPoint

The creation of an instance uses a PointCollection object

pointsAdd(pt00)

pointsAdd(pt11)

IMultiPoint pt00pt11 = geomFactoryCreateMultiPoint(points)

pointsClear()

IMultiLineString

The creation of an instance uses a LineStringCollection object

linesAdd(line0121)

linesAdd(line0222)

IMultiLineString line0121line0222 = geomFactoryCreateMultiLineS

tring(lines)

linesClear()

IMultiCurveString

The creation of an instance uses a CurveStringCollection object

202 | Chapter 13 FDO Cookbook

curvesAdd(csAs012122)

curvesAdd(csAs022223Ls233033)

IMultiCurveString aMultiCurvePolygon = geomFactoryCreateMultiCur

veString(curves)

curvesClear()

IMultiPolygon

The creation of an instance uses a PolygonCollection object

linearPolygonsAdd(polygonNum1)

linearPolygonsAdd(polygonNum2)

IMultiPolygon aMultiPolygon = geomFactoryCreateMultiPolygon(lin

earPolygons)

linearPolygonsClear()

IMultiCurvePolygon

The creation of an instance uses a CurvePolygonCollection object

curvePolygonsAdd(curvePolygonNum1)

curvePolygonsAdd(curvePolygonNum2)

IMultiCurvePolygon aMultiCurvePolygon = geomFactoryCreateMultiC

urvePolygon(curvePolygons)

curvePolygonsClear()

IMultiGeometry

The creation of an instance uses a GeometryCollection object

geometriesAdd(aPoint)

geometriesAdd(aMultiPoint)

geometriesAdd(aLineString)

geometriesAdd(aMultiLineString)

geometriesAdd(aCurveString)

geometriesAdd(aMultiCurveString)

geometriesAdd(aPolygon)

geometriesAdd(aMultiPolygon)

geometriesAdd(aCurvePolygon)

geometriesAdd(aMultiCurvePolygon)

IMultiGeometry aMultiGeometry = geomFactoryCreateMultiGeometry(geo

metries)

geometriesClear()

Construction | 203

C Geometries from Text Specifications

You can use the geometry factoryrsquos CreateGeometry method to creategeometries from text specifications Herersquos an IPoint example

IPoint pt11 = geomFactoryCreatePoint(pos11)

IPoint aSecondPt11 = geomFactoryCreateGeometry(pt11Text) as

IPoint

aThirdPt11 = geomFactoryCreateGeometry(POINT (1 1)) as IPoint

Deconstruction

Deconstruction means getting information such as dimensionality envelopetext specification geometry geometry subcomponents and positions(coordinates) The following table specifies the information available fromthe classes

Position means coordinate values Dimensionality values are XY XYZ XYMor XYZM Envelope means bounding rectangle The envelope for an aggregategeometry contains all of the included geometries Text means FGF well-knowntext specification IsClosed is a boolean specifying whether or not the startand end coordinates are identical

Information availableClass

position dimensionalityIDirectPosition

position dimensionality envelope textIPoint

dimensionality envelope text IPointIMultiPoint

position dimensionality envelope textILineString

dimensionality envelope text ILineStrinIMultiLineString

IsClosed position dimensionality envelopeILineStringSegment

IsClosed position dimensionality envelopeICircularArcSegment

204 | Chapter 13 FDO Cookbook

Information availableClass

position dimensionality envelope text ICircularArcSegment ILineStringSegmentICurveString

dimensionality envelope text ICurveStringIMultiCurveString

position dimensionality envelopeILinearRing

dimensionality envelope text ILinearRingIPolygon

dimensionality envelope text IPolygonIMultiPolygon

position dimensionality ICircularArcSegment ILineStringSegmentIRing

dimensionality envelope text IRingICurvePolygon

dimensionality envelope text ICurvePolygonIMultiCurvePolygon

dimensionality envelope text IPoint IMultiPoint ILineString IMultiLineStringICurveString IMultiCurveString IPolygon IMultiPolygon ICurvePolygon IMulti-CurvePolygon

IMultiGeometry

Coordinates

IDirectPosition aPosition

double X = aPositionX

double Y = aPositionY

double Z

double M

int dim = aPositionDimensionality

if ((dim amp 1) == 1)

Z = aPositionZ

if ((dim amp 2) == 2)

M = aPositionM

Deconstruction | 205

IDirectPosition (IPoint ILineString ICircularArcSegmentILineStringSegment ILinearRing)

IPoint aPoint

IDirectPosition position = aPointPosition

ILineString line

IDirectPosition aPosition = null

IDirectPosition startPosition = lineStartPosition

IDirectPosition endPosition = lineEndPosition

for (int i = 0 i lt lineCount i++)

aPosition = lineget_Item(i)

ICircularArcSegment arcSegment

IDirectPosition startPosition = arcSegmentStartPosition

IDirectPosition midPoint = arcSegmentMidPoint

IDirectPosition endPosition = arcSegmentEndPosition

ILineStringSegment lineSegment

IDirectPosition startPosition = lineSegmentStartPosition

IDirectPosition endPosition = lineSegmentEndPosition

DirectPositionCollection positions = lineSegmentPositions

foreach(IDirectPosition position in positions)

ICurveString curve

IDirectPosition startPosition = curveStartPosition

IDirectPosition endPosition = curveEndPosition

ILinearRing linearRing

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

ILinearRing ring

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

Dimensionality Envelope and Text

int dimensionality = aPointDimensionality

IEnvelope envelope = aPointEnvelope

string text = aPointText

206 | Chapter 13 FDO Cookbook

IsClosed (ICircularArcSegment and ILineStringSegment)

ICircularArcSegment arcSegment

bool isClosed = arcSegmentIsClosed

ILineStringSegment lineSegment

bool isClosed = lineSegmentIsClosed

IPoint and IMultiPoint

IMultiPoint aMultiPoint

IPoint aPoint = null

for (int i = 0 i lt aMultiPointCount i++)

aPoint = aMultiPointget_Item(i)

ILineString and IMultiLineString

IMultiLineString aMultiLineString

ILineString line = null

for (int i = 0 i lt aMultiLineStringCount i++)

line = aMultiLineStringget_Item(i)

ICurveString and IMultiCurveString

IMultiCurveString aMultiCurveString

ICurveString curve = null

for (int i = 0 i lt aMultiCurveStringCount i++)

curve = aMultiCurveStringget_Item(i)

Deconstruction | 207

ICircularArcSegment and ILineStringSegment (ICurveString andIRing)

ICurveString aCurveString

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt aCurveStringCount i++)

curveSegment = aCurveStringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

IRing ring

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt ringCount i++)

curveSegment = ringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

ILinearRing (IPolygon)

IPolygon aPolygon

ILinearRing anExteriorRing = aPolygonExteriorRing

ILinearRing anInteriorRing = null

for (int i = 0 i lt aPolygonInteriorRingCount i++)

anInteriorRing = aPolygonGetInteriorRing(i)

208 | Chapter 13 FDO Cookbook

IPolygon and IMultiPolygon

IMultiPolygon aMultiPolygon

IPolygon aPolygon = null

for (int i = 0 i lt aMultiPolygonCount i++)

aPolygon = aMultiPolygonget_Item(i)

IRing (ICurvePolygon)

ICurvePolygon aCurvePolygon

IRing anExteriorRing = aCurvePolygonExteriorRing

IRing anInteriorRing = null

for (int i = 0 i lt count i++)

anInteriorRing = aCurvePolygonget_InteriorRing(i)

ICurvePolygon and IMultiCurvePolygon

IMultiCurvePolygon aMultiCurvePolygon

ICurvePolygon aCurvePolygon = null

for (int i = 0 i lt aMultiCurvePolygonCount i++)

aCurvePolygon = aMultiCurvePolygonget_Item(i)

Deconstruction | 209

IMultiGeometry

IMultiGeometry aMultiGeometry

IGeometry geom = null

GeometryType geomType

IPoint pt = null

IMultiPoint mpt = null

ILineString line = null

IMultiLineString mline = null

ICurveString curve = null

IMultiCurveString mcurve = null

IPolygon poly = null

IMultiPolygon mpoly = null

ICurvePolygon curvPoly = null

IMultiCurvePolygon mCurvPoly = null

for (int i = 0 i lt aMultiGeometryCount i++)

geom = aMultiGeometryget_Item(i)

geomType = geomDerivedType

switch (geomType)

case GeometryTypeGeometryType_Point pt = geom as IPoint break

case GeometryTypeGeometryType_MultiPoint mpt = geom as IMulti

Point break

case GeometryTypeGeometryType_LineString line = geom as ILin

eString break

case GeometryTypeGeometryType_MultiLineString mline = geom as

IMultiLineString break

case GeometryTypeGeometryType_CurveString curve = geom as

ICurveString break

case GeometryTypeGeometryType_MultiCurveString mcurve = geom

as IMultiCurveString break

case GeometryTypeGeometryType_Polygon poly = geom as IPolygon

break

case GeometryTypeGeometryType_MultiPolygon mpoly = geom as

IMultiPolygon break

case GeometryTypeGeometryType_CurvePolygon curvPoly = geom as

ICurvePolygon break

case GeometryTypeGeometryType_MultiCurvePolygon mCurvPoly =

geom as IMultiCurvePolygon break

default break

210 | Chapter 13 FDO Cookbook

OSGeo FDO Provider forArcSDE

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ArcSDE

What Is FDO Provider for ArcSDEThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store A provider is a specific implementation of theFDO API that provides access to data in a particular data store ESRIreg ArcSDEreg

(Spatial Database Engine) is part of the ArcGIS 9 system ArcSDE manages theexchange of information between an (ArcGIS 9 Desktop) application and arelational database management system FDO Provider for ArcSDE provides FDOwith access to an ArcSDE 9-based data store which in this case must be Oracle9i (9206)

FDO Provider for ArcSDE SoftwareRequirements

Installed Components

FDO Provider for ArcSDE dynamically linked libraries are installed with the FDOSDK They are located in ltFDO SDK Install LocationgtFDObin You do nothave to do anything to make these DLLs visible

A

211

External Dependencies

The operation of FDO Provider for ArcSDE is dependent on the presence ofArcSDE 9 and a supported data source such as Oracle 9i in the networkenvironment The host machine running FDO Provider for ArcSDE must alsohave the required DLLs present which are available by installing either anArcGIS 91 Desktop application or the ArcSDE SDK For example the requiredDLLs are present if either ArcViewreg ArcEditorreg or ArcInforeg are installed Formore information about ArcGIS 91 Desktop applications and the ArcSDE SDKrefer to the ESRI documentation

Specifically in order for FDO Provider for ArcSDE to run three dynamicallylinked libraries sde91dll sg91dll and pe91dll are required and you mustensure that the PATH environment variable references the local foldercontaining these DLLs For example in Microsoft Windows if ArcGIS 91Desktop is installed to CProgram FilesArcGIS then the required ArcSDEbinaries are located at CProgram FilesArcGISArcSDEbin Similarly if theArcSDE SDK is installed to the default location then the required ArcSDEbinaries are located at CArcGisArcSDEbin The absence of thisconfiguration may cause the following exception message The ArcSDE runtimewas not found

FDO Provider for ArcSDE LimitationsThe FDO Provider for ArcSDE is based on a subset of the ArcSDE API Thissubset does not include the following

Raster functionality

Native ArcSDE metadata

The annotation data with the exception of the ANNO_TEXT column

ArcSDE LimitationsFDO Provider for ArcSDE must abide by limitations of the ArcSDE technologyto which it connects This section discusses these limitations

212 | Appendix A OSGeo FDO Provider for ArcSDE

Relative to ArcObjects API and ArcGIS Server API

The ArcSDE API does not support the following advanced functionality foundin the ArcObjects API and the newer ArcGIS Server API

Advanced geometries such as Bezier curves and ellipses

Relationships

Topology

Networks

Analysis

Linear referencing

Curved Segments

If ArcSDE encounters curved segments it will automatically tessellate themThis means that if you create a geometry containing an arc segment in anArcSDE table using ArcObjects API and then you try to read that geometryback using the ArcSDE API you will get a series of line segments thatapproximate the original arc segment That is you get an approximation ofthe original geometry

Locking and Versioning

ArcSDE permits row locks or table versioning provided that the ID columnwhich uniquely identifies the row is maintained by ArcSDE If there is no IDcolumn or the ID column is maintained by the user ArcSDE does not permitrow locking or table versioning to be enabled

NOTE In ArcSDE you can either lock rows in a table or version a table but youcannot do both at the same time To do either you must alter the tablersquosregistration

The following sections illustrate these three steps

1 The creation of a table

Relative to ArcObjects API and ArcGIS Server API | 213

2 The alteration of the table registration to identify one of the columndefinitions as the row ID column and to enable row locking

3 The alteration of the table registration to disable row locking and toenable versioning

Table Creation

The command is

sdetable -o create -t hassdemaintainedrowid -d name string(20)

fid integer(9) -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The Row Lock has no value and the value of Dependent Objects is None

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column

Row ID Column Type

Row Lock

Minimum Row ID

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Identity Row ID Column and Enable Row Locking

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -c fid -C sde -L

on -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

214 | Appendix A OSGeo FDO Provider for ArcSDE

NOTE The Row ID Column value is FID the Row ID Column Type value is SDEMaintained and the Row Lock value is Enable

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Enable

Minimum Row ID 1

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Disable Row Locking and Enable Versioning

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -L off -V MULTI -u

t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The ldquoRow Lockrdquo is ldquoNot Enablerdquo and ldquoDependent Objectsrdquo is ldquoMultiversionTablerdquo

Locking and Versioning | 215

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Not Enable

Minimum Row ID 1

Dependent Objects Multiversion Table

Dependent Object Names A18111 D18111

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

FDO Provider for ArcSDE ConnectionThis information supplements the Establishing a Connection chapter Youconnect to an ArcSDE data store indirectly through the ArcSDE server Theunderlying data source for the data store is a database such as Oracle TheArcSDE server is connected to the data source and mediates the requests thatyou send it

You can connect to FDO Provider for ArcSDE in one step if you already knowthe name of the data store that you want to use Otherwise you must connectin two steps

The minimum required connection properties for the initial call to Open()are server instance username and password Multiple users can access thedata store However access is password-protected The server property is thename of the machine hosting the ArcSDE server The instance property actsas an index into an entry in the services file An entry contains port andprotocol information used to connect to the ArcSDE server On a Windowsmachine the services file is located in CWINDOWSsystem32driversetcAssuming that the instance name is ldquoesri_sderdquo an entry would look somethinglike this ldquoesri_sde 5151tcp ArcSDE Server Listening Portrdquo

An ArcSDE data source may contain more than one data store For the firstcall to Open() a data store name is optional If successful the first call toOpen() results in the data store parameter becoming a required parameter anda list of the names of the data stores in the data source becoming availableYou must choose a data store and call Open() again

216 | Appendix A OSGeo FDO Provider for ArcSDE

If the data source supports multiple data stores the list returned by the firstcall to Open() will contain a list of all of the data stores resident in the datasource Otherwise the list will contain one entry ldquoDefault Data Storerdquo

If you know the name of the data store you can provide it for the first call toOpen() and make the connection in one step

Data Type MappingsThis section shows the mappings from FDO data types to ArcSDE data typesto Oracle data types

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDataType_Boolean

Not supportedNot supportedFdoDataType_Byte

DATEdateFdoDataType_DateTime

Not supportedNot supportedFdoDataType_Decimal

NUMBER(388)double(388)FdoDataType_Double

NUMBER(4)integer(4)FdoDataType_Int16

NUMBER(10)integer(10)FdoDataType_Int32

Not supportedNot supportedFdoDataType_Int64

NUMBER(62)float(62) typicalFdoDataType_SingleNUMBER(n8)float(0ltnlt=6 oltmltDBMSLimit)) possible

VARCHAR2(ltlengthgt)string(ltlengthgt)FdoDataType_String

LONG RAWblobFdoDataType_BLOB

Not supportedNot supportedFdoDataType_CLOB

Data Type Mappings | 217

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDatatype_UniqueID

Creating a Feature SchemaThis section describes the creation of the SampleFeatureSchema which is theexample feature schema described in the Schema Management chapter It alsodescribes the creation of the OGC980461FS schema which is the schemadefined in the OpenGIS project document 98-046r1

FDO Provider for ArcSDE does not support the creation or destruction offeature schema (that is does not support the FdoIApplySchema andFdoIDestroySchema commands) However it does support theFdoIDescribeSchema command The intended use of FDO Provider for ArcSDEis to operate on already existing feature schemas FDO Provider for ArcSDEsupports inserting selecting updating and deleting data in existing schemas

You can use FDO Provider for ArcSDE to operate on a new feature schemaHowever you must create the schema using ArcSDE tools In particular youuse the sdetable and sdelayer commands which can be used to create a schemain any of the data store technologies used by ArcSDE This part of thedescription is generic Other parts of the description are specific to Oracle andto Windows XP because Oracle is the data store technology and Windows XPis the operating system for this exercise

First you must create an Oracle username for the feature schema (that is thename of the Oracle user is the name of the feature schema) To do this youconnect as system administrator to the Oracle instance used by the ArcSDEserver The following command creates the user and grants to that user theprivileges necessary for the ArcSDE tool commands to succeed

grant connectresource to ltschemaNamegt identified by ltpasswordgt

Secondly you must log in to the host where the ArcSDE server is runningArcSDE tools are on the host machine where the ArcSDE server resides

TIP NetMeeting can be used to remotely login to where the ArcSDE Server isrunning and launch a command window (that is in the Run dialog box entercmd) The ArcSDE tool commands can be executed through the command windowDo not use CWINDOWSSYSTEM32COMMANDCOM because the line bufferis too short to contain the entire text of some of the SDE tool command strings

218 | Appendix A OSGeo FDO Provider for ArcSDE

Finally execute the sdetable and sdelayer commands in a command windowto create each of the classes Since you are executing these commands on thehost where the ArcSDE server is located you can omit the server name optionIf the ArcSDE server is connected to only one data store you can omit theservice option For more information about all of the ArcSDE commandsconsult the ArcSDE Developer Help Guide

SampleFeatureSchema

In this sample a feature schema called SampleFeatureSchema is created whichcontains one feature class called SampleFeatureClass This feature class hasthe following three properties

An Int32 called SampleIdentityDataProperty

A string called SampleNameDataProperty

A polygon geometry called SampleGeometricProperty

First use the sdetable -o create command to add the integer and stringproperties to SampleFeatureClass Then use the sdetable -o alter_reg commandto identify the SampleIdentityDataProperty as an identity property Finallyuse the sdelayer -o add command to add the geometric property toSampleFeatureClass This assumes that only one ArcSDE server service isrunning so that the -i option is optional The -i option takes a service nameas an argument

The sdetable -o create command can be invoked as follows

sdetable -o create -t SampleFeatureClass -d ldquoSampleIdentityData

Property INTEGER(10) SampleNameDataProperty STRING(64)rdquo -u

SampleFeatureSchema -p test

The -o option takes the command option name The -d option takes thecolumn definitions which is a quoted list of column namecolumn type pairsdelimited by commas The -u option takes an Oracle database user namewhich becomes the feature schema name The -p option takes a password

The sdetable -o alter_reg command is invoked as follows

sdetable -o alter_reg -t SampleFeatureClass -c SampleIdentityData

Property -C USER -u SampleFeatureSchema -p test

The -c option identifies the column name that will be the identity propertyThe -C option indicates whether SDE is supposed to generate the value orobtain it from the user You will be prompted to confirm that you want toalter the registration of the table

Creating a Feature Schema | 219

The sdelayer command is invoked as follows

sdelayer -o add -l SampleFeatureClassSampleGeometricProperty -E

0010050 -e a -u SampleFeatureSchema -p test

The -o option takes the command option name The -l option identifies thetable and column The -E option identifies the extents the arguments areltxminyminxmaxymaxgt The -e option identifies the geometry type withlsquoarsquo indicating an area shape

OGC980461FS

This schema contains the ten classes defined in the OpenGIS Project Document980946r1 The types of the properties belonging to the classes is similar tothat of SampleFeatureClass namely an integer a string and a geometry Onedifference is that the geometry in three of the classes is multipart Two ofthem have MULTIPOLYGON geometries and one of them has aMULTILINESTRING geometry A multipart geometry is indicated by addinga lsquo+rsquo to the entity argument to the -e option in the sdelayer command AMULTIPOLYGON geometry is indicated by ldquo-e a+rdquo and a MULTILINESTRINGgeometry is indicated by ldquo-e l+rdquo

An ArcSDE table cannot have two geometries This restriction impacts thedefinition of the buildings class which has a POLYGON and a POINTgeometry We have chosen to add the POINT geometry The OpenGIS 98-046r1document defines one query that references building objects and the POINTgeometry supports this query

NOTE The use of -E option in the sdelayer command defines the extents Thearguments are ltxminyminxmaxymaxgt The values provided below ensure thatyou will not receive any ldquoordinate out of boundsrdquo errors when inserting the98046r1 data

220 | Appendix A OSGeo FDO Provider for ArcSDE

ArcSDE Commands That Define the OGC980461FS Classes

Creating a Feature Schema | 221

sdetable -o create -t lakes -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t lakes -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l lakesshore -E 0010050 -e a -u OGC980461FS

-p test

sdetable -o create -t road_segments -d fid integer(10) name

string(64) aliases string(64) num_lanes integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t road_segments -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l road_segmentscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t divided_routes -d fid integer(10) name

string(64) num_lanes integer(10) -u OGC980461FS -p test

sdetable -o alter_reg -t divided_routes -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l divided_routescenterlines -E 0010050 -e l+

-u OGC980461FS -p test

sdetable -o create -t forests -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t forests -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l forestsboundary -E 0010050 -e a+ -u

OGC980461FS -p test

sdetable -o create -t bridges -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t bridges -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l bridgesposition -E 0010050 -e p -u

OGC980461FS -p test

sdetable -o create -t streams -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t streams -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l streamscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t buildings -d fid integer(10) address

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t buildings -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l buildingsposition -E 0010050 -e p -u

OGC980461FS -p test

222 | Appendix A OSGeo FDO Provider for ArcSDE

sdetable -o create -t ponds -d fid integer(10) name string(64)

type string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t ponds -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l pondsshores -E 0010050 -e a+ -u OGC980461FS

-p test

sdetable -o create -t named_places -d fid integer(10) name

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t named_places -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l named_placesboundary -E 0010050 -e a -u

OGC980461FS -p test

sdetable -o create -t map_neatlines -d fid integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t map_neatlines -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l map_neatlinesneatline -E 0010050 -e a -u

OGC980461FS -p test

Logical to Physical Schema MappingThis mapping does not apply because the ArcSDE provider does not supportthe ApplySchema command

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data types TheArcSDE provider talks to the ArcSDE server The server uses either Oracle orSql Server as the back-end data store technology So two schema mappins aredescribed here

Oracle 10gR2 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter The class name is the name of the tablecreated using the sdetable command The property names are the columnnames

Logical to Physical Schema Mapping | 223

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoSrdquo means that the storage typeused for the geometry is Oracle Spatial The -G argument ldquo26910rdquo is the SRID ofa coordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N The sqlplus command select cs_name from mdsyscs_srs where srid =

26910 returns NAD83 UTM zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde -u existinguser -p test -G 26910 -P 32 -t S

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int16NUMBER(4)SE_INT16 4SMINT4COL

UnmappedCHAR(38)SE_UUID 38ID

Int16NUMBER(4)SE_INT16 4INT16COL

224 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int32NUMBER(38)SE_INT32 10INT32COL

SingleNUMBER(62)SE_FLOAT32 6 2FLOAT32COL

DoubleNUMBER(154)SE_FLOAT64 7 2FLOAT64COL

Int32NUMBER(10)SEINT32 10INT10

SingleNUMBER(44)SE_FLOAT32 4 4FLOAT4_4

DoubleNUMBER(72)SE_FLOAT64 7 2DOUBLE7_2

StringVARCHAR2(64)SE_STRING 64STRING64

BLOBBLOBSE_BLOB 0BLOBCOL

UnmappedCLOBSE_CLOB 0CLOBCOL

StringNVARCHAR2(255)SE_NSTRING 255NSTRINGCOL

UnmappedNCLOBSE_NCLOB 0NCLOBCOL

DateTimeDATESE_DATE 0DATECOL

GeometryMDSYSSDO_GEOMETRYSE_SHAPE 0FEATGEOM

Int32NUMBER(38)SE_INT32 10OBJECTID

NOTE The OBJECTID column was not specified in the -d arguments of the sdetablecommand

Sql Server 2005 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter prefixed by ldquoSDE_rdquo The class name is the

Physical to Logical Schema Mapping | 225

name of the table created using the sdetable command The property namesare the column names

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoBrdquo means that the storage typeused for the geometry is Esri Binary The -G argument ldquo26910rdquo is the SRID of acoordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde_ss

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde_ss -u existinguser -p test -G 26910 -P 32 -t B

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int16smallintSE_INT16 4SMINT4COL

UnmappeduniqueidentifierSE_UUID 38ID

Int16smallintSE_INT16 4INT16COL

226 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int32intSE_INT32 10INT32COL

SinglerealSE_FLOAT32 6 2FLOAT32COL

DoublefloatSE_FLOAT64 7 2FLOAT64COL

Int32intSEINT32 10INT10

Singlenumeric(44)SE_FLOAT32 4 4FLOAT4_4

Singlenumeric(72)SE_FLOAT64 7 2DOUBLE7_2

Stringvarchar(64)SE_STRING 64STRING64

BLOBimageSE_BLOB 0BLOBCOL

UnmappedtextSE_CLOB 0CLOBCOL

Stringnvarchar(255)SE_NSTRING 255NSTRINGCOL

UnmappedntextSE_NCLOB 0NCLOBCOL

DateTimedateSE_DATE 0DATECOL

GeometryintSE_SHAPE 0FEATGEOM

FDO Provider for ArcSDE CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

FDO Provider for ArcSDE Capabilities | 227

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

locking

exclusive locking type

transactions

long transactions

SQL

multiple spatial contexts

specifying coordinate systems by name or ID without specifying WKT

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

228 | Appendix A OSGeo FDO Provider for ArcSDE

The following capabilities are supported

class and feature class class types

DateTime data type with a maximum length of 12 bytes

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 4294967296

BLOB data type with a maximum length of 4294967296

Int32 auto-generated data type

Identity properties of type DateTime Double Int16 Int32 Single Stringand BLOB

Name size limitation of 123 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 65 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 160 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 32 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite unique value constraints

Multiple schemas

Null value constraints

Unique value constraints

FDO Provider for ArcSDE Capabilities | 229

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ActivateSpatialContext

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLComnmand

FdoCommandType_AcquireLock

FdoCommandType_GetLockInfo

FdoCommandType_GetLockedObjects

FdoCommandType_GetLockOwners

FdoCommandType_ReleaseLock

FdoCommandType_ActivateLongTransaction

FdoCommandType_DeactivateLongTransaction

FdoCommandType_CommitLongTransaction

FdoCommandType_CreateLongTransaction

FdoCommandType_GetLongTransactions

230 | Appendix A OSGeo FDO Provider for ArcSDE

FdoCommandType_RollbackLongTransaction

FdoCommandType_ListDataStores

The following capabilities are supported

command parameterization

simple functions in Select and SelectAggregate commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

the Beyond and Within distance operations

spatial operations of type Contains Crosses Disjoint Equals IntersectsOverlaps Touches Within CoveredBy Inside and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic expressions are supported

The following functions are supported

Double Sum(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Int64 Count(lttypegt value) where lttypegt is one of Boolean Double SingleDecimal Byte DateTime Int16 Int32 Int64 String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

FDO Provider for ArcSDE Capabilities | 231

Double Avg(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double Max(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double StdDev(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

232 | Appendix A OSGeo FDO Provider for ArcSDE

OSGeo FDO Provider forMySQL

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor MySQL

What Is FDO Provider for MySQLThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for MySQL provides FDO withaccess to a MySQL-based data store

The FDO Provider for MySQL API provides custom commands that arespecifically designed to work with the FDO API For example using thesecommands you can do the following

Gather information about a provider

Transmit client services exceptions

Get lists of accessible data stores

Create connection objects

Create and execute spatial queries

The MySQL architecture supports different storage engines Choose an engineas needed depending on its characteristics and capabilities such as the following

MyISAM is a disk-based storage engine It does not support transactions

InnoDB is a disk-based storage engine It has full ACID transaction capability

B

233

Memory (Heap) is a storage engine utilizing only RAM It is very fast

NDB is the MySQL Cluster storage engine

MERGE is a variation of MyISAM A MERGE table is a collection of identicalMyISAM tables which means that all tables have the same columnscolumn types indexes and so on

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for MySQL API Reference Help(MySQL_Provider_APIchm)

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in thecommandrsquos class collection The mapping of logical FDO data types to nativetypes is described here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the numberof digits to the right of the decimal point The maximum number of digits in thenative type is 64

NOTE The definition of the FDO String data type requires that the length propertybe set

Native Data TypeFDO Data Type

tinyint(4)Boolean

tinyint(3) unsignedByte

datetimeDateTime

decimal(204)Decimal (precision = 20 scale = 4)

doubleDouble

smallint(6)Int16

234 | Appendix B OSGeo FDO Provider for MySQL

Native Data TypeFDO Data Type

int(11)Int32

bigint(20)Int64

doubleSingle

varchar(64)String (length is 64)

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The name of the schema is the concatenation of lsquoFdorsquo and the name of thedatabase This is the database created using the lsquoCREATE DATABASErsquo commandand containing the existing table(s) The table names are the class names andthe column names are the property names

NOTE The length of a bit field is in the range 1-64 A row in a column of typebit(64) can hold 64 bit values

NOTE The following native types are not mapped to FDO data types float floatunsigned real unsigned double unsigned binary varbinary tinyblob blobmediumblob longblob tinytext mediumtext and longtext

FDO Data TypeDefaultsNative Type

Booleanlength = 1bit(

Bytebit(2)

Int64bit(64)

Int16length = 4tinyint

Physical to Logical Schema Mapping | 235

FDO Data TypeDefaultsNative Type

Bytelength = 3tinyint unsigned

Int16length = 6smallint

Int32length = 5smallint unsigned

Int32length = 9mediumint

Int32length = 8mediumint unsigned

Int32length = 11int

Int64length = 10int unsigned

Int64length = 20bigint

Int64length = 20bigint unsigned

Doublereal

Doubledouble

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric unsigned

DateTimedate

DateTimedatetime

DateTimetimestamp

Int32year

236 | Appendix B OSGeo FDO Provider for MySQL

FDO Data TypeDefaultsNative Type

String (length = 192)char(64)

String (length = 192)varchar(64)

Stringenum

Stringset

FDO Provider for MySQL CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

transactions

FDO Provider for MySQL Capabilities | 237

SQL

multiple spatial contexts

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 95 digits (maximum decimalprecision of 65 and maximum decimal scale of 30)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 2147483647

Int64 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Datastore

238 | Appendix B OSGeo FDO Provider for MySQL

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Composite unique value constraints

Datastore scope unique ID generation

Default value

Exclusive value range constraints

Inclusive value range constraints

Inheritance

Multiple schemas

Null value constraints

Object properties

Unique value constraints

Schema modification

Schema overrides

Unique value constraints

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()

FDO Provider for MySQL Capabilities | 239

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

FdoCommandType_ListDataStores

FdoCommandType_DescribeSchemaMapping

FdoCommandType_SQLComnmand

FdoRdbmsCommandType_CreateSpatialIndex

FdoRdbmsCommandType_DestroySpatialIndex

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

240 | Appendix B OSGeo FDO Provider for MySQL

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

spatial operations of type Intersects and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic function and parameter expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Decimal Double SingleInt16 Int32 or Int64

Decimal Ceil(lttypegt value) where lttypegt is one of Decimal or Double

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single or String

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

FDO Provider for MySQL Capabilities | 241

Byte Min(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

Double Sum(lttypegt value) where lttypegt is one of Decimal Double Int16Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

242 | Appendix B OSGeo FDO Provider for MySQL

OSGeo FDO Provider forODBC

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ODBC

What Is FDO Provider for ODBCThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for ODBC provides FDO withaccess to an ODBC-based data store

The FDO Provider for ODBC can access simple x y z feature objects that canrun in a multi-platform environment including Windows Linux and UNIX

The FDO Provider for ODBC has the following characteristics

The FDO Provider for ODBC supports the definition of one or more featureclasses in terms of any relational database table that contains an X Y andoptionally Z columns

Metadata which maps the table name and X Y and optionally Z columnsto a feature class is maintained outside the database in a configuration fileThis information in conjunction with the table structure in the databaseprovides the definition of the feature class

The x y and z locations of objects are stored in separate properties in theprimary object definition of a feature but are accessible through a singleclass property lsquoGeometryrsquo

C

243

Read-only access is provided to pre-existing data defined and populatedthrough 3rd party applications (that is FDO Provider for ODBC will notbe responsible for defining the physical schema of the data store nor forpopulating the object data)

The schema configuration of the data store is provided to the FDO Providerfor ODBC through an optional XML file containing the Geographic MarkupLanguage (GML) definition of the schema that maps lsquotablesrsquo and lsquocolumnsrsquoin the data store to feature classes and property mappings in the FDO datamodel

NOTE Microsoft Excel (must have at least one named range do not use DATABASEor other reserved words as a range name)

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for ODBC API Reference Help (ODBC_Provider_APIchm)

Physical to Logical Schema MappingsMappings of data in three data sources a Microsoft Access database (an accdbfile) an Excel spreadsheet (xlsx file) and a text file to FDO data types areshown

Microsoft Access

Use the ODBC provider to connect to a Microsoft Access database

The schema name is ldquoFdordquo There is only one database per file so there canbe only one schema The table names are used for class names Column namesare used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are AutoNumberReplication ID NumberReplication ID and OLE objectThe mapping of the rest of the native data types is in the following table

244 | Appendix C OSGeo FDO Provider for ODBC

NOTE The AutoNumber Number and DateTime native types are sub-typed Ifa column named X and a column named Y both typed NumberDouble arepresent they are mapped to an FDO geometric property whose type is Point andwhose spatial context association property is ldquoDefaultrdquo

FDO TypeNative TypeSubType

Int32AutoNumberLong Integer

Notmapped

AutoNumberReplication ID

StringText

StringMemo

ByteNumberByte

Int16NumberInteger

Int32NumberLong Integer

SingleNumberSingle

DoubleNumberDouble

DecimalNumberDecimal

Notmapped

NumberReplication ID

DateTimeDateTimeGeneral Date

DateTimeDateTimeLong Date

DateTimeDateTimeMedium Date

DateTimeDateTimeShort Date

Physical to Logical Schema Mappings | 245

FDO TypeNative TypeSubType

DateTimeDateTimeLong Time

DateTimeDateTimeMedium Time

DateTimeDateTimeShort Time

DecimalCurrency

BooleanYesNo

Notmapped

OLE object

StringHyperlink

StringAttachment

Microsoft Excel

Use the ODBC provider to connect to an Excel file

The schema name is ldquoFdordquo There is only one schema per file The range namesare used for class names Column names are used for property names A columnname is a text entry in a cell that is at the top of a column as defined by theboundaries of the named range

If a column named X and a column named Y are present they are mappedto an FDO geometric property whose type is Point and whose spatial contextassociation property is ldquoDefaultrdquo

Three approaches were used to explore the mapping The first approach lookedat the effect of cell content the second approach looked at the effect of cellformat the third approach looked at the effect of both

The first approach involved copying data from a Microsoft Access databaseinto an Excel spreadsheet The copy operation created a named range thatincluded all of the copied data The name for the range came from the Accessdatabase By default all of the Excel cells have a format type of ldquoGeneralrdquo The

246 | Appendix C OSGeo FDO Provider for ODBC

accompanying table shows the mapping of sample cell content to FDO datatype

FDO TypeCell Content

Double2

Double6452067

StringRussia

Stringltemptygt

StringN

NOTE All of the data in each column was consistent The column containing ldquo2rdquocontained only positive integers The column containing ldquo6452067rdquo containedonly similar numbers including negative values The column containing the lsquoNrsquocontained only single characters that were either lsquoNrsquo or lsquoYrsquo The column containingldquoRussiardquo contained only names The column containing an empty cell containedonly empty cells

The second approach involved setting up a named range consisting of 9columns by 2 rows The cells of the first row are formatted as ldquoGeneralrdquo andcontain column labels The cells of the second row are formatted respectivelyldquoGeneralrdquo ldquoNumberrdquo ldquoCurrencyrdquo ldquoAccountingrdquo ldquoDaterdquo ldquoTimerdquoldquoPercentagerdquo ldquoFractionrdquo ldquoScientificrdquo and ldquoTextrdquo No cell in the second rowhas content The accompanying table shows the mapping of cell format toFDO data type

FDO TypeExcel Cell Format

StringGeneral

DoubleNumber

DecimalCurrency

DecimalAccounting

Physical to Logical Schema Mappings | 247

FDO TypeExcel Cell Format

DateTimeDate

DateTimeTime

DoublePercentage

DoubleFraction

DoubleScientific

StringText

The intent of the third approach is to understand how the mapping wouldbe affected by content that violated the cellrsquos format or was inconsistent withthe data in the rest of the column

Inserting ldquohererdquo in the cells formatted as Number Currency AccountingDate Time Percentage Fraction and Scientific caused them to be mapped toString

Inserting -1225 in the cell formatted as Currency caused no change in themapping to Decimal

Inserting 1225 in the cell formatted as Date caused no change in the mappingto DateTime Excel converted 1225 to ldquo1121900 60000 AMrdquo

Inserting ldquohererdquo in one of the cells in the column of integers copied from theAccess database resulted in no change to the mapping to Double This maybe a bug

Text File

Use the ODBC provider to connect to a text file You must first create a DSNusing the XP Data Sources (ODBC) administrative tool The DSN maps to adirectory not a file Each file in the directory is mapped to an FDO class

248 | Appendix C OSGeo FDO Provider for ODBC

NOTE When selecting the directory for the DSN you will notice a listing of thefiles recognized as text files by the driver It will recognize Vim backup files forexample Citiestxt~ as text files The execution of a describe schema commandon a directory containing a Vim backup file caused an exception whose messageis ldquoRDBMS [Microsoft][ODBC Text Driver] Cannot update Database or object isread-onlyrdquo Removal of the Vim backup file prevented this exception

The schema name is ldquoFdordquo There is only one schema per directory The classname is the name of the file for example ldquoCities_txtrdquo The property namesare taken from the first line in the file Here are the first two lines from acomma-delimited text file The property names are ldquoCITY_IDrdquo ldquoNAMErdquo etcThe table shows the mapping of the sample text to FDO data type

CITY_IDNAMECOUNTRYPOPULATIONCAPITALLATITUDELON

GITUDEURLFOUNDED

1MurmanskRussia468000N689633087172008 00000

FDO Data TypeSample Text

Int32468000

StringRussia

Double6896

Stringltemptygt

NOTE Changing ldquoLATITUDErdquo to ldquoYrdquo and ldquoLONGITUDErdquo to ldquoXrdquo causes these twofields to be mapped to a geometric property called ldquoGeometryrdquo whose spatialcontext association is to a spatial context called ldquoDefaultrdquo

FDO Provider for ODBC CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

FDO Provider for ODBC Capabilities | 249

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

SQL

XML configuration

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 56 digits (maximum decimalprecision of 28 and maximum decimal scale of 28)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

250 | Appendix C OSGeo FDO Provider for ODBC

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Auto-generated data types Int16 and Int64

Identity properties of type Boolean Byte and DateTime

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite ID

Default value

Inheritance

Multiple schemas

Null value constraints

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaning

FDO Provider for ODBC Capabilities | 251

of the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLCommand

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Intersects Within Inside and EnvelopeIntersects

252 | Appendix C OSGeo FDO Provider for ODBC

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The full range of expression functions are supported as set out in theCapabilities chapter

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZ is supported The Point geometry types is supported

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for ODBC Capabilities | 253

254

OSGeo FDO Provider forSDF

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SDF

What Is FDO Provider for SDFThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SDF is a standalone fileformat that supports GIS data

The FDO Provider for SDF uses Autodesks spatial database format which is afile-based personal geodatabase that supports multiple featuresattributes spatialindexing interoperability file-locking and high performance for large datasets

The SDF file format has the following characteristics

SDF files can be read on different platforms

The SDF file has its own spatial indexing

SDF files can store geometric and non-geometric data with minimumoverhead

Although it does not support concurrency control (locking) the SDF fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SDF API Reference Help (SDF_Provider_APIchm)

D

255

FDO Provider for SDF CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per command threaded

dynamic spatial content extent type

Write

Flush

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

256 | Appendix D OSGeo FDO Provider for SDF

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Int32 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Exclusive value range constraints

FDO Provider for SDF Capabilities | 257

Inclusive value range constraints

Inheritance

Null value constraints

Schema modification

Value constraints list

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

SdfCommandType_ExtendedSelect

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

258 | Appendix D OSGeo FDO Provider for SDF

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Contains Disjoint Inside Intersects Withinand EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty geomValue)

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBGeometricProperty AssociationProperty

Double Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

FDO Provider for SDF Capabilities | 259

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeometry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

260 | Appendix D OSGeo FDO Provider for SDF

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SDF Capabilities | 261

262

OSGeo FDO Provider forSHP

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SHP

What Is FDO Provider for SHPThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SHP provides FDO withaccess to an SHP-based data store

The FDO Provider for SHP uses a standalone file format that supports GIS dataThe FDO Provider for SHP (Shape) has the following characteristics

Read-only access is provided to pre-existing spatial and attribute data froman Environmental Systems Research Institute (ESRI) Shape file (SHP)

The FDO Provider for SHP can run in a multi-platform environmentincluding Windows and Linux

A Shape file consists of three separate files SHP (shape geometry) SHX (shapeindex) and DBF (shape attributes in dBASE format)

The FDO Provider for SHP accesses the information in each of the threeseparate files and treats each SHP and its associated DBF file as a featureclass with a single geometry property and optionally with data attributeproperties

Schema configuration of the data store is provided to the FDO Provider forSHP through an XML file containing the Geographic Markup Language

E

263

(GML) definition of the schema that maps SHP and DBF data in the datastore to feature classes and property mappings in the FDO data model

Although it does not support concurrency control (locking) the SHP fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SHP API Reference Help (SHP_Provider_APIchm)

Creating SHP Files for the Logical to PhysicalSchema Mapping

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The shape files used for the purpose of mapping FDO logical types to shapenative types were created using the following method The path argument isthe path to a filename whose pattern is ltbasegtshp The type argument specifiesthe type of the shape filersquos geometry for example ShapLibShapeTypePointExecution of the method creates the named ltbasegtshp file as well as altbasegtshx file

using MapTools

public bool CreateShpFile(string path ShapeLibShapeType type)

IntPtr hShp = ShapeLibSHPCreate(path type)

if (hShpEquals(IntPtrZero)) return false

else

ShapeLibSHPClose(hShp)

return true

The FDO ApplySchema creates the ltbasegtdbf and ltbasegtcpg It will alsocreate the ltbasegtprj file if a spatial context has been created and the nameof the coordinate system referenced by the spatial context definition has beenassigned to the feature geometric property definitionrsquos spatial contextassociation property

264 | Appendix E OSGeo FDO Provider for SHP

Creating SHP Files for the Physical to LogicalSchema Mapping

To do the physical to logical schema mapping requires shp files containingall possible shp data types Two approaches for creating such shp files havebeen used The first approach is to use the ArcSDE sde2shp command toconvert an ArcSDE schema to a shapefile schema The second approach is touse the ShapeLib C library to create the shapefiles

sde2shp

This command converts the contents of an ArcSDE data store into a set ofshape files The conversion is guided by a text specification that maps anArcSDE column name to a tuple consisting of a shape table column name ashape column type identifier a column width and optionally the number ofdeciaml places

The source ArcSDE data store for this exercise is that specified in the ArcSDEappendix in the topic about physical to logical schema mapping The datastore contained a table called ldquoExistingTablerdquo This table containing a geometrycolumn called ldquofeatgeomrdquo The featgeom column allows only point geometriesto be stored A shape geometry can only be of one type So for the conversionto work the ArcSDE geometry column has to be restricted to contain onlyone geometry type The source ArcSDE data store contained no data TheArcSDE geometry was created with a coordinate system specified

The syntax of the command follows sde2shp -o init -l

ExistingTablefeatgeom -f points -a file=pointstxt -t point -i

esri_sde_ss -u sde -p fdotest The -f argument becomes the root name ofthe shape files that are created by the command (pointsshp pointsshxpointsdbf pointsidx and pointsprj) The -t argument is the shape geometrytype The -i argument is the name of the ArcSDE server instance the symbolicname is mapped to a TCP port in theCWINDOWSsystem32driversetcservices file The -u and -p argumentsidentify a username and password in the data store The -a argument identifiesthe file used to specify the conversion of the non-geometry columnconversions

The contents of the pointstxt conversion file are as follows

Creating SHP Files for the Physical to Logical Schema Mapping | 265

smInt4Col smInt4 N 4

int16Col int16Col N 4

int32Col int32Col N 10

float32Col float32C N 6 2

float64Col float64C N 15 4

int10 Int10 N 10

float4_4 float4_4 N 4 3

double7_4 doubl7_2 N 7 2

string64 str64 C 64

nStringCol nStrCol C 254

dateCol dateCol D 8

NOTE Initial values for column widths and number of decimal places were takenfrom the output of the sdetable -o describe command These values were changedover the course of several executions of the sde2shp in response to warning anderror messages issued by the sde2shp command

ShapeLib

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The ltbasegtshp and ltbasegtshx files are created by the ShapeLibSHPCreatemethod

The ltbasegtprj file is created by using a text editor to create the file andinserting the WKT string specification for the coordinate system

The ltbasegtdbf file is created by the following code

IntPtr dbfFile = MapToolsShapeLibDBFCre

ate(Pointspointsdbf)

int logicalColNum = MapToolsShapeLibDBFAddField(dbfFile Logic

alCol ShapeLibDBFFieldTypeFTLogical 1 0)

int strColNum = MapToolsShapeLibDBFAddField(dbfFile StrCol

ShapeLibDBFFieldTypeFTString 64 0)

int dateColNum = MapToolsShapeLibDBFAddField(dbfFile DateCol

ShapeLibDBFFieldTypeFTDate 8 0)

int integer20_0Num = MapToolsShapeLibDBFAddField(dbfFile In

teger20 ShapeLibDBFFieldTypeFTInteger 20 0)

int double18_4Num = MapToolsShapeLibDBFAddField(dbfFile

Double18_4 ShapeLibDBFFieldTypeFTDouble 18 4)

MapToolsShapeLibDBFClose(dbfFile)

266 | Appendix E OSGeo FDO Provider for SHP

Logical to Physical Schema MappingThe SHP provider supports the DestroySchema and ApplySchema commandsSo it is possible to create shape files whose schema has been defined usingFDO and then map the logical FDO data types to the shape native types Thismapping is described here The creation of the shape file used for this purposeis described in this appendix

Native Type Column Width Decimal PlacesFDO Type

L 1Boolean

D 8DateTime

N gt0 gt0Decimal

N 11Int32

C gt0String

Physical to Logical Schema MappingWhen FDO describes the schema of an existing shapefile that was not createdby the ApplySchema command it maps native data types to FDO data typesTwo shapfiles have been mapped One shapfile has been created using theArcSDE command sde2shp The creation of the source ArcSDE schema isdescribed in the appendix for the ArcSDE provider The other shapfile hasbeen created using a NET wrapper for the ShapeLib C Library These twomethods for creating shapefiles are described in this appendix

The schema name is ldquoDefaultrdquo The class name is the root name of the fileFor example if the filename is ldquopointsshprdquo the class name is ldquopointsrdquo Theattribute property names are the dBASE column names The geometry propertyname is ldquoGeometryrdquo The value of the feature classrsquos SpatialContextAssociationproperty is the name of the coordinate system specified in the prj file Forexample if the coordinate system specification in the prj has the patternldquoPROJCS[]rdquo the value of the SpatialContextAssociation proerty is the valueof the ltnamegt parameter in the pattern ldquoPROJCS[ltnamegt]rdquo

Logical to Physical Schema Mapping | 267

sde2shp

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat came from the conversion of an ArcSDE schema is in the following table

FDO Data TypeNative Type Column Width DecimalPlaces

DecimalN 4

DecimalN 10

DecimalN 6 2

DecimalN 15 4

DecimalN 4 3

DecimalN 7 2

StringC

DateTimeD

ShapeLib

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat was created by a ShapeLib program is in the following table

FDO Data TypeNative Type Column Width Decimal Places

BooleanL 1

StringC 64

DateTimeD 8

DecimalN 20 0

268 | Appendix E OSGeo FDO Provider for SHP

FDO Data TypeNative Type Column Width Decimal Places

DecimalN 18 4

FDO Provider for SHP CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

multiple spatial contexts

Write

Multi-user write

Flush

FDO Provider for SHP Capabilities | 269

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 255 digits (maximum decimalprecision of 255 and maximum decimal scale of 255)

Int32 data type with a maximum length of 4 bytes

String data type with a maximum length of 255

Int32 auto-generated data type

Identity properties of type Int32

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 7 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 11 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 0 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Multiple schemas

Null value constraints

270 | Appendix E OSGeo FDO Provider for SHP

Schema modification

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

FDO Provider for SHP Capabilities | 271

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Within Inside Intersects EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleSingle Int16 Int32 or Int64

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

272 | Appendix E OSGeo FDO Provider for SHP

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

GeometricProperty SpatialContexts(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SHP Capabilities | 273

274

OSGeo FDO Provider forSQL Server Spatial

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in the commandrsquosclass collection The mapping of logical FDO data types to native types isdescribed here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the number ofdigits to the right of the decimal point The maximum number of digits in the nativetype is 38

NOTE The definition of the FDO String data type requires that the length propertybe set

Native TypeFDO Data Type

bitBoolean

tinyintByte

datetimeDateTime

decimal(204)Decimal (precision property is set to 20and scale property is set to 4)

F

275

Native TypeFDO Data Type

floatDouble

smallintInt16

intInt32

bigintInt64

realSingle

nvarchar(64)String (length property set to 64)

geographygeometry with a geodetic coordinate sys-tem

geometrygeometry with a Euclidean coordinate sys-tem

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The database name is used for the feature schema name The table names areused for class names Column names are used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are date datetim2(7) datetimeoffset(7) hierarchyid sql_variatn time(7)and xml The mapping of the rest of the native data types is in the followingtable

276 | Appendix F OSGeo FDO Provider for SQL Server Spatial

NOTE The geography and geometric native types map to the geometric propertytype FDO properties are classified as data geometric object association or rasterOnly the data properties are further classified

FDO TypeNative Type

Int64bigint

BLOBbinary(50)

Booleanbit

Stringchar(10)

DateTimedatetime

Decimaldecimal(180)

Doublefloat

Geometricgeography

Geometricgeometry

BLOBimage

Int32int

Decimalmoney

Stringnchar(10)

Stringntext

Decimalnumeric(180)

Stringnvarchar(50)

Physical to Logical Schema Mapping | 277

FDO TypeNative Type

Stringnvarchar(MAX)

Singlereal

DateTimesmalldatetime

Int16smallint

Decimalsmallmoney

Stringtext

DateTimetimestamp

Bytetinyint

Stringuniqueidentifier

BLOBvarbinary(50)

Stringvarchar(50)

BLOBvarbinary(MAX)

278 | Appendix F OSGeo FDO Provider for SQL Server Spatial

OSGeo FDO Provider forWFS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WFS

What Is FDO Provider for WFSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WFS provides FDO withaccess to a WFS-based data store

An OGC Web Feature Service (WFS) provides access to geographic features thatare stored in an opaque data store in a clientserver environment A client usesWFS to retrieve geospatial data that is encoded in Geography Markup Language(GML) from a single or multiple Web Feature Service The communicationbetween client and server is encoded in XML If the WFS response includesfeature geometries it is encoded in Geography Markup Language (GML) whichis specified in the OpenGIS Geographic Markup Language ImplementationSpecification

Using FDO Provider for WFS data manipulation operations you can do thefollowing

Query features based on spatial and non-spatial constraints

Create new feature instances

Delete feature instances

Update feature instances

G

279

Lock feature instances

For more information see The Essential FDO (FET_TheEssentialFDOpdf)

NOTE There is no public API documentation for the FDO Provider for WFSfunctionality is available through the main FDO API

FDO Provider for WFS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threaded

static spatial content extent type

multiple spatial contexts

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()

280 | Appendix G OSGeo FDO Provider for WFS

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of unknown bytes

Byte data type with a maximum length of unknown bytes

DateTime data type with a maximum length of unknown bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of unknown bytes

Int16 data type with a maximum length of unknown bytes

Int32 data type with a maximum length of unknown bytes

Int64 data type with a maximum length unknown 8 bytes

Single data type with a maximum length of unknown bytes

String data type with a maximum length of unknown

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name (null)

Composite ID

FDO Provider for WFS Capabilities | 281

Multiple schemas

Object properties

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_GetSpatialContexts

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

use of expressions for properties in Select and SelectAggregates commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

282 | Appendix G OSGeo FDO Provider for WFS

Basic expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeoemtry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

FDO Provider for WFS Capabilities | 283

No Raster capabilities are supported

284 | Appendix G OSGeo FDO Provider for WFS

OSGeo FDO Provider forWMS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WMS

What Is FDO Provider for WMSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WMS provides FDO withaccess to a WMS-based data store

An Open Geospatial Consortium (OGC) Web Map Service (WMS) producesmaps of spatially referenced data dynamically from geographic informationThis international standard defines a map to be a portrayal of geographicinformation as a digital image file suitable for display on a computer screen Amap is not the data itself Maps by WMS are generally rendered in a pictorialformat such as PNG GIF or JPEG or occasionally as vector-based graphicalelements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile(WebCGM) formats

The FDO Provider for WMS has the following characteristics

The FDO Provider for WMS serves up map information originating from anOGC Basic Web Map Service that provides pictorially formatted images suchas PNG GIF or JPEG

WMS map data is exposed through an FDO feature schema whose classescontain an FDO Raster property definition The FDO schema exposed fromthe FDO Provider for WMS conforms to a pre-defined FDO schema that is

H

285

specific to WMS and that acts as the basis for all FDO interaction withWMS data regardless of the originating source of the WMS images

WMS data manipulation operations are limited to querying features basedon spatial and non-spatial constraints Schema manipulation operationsare not supported

The FDO Provider for WMS can run in a multi-platform environmentincluding Windows and Linux

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for WMS API Reference Help (WMS_Provider_APIchm)

FDO Provider for WMS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

286 | Appendix H OSGeo FDO Provider for WMS

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

String data type with a maximum length of unknown

BLOB data type with a maximum length of unknown bytes

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Inheritance

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FDO Provider for WMS Capabilities | 287

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_GetSpatialContexts

The following capabilities are supported

simple functions in Select and SelectAggregate commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No filter capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Function expressions are supported

The following functions are supported

BLOB RESAMPLE(BLOB raster Double minX Double minY Double maxXDouble maxY Int32 height Int32 width)

BLOB CLIP(BLOB raster Double minX Double minY Double maxX DoublemaxY)

GeometricProperty SpatialExtents(BLOB raster)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaning

288 | Appendix H OSGeo FDO Provider for WMS

of the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Polygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

The Raster capability is supported The following raster data models aresupported

Bitonal1-bitpixelUnsigned Integer

Gray8-bitpixelUnsigned Integer

RGB24-bitpixelUnsigned Integer

RGBA32-bitpixelUnsigned Integer

Palette8-bitpixelUnsigned Integer

FDO Provider for WMS Capabilities | 289

290

Index

A

AGF 152API

defined 5FDO 5

application development 11architecture and packages 8ArcSDE

limitations 212ArcSDE Provider 211

Capabilities 227 237 249 256 269 280 286

Software Requirements 211association property 15Autodesk Geometry Format (AGF) 152

B

behaviors GisPtr 25BinaryOperations 146

C

calls chain 25capabilities

FDO Provider for ArcSDE 227 237 249 256 269 280 286

classcontained 91feature 14IdentityProperty and

ObjectProperty 91ndash92standalone 91

Class Diagram FDO Schema Element 93class type 14collection classes 23comparison operations 146connection

ArcSDE 216establishing 29

semantics 27constraints expression text 141constraints filter text 141constraints provider-specific 141Contained Class 91context spatial 18

D

data concepts 13data property

defined 15data sources and data stores 27data store 18

defined 18FDO Provider for ArcSDE 211FDO Provider for MySQL 233FDO Provider for ODBC 243FDO Provider for SDF 255FDO Provider for SHP 263FDO Provider for WMS 285filtering 19 139locking 19querying 129schemas and the 85transactions 20

data stores data sources and 27data type

DATETIME 145DOUBLE 145IDENTIFIER 144INTEGER 145PARAMETER 144STRING 144

data type mappings 217data types 144DataStore

FDO Provider for ArcSDE 211develop applications 11dimensionality defined 15

Index | 291

E

edit a GML schema file 101element states schema 94elements of a schema 14example

creating a schema 111creating a schema read in from an

XML file 114deleting property values 127describing a schema 114destroying a schema 114inserting an Integer a string and a

Geometry Value 122query 130schema management 111updating property values 125

expression grammar 143expression text 140Expression defined 19expressions 140

F

factory abstract geometry 159FDO

architecture and packages 8FDO API

defined 5FDO concepts

commands 18data store 18expression 19feature class 14filter 19geometry property 16locking 19object property 17property 15spatial context 18transactions 20

FDO In General 161FDO Provider for ArcSDE

capabilities 227 237 249 256 269 280 286

connection 216

defined 211software requirements 211

FDO Provider for MySQLdefined 233

FDO Provider for ODBCdefined 243

FDO Provider for SDF 255defined 255

FDO Provider for SDF defined 255FDO Provider for SHP

defined 263FDO Provider for WMS

defined 285FDO schema element class diagram 93FDO XML format 95FDOClass 90FDOFeatureClass 90FDOIActivateLongTransaction 136FDOICommitLongTransaction 137FDOICreateLongTransaction 137FDOIDeactivateLongTransaction 136FDOIGetLongTransactions 137FDOIRollbackLongTransaction 136feature class 14feature schema creating a 218filter

grammar 141Filter 139

defined 19filter text 140filters 19

G

geometric types mapping betweenGeometry and 160

geometry 16Geometry

basic or pure 152properties 16types 159value 147working with 151

geometry and geometric types mappingbetween 160

Geometry API 151

292 | Index

GIS_SAFE_RELEASE (ptr) 21ndash22GisPtr 22GML schema file creating and

editing 101

H

handler exception 23

K

keywords filter and expression 144

L

locking 19ArcSDE limitations 213defined 19

long transactiondefined 135leaf 135root 20 135ndash136

M

mappingsdata type 217physical 86

memory management 21models modifying 94

N

non-feature class issues 91non-smart ptr 26

O

object propertydefined 17

ObjectProperty types 90OGC WKT 151operations comparison 146operations data maintenance 119

operator precedence 146operators 146overrides

schema 88

P

packageconnections 27Schema 85

packages FDO 8parent in the schema classes 86properties

base 85Geometry 16

propertyassociation 15data 15defined 15object 17Raster 17

property definitions adding GMLfor 105

property values 120data 120geometry 121

Provider for ArcSDEconnection 216defined 211

Provider for MySQLdefined 233

Provider for ODBCdefined 243

Provider for SHPdefined 263

provider defined 9

Q

querycreating 129example 130

Index | 293

R

raster propertydefined 17

references cross-schema 86requirements

FDO Provider for ArcSDE 211rollback mechanism schema 95root long transaction defined 20

S

SampleFeatureSchemaxml 115schema

defined 13schema elements 14

schema management 111schema mapping defined 14schema overrides 14schema create 89 218schemas

describing 92element states 94modifying models 94rollback mechanism 95working with 88

SDFFDO Provider for 255

software requirements 211spatial context 161spatial context defined 18special characters 147

standalone class 91states schema element 94supported interfaces LT 136

T

text expression 140text filter 140transaction long 20types

Geometry 159ObjectProperty 90

U

UnaryOperations 146

V

valuesdeleting 126updating 125

W

WKT 151

X

XML Format FDO 95

294 | Index

  • Contents
  • About This Guide
    • Audience and Purpose
    • How This Guide Is Organized
    • Whatrsquos New
      • Introduction
        • What Is the FDO API
          • From the Perspective of the Client Application User
          • From the Perspective of the Client Application Engineer
            • Getting Started
            • FDO Architecture and Providers
            • What Is a Provider
            • Developing Applications
              • FDO Concepts
                • Data Concepts
                • Operational Concepts
                  • Development Practices
                    • Memory Management
                    • Collections
                    • Exception Handling
                    • Exception Messages
                    • Managing FdoPtr Behaviors
                      • Establishing a Connection
                        • Connection Semantics
                        • Establishing a Connection
                          • FDO Capabilities
                            • FDO Capabilities
                              • Introduction
                              • Provider Type
                              • Command
                              • Connection
                              • Expression
                              • Filter
                              • Geometry
                              • Raster
                              • Schema
                                • Expressible as Boolean
                                • Not Expressible as a Boolean
                                  • Schema Management
                                    • Schema Package
                                    • Schema Mappings
                                    • Schema Overrides
                                    • Working with Schemas
                                    • FDOFeatureClass
                                    • FDOClass
                                    • Non-Feature Class Issues
                                    • Modifying Models
                                    • Schema Element States
                                    • Rollback Mechanism
                                    • FDO XML Format
                                    • Creating and Editing a GML Schema File
                                    • Schema Management Examples
                                      • Data Maintenance
                                        • Data Maintenance Operations
                                          • Inserting Values
                                          • Updating Values
                                          • Deleting Values
                                            • Related Class Topics
                                              • Performing Queries
                                                • Creating a Query
                                                • Query Example
                                                  • Long Transaction Processing
                                                    • What Is Long Transaction Processing
                                                    • Supported Interfaces
                                                      • Filter and Expression Languages
                                                        • Filters
                                                        • Expressions
                                                        • Filter and Expression Text
                                                        • Language Issues
                                                          • Provider-Specific Constraints on Filter and Expression Text
                                                          • Filter Grammar
                                                          • Expression Grammar
                                                          • Filter and Expression Keywords
                                                          • Data Types
                                                            • Identifier
                                                            • Parameter
                                                            • String
                                                            • Integer
                                                            • Double
                                                            • DateTime
                                                              • Operators
                                                              • Special Character
                                                              • Geometry Value
                                                                  • The Geometry API
                                                                    • Introduction
                                                                    • FGF and WKB
                                                                    • FGF Binary Specification
                                                                    • FGF Text
                                                                    • Abstract and Concrete Classes
                                                                    • Geometry Types
                                                                    • Mapping Between Geometry and Geometric Types
                                                                    • Spatial Context
                                                                    • Specify Dimensionality When Creating Geometries Using String Specifications
                                                                    • Inserting Geometry Values
                                                                      • FDO Cookbook
                                                                        • Introduction
                                                                        • Recommendations
                                                                        • Registry
                                                                        • Connection
                                                                        • Capabilities
                                                                        • Data Store
                                                                        • User Management
                                                                        • Spatial Context
                                                                        • Basic Schema Operations
                                                                        • Insert Data
                                                                        • Select Data
                                                                        • Select Aggregate Data
                                                                        • Delete Data
                                                                        • Schema Overrides
                                                                        • Xml SerializeDeserialize
                                                                          • C
                                                                            • Geometry
                                                                              • Construction
                                                                                • C Namespaces
                                                                                • C Geometry Scaffolding Classes
                                                                                • C Geometries Constructed using IDirectPositionImpl
                                                                                • C Geometries Constructed Using Geometry Subcomponents
                                                                                • C Aggregate Geometries
                                                                                • C Geometries from Text Specifications
                                                                                  • Deconstruction
                                                                                      • OSGeo FDO Provider for ArcSDE
                                                                                        • What Is FDO Provider for ArcSDE
                                                                                        • FDO Provider for ArcSDE Software Requirements
                                                                                          • Installed Components
                                                                                          • External Dependencies
                                                                                            • FDO Provider for ArcSDE Limitations
                                                                                            • ArcSDE Limitations
                                                                                              • Relative to ArcObjects API and ArcGIS Server API
                                                                                                • Curved Segments
                                                                                                  • Locking and Versioning
                                                                                                    • Table Creation
                                                                                                    • Identity Row ID Column and Enable Row Locking
                                                                                                    • Disable Row Locking and Enable Versioning
                                                                                                        • FDO Provider for ArcSDE Connection
                                                                                                        • Data Type Mappings
                                                                                                        • Creating a Feature Schema
                                                                                                        • Logical to Physical Schema Mapping
                                                                                                        • Physical to Logical Schema Mapping
                                                                                                        • FDO Provider for ArcSDE Capabilities
                                                                                                          • OSGeo FDO Provider for MySQL
                                                                                                            • What Is FDO Provider for MySQL
                                                                                                            • Logical to Physical Schema Mapping
                                                                                                            • Physical to Logical Schema Mapping
                                                                                                            • FDO Provider for MySQL Capabilities
                                                                                                              • OSGeo FDO Provider for ODBC
                                                                                                                • What Is FDO Provider for ODBC
                                                                                                                • Physical to Logical Schema Mappings
                                                                                                                • FDO Provider for ODBC Capabilities
                                                                                                                  • OSGeo FDO Provider for SDF
                                                                                                                    • What Is FDO Provider for SDF
                                                                                                                    • FDO Provider for SDF Capabilities
                                                                                                                      • OSGeo FDO Provider for SHP
                                                                                                                        • What Is FDO Provider for SHP
                                                                                                                        • Creating SHP Files for the Logical to Physical Schema Mapping
                                                                                                                        • Creating SHP Files for the Physical to Logical Schema Mapping
                                                                                                                        • Logical to Physical Schema Mapping
                                                                                                                        • Physical to Logical Schema Mapping
                                                                                                                        • FDO Provider for SHP Capabilities
                                                                                                                          • OSGeo FDO Provider for SQL Server Spatial
                                                                                                                            • Logical to Physical Schema Mapping
                                                                                                                            • Physical to Logical Schema Mapping
                                                                                                                              • OSGeo FDO Provider for WFS
                                                                                                                                • What Is FDO Provider for WFS
                                                                                                                                • FDO Provider for WFS Capabilities
                                                                                                                                  • OSGeo FDO Provider for WMS
                                                                                                                                    • What Is FDO Provider for WMS
                                                                                                                                    • FDO Provider for WMS Capabilities
                                                                                                                                      • Index
Page 3: here - OSGeo Download Server

Contents

Chapter 1 About This Guide 1Audience and Purpose 1How This Guide Is Organized 1Whatrsquos New 3

Chapter 2 Introduction 5What Is the FDO API 5

From the Perspective of the Client Application User 5From the Perspective of the Client Application Engineer 5

Getting Started 6FDO Architecture and Providers 7What Is a Provider 9Developing Applications 11

Chapter 3 FDO Concepts 13Data Concepts 13Operational Concepts 18

Chapter 4 Development Practices 21Memory Management 21Collections 23Exception Handling 23

iii

Exception Messages 24Managing FdoPtr Behaviors 25

Chapter 5 Establishing a Connection 27Connection Semantics 27Establishing a Connection 29

Chapter 6 FDO Capabilities 35FDO Capabilities 35

Introduction 35Provider Type 36Command 37Connection 43Expression 47Filter 74Geometry 77Raster 78Schema 79

Expressible as Boolean 82Not Expressible as a Boolean 83

Chapter 7 Schema Management 85Schema Package 85Schema Mappings 87Schema Overrides 88Working with Schemas 88FDOFeatureClass 90FDOClass 90Non-Feature Class Issues 91Modifying Models 94Schema Element States 94Rollback Mechanism 95FDO XML Format 95Creating and Editing a GML Schema File 101Schema Management Examples 111

Chapter 8 Data Maintenance 119Data Maintenance Operations 119

Inserting Values 119Updating Values 125Deleting Values 126

Related Class Topics 127

iv | Contents

Chapter 9 Performing Queries 129Creating a Query 129Query Example 130

Chapter 10 Long Transaction Processing 135What Is Long Transaction Processing 135Supported Interfaces 136

Chapter 11 Filter and Expression Languages 139Filters 139Expressions 140Filter and Expression Text 140Language Issues 141

Provider-Specific Constraints on Filter and Expression Text 141Filter Grammar 141Expression Grammar 143Filter and Expression Keywords 144Data Types 144

Identifier 144Parameter 144String 144Integer 145Double 145DateTime 145

Operators 146Special Character 147Geometry Value 147

Chapter 12 The Geometry API 151Introduction 151FGF and WKB 151FGF Binary Specification 152FGF Text 158Abstract and Concrete Classes 158Geometry Types 159Mapping Between Geometry and Geometric Types 160Spatial Context 161Specify Dimensionality When Creating Geometries Using String

Specifications 161Inserting Geometry Values 162

Chapter 13 FDO Cookbook 163Introduction 163

Contents | v

Recommendations 163Registry 163Connection 164Capabilities 168Data Store 171User Management 173Spatial Context 175Basic Schema Operations 178Insert Data 181Select Data 182Select Aggregate Data 183Delete Data 184Schema Overrides 184Xml SerializeDeserialize 194

C 1 9 4Geometry 196

Construction 196C Namespaces 197C Geometry Scaffolding Classes 197C Geometries Constructed using

IDirectPositionImpl 200C Geometries Constructed Using Geometry

Subcomponents 201C Aggregate Geometries 202C Geometries from Text Specifications 204

Deconstruction 204

Appendix A OSGeo FDO Provider for ArcSDE 211What Is FDO Provider for ArcSDE 211FDO Provider for ArcSDE Software Requirements 211

Installed Components 211External Dependencies 212

FDO Provider for ArcSDE Limitations 212ArcSDE Limitations 212

Relative to ArcObjects API and ArcGIS Server API 213Curved Segments 213

Locking and Versioning 213Table Creation 214Identity Row ID Column and Enable Row Locking 214Disable Row Locking and Enable Versioning 215

FDO Provider for ArcSDE Connection 216Data Type Mappings 217Creating a Feature Schema 218Logical to Physical Schema Mapping 223Physical to Logical Schema Mapping 223FDO Provider for ArcSDE Capabilities 227

vi | Contents

Appendix B OSGeo FDO Provider for MySQL 233What Is FDO Provider for MySQL 233Logical to Physical Schema Mapping 234Physical to Logical Schema Mapping 235FDO Provider for MySQL Capabilities 237

Appendix C OSGeo FDO Provider for ODBC 243What Is FDO Provider for ODBC 243Physical to Logical Schema Mappings 244FDO Provider for ODBC Capabilities 249

Appendix D OSGeo FDO Provider for SDF 255What Is FDO Provider for SDF 255FDO Provider for SDF Capabilities 256

Appendix E OSGeo FDO Provider for SHP 263What Is FDO Provider for SHP 263Creating SHP Files for the Logical to Physical Schema Mapping 264Creating SHP Files for the Physical to Logical Schema Mapping 265Logical to Physical Schema Mapping 267Physical to Logical Schema Mapping 267FDO Provider for SHP Capabilities 269

Appendix F OSGeo FDO Provider for SQL Server Spatial 275Logical to Physical Schema Mapping 275Physical to Logical Schema Mapping 276

Appendix G OSGeo FDO Provider for WFS 279What Is FDO Provider for WFS 279FDO Provider for WFS Capabilities 280

Appendix H OSGeo FDO Provider for WMS 285What Is FDO Provider for WMS 285FDO Provider for WMS Capabilities 286

Index 291

Contents | vii

viii

About This Guide

The FDO Developerrsquos Guide introduces the Feature Data Objects (FDO) application programminginterface (API) and explains how to use its customization and development features

NOTE For detailed information about installing the FDO SDK and getting started usingthe FDO API see The Essential FDO (FET_TheEssentialFDO)

Audience and PurposeThis guide is intended to be used by developers of FDO applications It introducesthe FDO API explains the role of a feature provider and provides detailedinformation and examples about how to code your application

How This Guide Is OrganizedThis guide consists of the following chapters and appendixes

Introduction provides an overview of the FDO API and the function of FDOfeature providers

FDO Concepts on page 13 describes the key data and operational conceptsupon which FDO is constructed

Development Practices on page 21 discusses the best practices to followwhen using FDO for application development

Establishing a Connection on page 27 describes how to establish aconnection to an FDO provider

1

1

Capabilities discusses the Capabilities API which is used to determine thecapabilities of a particular provider

Schema Management on page 85 describes how to create and work withschemas and presents the issues related to schema management

Data Maintenance on page 119 provides information about using the FDOAPI to maintain the data

Performing Queries on page 129 describes how to create and performqueries

Long Transaction Processing on page 135 discusses long transactions (LT)and how to implement LT processing in your application

Filter and Expression Languages on page 139 discusses the use of filterexpressions to specify to an FDO provider how to identify a subset of theobjects of an FDO data store

The Geometry API on page 151 discusses the various Geometry types andformats and describes how to work with the Geometry API to developFDO-based applications

OSGeo FDO Provider for ArcSDE on page 211 discusses development issuesthat apply when using FDO Provider for ESRIreg ArcSDEreg

OSGeo FDO Provider for MySQL on page 233 discusses development issuesthat apply when using FDO Provider for MySQL

OSGeo FDO Provider for ODBC on page 243 discusses development issuesthat apply when using FDO Provider for ODBC

OSGeo FDO Provider for SDF on page 255 discusses development issuesthat apply when using FDO Provider for SDF

OSGeo FDO Provider for SHP on page 263 discusses development issuesthat apply when using FDO Provider for SHP (Shape)

OSGeo FDO Provider for WFS on page 279 discusses development issuesthat apply when using FDO Provider for WFS

OSGeo FDO Provider for WMS on page 285 discusses development issuesthat apply when using FDO Provider for WMS

Expression Functions outlines the signatures and implementation detailsfor the enhanced expression functions

2 | Chapter 1 About This Guide

Whatrsquos NewThis section summarizes the changes and enhancements you will find in thisversion of FDO

Enhanced Set of Expression Functions

The enhanced set includes aggregate conversion date mathematical numericstring and geometry functions All functions are supported by all providerswith the exception of the Raster WFS and WMS providers

For more information and implementation details about the expressionfunction signatures the RDBMS-specific built-in support for some of thefunctions and the provider-specific support see the appendix ExpressionFunctions

Whatrsquos New | 3

4

Introduction

You can use the APIs in the FDO API to manipulate define and analyze geospatial information

This chapter introduces application development with the FDO API and explains the role ofa feature provider

What Is the FDO API

From the Perspective of the Client Application User

The FDO API is a set of APIs used for creating managing and examininginformation enabling Autodesk GIS products to seamlessly share spatial andnon-spatial information with minimal effort

FDO is intended to provide consistent access to feature data whether it comesfrom a CAD-based data source or from a relational data store that supports richclassification To achieve this FDO supports a model that can readily supportthe capabilities of each data source allowing consumer applications functionalityto be tailored to match that of the data source For example some data sourcesmay support spatial queries while others do not Also a flexible metadata modelis required in FDO allowing clients to adapt to the underlying feature schemaexposed by each data source

From the Perspective of the Client ApplicationEngineer

The FDO API provides a common general purpose abstraction layer for accessinggeospatial data from a variety of data sources The API is in part an interface

2

5

specification of the abstraction layer A provider such as OSGeo FDO Providerfor MySQL is an implementation of the interface for a specific type of datasource (for example for a MySQL relational database) The API supports thestandard data store manipulation operations such as querying updatingversioning locking and others It also supports analysis

The API includes an extensive set of methods that return information aboutthe capabilities of the underlying data source For example one methodindicates whether the data source supports the creation of multiple schemasand another indicates whether the data source supports schema modification

A core set of services for providers is also available in the API such as providerregistration schema management filter and expression construction andXML serialization and deserialization

The API uses an object-oriented model for the construction of feature schemaA feature is a class and its attributes including its geometry are a propertyof the class The instantiation of a feature class a Feature Data Object (FDO)can contain other FDOs

Getting StartedFor detailed information to help you install and get started using Feature DataObjects (FDO) see The Essential FDO It provides details about connecting toand configuring providers data store management (createdelete) user IDs(create grant permissions) and spatial context

6 | Chapter 2 Introduction

FDO Architecture and ProvidersThe following diagram shows the high-level overview architecture of the FDOAPI and included FDO providers

FDO Architecture and Providers | 7

FDO Architecture and Providers

FDO Packages

FDO is assembled in conceptual packages of similar functionality Thisconceptual packaging is reflected in the substructure of the FDO SDK ldquoincludesrdquofolder For more information about the structure see The Essential FDO

FDO commands provider-specific commands and connections and capabilitiesprovide access to native data stores through each different FDO providerSchema management (through XML) client services and filters and expressionsare provider-independent packages that tie into the FDO API Each of theseare explained in more detail in subsequent sections

8 | Chapter 2 Introduction

The FDO API consists of classes grouped within the following packages

Commands package Contains a collection of classes that provide thecommands allowing the application to select and update features definenew types of feature classes lock features and perform analysis on featuresEach Command object executes a specific type of command against theunderlying data store In addition FDO providers expose one or moreCommand objects

ConnectionsCapabilities Contains a collection of classes that establishand manage the connection to the underlying data store Connectionobjects implement the FdoIConnection interface Capabilities API providesthe code for retrieving the various FDO provider capability categories suchas connection or schema capabilities You can use this this API to determinethe capabilities of a particular provider

Filters and Expression package Contains a collection of classes that definefilters and expression in FDO which are used to identify a subset of objectsof an FDO data store

Client Services package Contains a collection of classes that define theclient services in FDO that for example enable support for dynamiccreation of connection objects given a provider name

Schema package and FDO XML Contains a collection of classes thatprovides a logical mechanism for specifying how to represent geospatialfeatures The FDO feature schema is based somewhat on a subset of theOpenGIS and ISO feature models FDO feature schemas can be written toan XML file The FdoFeatureSchema and FdoFeatureSchemaCollectionclasses support the FdoXmlSerializable interface

In addition FDO is integrated with the Geometry API which includes theclasses that support specific Autodesk applications and APIs including FDO

For more information about each of the FDO packages see FDO API ReferenceHelp and subsequent chapters in this guide

Provider API(s) complete the FDO API configuration Each provider has aseparate API reference Help

What Is a ProviderA provider is a specific implementation of the FDO API It is the softwarecomponent that provides access to data in a particular data store

What Is a Provider | 9

For this release the providers that are included are as follows

NOTE For more information see the Open Source Geospatial Foundation websiteat wwwOSGeoorg

OsGeo FDO Provider for ArcSDE Readwrite access to feature data in anESRI ArcSDE-based data store (that is with an underlying Oracle or SQLServer database) Supports describing schema and inserting selectingupdating and deleting feature data in existing schemas does not supportcreating or deleting schemas

OsGeo FDO Provider for MySQL Readwrite access to feature data in aMySQL-based data store Supports spatial data types and spatial queryoperations A custom API can gather information transmit exceptions listdata stores and create connection objects MySQL architecture supportsvarious storage engines characteristics and capabilities

OsGeo FDO Provider for ODBC Readwrite access to feature data in anODBC-based data store Supports XYZ feature objects and can define featureclasses for any relational database table with X Y and optionally Zcolumns does not support creating or deleting schema Object locationsare stored in separate properties in the object definition

OsGeo FDO Provider for SDF Read-write access to feature data in anSDF-based data store Autodeskrsquos geospatial file format SDF supportsmultiple featuresattributes provides high performance for large data setsand interoperability with other Autodesk products and spatial indexingThe SDF provider a valid alternative to database storage Note that thisrelease of the SDF provider supports version 30 of the SDF file format

OsGeo FDO Provider for SHP Readwrite access to existing spatial andattribute data in an ESRI SHP-based data store which consists of separateshape files for geometry index and attributes Each SHP and its associatedDBF file is treated as a feature class with a single geometry property Thisis a valid alternative to database storage but does not support locking

OsGeo FDO Provider for WFS Read-only access to feature data in an OGCWFS-based data store Supports clientserver environment and retrievesgeospatial data encoded in GML from one or more Web Feature Servicessites Clientserver communication is encoded in XML with the exceptionof feature geometries which are encoded in GML Note that there is nopublic API documentation for this provider all functionality is accessiblevia the base FDO API

10 | Chapter 2 Introduction

OsGeo FDO Provider for WMS Read-only access to feature data in an OGCWMS-based data store Web Map Service (WMS) produces maps of spatiallyreferenced data dynamically from geographic information which aregenerally rendered in PNG GIF or JPEG or as vector-based Scalable VectorGraphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats

FDO supports retrieval and update of spatial and non-spatial GIS feature datathrough a rich classification model that is based on OpenGIS and ISOstandards

An overview of the relationships between providers data sources data storesand schemas is presented in the FDO Architecture and Providers graphic

For more detailed information about the providers see the appropriateappendix in this document Data sources and data stores are discussed in theEstablishing a Connection on page 27 chapter Schema concepts are discussedin the Schema Management on page 85 chapter

Developing ApplicationsYou will need to perform several major tasks in using the FDO API to developa custom application Each of these tasks breaks down into a number of moredetailed coding issues

The major development tasks are

Working with the Build Environment

Establishing a Connection

Schema Management

Data Maintenance

Creating Queries

Using Custom Commands (Provider-Specific)

These tasks are explored in detail in the chapters that follow

Developing Applications | 11

12

FDO Concepts

Before you can work properly with the FDO API you need to have a good understanding ofits basic underlying concepts This chapter defines the essential constructs and dynamicsthat comprise the FDO API The definitions of these constructs and dynamics are groupedinto two interdependent categories

Data Concepts Definitions of the data constructs that comprise the FDO API

Operational Concepts Definitions of the operations that are used to manage andmanipulate the data

Data ConceptsAll concepts that are defined in this section relate to the data that FDO isdesigned to manage and manipulate

What Is a Feature

A feature is an abstraction of a natural or man-made real world object It isrelated directly or indirectly to geographic locations A spatial feature has oneor more geometric properties For example a road feature might be representedby a line and a hydrant might be represented by a point A non-spatial featuredoes not have geometry but can be related to a spatial feature which does Forexample a road feature may contain a sidewalk feature that is defined as notcontaining a geometry

What Is a Schema

A schema is a logical description of the data types used to model real-worldobjects A schema is not the actual data instances (that is not a particular roador land parcel) rather it is metadata A schema is a model of the types of data

3

13

that would be found in a data store For example a schema which models thelayout of city streets has a class called Road and this class has a property calledName The definition of Road and its associated classes constitute the schema

What Is a Schema Override

A schema override comprises instructions to override the default schemamappings For example an RDBMS-type FDO provider could map a featureclass to a table of the same name by default A schema override might mapthe class to a differently named table for example by mapping the poleclass to the telco_pole table

What is a Schema Mapping

A Schema Mapping is a correspondence between a Schema Element and aphysical object in a data store For example OSGeo FDO Provider for MySQLmaps each Feature Class onto a table in the MySQL database where the datastore resides The physical structure of data stores for each FDO provider canvary greatly so the types of Schema Mappings can also vary between providersEach provider defines a set of default schema mappings For example OSGeoFDO Provider for MySQL maps a class to a table of the same name by defaultThese defaults can be overridden by specifying Schema Overrides

What Are Elements of a Schema

A schema consists of a collection of schema elements In the FDO API schemaelements are related to one another by derivation and by aggregation Anelement of a schema defines a particular type of data such as a feature classor a property or an association For example a feature class definition for aroad includes the class name (for example Road) and the class properties (forexample Name NumberLanes PavementType and Geometry)

What Is a Class Type

A class type is a specialization of the base FDO class definition(FdoClassDefinition) It is used to represent the complex properties of spatialand non-spatial features

What is a Feature Class

A feature class is a schema element that describes a type of real-world objectIt includes a class name and property definitions including zero or moregeometric properties It describes the type of data that would be included inobject instances of that type

14 | Chapter 3 FDO Concepts

What Is a Property

A property is a single attribute of a class and a class is defined by one or moreproperty definitions For example a Road feature class may have propertiescalled Name NumberLanes or Location A property has a particular typewhich can be a simple type such as a string or number or a complex typedefined by a class such as an Address type which itself is defined by a set ofproperties such as StreetNumber StreetName or StreetType

There are five kinds of properties association properties data propertiesgeometric properties object properties and raster properties

Individual properties are defined in the following sections

What Is an Association Property

The FdoAssociationPropertyDefinition class is used to model a peer-to-peerrelationship between two classes This relationship is defined at schemacreation time and instantiated at object creation time The association propertysupports various cardinality settings cascading locks and differing deleterules An FDO filter can be based on association properties andFdoIFeatureReader can handle associated objects through the GetObject()method

What Is a Data Property

A data property is a non-spatial property An instance of a data propertycontains a value whose type is either boolean byte datetime decimal singledouble Int16 Int32 Int64 string binary large object or character large object

What Is Dimensionality

Dimensionality and the concept of dimension has two different meaningsin the discussion of geometry and geometric property

The first is called shape dimensionality and it is defined by theFdoGeometricType enumeration The four shapes are point (0 dimensions)curve (1 dimensions) surface (2 dimensions) and solid (3 dimensions)

The other is called ordinate dimensionality and it is defined by theFdoDimensionality enumeration There are four ordinate dimensions XYXYZ XYM and XYZM M stands for measure

Data Concepts | 15

What Is a Geometric Property

An instance of a geometric property contains an object that represents ageometry value The definition of the geometric property may restrict anobject to represent a geometry that always has the same shape such as a pointor it could allow different object instances to have different dimensions Forexample one geometric property object could represent a point and anothercould represent a line Any combination of shapes is permissible in thespecification of the geometric types that a geometry property definitionpermits The default geometric property specifies that an object could representa geometry that is any one of the four shapes

With respect to ordinate dimensionality all instances of a geometric propertymust have the same ordinate dimension The default is XY

Geometric property definitions have two attributes regarding ordinatedimensionality HasElevation for Z and HasMeasure for M

What is a Geometry

A geometry is represented using geometric constructs either defined as listsof one or more XY or XYZ points or defined parametrically for example asa circular arc While geometry typically is two- or three-dimensional it mayalso contain the measurement dimension (M) to provide the basis for dynamicsegments

The geometry types are denoted by the FdoGeometryType enumeration anddescribe the following

Point

LineString (one or more connected line segments defined by positions atthe vertices)

CurveString (a collection of connected circular arc segments and linearsegments)

Polygon (a surface bound by one outer ring and zero or more interior ringsthe rings are closed connected line segments defined by positions at thevertices)

CurvePolygon (a surface bound by one outer ring and zero or more interiorrings the rings are closed connected curve segments)

MultiPoint (multiple points which may be disjoint)

MultiLineString (multiple LineStrings which may be disjoint)

16 | Chapter 3 FDO Concepts

MultiCurveString (multiple CurveStrings which may be disjoint)

MultiPolygon (multiple Polygons which may be disjoint)

MultiCurvePolygon (multiple CurvePolygons which may be disjoint)

MultiGeometry (a heterogenous collection of geometries which may bedisjoint)

Most geometry types are defined using either curve segments or a series ofconnected line segments Curve segments are used where non-linear curvesmay appear The following curve segment types are supported

CircularArcSegment (circular arc defined by three positions on the arc)

LineStringSegment ( a series of connected line segments defined bypositions are the vertices)

There are currently no geometries of type ldquosolidrdquo (3D shape dimensionality)supported

The FdoIConnectionGetGeometryCapabilities() method can be used to querywhich geometry types and ordinate dimensionalities are supported by aparticular provider

What Is an Object Property

An object property is a complex property type that can be used within a classand an object property itself is defined by a class definition For examplethe Address type example described previously in the Property definition Anobject property may define a single instance for each class object instance (forexample an address property of a land parcel) or may represent a list ofinstances of that class type per instance of the owning class (for exampleinspection records as a complex property of an electrical device feature class)

What is a Raster Property

A raster property defines the information needed to process a raster imagefor example the number of bits of information per pixel the size in pixels ofthe X dimension and the size in pixels of the Y dimension needed to processa raster image

Data Concepts | 17

What Is a Spatial Context

A spatial context describes the general metadata or parameters within whichgeometry for a collection of features resides In particular the spatial contextincludes the definition of the coordinate system spheroid parameters unitsspatial extents and so on for a collection of geometries owned by features

Spatial context can be described as the ldquocoordinate system plus identityrdquo Anygeometries that are to be spatially related must be in a common spatial context

The identity component is required in order to support separate workspacessuch as schematic diagrams which are non-georeferenced Also it supportsgeoreferenced cases For example two users might create drawings using somedefault spatial parameters (for example rectangular and 10000x10000)although each drawing had nothing to do with the other If the drawings wereput into a common database the users could preserve not only the spatialparameters but also the container aspect of their data using spatial context

For more information about spatial context see Spatial Context on page 161

What is a Data Store

A data store is a repository of an integrated set of objects The objects in a datastore are modeled either by classes or feature classes defined within one ormore schemas For example a data store may contain data for both a LandUseschema and a TelcoOutsidePlant schema Some data stores can represent datain only one schema while other data stores can represent data in manyschemas (for example RDBMS-based data stores such as MySQL)

Operational ConceptsThe concepts that are defined in this section relate to the FDO operations usedto manage and manipulate data

What Is a Command

In FDO the application uses a command to select and update features definenew types of feature classes lock features version features and perform someanalysis of features Each Command object executes a specific type of commandagainst the underlying data store Interfaces define the semantics of eachcommand allowing them to be well-defined and strongly typed Because FDOuses a standard set of commands providers can extend existing commandsand add new commands specific to that provider Feature commands execute

18 | Chapter 3 FDO Concepts

against a particular connection and may execute within the scope of atransaction

An FDO command is a particular FDO interface that is used by the applicationto invoke an operation against a data store A command may retrieve datafrom a data store (for example a Select command) may update data in a datastore (for example an Update or Delete command) may perform some analysis(for example an Activate Spatial Context command) or may cause some otherchange in a data store or session (for example a Begin Transaction command)

What Is an Expression

An expression is a construct that an application can use to build up a filterAn expression is a clause of a filter or larger expression For example ldquoLanesgt=4 and PavementType = Asphaltrdquo takes two expressions and combines themto create a filter

For more information about using expressions with FDO see Filter andExpression Languages on page 139

What Is a Filter

A filter is a construct that an application specifies to an FDO provider toidentify a subset of objects of an FDO data store For example a filter may beused to identify all Road type features that have 2 lanes and that are within200 metres of a particular location Many FDO commands use filter parametersto specify the objects to which the command applies For example a Selectcommand uses a filter to identify the objects that the application wants toretrieve Similarly a Delete command uses a filter to identify the objects thatthe application wants to delete from the data store

For more information about using filters with FDO see Filter and ExpressionLanguages on page 139

What Is Locking

A user can use locking to gain update control of an object in the data store tothe exclusion of other users There are two general types of locksmdashtransactionlocks and persistent locks Transaction locks are temporary and endure onlyfor the duration of the transaction (see What Is a Transaction on page 20)

Persistent locks applied to objects by a user remain with the object until eitherthat user removes those locks or the locks are removed by another user withthe appropriate authority

Operational Concepts | 19

What Is a Transaction

A transaction changes the data store in some way The way these changesaffect the data store is determined by the transactionrsquos properties For examplethe Atomic property specifies that either all changes happen or non happenIn transaction processing the data store treats a series of commands as a singleatomic unit of change to that data store Either all changes generated by thecommands are successful or the whole set is cancelled A transaction is a singleatomic unit of changes to a data store The application terminates a transactionwith either a ldquocommitrdquo which applies the set of changes or a ldquorollbackrdquowhich cancels the set of changes Further the data store may automaticallyroll back a transaction if it detects a severe error in any of the commandswithin the transaction A transaction has the following properties

Atomic Either all changes generated by the commands within a transactionhappen or none happen

Consistent The transaction leaves the data store in a consistent stateregarding any constraints or other data integrity rules

Isolated Changes being made within a transaction by one user are notvisible to other users until after that transaction is committed

Durable After a transaction is completed successfully the changes arepersistent in the data store on disk and cannot be lost if the program orprocessor fails

What Is a Long Transaction

A long transaction (LT) is an administration unit used to group conditionalchanges to objects Depending on the situation such a unit might containconditional changes to one or to many objects Long transactions are used tomodify as-built data in the database without permanently changing the as-builtdata Long transactions can be used to apply revisions or alternates to anobject

What Is a Root Long Transaction

A root long transaction is a long transaction that represents permanent dataAny long transaction has a root long transaction as an ancestor in its longtransaction dependency graph

20 | Chapter 3 FDO Concepts

Development Practices

This chapter explains several practices to follow when working with the FDO API and providesexamples of how to follow these practices

Memory ManagementSome FDO functions (for example the Create methods) allocate memory whenthey are called This memory needs to be freed to prevent memory leaks Alldestructors on FDO classes are protected so you must call a Release() functionto destroy them (thus freeing their allocated memory) Each class inherits fromthe FdoIDisposable class which defines the Release() method and the AddRef()method

In addition these classes are reference counted and the count is increased (byAddRef()) when you retrieve them through a Get function After finishing withthe object you need to release it (just as with COM objects) The object isdestroyed only when the reference count hits 0 Two macros are defined to helpin the use of the Release() and AddRef() methods

FDO_SAFE_RELEASE (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_RELEASE calls the release() methodof the object pointed to by the ldquoptrrdquo argument and then sets the local pointerto the object to NULL The macro definition is define FDO_SAFE_RELEASE(x)

if (x) (x)-gtRelease() (x) = NULL

FdoFeatureClass pBase = myClass-gtGetBaseClass()

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

4

21

FDO_SAFE_ADDREF (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_ADDREF calls the AddRef()method of the object pointed to by the ldquoptrrdquo argument The macro definitionis define FDO_SAFE_ADDREF(x) ((x = NULL) (x)-gtAddRef() (x)

(NULL))

return FDO_SAFE_ADDREF(value)returns NULL if value equals NULL orincrements the reference count of the object that value points to andreturns value

m_list[index] = FDO_SAFE_ADDREF(value) assigns NULL to the arrayentry if value is NULL or increments the reference count of the object thatvalue points to and assigns value to the array entry

FdoPtr

An FdoPtr smart pointer is provided to help manage memory You wrap anFDO object in a FdoPtr The requirement is that the objectrsquos type must inheritfrom FdoIDisposable The object is then released automatically when theFdoPtr goes out of scope The following code illustrates how to use FdoPtr

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

No need to call FDO_SAFE_RELEASE

Before it is destroyed pBase calls Release() on the FdoFeature

Class object

NOTE If for some reason you wanted to use FDO_SAFE_RELEASE on an FdoPtryou would have to use an FdoPtr method to get a pointer to the object that FdoPtrwraps and pass that pointer to FDO_SAFE_RELEASE

You can use FdoPtr for your own classes by inheriting from the abstract classFdoIDisposable and providing an implementation for the Dispose() method(typically delete this)

FdoPtr Typedefs

Typedefs are provided that define identifiers representing Fdo classes wrappedbyFdoPtr An example is typedef FdoPtrltFdoClassgt FdoClassP

22 | Chapter 4 Development Practices

CollectionsYou can use FDO collection template classes to store your own objects Therequirements for your collection class and the class used to instantiate thetemplate are the same as those for wrapping a class in a FdoPtr

Exception HandlingIn the FDO API FdoCommandException class is the exception type thrownfrom classes in the Commands package and FdoConnectionException classis the exception type thrown from classes in the Connections package Bothof these exception types derive from a language-level exception class that isenvironment-specific

All exceptions are derived from the FdoException class To catch and processspecific exception types nest catch statements as in the following example

try

code

catch (FdoCommandException ex)

process message

catch (FdoException ex)

process message

In some cases underneath an FDO command the FDO level throws anFdoException The FDO command then traps the FdoException and wraps itin an FdoCommandException (or FdoSchemaException for a schemacommand) In this case several messages are returned by one exception Thefollowing example shows how to process multiple messages from oneexception

catch ( FdoSchemaException ex )

Loop through all the schema messages

FdoException currE = ex

while ( currE )

CW2A msg(currE-gtGetExceptionMessage())

acutPrintf (FdoConnectionException sn msg)

currE = currE-gtGetCause()

Collections | 23

An application function may need to catch and then re-throw exceptions inorder to clean up memory However the need to do this can be eliminatedby using FdoPtr The following example cleans up memory on error

FdoFeatureClass pBase = NULL

try

pBase = myClass-gtGetBaseClass()

catch ()

FDO_SAFE_RELEASE(pBase)

throw

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

The catch and rethrow is unnecessary when FdoPtr is used

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

Exception MessagesException messages are localized On Windows the localized strings are inresource-only DLLs and on Linux they are in catalogs The message DLLs arein the bin folder the DLL name contains Message or Msg The catalog filesare in the usrlocalfdo-320nls directory the names of these files ends in catNLS stands for National Language Support

On Linux set the NLSPATH environment variable so that the runtime codecan locate the message catalogs For example exportNLSPATH=usrlocalfdo-320nlsN

On Windows you do not have do anything special to enable the runtime codeto locate the message DLLs

The contents of the exception message files are indexed When you call oneof the FdoExceptionNLSGetMessage methods declared in Exceptionh youprovide a message number argument You may also provide a default messagestring argument In the event that the exception message resource file cannotbe found the default message is subsituted instead If the default messagestring is not provided and the resource file cannot be found the messagenumber is used as the exception message Not finding the resource file canonly happend on Linux and only if the NLSPATH envrionment variable is notset

24 | Chapter 4 Development Practices

The following two examples when called on Linux with the NLSPATHenvironment variable not set show the use of the default message and themessage number in the exception message

The following is an example of using the default string throwFdoSchemaExceptionCreate(NlsMsgGet1(FDORDBMS_333 Class 1$lsnot

found value-gtGetText()))

The following is an example of not setting the default string and using themessage number instead FdoSchemaException pNewException =

FdoSchemaExceptionCreate(

FdoSmErrorNLSGetMessage(FDO_NLSID(FDOSM_221)

pFeatSchema-gtGetName()) pException)

Managing FdoPtr BehaviorsThe topics in this section describe several ways that you can manager FdoPtrbehavior For more information about managing FdoPtr behavior see therelated topics ldquoFdoPtr ltTgt Class Template Referencerdquo and ldquoFdoIDisposableClass Referencerdquo in the FDO Reference Help and The Essential FDO

Chain Calls

Do not chain calls If you do returned pointers will not be released Forexample given an FdoClassDefinition pclassDef

psz = pclassDef -gtGetProperties()-gtGetItem(0)-gtGetName())

The above code would result in two memory leaks Instead use

FdoPropertyDefinitionCollection pprops = pclassDef -gt GetProper

ties()

FdoPropertyDefinition ppropDef = pprops-gtGetItem(0)

psz = propDef-gtGetName()

ppropDef-gtRelease()

pprops-gtRelease()

or (with FdoPtr)

FdoPtrltFdoPropertyDefinitionCollectiongt pprops = pclassDef-gt Get

Properties()

FdoPtrltFdoPropertyDefinitiongt ppropDef = pprops-gt GetItem(0)

psz = propDef-gtGetName()

or (also with FdoPtr)

Managing FdoPtr Behaviors | 25

psz = FdoPtr ltFdoPropertyDefinitiongt (FdoPtr ltFdoPropertyDefini

tionCollectiongt(pclassDef-gtGetProperties())-gt GetItem(0))-gtGet

Name()

Assigning Return Pointer of an FDO Function Call to a Non-SmartPointer

If you are assigning the return pointer of an FDO function call to a non-smartpointer then you should assign that pointer to a FdoPtr For example

FdoLineString P = gfCreateLineString()

FdoPtr ltFdoLineStringgt p2 = FDO_SAFE_ADDREF(p)

26 | Chapter 4 Development Practices

Establishing aConnection

This chapter explains how to establish a connection to an FDO provider and provides aconnection example

Connection SemanticsData Sources and Data Stores

The FDO API uses connection semantics to implement access to feature schemadata The term data store is used to refer to a collection of zero or more objectswhich instantiate class definitions belonging to one or more FDO feature schemaThe connection is to a data store because that is where data objects are storedThe underlying data source technologies used to hold data stores can berelational databases such as a MySQL database or a file-based solution suchas an SDF file

The mapping of a data store to data source technology can be one-to-one ormany-to-one For example it is

One-to-one when the connection is made by way of the OSGeo FDO Providerfor ArcSDE and the ArcSDE server is using an Oracle database

Many-to-one when the data source is a MySQL database and the connectionis made by way of the OSGeo FDO Provider for MySQL (in this case the datastore is like a container within a container)

When many-to-one mapping is possible a connection can be made in one ortwo steps For more information see Establishing a Connection on page 29 andThe Essential FDO

5

27

The underlying data source technologies differ in the connection parametersused for connecting to a particular provider The values for these parametersare generated during the installation and configuration of the containertechnologies For more information about these values and the process ofinstalling and configuring the associated data source technologies see theappropriate appendix in this document and The Essential FDO

Providers

You connect to a data store by way of a provider

The FDO API contains a registry interface that you can use to register orderegister a provider See the class FdoProviderRegistry inIncFdoClientServicesProviderRegistryh

The providers are registered during the initialization of the FDO SDK In orderto connect to a provider you will need the name of the provider in a particularformat ltCompanyFoundationOriginatorgtltProvidergtltVersiongt TheltCompanyFoundationOriginatorgt and ltProvidergt values are invariable Forspecific values see The Essential FDO

In order to connect you will need the full name including the ltVersiongtvalue You can retrieve the full name from the registry and display the set ofprovider names in a connection menu list If for whatever reason youderegister a provider save the registry information for that provider in caseyou want to reregister it again The provider object returned by the registryhas a Set() method to allow you to change values However the only valueyou can safely change is the display name Sample code for using the providerregistry is located in Establishing a Connection on page 29

The registry contains the following information about a provider

Name The unique name of the feature provider This name should be ofthe form ltCompanyFoundationOriginatorgtltProvidergtltVersiongt forexample AutodeskOracle30 or OSGeoMySQL30

DisplayName A user-friendly display name of the feature provider Theinitial values of this property for the pre-registered providers are ldquoAutodeskFDO Provider for Oraclerdquo ldquoOSGeo FDO Provider for SDFrdquo etc or theequivalent in the language of the country where the application is beingused

Description A brief description of the feature provider For example thethe OsGeo FDO Provider for SDF description is ldquoReadwrite access toAutodesks spatial database format a file-based personal geodatabase thatsupports multiple featuresattributes spatial indexing and file-lockingrdquo

28 | Chapter 5 Establishing a Connection

Version The version of the feature provider The version number stringhas the form ltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgtfor example 3000

FDOVersion The version of the feature data objects specification to whichthe feature provider conforms The version number string has the formltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgt for example3010

libraryPath The FULL library path including the library name of theprovider for example ltFDO SDK Install LocationgtbinFdoRdbmsdll

isManaged A flag indicating whether the provider is a managed orunmanaged NET provider

Establishing a ConnectionAs mentioned in a previous section Connection Semantics on page 27 theFDO API uses a provider to connect to a data store and its underlying datasource technology These data source technologies must be installed andconfigured Certain values generated during data source installation andconfiguration are used as arguments during the connection process Becausethe FDO API does not provide any methods to automate the collection andpresentation of these configuration values either the application developermust request the user to input these configuration values during theconnection process or the application developer can provide an applicationconfiguration interface which would populate the application with thecontainer configuration values and thus allow the user to choose them fromlists

NOTE For more information about connecting see The Essential FDO

A connection can be made in either one or two steps

One-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method once the returned stateis FdoConnectionState_Open no additional information is needed

Two-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method the returned state isFdoConnectionState_Pending additional information is needed to completethe connection In this case the first call to Open() has resulted in theretrieval of a list of values for a property that becomes a required property

Establishing a Connection | 29

for the second call to the Open() method After the user has selected oneof the values in the list the second call to Open() should result inFdoConnectionState_Open

Connecting to a data store by way of the MySQL or the ArcSDE provider forexample can be done in either one or two steps In the first step the datastore parameter is not required If the user does not give the data storeparameter a value the FDO will retrieve the list of data store values from thedata source so that the user can choose from them during the second stepOtherwise the user can give the data store a value in the first step andassuming that the value is valid the connection will be completed in onestep

For the purpose of this example letrsquos assume that the user has installed MySQLon his local machine During the installation he was prompted to assign apassword to the system administrator account whose name is lsquorootrsquo He setthe password to lsquotestrsquo

The following steps are preliminary to establishing a connection

1 Get the list of providers

FdoPtrltFdoProviderRegistrygt registry = (FdoProviderRegistry

)FdoFeatureAccessManagerGetProviderRegistry()

FdoProviderCollection providers = registry-gtGetProviders()

2 Get the display names for all of the providers in the registry An exampleof a display name might be OSGeo FDO Provider for MySQL

FdoStringP displayName

FdoStringP internalName

FdoPtrltFdoProvidergt provider

int count = providers-gtGetCount()

for(int i = 0 i lt count i++)

provider = providers-gtGetItem(i)

internalName = provider-gtGetName()

displayName = provider-gtGetDisplayName()

add displayName to your list

3 Use the display names to create a menu list from which the user willselect from when making a connection

After the user initiates a provider display name from the connection menudo the following

30 | Chapter 5 Establishing a Connection

1 Loop through the providers in the registry until you match the displayname selected by the user from the connection menu with a providerdisplay name in the registry and retrieve the internal name for thatprovider An example of an internal could be OSGeoMySQL32

FdoStringP internalName = provider-gtGetName()

2 Get an instance of the connection manager

FdoPtrltFdoConnectionManagergt connectMgr = (FdoConnectionManager

)FdoFeatureAccessManagerGetConnectionManager()

3 Call the managerrsquos CreateConnection() method using the provider internalname as an argument to obtain a connection object

FdoPtrltFdoIConnectiongt fdoConnection = connectMgr-gtCreateConnec

tion(LrdquoOsGeoMySQL32rdquo)

4 Obtain a connection info object by calling the connection objectrsquosGetConnectionInfo() method

FdoPtrltFdoIConnectionInfogt info = fdoConnection-gtGetConnection

Info()

5 Obtain a connection property dictionary object by calling the connectioninfo objectrsquos GetConnection Properties() method and use this dictionaryto construct a dialog box requesting connection information from theuser

FdoPtrltFdoIConnectionPropertyDictionarygt ConnDict = info-gtGetCon

nectionProperties()

6 Get a list of connection property names from the dictionary and use thislist to get information about the property The following code loopsthrough the dictionary getting all of the possible information

NOTE An attempt to get the values of an enumerable property is made onlyif the property is required

FdoInt32 count = 0

FdoString names = NULL

FdoStringP name

FdoStringP localname

FdoStringP val

FdoStringP defaultVal

bool isRequired = false

bool isProtected = false

bool isFilename = false

bool isFilepath = false

Establishing a Connection | 31

bool isDatastorename = false

bool isEnumerable = false

FdoInt32 enumCount = 0

FdoString enumNames = NULL

FdoStringP enumName

names = ConnDict-gtGetPropertyNames(count)

for(int i = 0 i lt count i++)

name = names[i]

val = dict-gtGetProperty(name)

defaultVal = dict-gtGetPropertyDefault(name)

localname = dict-gtGetLocalizedName(name)

isRequired = dict-gtIsPropertyRequired(name)

isProtected = dict-gtIsPropertyProtected(name)

isFilename = dict-gtIsPropertyFileName(name)

isFilepath = dict-gtIsPropertyFilePath(name)

isDatastorename = dict-gtIsPropertyDatastoreName(name)

isEnumerable = dict-gtIsPropertyEnumerable(name)

if (isEnumerable)

if (isRequired)

enumNames = dict-gtEnumeratePropertyValues(name enumCount)

for(int j = 0 j lt enumCount j++)

enumName = enumNames[j]

7 Use the GetLocalizedName method to obtain the name of the propertyto present to the user Calls to dictionary methods need the value of theinternal name in the string array returned by GetPropertyNames() Sowhen the user selects the localized name in the menu the program mustmap the localized name to the internal name

8 Use the IsPropertyRequired method to determine whether to mark theline as either required or optional the dialog box handler should notpermit the user to click OK in the dialog box unless a required field hasa value

9 Use the IsPropertyProtected method to determine whether the dialogbox handler should process the field value as protected data for examplea password

10 Use the IsPropertyEnumerable and IsRequired methods to determinewhether to call the EnumeratePropertyValues method to get a list of validvalues

32 | Chapter 5 Establishing a Connection

NOTE Call the EnumeratePropertyValues method only if both methods returntrue Otherwise be prepared to catch an exception if there is no pendingconnection The assumption is that a connection exists and the program isretrieving values from the data store

As shown in the code lines above the EnumeratePropertyValues method takesa property name and an updates integer argument and returns a string arrayThe updates integer will say how many values are in the returned array Presentthe list of choices to the user

If the property is not enumerable present the values returned by either theGetProperty or GetPropertyDefault methods to the user

Now that the user has seen the set of properties in the dictionary she canset the required properties A property is set by calling the dictionaryrsquosSetProperty method The MySQL connection property names are UsernamePassword Service and DataStore The dictionary tells us that UsernamePassword and Service are required properties and that DataStore is not requiredLetrsquos connect to the MySQL as root

ConnDict-gtSetProperty(LrdquoUsernamerdquo Lrdquorootrdquo)

ConnDict-gtSetProperty(LrdquoPasswordrdquo Lrdquotestrdquo)

ConnDict-gtSetProperty(LrdquoServicerdquo Lrdquolocalhostrdquo)

NOTE fdoconnection-gtGetConnectionString() returnsUsername=rootPassword=testService=localhostfdoconnection-gtSetConnectionString(LrdquoUsername=rootPassword=testService=localhostrdquo)

would set the connection properties to the same values as the three calls aboveto the connection dictionaryrsquos SetProperty() method

Open the connection

FdoConnectionState state = fdoConnection-gtOpen()

The value of state is FdoConnectionState_Pending An examination of theconnection dictionary will reveal that the DataStore property is now required

When the user checks the command capabilities he discovers that he cancreate a data store

Establishing a Connection | 33

FdoPtrltFdoICommandCapabilitiesgt commandCapabilities = fdoConnec

tion-gtGetCommandCapabilities()

bool bSupportsCreateDatastore = false

FdoInt32 numCommands

FdoIn32 commands = commandCapabilities-gtGetCommands(numCommands)

for(int i = 0 i lt numCommands i++)

switch(commands[i])

case FdoCommandType_CreateDataStore bSupportsCreateDatastore

= true

He can use the pending connection to MySQL to create the datastore Use theconnection object to create the FdoICreateDataStore command object Usethe command object to create the FdoIDataStorePropertyDictionary objectand find out from this object what properties you must define Use thedictionary object to set the required properties and then execute the commandto create the lsquofdo_userrsquo data store The only required property is DataStore

NOTE The FdoIDataPropertyDictionary and the FdoIConnectionPropertyDictionaryclasses are both derived from FdoIPropertyDictionary The code used above toaccess the FdoIConnectionPropertyDictionary object works for theFdoIDataPropertyDictionary

FdoPtrltFdoICreateDataStoregt createDataStoreCmd = dynam

ic_castltFdoICreateDataStore gt (fdoConnection-gtCreateCommand(Fdo

CommandType_CreateDataStore))

FdoPtrltFdoIDataStorePropertyDictionarygt createDsDict = createData

StoreCmd-gtGetDataStoreProperties()

createDsDict-gtSetProperty(LrdquoDataStorerdquo Lrdquofdo_userrdquo)

createDataStoreCmd-gtExecute()

Now use the connection property dictionary to set the DataStore property tolsquofdo_userrsquo and call the Open() method on the connection object This methodshould return FdoConnectionState_Open

34 | Chapter 5 Establishing a Connection

FDO Capabilities

FDO Capabilities

Introduction

The FDO capabilities are statically defined They are accessed through aconnection object in the closed state The following code illustrates how to geta connection object in the closed state

If you are using C you will find the capability definitions in theOSGeoFDOConnectionsCapabilities namespace If you are using C++ youwill find the headers in the FdoConnectionsCapabilties directory

In C you access them using the OSGeoFDOConnectionsIConnection objectIn C++ you access them using the IConnection object whose header is in theFdoConnections directory

The information in the capabilities tables reflects the state of the FDO providercapabilities as of the commercial release of Map 3D 2009

For the most part FDO defines capabilities in three ways booleans enumerationsor integers representing enumerated values and collections One schemacapability is defined as a string and two other schema capabilities as integersFor example the Command capability SupportsParameters is a boolean andthe Command capability Commands is a set of integers whose meaning isdefined by the C CommandType enumeration and the C++ FdoCommandTypeenumeration Function capabilities are defined as collections of functionsignatures The C type isOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionThe C++ type is FdoReadOnlySignatureDefinitionCollection The latter is

6

35

defined in FdoConnectionsCapabilitiesSignatureDefinitionh Each booleanenumeration and signature value is shown in the tables

In general where a number of capabilities are supported by the same set ofproviders the capabilities are aggregated into one line in the table This ruleis modified in the function category tables in the Expression section

In some cases for example the CLIP raster function there is only one signatureAt the other end of the spectrum is the Concat string function which hasalmost 100 signatures The same set of providers supports an enormous numberof functions and so the rule for presenting aggregations of capabilities had tobe modfied for functions The rule for functions is to present all of thesignatures for one function on a line in the table A handful of functions hadso many signatures that their presentation had to be split over two lines

Provider Type

A provider can be one of four types Database Server File Web Server orUnknown The type information is available from the connection object inthe closed state The ldquoUnknownrdquo type indicates that the provider can connectto more than one type of data store technology The ODBC and OGR providerscan connect either to a file-based or RDBMS-based data store technologywhich is not known until the connection is in the open state

In C the ProviderDatastoreType enumeration is in theOSGeoFDOConnections namespace The ProviderDatastoreType property isaccessible through the OSGeoFDOConnectionsIConnection object(connectionConnectionInfoProviderDatastoreType)

In C++ the FdoProviderDatastoreType enumeration is defined in theltFdoConnectionsProviderDatastoreTypehgt header file TheFdoProviderDatastoreType value is accessible through the IConnection object(connection-gtGetConnectionInfo()-gtGetProviderDatastoreType())

TypeProvider

DatabaseServerOSGeoArcSDE33

DatabaseServerOSGeoKingOracle33

DatabaseServerOSGeoMySQL33

36 | Chapter 6 FDO Capabilities

TypeProvider

DatabaseServerOSGeoPostGIS33

DatabaseServerOSGeoSQLServerSpatial33

FileOSGeoGdal33

FileOSGeoSDF33

FileOSGeoSHP33

WebServerOSGeoWFS33

WebServerOSGeoWMS33

UnknownOSGeoODBC33

UnknownOSGeoOGR33

NOTE A provider name with OSGeo at the beginning indicates that the provideris available as open source from httpfdoosgeoorg

Command

In C you access theOSGeoFDOConnectionsCapabilitiesICommandCapabilities using theIConnection object (connectionCommandCapabilities)

In C++ you access the FdoICommandCapabilities using the IConnection object(connection-gtGetCommandCapabilities())

DescriptionCommand

Locks feature instances of a given class that match thespecified criteria

AcquireLock

Command | 37

DescriptionCommand

Activates a long transaction so that features can be ver-sioned

ActivateLongTransaction

Activates a specified spatial contextActivateSpatialContext

Creates or updates a feature schema within the datastore Optionally a provider-specificmapping of featureschema elements to physical storage can be specified

ApplySchema

Commits all of the data within a leaf long transaction(one that does not have descendent long transactions)

CommitLongTransaction

to the parent long transaction and removes the longtransaction Requires access commit and remove priv-ileges to the long transaction and the access privilegeto the parent long transaction

Creates anew provider specific datastoreCreateDataStore

Creates a long transaction as a child of the currentlyactive long transaction

CreateLongTransaction

Creates a new spatial context Input to the commandincludes the name description coordinate system ex-tent type and extent for the new context

CreateSpatialContext

Deactivates the active long transaction and automaticallyactivates the root long transaction If the root long

DeactivateLongTransaction

transaction is the active one the deactivation has noeffect

Deletes the instances of a given class that match thespecified criteria The instances can be at global scopeor contained within an object collection

Delete

Describe a single schema or all schemas available fromtheconnection

DescribeSchema

38 | Chapter 6 FDO Capabilities

DescriptionCommand

Describes the logical to physical schema mappings forone or all feature schemas available from the connection

DescribeSchemaMapping

Remove a data storeDestroyDataStore

Destroys a schema definition including all class defini-tions relationship definitions and instance data within

DestroySchema

it If elements in other schemas referto the schema tobe destroyed execution will fail

Destroys an existing spatial context which destroys alldata stored in that context

DestroySpatialContext

Gets a list of all objects that are currently locked by aparticular user

GetLockedObjects

Gets lock information for the feature instances of a givenclass that match the specified filter

GetLockInfo

Gets a list of all lock ownersGetLockOwners

Gets one specific long transaction or all available longtransactions

GetLongTransactions

Enumerates the existing measurement unitsGetMeasureUnits

Gets all spatial contexts or just the active oneGetSpatialContexts

inserts a new instance of a given class The instance canbe at global scope or contained within an object collec-tion

Insert

Gets a list of datastores at a particular serverListDataStores

Create a spatial index for the specified spatial contextOracleCreateSpatialIndex

Command | 39

DescriptionCommand

Drop the specified spatial indexOracleDestroySpatialIndex

Enumerate the existing spatial indexesOracleGetSpatialIndexes

Releases locks from feature instances of a given class thatmatch the specified criteria

ReleaseLock

Removes all of the data within a long transaction andremoves the long transaction as well Requires access

RollbackLongTransaction

commit and remove privileges to the long transactionand the access privilege to the parent long transaction

creates a new SDF+ file with a specified location and filename and a given spatial coordinate system This com-

SDFCreateSDFFile

mand has been superceded by the CreateDataStorecommand

Supports the selection and ordering of feature instancesof a given class according to the specified criteria Theresults of the select are written to an SDF file

SDFExtended_Select

Queries for features of a given class that match the spe-cified criteria

Select

Queries for features of a given class that match the spe-cified criteria The criteria can specify that feature values

SelectAggregates

from multiple instances be aggregated be distinct orbe grouped

Supports the execution of a SQL statement against anunderlying RDBMS Two execute methods are provided

SQLCommand

to distinguish between statements that return table dataversus those that execute non query type operations

Modifies instances of a given class that match the spe-cified criteria The instance can be at global scope orcontained within an object collection

Update

40 | Chapter 6 FDO Capabilities

DescriptionCommand

Gets the image formats supported by the connectionWMSGetImageFormats

Gets the layer styles available for the specified featureclass

WMSGetFeatureClassStyles

Gets the CRS names available for the specified featureclass

WMSFeatureClassCRS-Names

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports the use of distinct in SelectAggreg-ates commands

SupportsSelectDistinct

Indicates whether or not a provider sup-ports the use of expressions for propertiesin Select and SelectAggregate commands

SupportsSelectExpressions

Indicates whether or not a provider sup-ports the use of functions in Select and

SupportsSelectFunctions

SelectAggregates command Only aggreg-ate functions can be used in the SelectAg-gregates command

Indicates whether or not a provider sup-ports the use of grouping criteria in theSelectAggregates command

SupportsSelectGrouping

Indicates whether or not a provider sup-ports ordering in the Select and SelectAg-gregates command

SupportsSelectOrdering

Command | 41

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports parameter substitution

SupportsParameters

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++Select DescribeSchema GetSpatialContexts

++++++++-+++SelectAggregates

+++-++-+++++SupportsSelectFunctions

++--++-+++++SupportsSelectDistinct Insert Update Delete

++-+++-++++-SupportsSelectExpressions

----++-+-+++CreateSpatialContext

-++-+-++-+--DescribeSchemaMapping

-+-----+++++SQLCommand

----++-++++-ApplySchema

-----+-++++-CreateDataStore

-+-----++++-SupportsSelectOrdering

-------+++-+ListDataStores

-+-----+-++-SupportsSelectGrouping

-----+-+++--DestroyDataStore

42 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

----+--+-+--DestroySchema

--------+-++SupportsParameters

-------+-+-+DestroySpatialContext

----++------SDFCreateSDFFile

-------+---+ActivateSpatialContext

-------+----OracleGetSpatialIndexes OracleCreateSpatialIndex Or-acleDestroySpatialIndex

-----+------SDFExtended_Select

--+---------WMSFeatureClassCRSNames WMSGetImageFormatsWMSGetFeatureClassStyles

-----------+AcquireLock CreateLongTransaction DeactivateLongTrans-action RollbackLongTransaction CommitLongTransactionGetLockOwners ReleaseLock GetLongTransactions Get-LockedObjects ActivateLongTransaction GetLockInfo

Connection

In C you access theOSGeoFDOConnectionsCapabilitiesIConnectionCapabilities using theIConnection object (connectionConnectionCapabilities)

Connection | 43

In C++ you access the FdoIConnectionCapabilities using the IConnectionobject (connection-gtGetConnectionCapabilities())

DescriptionCapability

Indicates that only this user can modify this object in thislong transaction No user not even the user locking the

LockType_AllLongTransactionExclusive

object can modify the object in any long transaction createdas a descendent of the one containing the object beinglocked When not in a long transaction situation (for ex-ample if only a root long transaction exists) the lock be-haves like an Exclusive lock

Indicates that only this user can modify this object In a longtransaction situation any user can modify the object in any

LockType_Exclusive

other long transaction including the root long transactionif it is not the current long transaction

Indicates that only this user can modify this object in thelong transaction containing the object or any long transac-

LockType_LongTransactionExclusive

tion created as a descendent of that one When not in along transaction situation (for example if only a root longtransaction exists) the lock behaves like an Exclusive lock

Indicates a shared lock typeLockType_Shared

Indicates that a transaction lock should be applied to anobject

LockType_Transaction

Indicates whether or not a provider can specify on a closedconnection an XML source to be used to configure the datastore

SupportsConfiguration

Indicates that the spatial extent of the context is dynamicand changes as data is added and removed from the con-text

SpatialContextExtentType_Dynamic

Indicates that the spatial extent of the context is static andmust be specified when the context is created

SpatialContextExtentType_Static

44 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the specifica-tion of a coordinate system during the creation of a spatial

SupportsCSysWKTFromCSysName

context using only the coordinate system name The pro-vider maps the name to the WKT internally

Indicates whether or not a provider supports the forcedwrite of cached data associated with a connection to thetarget data store

SupportsFlush

Indicates whether or not a provider supports the set oflocking commands acquire get locked objects get lockowners get lock info and release

SupportsLocking

Indicates whether or not a provider supports the set of longtransaction commands activate commit create deactivateand get

SupportsLongTransactions

Indicates that the data store can contain multiple spatialcontexts but the provider does not necessarily support thecreate spatial context command

SupportsMultipleSpatialContexts

Indicates whether or not a provider supports the SQL com-mand

SupportsSQL

Indicates whether or not a provider supports the creationof a transaction associated with a connection to a data store

SupportsTransactions

Indicates that the provider supports a single thread perconnection Multiple concurrent threads cannot access the

ThreadCapability_PerConnectionThreaded

same connection object and only one command can beexecuting per connection Multiple connections can beactive concurrently as long as each is executing on its ownthread

Indicates that the provider supports a single thread percommand Multiple concurrent threads cannot access the

ThreadCapability_PerCommandThreaded

same command object however multiple commands canbe executing concurrently against a single connection

Connection | 45

DescriptionCapability

Indicates that the provider is not thread safeThreadCapability_SingleThreaded

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-++++-++++++SpatialContextExtentType_Static

++++++-+++-+ThreadCapability_PerConnectionThreaded

--+++-++++++SupportsMultipleSpatialContexts

-+-----+++++SupportsSQL

-++-+-+---+-SupportsConfiguration

-------++--+SupportsTransactions

----------++LockType_Exclusive

+----+------SpatialContextExtentType_Dynamic

----++------SupportsFlush

--------+-+-LockType_Transaction

----------+-LockType_AllLongTransactionExclusive LockType_LongTrans-actionExclusive ThreadCapability_PerCommandThreadedLockType_Shared

-----------+SupportsLocking SupportsCSysWKTFromCSysName Sup-portsLongTransactions

------+-----ThreadCapability_SingleThreaded

46 | Chapter 6 FDO Capabilities

Expression

In C you access theOSGeoFDOConnectionsCapabilitiesIExpressionCapabilities and theOSGeoFDOConnectionsCapabilitiesFunctionDefinitionCollectionusingthe IConnection object connectionExpressionCapabilities andconnectionExpressionCapabilitiesFunctions respectively EachOSGeoFDOConnectionsCapabilitiesFunctionDefinition in the collectionhas has aOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionwhich is accessed by functionDefSignatures

In C++ you access the FdoIExpressionCapabilities and theFdoFunctionDefinitionCollection using the IConnection objectconnection-gtGetExpressionCapabilities()expression_capabilities-gtGetFunctions() respectively EachFdoFunctionDefinition in the collection has anFdoReadOnlySignatureDefinitionCollection which is accessed byfunctionDef-gtGetSignatures()

The functions can be broadly divided into two groups according to the modeof their implementation The largest group contains the functions whoseunderlying implementation is based on the Expression Builder The first releaseof the Expression Builder component is in FDO 33 The remaining functionsare those whose implementation was not touched by the introduction of theExpression Builder component

The functions whose implementation is based on the Expression Builder arefurther categorized for UI purposes into 7 groups aggregate conversion dategeometry math numeric and string These UI categories are used in thisdocument to group the presentation of the functions

General Capabilities

DescriptionCapability

Indicates whether or not the provider supports basicarithmetic expressions for example + - negate andstring concatenation

ExpressionType_Basic

Indicates whether or not the provider supports functionevaluations

ExpressionType_Function

Expression | 47

DescriptionCapability

Indicates whether or not the provider supports parametersubstitution An expression can be constructed using

ExpressionType_Parameter

named parameters and values bound to the parameter ata later time This allows the constructed expression to bereused

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ExpressionType_Function

++-+++-+++++ExpressionType_Basic

-------+-+--ExpressionType_Parameter

Argument and Return Types

Tthe following tables specify the function name arguments and the type ofthe return value An argument is optional if it is enclosed in square bracketsAn argument may be a literal such as ldquoALLrdquo or ldquoDISTINCTrdquo or a featureproperty name Where the argument value is a feature property name thetype of the feature property is specified The set of valid alternatives for anargument value is indicated by enclosing the set of ORrsquod property types orliteral values in parentheses For brevityrsquos sake a lsquonumericrsquo property typeindicates the set of numeric property types namely Byte | Decimal | Double| Int16 | Int32 | Int 64 | Single The other property types BLOB BooleanCLOB DateTime Geometry and String are indicated directly in the argumentspecification

Some functions have more than one return type The general rule is that thereturn type matches the argument type

48 | Chapter 6 FDO Capabilities

Aggregate Expression Functions

These functions can be used with the SelectAggregates command

DescriptionFunctionName

Returnsa double which is the average of the values identified by theprovided expression Avg ([ALL | DISTINCT ] numeric)

Avg

Returns an Int64 which is the number of rows returned by a queryidentified by the provided expression Count ([ALL | DISTINCT ]bool | DateTime | numeric | string | blob | clob | geometry)

Count

Returns a DateTime numeric or string in agreement with the typeof the argument which is the maximum value of the provided expres-sion Max ([ALL | DISTINCT ] DateTime | numeric | string)

Max

Represents an inverse distribution function that assumes a continuousdistribution model It takes a numeric or date-time value and returns

Median

a Double which is the middle value or an interpolated value thatwould be the middle value once the values are sorted Median (nu-meric)

Returns a DateTime numeric or string in agreement with the typeof the argument which is the minimum value of the provided expres-sion Min ([ALL | DISTINCT ] DateTime | numeric | string)

Min

Returns a Double which is the sample standard deviation of theprovided expression Stddev ([ALL | DISTINCT ] numeric)

Stddev

Returns a Double which is the sum of the values identified by theprovided expression Sum ([ALL | DISTINCT ] numeric)

Sum

Returns a byte array which yields the spatial extent of a set of geo-metries The argument is the name of geometry property SpatialEx-

Spatial Extent

tent (ltgeometriesgt) For example given these geometries POINT(11) LINESTRING(01 21) and POLYGON((01 21 12 01)) it returnsPOLYGON((01 21 22 02 01))

Expression | 49

NOTE The median is selected or calculated by doing the following

1 Sort the sample in ascending order

2 Calculate the Row of Interest (roi) using the forumula roi = (1 +((ltsample_sizegt - 1) 2))

3 Compare three values roi Ceil(roi) and Floor(roi) If they are equal themedian is the value in the Row Of Interest If they are not equal themedian is calculated by averaging the values in the rows preceding andsucceeding the Row of Interest

NOTE The value returned by the StdDev function is known as the sample standarddeviation and represents an estimate of the standard deviation of a populationbased on a random sample of that population See the Wikipedia entry for furtherdiscussion and a definition of the formula for sample standard deviationhttpenwikipediaorgwikiStandard_deviation

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++-+++++Double Avg(Double)

++--++-+++++Int64 Count(Int64)

++--++-+++++Double Max(Double)

++--++-+++++Double Min(Double)

++--++-+++++Double Sum(Double)

-+-+++-+-+++BLOB SpatialExtents(BLOB)

-+--++-+-+-+Double Avg(Byte) Double Avg(Decimal) Double Avg(Int16)Double Avg(Int32) Double Avg(Int64) Double Avg(Single)Double Avg(StringByte) Double Avg(StringDecimal) DoubleAvg(StringDouble) Double Avg(StringInt16) Double

50 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Avg(StringInt32) Double Avg(StringInt64) DoubleAvg(StringSingle)

-+--++-+-+-+Int64 Count(BLOB) Int64 Count(Boolean) Int64 Count(Byte)Int64 Count(CLOB) Int64 Count(DateTime) Int64Count(Decimal) Int64 Count(Double) Int64 Count(Int16) Int64Count(Int32) Int64 Count(Single) Int64 Count(String) Int64Count(StringBoolean) Int64 Count(StringByte) Int64Count(StringDateTime) Int64 Count(StringDecimal) Int64Count(StringDouble) Int64 Count(StringInt16) Int64Count(StringInt32) Int64 Count(StringInt64) Int64Count(StringSingle) Int64 Count(StringString)

-+--++-+-+-+Byte Max(Byte) Byte Max(StringByte) DateTime Max(Date-Time) DateTime Max(StringDateTime) Decimal Max(Decimal)Decimal Max(StringDecimal) Double Max(StringDouble) Int16Max(Int16) Int16 Max(StringInt16) Int32 Max(Int32) Int32Max(StringInt32) Int64 Max(Int64) Int64 Max(StringInt64)Single Max(Single) Single Max(StringSingle) StringMax(String) String Max(StringString)

-+--++-+-+-+Double Median(Byte) Double Median(Decimal) Double Medi-an(Double) Double Median(Int16) Double Median(Int32)Double Median(Int64) Double Median(Single)

-+--++-+-+-+Byte Min(Byte) Byte Min(StringByte) DateTime Min(DateTime)DateTime Min(StringDateTime) Decimal Min(Decimal)Decimal Min(StringDecimal) Double Min(StringDouble) Int16Min(Int16) Int16 Min(StringInt16) Int32 Min(Int32) Int32Min(StringInt32) Int64 Min(Int64) Int64 Min(StringInt64)Single Min(Single) Single Min(StringSingle) String Min(String)String Min(StringString)

-+--++-+-+-+Double Stddev(Byte) Double Stddev(Decimal) DoubleStddev(Double) Double Stddev(Int16) Double Stddev(Int32)Double Stddev(Int64) Double Stddev(Single) Double

Expression | 51

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Stddev(StringByte) Double Stddev(StringDecimal) DoubleStddev(StringDouble) Double Stddev(StringInt16) DoubleStddev(StringInt32) Double Stddev(StringInt64) DoubleStddev(StringSingle)

-+--++-+-+-+Double Sum(Byte) Double Sum(Decimal) Double Sum(Int16)Double Sum(Int32) Double Sum(Int64) Double Sum(Single)Double Sum(StringByte) Double Sum(StringDecimal) DoubleSum(StringDouble) Double Sum(StringInt16) DoubleSum(StringInt32) Double Sum(StringInt64) DoubleSum(StringSingle)

Conversion Expression Functions

DescriptionFunction Name

Evaluates two expressions and returns the first one if it does notevaluate to NULL the second otherwise The signatures without

NullValue

function name are Boolean(BooleanBoolean) Byte(ByteByte)DateTime(DateTimeDateTime) Decimal(DecimalDecimal)Double(DecimalDouble) Decimal(DecimalInt16 | Int32)Double(DecimalInt64) Single(DecimalSingle)Double(DoubleDecimal | Double | Int16 | Int32 | Int64 | Single)Double(Int16Decimal | Double) Int16(Int16Int16)Int32(Int16Int32) Int64(Int16Int64) Single(Int16Single)Double(Int32Decimal | Double) Int32(Int32Int16 | Int32)Int64(Int32Int64) Double(Int32Single)Double(Int64Decimal |Double | Single) Int64(Int64Int16 | Int32 | Int64)Double(SingleDecimal | Double | Int32 | Int64) Single(SingleInt16| Single) String(StringDecimal | Double | Int16 | Int32 | Int64 |Single | String)

Converts a string with datetime information to a date ToDate(date_string [ format_string]) The default format_string is ldquoDDMON YYYY h24 mm ssrdquo

ToDate

52 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Converts a numeric or string expression to a double ToDouble(numeric | string)

ToDouble

Converts a numeric or string expression to a float ToFloat (numeric| string)

ToFloat

Converts a numeric or string expression to an int32 ToInt32 (nu-meric | string)

ToInt32

Converts a numeric or string expression to an int64 ToInt64 (nu-meric | string)

ToInt64

Converts a numeric or date expression to a string ToString(numer-ic) ToString (DateTime [ format_string]) The default format_stringis ldquoDD-MON-YYYY h24mmssrdquo

ToString

The ToDate function takes a string value representing date andor timeinformation and converts it to a date object The optional format specificationparameter defines the format used in the string to represent the date usingthe abbreviations described in the following table For example for a stringcontaining the date April 2 1998 the format specification should containMonth DD YYYY

The ToString function takes a date value and creates a representation of it ina string The optional format specification parameter allows the user to definethe structure of the string to be created using the abbreviations described inthe following table

DescriptionAbbrevi-ation

Indicates that a year is defined as a two digit number (example 07)YY

Indicates that a year is defined as a four digit number (example 2007)YYYY

Indicates that a month is defined by its name all in uppercase letters (example APRIL)MONTH

Indicates that a month is defined by its name all in lowercase letters (example april)month

Expression | 53

DescriptionAbbrevi-ation

Indicates that a month is defined by its name with the first letter being an uppercaseletter (example April)

Month

Indicates that a month is defined by its abbreviation all in uppercase letters (exampleAPR)

MON

Indicates that a month is defined by its abbreviation all in lowercase letters (exampleapr)

mon

Indicates that a month is defined by its number (example 04)MM

Indicates that a day is defined by its number (example 04)DD

Indicates that a hour is defined by its number in the range [0-24]hh24

Indicates that a hour is defined by its number in the range [1-12]hh12

Represents a default representation of an hour Defaults to hh24hh

Indicates a minute definitionmm

Indicates a second definitionss

Indicates a millisecond definitionms

The meridiem Only considered if used with the time range [1-12] (format hh12)am | pm

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Boolean NullValue(BooleanBoolean) Byte NullValue(ByteByte)DateTime NullValue(DateTimeDateTime) Decimal Null-Value(DecimalDecimal) Decimal NullValue(DecimalInt16)

54 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Decimal NullValue(DecimalInt32) Double NullValue(Decim-alDouble) Double NullValue(DecimalInt64) Double Null-Value(DoubleDecimal) Double NullValue(DoubleDouble)Double NullValue(DoubleInt16) Double NullValue(DoubleInt32)Double NullValue(DoubleInt64) Double Null-Value(DoubleSingle) Double NullValue(Int16Decimal) DoubleNullValue(Int16Double) Double NullValue(Int32Decimal)Double NullValue(Int32Double) Double NullValue(Int32Single)Double NullValue(Int64Decimal) Double Null-Value(Int64Double) Double NullValue(Int64Single) DoubleNullValue(SingleDecimal) Double NullValue(SingleDouble)Double NullValue(SingleInt32) Double NullValue(SingleInt64)Int16 NullValue(Int16Int16) Int32 NullValue(Int16Int32) Int32NullValue(Int32Int16) Int32 NullValue(Int32Int32) Int64 Null-Value(Int16Int64) Int64 NullValue(Int32Int64) Int64 Null-Value(Int64Int16) Int64 NullValue(Int64Int32) Int64 Null-Value(Int64Int64) Single NullValue(DecimalSingle) SingleNullValue(Int16Single) Single NullValue(SingleInt16) SingleNullValue(SingleSingle) String NullValue(StringDecimal) StringNullValue(StringDouble) String NullValue(StringInt16) StringNullValue(StringInt32) String NullValue(StringInt64) StringNullValue(StringSingle) String NullValue(StringString)

-+--++-+-+-+DateTime ToDate(String) DateTime ToDate(StringString)

-+--++-+-+-+Double ToDouble(Byte) Double ToDouble(Decimal) DoubleToDouble(Double) Double ToDouble(Int16) Double To-Double(Int32) Double ToDouble(Int64) Double To-Double(Single) Double ToDouble(String)

-+--++-+-+-+Single ToFloat(Byte) Single ToFloat(Decimal) Single To-Float(Double) Single ToFloat(Int16) Single ToFloat(Int32) SingleToFloat(Int64) Single ToFloat(Single) Single ToFloat(String)

Expression | 55

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Int32 ToInt32(Byte) Int32 ToInt32(Decimal) Int32ToInt32(Double) Int32 ToInt32(Int16) Int32 ToInt32(Int32)Int32 ToInt32(Int64) Int32 ToInt32(Single) Int32 ToInt32(String)

-+--++-+-+-+Int64 ToInt64(Byte) Int64 ToInt64(Decimal) Int64ToInt64(Double) Int64 ToInt64(Int16) Int64 ToInt64(Int32)Int64 ToInt64(Int64) Int64 ToInt64(Single) Int64 ToInt64(String)

-+--++-+-+-+String ToString(Byte) String ToString(DateTime) String To-String(DateTimeString) String ToString(Decimal) String To-String(Double) String ToString(Int16) String ToString(Int32)String ToString(Int64) String ToString(Single)

Date Expression Functions

DescriptionFunction Name

Adds a specified number of months to agiven date expression and returns a Date-Time AddMonths (date_time numeric)

AddMonths

Returns the current date CurrentDate ()CurrentDate

Extracts a specified portion of a date andreturns a DateTime Extract (YEAR|

Extract

MONTH | DAY | HOUR | MINUTE |SECOND date_time)

Calculates the number of months betweentwo provide date expressions and returns

MonthsBetween

56 | Chapter 6 FDO Capabilities

DescriptionFunction Name

a Double MonthsBetween (date_timedate_time)

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+DateTime AddMonths(DateTimeByte) DateTimeAddMonths(DateTimeDecimal) DateTime AddMonths(Date-TimeDouble) DateTime AddMonths(DateTimeInt16) DateTimeAddMonths(DateTimeInt32) DateTime AddMonths(Date-TimeInt64) DateTime AddMonths(DateTimeSingle)

-+--++-+-+-+DateTime CurrentDate()

-+--++-+-+-+DateTime Extract(StringDateTime)

-+--++-+-+-+Double MonthsBetween(DateTimeDateTime)

Geometry Expression Functions

DescriptionFunction Name

Returns a Double which is the area of ageometry Area2D (ltgeometrygt)

Area2D

Returns a Double which is the length of ageometry Length2D (ltgeometrygt)

Length2D

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Area2D(BLOB)

Expression | 57

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Length2D(BLOB)

Mathematical Expression Functions

DescriptionFunction Name

Returns the absolute value of a numeric expression Abs (numeric)The return type is the same as the argument type

Abs

Returns a Double which is the arc cosine of a numeric expressionAcos (numeric)

Acos

Returns a Double which is the arc sine of a numeric expressionAsin (numeric)

Asin

Returns a Double which is the arc tangent of a numeric expressionAtan (numeric)

Atan

Returns a Double which is the arc tangent based on two numericexpressions Atan2 (numeric numeric)

Atan2

Returns a Double which is the cosine of a numeric expression Cos(numeric)

Cos

Returns a Double which is e raised to the power of a numeric ex-pression Exp (numeric)

Exp

Returns a Double which is the natural logarithm of a numeric ex-pression Ln (numeric)

Ln

Returns a Double which is the logarithm of a numeric expressionusing the provided base Log (base_numeric numeric)

Log

58 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Returns the remainder of the division of two numeric expressionsMod (numeric divisior_numeric) The implementation alogirthm

Mod

is Mod (m n) = (sign(m) (abs(m) - (abs(n) Floor(mn)))))mod(154) returns 3 mod(150) returns 15 mod(1162) returns16 mod(11621) returns 11 mod(-154) returns -3 mod(-150)returns -15 The return signatures without the function name areByte(ByteByte | Int16 | Int32 | Int64) Double(ByteDecimal |Double) Single(ByteSingle) Double(Decimal | DoubleByte |Decimal | Double | Int16 | Int32 | Int64 | Single) Int16(Int16Byte| Int16 | Int32 | Int64) Double(Int16Decimal | Double)Single(Int16Single) Int32(Int32Byte) Double(Int32Decimal |Double) Int16(Int32Int16) Int32(Int32Int32 | Int64)Single(Int32Single) Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single) Double(SingleDecimal | Double)

Returns a Double which is the result of a numeric expression raisedto the power of another numeric expression Power (numericpower_numeric)

Power

Returns the remainder of the division of two numeric expressionsRemainder (numeric divisor_numeric) The implementation al-

Remainder

gorithm is Remainder (mn) = (sign(m) (abs(m) - (abs(n) Round(mn)))) remainder(156) returns 3 remainder(155) returns0 remainder(154) returns -1 remainder(1162) returns -04 re-mainder(11621) returns -1 remainder(-154) returns 1 The sig-natures without function name are Int16(ByteByte | Int16)Double(ByteDecimal | Double) Int32(ByteInt32)Int64(ByteInt64) Single(ByteSingle) Double(Decimal |DoubleByte | Decimal | Double | Int16 | Int32 | Int64 | Single)Int16(Int16Byte | Int16 | Int32 | Int32) Double(Int16Decimal |Double) Single(Int16Single) Int32(Int32Byte | Int32 | Int64)Double(Int32Decimal | Double) Int16(Int32Int16)Single(Int32Single)Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single))

Expression | 59

DescriptionFunction Name

Returns a Double which is the sine of a numeric expression Sin(numeric)

Sin

Returns a Double which is the square root of a numeric expressionSqrt (numeric)

Sqrt

Returns a Double which is the tangent of a numeric expressionTan (numeric)

Tan

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Byte Abs(Byte) Decimal Abs(Decimal) Double Abs(Double)Int16 Abs(Int16) Int32 Abs(Int32) Int64 Abs(Int64) SingleAbs(Single)

-+--++-+-+-+Double Acos(Byte) Double Acos(Decimal) Double Acos(Double)Double Acos(Int16) Double Acos(Int32) Double Acos(Int64)Double Acos(Single)

-+--++-+-+-+Double Asin(Byte) Double Asin(Decimal) Double Asin(Double)Double Asin(Int16) Double Asin(Int32) Double Asin(Int64)Double Asin(Single)

-+--++-+-+-+Double Atan(Byte) Double Atan(Decimal) Double Atan(Double)Double Atan(Int16) Double Atan(Int32) Double Atan(Int64)Double Atan(Single)

-+--++-+-+-+Double Atan2(ByteByte) Double Atan2(ByteDecimal) DoubleAtan2(ByteDouble) Double Atan2(ByteInt16) DoubleAtan2(ByteInt32) Double Atan2(ByteInt64) DoubleAtan2(ByteSingle) Double Atan2(DecimalByte) DoubleAtan2(DecimalDecimal) Double Atan2(DecimalDouble) DoubleAtan2(DecimalInt16) Double Atan2(DecimalInt32) DoubleAtan2(DecimalInt64) Double Atan2(DecimalSingle) Double

60 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Atan2(DoubleByte) Double Atan2(DoubleDecimal) DoubleAtan2(DoubleDouble) Double Atan2(DoubleInt16) DoubleAtan2(DoubleInt32) Double Atan2(DoubleInt64) DoubleAtan2(DoubleSingle) Double Atan2(Int16Byte) DoubleAtan2(Int16Decimal) Double Atan2(Int16Double) DoubleAtan2(Int16Int16) Double Atan2(Int16Int32) DoubleAtan2(Int16Int64) Double Atan2(Int16Single) DoubleAtan2(Int32Byte) Double Atan2(Int32Decimal) DoubleAtan2(Int32Double) Double Atan2(Int32Int16) DoubleAtan2(Int32Int32) Double Atan2(Int32Int64) DoubleAtan2(Int32Single) Double Atan2(Int64Byte) DoubleAtan2(Int64Decimal) Double Atan2(Int64Double) DoubleAtan2(Int64Int16) Double Atan2(Int64Int32) DoubleAtan2(Int64Int64) Double Atan2(Int64Single) DoubleAtan2(SingleByte) Double Atan2(SingleDecimal) DoubleAtan2(SingleDouble) Double Atan2(SingleInt16) DoubleAtan2(SingleInt32) Double Atan2(SingleInt64) DoubleAtan2(SingleSingle)

-+--++-+-+-+Double Cos(Byte) Double Cos(Decimal) Double Cos(Double)Double Cos(Int16) Double Cos(Int32) Double Cos(Int64)Double Cos(Single)

-+--++-+-+-+Double Exp(Byte) Double Exp(Decimal) Double Exp(Double)Double Exp(Int16) Double Exp(Int32) Double Exp(Int64)Double Exp(Single)

-+--++-+-+-+Double Ln(Byte) Double Ln(Decimal) Double Ln(Double)Double Ln(Int16) Double Ln(Int32) Double Ln(Int64) DoubleLn(Single)

-+--++-+-+-+Double Log(ByteByte) Double Log(ByteDecimal) DoubleLog(ByteDouble) Double Log(ByteInt16) DoubleLog(ByteInt32) Double Log(ByteInt64) DoubleLog(ByteSingle) Double Log(DecimalByte) DoubleLog(DecimalDecimal) Double Log(DecimalDouble) Double

Expression | 61

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Log(DecimalInt16) Double Log(DecimalInt32) DoubleLog(DecimalInt64) Double Log(DecimalSingle) DoubleLog(DoubleByte) Double Log(DoubleDecimal) DoubleLog(DoubleDouble) Double Log(DoubleInt16) DoubleLog(DoubleInt32) Double Log(DoubleInt64) DoubleLog(DoubleSingle) Double Log(Int16Byte) DoubleLog(Int16Decimal) Double Log(Int16Double) DoubleLog(Int16Int16) Double Log(Int16Int32) DoubleLog(Int16Int64) Double Log(Int16Single) DoubleLog(Int32Byte) Double Log(Int32Decimal) DoubleLog(Int32Double) Double Log(Int32Int16) DoubleLog(Int32Int32) Double Log(Int32Int64) DoubleLog(Int32Single) Double Log(Int64Byte) DoubleLog(Int64Decimal) Double Log(Int64Double) DoubleLog(Int64Int16) Double Log(Int64Int32) DoubleLog(Int64Int64) Double Log(Int64Single) DoubleLog(SingleByte) Double Log(SingleDecimal) DoubleLog(SingleDouble) Double Log(SingleInt16) DoubleLog(SingleInt32) Double Log(SingleInt64) DoubleLog(SingleSingle)

-+--++-+-+-+Byte Mod(ByteByte) Byte Mod(ByteInt16) ByteMod(ByteInt32) Byte Mod(ByteInt64) DoubleMod(ByteDecimal) Double Mod(ByteDouble) DoubleMod(DecimalByte) Double Mod(DecimalDecimal) DoubleMod(DecimalDouble) Double Mod(DecimalInt16) DoubleMod(DecimalInt32) Double Mod(DecimalInt64) DoubleMod(DecimalSingle) Double Mod(DoubleByte) DoubleMod(DoubleDecimal) Double Mod(DoubleDouble) DoubleMod(DoubleInt16) Double Mod(DoubleInt32) DoubleMod(DoubleInt64) Double Mod(DoubleSingle) DoubleMod(Int16Decimal) Double Mod(Int16Double) DoubleMod(Int32Decimal) Double Mod(Int32Double) DoubleMod(Int64Decimal) Double Mod(Int64Double) DoubleMod(SingleDecimal) Double Mod(SingleDouble) Int16Mod(Int16Byte) Int16 Mod(Int16Int16) Int16Mod(Int16Int32) Int16 Mod(Int16Int64) Int16

62 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Mod(Int32Int16) Int16 Mod(Int64Int16) Int32Mod(Int32Byte) Int32 Mod(Int32Int32) Int32Mod(Int32Int64) Int32 Mod(Int64Int32) Int64Mod(Int64Byte) Int64 Mod(Int64Int64) SingleMod(ByteSingle) Single Mod(Int16Single) SingleMod(Int32Single) Single Mod(Int64Single) SingleMod(SingleByte) Single Mod(SingleInt16) SingleMod(SingleInt32) Single Mod(SingleInt64) SingleMod(SingleSingle)

-+--++-+-+-+Double Power(ByteByte) Double Power(ByteDecimal) DoublePower(ByteDouble) Double Power(ByteInt16) DoublePower(ByteInt32) Double Power(ByteInt64) DoublePower(ByteSingle) Double Power(DecimalByte) DoublePower(DecimalDecimal) Double Power(DecimalDouble) DoublePower(DecimalInt16) Double Power(DecimalInt32) DoublePower(DecimalInt64) Double Power(DecimalSingle) DoublePower(DoubleByte) Double Power(DoubleDecimal) DoublePower(DoubleDouble) Double Power(DoubleInt16) DoublePower(DoubleInt32) Double Power(DoubleInt64) DoublePower(DoubleSingle) Double Power(Int16Byte) DoublePower(Int16Decimal) Double Power(Int16Double) DoublePower(Int16Int16) Double Power(Int16Int32) DoublePower(Int16Int64) Double Power(Int16Single) DoublePower(Int32Byte) Double Power(Int32Decimal) DoublePower(Int32Double) Double Power(Int32Int16) DoublePower(Int32Int32) Double Power(Int32Int64) DoublePower(Int32Single) Double Power(Int64Byte) DoublePower(Int64Decimal) Double Power(Int64Double) DoublePower(Int64Int16) Double Power(Int64Int32) DoublePower(Int64Int64) Double Power(Int64Single) DoublePower(SingleByte) Double Power(SingleDecimal) DoublePower(SingleDouble) Double Power(SingleInt16) DoublePower(SingleInt32) Double Power(SingleInt64) DoublePower(SingleSingle)

Expression | 63

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Remainder(ByteDecimal) Double Re-mainder(ByteDouble) Double Remainder(DecimalByte) DoubleRemainder(DecimalDecimal) Double Remainder(Decim-alDouble) Double Remainder(DecimalInt16) Double Re-mainder(DecimalInt32) Double Remainder(DecimalInt64)Double Remainder(DecimalSingle) Double Re-mainder(DoubleByte) Double Remainder(DoubleDecimal)Double Remainder(DoubleDouble) Double Re-mainder(DoubleInt16) Double Remainder(DoubleInt32)Double Remainder(DoubleInt64) Double Re-mainder(DoubleSingle) Double Remainder(Int16Decimal)Double Remainder(Int16Double) Double Re-mainder(Int32Decimal) Double Remainder(Int32Double)Double Remainder(Int64Decimal) Double Re-mainder(Int64Double) Double Remainder(SingleDecimal)Double Remainder(SingleDouble) Int16 Remainder(ByteByte)Int16 Remainder(ByteInt16) Int16 Remainder(Int16Byte) Int16Remainder(Int16Int16) Int16 Remainder(Int16Int32) Int16Remainder(Int16Int64) Int16 Remainder(Int32Int16) Int16Remainder(Int64Int16) Int32 Remainder(ByteInt32) Int32 Re-mainder(Int32Byte) Int32 Remainder(Int32Int32) Int32 Re-mainder(Int32Int64) Int32 Remainder(Int64Int32) Int64 Re-mainder(ByteInt64) Int64 Remainder(Int64Byte) Int64 Re-mainder(Int64Int64) Single Remainder(ByteSingle) Single Re-mainder(Int16Single) Single Remainder(Int32Single) SingleRemainder(Int64Single) Single Remainder(SingleByte) SingleRemainder(SingleInt16) Single Remainder(SingleInt32) SingleRemainder(SingleInt64) Single Remainder(SingleSingle)

-+--++-+-+-+Double Sin(Byte) Double Sin(Decimal) Double Sin(Double)Double Sin(Int16) Double Sin(Int32) Double Sin(Int64) DoubleSin(Single)

-+--++-+-+-+Double Sqrt(Byte) Double Sqrt(Decimal) Double Sqrt(Double)Double Sqrt(Int16) Double Sqrt(Int32) Double Sqrt(Int64)Double Sqrt(Single)

64 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Tan(Byte) Double Tan(Decimal) Double Tan(Double)Double Tan(Int16) Double Tan(Int32) Double Tan(Int64)Double Tan(Single)

Numeric Expression Functions

DescriptionFunction Name

Returns the smallest integer greater than or equal to a numeric ex-pression The return type is the same as the argument type Where

Ceil

the argument is a Decimal Double or Single the returned value isan integral number Ceil(numeric)

Returns the largest integer less than or equal to a numeric expres-sion The return type is the same as the argument type Where the

Floor

argument is a Decimal Double or Single the returned value is anintegral number Floor (numeric)

Returns the rounded value of a numeric expression The return typeis the same as the type of the first argument Round (numeric [number_of_decimals_numeric])

Round

Returns and Int32 which is -1 if the provided numeric expressionevaluates to a value less than 0 0 if the expression evaluates to 0

Sign

and 1 if the expression evaluates to a value bigger than 0 Sign(numeric)

Truncates a numeric or date expression The return type is the sameas the type of the first argument Trunc (date_time YEAR | MONTH

Trunc

Expression | 65

DescriptionFunction Name

| DAY | HOUR | MINUTE) Trunc (numeric [ number_of_decim-als_numeric])

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+++Int64 Ceil(Int64)

-+--++-+-+++Int64 Floor(Int64)

-+--++-+-+-+Byte Ceil(Byte) Decimal Ceil(Decimal) Double Ceil(Double)Int16 Ceil(Int16) Int32 Ceil(Int32) Single Ceil(Single)

-+--++-+-+-+Byte Floor(Byte) Decimal Floor(Decimal) DoubleFloor(Double) Int16 Floor(Int16) Int32 Floor(Int32) SingleFloor(Single)

-+--++-+-+-+Byte Round(Byte) Byte Round(ByteByte) ByteRound(ByteDecimal) Byte Round(ByteDouble) ByteRound(ByteInt16) Byte Round(ByteInt32) ByteRound(ByteInt64) Byte Round(ByteSingle) DecimalRound(Decimal) Decimal Round(DecimalByte) DecimalRound(DecimalDecimal) Decimal Round(DecimalDouble)Decimal Round(DecimalInt16) Decimal Round(Decim-alInt32) Decimal Round(DecimalInt64) DecimalRound(DecimalSingle) Double Round(Double) DoubleRound(DoubleByte) Double Round(DoubleDecimal) DoubleRound(DoubleDouble) Double Round(DoubleInt16) DoubleRound(DoubleInt32) Double Round(DoubleInt64) DoubleRound(DoubleSingle) Int16 Round(Int16) Int16Round(Int16Byte) Int16 Round(Int16Decimal) Int16Round(Int16Double) Int16 Round(Int16Int16) Int16Round(Int16Int32) Int16 Round(Int16Int64) Int16Round(Int16Single) Int32 Round(Int32) Int32Round(Int32Byte) Int32 Round(Int32Decimal) Int32Round(Int32Double) Int32 Round(Int32Int16) Int32

66 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Round(Int32Int32) Int32 Round(Int32Int64) Int32Round(Int32Single) Int64 Round(Int64) Int64Round(Int64Byte) Int64 Round(Int64Decimal) Int64Round(Int64Double) Int64 Round(Int64Int16) Int64Round(Int64Int32) Int64 Round(Int64Int64) Int64Round(Int64Single) Single Round(Single) SingleRound(SingleByte) Single Round(SingleDecimal) SingleRound(SingleDouble) Single Round(SingleInt16) SingleRound(SingleInt32) Single Round(SingleInt64) SingleRound(SingleSingle)

-+--++-+-+-+Int32 Sign(Byte) Int32 Sign(Decimal) Int32 Sign(Double)Int32 Sign(Int16) Int32 Sign(Int32) Int32 Sign(Int64) Int32Sign(Single)

-+--++-+-+-+Byte Trunc(Byte) Byte Trunc(ByteByte) ByteTrunc(ByteDecimal) Byte Trunc(ByteDouble) ByteTrunc(ByteInt16) Byte Trunc(ByteInt32) ByteTrunc(ByteInt64) Byte Trunc(ByteSingle) DateTimeTrunc(DateTimeString) Decimal Trunc(Decimal) DecimalTrunc(DecimalByte) Decimal Trunc(DecimalDecimal)Decimal Trunc(DecimalDouble) Decimal Trunc(Decim-alInt16) Decimal Trunc(DecimalInt32) DecimalTrunc(DecimalInt64) Decimal Trunc(DecimalSingle) DoubleTrunc(Double) Double Trunc(DoubleByte) DoubleTrunc(DoubleDecimal) Double Trunc(DoubleDouble)Double Trunc(DoubleInt16) Double Trunc(DoubleInt32)Double Trunc(DoubleInt64) Double Trunc(DoubleSingle)Int16 Trunc(Int16) Int16 Trunc(Int16Byte) Int16Trunc(Int16Decimal) Int16 Trunc(Int16Double) Int16Trunc(Int16Int16) Int16 Trunc(Int16Int32) Int16Trunc(Int16Int64) Int16 Trunc(Int16Single) Int32Trunc(Int32) Int32 Trunc(Int32Byte) Int32Trunc(Int32Decimal) Int32 Trunc(Int32Double) Int32Trunc(Int32Int16) Int32 Trunc(Int32Int32) Int32Trunc(Int32Int64) Int32 Trunc(Int32Single) Int64Trunc(Int64) Int64 Trunc(Int64Byte) Int64

Expression | 67

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Trunc(Int64Decimal) Int64 Trunc(Int64Double) Int64Trunc(Int64Int16) Int64 Trunc(Int64Int32) Int64Trunc(Int64Int64) Int64 Trunc(Int64Single) SingleTrunc(Single) Single Trunc(SingleByte) SingleTrunc(SingleDecimal) Single Trunc(SingleDouble) SingleTrunc(SingleInt16) Single Trunc(SingleInt32) SingleTrunc(SingleInt64) Single Trunc(SingleSingle)

String Expression Functions

All of these functions return a string

DescriptionFunction Name

Returns the concatenation of two string expressions Concat(boolean | date | numeric | string boolean | date | numeric |string)

Concat

Returns an Int64 which is the position of a substring in a stringexpression Instr(stringstring)

Instr

Returns an Int64 which is the length of a string expressionLength(string)

Length

Converts all uppercase letters in a string expression into lowercaseletters string Lower (string)

Lower

Pads a string expression to the left to a predefined string lengthstring Lpad (string TotalLengthOfResult [ pad-string]) If used withtwo parameters only the pad-string is a single space character

Lpad

Removes leading blanks from a string expression string Ltrim(string)

Ltrim

68 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Pads a string expression to the right to a predefined string lengthstring Rpad (string TotalLengthOfResult [ pad-string]) If used

Rpad

with two parameters only the pad-string is a single space character

Removes trailing blanks from a string expression string Rtrim(string)

Rtrim

Returns a string which is the phonetic representation of a stringexpression See the entry in Wikipedia for more information ht-

Soundex

tpenwikipediaorgwikiSoundex Soundex (string) Soun-dex(lsquoeightrsquo) returns ldquoE230rdquo and Soundex(lsquoexpressionrsquo) returnsldquoE216rdquo

Extracts a substring from a string expression string Substr (stringstart_pos [ length])

Substr

Replaces a set of letters in a string Translate (string from_set_stringto_set_string) If string is ldquoSQLPlus Users Guiderdquo and

Translate

from_set_string is thatis lsquospaceasteriskforward slashsingle quotesingle quotersquo and the to_set_string is___ that islsquounderscoreunderscoreunderscorersquo then the returned stringis lsquoSQL_PLus_Users_Guidersquo Translate looks for each character inthe from_set_string in the string argument and replaces it with thecorresponding character from the to_set_string In this case twospaces are replace by underscores and an asterisk is replaced by nunderscore There is no forward slash in the target string to be re-placed and there is no replacement character in the to_set_stringcorresponding to the single apostrophe character in thefrom_set_string When there is no replacement character in theto_set_string corresponding to a character in the from_set_stringthe character in the from_set_string is removed wherever it is foundin the target string

Removes leading andor trailing blanks from a string expressionTrim ([BOTH | LEADING | TRAILING ] string)

Trim

Expression | 69

DescriptionFunction Name

Converts all lowercase letters in a string expression into uppercaseletters Upper (string)

Upper

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+++++String Concat(StringString)

-+--++-+-+-+String Concat(BooleanBoolean) String Concat(BooleanByte)String Concat(BooleanDateTime) String Concat(BooleanDecim-al) String Concat(BooleanDouble) String Concat(BooleanInt16)String Concat(BooleanInt32) String Concat(BooleanInt64) StringConcat(BooleanSingle) String Concat(BooleanString) StringConcat(ByteBoolean) String Concat(ByteByte) String Con-cat(ByteDateTime) String Concat(ByteDecimal) String Con-cat(ByteDouble) String Concat(ByteInt16) String Con-cat(ByteInt32) String Concat(ByteInt64) String Con-cat(ByteSingle) String Concat(ByteString) String Concat(Date-TimeBoolean) String Concat(DateTimeByte) String Concat(Dat-eTimeDateTime) String Concat(DateTimeDecimal) StringConcat(DateTimeDouble) String Concat(DateTimeInt16) StringConcat(DateTimeInt32) String Concat(DateTimeInt64) StringConcat(DateTimeSingle) String Concat(DateTimeString) StringConcat(DecimalBoolean) String Concat(DecimalByte) StringConcat(DecimalDateTime) String Concat(DecimalDecimal)String Concat(DecimalDouble) String Concat(DecimalInt16)String Concat(DecimalInt32) String Concat(DecimalInt64)String Concat(DecimalSingle) String Concat(DecimalString)String Concat(DoubleBoolean) String Concat(DoubleDateTime)String Concat(DoubleDecimal) String Concat(DoubleDouble)String Concat(DoubleInt16) String Concat(DoubleInt32) StringConcat(DoubleInt64) String Concat(DoubleSingle) StringConcat(DoubleString) String Concat(Int16Boolean) StringConcat(Int16Byte) String Concat(Int16DateTime) String Con-cat(Int16Decimal) String Concat(Int16Double) String Con-cat(Int16Int16) String Concat(Int16Int32) String Con-cat(Int16Int64) String Concat(Int16Single) String Con-

70 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

cat(Int16String) String Concat(Int32Boolean) String Con-cat(Int32Byte) String Concat(Int32DateTime) String Con-cat(Int32Decimal) String Concat(Int32Double) String Con-cat(Int32Int16) String Concat(Int32Int32) String Con-cat(Int32Int64) String Concat(Int32Single) String Con-cat(Int32String) String Concat(Int64Boolean) String Con-cat(Int64Byte) String Concat(Int64DateTime) String Con-cat(Int64Decimal) String Concat(Int64Double) String Con-cat(Int64Int16) String Concat(Int64Int32) String Con-cat(Int64Int64) String Concat(Int64Single) String Con-cat(Int64String) String Concat(SingleBoolean) String Con-cat(SingleByte) String Concat(SingleDateTime) String Con-cat(SingleDecimal) String Concat(SingleDouble) String Con-cat(SingleInt16) String Concat(SingleInt32) String Con-cat(SingleInt64) String Concat(SingleSingle) String Con-cat(SingleString) String Concat(StringBoolean) String Con-cat(StringByte) String Concat(StringDateTime) String Con-cat(StringDecimal) String Concat(StringDouble) String Con-cat(StringInt16) String Concat(StringInt32) String Con-cat(StringInt64) String Concat(StringSingle)

-+--++-+-+-+Int64 Instr(StringString)

-+--++-+-+-+Int64 Length(String)

-+--++-+-+-+String Lower(String)

-+--++-+-+-+String Lpad(StringByte) String Lpad(StringByteString) StringLpad(StringDecimal) String Lpad(StringDecimalString) StringLpad(StringDouble) String Lpad(StringDoubleString) StringLpad(StringInt16) String Lpad(StringInt16String) StringLpad(StringInt32) String Lpad(StringInt32String) StringLpad(StringInt64) String Lpad(StringInt64String) StringLpad(StringSingle) String Lpad(StringSingleString)

-+--++-+-+-+String Ltrim(String)

Expression | 71

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+String Rpad(StringByte) String Rpad(StringByteString) StringRpad(StringDecimal) String Rpad(StringDecimalString) StringRpad(StringDouble) String Rpad(StringDoubleString) StringRpad(StringInt16) String Rpad(StringInt16String) StringRpad(StringInt32) String Rpad(StringInt32String) StringRpad(StringInt64) String Rpad(StringInt64String) StringRpad(StringSingle) String Rpad(StringSingleString)

-+--++-+-+-+String Rtrim(String)

-+--++-+-+-+String Soundex(String)

-+--++-+-+-+String Substr(StringByte) String Substr(StringByteByte) StringSubstr(StringByteDecimal) String Substr(StringByteDouble)String Substr(StringByteInt16) String Substr(StringByteInt32)String Substr(StringByteInt64) String Substr(StringByteSingle)String Substr(StringDecimal) String Substr(StringDecimalByte)String Substr(StringDecimalDecimal) String Substr(StringDecim-alDouble) String Substr(StringDecimalInt16) String Sub-str(StringDecimalInt32) String Substr(StringDecimalInt64)String Substr(StringDecimalSingle) String Substr(StringDouble)String Substr(StringDoubleByte) String Sub-str(StringDoubleDecimal) String Substr(StringDoubleDouble)String Substr(StringDoubleInt16) String Sub-str(StringDoubleInt32) String Substr(StringDoubleInt64) StringSubstr(StringDoubleSingle) String Substr(StringInt16) StringSubstr(StringInt16Byte) String Substr(StringInt16Decimal)String Substr(StringInt16Double) String Sub-str(StringInt16Int16) String Substr(StringInt16Int32) StringSubstr(StringInt16Int64) String Substr(StringInt16Single)String Substr(StringInt32) String Substr(StringInt32Byte) StringSubstr(StringInt32Decimal) String Substr(StringInt32Double)String Substr(StringInt32Int16) String Substr(StringInt32Int32)String Substr(StringInt32Int64) String Substr(StringInt32Single)String Substr(StringInt64) String Substr(StringInt64Byte) StringSubstr(StringInt64Decimal) String Substr(StringInt64Double)

72 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

String Substr(StringInt64Int16) String Substr(StringInt64Int32)String Substr(StringInt64Int64) String Substr(StringInt64Single)String Substr(StringSingle) String Substr(StringSingleByte)String Substr(StringSingleDecimal) String Sub-str(StringSingleDouble) String Substr(StringSingleInt16) StringSubstr(StringSingleInt32) String Substr(StringSingleInt64)String Substr(StringSingleSingle)

-+--++-+-+-+String Translate(StringStringString)

-+--++-+-+-+String Trim(String) String Trim(StringString)

-+--++-+-+-+String Upper(String)

----------+-String Lower(StringString)

----------+-String Upper(StringString)

Miscellaneous Expression Functions

The following functions were not affected by the introduction of the ExpressionBuilder component in FDO 33

DescriptionFunction Name

Returns a geometry that is the subset of the geometry argumentdefined by the polygon specified by the coordinate argumentsCLIP(BLOBDoubleDoubleDoubleDouble)

CLIP

Returns a geometry MOSAIC(BLOB)MOSAIC

Returns a geometry RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

RESAMPLE

Expression | 73

DescriptionFunction Name

Returns a geometry SpatialExtent(BLOB)SpatialExtent

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----BLOB CLIP(BLOBDoubleDoubleDoubleDouble)

--+---+-----BLOB RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

--+---------BLOB SpatialExtents(BLOB)

------+-----BLOB MOSAIC(BLOB)

Filter

In C you access theOSGeoFDOConnectionsCapabilitiesIFilterCapabilities using theIConnection object (connectionFilterCapabilities)

In C++ you access the FdoIFilterCapabilities using the IConnection object(connection-gtGetFilterCapabilities())

DescriptionCapability

Tests if the value of a specified data property is within a givenset of literal values

ConditionType_In

Tests if one expression is equal not equal greater than lessthan greater than or equal to or less than or equal to anotherexpression

ConditionType_Comparison

Tests whether the value of a geometric property is within orbeyond a specified distance of a literal geometric value

ConditionType_Distance

74 | Chapter 6 FDO Capabilities

DescriptionCapability

Tests whether the value of a specified data property matchesa specified pattern

ConditionType_Like

Tests whether the value of a specified data property is nullConditionType_Null

Tests whether the value of a geometric property and a literalgeometric value satisfy the spatial relationship implied by theoperation

ConditionType_Spatial

Tests whether the geometric property value lies beyond aspecified distance of a literal geometric value

DistanceOperations_Beyond

Tests whetherthe geometric property value lies within a spe-cified distance of a literal geometric value

DistanceOperations_Within

Tests whetherthe geometric property value spatially containsthe literal geometric value

SpatialOperations_Contains

Tests whether the geometric property value is covered by theinterior and boundary of the given geometry

SpatialOperations_CoveredBy

Tests whetherthe geometric property value spatially crossesthe given geometry

SpatialOperations_Crosses

Tests whether the geometric property value is spatially disjointfrom the given geometry

SpatialOperations_Disjoint

Tests whether the envelope of the referenced geometricproperty value spatially intersects the given geometry

SpatialOperations_EnvelopeIntersects

Tests whether the geometric property value is spatially equalto the given geometry

SpatialOperations_Equals

Tests whether the geometric property value is inside the in-terior of the given geometry not touching the boundary

SpatialOperations_Inside

Filter | 75

DescriptionCapability

Tests whether the geometric property value spatially intersectsthe given geometry

SpatialOperations_Intersects

Tests whether the geometric property value spatially overlapsthe given geometry

SpatialOperations_Overlaps

Tests whether the geometric property value spatially touchesthe given geometry

SpatialOperations_Touches

Tests whether the geometric property value is spatially withinthe given geometry

SpatialOperations_Within

Tests whether the spatial and distance operations can be ap-plied between two geometric properties Returns false if spatial

SupportsNonLiteralGeometricOperations

and distance operations can be applied only between a geo-metric property and a literal geometry Returns true if spatialand distance operations can be applied

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++++++++SpatialOperations_EnvelopeIntersects ConditionType_In Condi-tionType_Spatial

-+--++++++++SpatialOperations_Intersects

++--++-+++++ConditionType_Null ConditionType_Comparison Condition-Type_Like

-+--+++++-++SpatialOperations_Inside

-+--+++-+-++SpatialOperations_Within

-------+++-+ConditionType_Distance

76 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-----+--+-++SpatialOperations_Disjoint SpatialOperations_Contains

--------+-++SpatialOperations_CoveredBy SpatialOperations_Crosses Spa-tialOperations_Touches SpatialOperations_Equals SpatialOper-ations_Overlaps

--------+--+DistanceOperations_Beyond DistanceOperations_Within

---+--------SupportsNonLiteralGeometricOperations

------------SupportsGeodesicDistance

Geometry

In C you access theOSGeoFDOConnectionsCapabilitiesIGeometryCapabilities using theIConnection object (connectionGeometryCapabilities)

In C++ you access the FdoIGeometryCapabilities using the IConnectionobject (connection-gtGetGeometryCapabilities())

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++FdoDimensionality_XY

+-++++-+++++GeometryType_Polygon GeometryComponentType_Linear-Ring

++-+++-+++++GeometryType_Point

Geometry | 77

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

+--+++-+++++GeometryType_MultiLineString GeometryType_MultiPointGeometryType_LineString

+--+-+-+++++GeometryType_MultiPolygon

+--+++-+--++GeometryComponentType_LineStringSegment

---+++--+-++FdoDimensionality_M FdoDimensionality_Z

+--+-+-+--+-GeometryComponentType_Ring

+--+-+--+-+-GeometryType_MultiGeometry

---+-+-+--+-GeometryType_CurvePolygon GeometryComponentType_Cir-cularArcSegment GeometryType_CurveString Geometry-Type_MultiCurvePolygon GeometryType_MultiCurveString

Raster

In C you access theOSGeoFDOConnectionsCapabilitiesIRasterCapabilities using theIConnection object (connectionRasterCapabilities)

In C++ you access the FdoIRasterCapabilities using the IConnection object(connection-gtGetRasterCapabilities())

DescriptionCapability

Indicates whether or not a provider supports the retrieval andmanipulation of image data

SupportsRaster

Indicates whether or not a provider supports the reduction ofthe amount of detail and data in the image

SupportsSubsampling

78 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the compositionof multiple raster images

SupportsStitching

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----SupportsRaster SupportsSubsampling

------------SupportsStitching

Schema

In C you access theOSGeoFDOConnectionsCapabilitiesISchemaCapabilities using theIConnection object (connectionSchemaCapabilities)

In C++ you access the FdoISchemaCapabilities using the IConnection object(connection-gtGetSchemaCapabilities())

DescriptionCapability

Indicates whether or not a provider supports auto gener-ation of values for the data types represented by the as-terisk Boolean Byte DateTime and Decimal

AutoGenerated_

Indicates whether or not a provider supports the Classtype which does not have a Geometry property

ClassType_Class

Indicates whether or not a provider supports the Classtype which does have a Geometry property

ClassType_FeatureClass

Indicates whether or not a provider supports the spe-cificdata type that replaces the BLOB Boolean Byte

DataType_

Schema | 79

DescriptionCapability

CLOB DateTime Decimal Double Int16 Int32 Int64Single or String

Indicates whether or not a provider supports the use ofthe property types represented by the asterisk as identity

IdentityProperty_

properties BLOB Boolean Byte DateTime DecimalDouble Int16 Int32 Int64 Single and String

Indicates whether or not a provider supports decimals upto the specified number of digits in length

MaximumDecimalPrecision

Indicates whether or not a provider supports decimalswith up to the specified number of digits to the right ofthe decimal point

MaximumDecimalScale

The set of characters which cannot be used in schemaelement names

ReservedCharactersForName

Indicates whether or not a provider supports the associ-ation property

SupportsAssociationProperties

Indicates whether or not a provider supports the automat-ic generation of id property values

SupportsAutoIdGeneration

Indicates whether or not a provider supports multipleidentity properties per class

SupportsCompositeId

Indicates whether or not a provider supports unique valueconstraints on a set of columns

SupportsCompositeUniqueValueConstraints

Indicates whether or not a provider supports the automat-ic generation of ID values that are unique for the entiredatastore rather than just for a particular class

SupportsDataStoreScopeUniqueIdGeneration

Indicates whether or not a provider supports the specific-ation of default values for property definitions

SupportsDefaultValue

80 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the settingof minimums that the input data must greater than andmaximums that the input data must be less than

SupportsExclusiveValueRangeConstraints

Indicates whether or not a provider supports the settingof minimums that the input data must greater than or

SupportsInclusiveValueRangeConstraints

equal to and maximums that the input data must be lessthan or equal to

Indicates whether or not a provider supports class hier-archies in the feature schema

SupportsInheritance

Indicates whether or not a provider supports the definitionof more than one feature schema in the data store

SupportsMultipleSchemas

Indicates whether or not a provider allows property valuesto be null

SupportsNullValueConstraints

Indicates whether or not a provider supports objectproperties A class instance can contain an instance ofanother class

SupportsObjectProperties

Indicates whether or not a provider supports the modific-ation of a schema after its intitial creation

SupportsSchemaModification

Indicates whether or not a provider supports the overrid-ing of the default rules for mapping feature schemas toprovider-specific physical schemas

SupportsSchemaOverrides

Indicates whether or not a provider supports requiringthat a column contain unique values

SupportsUniqueValueConstraints

Indicates whether or not a provider supports requiringthat a column contain values that belong to a value con-straints list

SupportsValueConstraintsList

Schema | 81

Expressible as Boolean

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ClassType_FeatureClass DataType_String

++-+++-+++++IdentityProperty_Int32 DataType_Int32 DataType_DateTimeClassType_Class

++-+-+-+++++DataType_Double

--++-+++++++IdentityProperty_String

-+-+-+-+++++DataType_Int16 DataType_Single IdentityProperty_Int16

-+--++-+++++SupportsAutoIdGeneration SupportsNullValueConstraints

-++-+-+++++-SupportsSchemaOverrides

-+-+++-++++-DataType_Decimal DataType_Boolean

++--++--+-++AutoGenerated_Int32

-+++-+++-+--SupportsInheritance

-+-+-+-++++-DataType_Byte IdentityProperty_Int64 DataType_Int64

---+-+-+++++IdentityProperty_Double IdentityProperty_DateTime Identi-tyProperty_Single

-+-+--++-+++SupportsMultipleSchemas

-+-+-+-+++--SupportsCompositeId

82 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+ReservedCharactersForName

----++-++++-SupportsSchemaModification

-+--+--+++-+MaximumDecimalPrecision MaximumDecimalScale

---+-+-++++-IdentityProperty_Boolean IdentityProperty_Decimal Identi-tyProperty_Byte

-------+++-+SupportsCompositeUniqueValueConstraints SupportsUnique-ValueConstraints

-+-----+++--AutoGenerated_Int64 SupportsDefaultValue

---+-+-+-+--SupportsAssociationProperties

--+---+----+DataType_BLOB

---+---+-+--SupportsObjectProperties

-------+-+--SupportsDataStoreScopeUniqueIdGeneration

-----+-+----SupportsValueConstraintsList SupportsExclusiveValueRangeCon-straints SupportsInclusiveValueRangeConstraints

Not Expressible as a Boolean

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

3838ArcSDE

Schema | 83

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

6565MySQL

10001000nullPostGIS

3838SQLServerSpa-tial

nullnullSDF

255255SHP

2828ODBC

84 | Chapter 6 FDO Capabilities

Schema Management

This chapter describes how to create and work with schemas and explains some issues relatedto schema management For example you can use the FDO feature schema to specify howto represent geospatial features

Schema PackageThe FDO feature schema provides a logical mechanism for specifying how torepresent geospatial features FDO providers are responsible for mapping thefeature schema to some underlying physical data store The FDO feature schemais based somewhat on a subset of the OpenGIS and ISO feature models Itsupports both non-spatial features and spatial features

The Schema package contains a collection of classes that define the logicalfeature schema These classes can be used to set up a feature schema and tointerrogate the metadata from a provider using an object-oriented structureThe logical feature schema provides a logical view of geospatial feature data thatis fully independent from the underlying storage schema All data operationsin FDO are performed against the classes and relationships defined by the logicalfeature schema For example different class types in the feature schema are usedto describe different types of geospatial objects and spatial features

Base Properties

All classes in the feature schema support the concept of base properties whichare properties that are pre-defined either by the FDO API or by a specific FDOfeature provider For example all classes in the schema have two base propertiesClassName and SchemaName These properties can be used to query across aninheritance hierarchy or to process the results of heterogeneous queries FDO

7

85

feature providers can also predefine base properties The following baseproperties are predefined by the FDO API

DescriptionRequiredProperty Name

Name of the schema to which objects of the classbelong read-only string

YSchemaName

Name of the class that defines the object read-onlystring

YClassName

Revision number of the object read-only 64-bit in-teger

NRevisionNumber

NOTE Some providers may use this property tosupport optimistic locking

Cross-Schema References

Some FDO feature providers may support multiple schemas For these providersthe feature schema supports the concept of cross-schema references for classesThis means that a class in one schema may derive from a class in anotherschema relate to a class in another schema or contain an object propertydefinition that is based on a class in another schema

Parenting in the Schema Classes

The feature schema object model defined in the FDO API supports fullnavigation through parenting That is once a schema element is added to anFdoFeatureSchema class it can navigate the object hierarchy upward to theroot FdoFeatureSchema and from there to any other element in the featureschema This parenting support is fully defined in the FdoSchemaElementabstract base class

When inserting features that have object collections the parent object instancemust be identified when inserting the child objects (for example a parentclass ldquoRoadrdquo has an object property called ldquosidewalksrdquo of type ldquoSidewalkrdquo)For more information see Data Maintenance on page 119

Physical Mappings

Each feature provider maps the logical feature schema to an underlyingphysical data store Some feature providers may provide some level of control

86 | Chapter 7 Schema Management

over how the logical schema gets mapped to the underlying physical storageFor example an RDBMS-based feature provider may allow table and columnnames to be specified for classes and properties Since this is entirelyprovider-dependent the FDO API simply provides abstract classes for passingphysical schema and class mappings to the provider(FdoPhysicalSchemaMapping FdoPhysicalClassMappingFdoPhysicalPropertyMapping and FdoPhysicalElementMapping respectively)The implementation of these abstract classes is up to each feature provider

Schema MappingsWhen a provider connects to a data source that it did not create and does adescribe schema command it will map FDO data types to the physical entitescontained in the data source This mapping is called the default schemamapping or alternatively the physical to logical schema mapping

When reverse engineering an existing schema FDO uses the following rulesto select the column(s) to use as the identity property

1 Use the primary key

2 Use a unique index

3 Treat the data as read-only

NOTE When reverse engineering a view FDO will apply rules 1 and 2 to the viewand then if necessary to the base tables

NOTE If FDO detects more than one unique index it calculates a weight for eachindex and selects the lightest one The weight of each index is the sum of theweights of its columns Column weight depends on column type as follows Indexeswith Blobs or Clobs are not chosen If FDO picks a multi-column index as theunique index it creates an identity property for each column in the index

1 for Boolean or Byte

2 for Int16

4 for Int32

8 for Int64 Decimal Double or Float

50 for DateTime

length for String

Schema Mappings | 87

After you use FDO to create a feature schema you can use external means toaccess the data store to inspect what native data types FDO uses for its logicaltypes This mapping is called the logical to physical schema mapping

The following mappings have been documented in the provider appendices

physical to logical schema mappings for ODBC connections to a MicrosoftAccess database an Excel spreadsheet and a text file

physical to logical and logical to physical schema mappings for OracleMySQL Sql Server and Sql Server Spatial

The mechanism for overriding the default schema mapping is described inthe next topic Sample code is located in the FDO Cookbook chapter of thisdocument

Schema OverridesUsing schema overrides FDO applications can customize the mappingsbetween Feature (logical) Schemas and the Physical Schema of the providerdata store

Schema overrides are provider-specific because different FDO providers supportFDO data stores with widely different physical formats Therefore the typesof schema mappings in these overrides also vary between providers Forexample an RDBMS-type provider might provide a mapping to index a set ofcolumns in a class table However other providers would not necessarily beable to work with the concept of an index For information about schemaoverrides support by a specific provider see the appropriate appendix in thisdocument and The Essential FDO

NOTE Some providers support only default schema mappings

Working with SchemasThere are three primary operations involved with schema management

Creating a schema

Describing a schema

Modifying a schema

88 | Chapter 7 Schema Management

Creating a Schema

The following basic steps are required to create a schema (some steps areoptional some may be done in an alternate order to achieve the same result)

Use the FdoFeatureSchemaCreate(ldquoSchemaNamerdquo ldquoFeatureSchemaDescriptionrdquo) method to create a schema

Use the FdoFeatureSchemaGetClasses() method to return a class collection

Use the FdoClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) orFdoFeatureClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) method to createFdoClass or FdoFeatureClass type objects

Use the FdoClassCollectionAdd(class) method to add FdoClass orFdoFeatureClass objects to the class collection

Use the FdoGeometricPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoGeometryProperty

Use the FdoDataPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo) methodto create FdoDataProperty

Use the FdoObjectPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoObjectProperty

Use the FdoClassDefinitionGetProperties() and Add(property) methodsto add property to class definition

Use the FdoIApplySchemaCommandSetFeatureSchema(feature schema)method to set the schema object for the IFdoApplySchemaCommand

Use the FdoAssociationPropertydefinition class to represent the associationbetween two classes The class of the associated class must already bedefined in the feature schema and cannot be abstract

Use the FdoIApplySchemaCommandExecute() method to execute changesto the feature schema

For an example of schema creation see Example Creating a Feature Schemaon page 111

Use the FdoClassDefinitionGetIdentityProperties() and Add(Property Object)methods to set the property as FdoClass or FdoFeatureClass Identifier FDOallows multiple Identifiers for both types of classes although Identifiers haveslight differences in both cases

Working with Schemas | 89

FDOFeatureClassFdoFeatureClass is a class that defines features In the case of GIS they wouldoften be spatial features having some sort of geometry associated with themIn most providers FdoFeatureClass requires a unique identifier to distinguishthe features

However there are identifiers only if no base class exists If the base class hasan identifier the child class does not have one You cannot set an identifierto the child class Any class definition that has a base class cannot also haveany identity properties because it inherits from the base class

Therefore you cannot send an identifier when a feature class is a child sinceit always inherits the identifier from the base class

FDOClassThis class is used for non-spatial data It can act as a stand-alone class whereit would have no association with any other class or if the FdoClass is beingused as an ObjectProperty it can be used to define properties of some otherFdoClass or FdoFeatureClass

ObjectProperty Types

ObjectProperties have the following types

Value

Collection

OrderedCollection

The Value ObjectProperty type has a relationship of one-to-one providing asingle value for each property

The Collection and OrderedCollection ObjectProperty types have aone-to-many relationship where many ObjectProperties may be associatedwith one property Ordered Collections can be stored in an ascending ordescending order

90 | Chapter 7 Schema Management

At least one Identifier will be required if the FdoClass is to be used as astand-alone Class

All Identifiers for FdoDataType_Int64 must not be Read-Only since noneof these will be an auto-generated property value

If creating multiple Identifiers all Identifiers must be set to NOT NULL

Non-Feature Class IssuesA non-feature class in FDO can be created as a stand-alone class a containedclass or both As a contained class it defines a property of another class orfeature class (see FdoFeatureClass and FdoClassType Global Enum) How thisnon-feature class is created affects the way the data is inserted queried andupdated

Stand-alone Class

This type of class stores non-feature data (for example manufacturers) TheFdoClassType_Class must be created with one or more identity properties (seeFdoObjectPropertyDefinition) which is required in order that the class has aphysical container (that is a table in the RDBMS) associated with it If theclass is created without specifying an IdentityProperty only the definition isstored in the metadata which prevents any direct data inserts

Contained Class

This type of class stores non-feature data that defines a property of anotherclass or feature class (for example Sidewalk could be a property of a Roadfeature class the Sidewalk class defines the RoadSidewalk property) In thiscase the FdoClassType_Class does not need to be created with one or moreidentity properties although it can be

Class With IdentityProperty Used as ObjectProperty

This type of class reacts like a stand-alone class however with this type it ispossible to do direct data inserts It can also be populated through a containerclass (for example RoadSidewalk) since it defines an object property (seeFdoObjectPropertyDefinition) If this class is queried directly only the datainserted into the class as a stand-alone is returned The data associated withthe ObjectProperty can only be queried through the container class (forexample RoadSidewalk)

Non-Feature Class Issues | 91

Class Without a Defined IdentityProperty Used as ObjectProperty

Because this class has no defined IdentityProperty it can only be populatedthrough the container class (for example RoadSidewalk) since it definesObjectProperty This class cannot be queried directly The data associated withthe object property can only be queried through the container class (forexample RoadSidewalk) As an object property it is defined as one of thefollowing

Value type property Does not need any identifier since it has a one-to-onerelationship with the container class

Collection type property Requires a local identifier which is an identifierdefined when creating the ObjectProperty object

Ordered Collection type property Requires a local identifier which is anidentifier defined when creating the ObjectProperty object

When defining either a Collection or Ordered Collection type ObjectPropertyyou must set an IdentityProperty attribute for that object property ThisObjectClassIdentityProperty acts only as a local identifier compared to theIdentityProperty set at the class level As a local identifier it acts to uniquelyidentify each item within each collection (for example if the local identifierfor RoadSidewalk is Side there can be multiple sidewalks with Side=rdquoLeftrdquobut only one per Road)

Describing a Schema

Use the FdoIDescribeSchemaExecute function to retrieve anFdoFeatureSchemaCollection in order to obtain any information about existingschema(s) The FdoFeatureSchemaCollection consists of all FdoFeatureSchemasin the data store and can be used to obtain information about any schemaobject including FdoFeatureSchema FdoClass FdoFeatureClass and theirrespective properties The following functions return the main collectionsrequired to obtain information about all schema objects

FdoFeatureSchemaGetClasses method obtains FdoClass andFdoFeatureClasses

FdoClassDefinitionGetProperties method obtains aFdoPropertyDefinitionCollection

FdoClassDefinitionGetBaseProperties method obtains aFdoPropertyDefinitionCollection of the properties inherited from the baseclasses

92 | Chapter 7 Schema Management

NOTE Even if your schema has no base classes (inheritance) all classes will inheritsome properties from system classes

Use these functions throughout the application to obtain any informationabout schema objects For example in order to insert data into a class youmust use these functions to determine what data type is required Descriptionof the data is separate from actions

The example in the following link is a simple function that shows how to useFdoIDescribeSchema and loop through the schema and class containers tosearch for duplicate class names It searches all schemas to ensure that theclass name does not exist in any schema in the data store Class names mustbe unique across the entire FDO database

For a schema description example see Example Describing a Schema andWriting It to an XML File on page 114 NO LABEL

FDO Schema Element Class Diagram

Non-Feature Class Issues | 93

Modifying ModelsAdd schema elements to a model by inserting them into the appropriatecollection

Elements are removed from the model by using either of the followingmethods

Call the FdoSchemaElementDelete() method This flags the element fordeletion when the changes are accepted (generally throughFdoIApplySchema) but the element remains a member of all collectionsuntil that time

Remove the element from the appropriate collection via theFdoSchemaCollectionRemove() or FdoSchemaCollectionRemoveAt()methods This immediately disassociates the element from the collection

Schema Element StatesAll elements within the model maintain a state flag This flag can be retrievedby calling FdoSchemaElementGetElementState() but it cannot be directlyset Instead its state changes in reaction to the changes made to the model

Unchanged When a schema model is retrieved via FdoIDescribeSchemaall elements are initially marked Unchanged

Detached Removing an element from an owning collection sets its stateto Detached

Deleted Calling the Delete() method on an element sets its state to Deleted

Added Placing an element within a collection marks the element as Added

Modified When adding or removing a sub-element such as a propertyelement from a class the class element state will be changed to Modified

Additionally when an element that is contained by another element is changedin any way the containing element is also marked as Modified So for exampleif a new value is added to the SchemaAttributeDictionary of the ldquoClass3rdquoelement in our model both the ldquoClass3rdquo FdoClass object and theFdoFeatureSchema object would be marked as Modified

94 | Chapter 7 Schema Management

The state flags are maintained until the changes are accepted that is whenIApplySchema is executed At that time all elements marked Deleted arereleased and all other elements are set to Unchanged

NOTE When you remove an element from an owning collection its state is markedas Detached All collections currently in FDO are owning collections except forone the collections FdoClassDefinitionGetIdentityProperties()

Rollback MechanismThe FdoFeatureSchema contains a mechanism that allows you to ldquoroll backrdquomodel changes to the last accepted state For example a model retrieved viaFdoIDescribeSchema can have classes added attributes deleted or names anddefault values changed All of these changes are thrown out and the modelreturned to its unmodified state by calling FdoFeatureSchemaRejectChanges()

The converse of this operation is the FdoFeatureSchemaAcceptChanges()method which removes all of the elements with a status of Deleted and setsthe state flag of all other elements to Unchanged Generally this method isonly invoked by FDO provider code after it has processed anFdoIApplySchemaExecute() command Normal FDO clients should not callthis method directly

FDO XML FormatFDO feature schemas can be written to an XML file The FdoFeatureSchemaand FdoFeatureSchemaCollection classes support the FdoXmlSerializableinterface The sample code shows an FdoFeatureSchema object calling theWriteXml() method to generate an XML file containing the feature schemacreated by the sample code

FDO feature schemas can also be read from an XML file TheFdoFeatureSchemaCollection class supports the FdoXmlDeserializable interfaceThe sample code shows an FdoFeatureSchemaCollection object calling theReadXml() method to read a set of feature schemas into memory from an XMLfile The code shows the desired schema being retrieved from the collectionand applied to the data store

The XML format used by FDO is a subset of the Geography Markup Language(GML) standardized by the Open GIS Consortium (OGC) One thing shownin the sample code is a round-trip conversion from FDO feature schema toGML schema back to FDO feature schema To accomplish this round-trip the

Rollback Mechanism | 95

ReadXml() method supports a superset of the GML that is written by theWriteXml() method

The following table specifies the mapping of FDO feature schema elementsto GML elements and attributes This mapping is sufficient to understand theXML file generated from the schema defined by the sample code It alsoprovides a guide for writing a GML schema file by hand This file can then beread in and applied to a data store For more information see ExampleCreating a Schema Read In from an XML File on page 114

Another form of round-trip translation would be from a GML schema producedby another vendorrsquos tool to an FDO feature schema and then back to a GMLschema However the resemblance the of resulting GML schema to the originalGML schema might vary from only roughly equivalent to being exactly thesame

Map FDO Element to GML Schema Fragment

GML Schema FragmentFDO Element

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaN

amegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgisdschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFea

tureSchemaNamegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

see ltMetaDatagt

optional xsimport element to enable schema validation

ltxsimport namespace=httpfdoosgeoorgschema

schemaLocation=ltFDO SDK Install LocationgtdocsXmlS

chemaFdoDocumentxsdgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

FeatureSchema

96 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxsfield xpath=rdquordquogt

ltxsfield xpath=rdquoltidentityPropertyltngtNamegtrdquo

ltxskeygt

ltxselementgt

ClassDefinition(with identity prop-erties)

ltxselement see ClassDefinition (with identity proper

ties)ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

see FeatureClassGeometryProperty

gt

see ltMetaDatagt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

gt

ltxssequencegt

list of properties see DataProperty Geometric

Property

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

FeatureClass

FDO XML Format | 97

GML Schema FragmentFDO Element

lt-- these attributes belong to the xscomplexType element

--gt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

FeatureClass Geo-metryProperty

lt--

minOccurs attribute generated only if value is 1

default attribute generated only if a default value exists

fdoreadOnly attribute generated only if value is true

--gt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxssimpleTypegt

see DataType String or DataType Decimal

ltxssimpleTypegt

ltxselementgt

DataProperty(decimal or string)

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxselementgt

DataProperty (oth-er type)

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

DataType String

98 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxsrestriction base=rdquoxsdecimalrdquogt

ltxstotalDigits value=rdquoltprecisiongtrdquogt

ltxsfractionDigits value=rdquoltscalegtrdquogt

ltxsrestrictiongt

DataType Decimal

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquogmlAbstractGeometryTyperdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

see ltMetaDatagt

ltxselementgt

GeometricProperty(not a defining Fea-tureClass Geo-metryProperty)

FDO XML Format | 99

GML Schema FragmentFDO Element

lt-- the pattern referenced in the xsschema element for

FeatureSchema--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeatureS

chemaCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xselement element for

DataProperty --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoDataProp

ertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt--

the pattern referenced in the xselement element for a

non-feature-defining

GeometricProperty

--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xscomplexType element

for FeatureClass --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeature

ClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

MetaData

Map FDO Datatype to GML Type

GML TypeFDO Datatype

xsbooleanBoolean

fdoByteByte

xsdateTimeDateTime

100 | Chapter 7 Schema Management

GML TypeFDO Datatype

xsdoubleDouble

fdoInt16Int16

fdoInt32Int32

fdoInt64Int64

xsfloatSingle

xsbase64BinaryBLOB

xsstringCLOB

Creating and Editing a GML Schema FileThe sample in this section illustrates the creation of a GML schema filecontaining the definition of an FDO feature schema that contains one featureThe name of this file will have the standard XML schema extension namexsd This means that it contains only one schema and that the root elementis xsschema The ReadXml() method will take a filename argument whoseextension is either xsd or xml In the latter case the file could contain manyschema definitions If it does each schema is contained in an xsschemaelement and all xsschema elements are contained in the fdoDataStoreelement If there is only one schema in the xml file then the fdoDataStoreelement is not used and the root element is xsschema

You may want to validate the schema that you create To do so you mustinclude the optional xsimport line specified in the GML schema fragmentfor FeatureSchema

The sample feature implements a table definition for the Buildings feature inthe Open GIS Consortium document 98-046r1 This table definition isexpressed in an XML format on page 14 of the document and is reproducedas follows

Creating and Editing a GML Schema File | 101

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtbuildingsltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtaddressltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtpositionltnamegt

lttypegtPOINTlttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtfootprintltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

Add GML for the FDO Feature Schema

Start with the skeleton GML for an FDO Feature Schema with the ltMetaDatagtreference replaced by the valid pattern

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaNamegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFeatureSchema

Namegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgt

description arg to static FdoFeatureSchemaCreate()

ltxsdocumentationgt

ltxsannotationgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

102 | Chapter 7 Schema Management

For ltcustomer_urlgt substitute ldquofdo_customerrdquo For ltFeatureSchemaNamegtsubstitute ldquoOGC980461FSrdquo and for description arg substitute ldquoOGCSimple Features Specification for SQLrdquo

Add GML for an FDO Feature Class

Start with the GML that is already written and add the skeleton for an FDOFeature Class which includes the skeleton for a class definition with identityproperties The ltMetaDatagt is replaced with the valid pattern

Creating and Editing a GML Schema File | 103

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoFeatureClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

104 | Chapter 7 Schema Management

gt

ltxssequencegt

list of properties see DataProperty GeometricProperty

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For ltclassNamegt substitute ldquobuildingsrdquo

Set the value of the xselement abstract attribute to false

For ltidentityPropertyNamegt substitute ldquofidrdquo A data property whose nameis ldquofidrdquo will be added

Set the value of the xscomplexType abstract attribute to false

For ltgeometryPropertyNamegt substitute ldquofootprintrdquo

For ltlist of FdoGeometricTypesgt substitute ldquosurfacerdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoFeatureClassCreate() substitute ldquoOGC 98-046r1buildingsrdquo

For lturigt substitute ldquohttpfdoosgeoorgschemardquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoa polygon defines a building perimeterrdquo

This class has no base class so set the value of the xsextension base attributeto lsquogmlAbstractFeatureTypersquo

Add GML for Property Definitions

An integer data property whose name is ldquofidrdquo will be added This property isalready identified as an identity property in the xskey element A string dataproperty whose name is ldquonamerdquo and a geometry property whose name isldquopositionrdquo will also be added

Creating and Editing a GML Schema File | 105

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquoalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquoltpropertyNamegtrdquo

106 | Chapter 7 Schema Management

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

Creating and Editing a GML Schema File | 107

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For the first data property ltpropertyNamegt substitute ldquofidrdquo

For the first data property ltdataTypegt substitute ldquofdoint32rdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquofidrdquo to false

Set the content for xsdocumentation for ldquofidrdquo to ldquofeature idrdquo

For the second data property ltpropertyNamegt substitute ldquoaddressrdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquonamerdquo to false

Set the content for xsdocumentation for ldquoaddressrdquo to ldquoaddress of thebuildingrdquo

For ltlengthgt substitute ldquo64rdquo

For the geometry property ltpropertyNamegt substitute ldquopositionrdquo

For ltlist of FdoGeometricTypesgt substitute ldquopointrdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoposition of the buildingrdquo

The Final Result

After all the required substitutions the GML for the schema containing theBuildings feature is as follows

108 | Chapter 7 Schema Management

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquofidrdquo

Creating and Editing a GML Schema File | 109

type=rdquofdoint32rdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtfeature id

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoaddressrdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtaddress of the building

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquo64rdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquopositionrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquopositionrdquo

fdogeometricTypes=rdquopointrdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtposition of the buildingltxsdocu

mentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

110 | Chapter 7 Schema Management

Schema Management ExamplesExample Creating a Feature Schema

The following sample code creates an FdoFeatureSchema object calledldquoSampleFeatureSchemardquo The schema contains one class which has threeproperties The class and its properties conform to the table definition for theLakes feature in the Open GIS Consortium document 98-046r1 This tabledefinition is expressed in an XML format on page 10 of the document and isreproduced as follows

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtlakesltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstgraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtnameltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtshoreltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

The table definition whose name is ldquolakesrdquo is mapped to an FdoFeatureClassobject called ldquoSampleFeatureClassrdquo The column definition whose name isldquofidrdquo is mapped to an FdoDataPropertyDefinition object calledldquoSampleIdentityDataPropertyrdquo The column definition whose name is ldquonamerdquois mapped to an FdoDataPropertyDefinition object calledldquoSampleNameDataPropertyrdquo The column definition whose name is ldquoshorerdquois mapped to an FdoGeometricPropertyDefinition object calledldquoSampleGeometricPropertyrdquo

Schema Management Examples | 111

Create the ApplySchema command

FdoPtrltFdoIApplySchemagt sampleApplySchema

sampleApplySchema = (FdoIApplySchema )

connection-gtCreateCommand(FdoCommandType_ApplySchema)

Create the feature schema

FdoPtrltFdoFeatureSchemagt sampleFeatureSchema

sampleFeatureSchema = FdoFeatureSchemaCreate(LSampleFeatureS

chema LSample Feature Schema Description)

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

create a feature class ie a class containing a geometric

property set some class level properties

FdoPtrltFdoFeatureClassgt sampleFeatureClass

sampleFeatureClass = FdoFeatureClassCreate(LSampleFeatureClass

LSample Feature Class Description)

sampleFeatureClass-gtSetIsAbstract(false)

get a pointer to the feature classs property collection

this pointer is used to add data and other properties to the

class

FdoPtrltFdoPropertyDefinitionCollectiongt sampleFeatureClassProper

ties

sampleFeatureClassProperties = sampleFeatureClass-gtGetProperties()

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

get a pointer to the feature classs identity property collec

tion

this property is used to add identity properties to the feature

class

FdoPtrltFdoDataPropertyDefinitionCollectiongt sampleFeatureClassId

entityProperties

sampleFeatureClassIdentityProperties = sampleFeatureClass-

gtGetIdentityProperties()

create a data property that is of type Int32 and identifies

the feature uniquely

FdoPtrltFdoDataPropertyDefinitiongt sampleIdentityDataProperty

sampleIdentityDataProperty = FdoDataPropertyDefinitionCre

ate(LSampleIdentityDataProperty LSample Identity Data Property

Description)

sampleIdentityDataProperty-gtSetDataType(FdoDataType_Int32)

112 | Chapter 7 Schema Management

sampleIdentityDataProperty-gtSetReadOnly(false)

sampleIdentityDataProperty-gtSetNullable(false)

sampleIdentityDataProperty-gtSetIsAutoGenerated(false)

add the identity property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleIdentityDataProperty)

sampleFeatureClassIdentityProperties-gtAdd(sampleIdentityDataProp

erty)

create a data property that is of type String and names the

feature

FdoPtrltFdoDataPropertyDefinitiongt sampleNameDataProperty

sampleNameDataProperty = FdoDataPropertyDefinitionCreate(LSam

pleNameDataProperty LSample Name Data Property Description)

sampleNameDataProperty-gtSetDataType(FdoDataType_String)

sampleNameDataProperty-gtSetLength(64)

sampleNameDataProperty-gtSetReadOnly(false)

sampleNameDataProperty-gtSetNullable(false)

sampleNameDataProperty-gtSetIsAutoGenerated(false)

add the name property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleNameDataProperty)

create a geometric property

FdoPtrltFdoGeometricPropertyDefinitiongt sampleGeometricProperty

sampleGeometricProperty = FdoGeometricPropertyDefinitionCre

ate(LSampleGeometricProperty LSample Geometric Property Descrip

tion)

sampleGeometricProperty-gtSetGeometryTypes(FdoGeometricType_Sur

face)

sampleGeometricProperty-gtSetReadOnly(false)

sampleGeometricProperty-gtSetHasMeasure(false)

sampleGeometricProperty-gtSetHasElevation(false)

add the geometric property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleGeometricProperty)

identify it as a geometry property

sampleFeatureClass-gtSetGeometryProperty(sampleGeometricProperty)

add the feature class to the schema

sampleClassCollection-gtAdd(sampleFeatureClass)

point the ApplySchema command at the newly created feature

schema and execute

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

Schema Management Examples | 113

Example Describing a Schema and Writing It to an XML File

The following sample code demonstrates describing a schema and writing itto an XML file

create the DescribeSchema command

FdoPtrltFdoIDescribeSchemagt sampleDescribeSchema

sampleDescribeSchema = (FdoIDescribeSchema )

connection-gtCreateCommand(FdoCommandType_DescribeSchema)

executing the DescribeSchema command returns a feature

schema collection that is the set of feature schema which

reside in the DataStore

FdoPtrltFdoFeatureSchemaCollectiongt sampleFeatureSchemaCollection

sampleFeatureSchemaCollection = sampleDescribeSchema-gtExecute()

find the target feature schema in the collection write it

to an xml file and clear the collection

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleFeatureSchema-gtWriteXml(LSampleFeatureSchemaxml)

sampleFeatureSchemaCollection-gtClear()

Example Destroying a Schema

The following sample code demonstrates destroying a schema

create the DestroySchema command

FdoPtrltFdoIDestroySchemagt sampleDestroySchema

sampleDestroySchema = (FdoIDestroySchema )

connection-gtCreateCommand(FdoCommandType_DestroySchema)

destroy the schema

sampleDestroySchema-gtSetSchemaName(LSampleFeatureSchema)

sampleDestroySchema-gtExecute()

Example Creating a Schema Read In from an XML File

The following sample code demonstrates creating a schema read in from anXML file

sampleFeatureSchemaCollection-gtReadXml(LSampleFeatureSchemaxml)

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

sampleFeatureSchemaCollection-gtClear()

114 | Chapter 7 Schema Management

SampleFeatureSchemaxml

The following sample XML schema is the contents of the file written out bythe WriteXml method belonging to the FdoFeatureSchema class object thatwas created in the preceding sample code

Schema Management Examples | 115

ltxml version=10 encoding=UTF-8 gt

ltxsschema xmlnsxs=httpwwww3org2001XMLSchema

targetNamespace=httpfdo_customerSampleFeatureSchema

xmlnsfdo=httpfdoosgeoorgschema

xmlnsgml=httpwwwopengisnetgml

xmlnsSampleFeatureSchema=httpfdo_customer

SampleFeatureSchema

elementFormDefault=qualified

attributeFormDefault=unqualifiedgt

ltxsannotationgt

ltxsdocumentationgtSample Feature Schema Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsannotationgt

ltxselement name=SampleFeatureClass

type=SampleFeatureSchemaSampleFeatureClassType

abstract=false substitutionGroup=gml_Featuregt

ltxskey name=SampleFeatureClassKeygt

ltxsselector xpath=SampleFeatureClass gt

ltxsfield xpath=SampleIdentityDataProperty gt

ltxskeygt

ltxselementgt

ltxscomplexType name=SampleFeatureClassType

abstract=false

fdogeometryName=SampleGeometricProperty

fdohasMeasure=false

fdohasElevation=false

fdosrsName=SC_0

fdogeometricTypes=surfacegt

ltxsannotationgt

ltxsdocumentationgtSample Feature Class Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsdocumentationgtSample Geometric Property Descrip

tionltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=gmlAbstractFeatureTypegt

ltxssequencegt

ltxselement name=SampleIdentityDataProperty

default=

type=fdoint32gt

ltxsannotationgt

116 | Chapter 7 Schema Management

ltxsdocumentationgt

Sample Identity Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=SampleNameDataProperty

default=gt

ltxsannotationgt

ltxsdocumentationgt

Sample Name Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=xsstringgt

ltxsmaxLength value=64 gt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

Schema Management Examples | 117

118

Data Maintenance

This chapter provides information about using the FDO API to maintain data

Data Maintenance OperationsThe primary operations associated with data maintenance are

Inserting

Updating

Deleting

Transactions

Locking

NOTE Discussion of Transactions and Locking is deferred to a future release of thisdocument

Inserting Values

Preconditions

In a previous chapter we created a feature schema and added a feature class toit The feature class had three properties an integer data property a string dataproperty and a geometric property We applied this feature schema to the datastore We are now ready to create feature data objects which are instances ofthe feature class and insert them into the data store

8

119

Property Values in General

We can now create feature data objects which are instances of the featureclass by defining a set of property values corresponding to the propertiesdefined for the class and then inserting them into the data store

An FDO class correspondends roughly to a table definition in a relationaldatabase and a property of a class corresponds roughly to a column definitionin a table Adding the property values corresponds roughly to adding a rowin the table

The main distinction between a data value or geometry value and a propertyvalue is the order in which they are created A data value or geometry valueobject is created first and is then used to create a property value object Theproperty value object is then added to the value collection object belongingto the Insert command object Then the command is executed

An insert operation consists of the following steps

1 Create the insert command object (type FdoIInsert) this object can bereused for multiple insert operations

2 Point the insert command object at the feature class to which you areadding values (call the SetFeatureClassName(ltclassNamegt) method)

3 From the insert command object obtain a pointer using theGetPropertyValues() method to a value collection object (typeFdoPropertyValueCollection) You will add property values to the insertcommand object by adding values to the collection object

4 Create a data value (type FdoDataValue) or geometry value (typeFdoGeometryValue) object Creating the data value is straightforwardyou pass the string or integer value to a static Create() method Creatingthe geometry value is described in Geometry Property Values on page 121

5 Create a property value (type FdoPropertyValue) object which involvespassing the data value or geometry value object as an argument to a staticCreate() method

6 Add the property value object to the value collection object

7 Execute the Insert command

Data Property Values

A data value object contains data whose type is one of the following

Boolean

120 | Chapter 8 Data Maintenance

Byte

DateTime

Decimal

Double

Int16

Int32

Int64

Single (another floating point type)

String

Binary large object (BLOB)

Character large object (CLOB)

The data value object is added to the data property value object The dataproperty value object is added to the property value collection belonging tothe Insert command

Geometry Property Values

A geometry property value object contains a geometry in the form of a bytearray A geometry can be relatively simple for example a point (a single pairof ordinates) or quite complex for example a polygon (one or more arraysof ordinates) In the latter case a number of geometry objects are created andthen combined together to form the target geometry Finally the targetgeometry is converted to a byte array and incorporated into the geometryproperty value object

Creating a geometry value object consists of the following steps

1 Create a geometry value object (type FdoGeometryValue) using a staticCreate() method

2 Create a geometry factory object (type FdoAgfGeometryFactory) using astatic GetInstance() method This object is used to create the geometryobject or objects which comprise the target geometry

3 Create the required geometry object or objects using the appropriateCreateltgeometrygt method() belonging to the geometry factory object

Inserting Values | 121

4 Use the geometry factory object to convert the target geometry object toa byte array

5 Incorporate the byte array into the geometry property value object

Example Inserting an Integer a String and a Geometry Value

The following sample code shows how to insert an integer a string and ageometry value

122 | Chapter 8 Data Maintenance

create the insert command

FdoPtrltFdoIInsertgt sampleInsert

sampleInsert = (FdoIInsert )

connection-gtCreateCommand(FdoCommandType_Insert)

index returned by the operation which adds a value to the value

collection

FdoInt32 valueCollectionIndex = 0

point the Insert command to the target class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleInsert-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

get the pointer to the value collection used to add properties

to the Insert command

FdoPtrltFdoPropertyValueCollectiongt samplePropertyValues

samplePropertyValues = sampleInsert-gtGetPropertyValues()

create an FdoDataValue for the identity property value

FdoPtrltFdoDataValuegt sampleIdentityDataValue

sampleIdentityDataValue = FdoDataValueCreate(101)

add the FdoDataValue to the identity property value

FdoPtrltFdoPropertyValuegt sampleIdentityPropertyValue

sampleIdentityPropertyValue =

FdoPropertyValueCreate(LSampleIdentityDataProperty

sampleIdentityDataValue)

add the identity property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleIdentityPropertyValue)

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LBlue Lake)

add the FdoDataValue to the name property value

FdoPtrltFdoPropertyValuegt sampleNamePropertyValue

sampleNamePropertyValue =

FdoPropertyValueCreate(LSampleNameDataProperty

sampleNameDataValue)

add the name property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleNamePropertyValue)

create an FdoGeometryValue for the geometry property value

this polygon represents a lake which has an island

the outer shoreline of the lake is defined as a linear ring

the shoreline of the island is defined as a linear ring

the outer shoreline is the external boundary of the polygon

Inserting Values | 123

the island shoreline is an internal linear ring

a polygon geometry can have zero or more internal rings

FdoPtrltFdoGeometryValuegt sampleGeometryValue

sampleGeometryValue = FdoGeometryValueCreate()

create an instance of a geometry factory used to create the

geometry objects

FdoPtrltFdoFgfGeometryFactorygt sampleGeometryFactory

sampleGeometryFactory = FdoFgfGeometryFactoryGetInstance()

define the external boundary of the polygon the shoreline of

Blue Lake

FdoPtrltFdoILinearRinggt exteriorRingBlueLake

FdoInt32 numBlueLakeShorelineOrdinates = 10

double blueLakeExteriorRingOrdinates[] = 520 180 660 230

730 90 480 60 520 180

exteriorRingBlueLake = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numBlueLakeShorelineOrdinates

blueLakeExteriorRingOrdinates)

define the shoreline of Goose Island which is on Blue Lake

this is the sole member of the list of interior rings

FdoPtrltFdoILinearRinggt linearRingGooseIsland

FdoInt32 numGooseIslandShorelineOrdinates = 10

double gooseIslandLinearRingOrdinates[] = 590 180 670 180

670 130 590 130 590 180

linearRingGooseIsland = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numGooseIslandShorelineOrdinates

gooseIslandLinearRingOrdinates)

add the Goose Island linear ring to the list of interior rings

FdoPtrltFdoLinearRingCollectiongt interiorRingsBlueLake

interiorRingsBlueLake = FdoLinearRingCollectionCreate()

interiorRingsBlueLake-gtAdd(linearRingGooseIsland)

create the Blue Lake polygon

FdoPtrltFdoIPolygongt blueLake

blueLake =

sampleGeometryFactory-gtCreatePolygon(exteriorRingBlueLake

interiorRingsBlueLake)

convert the Blue Lake polygon into a byte array

and set the geometry value to this byte array

FdoByteArray geometryByteArray =

sampleGeometryFactory-gtGetAgf(blueLake)

sampleGeometryValue-gtSetGeometry(geometryByteArray)

add the Blue Lake FdoGeometryValue to the geometry property

value

FdoPtrltFdoPropertyValuegt sampleGeometryPropertyValue

124 | Chapter 8 Data Maintenance

sampleGeometryPropertyValue =

FdoPropertyValueCreate(LSampleGeometryProperty

sampleGeometryValue)

add the geometry property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleGeometryPropertyValue)

do the insertion

the command returns an FdoIFeatureReader

FdoPtrltFdoIFeatureReader sampleFeatureReader

sampleFeatureReader = sampleInsert-gtExecute()

Updating Values

After inserting (see Inserting Values on page 119) you can update the valuesThe update operation involves identifying a feature class (ldquotablerdquo) a featureclass object (ldquorowrdquo) and an object property (ldquocolumn in a rowrdquo) to be changedand supplying a new value for the object property to replace the old

First create an FdoIUpdate command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class object whose properties we want to updateand use the command objectrsquos SetFilter() method to attach the command toit Filters are discussed in Filter and Expression Languages on page 139

One of the data properties in the example SampleFeatureClass class definitionis an identity property whose name is ldquoSampleIdentityDataPropertyrdquo andwhose type is fdoInt32 This means that its value uniquely identifies thefeature class object that is the ldquorowrdquo Use the name of the identity propertyin the filter In the Insert operation the value of the identity property was setto be lsquo101rsquo The value of the filter that is needed is ldquo(SampleIdentityDataProperty = 101 )rdquo

Finally create a property value which contains the new value attach it tothe command object and then execute the command

Example Updating Property Values

The following is an example of updating property values

Updating Values | 125

FdoPtrltFdoIUpdategt sampleUpdate

sampleUpdate =

(FdoIUpdate )connection-gtCreateCommand(FdoCommandType_Update)

FdoInt32 numUpdated = 0

point the Update command at the target feature class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleUpdate-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

set the filter to identify which set of properties to update

sampleUpdate-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

get the pointer to the value collection used to add properties

to the Update command

we are reusing the samplePropertyValues object that we used

for the insert operation

samplePropertyValues = sampleUpdate-gtGetPropertyValues()

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LGreen Lake)

set the name and value of the property value

sampleNamePropertyValue-gtSetName(LSampleNameDataProperty)

sampleNamePropertyValue-gtSetValue(sampleNameDataValue)

add the name property value to the property value collection

owned by the Update command

samplePropertyValues-gtAdd(sampleNamePropertyValue)

execute the command

numUpdated = sampleUpdate-gtExecute()

Deleting Values

In addition to inserting (see Inserting Values on page 119) and updating (seeUpdating Values on page 125) values you can delete the values The deletionoperation involves identifying a feature class (ldquotablerdquo) whose feature classobjects (ldquorowsrdquo) are to be deleted

First create an FdoIDelete command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class objects that you want to delete and use thecommand objectrsquos SetFilter() method to attach the filter to it You can use thesame filter that was specified in the preceding section Updating Values onpage 125 Finally execute the command

126 | Chapter 8 Data Maintenance

Example Deleting Property Values

FdoPtrltFdoIDeletegt sampleDelete

sampleDelete =

(FdoIDelete )connection-gtCreateCommand(FdoCommandType_Delete)

FdoInt32 numDeleted = 0

sampleDelete-gt

SetFeatureClassName(LSampleFeatureSchemaSampleFeatureClass)

sampleDelete-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

numDeleted = sampleDelete-gtExecute()

Related Class TopicsThe following classes are used in the preceding Data Maintenance examples

FdoIInsert

FdoPropertyValueCollection

FdoDataValue

FdoPropertyValue

FdoGeometryValue

FdoFgfGeometryFactory

FdoILinearRing

FdoLinearRingCollection

FdoIPolygon

FdoByteArray

FdoIDelete

FdoIUpdate

For more information see FDO API Reference Help

Related Class Topics | 127

128

Performing Queries

This chapter describes how to create and perform queries In the FDO API you can use queriesto retrieve specific features from a data store

Creating a QueryYou create and perform queries using the FdoISelect class which is a memberof the Feature sub-package of the Commands package Queries are used toretrieve features from the data store and are executed against one class at atime The class is specified using the SetFeatureClassName() method inFdoIFeatureCommand The SetFeatureClassName can be used with feature andnon-feature classes

FdoISelect supports the use of filters to limit the scope of features returned bythe command This is done through one of the SetFilter methods available inthe FdoIFeatureCommand class The filter is similar to the SQL WHERE clausewhich specifies the search conditions that are applied to one or more classproperties

Search conditions include spatial and non-spatial conditions Non-spatial queriescreate a condition against a data property such as an integer or string Basiccomparisons (= lt gt gt= lt= =) pattern matching (like) and lsquoInrsquo comparisonscan be specified Spatial queries create a spatial condition against a geometryproperty Spatial conditions are enumerated in FdoSpatialCondition andFdoDistanceCondition

The feature reader (FdoIFeatureReader) is used to retrieve the results of a queryfor feature and non-feature classes To retrieve the features from the readeriterate through the reader using the FdoIFeatureReaderReadNext method()

9

129

Query ExampleIn the Data Maintenance chapter we created an instance of theFdoFeatureClass SampleFeatureClass and assigned values to its integer stringand geometry properties (see Example Inserting an Integer a String and aGeometry Value on page 122) The sample code in the following query exampleselects this instance and retrieves the values of its properties Specifically thesample code does the following

1 Creates the select command and

2 Points the select command at the target FdoFeatureClassSampleFeatureClass and

3 Creates a filter to identify which instance of SampleFeatureClass to selectand

4 Points the select command at the filter and

5 Executes the command which returns an FdoIFeatureReader object and

6 Loops through the feature reader object which contains one or morequery results depending on the filter arguments In the sample codeprovided there is only one result

7 Finally the code extracts the property values from each query result

130 | Chapter 9 Performing Queries

we have one FdoFeatureClass object in the DataStore

create a query that returns this object

create the select command

FdoPtrltFdoISelectgt sampleSelect

sampleSelect = (FdoISelect )

connection-gtCreateCommand(FdoCommandType_Select)

point the select command at the target FdoFeatureClass

SampleFeatureClass

sampleSelect-gtSetFeatureClassName(LSampleFeatureClass)

create the filter by

1 creating an FdoIdentifier object containing the name of

the identity property

FdoPtrltFdoIdentifiergt queryPropertyName

queryPropertyName =

FdoIdentifierCreate(LSampleIdentityDataProperty)

2 creating an FdoDataValue object containing the value of the

identity property

FdoPtrltFdoDataValuegt queryPropertyValue

queryPropertyValue = FdoDataValueCreate(101)

3 calling FdoComparisonConditionCreate() passing in the

the queryPropertyName an enumeration constant signifying an

equals comparison operation and the queryPropertyValue

FdoPtrltFdoFiltergt filter

filter = FdoComparisonConditionCreate(queryPropertyName

FdoComparisonOperations_EqualTo queryPropertyValue)

point the select command at the filter

sampleSelect-gtSetFilter(filter)

execute the select command

FdoPtrltFdoIFeatureReadergt queryResults

queryResults = sampleSelect-gtExecute()

declare variables needed to capture query results

FdoPtrltFdoClassDefinitiongt classDef

FdoPtrltFdoPropertyDefinitionCollectiongt properties

FdoInt32 numProperties = 0

FdoPropertyDefinition propertyDef

FdoPropertyType propertyType

FdoDataType dataType

FdoDataPropertyDefinition dataPropertyDef

FdoString propertyName = NULL

FdoPtrltFdoByteArraygt byteArray

FdoIGeometry geometry = NULL

FdoGeometryType geometryType = FdoGeometryType_None

FdoIPolygon polygon = NULL

Query Example | 131

FdoILinearRing exteriorRing = NULL

FdoILinearRing interiorRing = NULL

FdoIDirectPosition position = NULL

FdoInt32 dimensionality = FdoDimensionality_XY

FdoInt32 numPositions = 0

FdoInt32 numInteriorRings = 0

loop through the query results

while (queryResults-gtReadNext())

get the feature class object and its properties

classDef = queryResults-gtGetClassDefinition()

properties = classDef-gtGetProperties()

loop through the properties

numProperties = properties-gtGetCount()

for(int i = 0 i lt numProperties i++)

propertyDef = properties-gtGetItem(i)

get the property name and property type

propertyName = propertyDef-gtGetName()

propertyType = propertyDef-gtGetPropertyType()

switch (propertyType)

itrsquos a data property

case FdoPropertyType_DataProperty

dataPropertyDef =

dynamic_castltFdoDataPropertyDefinition gt

(propertyDef)

dataType = dataPropertyDef-gtGetDataType()

switch (dataType)

case FdoDataType_Boolean

break

case FdoDataType_Int32

break

case FdoDataType_String

break

default

break

itrsquos a geometric property

convert the byte array to a geometry

and determine the derived type of the geometry

case FdoPropertyType_GeometricProperty

byteArray = queryResults-gtGetGeometry(propertyName)

geometry =

sampleGeometryFactory-gtCreateGeometryFromAgf

(byteArray)

132 | Chapter 9 Performing Queries

geometryType = geometry-gtGetDerivedType()

resolve the derived type into a list of ordinates

switch (geometryType)

case FdoGeometryType_None

break

case FdoGeometryType_Point

break

case FdoGeometryType_LineString

break

case FdoGeometryType_Polygon

polygon = dynamic_castltFdoIPolygon gt(geometry)

exteriorRing = polygon-gtGetExteriorRing()

dimensionality = exteriorRing-

gtGetDimensionality()

numPositions = exteriorRing-gtGetCount()

double X Y Z M

for(int i=0 iltnumPositions i++)

position = exteriorRing-gtGetItem(i)

if (dimensionality amp FdoDimensionality_Z ampamp

dimensionality amp FdoDimensionality_M)

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

M = position-gtGetM()

else if (dimensionality amp FdoDimensionality_Z

ampamp (dimensionality amp FdoDimensionality_M))

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

else

X = position-gtGetX()

Y = position-gtGetY()

numInteriorRings = polygon-

gtGetInteriorRingCount()

for(int i=0 iltnumInteriorRings i++)

interiorRing = polygon-gtGetInteriorRing(i)

do same for interior ring as exterior ring

break

case FdoGeometryType_MultiPoint

break

Query Example | 133

case FdoGeometryType_MultiLineString

break

case FdoGeometryType_MultiPolygon

break

case FdoGeometryType_MultiGeometry

break

case FdoGeometryType_CurveString

break

case FdoGeometryType_CurvePolygon

break

case FdoGeometryType_MultiCurveString

break

case FdoGeometryType_MultiCurvePolygon

break

default

break

default

134 | Chapter 9 Performing Queries

Long TransactionProcessing

This chapter defines long transactions (LT) and long transaction interfaces and explains howto implement LT processing in your application

NOTE For this release the providers that support long transaction processing are AutodeskFDO Provider for Oracle and OSGeo FDO Provider for ArcSDE

What Is Long Transaction ProcessingA long transaction (LT) is an administration unit that is used to groupconditional changes to objects Depending on the situation such a unit cancontain conditional changes to one or to many objects Long transactions areused to modify as-built data in the database without permanently changing theas-built data Long transactions can be used to apply revisions or alternates toan object

A root long transaction is a long transaction that represents permanent dataand that has descendents Any long transaction has a root long transaction asan ancestor in its long transaction dependency graph A leaf long transactiondoes not have descendents

For more information about Oracle-specific long transaction versions andlocking see Locking and Long Transactions

10

135

Supported InterfacesIn the current release of FDO the following long transaction interfaces aresupported

FDOIActivateLongTransaction

FDOIDeactivateLongTransaction

FDOIRollbackLongTransaction

FDOICommitLongTransaction

FDOICreateLongTransaction

FDOIGetLongTransaction

These interfaces are summarized below For more information about theirusage supported methods associated enumerations and readers see the FDOAPI Reference Help

FDOIActivateLongTransaction

The FdoIActivateLongTransaction interface defines theActivateLongTransaction command which activates a long transaction wherefeature manipulation and locking commands operate on it Input to theactivate long transaction command is the long transaction name The Executeoperation activates the identified long transaction

FDOIDeactivateLongTransaction

The FdoIDeactivateLongTransaction interface defines theDeactivateLongTransaction command which deactivates the active longtransaction where feature manipulation and locking commands operate onit If the active long transaction is the root long transaction then no longtransaction will be deactivated

FDOIRollbackLongTransaction

The FdoIRollbackLongTransaction interface defines theRollbackLongTransaction command which allows a user to execute rollbackoperations on a long transaction Two different rollback operations areavailable Full and Partial

136 | Chapter 10 Long Transaction Processing

The operation is executed on all data within a long transaction and on all itsdescendents The data is removed from the database and all versions involvedin the process deleted

NOTE If the currently active long transaction is the same as the one beingcommitted or rolled back then if the commit or rollback succeeds the providerresets the current active long transaction to be the root long transaction If it doesnot succeed the active long transaction is left alone and current If the currentlyactive long transaction is not the same as the one being committed or rolled backthen it is not affected

FDOICommitLongTransaction

The FdoICommitLongTransaction interface defines theCommitLongTransaction command which allows a user to execute commitoperations on a long transaction Two different commit operations areavailable Full and Partial

The commit operation can be performed on a leaf long transaction only Along transaction is a leaf long transaction if it does not have descendents

FDOICreateLongTransaction

The FdoICreateLongTransaction interface defines the CreateLongTransactioncommand which creates a long transaction that is based on the currentlyactive long transaction There is always an active long transaction If the userhas not activated a user-defined long transaction then the root longtransaction is active

Input to the CreateLongTransaction command includes a name and descriptionfor the new long transaction The long transaction name submitted to thecommand has to be unique If it is not unique an exception is thrown

FDOIGetLongTransactions

The FdoIGetLongTransactions interface defines the GetLongTransactionscommand which allows the user to retrieve long transaction information Ifa long transaction name is submitted the command returns the informationfor the named long transaction only If no long transaction name is giventhe command retrieves the names of all available long transactions

For each returned long transaction the user has the option to retrieve a listof descendents andor ancestors

Supported Interfaces | 137

138

Filter and ExpressionLanguages

This chapter discusses the use of filters and filter expressions You can use filters and expressionsto specify to an FDO provider how to identify a subset of the objects in a data store

For more information and implementation details about the expression functions signaturesthe RDBMS-specific built-in support for some of the functions and the provider-specificsupport see the appendix Expression Functions

FiltersFDO uses filters through its commands (including provider-specific commands)to select certain features and exclude others

A filter is a construct that an application specifies to an FDO provider to identifya subset of objects of an FDO data store For example a filter may be used toidentify all Road type features that have 2 lanes and that are within 200 metresof a particular location Many FDO commands use filter parameters to specifythe objects to which the command applies For example a select commandtakes a filter to identify the objects that the application wants to retrieve or adelete command takes a filter to identify the objects that the application wantsto delete from the data store

When a command executes the filter is evaluated for each feature instance andthat instance is included in the scope of the command only if the filter evaluatesto True Filters may be specified either as text or as an expression tree Featureproviders declare their level of support for filters through the filter capabilitiesmetadata Query builders should configure themselves based on the filtercapabilities metadata in order to provide users with a robust user interface Formore information see What Is an Expression on page 19

11

139

ExpressionsFDO uses expressions through its commands (including provider-specificcommands) to specify input values in order to filter features In generalcommands in FDO do not support the SQL command language (the oneexception is the optional SQLCommand) However to facilitate ease of usefor application developers expressions in FDO can be specified using a textualnotation that is based syntactically on expressions and SQL WHERE clausesIn FDO expressions are not intended to work against tables and columns butagainst feature classes properties and relationships For example an expressionto select roads with four or more lanes might look like this

Lanes gt= 4

An expression is a construct that an application can use to build up a filterIn other words an expression is a clause of a filter or larger expression Forexample ldquoLanes gt=4 and PavementType = Asphaltrdquo takes two expressionsand combines them to create a filter

Filter and Expression TextIn general commands in FDO do not support the SQL command language(the one exception is the optional SQLCommand) However to facilitate easeof use for application developers expressions and filters in FDO can be specifiedusing a textual notation that is based syntactically on expressions and SQLWHERE clauses The biggest difference between this approach and SQL is thatthese clauses are not intended to work against tables and columns but againstfeature classes properties and relationships For example a filter to selectroads with four or more lanes might look like

Lanes gt= 4

Similarly a filter to select all PipeNetworks that have at least one Pipe in theproposed state might look like

Pipesstate = proposed

Furthermore a filter to select all existing parcels whose owner contains thetext ldquoSmithrdquo might look like

state = existing and owner like Smith

Finally a filter to select all parcels that are either affected or encroached uponby some change might look like

140 | Chapter 11 Filter and Expression Languages

state in (affected encroached)

Language IssuesThere are a number of language issues to be considered when working withclasses in the Filter Expression and Geometry packages

Provider-specific constraints on text

Filter grammar

Expression grammar

Filter and Expression keywords

Data types

Operators

Special characters

Geometry value

Provider-Specific Constraints on Filter andExpression Text

Some providers may have reserved words that require special rules when usedwith filters and expressions For more information see Oracle Reserved WordsUsed with Filter and Expression Text

Filter Grammar

The rules for entering filter expressions are described in the following sectionsusing BNF notation For more information about BNF notation seehttpcuiunigechdb-researchEnseignementanalyseinfoAboutBNFhtml

The FdoFilterParse() method supports the following filter grammar

Language Issues | 141

ltFiltergt = ( Filter )

| ltLogicalOperatorgt

| ltSearchConditiongt

ltLogicalOperatorgt = ltBinaryLogicalOperatorgt

| ltUnaryLogicalOperatorgt

ltBinaryLogicalOperatorgt =

ltFiltergt ltBinaryLogicalOperationsgt ltFiltergt

ltSearchConditiongt = ltInConditiongt

| ltComparisonConditiongt

| ltGeometricConditiongt

| ltNullConditiongt

ltInConditiongt = ltIdentifiergt IN ( ValueExpressionCollection

)

ltValueExpressionCollectiongt = ltValueExpressiongt

| ltValueExpressionCollectiongt ltValueExpressiongt

ltComparisonConditiongt =

ltExpressiongt ltComparisonOperationsgt ltExpressiongt

ltGeometricConditiongt = ltDistanceConditiongt

| ltSpatialConditiongt

ltDistanceConditiongt =

ltIdentifiergt ltDistanceOperationsgt ltExpressiongt ltdistancegt

ltNullConditiongt = ltIdentifiergt NULL

ltSpatialConditiongt =

ltIdentifiergt ltSpatialOperationsgt ltExpressiongt

ltUnaryLogicalOperatorgt = NOT ltFiltergt

ltBinaryLogicalOperationsgt = AND | OR

ltComparisionOperationsgt =

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

LIKE Like

ltDistanceOperationsgt = BEYOND | WITHINDISTANCE

ltdistancegt = DOUBLE | INTEGER

ltSpatialOperationsgt = CONTAINS | CROSSES | DISJOINT

| EQUALS | INTERSECTS | OVERLAPS | TOUCHES | WITHIN | COVEREDBY |

INSIDE

142 | Chapter 11 Filter and Expression Languages

Expression Grammar

The FdoExpressionParse() method supports the following expression grammar

ltExpressiongt = ( Expression )

| ltUnaryExpressiongt

| ltBinaryExpressiongt

| ltFunctiongt

| ltIdentifiergt

| ltValueExpressiongt

ltBinaryExpressiongt =

ltExpressiongt + ltExpressiongt

| ltExpressiongt - ltExpressiongt

| ltExpressiongt ltExpressiongt

| ltExpressiongt ltExpressiongt

ltDataValuegt =

TRUE

| FALSE

| DATETIME

| DOUBLE

| INTEGER

| STRING

| BLOB

| CLOB

| NULL

ltFunctiongt = ltIdentifiergt ( ltExpressionCollectiongt )

ltExpressionCollectiongt =

| ltExpressiongt

| ltExpressionCollectiongt ltExpressiongt

ltGeometryValuegt = GEOMFROMTEXT ( STRING )

ltIdentifiergt = IDENTIFIER

ltValueExpressiongt = ltLiteralValuegt | ltParametergt

ltLiteralValuegt = ltGeometryValuegt | ltDataValuegt

ltParametergt = PARAMETER | STRING

ltUnaryExpressiongt = - ltExpressiongt

Expression Operator Precedence

The precedence is shown in YACC notation that is the highest precedenceoperators are at the bottom

left Add Subtract

left Multiply Divide

left Negate

Expression Grammar | 143

Filter and Expression Keywords

The following case-insensitive keywords are reserved in the language that isthey cannot be used as identifier or function names

AND BEYOND COMPARE CONTAINS COVEREDBY CROSSES DATE

DISJOINT DISTANCE EQUALS FALSE GeomFromText IN INSIDE

INTERSECTS LIKE NOT NULL OR OVERLAPS RELATE SPATIAL TIME

TIMESTAMP TOUCHES TRUE WITHIN WITHINDISTANCE

Data Types

The available data types are described in this section

Identifier

An identifier can be any alphanumeric sequence of characters other than akeyword Identifiers can be enclosed in double quotes to allow specialcharacters and white space If you need to include a double quote characterinside an identifier double the character for example abcdef

Parameter

Parameters are defined by a colon followed by alphanumeric characters TheFDO filter language extends SQL to allow for a literal string to follow the colonto allow blanks (and other possibilities) for example Enter Name

Determine whether parameters are supported by the FDO Provider you areusing by checking SupportParameters on the Connection interface

String

Strings are literal constants enclosed in single quotes The FDO filter languagealso supports the special characters (left and right single quotes) that MicrosoftWord uses to automatically replace the single quote character typed from thekeyboard If you need to include a single quote character inside a string youcan double the character for example aaabbb

144 | Chapter 11 Filter and Expression Languages

Integer

Integers allow only decimal characters with an optional unary minus signUnary plus is not supported

(-)[0-9]

Double

Floating point numbers have a decimal point can be signed (-) and includean optional exponent (e[0-9])

NOTE If an integer is out of the 32-bit precision range it is converted to floatingpoint

Examples

-34

12345678901234567

12e13

DateTime

Date and time are parsed using the standard SQL literal strings

DATE YYYY-MM-DD

TIME HHMMSS[sss]

TIMESTAMP YYYY-MM-DD HHMMSS[sss]

For example

DATE 1971-12-24

TIMESTAMP 2003-10-23 110002

NOTE The BLOB and CLOB strings are currently not supported If you need tosupport binary input use parameters

Data Types | 145

Operators

The following operators are special characters common to SQL and mostprogramming languages

BinaryOperations

These binary operations are available

+ Add (for compatibility with SQL string concatenation may also be definedusing ldquo||rdquo)

- Subtract

Multiply

Divide

UnaryOperations

These unary operation are available

- Negate

Comparison Operations

These comparison operations are available

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

Operator Precedence

The following precedence is shown from highest to lowest

Negate NOT

Multiply Divide

Add Subtract

146 | Chapter 11 Filter and Expression Languages

EQ NE GT GE LT LE

AND

OR

Special Character

The following special characters are used in ExpressionCollections andValueExpressions to define function arguments and IN conditions

( Left Parenthesis

Comma

) Right Parenthesis

The Colon () is used in defining parameters and the Dot () can be includedin real numbers and identifiers

Geometry Value

Geometry values are handled using a function call GeomFromText(FGF Textstring) as is typical in an SQL query

The Autodesk extension to WKT referred to as FGF Text is a superset of WKT(that is you can enter WKT as valid FGF Text strings) Dimensionality isoptional It can be XY XYM XYZ or XYZM If it is not specified it is assumedto be XY For more information about FGF Text see FGF Text on page 158

NOTE Extra ordinates are ignored rather than generating an error during FGFtext parsing For example in the string ldquoPOINT (10 11 12)rdquo the lsquo12rsquo is ignoredbecause the dimensionality is assumed to be XY

The following is the grammar definition for FGF Text

ltFGF Textgt = POINT ltDimensionalitygt ltPointEntitygt

| LINESTRING ltDimensionalitygt ltLineStringgt

| POLYGON ltDimensionalitygt ltPolygongt

| CURVESTRING ltDimensionalitygt ltCurveStringgt

| CURVEPOLYGON ltDimensionalitygt ltCurvePolygongt

| MULTIPOINT ltDimensionalitygt ltMultiPointgt

Special Character | 147

| MULTILINESTRING ltDimensionalitygt ltMultiLineStringgt

| MULTIPOLYGON ltDimensionalitygt ltMultiPolygongt

| MULTICURVESTRING ltDimensionalitygt ltMultiCurveStringgt

| MULTICURVEPOLYGON ltDimensionalitygt ltMultiCurvePolygongt

| GEOMETRYCOLLECTION ltGeometryCollectiongt

ltPointEntitygt = ( ltPointgt )

ltLineStringgt = ( ltPointCollectiongt )

ltPolygongt = ( ltLineStringCollectiongt )

ltMultiPointgt = ( ltPointCollectiongt )

ltMultiLineStringgt = ( ltLineStringCollectiongt )

ltMultiPolygongt = ( ltPolygonCollectiongt )

ltGeometryCollection ( ltFGF Collection Textgt )

ltCurveStringgt = ( ltPointgt ( ltCurveSegmentCollectiongt ) )

ltCurvePolygongt = ( ltCurveStringCollectiongt )

ltMultiCurveStringgt = ( ltCurveStringCollectiongt )

ltMultiCurvePolygongt = ( ltCurvePolygonCollectiongt )

ltDimensionalitygt = default to XY

| XY

| XYZ

| XYM

| XYZM

ltPointgt = DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE DOUBLE

ltPointCollectiongt = ltPointgt

| ltPointCollection ltPointgt

ltLineStringCollectiongt = ltLineStringgt

| ltLineStringCollectiongt ltLineStringgt

ltPolygonCollectiongt = ltPolygongt

148 | Chapter 11 Filter and Expression Languages

| ltPolygonCollectiongt ltPolygongt

ltFGF Collection Textgt = ltFGF Textgt

| ltFGF Collection Textgt ltFGF Textgt

ltCurveSegmentgt = CIRCULARARCSEGMENT ( ltPointgt ltPointgt )

| LINESTRINGSEGMENT ( ltPointCollectiongt )

ltCurveSegmentCollectiongt = ltCurveSegmentgt

| ltCurveSegmentCollectiongt ltCurveSegmentgt

ltCurveStringCollectiongt = ltCurveStringgt

| ltCurveStringCollectiongt ltCurveStringgt

ltCurvePolygonCollectiongt = ltCurvePolygongt

| ltCurvePolygonCollectiongt ltCurvePolygongt

The only other token type is DOUBLE representing a double precision floatingpoint values Integer (non-decimal point) input is converted to DOUBLE inthe lexical analyzer

Examples of the Autodesk extensions include

POINT XY (10 11) equivalent to POINT (10 11)

POINT XYZ (10 11 12)

POINT XYM (10 11 12)

POINT XYZM (10 11 12 12)

GEOMETRYCOLLECTION (POINT xyz (10 11 12)POINT XYM (30 20 18)LINESTRING XYZM(1 2 3 4 3 5 15 3 20 20))

CURVESTRING (0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40))))

CURVESTRING (0 0 (CIRCULARARCSEGMENT (11 11 12 12)LINESTRINGSEGMENT (10 10 20 20 30 40)))

CURVESTRING (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 30 40)))

CURVESTRING XYZ (0 0 0 (LINESTRINGSEGMENT (10 10 1 20 20 1 30 401)))

MULTICURVESTRING ((0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40)))(00 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 20 20 30 40))))

Geometry Value | 149

CURVEPOLYGON ((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20) ARC(20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 40 40 90 90))))

MULTICURVEPOLYGON (((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90))))((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90)))))

150 | Chapter 11 Filter and Expression Languages

The Geometry API

This chapter describes the FdoGeometry API (hereafter called the ldquoGeometry APIrdquo) and explainsthe various geometry types and formats

IntroductionThe Geometry API supports specific Autodesk applications and APIs includingFDO (Feature Data Objects) This API consists of the following components

a Geometry Type package (all through fully encapsulated interfaces)

an Abstract Geometry Factory

a Concrete Geometry Factory for FGF

You can work with the Geometry API in several different ways

FGF (Feature Geometry Format)

FGF Text

Abstract Geometry Factory

FGF and WKBWKB is a memory layout used to store geometry features This format was createdby the OpenGIS organization to allow the efficient exchange of geometry databetween different components in an FDO system Most pieces of the originalspecification defining the WKB format are in the document 99-050pdf theOpenGIS Simple feature specification for OLECOM that can be found atwwwopengisorg

12

151

FGF is an extended version of the Well Known Binary (WKB) format The twoformats differ in the following ways

WKB defines a byte order of the data in every piece of geometry This isstored as a byte field which may change the memory alignment fromword to byte In FGF only one memory alignment type is supported whichis the same alignment type used by the NET framework and Windowsthe encoding uses the little-endian byte order format As a result the byteflag does not need to be stored

WKB is defined as a 2D format only This is insufficient to represent 3Dpoints polylines and polygons In FGF the dimension flag has been addedIn particular a flag is included for each geometry piece to indicate whetherthe geometry is 2D 3D or even 4D (storing a measure value as used bydynamic segmentation

FGF includes geometry types that are not yet covered by any WKBspecification

FGF Binary SpecificationIn this section the memory layout of each simple geometry type is describedThe format is based on the OGC specification which is built on the memorylayout of a C++ struct All arrays have a computable size and are inline theydo not point to a different location in memory This format allows streamingof geometry data

First the different data types their size and memory layout are discussed

152 | Chapter 12 The Geometry API

double == 8byte IEEE double number in little endian encoding

int == 4 byte integer in little endian encoding

the type of the geometry

enum GeometryType int

None = 0

Point = 1

LineString = 2

Polygon = 3

MultiPoint = 4

MultiLineString = 5

MultiPolygon = 6

MultiGeometry = 7

CurveString = 10

CurvePolygon = 11

MultiCurveString = 12

MultiCurvePolygon = 13

Coordinate Types

This is a bit field for example xym == coordinateDimensionalityXY |CoordinateDimensionalityM The following sequence defines the type ofcoordinates used for this object

enum CoordinateDimensionality FdoInt32

XY = 0

Z = 1

M = 2

Basic Geometry

The following sequence establishes the basic pure geometry

struct Geometry

int geomType

CoordinateDimensionality type

FGF Binary Specification | 153

Notation Definition

The following sequence defines a notation used to specify geometries withina byte stream

154 | Chapter 12 The Geometry API

Define a notation within this specification

int PositionSize(geometry)

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM ||

geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityZ)

return 3

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM | CoordinateDimensionalityZ)

return 4

return 2

struct Point Geometry

int geomType == GeometryTypePoint

CoordinateDimensionality type all types allowed

double[] coords size = PositionSize(this)

struct LineString

int geomType

CoordinateDimensionality type

int numPts gt0

double[] coords size = numPts PositionSize(this)

struct MultiPoint

int geomType

int numPoints gt 0

Point[] points size = numPoints

struct MultiLineString

int geomType

int numLineStrings gt= 0

LineString[] lineStrings size = numLineStrings

building block for polygons not geometry by itself

struct LinearRing

int numPts gt0

double[] coords size = numPts PositionSize(polygon)

FGF Binary Specification | 155

struct Polygon

int geomType

CoordinateDimensionality type

int numRings gt= 1 as there has to be at least one ring

LinearRing[] lineStrings size = numRings

struct MultiPolygon

int geomType

int numPolygons gt= 0

Polygon[] polygons size = numPolygons

struct MultiGeometry

int geomType

int numGeom gt= 0

Geometry[] geometry size = numGeom

enum CurveElementType int

LineString = 1

CircularArc = 2

struct CurveStringElement

int CurveElementType

struct LinearCurveStringElement

int CurveElementType

int length

double[] coords size = thislength PositionSize (this)

struct CircularArcCurveStringElement

int CurveElementType == CurveElmentTypeArc

double[] coords size = 2 PositionSize(this)

struct CurveString

int geomType

156 | Chapter 12 The Geometry API

CoordinateDimensionality type all types allowed

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct Ring

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct MultiCurveString

int geomType

int numCurveStrings gt= 0

CurveString[] curveStrings size = numCurveStrings

struct CurvePolygon

int geomType

CoordinateDimensionality type

int numRings gt=1 as there has to be at least one ring

Ring[] rings size = numRings

struct MultiCurvePolygon

int geomType

int numPolygons gt=0

CurvePolygon[] polygons size = numElements

In the following example a polygon is formatted within a byte arrayrepresenting the stream according to the FGF specification

FGF Binary Specification | 157

T = 3 stands for GeometryType == GeometryTypePolygon

CT = 0 stands for CoordinateDimensionality == CoordinateDimensionalityXY

NR = 2 stands for number of rings = 2

NP =3 stands for number of points = 3

FGF TextFGF Text is the textual analogue to the binary FGF format It is a superset ofthe OGC WKT format XY dimensionality is the default and is optional FGFText can be used to represent any geometry value in the Geometry API whetheror not it originates from the FGF geometry factory Conversions are done withthe following methods

FdoGeometryFactoryAbstract CreateGeometry(FdoString text)

FdoIGeometry GetText()rdquo

A BNF for the FGF textual specification is contained in the topic GeometryValue on page 147

Abstract and Concrete ClassesThe Geometry API is almost completely abstract It provides an object-orientedinterface to geometry values All objects in the Geometry API have factorymethods in the FdoGeometryFactorytAbstract class One defaultimplementation is provided based on FGF in-memory binary storage It isaccessible via the concrete class FdoFgfGeometryFactory

NOTE The FdoFgfGeometryFactory employes object pooling for many of the datatypes in the API While many methods appear to be executing ldquoCreaterdquo or ldquoGetrdquoactions they are in fact accessing object pools thus avoiding costly operationson the memory heap

All of the other classes in the Geometry API with the exception of two relateto the main abstract type FdoIGeometry They either derive from it or arecomponents of it

158 | Chapter 12 The Geometry API

The two exception concrete classes are

FdoDirectPositionImpl a small helper class implementingFdoIDirectPosition

FdoEnvelopeImpl a small helper class implementing FdoIEnvelope

Geometries in FGF format can be exchanged between software componentswithout depending on the Geometry API itself because they are not genuinegeometry ldquoobjectsrdquo FGF content is based on byte arrays It is handled througha simple FdoByteArray class that is not specific to geometry

Geometry TypesThe Geometry types comprise the Global Enum FdoGeometryType Thefollowing are Geometry types

0 FdoGeometryType_None Indicates no specific type used for ldquounknownrdquoldquodo not carerdquo or an incompletely constructed Geometry object

NOTE FdoGeometryType_ None does not represent an instantiable type An FDOclient should not expect an FDO provider to list support for it in its capabilities

1 FdoGeometryType_Point Point type (FdoIPoint)

2 FdoGeometryType_LineString LineString type (FdoILineString)

3 FdoGeometryType_Polygon Polygon type (FdoIPolygon)

4 FdoGeometryType_MultiPoint MultiPoint type (FdoIMultiPoint)

5 FdoGeometryType_MultiLineString MultiLineString type(FdoIMultiLineString)

6 FdoGeometryType_MultiPolygon MultiPolygon type (FdoIMultiPolygon)

7 FdoGeometryType_MultiGeometry MultiGeometry type(FdoIMultiGeometry)

10 FdoGeometryType_CurveString CurveString type (FdoICurveString)

11 FdoGeometryType_CurvePolygon CurvePolygon type(FdoICurvePolygon)

Geometry Types | 159

12 FdoGeometryType_MultiCurveString MultiCurveString type(FdoIMultiCurveString)

13 FdoGeometryType_MultiCurvePolygon MultiCurvePolygon type(FdoIMultiCurvePolygon

Mapping Between Geometry and GeometricTypes

The FDO API GeometricType enumeration of GeometricProperty gives theclient application some knowledge of which geometry types comprise thegeometric property so that it can present the user with an intelligent editorfor selecting styles for rendering the geometry In particular GeometricTyperelates to shape dimensionality of geometries allowed in FDO geometricproperties The nearest analogues in the Geometry API are

FdoDimensionality which pertains to ordinate (not shape) dimensionalityof geometry values

FdoGeometryType which has types whose abstract base types map toGeometric Type

The GeometricType enumeration is as follows

Point = 0x01 Point Type Geometry

Curve = 0x02 Line and Curve Type Geometry

Surface = 0x04 Surface (or Area) Type Geometry

Solid = 0x08 Solid Type Geometry

NOTE The enumeration defines a bit mask and the GetGeometricTypes andSetGeometricTypes methods take and return an integer This is to allow a geometryproperty to be of more than one type For example the callgeometricPropertySetGeometricTypes(Point | Surface)

would allow the geometric property to represent either point type geometry orsurface type geometry (polygons)

160 | Chapter 12 The Geometry API

Spatial ContextSpatial Context is a coordinate system with an identity Any geometries thatare to be spatially related must be in a common spatial context

Providing an identify for each coordinate system supports separate workspacessuch as schematic diagrams which are non-georeferenced However thereare also georeferenced cases In general two users may create drawings usingthe same default spatial parameters (for example rectangular and10000x10000) that have nothing to do with each other If their drawingsare to be put into a common database the spatial context capability of FDOpreserves the container aspect of the data along wih the spatial parameters

The FDO Spatial Context Commands are part of the FDO API They supportcontrol over Spatial Contexts in the following ways

Metadata control Creates and deletes Spatial Contexts

Active Spatial Context A session setting to specify which Spatial Contextto use by default while storingretrieving geometries and performing spatialqueries

There is a default Spatial Context for each database Its attributes (such ascoordinate system) are specified when the database is created This SpatialContext is the active one in any FDO session until a Spatial Context Commandis used to change this state The default Spatial Contextrsquos identifier numberis 0 (zero)

Spatial contexts have two tolerance attributes XYTolerance and ZToleranceThe tolerances are in distance units that depend on the coordinate system inuse Geodetic coordinate systems typically have ldquoon the groundrdquo linear distanceunits instead of the angular (that is degrees minutes or seconds) units usedfor positional ordinates The meter is the most common unit Mostnon-geodetic systems are rectilinear and use the same unit for positionalordinates and distances for example meters or feet

Specify Dimensionality When CreatingGeometries Using String Specifications

When creating a 3D geometry from string specifications you must specify theDimensionality argument XYZ explicitly because the default dimensionalityis XY and the geometry factory code will only process the first two ordinates

Spatial Context | 161

The following code successfully creates pointOne as a 3D point whereaspointTwo is created as a 2D point

FdoFgfGeometryFactory geometryFactory = FdoFgfGeometryFact

oryGetInstance()

FdoIPoint pointOne

pointOne = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT XYZ (1 2 3)rsquo)rdquo))

FdoPoint pointTwo

pointTwo = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT (1 2 3)rsquo)rdquo))

xmlFeatureFlags = FdoXmlFeatureFlagsCreate( None FdoXmlFlagsEr

rorLevel_Normal True FdoXmlFeatureFlagsConflictOption_Add )

Inserting Geometry ValuesFor information about geometry property values see Geometry Property Valueson page 121

See Example Inserting an Integer a String and a Geometry Value on page122 for a code example that shows how to insert a Geometry value

162 | Chapter 12 The Geometry API

FDO Cookbook

IntroductionThis chapter contains code samples of common operations

Some operations like connection must discuss differences among providersReferences are made to both Autodesk proprietary providers and open sourceproviders Providers whose name begins with ldquoAutodeskrdquo are available only incommercial releases of Autodesk products Providers whose name begins withldquoOSGeordquo are available in releases of open source software at httpfdoosgeoorgSome of the open source providers are also available in commercial releases ofAutodesk products

Recommendations

After iterating through readers such IFeatureReader IDataReaderISQLDataReader or DbUserReader call the Close() or Dispose() method Notdoing so may cause unhandled exceptions at some future time Be sure toenclose the statement that returns a reader in a try block so that you canclose the reader in the catch block

RegistryThe registry contains the list of providers that are available in a particular FDOinstallation FDO initializes the registry using the contents of the providersxmlfile that is co-located with the FDO binaries

13

163

The FeatureProviderRegistryFeatureProviderName elements in theprovidersxml file contain fully qualified provider names A fully qualifiedprovider name has four parts which are separated by dot (lsquorsquo) characters Theparts areltdomaingtltshortNamegtltmajorReleaseNumbergtltminorReleaseNumbergtThere are two domains Autodesk and OSGeo The former indicates proprietaryand the latter open source software

Use Cases

Get a fully qualified provider name in order to create a a connection Thefully qualified name contains version numbers so having a dictionary thatmaps generic provider names to the currently loaded fully qualified nameis useful

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager andProviderCollection

OSGeoFDO for IProviderRegistry

IProviderRegistry registry = FeatureAccessManagerGetProviderRe

gistry()

ProviderCollection providers = registryGetProviders()

Map provider short name to fully qualified name

Dictionaryltstring stringgt providerAbbrToFullName = new Diction

aryltstring stringgt()

string shortName = null

foreach (Provider provider in providers)

shortName = providerNameSplit()[1]

providerAbbrToFullName[shortName] = providerName

ConnectionThe connection object contains a connection string property that containsthe connection parameter names and values The connection string propertycan be set by using a connection property dictionary or by assigning a

164 | Chapter 13 FDO Cookbook

connection string directly to it The property dictionaryrsquos methods tell youthe names of the connection parameters their current values and theiroptionality

Some parameters must always be set for a connection to succeed for examplethe OSGeoSDF File parameter and the AutodeskOracle Username Passwordand Service parameters Some parameters need not be set if you accept thedefault value For example the SDF ReadOnly parameter has a default settingof false The Oracle DataStore parameter need not be set if your objective isto obtain the names of the available data stores within the data source In thiscase connecting with Username Password and Service parameters results ina pending connection You can then query the DataStore parameter to getthe list of available data stores set the DataStore parameter to the value ofone of the list members and open the connection again but this time to afully operational state If you already know the name of the data store thatyou want you can set its value at the outset and open the connection fullywithout the intervening step

The following table sets out the names of the connection parameters for eachprovider

Connection ParametersProvider

Username Password Service DataStoreAutodeskOracle

DefaultRasterFileLocationAutodeskRaster

Username Password Service DataStoreAutodeskSqlServer

Server Instance Username Password DatastoreOsGeoArcSDE

DefaultRasterFileLocationOSGeoGdal

Username Password Service OracleSchema KingFdoClassOSGeoKingOracle

Username Password Service DataStoreOSGeoMySQL

UserId Password DataSourceName ConnectionStringGenerateDefaultGeometryProperty

OSGeoODBC

DataSource ReadOnlyOSGeoOGR

Connection | 165

Connection ParametersProvider

Username Password Service DataStoreOSGeoPostGIS

File ReadOnlyOSGeoSDF

DefaultFileLocationOSGeoSHP

Username Password Service DataStoreOSGeoSQLServerSpatial

FeatureServer Username PasswordOSGeoWFS

FeatureServer Username Password DefaultImageHeightOSGeoWMS

Use Cases

Create a connection to get the provider capabilities See the Capabilitieson page 168 topic

Get a list of the connection parameters

Determine the optionality of a parameter

Set the value of a parameter

Open and close connections

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager

OSGeoFDO for IConnectionManager

OSGeoFDOConnections for IConnectionImp IConnectionInfoIConnectionPropertyDictionary ConnectionState

Create a Connection

The connection is created in the closed state

166 | Chapter 13 FDO Cookbook

IConnectionManager connMgr = FeatureAccessManagerGetConnectionMan

ager()

string fullName = providerAbbrToFullName[ldquoOraclerdquo]

IConnectionImp conn = connMgrCreateConnection(fullName) as ICon

nectionImp

Determine the Names of the Parameters

Before a connection can be opened the connection parameters must beidentified and given values You can query a connection to identify theseparameters The code block shows the retrieval of the connection parameternames into a string array

IConnectionInfo connInfo = connectionConnectionInfo

IConnectionPropertyDictionary properties = connInfoConnectionProp

erties

string[] names = propertiesPropertyNames

Determine the Optionality of a Parameter

The code block shows determining the optionality of the first connectionparameter

Boolean isRequired = propertiesIsPropertyRequired(names[0])

Set a Parameter

The code block shows the setting of the Username parameter

propertiesSetProperty(ldquoUsernamerdquo ldquoEXISTINGUSERrdquo)

Get the Connection String

The code block shows getting the connection string value from the connection

string connectionString = connectionConnectionString

Open and Close a Connection

The code block shows opening and closing a connection Valid connectionstates are Busy Closed Open and Pending

ConnectionState connState = connectionOpen()

ConnectionState connState = connectionClose()

Connection | 167

CapabilitiesThe following code samples are a representative listing of the capabilitymethods in each category For a complete listing consult the API referencedocumentation

The capabilities for a provider are statically defined You create a connectionobject for the provider and use this object to query the capabilities Theconnection does not have to be open

Some capabilities are defined as booleans for example support for theDISTINCT operator in a SQL SELECT statement Sample code for this is shownin the Command section Some capabilities are defined by arrays of enumeratedtype values for example the feature commands The presence of the capabilityis determined by testing each value in the array for its equality with one ofthe values in the enumerated type range sample code that tests for thepresence of the create data store command is shown in the Command section

The schema capabilities include a string type that defines the characters thatmay not appear in a schema name and two integer types that define themaximum decimal precision and scale

Use Cases

Get the capabilities of a provider

Write code that executes if the provider currently in use supports it

C

The following namespaces and types are used

OSGeoFDOCommands for CommandType

OSGeoFDOCommandsLocking for LockType

OSGeoFDOCommandsSpatialContext for SpatialContextExtentType

OSGeoFDOCommon for GeometryComponentType GeometryType

OSGeoFDOConnectionsCapabilities for ICommandCapabiltiesIConnectionCapabilities IExpressionCapabilities IFilterCapabilitiesIGeometryCapabilities IRasterCapabilities ISchemaCapabilitiesFunctionDefinitionCollection FunctionDefinitionReadOnlySignatureDefinitionCollection SignatureDefinition

168 | Chapter 13 FDO Cookbook

ReadOnlyArgumentDefinitionCollection ArgumentDefinitionThreadCapability

OSGeoFDOExpression for ExpressionType

OSGeoFDOFilter for ConditionType DistanceOperationsSpatialOperations

OSGeoFDOSchema for ClassType DataType PropertyType

Command

ICommandCapabilities cmdCapabilities = connCommandCapabilities

int[] commands = cmdCapabilitiesCommands

Boolean supportsSelectDistinct = cmdCapabilitiesSupportsSelectDis

tinct()

CommandType cmdType = (CommandType)commands[0]

Boolean supportsCreateDataStore = false

for (int i = 0 i lt commandsGetLength(0) i++)

if (commands[i] == (int)CommandTypeCommandType_CreateDataStore)

supportsCreateDataStore = true

Connection

IConnectionCapabilities connCapabilities = connConnectionCapabil

ities

LockType[] lockTypes = connCapabilitiesLockTypes

SpatialContextExtentType[] spatialContextExtentTypes = connCapab

ilitiesSpatialContextTypes

ThreadCapability threadCapability = connCapabilitiesThreadCapab

ility

Boolean supportsConfiguration = connCapabilitiesSupportsConfigur

ation()

Capabilities | 169

Expression

IExpressionCapabilities exprCapabilities = connectionExpression

Capabilities

ExpressionType[] expressionTypes = exprCapabilitiesExpression

Types

FunctionDefinitionCollection functions = exprCapabilitiesFunc

tions

FunctionDefinition function = functions[0]

ReadOnlySignatureDefinitionCollection signatureDefs = functionSig

natures

SignatureDefinition signatureDef = signatureDefs[0]

PropertyType returnPropertyType = signatureDefReturnPropertyType

if (returnPropertyType == PropertyTypePropertyType_DataProperty)

DataType returnDataType = signatureDefReturnType

ReadOnlyArgumentDefinitionCollection arguments = signatureDefAr

guments

ArgumentDefinition argDef = arguments[0]

PropertyType argPropertyType = argDefPropertyType

if (argPropertyType == PropertyTypePropertyType_DataProperty)

DataType argDataType = argDefDataType

Filter

IFilterCapabilities filterCapabilities = connFilterCapabilities

Boolean supportsGeodesicDistance = filterCapabilitiesSupports

GeodesicDistance()

ConditionType[] conditionTypes = filterCapabilitiesConditionTypes

DistanceOperations[] distanceOperations = filterCapabilitiesDis

tanceOperations

SpatialOperations[] spatialOperations = filterCapabilitiesSpatia

lOperations

170 | Chapter 13 FDO Cookbook

Geometry

IGeometryCapabilities geometryCapabilities = connGeometryCapabil

ities

GeometryType[] geometryTypes = geometryCapabilitiesGeometryTypes

GeometryComponentType[] geometryComponentTypes = geometryCapabil

itiesGeometryComponentTypes

int dimensionalities = geometryCapabilitiesDimensionalities

Boolean HasZ = (dimensionalities amp 1) == 1

Boolean HasM = (dimensionalities amp 2) == 2

NOTE The dimensionalities integer contains bit-field definitions XY is 0 becauseall spatial data has at least an X and Y coordinate Z is 1 and M is 2 Use bitwiseAND (amp) to combine and bitwise OR (|) to separate

Raster

IRasterCapabilities rasterCapabilities = connRasterCapabilities

Boolean supportsRaster = rasterCapabilitiesSupportsRaster()

Schema

ISchemaCapabilities schemaCapabilities = connSchemaCapabilities

DataType[] dataTypes = schemaCapabilitiesDataTypes

ClassType[] classTypes = schemaCapabilitiesClassTypes

string reservedCharactersForName = schemaCapabilitiesReservedChar

actersForName

int maximumDecimalPrecision = schemaCapabilitiesMaximumDecimalPre

cision

DataType[] supportedAutoGeneratedTypes = schemaCapabilitiesSuppor

tedAutoGeneratedTypes

DataType[] supportedIdentityPropertyTypes = schemaCapabilitiesSup

portedIdentityPropertyTypes

Boolean supportsAutoIdGeneration = schemaCapabilitiesSupportsAut

oIdGeneration

Data StoreThe Sql Server SQL Server Spatial Oracle MySQL PostGIS and SDF providerssupport the following data store commands create destroy and with theexception of SDF list SDF is a file-based provider and the rest areRDBMS-based

Data Store | 171

By default the Sql Server Oracle MySQL and SDF providers create data storesthat contain FDO metadata By default the SQL Server Spatial provider createsa data store that does not contain the FDO metadata To make this providercreate a data store that does contain the FDO metadata you must set theIDataStorePropertyDictionary property IsFdoEnabled to true The PostGISprovider creates a data store without the FDO metadata

A provider uses the FDO metadata to

Assign a default spatial context to a Geometric Property Definition duringschema creation

When connected to the SDF Provider the CreateDataStore command createsan SDF file and the DestroyDataStore command deletes it There cannot bemultiple data stores in an SDF file and so there is no need for the list commandUnlike the RDBMS-based providers you do not have to open a pendingconnection in order to create and execute the CreateDataStore commandBefore executing the DestroyDataStore command close the connection

For the RDBMS-based providers creating a data store means creating a containerwithin a database There can be many data stores within a database and thelist command lists them

To create a data store in one of these RDBMS-based providers you open apending connection using an administrator account name and password andthen execute the CreateDataStore command Once you have created the datastore you close the administrator connection and open a normal userconnection This time you give a value to the DataStore connection parameterand open the connection to a fully operational state Before executing theDestroyDataStore command close the connection unset the DataStoreconnection parameter and reopen it using the administrator account nameand password in the pending state

C

The following namespaces are used

OSGeoFDOCommandsDataStore

OSGeoFDOCommands

172 | Chapter 13 FDO Cookbook

ICreateDataStore createDS = connCreateCommand(CommandTypeCom

mandType_CreateDataStore) as ICreateDataStore

IDataStorePropertyDictionary properties = createDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

createDSExecute()

IListDataStores listDS = connCreateCommand(CommandTypeCommand

Type_ListDataStores) as IListDataStores

IDataStoreReader reader = listDSExecute()

IDestroyDataStore destroyDS = connCreateCommand(CommandTypeCom

mandType_DestroyDataStore) as IDestroyDataStore

IDataStorePropertyDictionary properties = destroyDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

destroyDSExecute()

User ManagementThe providers may be categorized into five groups with respect to usermanagement The grouping criteria is the method used to create the username

The first group consists of the AutodeskOracle provider which has access toan FDO API for user management

The second group consists of MySQL SqlServer and SQLServerSpatial Theseproviders support the SQLCommand which can be used to create users

The third group consists of ODBC A username and password may be quiredto connect depending on the back-end data store On XP you use the ODBCData Source Administrator tool to configure the username

The third group consists of the web server providers WFS and WMS Ausername and password may be required depending on the site

The fourth group consists of the file-based providers which do not require ausername and password

The FDO User Management API

The AutodeskOracle provider has access to an FDO API for user managementBefore you can add a user you must have added the f_user_role to the databaseas described in the Preparations topic at the beginning of this chapter Duringthe add user operation the f_user_role is assigned to the new user You must

User Management | 173

open a pending connection using an administrator account name and passwordto add or drop a user

C

The AutodeskFdoFdoUtilitiesUserMgr namespace is used

IUserManagerImp userMgr = new IUserManagerImp(connection)

userMgrAddUser(AUserName APassword)

DbUserReader reader = userMgrGetDbUsers()

userMgrDropUser(AUserName)

The SQLCommand Method for User Management

List usersDrop a userAdd a userProvider

SELECT user FROM mysqluserWHERE user = lsquoAUserNamersquo

DROP USER lsquoAUser-Namersquo

CREATE USER lsquoAUserNamersquoIDENTIFIED BY lsquoAPasswordrsquo

MySQL

GRANT ALL ON TO lsquoAUs-erNamersquo

SELECT name FROM sysserv-er_principals WHERE name =lsquoAUserNamersquo

EXEC sp_droploginloginame = lsquoAUser-Namersquo

CREATE LOGIN AUserNameWITH password = lsquoAPass-wordrsquo EXEC sp_addsrvrole-

SqlServer andSQLServerSpa-tial

member loginame = lsquoAUs-erNamersquo rolename =lsquosysadminrsquo

C

The code samples use the SQL syntax supported by MySQL in the stringspassed to the FDO API command calls

The following namespaces are used

OSGeoFDOCommandsSQL

OSGeoFDOCommands

174 | Chapter 13 FDO Cookbook

create a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = create user AUserName identified by

APassword

int returnVal = sqlCommandExecuteNonQuery()

sqlCommandSQLStatement = grant all on to AUserName

returnVal = sqlCommandExecuteNonQuery()

drop a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = drop user AUserName

int returnVal = sqlCommandExecuteNonQuery()

list users

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = select user from mysqluser where user

= AUserName

ISQLDataReader reader = sqlCommandExecuteReader()

readerClose()

Spatial ContextA spatial context specifies a coordinate system and an extent for a set ofgeometries The spatial context object has a Name property The value of theName property is assigned to the SpatialContextAssociation property of theGeometricPropertyDefinition object that defines a feature or non-featuregeometry belonging to a feature class In this way a coordinate system andextent is associated with geometry values inserted into the data store as partof instances of the class Example code showing this association is containedin the Basic Schema Operations on page 178 topic

NOTE It is worth emphasizing that each geometric property definiton in a featureclass definition can have a different spatial context This mechanism replaces thatof the active spatial context

The data stores created by the Oracle Sql Server MySQL and optionally theSQL Server Spatial providers contain metadata that supports the assignmentof a default spatial context to a Geometric Property Definition during schema

Spatial Context | 175

creation in the event that the user has not explicitly assigned one The attributevalues of the default spatial context are set out in the following table

ValueAttribute

DefaultName

ltno valuegtCoordinateSystem

ltno valuegtCoordinateSystemWkt

SpatialContextExtentType_StaticExtentType

POLYGON((-2000000 -2000000 2000000 -20000002000000 2000000 -2000000 2000000 -2000000 -2000000))

Extent

C

The code samples show how to create a spatial context and how to get thespatial contexts from a data store

The following namespaces are used

OSGeoFDOCommandsSpatialContext

OSGeoFDOGeometry

OSGeoFDOConnections

176 | Chapter 13 FDO Cookbook

get the spatial contexts from a data store

IGetSpatialContexts getSpatialContexts = connectionCreateCom

mand(CommandTypeCommandType_GetSpatialContexts) as IGetSpatialCon

texts

ISpatialContextReader reader = getSpatialContextsExecute()

string name = null

string coordSys = null

string wellKnownText = null

string desc = null

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IGeometry geom = null

string extent = null

SpatialContextExtentType extentType

double xyTolerance

double zTolerance

while (readerReadNext())

name = readerGetName()

coordSys = readerGetCoordinateSystem()

wellKnownText = readerGetCoordinateSystemWkt()

desc = readerGetDescription()

geom = geomFactoryCreateGeometryFromFgf(readerGetExtent())

extent = geomText

extentType = readerGetExtentType()

xyTolerance = readerGetXYTolerance()

zTolerance = readerGetZTolerance()

readerDispose()

Spatial Context | 177

create a spatial context whose coordinate system is WGS84 and

whose extent is the maximum

create the extent

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

ICreateSpatialContext createSpatialContext = connectionCreateCom

mand(CommandTypeCommandType_CreateSpatialContext) as ICreateSpa

tialContext

createSpatialContextCoordinateSystem =

createSpatialContextCoordinateSystemWkt = wgs84Wkt

createSpatialContextDescription = This Coordinate System is used

for GPS

a static extent is defined once and never changed

a dynamic extent grows to accommodate the geometries added to

the data store

createSpatialContextExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

createSpatialContextExtent = extent

the value of Name is assigned to the SpatialContextAssociation

attribute of a GeometricPropertyDefinition object during the

creation of the logical feature schema

in this way a coordinate system and extent is associated with

the geoemtries

createSpatialContextName = WGS84 Spatial Context

createSpatialContextExecute()

Basic Schema OperationsAll providers allow you to describe a schema but only SDF SHP MySQLPostGIS SqlServer SQLServerSpatial KingOracle and Oracle allow you toapply and destroy a schema

178 | Chapter 13 FDO Cookbook

C

The code samples show how to describe apply and destroy a schema

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommands

OSGeoFDOSchema

describe a schema

IDescribeSchema descSchema = connCreateCommand(CommandTypeCom

mandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

FeatureSchema schema = schemas[0]

ClassCollection classes = schemaClasses

Class featureClass = classes[0]

PropertyDefinitionCollection properties = featureClassProperties

PropertyDefinition property = properties[0]

PropertyType propertyType = propertyPropertyType

if (propertyType == PropertyTypePropertyType_DataProperty)

DataPropertyDefinition dataPropDef = property as DataPropertyDefin

ition

DataType dataType = dataPropDefDataType

Basic Schema Operations | 179

create and apply a schema

FeatureSchema schema = new FeatureSchema(AnApplicationSchema

This schema contains one feature class)

FeatureClass featClass = new FeatureClass(AFeatureClass This

feature class contains one identity property one data property and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(ID

This is the identity property)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = true

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition int32Prop = new DataPropertyDefini

tion(Int32Prop This is an Int32 property)

int32PropDataType = DataTypeDataType_Int32

propertiesAdd(int32Prop)

add the feature geometry

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(FeatGeomProp This is the feature geometry)

associate this geometric property with a spatial context

you must have already added the named context to the data store

if this property is not set it is assigned the default spatial

context

see the Spatial Context topic to read a description of the de

fault spatial context

featGeomPropSpatialContextAssociation = XY-M Spatial Context

by default this geometric property can contain geometries that

may be classified as point curve surface or solid

also by default this geometric property cannot contain geomet

ries that have a Z ordinate or a measure attribute

propertiesAdd(featGeomProp)

without the following line you would be adding a non-feature

geometry

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

apply the schema

180 | Chapter 13 FDO Cookbook

IApplySchema applySchema = connCreateCommand(CommandTypeCommand

Type_ApplySchema) as IApplySchema

applySchemaFeatureSchema = schema

applySchemaExecute()

destroy the schema

IDestroySchema destroySchema = connCreateCommand(CommandTypeCom

mandType_DestroySchema) as IDestroySchema

destroySchemaSchemaName = AnApplicationSchema

destroySchemaExecute()

Insert DataAll providers except Gdal Raster WFS and WMS allow you to insert data

C

The code sample shows how to insert a feature consisting of a data value anda geometry value

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOGeometry

Insert Data | 181

Identifier className = new Identifier(FeatureClass)

IInsert insert = connCreateCommand(CommandTypeCommandType_Insert)

as IInsert

insertFeatureClassName = className

PropertyValueCollection values = insertPropertyValues

add the Int32 value to the insert command

int32Value = new Int32Value(5)

int32PropVal = new PropertyValue(Int32Prop int32Value)

valuesAdd(int32PropVal)

add the feature geometry to the insert command

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

DirectPositionImpl position1 = new DirectPositionImpl(10 10)

IPoint point = geomFactoryCreatePoint(position1)

GeometryValue geomVal = new GeometryValue(geomFactoryGet

Fgf(point))

PropertyValue geomPropVal = new PropertyValue(FeatGeomProp

geomVal)

valuesAdd(geomPropVal)

insert the feature

IFeatureReader reader = insertExecute()

readerClose()

Select DataAll providers allow you to select data

C

In the following code sample the filter is set to retrieve values for each featurein the database Without adding a computed identifier to the select commandrsquosproperty collection the select command would return all of the propertyvalues for each feature in the database In this example the computed identifiercontains a function expression that converts the DateTime value in theDateTimeProp property to a string and returns the string So the select returnsa set of DateTime strings

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

182 | Chapter 13 FDO Cookbook

OSGeoFDOFilter

Identifier className = new Identifier(FeatureClass)

ISelect select = connCreateCommand(CommandTypeCommandType_Select)

as ISelect

selectFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectFilter = filter

ComputedIdentifier computedId = ExpressionParse((ToString(Date

TimeProp) as computedId)) as ComputedIdentifier

selectPropertyNamesAdd(computedId)

IFeatureReader reader = selectExecute()

readerClose()

Select Aggregate DataAll providers except the PostGIS provider allow you to select aggregate data

C

In the following code sample the filter is set to retrieve values for each featurein the database The computed identifier contains a function expression thattakes the average of all of the values in the property whose name is Int32Propand returns a double

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

Select Aggregate Data | 183

Identifier className = new Identifier(FeatureClass)

ISelectAggregates selectAggregates = connCreateCommand(Command

TypeCommandType_SelectAggregates) as ISelectAggregates

selectAggregatesFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectAggregatesFilter = filter

ComputedIdentifier computedId = ExpressionParse((Avg(Int32Prop)

as computedId)) as ComputedIdentifier

selectAggregatesPropertyNamesAdd(computedId)

IDataReader reader = selectAggregatesExecute()

readerClose()

Delete DataAll providers except Gdal Raster WFS and WMS allow you to delete data

C

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

delete all of the data

ID is the name of the identity property

Filter filter = FilterParse(ID gt= 0)

Identifier className = new Identifier(FeatureClass)

IDelete delete = connCreateCommand(CommandTypeCommandType_Delete)

as IDelete

deleteFeatureClassName = className

deleteFilter = filter

int numDeleted = deleteExecute()

Schema OverridesWhen FDO connects to a datastore with an existing schema and describes theschema it maps the native data types to FDO data types to create a default

184 | Chapter 13 FDO Cookbook

physical to logical schema mapping You can create a schema mapping thatoverrides the default FDO mapping This schema override must be appliedevery time that you connect to the data store Use the providerrsquos SchemaOverride API to write a program that defines the overrides and writes themto an XML configuration file Thereafter before opening the connection tothe provider set the connection objectsrsquos configuration property to point tothe XML configuration file

The key elements to a schema override are an FDO feature schema and amapping of column names in the existing table to property names in the FDOfeature schema The ODBC provider supports the mapping of two columnnames in an existing table to a 2D FDO point geometry property and optionallysupports the mapping of three columns to a 3D point geometry property Inthe event that the mapping includes an FDO geometry property a spatialcontext definition should be provided

The description given here is based on sample code written to define a schemaoverride for a table in a Microsoft Access database The following table showsthe name of the column in the Access database which is the same as thedefault FDO property name the FDO property name assigned by the schemaoverride a description of the contents of the column the FDO data typeassigned by the default schema mapping and the FDO data type assigned bythe schema override

The default schema mapping of the CITY_ID and POPULATION columns areoverriden to assign them different data types than the default ones and togive them different names A change in case counts as a change in name Thedefault schema mapping of the LATITUDE and LONGITUDE columns areoverriden because they are combined into a single property that has a differentname and a different type than the defaults The default schema mapping ofthe NAME COUNTRY and CAPITAL columns are overriden to assign themdifferent names than the defaults The default schema mapping of the URLcolumn is not overriden and retains its default type and name

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

Int64Int16consecutive sequence of integersfrom 1 to lt 1000

IdCITY_ID

StringStringNamesNameNAME

StringStringNamesCountryCOUNTRY

Schema Overrides | 185

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

StringStringlsquoNrsquo or lsquoYrsquoCaptialCAPITAL

Not over-riden

StringnullNot over-riden

URL

Int32Doublepositive integers lt 17000000PopulationPOPULATION

GeometryDoublepositive and negative decimalsGeometryLATITUDE

GeometryDoublepositive and negative decimalsGeometryLONGITUDE

First a conceptual view of how to create the XML configuration file for aschema override is presented and then a code view is presented The overrideincludes a geometry property and so a spatial context is defined as well

1 Open the XML file

2 Create a spatial context for the geometry and write it to the XML file

3 Create the FDO feature schema and write it to the XML file

4 Create a connection to the provider and get a reference to theconnectionrsquos physical schema mapping

5 Use the reference to the connectionrsquos physical schema mapping and theSchema Override API to create the schema override whereby the logicalfields in the feature schema are associated with columns in the databasetable

6 Write the schema override to the XML file

7 Close the XML file

C

The following namespaces are used

OSGeoFDOCommonIo

OSGeoFDOCommonXml

186 | Chapter 13 FDO Cookbook

OSGeoFDOGeometry

OSGeoFDOSchema

Create the XML Schema Override Configuration File

Open the XML File

IoFileStream writeFileStream = new IoFileStream(Citiesxml w)

XmlWriter writer = new XmlWriter(writeFileStream)

Create a Spatial Context and Write It to the XML File

XmlSpatialContextFlags flags = new XmlSpatialContextFlags()

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(writer flags)

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

spatialContextWriterCoordinateSystem = WGS 84

spatialContextWriterCoordinateSystemWkt = GEOGCS [ Longitude

Latitude (WGS 84) DATUM [WGS 84 SPHEROID [WGS 84

6378137 298257223563]] PRIMEM [ Greenwich 0000000 ] UNIT

Decimal Degree 001745329251994330]]

spatialContextWriterDescription = This Coordinate System is used

for GPS

spatialContextWriterExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

spatialContextWriterExtent = extent

spatialContextWriterName = WGS84

spatialContextWriterXYTolerance = 0001

the next line writes the XML declaration the opening tag for

the fdoDataStore element

and the gmlDerivedCRS element to the XML file

spatialContextWriterWriteSpatialContext()

Schema Overrides | 187

Create the Feature Schema and Write It to the XML File

188 | Chapter 13 FDO Cookbook

FeatureSchema schema = new FeatureSchema(World Logical feature

schema)

FeatureClass featClass = new FeatureClass(Cities This feature

class contains one identity property many data properties and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(Id

This is the unique id number for the city)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = false

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition nameProp = new DataPropertyDefini

tion(Name This is the name of the City)

namePropDataType = DataTypeDataType_String

namePropLength = 64

propertiesAdd(nameProp)

DataPropertyDefinition countryProp = new DataPropertyDefini

tion(Country This is country that contains the city)

countryPropDataType = DataTypeDataType_String

countryPropLength = 64

propertiesAdd(countryProp)

DataPropertyDefinition populationProp = new DataPropertyDefini

tion(Population This is the population of the city)

populationPropDataType = DataTypeDataType_Int32

propertiesAdd(populationProp)

DataPropertyDefinition capitalProp = new DataPropertyDefini

tion(Capital This is Y or N to say whether the city is the

capital of the country)

capitalPropDataType = DataTypeDataType_String

capitalPropLength = 1

propertiesAdd(capitalProp)

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(Geometry This is the feature geometry)

featGeomPropGeometryTypes = (int)GeometricTypeGeometric

Type_Point

featGeomPropHasElevation = false

featGeomPropHasMeasure = false

propertiesAdd(featGeomProp)

Schema Overrides | 189

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

the next line writes the xsschema element to the XML file

schemaWriteXml(writer)

190 | Chapter 13 FDO Cookbook

Create the Physical Schema Mapping and Write It to the XML File

Schema Overrides | 191

set the connection to point

at the Microsoft Access database file

whose Data Source Name (DSN) has been

defined using the Data Sources (ODBC)

Windows XP administrative tool

connectionConnectionString = DataSourceName= + dataSourceName

get a reference to the PhysicalSchemaMapping object contained

in the connection

PhysicalSchemaMapping connectionSchemaMapping = connectionCreateS

chemaMapping()

use that reference to create an override physical schema mapping

the override definition associates columns in the columns of

the Access database with property names in the FDO feature schema

OvPhysicalSchemaMapping mapping = new OvPhysicalSchemaMapping(con

nectionSchemaMapping false)

mappingName = World

OvClassCollection overrideClasses = mappingClasses

OvClassDefinition overrrideClassDef = new OvClassDefinition(Cit

ies)

OvPropertyDefinitionCollection overrideProperties = overrride

ClassDefProperties

associate the table in the Access database with the override

class definition

OvTable table = new OvTable(Cities)

overrrideClassDefTable = table

associate the columns in the table in the Access database with

the properties in the FDO feature schema

OvColumn column = null

OvGeometricPropertyDefinition overridGeomProp = new OvGeometric

PropertyDefinition(Geometry)

overridGeomPropGeometricColumnType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricColumnTypeOvGeometricColumnType_Double

overridGeomPropGeometricContentType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricContentTypeOvGeometricContentType_Ordin

ates

overridGeomPropXColumnName = LONGITUDE

overridGeomPropYColumnName = LATITUDE

overridePropertiesAdd(overridGeomProp)

OvDataPropertyDefinition overrideIdProp = new OvDataPropertyDefin

ition(Id)

column = new OvColumn(CITY_ID) overrideIdPropColumn = column

overridePropertiesAdd(overrideIdProp)

192 | Chapter 13 FDO Cookbook

OvDataPropertyDefinition overrideNameProp = new OvDataPropertyDefin

ition(Name)

column = new OvColumn(NAME)

overrideNamePropColumn = column

overridePropertiesAdd(overrideNameProp)

OvDataPropertyDefinition overrideCountryProp = new OvDataProperty

Definition(Country)

column = new OvColumn(COUNTRY)

overrideCountryPropColumn = column

overridePropertiesAdd(overrideCountryProp)

OvDataPropertyDefinition overridePopulationProp = new OvDataProp

ertyDefinition(Population)

column = new OvColumn(POPULATION)

overridePopulationPropColumn = column

overridePropertiesAdd(overridePopulationProp)

OvDataPropertyDefinition overrideCapitalProp = new OvDataProperty

Definition(Capital)

column = new OvColumn(CAPITAL)

overrideCapitalPropColumn = column

overridePropertiesAdd(overrideCapitalProp)

overrideClassesAdd(overrideClassDef)

write the override definition to the XML file

XmlFlags flags = new XmlFlags()

the next line writes the SchemaMapping element to the XML file

mappingWriteXml(writer flags)

mappingDispose()

Write the Closing Tag and Close the XML File

the next line writes the closing tag of the fdoDataStore ele

ment to the XML file

writerWriteEndElement()

writerClose()

writerDispose()

writeFileStreamClose()

writeFileStreamDispose()

Configure a Connection to Use the Schema Override

The connection object contains a property whose value points to the XMLconfiguration file

Schema Overrides | 193

IConnection connection = connMgrCreateConnection(providerName)

IoFileStream configurationFileStream = new IoFileStream(Cit

iesxml r)

connectionConfiguration = configurationFileStream

connectionConnectionString = DataSourceName= + dataSourceName

connectionOpen()

Xml SerializeDeserializeThis code sample serializes the spatial context and feature schema of a datastore to an xml file and then deserializes it in another data store

C

This is the C code

Namespaces

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommonIo

OSGeoFDOCommonXml

OSGeoFDOSchema

OSGeoFDOXml

194 | Chapter 13 FDO Cookbook

Serialize

open the xml file

XmlWriter xmlWriter = new XmlWriter(xmlFilename)

serial the spatial contexts

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(xmlWriter)

XmlSpatialContextSerializerXmlSerialize(connection spatialContex

tWriter)

serialize the feature schemas

IDescribeSchema descSchema = connectionCreateCommand(Command

TypeCommandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

schemasWriteXml(xmlWriter)

clean up

spatialContextWriterDispose()

xmlWriterDispose()

C | 195

Deserialize

deserialize the spatial contexts

IoFileStream fileStream = new IoFileStream(xmlFilename r)

XmlReader xmlReader = new XmlReader(fileStream)

XmlSpatialContextReader xScReader = new XmlSpatialContextReader(xm

lReader)

XmlSpatialContextSerializerXmlDeserialize(connection xScReader)

fileStreamReset()

deserialize the schema

FeatureSchemaCollection schemas = new FeatureSchemaCollec

tion(null)

schemasReadXml(fileStream)

IApplySchema applySchema = connectionCreateCommand(CommandTypeCom

mandType_ApplySchema) as IApplySchema

FeatureSchema schema = null

for (int i = 0 i lt schemasCount i++)

schema = schemasget_Item(i)

applySchemaFeatureSchema = schema

applySchemaExecute()

fileStreamReset()

clean up

xmlReaderDispose()

fileStreamClose()

GeometryThe geometry code samples are divided into two parts The first is constructinggeometries The second is deconstructing them that is extracting informationfrom the geometry objects

Construction

Geometries can be constructed using a set of scaffolding classes which includesa geometry factory class or they can be constructed using the geometry factoryclass from text specifications The syntax for the text specifications is describedin the Geometry Value section in the Filter and Expression Languages chapter

196 | Chapter 13 FDO Cookbook

What follows here is a description of geometry construction using thescaffolding classes

Some geometries are constructed using a two step procedure First createcoordinates and then create the geometry Some geometries require anintermediate step Use the coordinates to create subcomponents and then usethe subcomponents to create the geometry The construction of somegeometries requires the use of helper collection classes Some of these classesare collections of geometries and some are collections of geometrysubcomponents

Simple geometries like point and line are constructed directly from coordinatesComplex geometries like curved lines and polygons are constructed fromgeometry subcomponents like arc and line segments and rings In generalsubcomponents are constructed from coordinates The exception is the ringwhich is constructed from arc and line segments The glue is the helpercollection classes for coordinates segments and rings

A geometry object may consist of homogeneous or heterogeneous aggregationsof points lines and polygons The glue is helper collection classes for pointslines and polygons

C Namespaces

The following namespaces are used

OSGeoFDOCommon

OSGeoFDOGeometry

C Geometry Scaffolding Classes

The scaffolding classes used to construct the simple complex and aggregategeometries are the following

the IDirectionPosition class used to construct positions (coordinates)

the FgfGeometryFactory class used to construct the geometrysubcomponents and geometries

the geometry subcomponent classes ILineStringSegmentICircularArcSegment ILinearRing and IRing

Construction | 197

the helper collection classes PointCollection LineStringCollectionCurveSegmentCollection LinearRingCollection RingCollectionPolygonCollection CurvePolygonCollection and GeometryCollection

IDirectPositionImpl

The IDirectPosition is the basic building block of geometries Use its constructorto define a coordinate Use instances of it to define the IPoint and ILineStringgeometries or to define the geometry subcompoonents ILinearRingICircularArcSegment and ILineStringSegment

DirectPositionImpl pos00 = new DirectPositionImpl(00 00)

FgfGeometryFactory

Use an instance of this class to do the following

create geometry subcomponents used to construct IGeometry-based objects

create IGeometry-based objects

convert IGeometry-based objects into binary-formatted geometries usedfor data store inserts

convert binary-formatted geometries retrieved during data store queriesinto IGeometry-based objects

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

Geometry Subcomponents

The following subcomponents are used in the construction of geometries andgeometry subcomponents

The ICircularArcSegment and ILineStringSegment subcomponents are usedto construct the ICurveString geometry and the IRing geometrysubcomponent

The ILinearRing subcomponent is used to contruct the IPolygon geometry

The IRing subcomponent is used to construct the ICurvePolygon geometry

198 | Chapter 13 FDO Cookbook

ICircularArcSegment

The creation of an instances uses IDirectPositionImpl objects whichrespectively define a start position a mid point and an end position for thearc

ICircularArcSegment as012122 = geomFactoryCreateCircularArcSeg

ment(pos01 pos21 pos22)

ILineStringSegment

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos23)

positionsAdd(pos30)

positionsAdd(pos33)

ILineStringSegment ls233033 = geomFactoryCreateLineStringSeg

ment(positions)

positionsClear()

ILinearRing

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos01)

positionsAdd(pos21)

positionsAdd(pos12)

positionsAdd(pos01)

ILinearRing lr01211201 = geomFactoryCreateLinearRing(positions)

positionsClear()

IRing

An IRing is constructed using a CurveSegmentCollection This collection cancontain ICircularArcSegment and ILineStringSegment objects

curveSegmentsAdd(as1340n20)

curveSegmentsAdd(lsn2013)

IRing rAs1340n20Lsn2013 = geomFactoryCreateRing(curveSegments)

curveSegmentsClear()

Construction | 199

Collection Classes

The following collection classes are used during the construction of the variousgeometries

Contains IDirectPositionImpl ojbects

DirectPositionCollection positions = new DirectPositionCollec

tion()

Contains IPoint objects

PointCollection points = new PointCollection()

Contains ILineString objects

LineStringCollection lines = new LineStringCollection()

Contains ICircularArcSegment and ILineStringSegment objects

CurveSegmentCollection curveSegments = new CurveSegmentCollec

tion()

Contains ICurveString objects

CurveStringCollection curves = new CurveStringCollection()

Contains ILinearRing objects

LinearRingCollection linearRings = new LinearRingCollection()

Contains IRing objects

RingCollection curveRings = new RingCollection()

Contains IPolygon objects

PolygonCollection linearPolygons = new PolygonCollection()

Contains ICurvePolygon objects

CurvePolygonCollection curvePolygons = new CurvePolygonCollec

tion()

GeometryCollection geometries = new GeometryCollection()

C Geometries Constructed usingIDirectPositionImpl

These geometries are IPoint and ILineString

IPoint

The creation of an instances uses an IDirectionPositionImpl object

IPoint pt00 = geomFactoryCreatePoint(pos00)

200 | Chapter 13 FDO Cookbook

ILineString

The creation of an instances uses a DirectPositionCollection object which iscomposed of IDirectionPositionImpl object

positionsAdd(pos01)

positionsAdd(pos21)

ILineString line0121 = geomFactoryCreateLineString(positions)

positionsClear()

C Geometries Constructed Using GeometrySubcomponents

These geometries are ICurveString IPolygon and ICurvePolygon

ICurveString

The creation of an instance uses a CurveSegmentCollection object whichcontains an ICircularArcSegment object and an ILineStringSegment object

ICurveString composed of a circular arc segment and a line

string segment

curveSegmentsAdd(as022223)

curveSegmentsAdd(ls233033)

ICurveString csAs022223Ls233033 = geomFactoryCreateCur

veString(curveSegments)

curveSegmentsClear()

IPolygon

The creation of an instance uses an ILinearRing object for the exterior ringand a LinearRingCollection object composed of ILinearRing objects for theinterior rings

IPolygon with one exterior ring and no interior rings

IPolygon polyEr01211201 = geomFactoryCreatePolygon(lr01211201

null)

IPolygon with one exterior ring and one interior ring

linearRingsAdd(lr01211201)

polyEr13n204013Ir01211201 = geomFactoryCreatePolygon(lr13n204013

linearRings)

linearRingsClear()

Construction | 201

ICurvePolygon

The creation of an instance uses an IRing object for the exterior ring and aRingCollection object composed of an IRing object for the interior rings

ICurvePolygon with one exterior ring rAs1340n20Lsn2013 which

is composed of an arc segment and a line segment

and one interior ring rLs0121Ls2112Ls1201 which is a triangle

made of three line segments

curveRingsAdd(rLs0121Ls2112Ls1201)

ICurve Polygon curvPolyErAs1340n20Lsn2013IrLs0121Ls2112Ls1201 =

geomFactoryCreateCurvePolygon(rAs1340n20Lsn2013 curveRings)

curveRingsClear()

C Aggregate Geometries

The aggregate geometries are IMultiPoint IMultiLineString IMultiCurveStringIMultiPolygon IMultiCurvePolygon and IMultiGeometry

IMultiPoint

The creation of an instance uses a PointCollection object

pointsAdd(pt00)

pointsAdd(pt11)

IMultiPoint pt00pt11 = geomFactoryCreateMultiPoint(points)

pointsClear()

IMultiLineString

The creation of an instance uses a LineStringCollection object

linesAdd(line0121)

linesAdd(line0222)

IMultiLineString line0121line0222 = geomFactoryCreateMultiLineS

tring(lines)

linesClear()

IMultiCurveString

The creation of an instance uses a CurveStringCollection object

202 | Chapter 13 FDO Cookbook

curvesAdd(csAs012122)

curvesAdd(csAs022223Ls233033)

IMultiCurveString aMultiCurvePolygon = geomFactoryCreateMultiCur

veString(curves)

curvesClear()

IMultiPolygon

The creation of an instance uses a PolygonCollection object

linearPolygonsAdd(polygonNum1)

linearPolygonsAdd(polygonNum2)

IMultiPolygon aMultiPolygon = geomFactoryCreateMultiPolygon(lin

earPolygons)

linearPolygonsClear()

IMultiCurvePolygon

The creation of an instance uses a CurvePolygonCollection object

curvePolygonsAdd(curvePolygonNum1)

curvePolygonsAdd(curvePolygonNum2)

IMultiCurvePolygon aMultiCurvePolygon = geomFactoryCreateMultiC

urvePolygon(curvePolygons)

curvePolygonsClear()

IMultiGeometry

The creation of an instance uses a GeometryCollection object

geometriesAdd(aPoint)

geometriesAdd(aMultiPoint)

geometriesAdd(aLineString)

geometriesAdd(aMultiLineString)

geometriesAdd(aCurveString)

geometriesAdd(aMultiCurveString)

geometriesAdd(aPolygon)

geometriesAdd(aMultiPolygon)

geometriesAdd(aCurvePolygon)

geometriesAdd(aMultiCurvePolygon)

IMultiGeometry aMultiGeometry = geomFactoryCreateMultiGeometry(geo

metries)

geometriesClear()

Construction | 203

C Geometries from Text Specifications

You can use the geometry factoryrsquos CreateGeometry method to creategeometries from text specifications Herersquos an IPoint example

IPoint pt11 = geomFactoryCreatePoint(pos11)

IPoint aSecondPt11 = geomFactoryCreateGeometry(pt11Text) as

IPoint

aThirdPt11 = geomFactoryCreateGeometry(POINT (1 1)) as IPoint

Deconstruction

Deconstruction means getting information such as dimensionality envelopetext specification geometry geometry subcomponents and positions(coordinates) The following table specifies the information available fromthe classes

Position means coordinate values Dimensionality values are XY XYZ XYMor XYZM Envelope means bounding rectangle The envelope for an aggregategeometry contains all of the included geometries Text means FGF well-knowntext specification IsClosed is a boolean specifying whether or not the startand end coordinates are identical

Information availableClass

position dimensionalityIDirectPosition

position dimensionality envelope textIPoint

dimensionality envelope text IPointIMultiPoint

position dimensionality envelope textILineString

dimensionality envelope text ILineStrinIMultiLineString

IsClosed position dimensionality envelopeILineStringSegment

IsClosed position dimensionality envelopeICircularArcSegment

204 | Chapter 13 FDO Cookbook

Information availableClass

position dimensionality envelope text ICircularArcSegment ILineStringSegmentICurveString

dimensionality envelope text ICurveStringIMultiCurveString

position dimensionality envelopeILinearRing

dimensionality envelope text ILinearRingIPolygon

dimensionality envelope text IPolygonIMultiPolygon

position dimensionality ICircularArcSegment ILineStringSegmentIRing

dimensionality envelope text IRingICurvePolygon

dimensionality envelope text ICurvePolygonIMultiCurvePolygon

dimensionality envelope text IPoint IMultiPoint ILineString IMultiLineStringICurveString IMultiCurveString IPolygon IMultiPolygon ICurvePolygon IMulti-CurvePolygon

IMultiGeometry

Coordinates

IDirectPosition aPosition

double X = aPositionX

double Y = aPositionY

double Z

double M

int dim = aPositionDimensionality

if ((dim amp 1) == 1)

Z = aPositionZ

if ((dim amp 2) == 2)

M = aPositionM

Deconstruction | 205

IDirectPosition (IPoint ILineString ICircularArcSegmentILineStringSegment ILinearRing)

IPoint aPoint

IDirectPosition position = aPointPosition

ILineString line

IDirectPosition aPosition = null

IDirectPosition startPosition = lineStartPosition

IDirectPosition endPosition = lineEndPosition

for (int i = 0 i lt lineCount i++)

aPosition = lineget_Item(i)

ICircularArcSegment arcSegment

IDirectPosition startPosition = arcSegmentStartPosition

IDirectPosition midPoint = arcSegmentMidPoint

IDirectPosition endPosition = arcSegmentEndPosition

ILineStringSegment lineSegment

IDirectPosition startPosition = lineSegmentStartPosition

IDirectPosition endPosition = lineSegmentEndPosition

DirectPositionCollection positions = lineSegmentPositions

foreach(IDirectPosition position in positions)

ICurveString curve

IDirectPosition startPosition = curveStartPosition

IDirectPosition endPosition = curveEndPosition

ILinearRing linearRing

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

ILinearRing ring

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

Dimensionality Envelope and Text

int dimensionality = aPointDimensionality

IEnvelope envelope = aPointEnvelope

string text = aPointText

206 | Chapter 13 FDO Cookbook

IsClosed (ICircularArcSegment and ILineStringSegment)

ICircularArcSegment arcSegment

bool isClosed = arcSegmentIsClosed

ILineStringSegment lineSegment

bool isClosed = lineSegmentIsClosed

IPoint and IMultiPoint

IMultiPoint aMultiPoint

IPoint aPoint = null

for (int i = 0 i lt aMultiPointCount i++)

aPoint = aMultiPointget_Item(i)

ILineString and IMultiLineString

IMultiLineString aMultiLineString

ILineString line = null

for (int i = 0 i lt aMultiLineStringCount i++)

line = aMultiLineStringget_Item(i)

ICurveString and IMultiCurveString

IMultiCurveString aMultiCurveString

ICurveString curve = null

for (int i = 0 i lt aMultiCurveStringCount i++)

curve = aMultiCurveStringget_Item(i)

Deconstruction | 207

ICircularArcSegment and ILineStringSegment (ICurveString andIRing)

ICurveString aCurveString

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt aCurveStringCount i++)

curveSegment = aCurveStringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

IRing ring

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt ringCount i++)

curveSegment = ringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

ILinearRing (IPolygon)

IPolygon aPolygon

ILinearRing anExteriorRing = aPolygonExteriorRing

ILinearRing anInteriorRing = null

for (int i = 0 i lt aPolygonInteriorRingCount i++)

anInteriorRing = aPolygonGetInteriorRing(i)

208 | Chapter 13 FDO Cookbook

IPolygon and IMultiPolygon

IMultiPolygon aMultiPolygon

IPolygon aPolygon = null

for (int i = 0 i lt aMultiPolygonCount i++)

aPolygon = aMultiPolygonget_Item(i)

IRing (ICurvePolygon)

ICurvePolygon aCurvePolygon

IRing anExteriorRing = aCurvePolygonExteriorRing

IRing anInteriorRing = null

for (int i = 0 i lt count i++)

anInteriorRing = aCurvePolygonget_InteriorRing(i)

ICurvePolygon and IMultiCurvePolygon

IMultiCurvePolygon aMultiCurvePolygon

ICurvePolygon aCurvePolygon = null

for (int i = 0 i lt aMultiCurvePolygonCount i++)

aCurvePolygon = aMultiCurvePolygonget_Item(i)

Deconstruction | 209

IMultiGeometry

IMultiGeometry aMultiGeometry

IGeometry geom = null

GeometryType geomType

IPoint pt = null

IMultiPoint mpt = null

ILineString line = null

IMultiLineString mline = null

ICurveString curve = null

IMultiCurveString mcurve = null

IPolygon poly = null

IMultiPolygon mpoly = null

ICurvePolygon curvPoly = null

IMultiCurvePolygon mCurvPoly = null

for (int i = 0 i lt aMultiGeometryCount i++)

geom = aMultiGeometryget_Item(i)

geomType = geomDerivedType

switch (geomType)

case GeometryTypeGeometryType_Point pt = geom as IPoint break

case GeometryTypeGeometryType_MultiPoint mpt = geom as IMulti

Point break

case GeometryTypeGeometryType_LineString line = geom as ILin

eString break

case GeometryTypeGeometryType_MultiLineString mline = geom as

IMultiLineString break

case GeometryTypeGeometryType_CurveString curve = geom as

ICurveString break

case GeometryTypeGeometryType_MultiCurveString mcurve = geom

as IMultiCurveString break

case GeometryTypeGeometryType_Polygon poly = geom as IPolygon

break

case GeometryTypeGeometryType_MultiPolygon mpoly = geom as

IMultiPolygon break

case GeometryTypeGeometryType_CurvePolygon curvPoly = geom as

ICurvePolygon break

case GeometryTypeGeometryType_MultiCurvePolygon mCurvPoly =

geom as IMultiCurvePolygon break

default break

210 | Chapter 13 FDO Cookbook

OSGeo FDO Provider forArcSDE

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ArcSDE

What Is FDO Provider for ArcSDEThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store A provider is a specific implementation of theFDO API that provides access to data in a particular data store ESRIreg ArcSDEreg

(Spatial Database Engine) is part of the ArcGIS 9 system ArcSDE manages theexchange of information between an (ArcGIS 9 Desktop) application and arelational database management system FDO Provider for ArcSDE provides FDOwith access to an ArcSDE 9-based data store which in this case must be Oracle9i (9206)

FDO Provider for ArcSDE SoftwareRequirements

Installed Components

FDO Provider for ArcSDE dynamically linked libraries are installed with the FDOSDK They are located in ltFDO SDK Install LocationgtFDObin You do nothave to do anything to make these DLLs visible

A

211

External Dependencies

The operation of FDO Provider for ArcSDE is dependent on the presence ofArcSDE 9 and a supported data source such as Oracle 9i in the networkenvironment The host machine running FDO Provider for ArcSDE must alsohave the required DLLs present which are available by installing either anArcGIS 91 Desktop application or the ArcSDE SDK For example the requiredDLLs are present if either ArcViewreg ArcEditorreg or ArcInforeg are installed Formore information about ArcGIS 91 Desktop applications and the ArcSDE SDKrefer to the ESRI documentation

Specifically in order for FDO Provider for ArcSDE to run three dynamicallylinked libraries sde91dll sg91dll and pe91dll are required and you mustensure that the PATH environment variable references the local foldercontaining these DLLs For example in Microsoft Windows if ArcGIS 91Desktop is installed to CProgram FilesArcGIS then the required ArcSDEbinaries are located at CProgram FilesArcGISArcSDEbin Similarly if theArcSDE SDK is installed to the default location then the required ArcSDEbinaries are located at CArcGisArcSDEbin The absence of thisconfiguration may cause the following exception message The ArcSDE runtimewas not found

FDO Provider for ArcSDE LimitationsThe FDO Provider for ArcSDE is based on a subset of the ArcSDE API Thissubset does not include the following

Raster functionality

Native ArcSDE metadata

The annotation data with the exception of the ANNO_TEXT column

ArcSDE LimitationsFDO Provider for ArcSDE must abide by limitations of the ArcSDE technologyto which it connects This section discusses these limitations

212 | Appendix A OSGeo FDO Provider for ArcSDE

Relative to ArcObjects API and ArcGIS Server API

The ArcSDE API does not support the following advanced functionality foundin the ArcObjects API and the newer ArcGIS Server API

Advanced geometries such as Bezier curves and ellipses

Relationships

Topology

Networks

Analysis

Linear referencing

Curved Segments

If ArcSDE encounters curved segments it will automatically tessellate themThis means that if you create a geometry containing an arc segment in anArcSDE table using ArcObjects API and then you try to read that geometryback using the ArcSDE API you will get a series of line segments thatapproximate the original arc segment That is you get an approximation ofthe original geometry

Locking and Versioning

ArcSDE permits row locks or table versioning provided that the ID columnwhich uniquely identifies the row is maintained by ArcSDE If there is no IDcolumn or the ID column is maintained by the user ArcSDE does not permitrow locking or table versioning to be enabled

NOTE In ArcSDE you can either lock rows in a table or version a table but youcannot do both at the same time To do either you must alter the tablersquosregistration

The following sections illustrate these three steps

1 The creation of a table

Relative to ArcObjects API and ArcGIS Server API | 213

2 The alteration of the table registration to identify one of the columndefinitions as the row ID column and to enable row locking

3 The alteration of the table registration to disable row locking and toenable versioning

Table Creation

The command is

sdetable -o create -t hassdemaintainedrowid -d name string(20)

fid integer(9) -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The Row Lock has no value and the value of Dependent Objects is None

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column

Row ID Column Type

Row Lock

Minimum Row ID

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Identity Row ID Column and Enable Row Locking

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -c fid -C sde -L

on -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

214 | Appendix A OSGeo FDO Provider for ArcSDE

NOTE The Row ID Column value is FID the Row ID Column Type value is SDEMaintained and the Row Lock value is Enable

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Enable

Minimum Row ID 1

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Disable Row Locking and Enable Versioning

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -L off -V MULTI -u

t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The ldquoRow Lockrdquo is ldquoNot Enablerdquo and ldquoDependent Objectsrdquo is ldquoMultiversionTablerdquo

Locking and Versioning | 215

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Not Enable

Minimum Row ID 1

Dependent Objects Multiversion Table

Dependent Object Names A18111 D18111

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

FDO Provider for ArcSDE ConnectionThis information supplements the Establishing a Connection chapter Youconnect to an ArcSDE data store indirectly through the ArcSDE server Theunderlying data source for the data store is a database such as Oracle TheArcSDE server is connected to the data source and mediates the requests thatyou send it

You can connect to FDO Provider for ArcSDE in one step if you already knowthe name of the data store that you want to use Otherwise you must connectin two steps

The minimum required connection properties for the initial call to Open()are server instance username and password Multiple users can access thedata store However access is password-protected The server property is thename of the machine hosting the ArcSDE server The instance property actsas an index into an entry in the services file An entry contains port andprotocol information used to connect to the ArcSDE server On a Windowsmachine the services file is located in CWINDOWSsystem32driversetcAssuming that the instance name is ldquoesri_sderdquo an entry would look somethinglike this ldquoesri_sde 5151tcp ArcSDE Server Listening Portrdquo

An ArcSDE data source may contain more than one data store For the firstcall to Open() a data store name is optional If successful the first call toOpen() results in the data store parameter becoming a required parameter anda list of the names of the data stores in the data source becoming availableYou must choose a data store and call Open() again

216 | Appendix A OSGeo FDO Provider for ArcSDE

If the data source supports multiple data stores the list returned by the firstcall to Open() will contain a list of all of the data stores resident in the datasource Otherwise the list will contain one entry ldquoDefault Data Storerdquo

If you know the name of the data store you can provide it for the first call toOpen() and make the connection in one step

Data Type MappingsThis section shows the mappings from FDO data types to ArcSDE data typesto Oracle data types

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDataType_Boolean

Not supportedNot supportedFdoDataType_Byte

DATEdateFdoDataType_DateTime

Not supportedNot supportedFdoDataType_Decimal

NUMBER(388)double(388)FdoDataType_Double

NUMBER(4)integer(4)FdoDataType_Int16

NUMBER(10)integer(10)FdoDataType_Int32

Not supportedNot supportedFdoDataType_Int64

NUMBER(62)float(62) typicalFdoDataType_SingleNUMBER(n8)float(0ltnlt=6 oltmltDBMSLimit)) possible

VARCHAR2(ltlengthgt)string(ltlengthgt)FdoDataType_String

LONG RAWblobFdoDataType_BLOB

Not supportedNot supportedFdoDataType_CLOB

Data Type Mappings | 217

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDatatype_UniqueID

Creating a Feature SchemaThis section describes the creation of the SampleFeatureSchema which is theexample feature schema described in the Schema Management chapter It alsodescribes the creation of the OGC980461FS schema which is the schemadefined in the OpenGIS project document 98-046r1

FDO Provider for ArcSDE does not support the creation or destruction offeature schema (that is does not support the FdoIApplySchema andFdoIDestroySchema commands) However it does support theFdoIDescribeSchema command The intended use of FDO Provider for ArcSDEis to operate on already existing feature schemas FDO Provider for ArcSDEsupports inserting selecting updating and deleting data in existing schemas

You can use FDO Provider for ArcSDE to operate on a new feature schemaHowever you must create the schema using ArcSDE tools In particular youuse the sdetable and sdelayer commands which can be used to create a schemain any of the data store technologies used by ArcSDE This part of thedescription is generic Other parts of the description are specific to Oracle andto Windows XP because Oracle is the data store technology and Windows XPis the operating system for this exercise

First you must create an Oracle username for the feature schema (that is thename of the Oracle user is the name of the feature schema) To do this youconnect as system administrator to the Oracle instance used by the ArcSDEserver The following command creates the user and grants to that user theprivileges necessary for the ArcSDE tool commands to succeed

grant connectresource to ltschemaNamegt identified by ltpasswordgt

Secondly you must log in to the host where the ArcSDE server is runningArcSDE tools are on the host machine where the ArcSDE server resides

TIP NetMeeting can be used to remotely login to where the ArcSDE Server isrunning and launch a command window (that is in the Run dialog box entercmd) The ArcSDE tool commands can be executed through the command windowDo not use CWINDOWSSYSTEM32COMMANDCOM because the line bufferis too short to contain the entire text of some of the SDE tool command strings

218 | Appendix A OSGeo FDO Provider for ArcSDE

Finally execute the sdetable and sdelayer commands in a command windowto create each of the classes Since you are executing these commands on thehost where the ArcSDE server is located you can omit the server name optionIf the ArcSDE server is connected to only one data store you can omit theservice option For more information about all of the ArcSDE commandsconsult the ArcSDE Developer Help Guide

SampleFeatureSchema

In this sample a feature schema called SampleFeatureSchema is created whichcontains one feature class called SampleFeatureClass This feature class hasthe following three properties

An Int32 called SampleIdentityDataProperty

A string called SampleNameDataProperty

A polygon geometry called SampleGeometricProperty

First use the sdetable -o create command to add the integer and stringproperties to SampleFeatureClass Then use the sdetable -o alter_reg commandto identify the SampleIdentityDataProperty as an identity property Finallyuse the sdelayer -o add command to add the geometric property toSampleFeatureClass This assumes that only one ArcSDE server service isrunning so that the -i option is optional The -i option takes a service nameas an argument

The sdetable -o create command can be invoked as follows

sdetable -o create -t SampleFeatureClass -d ldquoSampleIdentityData

Property INTEGER(10) SampleNameDataProperty STRING(64)rdquo -u

SampleFeatureSchema -p test

The -o option takes the command option name The -d option takes thecolumn definitions which is a quoted list of column namecolumn type pairsdelimited by commas The -u option takes an Oracle database user namewhich becomes the feature schema name The -p option takes a password

The sdetable -o alter_reg command is invoked as follows

sdetable -o alter_reg -t SampleFeatureClass -c SampleIdentityData

Property -C USER -u SampleFeatureSchema -p test

The -c option identifies the column name that will be the identity propertyThe -C option indicates whether SDE is supposed to generate the value orobtain it from the user You will be prompted to confirm that you want toalter the registration of the table

Creating a Feature Schema | 219

The sdelayer command is invoked as follows

sdelayer -o add -l SampleFeatureClassSampleGeometricProperty -E

0010050 -e a -u SampleFeatureSchema -p test

The -o option takes the command option name The -l option identifies thetable and column The -E option identifies the extents the arguments areltxminyminxmaxymaxgt The -e option identifies the geometry type withlsquoarsquo indicating an area shape

OGC980461FS

This schema contains the ten classes defined in the OpenGIS Project Document980946r1 The types of the properties belonging to the classes is similar tothat of SampleFeatureClass namely an integer a string and a geometry Onedifference is that the geometry in three of the classes is multipart Two ofthem have MULTIPOLYGON geometries and one of them has aMULTILINESTRING geometry A multipart geometry is indicated by addinga lsquo+rsquo to the entity argument to the -e option in the sdelayer command AMULTIPOLYGON geometry is indicated by ldquo-e a+rdquo and a MULTILINESTRINGgeometry is indicated by ldquo-e l+rdquo

An ArcSDE table cannot have two geometries This restriction impacts thedefinition of the buildings class which has a POLYGON and a POINTgeometry We have chosen to add the POINT geometry The OpenGIS 98-046r1document defines one query that references building objects and the POINTgeometry supports this query

NOTE The use of -E option in the sdelayer command defines the extents Thearguments are ltxminyminxmaxymaxgt The values provided below ensure thatyou will not receive any ldquoordinate out of boundsrdquo errors when inserting the98046r1 data

220 | Appendix A OSGeo FDO Provider for ArcSDE

ArcSDE Commands That Define the OGC980461FS Classes

Creating a Feature Schema | 221

sdetable -o create -t lakes -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t lakes -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l lakesshore -E 0010050 -e a -u OGC980461FS

-p test

sdetable -o create -t road_segments -d fid integer(10) name

string(64) aliases string(64) num_lanes integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t road_segments -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l road_segmentscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t divided_routes -d fid integer(10) name

string(64) num_lanes integer(10) -u OGC980461FS -p test

sdetable -o alter_reg -t divided_routes -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l divided_routescenterlines -E 0010050 -e l+

-u OGC980461FS -p test

sdetable -o create -t forests -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t forests -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l forestsboundary -E 0010050 -e a+ -u

OGC980461FS -p test

sdetable -o create -t bridges -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t bridges -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l bridgesposition -E 0010050 -e p -u

OGC980461FS -p test

sdetable -o create -t streams -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t streams -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l streamscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t buildings -d fid integer(10) address

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t buildings -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l buildingsposition -E 0010050 -e p -u

OGC980461FS -p test

222 | Appendix A OSGeo FDO Provider for ArcSDE

sdetable -o create -t ponds -d fid integer(10) name string(64)

type string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t ponds -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l pondsshores -E 0010050 -e a+ -u OGC980461FS

-p test

sdetable -o create -t named_places -d fid integer(10) name

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t named_places -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l named_placesboundary -E 0010050 -e a -u

OGC980461FS -p test

sdetable -o create -t map_neatlines -d fid integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t map_neatlines -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l map_neatlinesneatline -E 0010050 -e a -u

OGC980461FS -p test

Logical to Physical Schema MappingThis mapping does not apply because the ArcSDE provider does not supportthe ApplySchema command

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data types TheArcSDE provider talks to the ArcSDE server The server uses either Oracle orSql Server as the back-end data store technology So two schema mappins aredescribed here

Oracle 10gR2 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter The class name is the name of the tablecreated using the sdetable command The property names are the columnnames

Logical to Physical Schema Mapping | 223

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoSrdquo means that the storage typeused for the geometry is Oracle Spatial The -G argument ldquo26910rdquo is the SRID ofa coordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N The sqlplus command select cs_name from mdsyscs_srs where srid =

26910 returns NAD83 UTM zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde -u existinguser -p test -G 26910 -P 32 -t S

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int16NUMBER(4)SE_INT16 4SMINT4COL

UnmappedCHAR(38)SE_UUID 38ID

Int16NUMBER(4)SE_INT16 4INT16COL

224 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int32NUMBER(38)SE_INT32 10INT32COL

SingleNUMBER(62)SE_FLOAT32 6 2FLOAT32COL

DoubleNUMBER(154)SE_FLOAT64 7 2FLOAT64COL

Int32NUMBER(10)SEINT32 10INT10

SingleNUMBER(44)SE_FLOAT32 4 4FLOAT4_4

DoubleNUMBER(72)SE_FLOAT64 7 2DOUBLE7_2

StringVARCHAR2(64)SE_STRING 64STRING64

BLOBBLOBSE_BLOB 0BLOBCOL

UnmappedCLOBSE_CLOB 0CLOBCOL

StringNVARCHAR2(255)SE_NSTRING 255NSTRINGCOL

UnmappedNCLOBSE_NCLOB 0NCLOBCOL

DateTimeDATESE_DATE 0DATECOL

GeometryMDSYSSDO_GEOMETRYSE_SHAPE 0FEATGEOM

Int32NUMBER(38)SE_INT32 10OBJECTID

NOTE The OBJECTID column was not specified in the -d arguments of the sdetablecommand

Sql Server 2005 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter prefixed by ldquoSDE_rdquo The class name is the

Physical to Logical Schema Mapping | 225

name of the table created using the sdetable command The property namesare the column names

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoBrdquo means that the storage typeused for the geometry is Esri Binary The -G argument ldquo26910rdquo is the SRID of acoordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde_ss

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde_ss -u existinguser -p test -G 26910 -P 32 -t B

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int16smallintSE_INT16 4SMINT4COL

UnmappeduniqueidentifierSE_UUID 38ID

Int16smallintSE_INT16 4INT16COL

226 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int32intSE_INT32 10INT32COL

SinglerealSE_FLOAT32 6 2FLOAT32COL

DoublefloatSE_FLOAT64 7 2FLOAT64COL

Int32intSEINT32 10INT10

Singlenumeric(44)SE_FLOAT32 4 4FLOAT4_4

Singlenumeric(72)SE_FLOAT64 7 2DOUBLE7_2

Stringvarchar(64)SE_STRING 64STRING64

BLOBimageSE_BLOB 0BLOBCOL

UnmappedtextSE_CLOB 0CLOBCOL

Stringnvarchar(255)SE_NSTRING 255NSTRINGCOL

UnmappedntextSE_NCLOB 0NCLOBCOL

DateTimedateSE_DATE 0DATECOL

GeometryintSE_SHAPE 0FEATGEOM

FDO Provider for ArcSDE CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

FDO Provider for ArcSDE Capabilities | 227

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

locking

exclusive locking type

transactions

long transactions

SQL

multiple spatial contexts

specifying coordinate systems by name or ID without specifying WKT

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

228 | Appendix A OSGeo FDO Provider for ArcSDE

The following capabilities are supported

class and feature class class types

DateTime data type with a maximum length of 12 bytes

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 4294967296

BLOB data type with a maximum length of 4294967296

Int32 auto-generated data type

Identity properties of type DateTime Double Int16 Int32 Single Stringand BLOB

Name size limitation of 123 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 65 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 160 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 32 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite unique value constraints

Multiple schemas

Null value constraints

Unique value constraints

FDO Provider for ArcSDE Capabilities | 229

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ActivateSpatialContext

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLComnmand

FdoCommandType_AcquireLock

FdoCommandType_GetLockInfo

FdoCommandType_GetLockedObjects

FdoCommandType_GetLockOwners

FdoCommandType_ReleaseLock

FdoCommandType_ActivateLongTransaction

FdoCommandType_DeactivateLongTransaction

FdoCommandType_CommitLongTransaction

FdoCommandType_CreateLongTransaction

FdoCommandType_GetLongTransactions

230 | Appendix A OSGeo FDO Provider for ArcSDE

FdoCommandType_RollbackLongTransaction

FdoCommandType_ListDataStores

The following capabilities are supported

command parameterization

simple functions in Select and SelectAggregate commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

the Beyond and Within distance operations

spatial operations of type Contains Crosses Disjoint Equals IntersectsOverlaps Touches Within CoveredBy Inside and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic expressions are supported

The following functions are supported

Double Sum(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Int64 Count(lttypegt value) where lttypegt is one of Boolean Double SingleDecimal Byte DateTime Int16 Int32 Int64 String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

FDO Provider for ArcSDE Capabilities | 231

Double Avg(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double Max(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double StdDev(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

232 | Appendix A OSGeo FDO Provider for ArcSDE

OSGeo FDO Provider forMySQL

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor MySQL

What Is FDO Provider for MySQLThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for MySQL provides FDO withaccess to a MySQL-based data store

The FDO Provider for MySQL API provides custom commands that arespecifically designed to work with the FDO API For example using thesecommands you can do the following

Gather information about a provider

Transmit client services exceptions

Get lists of accessible data stores

Create connection objects

Create and execute spatial queries

The MySQL architecture supports different storage engines Choose an engineas needed depending on its characteristics and capabilities such as the following

MyISAM is a disk-based storage engine It does not support transactions

InnoDB is a disk-based storage engine It has full ACID transaction capability

B

233

Memory (Heap) is a storage engine utilizing only RAM It is very fast

NDB is the MySQL Cluster storage engine

MERGE is a variation of MyISAM A MERGE table is a collection of identicalMyISAM tables which means that all tables have the same columnscolumn types indexes and so on

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for MySQL API Reference Help(MySQL_Provider_APIchm)

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in thecommandrsquos class collection The mapping of logical FDO data types to nativetypes is described here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the numberof digits to the right of the decimal point The maximum number of digits in thenative type is 64

NOTE The definition of the FDO String data type requires that the length propertybe set

Native Data TypeFDO Data Type

tinyint(4)Boolean

tinyint(3) unsignedByte

datetimeDateTime

decimal(204)Decimal (precision = 20 scale = 4)

doubleDouble

smallint(6)Int16

234 | Appendix B OSGeo FDO Provider for MySQL

Native Data TypeFDO Data Type

int(11)Int32

bigint(20)Int64

doubleSingle

varchar(64)String (length is 64)

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The name of the schema is the concatenation of lsquoFdorsquo and the name of thedatabase This is the database created using the lsquoCREATE DATABASErsquo commandand containing the existing table(s) The table names are the class names andthe column names are the property names

NOTE The length of a bit field is in the range 1-64 A row in a column of typebit(64) can hold 64 bit values

NOTE The following native types are not mapped to FDO data types float floatunsigned real unsigned double unsigned binary varbinary tinyblob blobmediumblob longblob tinytext mediumtext and longtext

FDO Data TypeDefaultsNative Type

Booleanlength = 1bit(

Bytebit(2)

Int64bit(64)

Int16length = 4tinyint

Physical to Logical Schema Mapping | 235

FDO Data TypeDefaultsNative Type

Bytelength = 3tinyint unsigned

Int16length = 6smallint

Int32length = 5smallint unsigned

Int32length = 9mediumint

Int32length = 8mediumint unsigned

Int32length = 11int

Int64length = 10int unsigned

Int64length = 20bigint

Int64length = 20bigint unsigned

Doublereal

Doubledouble

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric unsigned

DateTimedate

DateTimedatetime

DateTimetimestamp

Int32year

236 | Appendix B OSGeo FDO Provider for MySQL

FDO Data TypeDefaultsNative Type

String (length = 192)char(64)

String (length = 192)varchar(64)

Stringenum

Stringset

FDO Provider for MySQL CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

transactions

FDO Provider for MySQL Capabilities | 237

SQL

multiple spatial contexts

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 95 digits (maximum decimalprecision of 65 and maximum decimal scale of 30)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 2147483647

Int64 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Datastore

238 | Appendix B OSGeo FDO Provider for MySQL

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Composite unique value constraints

Datastore scope unique ID generation

Default value

Exclusive value range constraints

Inclusive value range constraints

Inheritance

Multiple schemas

Null value constraints

Object properties

Unique value constraints

Schema modification

Schema overrides

Unique value constraints

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()

FDO Provider for MySQL Capabilities | 239

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

FdoCommandType_ListDataStores

FdoCommandType_DescribeSchemaMapping

FdoCommandType_SQLComnmand

FdoRdbmsCommandType_CreateSpatialIndex

FdoRdbmsCommandType_DestroySpatialIndex

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

240 | Appendix B OSGeo FDO Provider for MySQL

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

spatial operations of type Intersects and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic function and parameter expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Decimal Double SingleInt16 Int32 or Int64

Decimal Ceil(lttypegt value) where lttypegt is one of Decimal or Double

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single or String

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

FDO Provider for MySQL Capabilities | 241

Byte Min(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

Double Sum(lttypegt value) where lttypegt is one of Decimal Double Int16Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

242 | Appendix B OSGeo FDO Provider for MySQL

OSGeo FDO Provider forODBC

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ODBC

What Is FDO Provider for ODBCThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for ODBC provides FDO withaccess to an ODBC-based data store

The FDO Provider for ODBC can access simple x y z feature objects that canrun in a multi-platform environment including Windows Linux and UNIX

The FDO Provider for ODBC has the following characteristics

The FDO Provider for ODBC supports the definition of one or more featureclasses in terms of any relational database table that contains an X Y andoptionally Z columns

Metadata which maps the table name and X Y and optionally Z columnsto a feature class is maintained outside the database in a configuration fileThis information in conjunction with the table structure in the databaseprovides the definition of the feature class

The x y and z locations of objects are stored in separate properties in theprimary object definition of a feature but are accessible through a singleclass property lsquoGeometryrsquo

C

243

Read-only access is provided to pre-existing data defined and populatedthrough 3rd party applications (that is FDO Provider for ODBC will notbe responsible for defining the physical schema of the data store nor forpopulating the object data)

The schema configuration of the data store is provided to the FDO Providerfor ODBC through an optional XML file containing the Geographic MarkupLanguage (GML) definition of the schema that maps lsquotablesrsquo and lsquocolumnsrsquoin the data store to feature classes and property mappings in the FDO datamodel

NOTE Microsoft Excel (must have at least one named range do not use DATABASEor other reserved words as a range name)

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for ODBC API Reference Help (ODBC_Provider_APIchm)

Physical to Logical Schema MappingsMappings of data in three data sources a Microsoft Access database (an accdbfile) an Excel spreadsheet (xlsx file) and a text file to FDO data types areshown

Microsoft Access

Use the ODBC provider to connect to a Microsoft Access database

The schema name is ldquoFdordquo There is only one database per file so there canbe only one schema The table names are used for class names Column namesare used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are AutoNumberReplication ID NumberReplication ID and OLE objectThe mapping of the rest of the native data types is in the following table

244 | Appendix C OSGeo FDO Provider for ODBC

NOTE The AutoNumber Number and DateTime native types are sub-typed Ifa column named X and a column named Y both typed NumberDouble arepresent they are mapped to an FDO geometric property whose type is Point andwhose spatial context association property is ldquoDefaultrdquo

FDO TypeNative TypeSubType

Int32AutoNumberLong Integer

Notmapped

AutoNumberReplication ID

StringText

StringMemo

ByteNumberByte

Int16NumberInteger

Int32NumberLong Integer

SingleNumberSingle

DoubleNumberDouble

DecimalNumberDecimal

Notmapped

NumberReplication ID

DateTimeDateTimeGeneral Date

DateTimeDateTimeLong Date

DateTimeDateTimeMedium Date

DateTimeDateTimeShort Date

Physical to Logical Schema Mappings | 245

FDO TypeNative TypeSubType

DateTimeDateTimeLong Time

DateTimeDateTimeMedium Time

DateTimeDateTimeShort Time

DecimalCurrency

BooleanYesNo

Notmapped

OLE object

StringHyperlink

StringAttachment

Microsoft Excel

Use the ODBC provider to connect to an Excel file

The schema name is ldquoFdordquo There is only one schema per file The range namesare used for class names Column names are used for property names A columnname is a text entry in a cell that is at the top of a column as defined by theboundaries of the named range

If a column named X and a column named Y are present they are mappedto an FDO geometric property whose type is Point and whose spatial contextassociation property is ldquoDefaultrdquo

Three approaches were used to explore the mapping The first approach lookedat the effect of cell content the second approach looked at the effect of cellformat the third approach looked at the effect of both

The first approach involved copying data from a Microsoft Access databaseinto an Excel spreadsheet The copy operation created a named range thatincluded all of the copied data The name for the range came from the Accessdatabase By default all of the Excel cells have a format type of ldquoGeneralrdquo The

246 | Appendix C OSGeo FDO Provider for ODBC

accompanying table shows the mapping of sample cell content to FDO datatype

FDO TypeCell Content

Double2

Double6452067

StringRussia

Stringltemptygt

StringN

NOTE All of the data in each column was consistent The column containing ldquo2rdquocontained only positive integers The column containing ldquo6452067rdquo containedonly similar numbers including negative values The column containing the lsquoNrsquocontained only single characters that were either lsquoNrsquo or lsquoYrsquo The column containingldquoRussiardquo contained only names The column containing an empty cell containedonly empty cells

The second approach involved setting up a named range consisting of 9columns by 2 rows The cells of the first row are formatted as ldquoGeneralrdquo andcontain column labels The cells of the second row are formatted respectivelyldquoGeneralrdquo ldquoNumberrdquo ldquoCurrencyrdquo ldquoAccountingrdquo ldquoDaterdquo ldquoTimerdquoldquoPercentagerdquo ldquoFractionrdquo ldquoScientificrdquo and ldquoTextrdquo No cell in the second rowhas content The accompanying table shows the mapping of cell format toFDO data type

FDO TypeExcel Cell Format

StringGeneral

DoubleNumber

DecimalCurrency

DecimalAccounting

Physical to Logical Schema Mappings | 247

FDO TypeExcel Cell Format

DateTimeDate

DateTimeTime

DoublePercentage

DoubleFraction

DoubleScientific

StringText

The intent of the third approach is to understand how the mapping wouldbe affected by content that violated the cellrsquos format or was inconsistent withthe data in the rest of the column

Inserting ldquohererdquo in the cells formatted as Number Currency AccountingDate Time Percentage Fraction and Scientific caused them to be mapped toString

Inserting -1225 in the cell formatted as Currency caused no change in themapping to Decimal

Inserting 1225 in the cell formatted as Date caused no change in the mappingto DateTime Excel converted 1225 to ldquo1121900 60000 AMrdquo

Inserting ldquohererdquo in one of the cells in the column of integers copied from theAccess database resulted in no change to the mapping to Double This maybe a bug

Text File

Use the ODBC provider to connect to a text file You must first create a DSNusing the XP Data Sources (ODBC) administrative tool The DSN maps to adirectory not a file Each file in the directory is mapped to an FDO class

248 | Appendix C OSGeo FDO Provider for ODBC

NOTE When selecting the directory for the DSN you will notice a listing of thefiles recognized as text files by the driver It will recognize Vim backup files forexample Citiestxt~ as text files The execution of a describe schema commandon a directory containing a Vim backup file caused an exception whose messageis ldquoRDBMS [Microsoft][ODBC Text Driver] Cannot update Database or object isread-onlyrdquo Removal of the Vim backup file prevented this exception

The schema name is ldquoFdordquo There is only one schema per directory The classname is the name of the file for example ldquoCities_txtrdquo The property namesare taken from the first line in the file Here are the first two lines from acomma-delimited text file The property names are ldquoCITY_IDrdquo ldquoNAMErdquo etcThe table shows the mapping of the sample text to FDO data type

CITY_IDNAMECOUNTRYPOPULATIONCAPITALLATITUDELON

GITUDEURLFOUNDED

1MurmanskRussia468000N689633087172008 00000

FDO Data TypeSample Text

Int32468000

StringRussia

Double6896

Stringltemptygt

NOTE Changing ldquoLATITUDErdquo to ldquoYrdquo and ldquoLONGITUDErdquo to ldquoXrdquo causes these twofields to be mapped to a geometric property called ldquoGeometryrdquo whose spatialcontext association is to a spatial context called ldquoDefaultrdquo

FDO Provider for ODBC CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

FDO Provider for ODBC Capabilities | 249

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

SQL

XML configuration

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 56 digits (maximum decimalprecision of 28 and maximum decimal scale of 28)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

250 | Appendix C OSGeo FDO Provider for ODBC

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Auto-generated data types Int16 and Int64

Identity properties of type Boolean Byte and DateTime

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite ID

Default value

Inheritance

Multiple schemas

Null value constraints

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaning

FDO Provider for ODBC Capabilities | 251

of the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLCommand

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Intersects Within Inside and EnvelopeIntersects

252 | Appendix C OSGeo FDO Provider for ODBC

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The full range of expression functions are supported as set out in theCapabilities chapter

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZ is supported The Point geometry types is supported

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for ODBC Capabilities | 253

254

OSGeo FDO Provider forSDF

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SDF

What Is FDO Provider for SDFThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SDF is a standalone fileformat that supports GIS data

The FDO Provider for SDF uses Autodesks spatial database format which is afile-based personal geodatabase that supports multiple featuresattributes spatialindexing interoperability file-locking and high performance for large datasets

The SDF file format has the following characteristics

SDF files can be read on different platforms

The SDF file has its own spatial indexing

SDF files can store geometric and non-geometric data with minimumoverhead

Although it does not support concurrency control (locking) the SDF fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SDF API Reference Help (SDF_Provider_APIchm)

D

255

FDO Provider for SDF CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per command threaded

dynamic spatial content extent type

Write

Flush

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

256 | Appendix D OSGeo FDO Provider for SDF

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Int32 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Exclusive value range constraints

FDO Provider for SDF Capabilities | 257

Inclusive value range constraints

Inheritance

Null value constraints

Schema modification

Value constraints list

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

SdfCommandType_ExtendedSelect

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

258 | Appendix D OSGeo FDO Provider for SDF

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Contains Disjoint Inside Intersects Withinand EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty geomValue)

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBGeometricProperty AssociationProperty

Double Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

FDO Provider for SDF Capabilities | 259

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeometry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

260 | Appendix D OSGeo FDO Provider for SDF

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SDF Capabilities | 261

262

OSGeo FDO Provider forSHP

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SHP

What Is FDO Provider for SHPThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SHP provides FDO withaccess to an SHP-based data store

The FDO Provider for SHP uses a standalone file format that supports GIS dataThe FDO Provider for SHP (Shape) has the following characteristics

Read-only access is provided to pre-existing spatial and attribute data froman Environmental Systems Research Institute (ESRI) Shape file (SHP)

The FDO Provider for SHP can run in a multi-platform environmentincluding Windows and Linux

A Shape file consists of three separate files SHP (shape geometry) SHX (shapeindex) and DBF (shape attributes in dBASE format)

The FDO Provider for SHP accesses the information in each of the threeseparate files and treats each SHP and its associated DBF file as a featureclass with a single geometry property and optionally with data attributeproperties

Schema configuration of the data store is provided to the FDO Provider forSHP through an XML file containing the Geographic Markup Language

E

263

(GML) definition of the schema that maps SHP and DBF data in the datastore to feature classes and property mappings in the FDO data model

Although it does not support concurrency control (locking) the SHP fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SHP API Reference Help (SHP_Provider_APIchm)

Creating SHP Files for the Logical to PhysicalSchema Mapping

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The shape files used for the purpose of mapping FDO logical types to shapenative types were created using the following method The path argument isthe path to a filename whose pattern is ltbasegtshp The type argument specifiesthe type of the shape filersquos geometry for example ShapLibShapeTypePointExecution of the method creates the named ltbasegtshp file as well as altbasegtshx file

using MapTools

public bool CreateShpFile(string path ShapeLibShapeType type)

IntPtr hShp = ShapeLibSHPCreate(path type)

if (hShpEquals(IntPtrZero)) return false

else

ShapeLibSHPClose(hShp)

return true

The FDO ApplySchema creates the ltbasegtdbf and ltbasegtcpg It will alsocreate the ltbasegtprj file if a spatial context has been created and the nameof the coordinate system referenced by the spatial context definition has beenassigned to the feature geometric property definitionrsquos spatial contextassociation property

264 | Appendix E OSGeo FDO Provider for SHP

Creating SHP Files for the Physical to LogicalSchema Mapping

To do the physical to logical schema mapping requires shp files containingall possible shp data types Two approaches for creating such shp files havebeen used The first approach is to use the ArcSDE sde2shp command toconvert an ArcSDE schema to a shapefile schema The second approach is touse the ShapeLib C library to create the shapefiles

sde2shp

This command converts the contents of an ArcSDE data store into a set ofshape files The conversion is guided by a text specification that maps anArcSDE column name to a tuple consisting of a shape table column name ashape column type identifier a column width and optionally the number ofdeciaml places

The source ArcSDE data store for this exercise is that specified in the ArcSDEappendix in the topic about physical to logical schema mapping The datastore contained a table called ldquoExistingTablerdquo This table containing a geometrycolumn called ldquofeatgeomrdquo The featgeom column allows only point geometriesto be stored A shape geometry can only be of one type So for the conversionto work the ArcSDE geometry column has to be restricted to contain onlyone geometry type The source ArcSDE data store contained no data TheArcSDE geometry was created with a coordinate system specified

The syntax of the command follows sde2shp -o init -l

ExistingTablefeatgeom -f points -a file=pointstxt -t point -i

esri_sde_ss -u sde -p fdotest The -f argument becomes the root name ofthe shape files that are created by the command (pointsshp pointsshxpointsdbf pointsidx and pointsprj) The -t argument is the shape geometrytype The -i argument is the name of the ArcSDE server instance the symbolicname is mapped to a TCP port in theCWINDOWSsystem32driversetcservices file The -u and -p argumentsidentify a username and password in the data store The -a argument identifiesthe file used to specify the conversion of the non-geometry columnconversions

The contents of the pointstxt conversion file are as follows

Creating SHP Files for the Physical to Logical Schema Mapping | 265

smInt4Col smInt4 N 4

int16Col int16Col N 4

int32Col int32Col N 10

float32Col float32C N 6 2

float64Col float64C N 15 4

int10 Int10 N 10

float4_4 float4_4 N 4 3

double7_4 doubl7_2 N 7 2

string64 str64 C 64

nStringCol nStrCol C 254

dateCol dateCol D 8

NOTE Initial values for column widths and number of decimal places were takenfrom the output of the sdetable -o describe command These values were changedover the course of several executions of the sde2shp in response to warning anderror messages issued by the sde2shp command

ShapeLib

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The ltbasegtshp and ltbasegtshx files are created by the ShapeLibSHPCreatemethod

The ltbasegtprj file is created by using a text editor to create the file andinserting the WKT string specification for the coordinate system

The ltbasegtdbf file is created by the following code

IntPtr dbfFile = MapToolsShapeLibDBFCre

ate(Pointspointsdbf)

int logicalColNum = MapToolsShapeLibDBFAddField(dbfFile Logic

alCol ShapeLibDBFFieldTypeFTLogical 1 0)

int strColNum = MapToolsShapeLibDBFAddField(dbfFile StrCol

ShapeLibDBFFieldTypeFTString 64 0)

int dateColNum = MapToolsShapeLibDBFAddField(dbfFile DateCol

ShapeLibDBFFieldTypeFTDate 8 0)

int integer20_0Num = MapToolsShapeLibDBFAddField(dbfFile In

teger20 ShapeLibDBFFieldTypeFTInteger 20 0)

int double18_4Num = MapToolsShapeLibDBFAddField(dbfFile

Double18_4 ShapeLibDBFFieldTypeFTDouble 18 4)

MapToolsShapeLibDBFClose(dbfFile)

266 | Appendix E OSGeo FDO Provider for SHP

Logical to Physical Schema MappingThe SHP provider supports the DestroySchema and ApplySchema commandsSo it is possible to create shape files whose schema has been defined usingFDO and then map the logical FDO data types to the shape native types Thismapping is described here The creation of the shape file used for this purposeis described in this appendix

Native Type Column Width Decimal PlacesFDO Type

L 1Boolean

D 8DateTime

N gt0 gt0Decimal

N 11Int32

C gt0String

Physical to Logical Schema MappingWhen FDO describes the schema of an existing shapefile that was not createdby the ApplySchema command it maps native data types to FDO data typesTwo shapfiles have been mapped One shapfile has been created using theArcSDE command sde2shp The creation of the source ArcSDE schema isdescribed in the appendix for the ArcSDE provider The other shapfile hasbeen created using a NET wrapper for the ShapeLib C Library These twomethods for creating shapefiles are described in this appendix

The schema name is ldquoDefaultrdquo The class name is the root name of the fileFor example if the filename is ldquopointsshprdquo the class name is ldquopointsrdquo Theattribute property names are the dBASE column names The geometry propertyname is ldquoGeometryrdquo The value of the feature classrsquos SpatialContextAssociationproperty is the name of the coordinate system specified in the prj file Forexample if the coordinate system specification in the prj has the patternldquoPROJCS[]rdquo the value of the SpatialContextAssociation proerty is the valueof the ltnamegt parameter in the pattern ldquoPROJCS[ltnamegt]rdquo

Logical to Physical Schema Mapping | 267

sde2shp

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat came from the conversion of an ArcSDE schema is in the following table

FDO Data TypeNative Type Column Width DecimalPlaces

DecimalN 4

DecimalN 10

DecimalN 6 2

DecimalN 15 4

DecimalN 4 3

DecimalN 7 2

StringC

DateTimeD

ShapeLib

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat was created by a ShapeLib program is in the following table

FDO Data TypeNative Type Column Width Decimal Places

BooleanL 1

StringC 64

DateTimeD 8

DecimalN 20 0

268 | Appendix E OSGeo FDO Provider for SHP

FDO Data TypeNative Type Column Width Decimal Places

DecimalN 18 4

FDO Provider for SHP CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

multiple spatial contexts

Write

Multi-user write

Flush

FDO Provider for SHP Capabilities | 269

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 255 digits (maximum decimalprecision of 255 and maximum decimal scale of 255)

Int32 data type with a maximum length of 4 bytes

String data type with a maximum length of 255

Int32 auto-generated data type

Identity properties of type Int32

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 7 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 11 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 0 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Multiple schemas

Null value constraints

270 | Appendix E OSGeo FDO Provider for SHP

Schema modification

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

FDO Provider for SHP Capabilities | 271

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Within Inside Intersects EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleSingle Int16 Int32 or Int64

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

272 | Appendix E OSGeo FDO Provider for SHP

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

GeometricProperty SpatialContexts(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SHP Capabilities | 273

274

OSGeo FDO Provider forSQL Server Spatial

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in the commandrsquosclass collection The mapping of logical FDO data types to native types isdescribed here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the number ofdigits to the right of the decimal point The maximum number of digits in the nativetype is 38

NOTE The definition of the FDO String data type requires that the length propertybe set

Native TypeFDO Data Type

bitBoolean

tinyintByte

datetimeDateTime

decimal(204)Decimal (precision property is set to 20and scale property is set to 4)

F

275

Native TypeFDO Data Type

floatDouble

smallintInt16

intInt32

bigintInt64

realSingle

nvarchar(64)String (length property set to 64)

geographygeometry with a geodetic coordinate sys-tem

geometrygeometry with a Euclidean coordinate sys-tem

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The database name is used for the feature schema name The table names areused for class names Column names are used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are date datetim2(7) datetimeoffset(7) hierarchyid sql_variatn time(7)and xml The mapping of the rest of the native data types is in the followingtable

276 | Appendix F OSGeo FDO Provider for SQL Server Spatial

NOTE The geography and geometric native types map to the geometric propertytype FDO properties are classified as data geometric object association or rasterOnly the data properties are further classified

FDO TypeNative Type

Int64bigint

BLOBbinary(50)

Booleanbit

Stringchar(10)

DateTimedatetime

Decimaldecimal(180)

Doublefloat

Geometricgeography

Geometricgeometry

BLOBimage

Int32int

Decimalmoney

Stringnchar(10)

Stringntext

Decimalnumeric(180)

Stringnvarchar(50)

Physical to Logical Schema Mapping | 277

FDO TypeNative Type

Stringnvarchar(MAX)

Singlereal

DateTimesmalldatetime

Int16smallint

Decimalsmallmoney

Stringtext

DateTimetimestamp

Bytetinyint

Stringuniqueidentifier

BLOBvarbinary(50)

Stringvarchar(50)

BLOBvarbinary(MAX)

278 | Appendix F OSGeo FDO Provider for SQL Server Spatial

OSGeo FDO Provider forWFS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WFS

What Is FDO Provider for WFSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WFS provides FDO withaccess to a WFS-based data store

An OGC Web Feature Service (WFS) provides access to geographic features thatare stored in an opaque data store in a clientserver environment A client usesWFS to retrieve geospatial data that is encoded in Geography Markup Language(GML) from a single or multiple Web Feature Service The communicationbetween client and server is encoded in XML If the WFS response includesfeature geometries it is encoded in Geography Markup Language (GML) whichis specified in the OpenGIS Geographic Markup Language ImplementationSpecification

Using FDO Provider for WFS data manipulation operations you can do thefollowing

Query features based on spatial and non-spatial constraints

Create new feature instances

Delete feature instances

Update feature instances

G

279

Lock feature instances

For more information see The Essential FDO (FET_TheEssentialFDOpdf)

NOTE There is no public API documentation for the FDO Provider for WFSfunctionality is available through the main FDO API

FDO Provider for WFS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threaded

static spatial content extent type

multiple spatial contexts

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()

280 | Appendix G OSGeo FDO Provider for WFS

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of unknown bytes

Byte data type with a maximum length of unknown bytes

DateTime data type with a maximum length of unknown bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of unknown bytes

Int16 data type with a maximum length of unknown bytes

Int32 data type with a maximum length of unknown bytes

Int64 data type with a maximum length unknown 8 bytes

Single data type with a maximum length of unknown bytes

String data type with a maximum length of unknown

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name (null)

Composite ID

FDO Provider for WFS Capabilities | 281

Multiple schemas

Object properties

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_GetSpatialContexts

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

use of expressions for properties in Select and SelectAggregates commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

282 | Appendix G OSGeo FDO Provider for WFS

Basic expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeoemtry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

FDO Provider for WFS Capabilities | 283

No Raster capabilities are supported

284 | Appendix G OSGeo FDO Provider for WFS

OSGeo FDO Provider forWMS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WMS

What Is FDO Provider for WMSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WMS provides FDO withaccess to a WMS-based data store

An Open Geospatial Consortium (OGC) Web Map Service (WMS) producesmaps of spatially referenced data dynamically from geographic informationThis international standard defines a map to be a portrayal of geographicinformation as a digital image file suitable for display on a computer screen Amap is not the data itself Maps by WMS are generally rendered in a pictorialformat such as PNG GIF or JPEG or occasionally as vector-based graphicalelements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile(WebCGM) formats

The FDO Provider for WMS has the following characteristics

The FDO Provider for WMS serves up map information originating from anOGC Basic Web Map Service that provides pictorially formatted images suchas PNG GIF or JPEG

WMS map data is exposed through an FDO feature schema whose classescontain an FDO Raster property definition The FDO schema exposed fromthe FDO Provider for WMS conforms to a pre-defined FDO schema that is

H

285

specific to WMS and that acts as the basis for all FDO interaction withWMS data regardless of the originating source of the WMS images

WMS data manipulation operations are limited to querying features basedon spatial and non-spatial constraints Schema manipulation operationsare not supported

The FDO Provider for WMS can run in a multi-platform environmentincluding Windows and Linux

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for WMS API Reference Help (WMS_Provider_APIchm)

FDO Provider for WMS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

286 | Appendix H OSGeo FDO Provider for WMS

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

String data type with a maximum length of unknown

BLOB data type with a maximum length of unknown bytes

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Inheritance

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FDO Provider for WMS Capabilities | 287

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_GetSpatialContexts

The following capabilities are supported

simple functions in Select and SelectAggregate commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No filter capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Function expressions are supported

The following functions are supported

BLOB RESAMPLE(BLOB raster Double minX Double minY Double maxXDouble maxY Int32 height Int32 width)

BLOB CLIP(BLOB raster Double minX Double minY Double maxX DoublemaxY)

GeometricProperty SpatialExtents(BLOB raster)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaning

288 | Appendix H OSGeo FDO Provider for WMS

of the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Polygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

The Raster capability is supported The following raster data models aresupported

Bitonal1-bitpixelUnsigned Integer

Gray8-bitpixelUnsigned Integer

RGB24-bitpixelUnsigned Integer

RGBA32-bitpixelUnsigned Integer

Palette8-bitpixelUnsigned Integer

FDO Provider for WMS Capabilities | 289

290

Index

A

AGF 152API

defined 5FDO 5

application development 11architecture and packages 8ArcSDE

limitations 212ArcSDE Provider 211

Capabilities 227 237 249 256 269 280 286

Software Requirements 211association property 15Autodesk Geometry Format (AGF) 152

B

behaviors GisPtr 25BinaryOperations 146

C

calls chain 25capabilities

FDO Provider for ArcSDE 227 237 249 256 269 280 286

classcontained 91feature 14IdentityProperty and

ObjectProperty 91ndash92standalone 91

Class Diagram FDO Schema Element 93class type 14collection classes 23comparison operations 146connection

ArcSDE 216establishing 29

semantics 27constraints expression text 141constraints filter text 141constraints provider-specific 141Contained Class 91context spatial 18

D

data concepts 13data property

defined 15data sources and data stores 27data store 18

defined 18FDO Provider for ArcSDE 211FDO Provider for MySQL 233FDO Provider for ODBC 243FDO Provider for SDF 255FDO Provider for SHP 263FDO Provider for WMS 285filtering 19 139locking 19querying 129schemas and the 85transactions 20

data stores data sources and 27data type

DATETIME 145DOUBLE 145IDENTIFIER 144INTEGER 145PARAMETER 144STRING 144

data type mappings 217data types 144DataStore

FDO Provider for ArcSDE 211develop applications 11dimensionality defined 15

Index | 291

E

edit a GML schema file 101element states schema 94elements of a schema 14example

creating a schema 111creating a schema read in from an

XML file 114deleting property values 127describing a schema 114destroying a schema 114inserting an Integer a string and a

Geometry Value 122query 130schema management 111updating property values 125

expression grammar 143expression text 140Expression defined 19expressions 140

F

factory abstract geometry 159FDO

architecture and packages 8FDO API

defined 5FDO concepts

commands 18data store 18expression 19feature class 14filter 19geometry property 16locking 19object property 17property 15spatial context 18transactions 20

FDO In General 161FDO Provider for ArcSDE

capabilities 227 237 249 256 269 280 286

connection 216

defined 211software requirements 211

FDO Provider for MySQLdefined 233

FDO Provider for ODBCdefined 243

FDO Provider for SDF 255defined 255

FDO Provider for SDF defined 255FDO Provider for SHP

defined 263FDO Provider for WMS

defined 285FDO schema element class diagram 93FDO XML format 95FDOClass 90FDOFeatureClass 90FDOIActivateLongTransaction 136FDOICommitLongTransaction 137FDOICreateLongTransaction 137FDOIDeactivateLongTransaction 136FDOIGetLongTransactions 137FDOIRollbackLongTransaction 136feature class 14feature schema creating a 218filter

grammar 141Filter 139

defined 19filter text 140filters 19

G

geometric types mapping betweenGeometry and 160

geometry 16Geometry

basic or pure 152properties 16types 159value 147working with 151

geometry and geometric types mappingbetween 160

Geometry API 151

292 | Index

GIS_SAFE_RELEASE (ptr) 21ndash22GisPtr 22GML schema file creating and

editing 101

H

handler exception 23

K

keywords filter and expression 144

L

locking 19ArcSDE limitations 213defined 19

long transactiondefined 135leaf 135root 20 135ndash136

M

mappingsdata type 217physical 86

memory management 21models modifying 94

N

non-feature class issues 91non-smart ptr 26

O

object propertydefined 17

ObjectProperty types 90OGC WKT 151operations comparison 146operations data maintenance 119

operator precedence 146operators 146overrides

schema 88

P

packageconnections 27Schema 85

packages FDO 8parent in the schema classes 86properties

base 85Geometry 16

propertyassociation 15data 15defined 15object 17Raster 17

property definitions adding GMLfor 105

property values 120data 120geometry 121

Provider for ArcSDEconnection 216defined 211

Provider for MySQLdefined 233

Provider for ODBCdefined 243

Provider for SHPdefined 263

provider defined 9

Q

querycreating 129example 130

Index | 293

R

raster propertydefined 17

references cross-schema 86requirements

FDO Provider for ArcSDE 211rollback mechanism schema 95root long transaction defined 20

S

SampleFeatureSchemaxml 115schema

defined 13schema elements 14

schema management 111schema mapping defined 14schema overrides 14schema create 89 218schemas

describing 92element states 94modifying models 94rollback mechanism 95working with 88

SDFFDO Provider for 255

software requirements 211spatial context 161spatial context defined 18special characters 147

standalone class 91states schema element 94supported interfaces LT 136

T

text expression 140text filter 140transaction long 20types

Geometry 159ObjectProperty 90

U

UnaryOperations 146

V

valuesdeleting 126updating 125

W

WKT 151

X

XML Format FDO 95

294 | Index

  • Contents
  • About This Guide
    • Audience and Purpose
    • How This Guide Is Organized
    • Whatrsquos New
      • Introduction
        • What Is the FDO API
          • From the Perspective of the Client Application User
          • From the Perspective of the Client Application Engineer
            • Getting Started
            • FDO Architecture and Providers
            • What Is a Provider
            • Developing Applications
              • FDO Concepts
                • Data Concepts
                • Operational Concepts
                  • Development Practices
                    • Memory Management
                    • Collections
                    • Exception Handling
                    • Exception Messages
                    • Managing FdoPtr Behaviors
                      • Establishing a Connection
                        • Connection Semantics
                        • Establishing a Connection
                          • FDO Capabilities
                            • FDO Capabilities
                              • Introduction
                              • Provider Type
                              • Command
                              • Connection
                              • Expression
                              • Filter
                              • Geometry
                              • Raster
                              • Schema
                                • Expressible as Boolean
                                • Not Expressible as a Boolean
                                  • Schema Management
                                    • Schema Package
                                    • Schema Mappings
                                    • Schema Overrides
                                    • Working with Schemas
                                    • FDOFeatureClass
                                    • FDOClass
                                    • Non-Feature Class Issues
                                    • Modifying Models
                                    • Schema Element States
                                    • Rollback Mechanism
                                    • FDO XML Format
                                    • Creating and Editing a GML Schema File
                                    • Schema Management Examples
                                      • Data Maintenance
                                        • Data Maintenance Operations
                                          • Inserting Values
                                          • Updating Values
                                          • Deleting Values
                                            • Related Class Topics
                                              • Performing Queries
                                                • Creating a Query
                                                • Query Example
                                                  • Long Transaction Processing
                                                    • What Is Long Transaction Processing
                                                    • Supported Interfaces
                                                      • Filter and Expression Languages
                                                        • Filters
                                                        • Expressions
                                                        • Filter and Expression Text
                                                        • Language Issues
                                                          • Provider-Specific Constraints on Filter and Expression Text
                                                          • Filter Grammar
                                                          • Expression Grammar
                                                          • Filter and Expression Keywords
                                                          • Data Types
                                                            • Identifier
                                                            • Parameter
                                                            • String
                                                            • Integer
                                                            • Double
                                                            • DateTime
                                                              • Operators
                                                              • Special Character
                                                              • Geometry Value
                                                                  • The Geometry API
                                                                    • Introduction
                                                                    • FGF and WKB
                                                                    • FGF Binary Specification
                                                                    • FGF Text
                                                                    • Abstract and Concrete Classes
                                                                    • Geometry Types
                                                                    • Mapping Between Geometry and Geometric Types
                                                                    • Spatial Context
                                                                    • Specify Dimensionality When Creating Geometries Using String Specifications
                                                                    • Inserting Geometry Values
                                                                      • FDO Cookbook
                                                                        • Introduction
                                                                        • Recommendations
                                                                        • Registry
                                                                        • Connection
                                                                        • Capabilities
                                                                        • Data Store
                                                                        • User Management
                                                                        • Spatial Context
                                                                        • Basic Schema Operations
                                                                        • Insert Data
                                                                        • Select Data
                                                                        • Select Aggregate Data
                                                                        • Delete Data
                                                                        • Schema Overrides
                                                                        • Xml SerializeDeserialize
                                                                          • C
                                                                            • Geometry
                                                                              • Construction
                                                                                • C Namespaces
                                                                                • C Geometry Scaffolding Classes
                                                                                • C Geometries Constructed using IDirectPositionImpl
                                                                                • C Geometries Constructed Using Geometry Subcomponents
                                                                                • C Aggregate Geometries
                                                                                • C Geometries from Text Specifications
                                                                                  • Deconstruction
                                                                                      • OSGeo FDO Provider for ArcSDE
                                                                                        • What Is FDO Provider for ArcSDE
                                                                                        • FDO Provider for ArcSDE Software Requirements
                                                                                          • Installed Components
                                                                                          • External Dependencies
                                                                                            • FDO Provider for ArcSDE Limitations
                                                                                            • ArcSDE Limitations
                                                                                              • Relative to ArcObjects API and ArcGIS Server API
                                                                                                • Curved Segments
                                                                                                  • Locking and Versioning
                                                                                                    • Table Creation
                                                                                                    • Identity Row ID Column and Enable Row Locking
                                                                                                    • Disable Row Locking and Enable Versioning
                                                                                                        • FDO Provider for ArcSDE Connection
                                                                                                        • Data Type Mappings
                                                                                                        • Creating a Feature Schema
                                                                                                        • Logical to Physical Schema Mapping
                                                                                                        • Physical to Logical Schema Mapping
                                                                                                        • FDO Provider for ArcSDE Capabilities
                                                                                                          • OSGeo FDO Provider for MySQL
                                                                                                            • What Is FDO Provider for MySQL
                                                                                                            • Logical to Physical Schema Mapping
                                                                                                            • Physical to Logical Schema Mapping
                                                                                                            • FDO Provider for MySQL Capabilities
                                                                                                              • OSGeo FDO Provider for ODBC
                                                                                                                • What Is FDO Provider for ODBC
                                                                                                                • Physical to Logical Schema Mappings
                                                                                                                • FDO Provider for ODBC Capabilities
                                                                                                                  • OSGeo FDO Provider for SDF
                                                                                                                    • What Is FDO Provider for SDF
                                                                                                                    • FDO Provider for SDF Capabilities
                                                                                                                      • OSGeo FDO Provider for SHP
                                                                                                                        • What Is FDO Provider for SHP
                                                                                                                        • Creating SHP Files for the Logical to Physical Schema Mapping
                                                                                                                        • Creating SHP Files for the Physical to Logical Schema Mapping
                                                                                                                        • Logical to Physical Schema Mapping
                                                                                                                        • Physical to Logical Schema Mapping
                                                                                                                        • FDO Provider for SHP Capabilities
                                                                                                                          • OSGeo FDO Provider for SQL Server Spatial
                                                                                                                            • Logical to Physical Schema Mapping
                                                                                                                            • Physical to Logical Schema Mapping
                                                                                                                              • OSGeo FDO Provider for WFS
                                                                                                                                • What Is FDO Provider for WFS
                                                                                                                                • FDO Provider for WFS Capabilities
                                                                                                                                  • OSGeo FDO Provider for WMS
                                                                                                                                    • What Is FDO Provider for WMS
                                                                                                                                    • FDO Provider for WMS Capabilities
                                                                                                                                      • Index
Page 4: here - OSGeo Download Server

Exception Messages 24Managing FdoPtr Behaviors 25

Chapter 5 Establishing a Connection 27Connection Semantics 27Establishing a Connection 29

Chapter 6 FDO Capabilities 35FDO Capabilities 35

Introduction 35Provider Type 36Command 37Connection 43Expression 47Filter 74Geometry 77Raster 78Schema 79

Expressible as Boolean 82Not Expressible as a Boolean 83

Chapter 7 Schema Management 85Schema Package 85Schema Mappings 87Schema Overrides 88Working with Schemas 88FDOFeatureClass 90FDOClass 90Non-Feature Class Issues 91Modifying Models 94Schema Element States 94Rollback Mechanism 95FDO XML Format 95Creating and Editing a GML Schema File 101Schema Management Examples 111

Chapter 8 Data Maintenance 119Data Maintenance Operations 119

Inserting Values 119Updating Values 125Deleting Values 126

Related Class Topics 127

iv | Contents

Chapter 9 Performing Queries 129Creating a Query 129Query Example 130

Chapter 10 Long Transaction Processing 135What Is Long Transaction Processing 135Supported Interfaces 136

Chapter 11 Filter and Expression Languages 139Filters 139Expressions 140Filter and Expression Text 140Language Issues 141

Provider-Specific Constraints on Filter and Expression Text 141Filter Grammar 141Expression Grammar 143Filter and Expression Keywords 144Data Types 144

Identifier 144Parameter 144String 144Integer 145Double 145DateTime 145

Operators 146Special Character 147Geometry Value 147

Chapter 12 The Geometry API 151Introduction 151FGF and WKB 151FGF Binary Specification 152FGF Text 158Abstract and Concrete Classes 158Geometry Types 159Mapping Between Geometry and Geometric Types 160Spatial Context 161Specify Dimensionality When Creating Geometries Using String

Specifications 161Inserting Geometry Values 162

Chapter 13 FDO Cookbook 163Introduction 163

Contents | v

Recommendations 163Registry 163Connection 164Capabilities 168Data Store 171User Management 173Spatial Context 175Basic Schema Operations 178Insert Data 181Select Data 182Select Aggregate Data 183Delete Data 184Schema Overrides 184Xml SerializeDeserialize 194

C 1 9 4Geometry 196

Construction 196C Namespaces 197C Geometry Scaffolding Classes 197C Geometries Constructed using

IDirectPositionImpl 200C Geometries Constructed Using Geometry

Subcomponents 201C Aggregate Geometries 202C Geometries from Text Specifications 204

Deconstruction 204

Appendix A OSGeo FDO Provider for ArcSDE 211What Is FDO Provider for ArcSDE 211FDO Provider for ArcSDE Software Requirements 211

Installed Components 211External Dependencies 212

FDO Provider for ArcSDE Limitations 212ArcSDE Limitations 212

Relative to ArcObjects API and ArcGIS Server API 213Curved Segments 213

Locking and Versioning 213Table Creation 214Identity Row ID Column and Enable Row Locking 214Disable Row Locking and Enable Versioning 215

FDO Provider for ArcSDE Connection 216Data Type Mappings 217Creating a Feature Schema 218Logical to Physical Schema Mapping 223Physical to Logical Schema Mapping 223FDO Provider for ArcSDE Capabilities 227

vi | Contents

Appendix B OSGeo FDO Provider for MySQL 233What Is FDO Provider for MySQL 233Logical to Physical Schema Mapping 234Physical to Logical Schema Mapping 235FDO Provider for MySQL Capabilities 237

Appendix C OSGeo FDO Provider for ODBC 243What Is FDO Provider for ODBC 243Physical to Logical Schema Mappings 244FDO Provider for ODBC Capabilities 249

Appendix D OSGeo FDO Provider for SDF 255What Is FDO Provider for SDF 255FDO Provider for SDF Capabilities 256

Appendix E OSGeo FDO Provider for SHP 263What Is FDO Provider for SHP 263Creating SHP Files for the Logical to Physical Schema Mapping 264Creating SHP Files for the Physical to Logical Schema Mapping 265Logical to Physical Schema Mapping 267Physical to Logical Schema Mapping 267FDO Provider for SHP Capabilities 269

Appendix F OSGeo FDO Provider for SQL Server Spatial 275Logical to Physical Schema Mapping 275Physical to Logical Schema Mapping 276

Appendix G OSGeo FDO Provider for WFS 279What Is FDO Provider for WFS 279FDO Provider for WFS Capabilities 280

Appendix H OSGeo FDO Provider for WMS 285What Is FDO Provider for WMS 285FDO Provider for WMS Capabilities 286

Index 291

Contents | vii

viii

About This Guide

The FDO Developerrsquos Guide introduces the Feature Data Objects (FDO) application programminginterface (API) and explains how to use its customization and development features

NOTE For detailed information about installing the FDO SDK and getting started usingthe FDO API see The Essential FDO (FET_TheEssentialFDO)

Audience and PurposeThis guide is intended to be used by developers of FDO applications It introducesthe FDO API explains the role of a feature provider and provides detailedinformation and examples about how to code your application

How This Guide Is OrganizedThis guide consists of the following chapters and appendixes

Introduction provides an overview of the FDO API and the function of FDOfeature providers

FDO Concepts on page 13 describes the key data and operational conceptsupon which FDO is constructed

Development Practices on page 21 discusses the best practices to followwhen using FDO for application development

Establishing a Connection on page 27 describes how to establish aconnection to an FDO provider

1

1

Capabilities discusses the Capabilities API which is used to determine thecapabilities of a particular provider

Schema Management on page 85 describes how to create and work withschemas and presents the issues related to schema management

Data Maintenance on page 119 provides information about using the FDOAPI to maintain the data

Performing Queries on page 129 describes how to create and performqueries

Long Transaction Processing on page 135 discusses long transactions (LT)and how to implement LT processing in your application

Filter and Expression Languages on page 139 discusses the use of filterexpressions to specify to an FDO provider how to identify a subset of theobjects of an FDO data store

The Geometry API on page 151 discusses the various Geometry types andformats and describes how to work with the Geometry API to developFDO-based applications

OSGeo FDO Provider for ArcSDE on page 211 discusses development issuesthat apply when using FDO Provider for ESRIreg ArcSDEreg

OSGeo FDO Provider for MySQL on page 233 discusses development issuesthat apply when using FDO Provider for MySQL

OSGeo FDO Provider for ODBC on page 243 discusses development issuesthat apply when using FDO Provider for ODBC

OSGeo FDO Provider for SDF on page 255 discusses development issuesthat apply when using FDO Provider for SDF

OSGeo FDO Provider for SHP on page 263 discusses development issuesthat apply when using FDO Provider for SHP (Shape)

OSGeo FDO Provider for WFS on page 279 discusses development issuesthat apply when using FDO Provider for WFS

OSGeo FDO Provider for WMS on page 285 discusses development issuesthat apply when using FDO Provider for WMS

Expression Functions outlines the signatures and implementation detailsfor the enhanced expression functions

2 | Chapter 1 About This Guide

Whatrsquos NewThis section summarizes the changes and enhancements you will find in thisversion of FDO

Enhanced Set of Expression Functions

The enhanced set includes aggregate conversion date mathematical numericstring and geometry functions All functions are supported by all providerswith the exception of the Raster WFS and WMS providers

For more information and implementation details about the expressionfunction signatures the RDBMS-specific built-in support for some of thefunctions and the provider-specific support see the appendix ExpressionFunctions

Whatrsquos New | 3

4

Introduction

You can use the APIs in the FDO API to manipulate define and analyze geospatial information

This chapter introduces application development with the FDO API and explains the role ofa feature provider

What Is the FDO API

From the Perspective of the Client Application User

The FDO API is a set of APIs used for creating managing and examininginformation enabling Autodesk GIS products to seamlessly share spatial andnon-spatial information with minimal effort

FDO is intended to provide consistent access to feature data whether it comesfrom a CAD-based data source or from a relational data store that supports richclassification To achieve this FDO supports a model that can readily supportthe capabilities of each data source allowing consumer applications functionalityto be tailored to match that of the data source For example some data sourcesmay support spatial queries while others do not Also a flexible metadata modelis required in FDO allowing clients to adapt to the underlying feature schemaexposed by each data source

From the Perspective of the Client ApplicationEngineer

The FDO API provides a common general purpose abstraction layer for accessinggeospatial data from a variety of data sources The API is in part an interface

2

5

specification of the abstraction layer A provider such as OSGeo FDO Providerfor MySQL is an implementation of the interface for a specific type of datasource (for example for a MySQL relational database) The API supports thestandard data store manipulation operations such as querying updatingversioning locking and others It also supports analysis

The API includes an extensive set of methods that return information aboutthe capabilities of the underlying data source For example one methodindicates whether the data source supports the creation of multiple schemasand another indicates whether the data source supports schema modification

A core set of services for providers is also available in the API such as providerregistration schema management filter and expression construction andXML serialization and deserialization

The API uses an object-oriented model for the construction of feature schemaA feature is a class and its attributes including its geometry are a propertyof the class The instantiation of a feature class a Feature Data Object (FDO)can contain other FDOs

Getting StartedFor detailed information to help you install and get started using Feature DataObjects (FDO) see The Essential FDO It provides details about connecting toand configuring providers data store management (createdelete) user IDs(create grant permissions) and spatial context

6 | Chapter 2 Introduction

FDO Architecture and ProvidersThe following diagram shows the high-level overview architecture of the FDOAPI and included FDO providers

FDO Architecture and Providers | 7

FDO Architecture and Providers

FDO Packages

FDO is assembled in conceptual packages of similar functionality Thisconceptual packaging is reflected in the substructure of the FDO SDK ldquoincludesrdquofolder For more information about the structure see The Essential FDO

FDO commands provider-specific commands and connections and capabilitiesprovide access to native data stores through each different FDO providerSchema management (through XML) client services and filters and expressionsare provider-independent packages that tie into the FDO API Each of theseare explained in more detail in subsequent sections

8 | Chapter 2 Introduction

The FDO API consists of classes grouped within the following packages

Commands package Contains a collection of classes that provide thecommands allowing the application to select and update features definenew types of feature classes lock features and perform analysis on featuresEach Command object executes a specific type of command against theunderlying data store In addition FDO providers expose one or moreCommand objects

ConnectionsCapabilities Contains a collection of classes that establishand manage the connection to the underlying data store Connectionobjects implement the FdoIConnection interface Capabilities API providesthe code for retrieving the various FDO provider capability categories suchas connection or schema capabilities You can use this this API to determinethe capabilities of a particular provider

Filters and Expression package Contains a collection of classes that definefilters and expression in FDO which are used to identify a subset of objectsof an FDO data store

Client Services package Contains a collection of classes that define theclient services in FDO that for example enable support for dynamiccreation of connection objects given a provider name

Schema package and FDO XML Contains a collection of classes thatprovides a logical mechanism for specifying how to represent geospatialfeatures The FDO feature schema is based somewhat on a subset of theOpenGIS and ISO feature models FDO feature schemas can be written toan XML file The FdoFeatureSchema and FdoFeatureSchemaCollectionclasses support the FdoXmlSerializable interface

In addition FDO is integrated with the Geometry API which includes theclasses that support specific Autodesk applications and APIs including FDO

For more information about each of the FDO packages see FDO API ReferenceHelp and subsequent chapters in this guide

Provider API(s) complete the FDO API configuration Each provider has aseparate API reference Help

What Is a ProviderA provider is a specific implementation of the FDO API It is the softwarecomponent that provides access to data in a particular data store

What Is a Provider | 9

For this release the providers that are included are as follows

NOTE For more information see the Open Source Geospatial Foundation websiteat wwwOSGeoorg

OsGeo FDO Provider for ArcSDE Readwrite access to feature data in anESRI ArcSDE-based data store (that is with an underlying Oracle or SQLServer database) Supports describing schema and inserting selectingupdating and deleting feature data in existing schemas does not supportcreating or deleting schemas

OsGeo FDO Provider for MySQL Readwrite access to feature data in aMySQL-based data store Supports spatial data types and spatial queryoperations A custom API can gather information transmit exceptions listdata stores and create connection objects MySQL architecture supportsvarious storage engines characteristics and capabilities

OsGeo FDO Provider for ODBC Readwrite access to feature data in anODBC-based data store Supports XYZ feature objects and can define featureclasses for any relational database table with X Y and optionally Zcolumns does not support creating or deleting schema Object locationsare stored in separate properties in the object definition

OsGeo FDO Provider for SDF Read-write access to feature data in anSDF-based data store Autodeskrsquos geospatial file format SDF supportsmultiple featuresattributes provides high performance for large data setsand interoperability with other Autodesk products and spatial indexingThe SDF provider a valid alternative to database storage Note that thisrelease of the SDF provider supports version 30 of the SDF file format

OsGeo FDO Provider for SHP Readwrite access to existing spatial andattribute data in an ESRI SHP-based data store which consists of separateshape files for geometry index and attributes Each SHP and its associatedDBF file is treated as a feature class with a single geometry property Thisis a valid alternative to database storage but does not support locking

OsGeo FDO Provider for WFS Read-only access to feature data in an OGCWFS-based data store Supports clientserver environment and retrievesgeospatial data encoded in GML from one or more Web Feature Servicessites Clientserver communication is encoded in XML with the exceptionof feature geometries which are encoded in GML Note that there is nopublic API documentation for this provider all functionality is accessiblevia the base FDO API

10 | Chapter 2 Introduction

OsGeo FDO Provider for WMS Read-only access to feature data in an OGCWMS-based data store Web Map Service (WMS) produces maps of spatiallyreferenced data dynamically from geographic information which aregenerally rendered in PNG GIF or JPEG or as vector-based Scalable VectorGraphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats

FDO supports retrieval and update of spatial and non-spatial GIS feature datathrough a rich classification model that is based on OpenGIS and ISOstandards

An overview of the relationships between providers data sources data storesand schemas is presented in the FDO Architecture and Providers graphic

For more detailed information about the providers see the appropriateappendix in this document Data sources and data stores are discussed in theEstablishing a Connection on page 27 chapter Schema concepts are discussedin the Schema Management on page 85 chapter

Developing ApplicationsYou will need to perform several major tasks in using the FDO API to developa custom application Each of these tasks breaks down into a number of moredetailed coding issues

The major development tasks are

Working with the Build Environment

Establishing a Connection

Schema Management

Data Maintenance

Creating Queries

Using Custom Commands (Provider-Specific)

These tasks are explored in detail in the chapters that follow

Developing Applications | 11

12

FDO Concepts

Before you can work properly with the FDO API you need to have a good understanding ofits basic underlying concepts This chapter defines the essential constructs and dynamicsthat comprise the FDO API The definitions of these constructs and dynamics are groupedinto two interdependent categories

Data Concepts Definitions of the data constructs that comprise the FDO API

Operational Concepts Definitions of the operations that are used to manage andmanipulate the data

Data ConceptsAll concepts that are defined in this section relate to the data that FDO isdesigned to manage and manipulate

What Is a Feature

A feature is an abstraction of a natural or man-made real world object It isrelated directly or indirectly to geographic locations A spatial feature has oneor more geometric properties For example a road feature might be representedby a line and a hydrant might be represented by a point A non-spatial featuredoes not have geometry but can be related to a spatial feature which does Forexample a road feature may contain a sidewalk feature that is defined as notcontaining a geometry

What Is a Schema

A schema is a logical description of the data types used to model real-worldobjects A schema is not the actual data instances (that is not a particular roador land parcel) rather it is metadata A schema is a model of the types of data

3

13

that would be found in a data store For example a schema which models thelayout of city streets has a class called Road and this class has a property calledName The definition of Road and its associated classes constitute the schema

What Is a Schema Override

A schema override comprises instructions to override the default schemamappings For example an RDBMS-type FDO provider could map a featureclass to a table of the same name by default A schema override might mapthe class to a differently named table for example by mapping the poleclass to the telco_pole table

What is a Schema Mapping

A Schema Mapping is a correspondence between a Schema Element and aphysical object in a data store For example OSGeo FDO Provider for MySQLmaps each Feature Class onto a table in the MySQL database where the datastore resides The physical structure of data stores for each FDO provider canvary greatly so the types of Schema Mappings can also vary between providersEach provider defines a set of default schema mappings For example OSGeoFDO Provider for MySQL maps a class to a table of the same name by defaultThese defaults can be overridden by specifying Schema Overrides

What Are Elements of a Schema

A schema consists of a collection of schema elements In the FDO API schemaelements are related to one another by derivation and by aggregation Anelement of a schema defines a particular type of data such as a feature classor a property or an association For example a feature class definition for aroad includes the class name (for example Road) and the class properties (forexample Name NumberLanes PavementType and Geometry)

What Is a Class Type

A class type is a specialization of the base FDO class definition(FdoClassDefinition) It is used to represent the complex properties of spatialand non-spatial features

What is a Feature Class

A feature class is a schema element that describes a type of real-world objectIt includes a class name and property definitions including zero or moregeometric properties It describes the type of data that would be included inobject instances of that type

14 | Chapter 3 FDO Concepts

What Is a Property

A property is a single attribute of a class and a class is defined by one or moreproperty definitions For example a Road feature class may have propertiescalled Name NumberLanes or Location A property has a particular typewhich can be a simple type such as a string or number or a complex typedefined by a class such as an Address type which itself is defined by a set ofproperties such as StreetNumber StreetName or StreetType

There are five kinds of properties association properties data propertiesgeometric properties object properties and raster properties

Individual properties are defined in the following sections

What Is an Association Property

The FdoAssociationPropertyDefinition class is used to model a peer-to-peerrelationship between two classes This relationship is defined at schemacreation time and instantiated at object creation time The association propertysupports various cardinality settings cascading locks and differing deleterules An FDO filter can be based on association properties andFdoIFeatureReader can handle associated objects through the GetObject()method

What Is a Data Property

A data property is a non-spatial property An instance of a data propertycontains a value whose type is either boolean byte datetime decimal singledouble Int16 Int32 Int64 string binary large object or character large object

What Is Dimensionality

Dimensionality and the concept of dimension has two different meaningsin the discussion of geometry and geometric property

The first is called shape dimensionality and it is defined by theFdoGeometricType enumeration The four shapes are point (0 dimensions)curve (1 dimensions) surface (2 dimensions) and solid (3 dimensions)

The other is called ordinate dimensionality and it is defined by theFdoDimensionality enumeration There are four ordinate dimensions XYXYZ XYM and XYZM M stands for measure

Data Concepts | 15

What Is a Geometric Property

An instance of a geometric property contains an object that represents ageometry value The definition of the geometric property may restrict anobject to represent a geometry that always has the same shape such as a pointor it could allow different object instances to have different dimensions Forexample one geometric property object could represent a point and anothercould represent a line Any combination of shapes is permissible in thespecification of the geometric types that a geometry property definitionpermits The default geometric property specifies that an object could representa geometry that is any one of the four shapes

With respect to ordinate dimensionality all instances of a geometric propertymust have the same ordinate dimension The default is XY

Geometric property definitions have two attributes regarding ordinatedimensionality HasElevation for Z and HasMeasure for M

What is a Geometry

A geometry is represented using geometric constructs either defined as listsof one or more XY or XYZ points or defined parametrically for example asa circular arc While geometry typically is two- or three-dimensional it mayalso contain the measurement dimension (M) to provide the basis for dynamicsegments

The geometry types are denoted by the FdoGeometryType enumeration anddescribe the following

Point

LineString (one or more connected line segments defined by positions atthe vertices)

CurveString (a collection of connected circular arc segments and linearsegments)

Polygon (a surface bound by one outer ring and zero or more interior ringsthe rings are closed connected line segments defined by positions at thevertices)

CurvePolygon (a surface bound by one outer ring and zero or more interiorrings the rings are closed connected curve segments)

MultiPoint (multiple points which may be disjoint)

MultiLineString (multiple LineStrings which may be disjoint)

16 | Chapter 3 FDO Concepts

MultiCurveString (multiple CurveStrings which may be disjoint)

MultiPolygon (multiple Polygons which may be disjoint)

MultiCurvePolygon (multiple CurvePolygons which may be disjoint)

MultiGeometry (a heterogenous collection of geometries which may bedisjoint)

Most geometry types are defined using either curve segments or a series ofconnected line segments Curve segments are used where non-linear curvesmay appear The following curve segment types are supported

CircularArcSegment (circular arc defined by three positions on the arc)

LineStringSegment ( a series of connected line segments defined bypositions are the vertices)

There are currently no geometries of type ldquosolidrdquo (3D shape dimensionality)supported

The FdoIConnectionGetGeometryCapabilities() method can be used to querywhich geometry types and ordinate dimensionalities are supported by aparticular provider

What Is an Object Property

An object property is a complex property type that can be used within a classand an object property itself is defined by a class definition For examplethe Address type example described previously in the Property definition Anobject property may define a single instance for each class object instance (forexample an address property of a land parcel) or may represent a list ofinstances of that class type per instance of the owning class (for exampleinspection records as a complex property of an electrical device feature class)

What is a Raster Property

A raster property defines the information needed to process a raster imagefor example the number of bits of information per pixel the size in pixels ofthe X dimension and the size in pixels of the Y dimension needed to processa raster image

Data Concepts | 17

What Is a Spatial Context

A spatial context describes the general metadata or parameters within whichgeometry for a collection of features resides In particular the spatial contextincludes the definition of the coordinate system spheroid parameters unitsspatial extents and so on for a collection of geometries owned by features

Spatial context can be described as the ldquocoordinate system plus identityrdquo Anygeometries that are to be spatially related must be in a common spatial context

The identity component is required in order to support separate workspacessuch as schematic diagrams which are non-georeferenced Also it supportsgeoreferenced cases For example two users might create drawings using somedefault spatial parameters (for example rectangular and 10000x10000)although each drawing had nothing to do with the other If the drawings wereput into a common database the users could preserve not only the spatialparameters but also the container aspect of their data using spatial context

For more information about spatial context see Spatial Context on page 161

What is a Data Store

A data store is a repository of an integrated set of objects The objects in a datastore are modeled either by classes or feature classes defined within one ormore schemas For example a data store may contain data for both a LandUseschema and a TelcoOutsidePlant schema Some data stores can represent datain only one schema while other data stores can represent data in manyschemas (for example RDBMS-based data stores such as MySQL)

Operational ConceptsThe concepts that are defined in this section relate to the FDO operations usedto manage and manipulate data

What Is a Command

In FDO the application uses a command to select and update features definenew types of feature classes lock features version features and perform someanalysis of features Each Command object executes a specific type of commandagainst the underlying data store Interfaces define the semantics of eachcommand allowing them to be well-defined and strongly typed Because FDOuses a standard set of commands providers can extend existing commandsand add new commands specific to that provider Feature commands execute

18 | Chapter 3 FDO Concepts

against a particular connection and may execute within the scope of atransaction

An FDO command is a particular FDO interface that is used by the applicationto invoke an operation against a data store A command may retrieve datafrom a data store (for example a Select command) may update data in a datastore (for example an Update or Delete command) may perform some analysis(for example an Activate Spatial Context command) or may cause some otherchange in a data store or session (for example a Begin Transaction command)

What Is an Expression

An expression is a construct that an application can use to build up a filterAn expression is a clause of a filter or larger expression For example ldquoLanesgt=4 and PavementType = Asphaltrdquo takes two expressions and combines themto create a filter

For more information about using expressions with FDO see Filter andExpression Languages on page 139

What Is a Filter

A filter is a construct that an application specifies to an FDO provider toidentify a subset of objects of an FDO data store For example a filter may beused to identify all Road type features that have 2 lanes and that are within200 metres of a particular location Many FDO commands use filter parametersto specify the objects to which the command applies For example a Selectcommand uses a filter to identify the objects that the application wants toretrieve Similarly a Delete command uses a filter to identify the objects thatthe application wants to delete from the data store

For more information about using filters with FDO see Filter and ExpressionLanguages on page 139

What Is Locking

A user can use locking to gain update control of an object in the data store tothe exclusion of other users There are two general types of locksmdashtransactionlocks and persistent locks Transaction locks are temporary and endure onlyfor the duration of the transaction (see What Is a Transaction on page 20)

Persistent locks applied to objects by a user remain with the object until eitherthat user removes those locks or the locks are removed by another user withthe appropriate authority

Operational Concepts | 19

What Is a Transaction

A transaction changes the data store in some way The way these changesaffect the data store is determined by the transactionrsquos properties For examplethe Atomic property specifies that either all changes happen or non happenIn transaction processing the data store treats a series of commands as a singleatomic unit of change to that data store Either all changes generated by thecommands are successful or the whole set is cancelled A transaction is a singleatomic unit of changes to a data store The application terminates a transactionwith either a ldquocommitrdquo which applies the set of changes or a ldquorollbackrdquowhich cancels the set of changes Further the data store may automaticallyroll back a transaction if it detects a severe error in any of the commandswithin the transaction A transaction has the following properties

Atomic Either all changes generated by the commands within a transactionhappen or none happen

Consistent The transaction leaves the data store in a consistent stateregarding any constraints or other data integrity rules

Isolated Changes being made within a transaction by one user are notvisible to other users until after that transaction is committed

Durable After a transaction is completed successfully the changes arepersistent in the data store on disk and cannot be lost if the program orprocessor fails

What Is a Long Transaction

A long transaction (LT) is an administration unit used to group conditionalchanges to objects Depending on the situation such a unit might containconditional changes to one or to many objects Long transactions are used tomodify as-built data in the database without permanently changing the as-builtdata Long transactions can be used to apply revisions or alternates to anobject

What Is a Root Long Transaction

A root long transaction is a long transaction that represents permanent dataAny long transaction has a root long transaction as an ancestor in its longtransaction dependency graph

20 | Chapter 3 FDO Concepts

Development Practices

This chapter explains several practices to follow when working with the FDO API and providesexamples of how to follow these practices

Memory ManagementSome FDO functions (for example the Create methods) allocate memory whenthey are called This memory needs to be freed to prevent memory leaks Alldestructors on FDO classes are protected so you must call a Release() functionto destroy them (thus freeing their allocated memory) Each class inherits fromthe FdoIDisposable class which defines the Release() method and the AddRef()method

In addition these classes are reference counted and the count is increased (byAddRef()) when you retrieve them through a Get function After finishing withthe object you need to release it (just as with COM objects) The object isdestroyed only when the reference count hits 0 Two macros are defined to helpin the use of the Release() and AddRef() methods

FDO_SAFE_RELEASE (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_RELEASE calls the release() methodof the object pointed to by the ldquoptrrdquo argument and then sets the local pointerto the object to NULL The macro definition is define FDO_SAFE_RELEASE(x)

if (x) (x)-gtRelease() (x) = NULL

FdoFeatureClass pBase = myClass-gtGetBaseClass()

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

4

21

FDO_SAFE_ADDREF (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_ADDREF calls the AddRef()method of the object pointed to by the ldquoptrrdquo argument The macro definitionis define FDO_SAFE_ADDREF(x) ((x = NULL) (x)-gtAddRef() (x)

(NULL))

return FDO_SAFE_ADDREF(value)returns NULL if value equals NULL orincrements the reference count of the object that value points to andreturns value

m_list[index] = FDO_SAFE_ADDREF(value) assigns NULL to the arrayentry if value is NULL or increments the reference count of the object thatvalue points to and assigns value to the array entry

FdoPtr

An FdoPtr smart pointer is provided to help manage memory You wrap anFDO object in a FdoPtr The requirement is that the objectrsquos type must inheritfrom FdoIDisposable The object is then released automatically when theFdoPtr goes out of scope The following code illustrates how to use FdoPtr

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

No need to call FDO_SAFE_RELEASE

Before it is destroyed pBase calls Release() on the FdoFeature

Class object

NOTE If for some reason you wanted to use FDO_SAFE_RELEASE on an FdoPtryou would have to use an FdoPtr method to get a pointer to the object that FdoPtrwraps and pass that pointer to FDO_SAFE_RELEASE

You can use FdoPtr for your own classes by inheriting from the abstract classFdoIDisposable and providing an implementation for the Dispose() method(typically delete this)

FdoPtr Typedefs

Typedefs are provided that define identifiers representing Fdo classes wrappedbyFdoPtr An example is typedef FdoPtrltFdoClassgt FdoClassP

22 | Chapter 4 Development Practices

CollectionsYou can use FDO collection template classes to store your own objects Therequirements for your collection class and the class used to instantiate thetemplate are the same as those for wrapping a class in a FdoPtr

Exception HandlingIn the FDO API FdoCommandException class is the exception type thrownfrom classes in the Commands package and FdoConnectionException classis the exception type thrown from classes in the Connections package Bothof these exception types derive from a language-level exception class that isenvironment-specific

All exceptions are derived from the FdoException class To catch and processspecific exception types nest catch statements as in the following example

try

code

catch (FdoCommandException ex)

process message

catch (FdoException ex)

process message

In some cases underneath an FDO command the FDO level throws anFdoException The FDO command then traps the FdoException and wraps itin an FdoCommandException (or FdoSchemaException for a schemacommand) In this case several messages are returned by one exception Thefollowing example shows how to process multiple messages from oneexception

catch ( FdoSchemaException ex )

Loop through all the schema messages

FdoException currE = ex

while ( currE )

CW2A msg(currE-gtGetExceptionMessage())

acutPrintf (FdoConnectionException sn msg)

currE = currE-gtGetCause()

Collections | 23

An application function may need to catch and then re-throw exceptions inorder to clean up memory However the need to do this can be eliminatedby using FdoPtr The following example cleans up memory on error

FdoFeatureClass pBase = NULL

try

pBase = myClass-gtGetBaseClass()

catch ()

FDO_SAFE_RELEASE(pBase)

throw

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

The catch and rethrow is unnecessary when FdoPtr is used

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

Exception MessagesException messages are localized On Windows the localized strings are inresource-only DLLs and on Linux they are in catalogs The message DLLs arein the bin folder the DLL name contains Message or Msg The catalog filesare in the usrlocalfdo-320nls directory the names of these files ends in catNLS stands for National Language Support

On Linux set the NLSPATH environment variable so that the runtime codecan locate the message catalogs For example exportNLSPATH=usrlocalfdo-320nlsN

On Windows you do not have do anything special to enable the runtime codeto locate the message DLLs

The contents of the exception message files are indexed When you call oneof the FdoExceptionNLSGetMessage methods declared in Exceptionh youprovide a message number argument You may also provide a default messagestring argument In the event that the exception message resource file cannotbe found the default message is subsituted instead If the default messagestring is not provided and the resource file cannot be found the messagenumber is used as the exception message Not finding the resource file canonly happend on Linux and only if the NLSPATH envrionment variable is notset

24 | Chapter 4 Development Practices

The following two examples when called on Linux with the NLSPATHenvironment variable not set show the use of the default message and themessage number in the exception message

The following is an example of using the default string throwFdoSchemaExceptionCreate(NlsMsgGet1(FDORDBMS_333 Class 1$lsnot

found value-gtGetText()))

The following is an example of not setting the default string and using themessage number instead FdoSchemaException pNewException =

FdoSchemaExceptionCreate(

FdoSmErrorNLSGetMessage(FDO_NLSID(FDOSM_221)

pFeatSchema-gtGetName()) pException)

Managing FdoPtr BehaviorsThe topics in this section describe several ways that you can manager FdoPtrbehavior For more information about managing FdoPtr behavior see therelated topics ldquoFdoPtr ltTgt Class Template Referencerdquo and ldquoFdoIDisposableClass Referencerdquo in the FDO Reference Help and The Essential FDO

Chain Calls

Do not chain calls If you do returned pointers will not be released Forexample given an FdoClassDefinition pclassDef

psz = pclassDef -gtGetProperties()-gtGetItem(0)-gtGetName())

The above code would result in two memory leaks Instead use

FdoPropertyDefinitionCollection pprops = pclassDef -gt GetProper

ties()

FdoPropertyDefinition ppropDef = pprops-gtGetItem(0)

psz = propDef-gtGetName()

ppropDef-gtRelease()

pprops-gtRelease()

or (with FdoPtr)

FdoPtrltFdoPropertyDefinitionCollectiongt pprops = pclassDef-gt Get

Properties()

FdoPtrltFdoPropertyDefinitiongt ppropDef = pprops-gt GetItem(0)

psz = propDef-gtGetName()

or (also with FdoPtr)

Managing FdoPtr Behaviors | 25

psz = FdoPtr ltFdoPropertyDefinitiongt (FdoPtr ltFdoPropertyDefini

tionCollectiongt(pclassDef-gtGetProperties())-gt GetItem(0))-gtGet

Name()

Assigning Return Pointer of an FDO Function Call to a Non-SmartPointer

If you are assigning the return pointer of an FDO function call to a non-smartpointer then you should assign that pointer to a FdoPtr For example

FdoLineString P = gfCreateLineString()

FdoPtr ltFdoLineStringgt p2 = FDO_SAFE_ADDREF(p)

26 | Chapter 4 Development Practices

Establishing aConnection

This chapter explains how to establish a connection to an FDO provider and provides aconnection example

Connection SemanticsData Sources and Data Stores

The FDO API uses connection semantics to implement access to feature schemadata The term data store is used to refer to a collection of zero or more objectswhich instantiate class definitions belonging to one or more FDO feature schemaThe connection is to a data store because that is where data objects are storedThe underlying data source technologies used to hold data stores can berelational databases such as a MySQL database or a file-based solution suchas an SDF file

The mapping of a data store to data source technology can be one-to-one ormany-to-one For example it is

One-to-one when the connection is made by way of the OSGeo FDO Providerfor ArcSDE and the ArcSDE server is using an Oracle database

Many-to-one when the data source is a MySQL database and the connectionis made by way of the OSGeo FDO Provider for MySQL (in this case the datastore is like a container within a container)

When many-to-one mapping is possible a connection can be made in one ortwo steps For more information see Establishing a Connection on page 29 andThe Essential FDO

5

27

The underlying data source technologies differ in the connection parametersused for connecting to a particular provider The values for these parametersare generated during the installation and configuration of the containertechnologies For more information about these values and the process ofinstalling and configuring the associated data source technologies see theappropriate appendix in this document and The Essential FDO

Providers

You connect to a data store by way of a provider

The FDO API contains a registry interface that you can use to register orderegister a provider See the class FdoProviderRegistry inIncFdoClientServicesProviderRegistryh

The providers are registered during the initialization of the FDO SDK In orderto connect to a provider you will need the name of the provider in a particularformat ltCompanyFoundationOriginatorgtltProvidergtltVersiongt TheltCompanyFoundationOriginatorgt and ltProvidergt values are invariable Forspecific values see The Essential FDO

In order to connect you will need the full name including the ltVersiongtvalue You can retrieve the full name from the registry and display the set ofprovider names in a connection menu list If for whatever reason youderegister a provider save the registry information for that provider in caseyou want to reregister it again The provider object returned by the registryhas a Set() method to allow you to change values However the only valueyou can safely change is the display name Sample code for using the providerregistry is located in Establishing a Connection on page 29

The registry contains the following information about a provider

Name The unique name of the feature provider This name should be ofthe form ltCompanyFoundationOriginatorgtltProvidergtltVersiongt forexample AutodeskOracle30 or OSGeoMySQL30

DisplayName A user-friendly display name of the feature provider Theinitial values of this property for the pre-registered providers are ldquoAutodeskFDO Provider for Oraclerdquo ldquoOSGeo FDO Provider for SDFrdquo etc or theequivalent in the language of the country where the application is beingused

Description A brief description of the feature provider For example thethe OsGeo FDO Provider for SDF description is ldquoReadwrite access toAutodesks spatial database format a file-based personal geodatabase thatsupports multiple featuresattributes spatial indexing and file-lockingrdquo

28 | Chapter 5 Establishing a Connection

Version The version of the feature provider The version number stringhas the form ltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgtfor example 3000

FDOVersion The version of the feature data objects specification to whichthe feature provider conforms The version number string has the formltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgt for example3010

libraryPath The FULL library path including the library name of theprovider for example ltFDO SDK Install LocationgtbinFdoRdbmsdll

isManaged A flag indicating whether the provider is a managed orunmanaged NET provider

Establishing a ConnectionAs mentioned in a previous section Connection Semantics on page 27 theFDO API uses a provider to connect to a data store and its underlying datasource technology These data source technologies must be installed andconfigured Certain values generated during data source installation andconfiguration are used as arguments during the connection process Becausethe FDO API does not provide any methods to automate the collection andpresentation of these configuration values either the application developermust request the user to input these configuration values during theconnection process or the application developer can provide an applicationconfiguration interface which would populate the application with thecontainer configuration values and thus allow the user to choose them fromlists

NOTE For more information about connecting see The Essential FDO

A connection can be made in either one or two steps

One-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method once the returned stateis FdoConnectionState_Open no additional information is needed

Two-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method the returned state isFdoConnectionState_Pending additional information is needed to completethe connection In this case the first call to Open() has resulted in theretrieval of a list of values for a property that becomes a required property

Establishing a Connection | 29

for the second call to the Open() method After the user has selected oneof the values in the list the second call to Open() should result inFdoConnectionState_Open

Connecting to a data store by way of the MySQL or the ArcSDE provider forexample can be done in either one or two steps In the first step the datastore parameter is not required If the user does not give the data storeparameter a value the FDO will retrieve the list of data store values from thedata source so that the user can choose from them during the second stepOtherwise the user can give the data store a value in the first step andassuming that the value is valid the connection will be completed in onestep

For the purpose of this example letrsquos assume that the user has installed MySQLon his local machine During the installation he was prompted to assign apassword to the system administrator account whose name is lsquorootrsquo He setthe password to lsquotestrsquo

The following steps are preliminary to establishing a connection

1 Get the list of providers

FdoPtrltFdoProviderRegistrygt registry = (FdoProviderRegistry

)FdoFeatureAccessManagerGetProviderRegistry()

FdoProviderCollection providers = registry-gtGetProviders()

2 Get the display names for all of the providers in the registry An exampleof a display name might be OSGeo FDO Provider for MySQL

FdoStringP displayName

FdoStringP internalName

FdoPtrltFdoProvidergt provider

int count = providers-gtGetCount()

for(int i = 0 i lt count i++)

provider = providers-gtGetItem(i)

internalName = provider-gtGetName()

displayName = provider-gtGetDisplayName()

add displayName to your list

3 Use the display names to create a menu list from which the user willselect from when making a connection

After the user initiates a provider display name from the connection menudo the following

30 | Chapter 5 Establishing a Connection

1 Loop through the providers in the registry until you match the displayname selected by the user from the connection menu with a providerdisplay name in the registry and retrieve the internal name for thatprovider An example of an internal could be OSGeoMySQL32

FdoStringP internalName = provider-gtGetName()

2 Get an instance of the connection manager

FdoPtrltFdoConnectionManagergt connectMgr = (FdoConnectionManager

)FdoFeatureAccessManagerGetConnectionManager()

3 Call the managerrsquos CreateConnection() method using the provider internalname as an argument to obtain a connection object

FdoPtrltFdoIConnectiongt fdoConnection = connectMgr-gtCreateConnec

tion(LrdquoOsGeoMySQL32rdquo)

4 Obtain a connection info object by calling the connection objectrsquosGetConnectionInfo() method

FdoPtrltFdoIConnectionInfogt info = fdoConnection-gtGetConnection

Info()

5 Obtain a connection property dictionary object by calling the connectioninfo objectrsquos GetConnection Properties() method and use this dictionaryto construct a dialog box requesting connection information from theuser

FdoPtrltFdoIConnectionPropertyDictionarygt ConnDict = info-gtGetCon

nectionProperties()

6 Get a list of connection property names from the dictionary and use thislist to get information about the property The following code loopsthrough the dictionary getting all of the possible information

NOTE An attempt to get the values of an enumerable property is made onlyif the property is required

FdoInt32 count = 0

FdoString names = NULL

FdoStringP name

FdoStringP localname

FdoStringP val

FdoStringP defaultVal

bool isRequired = false

bool isProtected = false

bool isFilename = false

bool isFilepath = false

Establishing a Connection | 31

bool isDatastorename = false

bool isEnumerable = false

FdoInt32 enumCount = 0

FdoString enumNames = NULL

FdoStringP enumName

names = ConnDict-gtGetPropertyNames(count)

for(int i = 0 i lt count i++)

name = names[i]

val = dict-gtGetProperty(name)

defaultVal = dict-gtGetPropertyDefault(name)

localname = dict-gtGetLocalizedName(name)

isRequired = dict-gtIsPropertyRequired(name)

isProtected = dict-gtIsPropertyProtected(name)

isFilename = dict-gtIsPropertyFileName(name)

isFilepath = dict-gtIsPropertyFilePath(name)

isDatastorename = dict-gtIsPropertyDatastoreName(name)

isEnumerable = dict-gtIsPropertyEnumerable(name)

if (isEnumerable)

if (isRequired)

enumNames = dict-gtEnumeratePropertyValues(name enumCount)

for(int j = 0 j lt enumCount j++)

enumName = enumNames[j]

7 Use the GetLocalizedName method to obtain the name of the propertyto present to the user Calls to dictionary methods need the value of theinternal name in the string array returned by GetPropertyNames() Sowhen the user selects the localized name in the menu the program mustmap the localized name to the internal name

8 Use the IsPropertyRequired method to determine whether to mark theline as either required or optional the dialog box handler should notpermit the user to click OK in the dialog box unless a required field hasa value

9 Use the IsPropertyProtected method to determine whether the dialogbox handler should process the field value as protected data for examplea password

10 Use the IsPropertyEnumerable and IsRequired methods to determinewhether to call the EnumeratePropertyValues method to get a list of validvalues

32 | Chapter 5 Establishing a Connection

NOTE Call the EnumeratePropertyValues method only if both methods returntrue Otherwise be prepared to catch an exception if there is no pendingconnection The assumption is that a connection exists and the program isretrieving values from the data store

As shown in the code lines above the EnumeratePropertyValues method takesa property name and an updates integer argument and returns a string arrayThe updates integer will say how many values are in the returned array Presentthe list of choices to the user

If the property is not enumerable present the values returned by either theGetProperty or GetPropertyDefault methods to the user

Now that the user has seen the set of properties in the dictionary she canset the required properties A property is set by calling the dictionaryrsquosSetProperty method The MySQL connection property names are UsernamePassword Service and DataStore The dictionary tells us that UsernamePassword and Service are required properties and that DataStore is not requiredLetrsquos connect to the MySQL as root

ConnDict-gtSetProperty(LrdquoUsernamerdquo Lrdquorootrdquo)

ConnDict-gtSetProperty(LrdquoPasswordrdquo Lrdquotestrdquo)

ConnDict-gtSetProperty(LrdquoServicerdquo Lrdquolocalhostrdquo)

NOTE fdoconnection-gtGetConnectionString() returnsUsername=rootPassword=testService=localhostfdoconnection-gtSetConnectionString(LrdquoUsername=rootPassword=testService=localhostrdquo)

would set the connection properties to the same values as the three calls aboveto the connection dictionaryrsquos SetProperty() method

Open the connection

FdoConnectionState state = fdoConnection-gtOpen()

The value of state is FdoConnectionState_Pending An examination of theconnection dictionary will reveal that the DataStore property is now required

When the user checks the command capabilities he discovers that he cancreate a data store

Establishing a Connection | 33

FdoPtrltFdoICommandCapabilitiesgt commandCapabilities = fdoConnec

tion-gtGetCommandCapabilities()

bool bSupportsCreateDatastore = false

FdoInt32 numCommands

FdoIn32 commands = commandCapabilities-gtGetCommands(numCommands)

for(int i = 0 i lt numCommands i++)

switch(commands[i])

case FdoCommandType_CreateDataStore bSupportsCreateDatastore

= true

He can use the pending connection to MySQL to create the datastore Use theconnection object to create the FdoICreateDataStore command object Usethe command object to create the FdoIDataStorePropertyDictionary objectand find out from this object what properties you must define Use thedictionary object to set the required properties and then execute the commandto create the lsquofdo_userrsquo data store The only required property is DataStore

NOTE The FdoIDataPropertyDictionary and the FdoIConnectionPropertyDictionaryclasses are both derived from FdoIPropertyDictionary The code used above toaccess the FdoIConnectionPropertyDictionary object works for theFdoIDataPropertyDictionary

FdoPtrltFdoICreateDataStoregt createDataStoreCmd = dynam

ic_castltFdoICreateDataStore gt (fdoConnection-gtCreateCommand(Fdo

CommandType_CreateDataStore))

FdoPtrltFdoIDataStorePropertyDictionarygt createDsDict = createData

StoreCmd-gtGetDataStoreProperties()

createDsDict-gtSetProperty(LrdquoDataStorerdquo Lrdquofdo_userrdquo)

createDataStoreCmd-gtExecute()

Now use the connection property dictionary to set the DataStore property tolsquofdo_userrsquo and call the Open() method on the connection object This methodshould return FdoConnectionState_Open

34 | Chapter 5 Establishing a Connection

FDO Capabilities

FDO Capabilities

Introduction

The FDO capabilities are statically defined They are accessed through aconnection object in the closed state The following code illustrates how to geta connection object in the closed state

If you are using C you will find the capability definitions in theOSGeoFDOConnectionsCapabilities namespace If you are using C++ youwill find the headers in the FdoConnectionsCapabilties directory

In C you access them using the OSGeoFDOConnectionsIConnection objectIn C++ you access them using the IConnection object whose header is in theFdoConnections directory

The information in the capabilities tables reflects the state of the FDO providercapabilities as of the commercial release of Map 3D 2009

For the most part FDO defines capabilities in three ways booleans enumerationsor integers representing enumerated values and collections One schemacapability is defined as a string and two other schema capabilities as integersFor example the Command capability SupportsParameters is a boolean andthe Command capability Commands is a set of integers whose meaning isdefined by the C CommandType enumeration and the C++ FdoCommandTypeenumeration Function capabilities are defined as collections of functionsignatures The C type isOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionThe C++ type is FdoReadOnlySignatureDefinitionCollection The latter is

6

35

defined in FdoConnectionsCapabilitiesSignatureDefinitionh Each booleanenumeration and signature value is shown in the tables

In general where a number of capabilities are supported by the same set ofproviders the capabilities are aggregated into one line in the table This ruleis modified in the function category tables in the Expression section

In some cases for example the CLIP raster function there is only one signatureAt the other end of the spectrum is the Concat string function which hasalmost 100 signatures The same set of providers supports an enormous numberof functions and so the rule for presenting aggregations of capabilities had tobe modfied for functions The rule for functions is to present all of thesignatures for one function on a line in the table A handful of functions hadso many signatures that their presentation had to be split over two lines

Provider Type

A provider can be one of four types Database Server File Web Server orUnknown The type information is available from the connection object inthe closed state The ldquoUnknownrdquo type indicates that the provider can connectto more than one type of data store technology The ODBC and OGR providerscan connect either to a file-based or RDBMS-based data store technologywhich is not known until the connection is in the open state

In C the ProviderDatastoreType enumeration is in theOSGeoFDOConnections namespace The ProviderDatastoreType property isaccessible through the OSGeoFDOConnectionsIConnection object(connectionConnectionInfoProviderDatastoreType)

In C++ the FdoProviderDatastoreType enumeration is defined in theltFdoConnectionsProviderDatastoreTypehgt header file TheFdoProviderDatastoreType value is accessible through the IConnection object(connection-gtGetConnectionInfo()-gtGetProviderDatastoreType())

TypeProvider

DatabaseServerOSGeoArcSDE33

DatabaseServerOSGeoKingOracle33

DatabaseServerOSGeoMySQL33

36 | Chapter 6 FDO Capabilities

TypeProvider

DatabaseServerOSGeoPostGIS33

DatabaseServerOSGeoSQLServerSpatial33

FileOSGeoGdal33

FileOSGeoSDF33

FileOSGeoSHP33

WebServerOSGeoWFS33

WebServerOSGeoWMS33

UnknownOSGeoODBC33

UnknownOSGeoOGR33

NOTE A provider name with OSGeo at the beginning indicates that the provideris available as open source from httpfdoosgeoorg

Command

In C you access theOSGeoFDOConnectionsCapabilitiesICommandCapabilities using theIConnection object (connectionCommandCapabilities)

In C++ you access the FdoICommandCapabilities using the IConnection object(connection-gtGetCommandCapabilities())

DescriptionCommand

Locks feature instances of a given class that match thespecified criteria

AcquireLock

Command | 37

DescriptionCommand

Activates a long transaction so that features can be ver-sioned

ActivateLongTransaction

Activates a specified spatial contextActivateSpatialContext

Creates or updates a feature schema within the datastore Optionally a provider-specificmapping of featureschema elements to physical storage can be specified

ApplySchema

Commits all of the data within a leaf long transaction(one that does not have descendent long transactions)

CommitLongTransaction

to the parent long transaction and removes the longtransaction Requires access commit and remove priv-ileges to the long transaction and the access privilegeto the parent long transaction

Creates anew provider specific datastoreCreateDataStore

Creates a long transaction as a child of the currentlyactive long transaction

CreateLongTransaction

Creates a new spatial context Input to the commandincludes the name description coordinate system ex-tent type and extent for the new context

CreateSpatialContext

Deactivates the active long transaction and automaticallyactivates the root long transaction If the root long

DeactivateLongTransaction

transaction is the active one the deactivation has noeffect

Deletes the instances of a given class that match thespecified criteria The instances can be at global scopeor contained within an object collection

Delete

Describe a single schema or all schemas available fromtheconnection

DescribeSchema

38 | Chapter 6 FDO Capabilities

DescriptionCommand

Describes the logical to physical schema mappings forone or all feature schemas available from the connection

DescribeSchemaMapping

Remove a data storeDestroyDataStore

Destroys a schema definition including all class defini-tions relationship definitions and instance data within

DestroySchema

it If elements in other schemas referto the schema tobe destroyed execution will fail

Destroys an existing spatial context which destroys alldata stored in that context

DestroySpatialContext

Gets a list of all objects that are currently locked by aparticular user

GetLockedObjects

Gets lock information for the feature instances of a givenclass that match the specified filter

GetLockInfo

Gets a list of all lock ownersGetLockOwners

Gets one specific long transaction or all available longtransactions

GetLongTransactions

Enumerates the existing measurement unitsGetMeasureUnits

Gets all spatial contexts or just the active oneGetSpatialContexts

inserts a new instance of a given class The instance canbe at global scope or contained within an object collec-tion

Insert

Gets a list of datastores at a particular serverListDataStores

Create a spatial index for the specified spatial contextOracleCreateSpatialIndex

Command | 39

DescriptionCommand

Drop the specified spatial indexOracleDestroySpatialIndex

Enumerate the existing spatial indexesOracleGetSpatialIndexes

Releases locks from feature instances of a given class thatmatch the specified criteria

ReleaseLock

Removes all of the data within a long transaction andremoves the long transaction as well Requires access

RollbackLongTransaction

commit and remove privileges to the long transactionand the access privilege to the parent long transaction

creates a new SDF+ file with a specified location and filename and a given spatial coordinate system This com-

SDFCreateSDFFile

mand has been superceded by the CreateDataStorecommand

Supports the selection and ordering of feature instancesof a given class according to the specified criteria Theresults of the select are written to an SDF file

SDFExtended_Select

Queries for features of a given class that match the spe-cified criteria

Select

Queries for features of a given class that match the spe-cified criteria The criteria can specify that feature values

SelectAggregates

from multiple instances be aggregated be distinct orbe grouped

Supports the execution of a SQL statement against anunderlying RDBMS Two execute methods are provided

SQLCommand

to distinguish between statements that return table dataversus those that execute non query type operations

Modifies instances of a given class that match the spe-cified criteria The instance can be at global scope orcontained within an object collection

Update

40 | Chapter 6 FDO Capabilities

DescriptionCommand

Gets the image formats supported by the connectionWMSGetImageFormats

Gets the layer styles available for the specified featureclass

WMSGetFeatureClassStyles

Gets the CRS names available for the specified featureclass

WMSFeatureClassCRS-Names

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports the use of distinct in SelectAggreg-ates commands

SupportsSelectDistinct

Indicates whether or not a provider sup-ports the use of expressions for propertiesin Select and SelectAggregate commands

SupportsSelectExpressions

Indicates whether or not a provider sup-ports the use of functions in Select and

SupportsSelectFunctions

SelectAggregates command Only aggreg-ate functions can be used in the SelectAg-gregates command

Indicates whether or not a provider sup-ports the use of grouping criteria in theSelectAggregates command

SupportsSelectGrouping

Indicates whether or not a provider sup-ports ordering in the Select and SelectAg-gregates command

SupportsSelectOrdering

Command | 41

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports parameter substitution

SupportsParameters

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++Select DescribeSchema GetSpatialContexts

++++++++-+++SelectAggregates

+++-++-+++++SupportsSelectFunctions

++--++-+++++SupportsSelectDistinct Insert Update Delete

++-+++-++++-SupportsSelectExpressions

----++-+-+++CreateSpatialContext

-++-+-++-+--DescribeSchemaMapping

-+-----+++++SQLCommand

----++-++++-ApplySchema

-----+-++++-CreateDataStore

-+-----++++-SupportsSelectOrdering

-------+++-+ListDataStores

-+-----+-++-SupportsSelectGrouping

-----+-+++--DestroyDataStore

42 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

----+--+-+--DestroySchema

--------+-++SupportsParameters

-------+-+-+DestroySpatialContext

----++------SDFCreateSDFFile

-------+---+ActivateSpatialContext

-------+----OracleGetSpatialIndexes OracleCreateSpatialIndex Or-acleDestroySpatialIndex

-----+------SDFExtended_Select

--+---------WMSFeatureClassCRSNames WMSGetImageFormatsWMSGetFeatureClassStyles

-----------+AcquireLock CreateLongTransaction DeactivateLongTrans-action RollbackLongTransaction CommitLongTransactionGetLockOwners ReleaseLock GetLongTransactions Get-LockedObjects ActivateLongTransaction GetLockInfo

Connection

In C you access theOSGeoFDOConnectionsCapabilitiesIConnectionCapabilities using theIConnection object (connectionConnectionCapabilities)

Connection | 43

In C++ you access the FdoIConnectionCapabilities using the IConnectionobject (connection-gtGetConnectionCapabilities())

DescriptionCapability

Indicates that only this user can modify this object in thislong transaction No user not even the user locking the

LockType_AllLongTransactionExclusive

object can modify the object in any long transaction createdas a descendent of the one containing the object beinglocked When not in a long transaction situation (for ex-ample if only a root long transaction exists) the lock be-haves like an Exclusive lock

Indicates that only this user can modify this object In a longtransaction situation any user can modify the object in any

LockType_Exclusive

other long transaction including the root long transactionif it is not the current long transaction

Indicates that only this user can modify this object in thelong transaction containing the object or any long transac-

LockType_LongTransactionExclusive

tion created as a descendent of that one When not in along transaction situation (for example if only a root longtransaction exists) the lock behaves like an Exclusive lock

Indicates a shared lock typeLockType_Shared

Indicates that a transaction lock should be applied to anobject

LockType_Transaction

Indicates whether or not a provider can specify on a closedconnection an XML source to be used to configure the datastore

SupportsConfiguration

Indicates that the spatial extent of the context is dynamicand changes as data is added and removed from the con-text

SpatialContextExtentType_Dynamic

Indicates that the spatial extent of the context is static andmust be specified when the context is created

SpatialContextExtentType_Static

44 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the specifica-tion of a coordinate system during the creation of a spatial

SupportsCSysWKTFromCSysName

context using only the coordinate system name The pro-vider maps the name to the WKT internally

Indicates whether or not a provider supports the forcedwrite of cached data associated with a connection to thetarget data store

SupportsFlush

Indicates whether or not a provider supports the set oflocking commands acquire get locked objects get lockowners get lock info and release

SupportsLocking

Indicates whether or not a provider supports the set of longtransaction commands activate commit create deactivateand get

SupportsLongTransactions

Indicates that the data store can contain multiple spatialcontexts but the provider does not necessarily support thecreate spatial context command

SupportsMultipleSpatialContexts

Indicates whether or not a provider supports the SQL com-mand

SupportsSQL

Indicates whether or not a provider supports the creationof a transaction associated with a connection to a data store

SupportsTransactions

Indicates that the provider supports a single thread perconnection Multiple concurrent threads cannot access the

ThreadCapability_PerConnectionThreaded

same connection object and only one command can beexecuting per connection Multiple connections can beactive concurrently as long as each is executing on its ownthread

Indicates that the provider supports a single thread percommand Multiple concurrent threads cannot access the

ThreadCapability_PerCommandThreaded

same command object however multiple commands canbe executing concurrently against a single connection

Connection | 45

DescriptionCapability

Indicates that the provider is not thread safeThreadCapability_SingleThreaded

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-++++-++++++SpatialContextExtentType_Static

++++++-+++-+ThreadCapability_PerConnectionThreaded

--+++-++++++SupportsMultipleSpatialContexts

-+-----+++++SupportsSQL

-++-+-+---+-SupportsConfiguration

-------++--+SupportsTransactions

----------++LockType_Exclusive

+----+------SpatialContextExtentType_Dynamic

----++------SupportsFlush

--------+-+-LockType_Transaction

----------+-LockType_AllLongTransactionExclusive LockType_LongTrans-actionExclusive ThreadCapability_PerCommandThreadedLockType_Shared

-----------+SupportsLocking SupportsCSysWKTFromCSysName Sup-portsLongTransactions

------+-----ThreadCapability_SingleThreaded

46 | Chapter 6 FDO Capabilities

Expression

In C you access theOSGeoFDOConnectionsCapabilitiesIExpressionCapabilities and theOSGeoFDOConnectionsCapabilitiesFunctionDefinitionCollectionusingthe IConnection object connectionExpressionCapabilities andconnectionExpressionCapabilitiesFunctions respectively EachOSGeoFDOConnectionsCapabilitiesFunctionDefinition in the collectionhas has aOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionwhich is accessed by functionDefSignatures

In C++ you access the FdoIExpressionCapabilities and theFdoFunctionDefinitionCollection using the IConnection objectconnection-gtGetExpressionCapabilities()expression_capabilities-gtGetFunctions() respectively EachFdoFunctionDefinition in the collection has anFdoReadOnlySignatureDefinitionCollection which is accessed byfunctionDef-gtGetSignatures()

The functions can be broadly divided into two groups according to the modeof their implementation The largest group contains the functions whoseunderlying implementation is based on the Expression Builder The first releaseof the Expression Builder component is in FDO 33 The remaining functionsare those whose implementation was not touched by the introduction of theExpression Builder component

The functions whose implementation is based on the Expression Builder arefurther categorized for UI purposes into 7 groups aggregate conversion dategeometry math numeric and string These UI categories are used in thisdocument to group the presentation of the functions

General Capabilities

DescriptionCapability

Indicates whether or not the provider supports basicarithmetic expressions for example + - negate andstring concatenation

ExpressionType_Basic

Indicates whether or not the provider supports functionevaluations

ExpressionType_Function

Expression | 47

DescriptionCapability

Indicates whether or not the provider supports parametersubstitution An expression can be constructed using

ExpressionType_Parameter

named parameters and values bound to the parameter ata later time This allows the constructed expression to bereused

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ExpressionType_Function

++-+++-+++++ExpressionType_Basic

-------+-+--ExpressionType_Parameter

Argument and Return Types

Tthe following tables specify the function name arguments and the type ofthe return value An argument is optional if it is enclosed in square bracketsAn argument may be a literal such as ldquoALLrdquo or ldquoDISTINCTrdquo or a featureproperty name Where the argument value is a feature property name thetype of the feature property is specified The set of valid alternatives for anargument value is indicated by enclosing the set of ORrsquod property types orliteral values in parentheses For brevityrsquos sake a lsquonumericrsquo property typeindicates the set of numeric property types namely Byte | Decimal | Double| Int16 | Int32 | Int 64 | Single The other property types BLOB BooleanCLOB DateTime Geometry and String are indicated directly in the argumentspecification

Some functions have more than one return type The general rule is that thereturn type matches the argument type

48 | Chapter 6 FDO Capabilities

Aggregate Expression Functions

These functions can be used with the SelectAggregates command

DescriptionFunctionName

Returnsa double which is the average of the values identified by theprovided expression Avg ([ALL | DISTINCT ] numeric)

Avg

Returns an Int64 which is the number of rows returned by a queryidentified by the provided expression Count ([ALL | DISTINCT ]bool | DateTime | numeric | string | blob | clob | geometry)

Count

Returns a DateTime numeric or string in agreement with the typeof the argument which is the maximum value of the provided expres-sion Max ([ALL | DISTINCT ] DateTime | numeric | string)

Max

Represents an inverse distribution function that assumes a continuousdistribution model It takes a numeric or date-time value and returns

Median

a Double which is the middle value or an interpolated value thatwould be the middle value once the values are sorted Median (nu-meric)

Returns a DateTime numeric or string in agreement with the typeof the argument which is the minimum value of the provided expres-sion Min ([ALL | DISTINCT ] DateTime | numeric | string)

Min

Returns a Double which is the sample standard deviation of theprovided expression Stddev ([ALL | DISTINCT ] numeric)

Stddev

Returns a Double which is the sum of the values identified by theprovided expression Sum ([ALL | DISTINCT ] numeric)

Sum

Returns a byte array which yields the spatial extent of a set of geo-metries The argument is the name of geometry property SpatialEx-

Spatial Extent

tent (ltgeometriesgt) For example given these geometries POINT(11) LINESTRING(01 21) and POLYGON((01 21 12 01)) it returnsPOLYGON((01 21 22 02 01))

Expression | 49

NOTE The median is selected or calculated by doing the following

1 Sort the sample in ascending order

2 Calculate the Row of Interest (roi) using the forumula roi = (1 +((ltsample_sizegt - 1) 2))

3 Compare three values roi Ceil(roi) and Floor(roi) If they are equal themedian is the value in the Row Of Interest If they are not equal themedian is calculated by averaging the values in the rows preceding andsucceeding the Row of Interest

NOTE The value returned by the StdDev function is known as the sample standarddeviation and represents an estimate of the standard deviation of a populationbased on a random sample of that population See the Wikipedia entry for furtherdiscussion and a definition of the formula for sample standard deviationhttpenwikipediaorgwikiStandard_deviation

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++-+++++Double Avg(Double)

++--++-+++++Int64 Count(Int64)

++--++-+++++Double Max(Double)

++--++-+++++Double Min(Double)

++--++-+++++Double Sum(Double)

-+-+++-+-+++BLOB SpatialExtents(BLOB)

-+--++-+-+-+Double Avg(Byte) Double Avg(Decimal) Double Avg(Int16)Double Avg(Int32) Double Avg(Int64) Double Avg(Single)Double Avg(StringByte) Double Avg(StringDecimal) DoubleAvg(StringDouble) Double Avg(StringInt16) Double

50 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Avg(StringInt32) Double Avg(StringInt64) DoubleAvg(StringSingle)

-+--++-+-+-+Int64 Count(BLOB) Int64 Count(Boolean) Int64 Count(Byte)Int64 Count(CLOB) Int64 Count(DateTime) Int64Count(Decimal) Int64 Count(Double) Int64 Count(Int16) Int64Count(Int32) Int64 Count(Single) Int64 Count(String) Int64Count(StringBoolean) Int64 Count(StringByte) Int64Count(StringDateTime) Int64 Count(StringDecimal) Int64Count(StringDouble) Int64 Count(StringInt16) Int64Count(StringInt32) Int64 Count(StringInt64) Int64Count(StringSingle) Int64 Count(StringString)

-+--++-+-+-+Byte Max(Byte) Byte Max(StringByte) DateTime Max(Date-Time) DateTime Max(StringDateTime) Decimal Max(Decimal)Decimal Max(StringDecimal) Double Max(StringDouble) Int16Max(Int16) Int16 Max(StringInt16) Int32 Max(Int32) Int32Max(StringInt32) Int64 Max(Int64) Int64 Max(StringInt64)Single Max(Single) Single Max(StringSingle) StringMax(String) String Max(StringString)

-+--++-+-+-+Double Median(Byte) Double Median(Decimal) Double Medi-an(Double) Double Median(Int16) Double Median(Int32)Double Median(Int64) Double Median(Single)

-+--++-+-+-+Byte Min(Byte) Byte Min(StringByte) DateTime Min(DateTime)DateTime Min(StringDateTime) Decimal Min(Decimal)Decimal Min(StringDecimal) Double Min(StringDouble) Int16Min(Int16) Int16 Min(StringInt16) Int32 Min(Int32) Int32Min(StringInt32) Int64 Min(Int64) Int64 Min(StringInt64)Single Min(Single) Single Min(StringSingle) String Min(String)String Min(StringString)

-+--++-+-+-+Double Stddev(Byte) Double Stddev(Decimal) DoubleStddev(Double) Double Stddev(Int16) Double Stddev(Int32)Double Stddev(Int64) Double Stddev(Single) Double

Expression | 51

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Stddev(StringByte) Double Stddev(StringDecimal) DoubleStddev(StringDouble) Double Stddev(StringInt16) DoubleStddev(StringInt32) Double Stddev(StringInt64) DoubleStddev(StringSingle)

-+--++-+-+-+Double Sum(Byte) Double Sum(Decimal) Double Sum(Int16)Double Sum(Int32) Double Sum(Int64) Double Sum(Single)Double Sum(StringByte) Double Sum(StringDecimal) DoubleSum(StringDouble) Double Sum(StringInt16) DoubleSum(StringInt32) Double Sum(StringInt64) DoubleSum(StringSingle)

Conversion Expression Functions

DescriptionFunction Name

Evaluates two expressions and returns the first one if it does notevaluate to NULL the second otherwise The signatures without

NullValue

function name are Boolean(BooleanBoolean) Byte(ByteByte)DateTime(DateTimeDateTime) Decimal(DecimalDecimal)Double(DecimalDouble) Decimal(DecimalInt16 | Int32)Double(DecimalInt64) Single(DecimalSingle)Double(DoubleDecimal | Double | Int16 | Int32 | Int64 | Single)Double(Int16Decimal | Double) Int16(Int16Int16)Int32(Int16Int32) Int64(Int16Int64) Single(Int16Single)Double(Int32Decimal | Double) Int32(Int32Int16 | Int32)Int64(Int32Int64) Double(Int32Single)Double(Int64Decimal |Double | Single) Int64(Int64Int16 | Int32 | Int64)Double(SingleDecimal | Double | Int32 | Int64) Single(SingleInt16| Single) String(StringDecimal | Double | Int16 | Int32 | Int64 |Single | String)

Converts a string with datetime information to a date ToDate(date_string [ format_string]) The default format_string is ldquoDDMON YYYY h24 mm ssrdquo

ToDate

52 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Converts a numeric or string expression to a double ToDouble(numeric | string)

ToDouble

Converts a numeric or string expression to a float ToFloat (numeric| string)

ToFloat

Converts a numeric or string expression to an int32 ToInt32 (nu-meric | string)

ToInt32

Converts a numeric or string expression to an int64 ToInt64 (nu-meric | string)

ToInt64

Converts a numeric or date expression to a string ToString(numer-ic) ToString (DateTime [ format_string]) The default format_stringis ldquoDD-MON-YYYY h24mmssrdquo

ToString

The ToDate function takes a string value representing date andor timeinformation and converts it to a date object The optional format specificationparameter defines the format used in the string to represent the date usingthe abbreviations described in the following table For example for a stringcontaining the date April 2 1998 the format specification should containMonth DD YYYY

The ToString function takes a date value and creates a representation of it ina string The optional format specification parameter allows the user to definethe structure of the string to be created using the abbreviations described inthe following table

DescriptionAbbrevi-ation

Indicates that a year is defined as a two digit number (example 07)YY

Indicates that a year is defined as a four digit number (example 2007)YYYY

Indicates that a month is defined by its name all in uppercase letters (example APRIL)MONTH

Indicates that a month is defined by its name all in lowercase letters (example april)month

Expression | 53

DescriptionAbbrevi-ation

Indicates that a month is defined by its name with the first letter being an uppercaseletter (example April)

Month

Indicates that a month is defined by its abbreviation all in uppercase letters (exampleAPR)

MON

Indicates that a month is defined by its abbreviation all in lowercase letters (exampleapr)

mon

Indicates that a month is defined by its number (example 04)MM

Indicates that a day is defined by its number (example 04)DD

Indicates that a hour is defined by its number in the range [0-24]hh24

Indicates that a hour is defined by its number in the range [1-12]hh12

Represents a default representation of an hour Defaults to hh24hh

Indicates a minute definitionmm

Indicates a second definitionss

Indicates a millisecond definitionms

The meridiem Only considered if used with the time range [1-12] (format hh12)am | pm

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Boolean NullValue(BooleanBoolean) Byte NullValue(ByteByte)DateTime NullValue(DateTimeDateTime) Decimal Null-Value(DecimalDecimal) Decimal NullValue(DecimalInt16)

54 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Decimal NullValue(DecimalInt32) Double NullValue(Decim-alDouble) Double NullValue(DecimalInt64) Double Null-Value(DoubleDecimal) Double NullValue(DoubleDouble)Double NullValue(DoubleInt16) Double NullValue(DoubleInt32)Double NullValue(DoubleInt64) Double Null-Value(DoubleSingle) Double NullValue(Int16Decimal) DoubleNullValue(Int16Double) Double NullValue(Int32Decimal)Double NullValue(Int32Double) Double NullValue(Int32Single)Double NullValue(Int64Decimal) Double Null-Value(Int64Double) Double NullValue(Int64Single) DoubleNullValue(SingleDecimal) Double NullValue(SingleDouble)Double NullValue(SingleInt32) Double NullValue(SingleInt64)Int16 NullValue(Int16Int16) Int32 NullValue(Int16Int32) Int32NullValue(Int32Int16) Int32 NullValue(Int32Int32) Int64 Null-Value(Int16Int64) Int64 NullValue(Int32Int64) Int64 Null-Value(Int64Int16) Int64 NullValue(Int64Int32) Int64 Null-Value(Int64Int64) Single NullValue(DecimalSingle) SingleNullValue(Int16Single) Single NullValue(SingleInt16) SingleNullValue(SingleSingle) String NullValue(StringDecimal) StringNullValue(StringDouble) String NullValue(StringInt16) StringNullValue(StringInt32) String NullValue(StringInt64) StringNullValue(StringSingle) String NullValue(StringString)

-+--++-+-+-+DateTime ToDate(String) DateTime ToDate(StringString)

-+--++-+-+-+Double ToDouble(Byte) Double ToDouble(Decimal) DoubleToDouble(Double) Double ToDouble(Int16) Double To-Double(Int32) Double ToDouble(Int64) Double To-Double(Single) Double ToDouble(String)

-+--++-+-+-+Single ToFloat(Byte) Single ToFloat(Decimal) Single To-Float(Double) Single ToFloat(Int16) Single ToFloat(Int32) SingleToFloat(Int64) Single ToFloat(Single) Single ToFloat(String)

Expression | 55

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Int32 ToInt32(Byte) Int32 ToInt32(Decimal) Int32ToInt32(Double) Int32 ToInt32(Int16) Int32 ToInt32(Int32)Int32 ToInt32(Int64) Int32 ToInt32(Single) Int32 ToInt32(String)

-+--++-+-+-+Int64 ToInt64(Byte) Int64 ToInt64(Decimal) Int64ToInt64(Double) Int64 ToInt64(Int16) Int64 ToInt64(Int32)Int64 ToInt64(Int64) Int64 ToInt64(Single) Int64 ToInt64(String)

-+--++-+-+-+String ToString(Byte) String ToString(DateTime) String To-String(DateTimeString) String ToString(Decimal) String To-String(Double) String ToString(Int16) String ToString(Int32)String ToString(Int64) String ToString(Single)

Date Expression Functions

DescriptionFunction Name

Adds a specified number of months to agiven date expression and returns a Date-Time AddMonths (date_time numeric)

AddMonths

Returns the current date CurrentDate ()CurrentDate

Extracts a specified portion of a date andreturns a DateTime Extract (YEAR|

Extract

MONTH | DAY | HOUR | MINUTE |SECOND date_time)

Calculates the number of months betweentwo provide date expressions and returns

MonthsBetween

56 | Chapter 6 FDO Capabilities

DescriptionFunction Name

a Double MonthsBetween (date_timedate_time)

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+DateTime AddMonths(DateTimeByte) DateTimeAddMonths(DateTimeDecimal) DateTime AddMonths(Date-TimeDouble) DateTime AddMonths(DateTimeInt16) DateTimeAddMonths(DateTimeInt32) DateTime AddMonths(Date-TimeInt64) DateTime AddMonths(DateTimeSingle)

-+--++-+-+-+DateTime CurrentDate()

-+--++-+-+-+DateTime Extract(StringDateTime)

-+--++-+-+-+Double MonthsBetween(DateTimeDateTime)

Geometry Expression Functions

DescriptionFunction Name

Returns a Double which is the area of ageometry Area2D (ltgeometrygt)

Area2D

Returns a Double which is the length of ageometry Length2D (ltgeometrygt)

Length2D

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Area2D(BLOB)

Expression | 57

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Length2D(BLOB)

Mathematical Expression Functions

DescriptionFunction Name

Returns the absolute value of a numeric expression Abs (numeric)The return type is the same as the argument type

Abs

Returns a Double which is the arc cosine of a numeric expressionAcos (numeric)

Acos

Returns a Double which is the arc sine of a numeric expressionAsin (numeric)

Asin

Returns a Double which is the arc tangent of a numeric expressionAtan (numeric)

Atan

Returns a Double which is the arc tangent based on two numericexpressions Atan2 (numeric numeric)

Atan2

Returns a Double which is the cosine of a numeric expression Cos(numeric)

Cos

Returns a Double which is e raised to the power of a numeric ex-pression Exp (numeric)

Exp

Returns a Double which is the natural logarithm of a numeric ex-pression Ln (numeric)

Ln

Returns a Double which is the logarithm of a numeric expressionusing the provided base Log (base_numeric numeric)

Log

58 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Returns the remainder of the division of two numeric expressionsMod (numeric divisior_numeric) The implementation alogirthm

Mod

is Mod (m n) = (sign(m) (abs(m) - (abs(n) Floor(mn)))))mod(154) returns 3 mod(150) returns 15 mod(1162) returns16 mod(11621) returns 11 mod(-154) returns -3 mod(-150)returns -15 The return signatures without the function name areByte(ByteByte | Int16 | Int32 | Int64) Double(ByteDecimal |Double) Single(ByteSingle) Double(Decimal | DoubleByte |Decimal | Double | Int16 | Int32 | Int64 | Single) Int16(Int16Byte| Int16 | Int32 | Int64) Double(Int16Decimal | Double)Single(Int16Single) Int32(Int32Byte) Double(Int32Decimal |Double) Int16(Int32Int16) Int32(Int32Int32 | Int64)Single(Int32Single) Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single) Double(SingleDecimal | Double)

Returns a Double which is the result of a numeric expression raisedto the power of another numeric expression Power (numericpower_numeric)

Power

Returns the remainder of the division of two numeric expressionsRemainder (numeric divisor_numeric) The implementation al-

Remainder

gorithm is Remainder (mn) = (sign(m) (abs(m) - (abs(n) Round(mn)))) remainder(156) returns 3 remainder(155) returns0 remainder(154) returns -1 remainder(1162) returns -04 re-mainder(11621) returns -1 remainder(-154) returns 1 The sig-natures without function name are Int16(ByteByte | Int16)Double(ByteDecimal | Double) Int32(ByteInt32)Int64(ByteInt64) Single(ByteSingle) Double(Decimal |DoubleByte | Decimal | Double | Int16 | Int32 | Int64 | Single)Int16(Int16Byte | Int16 | Int32 | Int32) Double(Int16Decimal |Double) Single(Int16Single) Int32(Int32Byte | Int32 | Int64)Double(Int32Decimal | Double) Int16(Int32Int16)Single(Int32Single)Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single))

Expression | 59

DescriptionFunction Name

Returns a Double which is the sine of a numeric expression Sin(numeric)

Sin

Returns a Double which is the square root of a numeric expressionSqrt (numeric)

Sqrt

Returns a Double which is the tangent of a numeric expressionTan (numeric)

Tan

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Byte Abs(Byte) Decimal Abs(Decimal) Double Abs(Double)Int16 Abs(Int16) Int32 Abs(Int32) Int64 Abs(Int64) SingleAbs(Single)

-+--++-+-+-+Double Acos(Byte) Double Acos(Decimal) Double Acos(Double)Double Acos(Int16) Double Acos(Int32) Double Acos(Int64)Double Acos(Single)

-+--++-+-+-+Double Asin(Byte) Double Asin(Decimal) Double Asin(Double)Double Asin(Int16) Double Asin(Int32) Double Asin(Int64)Double Asin(Single)

-+--++-+-+-+Double Atan(Byte) Double Atan(Decimal) Double Atan(Double)Double Atan(Int16) Double Atan(Int32) Double Atan(Int64)Double Atan(Single)

-+--++-+-+-+Double Atan2(ByteByte) Double Atan2(ByteDecimal) DoubleAtan2(ByteDouble) Double Atan2(ByteInt16) DoubleAtan2(ByteInt32) Double Atan2(ByteInt64) DoubleAtan2(ByteSingle) Double Atan2(DecimalByte) DoubleAtan2(DecimalDecimal) Double Atan2(DecimalDouble) DoubleAtan2(DecimalInt16) Double Atan2(DecimalInt32) DoubleAtan2(DecimalInt64) Double Atan2(DecimalSingle) Double

60 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Atan2(DoubleByte) Double Atan2(DoubleDecimal) DoubleAtan2(DoubleDouble) Double Atan2(DoubleInt16) DoubleAtan2(DoubleInt32) Double Atan2(DoubleInt64) DoubleAtan2(DoubleSingle) Double Atan2(Int16Byte) DoubleAtan2(Int16Decimal) Double Atan2(Int16Double) DoubleAtan2(Int16Int16) Double Atan2(Int16Int32) DoubleAtan2(Int16Int64) Double Atan2(Int16Single) DoubleAtan2(Int32Byte) Double Atan2(Int32Decimal) DoubleAtan2(Int32Double) Double Atan2(Int32Int16) DoubleAtan2(Int32Int32) Double Atan2(Int32Int64) DoubleAtan2(Int32Single) Double Atan2(Int64Byte) DoubleAtan2(Int64Decimal) Double Atan2(Int64Double) DoubleAtan2(Int64Int16) Double Atan2(Int64Int32) DoubleAtan2(Int64Int64) Double Atan2(Int64Single) DoubleAtan2(SingleByte) Double Atan2(SingleDecimal) DoubleAtan2(SingleDouble) Double Atan2(SingleInt16) DoubleAtan2(SingleInt32) Double Atan2(SingleInt64) DoubleAtan2(SingleSingle)

-+--++-+-+-+Double Cos(Byte) Double Cos(Decimal) Double Cos(Double)Double Cos(Int16) Double Cos(Int32) Double Cos(Int64)Double Cos(Single)

-+--++-+-+-+Double Exp(Byte) Double Exp(Decimal) Double Exp(Double)Double Exp(Int16) Double Exp(Int32) Double Exp(Int64)Double Exp(Single)

-+--++-+-+-+Double Ln(Byte) Double Ln(Decimal) Double Ln(Double)Double Ln(Int16) Double Ln(Int32) Double Ln(Int64) DoubleLn(Single)

-+--++-+-+-+Double Log(ByteByte) Double Log(ByteDecimal) DoubleLog(ByteDouble) Double Log(ByteInt16) DoubleLog(ByteInt32) Double Log(ByteInt64) DoubleLog(ByteSingle) Double Log(DecimalByte) DoubleLog(DecimalDecimal) Double Log(DecimalDouble) Double

Expression | 61

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Log(DecimalInt16) Double Log(DecimalInt32) DoubleLog(DecimalInt64) Double Log(DecimalSingle) DoubleLog(DoubleByte) Double Log(DoubleDecimal) DoubleLog(DoubleDouble) Double Log(DoubleInt16) DoubleLog(DoubleInt32) Double Log(DoubleInt64) DoubleLog(DoubleSingle) Double Log(Int16Byte) DoubleLog(Int16Decimal) Double Log(Int16Double) DoubleLog(Int16Int16) Double Log(Int16Int32) DoubleLog(Int16Int64) Double Log(Int16Single) DoubleLog(Int32Byte) Double Log(Int32Decimal) DoubleLog(Int32Double) Double Log(Int32Int16) DoubleLog(Int32Int32) Double Log(Int32Int64) DoubleLog(Int32Single) Double Log(Int64Byte) DoubleLog(Int64Decimal) Double Log(Int64Double) DoubleLog(Int64Int16) Double Log(Int64Int32) DoubleLog(Int64Int64) Double Log(Int64Single) DoubleLog(SingleByte) Double Log(SingleDecimal) DoubleLog(SingleDouble) Double Log(SingleInt16) DoubleLog(SingleInt32) Double Log(SingleInt64) DoubleLog(SingleSingle)

-+--++-+-+-+Byte Mod(ByteByte) Byte Mod(ByteInt16) ByteMod(ByteInt32) Byte Mod(ByteInt64) DoubleMod(ByteDecimal) Double Mod(ByteDouble) DoubleMod(DecimalByte) Double Mod(DecimalDecimal) DoubleMod(DecimalDouble) Double Mod(DecimalInt16) DoubleMod(DecimalInt32) Double Mod(DecimalInt64) DoubleMod(DecimalSingle) Double Mod(DoubleByte) DoubleMod(DoubleDecimal) Double Mod(DoubleDouble) DoubleMod(DoubleInt16) Double Mod(DoubleInt32) DoubleMod(DoubleInt64) Double Mod(DoubleSingle) DoubleMod(Int16Decimal) Double Mod(Int16Double) DoubleMod(Int32Decimal) Double Mod(Int32Double) DoubleMod(Int64Decimal) Double Mod(Int64Double) DoubleMod(SingleDecimal) Double Mod(SingleDouble) Int16Mod(Int16Byte) Int16 Mod(Int16Int16) Int16Mod(Int16Int32) Int16 Mod(Int16Int64) Int16

62 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Mod(Int32Int16) Int16 Mod(Int64Int16) Int32Mod(Int32Byte) Int32 Mod(Int32Int32) Int32Mod(Int32Int64) Int32 Mod(Int64Int32) Int64Mod(Int64Byte) Int64 Mod(Int64Int64) SingleMod(ByteSingle) Single Mod(Int16Single) SingleMod(Int32Single) Single Mod(Int64Single) SingleMod(SingleByte) Single Mod(SingleInt16) SingleMod(SingleInt32) Single Mod(SingleInt64) SingleMod(SingleSingle)

-+--++-+-+-+Double Power(ByteByte) Double Power(ByteDecimal) DoublePower(ByteDouble) Double Power(ByteInt16) DoublePower(ByteInt32) Double Power(ByteInt64) DoublePower(ByteSingle) Double Power(DecimalByte) DoublePower(DecimalDecimal) Double Power(DecimalDouble) DoublePower(DecimalInt16) Double Power(DecimalInt32) DoublePower(DecimalInt64) Double Power(DecimalSingle) DoublePower(DoubleByte) Double Power(DoubleDecimal) DoublePower(DoubleDouble) Double Power(DoubleInt16) DoublePower(DoubleInt32) Double Power(DoubleInt64) DoublePower(DoubleSingle) Double Power(Int16Byte) DoublePower(Int16Decimal) Double Power(Int16Double) DoublePower(Int16Int16) Double Power(Int16Int32) DoublePower(Int16Int64) Double Power(Int16Single) DoublePower(Int32Byte) Double Power(Int32Decimal) DoublePower(Int32Double) Double Power(Int32Int16) DoublePower(Int32Int32) Double Power(Int32Int64) DoublePower(Int32Single) Double Power(Int64Byte) DoublePower(Int64Decimal) Double Power(Int64Double) DoublePower(Int64Int16) Double Power(Int64Int32) DoublePower(Int64Int64) Double Power(Int64Single) DoublePower(SingleByte) Double Power(SingleDecimal) DoublePower(SingleDouble) Double Power(SingleInt16) DoublePower(SingleInt32) Double Power(SingleInt64) DoublePower(SingleSingle)

Expression | 63

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Remainder(ByteDecimal) Double Re-mainder(ByteDouble) Double Remainder(DecimalByte) DoubleRemainder(DecimalDecimal) Double Remainder(Decim-alDouble) Double Remainder(DecimalInt16) Double Re-mainder(DecimalInt32) Double Remainder(DecimalInt64)Double Remainder(DecimalSingle) Double Re-mainder(DoubleByte) Double Remainder(DoubleDecimal)Double Remainder(DoubleDouble) Double Re-mainder(DoubleInt16) Double Remainder(DoubleInt32)Double Remainder(DoubleInt64) Double Re-mainder(DoubleSingle) Double Remainder(Int16Decimal)Double Remainder(Int16Double) Double Re-mainder(Int32Decimal) Double Remainder(Int32Double)Double Remainder(Int64Decimal) Double Re-mainder(Int64Double) Double Remainder(SingleDecimal)Double Remainder(SingleDouble) Int16 Remainder(ByteByte)Int16 Remainder(ByteInt16) Int16 Remainder(Int16Byte) Int16Remainder(Int16Int16) Int16 Remainder(Int16Int32) Int16Remainder(Int16Int64) Int16 Remainder(Int32Int16) Int16Remainder(Int64Int16) Int32 Remainder(ByteInt32) Int32 Re-mainder(Int32Byte) Int32 Remainder(Int32Int32) Int32 Re-mainder(Int32Int64) Int32 Remainder(Int64Int32) Int64 Re-mainder(ByteInt64) Int64 Remainder(Int64Byte) Int64 Re-mainder(Int64Int64) Single Remainder(ByteSingle) Single Re-mainder(Int16Single) Single Remainder(Int32Single) SingleRemainder(Int64Single) Single Remainder(SingleByte) SingleRemainder(SingleInt16) Single Remainder(SingleInt32) SingleRemainder(SingleInt64) Single Remainder(SingleSingle)

-+--++-+-+-+Double Sin(Byte) Double Sin(Decimal) Double Sin(Double)Double Sin(Int16) Double Sin(Int32) Double Sin(Int64) DoubleSin(Single)

-+--++-+-+-+Double Sqrt(Byte) Double Sqrt(Decimal) Double Sqrt(Double)Double Sqrt(Int16) Double Sqrt(Int32) Double Sqrt(Int64)Double Sqrt(Single)

64 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Tan(Byte) Double Tan(Decimal) Double Tan(Double)Double Tan(Int16) Double Tan(Int32) Double Tan(Int64)Double Tan(Single)

Numeric Expression Functions

DescriptionFunction Name

Returns the smallest integer greater than or equal to a numeric ex-pression The return type is the same as the argument type Where

Ceil

the argument is a Decimal Double or Single the returned value isan integral number Ceil(numeric)

Returns the largest integer less than or equal to a numeric expres-sion The return type is the same as the argument type Where the

Floor

argument is a Decimal Double or Single the returned value is anintegral number Floor (numeric)

Returns the rounded value of a numeric expression The return typeis the same as the type of the first argument Round (numeric [number_of_decimals_numeric])

Round

Returns and Int32 which is -1 if the provided numeric expressionevaluates to a value less than 0 0 if the expression evaluates to 0

Sign

and 1 if the expression evaluates to a value bigger than 0 Sign(numeric)

Truncates a numeric or date expression The return type is the sameas the type of the first argument Trunc (date_time YEAR | MONTH

Trunc

Expression | 65

DescriptionFunction Name

| DAY | HOUR | MINUTE) Trunc (numeric [ number_of_decim-als_numeric])

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+++Int64 Ceil(Int64)

-+--++-+-+++Int64 Floor(Int64)

-+--++-+-+-+Byte Ceil(Byte) Decimal Ceil(Decimal) Double Ceil(Double)Int16 Ceil(Int16) Int32 Ceil(Int32) Single Ceil(Single)

-+--++-+-+-+Byte Floor(Byte) Decimal Floor(Decimal) DoubleFloor(Double) Int16 Floor(Int16) Int32 Floor(Int32) SingleFloor(Single)

-+--++-+-+-+Byte Round(Byte) Byte Round(ByteByte) ByteRound(ByteDecimal) Byte Round(ByteDouble) ByteRound(ByteInt16) Byte Round(ByteInt32) ByteRound(ByteInt64) Byte Round(ByteSingle) DecimalRound(Decimal) Decimal Round(DecimalByte) DecimalRound(DecimalDecimal) Decimal Round(DecimalDouble)Decimal Round(DecimalInt16) Decimal Round(Decim-alInt32) Decimal Round(DecimalInt64) DecimalRound(DecimalSingle) Double Round(Double) DoubleRound(DoubleByte) Double Round(DoubleDecimal) DoubleRound(DoubleDouble) Double Round(DoubleInt16) DoubleRound(DoubleInt32) Double Round(DoubleInt64) DoubleRound(DoubleSingle) Int16 Round(Int16) Int16Round(Int16Byte) Int16 Round(Int16Decimal) Int16Round(Int16Double) Int16 Round(Int16Int16) Int16Round(Int16Int32) Int16 Round(Int16Int64) Int16Round(Int16Single) Int32 Round(Int32) Int32Round(Int32Byte) Int32 Round(Int32Decimal) Int32Round(Int32Double) Int32 Round(Int32Int16) Int32

66 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Round(Int32Int32) Int32 Round(Int32Int64) Int32Round(Int32Single) Int64 Round(Int64) Int64Round(Int64Byte) Int64 Round(Int64Decimal) Int64Round(Int64Double) Int64 Round(Int64Int16) Int64Round(Int64Int32) Int64 Round(Int64Int64) Int64Round(Int64Single) Single Round(Single) SingleRound(SingleByte) Single Round(SingleDecimal) SingleRound(SingleDouble) Single Round(SingleInt16) SingleRound(SingleInt32) Single Round(SingleInt64) SingleRound(SingleSingle)

-+--++-+-+-+Int32 Sign(Byte) Int32 Sign(Decimal) Int32 Sign(Double)Int32 Sign(Int16) Int32 Sign(Int32) Int32 Sign(Int64) Int32Sign(Single)

-+--++-+-+-+Byte Trunc(Byte) Byte Trunc(ByteByte) ByteTrunc(ByteDecimal) Byte Trunc(ByteDouble) ByteTrunc(ByteInt16) Byte Trunc(ByteInt32) ByteTrunc(ByteInt64) Byte Trunc(ByteSingle) DateTimeTrunc(DateTimeString) Decimal Trunc(Decimal) DecimalTrunc(DecimalByte) Decimal Trunc(DecimalDecimal)Decimal Trunc(DecimalDouble) Decimal Trunc(Decim-alInt16) Decimal Trunc(DecimalInt32) DecimalTrunc(DecimalInt64) Decimal Trunc(DecimalSingle) DoubleTrunc(Double) Double Trunc(DoubleByte) DoubleTrunc(DoubleDecimal) Double Trunc(DoubleDouble)Double Trunc(DoubleInt16) Double Trunc(DoubleInt32)Double Trunc(DoubleInt64) Double Trunc(DoubleSingle)Int16 Trunc(Int16) Int16 Trunc(Int16Byte) Int16Trunc(Int16Decimal) Int16 Trunc(Int16Double) Int16Trunc(Int16Int16) Int16 Trunc(Int16Int32) Int16Trunc(Int16Int64) Int16 Trunc(Int16Single) Int32Trunc(Int32) Int32 Trunc(Int32Byte) Int32Trunc(Int32Decimal) Int32 Trunc(Int32Double) Int32Trunc(Int32Int16) Int32 Trunc(Int32Int32) Int32Trunc(Int32Int64) Int32 Trunc(Int32Single) Int64Trunc(Int64) Int64 Trunc(Int64Byte) Int64

Expression | 67

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Trunc(Int64Decimal) Int64 Trunc(Int64Double) Int64Trunc(Int64Int16) Int64 Trunc(Int64Int32) Int64Trunc(Int64Int64) Int64 Trunc(Int64Single) SingleTrunc(Single) Single Trunc(SingleByte) SingleTrunc(SingleDecimal) Single Trunc(SingleDouble) SingleTrunc(SingleInt16) Single Trunc(SingleInt32) SingleTrunc(SingleInt64) Single Trunc(SingleSingle)

String Expression Functions

All of these functions return a string

DescriptionFunction Name

Returns the concatenation of two string expressions Concat(boolean | date | numeric | string boolean | date | numeric |string)

Concat

Returns an Int64 which is the position of a substring in a stringexpression Instr(stringstring)

Instr

Returns an Int64 which is the length of a string expressionLength(string)

Length

Converts all uppercase letters in a string expression into lowercaseletters string Lower (string)

Lower

Pads a string expression to the left to a predefined string lengthstring Lpad (string TotalLengthOfResult [ pad-string]) If used withtwo parameters only the pad-string is a single space character

Lpad

Removes leading blanks from a string expression string Ltrim(string)

Ltrim

68 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Pads a string expression to the right to a predefined string lengthstring Rpad (string TotalLengthOfResult [ pad-string]) If used

Rpad

with two parameters only the pad-string is a single space character

Removes trailing blanks from a string expression string Rtrim(string)

Rtrim

Returns a string which is the phonetic representation of a stringexpression See the entry in Wikipedia for more information ht-

Soundex

tpenwikipediaorgwikiSoundex Soundex (string) Soun-dex(lsquoeightrsquo) returns ldquoE230rdquo and Soundex(lsquoexpressionrsquo) returnsldquoE216rdquo

Extracts a substring from a string expression string Substr (stringstart_pos [ length])

Substr

Replaces a set of letters in a string Translate (string from_set_stringto_set_string) If string is ldquoSQLPlus Users Guiderdquo and

Translate

from_set_string is thatis lsquospaceasteriskforward slashsingle quotesingle quotersquo and the to_set_string is___ that islsquounderscoreunderscoreunderscorersquo then the returned stringis lsquoSQL_PLus_Users_Guidersquo Translate looks for each character inthe from_set_string in the string argument and replaces it with thecorresponding character from the to_set_string In this case twospaces are replace by underscores and an asterisk is replaced by nunderscore There is no forward slash in the target string to be re-placed and there is no replacement character in the to_set_stringcorresponding to the single apostrophe character in thefrom_set_string When there is no replacement character in theto_set_string corresponding to a character in the from_set_stringthe character in the from_set_string is removed wherever it is foundin the target string

Removes leading andor trailing blanks from a string expressionTrim ([BOTH | LEADING | TRAILING ] string)

Trim

Expression | 69

DescriptionFunction Name

Converts all lowercase letters in a string expression into uppercaseletters Upper (string)

Upper

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+++++String Concat(StringString)

-+--++-+-+-+String Concat(BooleanBoolean) String Concat(BooleanByte)String Concat(BooleanDateTime) String Concat(BooleanDecim-al) String Concat(BooleanDouble) String Concat(BooleanInt16)String Concat(BooleanInt32) String Concat(BooleanInt64) StringConcat(BooleanSingle) String Concat(BooleanString) StringConcat(ByteBoolean) String Concat(ByteByte) String Con-cat(ByteDateTime) String Concat(ByteDecimal) String Con-cat(ByteDouble) String Concat(ByteInt16) String Con-cat(ByteInt32) String Concat(ByteInt64) String Con-cat(ByteSingle) String Concat(ByteString) String Concat(Date-TimeBoolean) String Concat(DateTimeByte) String Concat(Dat-eTimeDateTime) String Concat(DateTimeDecimal) StringConcat(DateTimeDouble) String Concat(DateTimeInt16) StringConcat(DateTimeInt32) String Concat(DateTimeInt64) StringConcat(DateTimeSingle) String Concat(DateTimeString) StringConcat(DecimalBoolean) String Concat(DecimalByte) StringConcat(DecimalDateTime) String Concat(DecimalDecimal)String Concat(DecimalDouble) String Concat(DecimalInt16)String Concat(DecimalInt32) String Concat(DecimalInt64)String Concat(DecimalSingle) String Concat(DecimalString)String Concat(DoubleBoolean) String Concat(DoubleDateTime)String Concat(DoubleDecimal) String Concat(DoubleDouble)String Concat(DoubleInt16) String Concat(DoubleInt32) StringConcat(DoubleInt64) String Concat(DoubleSingle) StringConcat(DoubleString) String Concat(Int16Boolean) StringConcat(Int16Byte) String Concat(Int16DateTime) String Con-cat(Int16Decimal) String Concat(Int16Double) String Con-cat(Int16Int16) String Concat(Int16Int32) String Con-cat(Int16Int64) String Concat(Int16Single) String Con-

70 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

cat(Int16String) String Concat(Int32Boolean) String Con-cat(Int32Byte) String Concat(Int32DateTime) String Con-cat(Int32Decimal) String Concat(Int32Double) String Con-cat(Int32Int16) String Concat(Int32Int32) String Con-cat(Int32Int64) String Concat(Int32Single) String Con-cat(Int32String) String Concat(Int64Boolean) String Con-cat(Int64Byte) String Concat(Int64DateTime) String Con-cat(Int64Decimal) String Concat(Int64Double) String Con-cat(Int64Int16) String Concat(Int64Int32) String Con-cat(Int64Int64) String Concat(Int64Single) String Con-cat(Int64String) String Concat(SingleBoolean) String Con-cat(SingleByte) String Concat(SingleDateTime) String Con-cat(SingleDecimal) String Concat(SingleDouble) String Con-cat(SingleInt16) String Concat(SingleInt32) String Con-cat(SingleInt64) String Concat(SingleSingle) String Con-cat(SingleString) String Concat(StringBoolean) String Con-cat(StringByte) String Concat(StringDateTime) String Con-cat(StringDecimal) String Concat(StringDouble) String Con-cat(StringInt16) String Concat(StringInt32) String Con-cat(StringInt64) String Concat(StringSingle)

-+--++-+-+-+Int64 Instr(StringString)

-+--++-+-+-+Int64 Length(String)

-+--++-+-+-+String Lower(String)

-+--++-+-+-+String Lpad(StringByte) String Lpad(StringByteString) StringLpad(StringDecimal) String Lpad(StringDecimalString) StringLpad(StringDouble) String Lpad(StringDoubleString) StringLpad(StringInt16) String Lpad(StringInt16String) StringLpad(StringInt32) String Lpad(StringInt32String) StringLpad(StringInt64) String Lpad(StringInt64String) StringLpad(StringSingle) String Lpad(StringSingleString)

-+--++-+-+-+String Ltrim(String)

Expression | 71

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+String Rpad(StringByte) String Rpad(StringByteString) StringRpad(StringDecimal) String Rpad(StringDecimalString) StringRpad(StringDouble) String Rpad(StringDoubleString) StringRpad(StringInt16) String Rpad(StringInt16String) StringRpad(StringInt32) String Rpad(StringInt32String) StringRpad(StringInt64) String Rpad(StringInt64String) StringRpad(StringSingle) String Rpad(StringSingleString)

-+--++-+-+-+String Rtrim(String)

-+--++-+-+-+String Soundex(String)

-+--++-+-+-+String Substr(StringByte) String Substr(StringByteByte) StringSubstr(StringByteDecimal) String Substr(StringByteDouble)String Substr(StringByteInt16) String Substr(StringByteInt32)String Substr(StringByteInt64) String Substr(StringByteSingle)String Substr(StringDecimal) String Substr(StringDecimalByte)String Substr(StringDecimalDecimal) String Substr(StringDecim-alDouble) String Substr(StringDecimalInt16) String Sub-str(StringDecimalInt32) String Substr(StringDecimalInt64)String Substr(StringDecimalSingle) String Substr(StringDouble)String Substr(StringDoubleByte) String Sub-str(StringDoubleDecimal) String Substr(StringDoubleDouble)String Substr(StringDoubleInt16) String Sub-str(StringDoubleInt32) String Substr(StringDoubleInt64) StringSubstr(StringDoubleSingle) String Substr(StringInt16) StringSubstr(StringInt16Byte) String Substr(StringInt16Decimal)String Substr(StringInt16Double) String Sub-str(StringInt16Int16) String Substr(StringInt16Int32) StringSubstr(StringInt16Int64) String Substr(StringInt16Single)String Substr(StringInt32) String Substr(StringInt32Byte) StringSubstr(StringInt32Decimal) String Substr(StringInt32Double)String Substr(StringInt32Int16) String Substr(StringInt32Int32)String Substr(StringInt32Int64) String Substr(StringInt32Single)String Substr(StringInt64) String Substr(StringInt64Byte) StringSubstr(StringInt64Decimal) String Substr(StringInt64Double)

72 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

String Substr(StringInt64Int16) String Substr(StringInt64Int32)String Substr(StringInt64Int64) String Substr(StringInt64Single)String Substr(StringSingle) String Substr(StringSingleByte)String Substr(StringSingleDecimal) String Sub-str(StringSingleDouble) String Substr(StringSingleInt16) StringSubstr(StringSingleInt32) String Substr(StringSingleInt64)String Substr(StringSingleSingle)

-+--++-+-+-+String Translate(StringStringString)

-+--++-+-+-+String Trim(String) String Trim(StringString)

-+--++-+-+-+String Upper(String)

----------+-String Lower(StringString)

----------+-String Upper(StringString)

Miscellaneous Expression Functions

The following functions were not affected by the introduction of the ExpressionBuilder component in FDO 33

DescriptionFunction Name

Returns a geometry that is the subset of the geometry argumentdefined by the polygon specified by the coordinate argumentsCLIP(BLOBDoubleDoubleDoubleDouble)

CLIP

Returns a geometry MOSAIC(BLOB)MOSAIC

Returns a geometry RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

RESAMPLE

Expression | 73

DescriptionFunction Name

Returns a geometry SpatialExtent(BLOB)SpatialExtent

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----BLOB CLIP(BLOBDoubleDoubleDoubleDouble)

--+---+-----BLOB RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

--+---------BLOB SpatialExtents(BLOB)

------+-----BLOB MOSAIC(BLOB)

Filter

In C you access theOSGeoFDOConnectionsCapabilitiesIFilterCapabilities using theIConnection object (connectionFilterCapabilities)

In C++ you access the FdoIFilterCapabilities using the IConnection object(connection-gtGetFilterCapabilities())

DescriptionCapability

Tests if the value of a specified data property is within a givenset of literal values

ConditionType_In

Tests if one expression is equal not equal greater than lessthan greater than or equal to or less than or equal to anotherexpression

ConditionType_Comparison

Tests whether the value of a geometric property is within orbeyond a specified distance of a literal geometric value

ConditionType_Distance

74 | Chapter 6 FDO Capabilities

DescriptionCapability

Tests whether the value of a specified data property matchesa specified pattern

ConditionType_Like

Tests whether the value of a specified data property is nullConditionType_Null

Tests whether the value of a geometric property and a literalgeometric value satisfy the spatial relationship implied by theoperation

ConditionType_Spatial

Tests whether the geometric property value lies beyond aspecified distance of a literal geometric value

DistanceOperations_Beyond

Tests whetherthe geometric property value lies within a spe-cified distance of a literal geometric value

DistanceOperations_Within

Tests whetherthe geometric property value spatially containsthe literal geometric value

SpatialOperations_Contains

Tests whether the geometric property value is covered by theinterior and boundary of the given geometry

SpatialOperations_CoveredBy

Tests whetherthe geometric property value spatially crossesthe given geometry

SpatialOperations_Crosses

Tests whether the geometric property value is spatially disjointfrom the given geometry

SpatialOperations_Disjoint

Tests whether the envelope of the referenced geometricproperty value spatially intersects the given geometry

SpatialOperations_EnvelopeIntersects

Tests whether the geometric property value is spatially equalto the given geometry

SpatialOperations_Equals

Tests whether the geometric property value is inside the in-terior of the given geometry not touching the boundary

SpatialOperations_Inside

Filter | 75

DescriptionCapability

Tests whether the geometric property value spatially intersectsthe given geometry

SpatialOperations_Intersects

Tests whether the geometric property value spatially overlapsthe given geometry

SpatialOperations_Overlaps

Tests whether the geometric property value spatially touchesthe given geometry

SpatialOperations_Touches

Tests whether the geometric property value is spatially withinthe given geometry

SpatialOperations_Within

Tests whether the spatial and distance operations can be ap-plied between two geometric properties Returns false if spatial

SupportsNonLiteralGeometricOperations

and distance operations can be applied only between a geo-metric property and a literal geometry Returns true if spatialand distance operations can be applied

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++++++++SpatialOperations_EnvelopeIntersects ConditionType_In Condi-tionType_Spatial

-+--++++++++SpatialOperations_Intersects

++--++-+++++ConditionType_Null ConditionType_Comparison Condition-Type_Like

-+--+++++-++SpatialOperations_Inside

-+--+++-+-++SpatialOperations_Within

-------+++-+ConditionType_Distance

76 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-----+--+-++SpatialOperations_Disjoint SpatialOperations_Contains

--------+-++SpatialOperations_CoveredBy SpatialOperations_Crosses Spa-tialOperations_Touches SpatialOperations_Equals SpatialOper-ations_Overlaps

--------+--+DistanceOperations_Beyond DistanceOperations_Within

---+--------SupportsNonLiteralGeometricOperations

------------SupportsGeodesicDistance

Geometry

In C you access theOSGeoFDOConnectionsCapabilitiesIGeometryCapabilities using theIConnection object (connectionGeometryCapabilities)

In C++ you access the FdoIGeometryCapabilities using the IConnectionobject (connection-gtGetGeometryCapabilities())

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++FdoDimensionality_XY

+-++++-+++++GeometryType_Polygon GeometryComponentType_Linear-Ring

++-+++-+++++GeometryType_Point

Geometry | 77

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

+--+++-+++++GeometryType_MultiLineString GeometryType_MultiPointGeometryType_LineString

+--+-+-+++++GeometryType_MultiPolygon

+--+++-+--++GeometryComponentType_LineStringSegment

---+++--+-++FdoDimensionality_M FdoDimensionality_Z

+--+-+-+--+-GeometryComponentType_Ring

+--+-+--+-+-GeometryType_MultiGeometry

---+-+-+--+-GeometryType_CurvePolygon GeometryComponentType_Cir-cularArcSegment GeometryType_CurveString Geometry-Type_MultiCurvePolygon GeometryType_MultiCurveString

Raster

In C you access theOSGeoFDOConnectionsCapabilitiesIRasterCapabilities using theIConnection object (connectionRasterCapabilities)

In C++ you access the FdoIRasterCapabilities using the IConnection object(connection-gtGetRasterCapabilities())

DescriptionCapability

Indicates whether or not a provider supports the retrieval andmanipulation of image data

SupportsRaster

Indicates whether or not a provider supports the reduction ofthe amount of detail and data in the image

SupportsSubsampling

78 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the compositionof multiple raster images

SupportsStitching

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----SupportsRaster SupportsSubsampling

------------SupportsStitching

Schema

In C you access theOSGeoFDOConnectionsCapabilitiesISchemaCapabilities using theIConnection object (connectionSchemaCapabilities)

In C++ you access the FdoISchemaCapabilities using the IConnection object(connection-gtGetSchemaCapabilities())

DescriptionCapability

Indicates whether or not a provider supports auto gener-ation of values for the data types represented by the as-terisk Boolean Byte DateTime and Decimal

AutoGenerated_

Indicates whether or not a provider supports the Classtype which does not have a Geometry property

ClassType_Class

Indicates whether or not a provider supports the Classtype which does have a Geometry property

ClassType_FeatureClass

Indicates whether or not a provider supports the spe-cificdata type that replaces the BLOB Boolean Byte

DataType_

Schema | 79

DescriptionCapability

CLOB DateTime Decimal Double Int16 Int32 Int64Single or String

Indicates whether or not a provider supports the use ofthe property types represented by the asterisk as identity

IdentityProperty_

properties BLOB Boolean Byte DateTime DecimalDouble Int16 Int32 Int64 Single and String

Indicates whether or not a provider supports decimals upto the specified number of digits in length

MaximumDecimalPrecision

Indicates whether or not a provider supports decimalswith up to the specified number of digits to the right ofthe decimal point

MaximumDecimalScale

The set of characters which cannot be used in schemaelement names

ReservedCharactersForName

Indicates whether or not a provider supports the associ-ation property

SupportsAssociationProperties

Indicates whether or not a provider supports the automat-ic generation of id property values

SupportsAutoIdGeneration

Indicates whether or not a provider supports multipleidentity properties per class

SupportsCompositeId

Indicates whether or not a provider supports unique valueconstraints on a set of columns

SupportsCompositeUniqueValueConstraints

Indicates whether or not a provider supports the automat-ic generation of ID values that are unique for the entiredatastore rather than just for a particular class

SupportsDataStoreScopeUniqueIdGeneration

Indicates whether or not a provider supports the specific-ation of default values for property definitions

SupportsDefaultValue

80 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the settingof minimums that the input data must greater than andmaximums that the input data must be less than

SupportsExclusiveValueRangeConstraints

Indicates whether or not a provider supports the settingof minimums that the input data must greater than or

SupportsInclusiveValueRangeConstraints

equal to and maximums that the input data must be lessthan or equal to

Indicates whether or not a provider supports class hier-archies in the feature schema

SupportsInheritance

Indicates whether or not a provider supports the definitionof more than one feature schema in the data store

SupportsMultipleSchemas

Indicates whether or not a provider allows property valuesto be null

SupportsNullValueConstraints

Indicates whether or not a provider supports objectproperties A class instance can contain an instance ofanother class

SupportsObjectProperties

Indicates whether or not a provider supports the modific-ation of a schema after its intitial creation

SupportsSchemaModification

Indicates whether or not a provider supports the overrid-ing of the default rules for mapping feature schemas toprovider-specific physical schemas

SupportsSchemaOverrides

Indicates whether or not a provider supports requiringthat a column contain unique values

SupportsUniqueValueConstraints

Indicates whether or not a provider supports requiringthat a column contain values that belong to a value con-straints list

SupportsValueConstraintsList

Schema | 81

Expressible as Boolean

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ClassType_FeatureClass DataType_String

++-+++-+++++IdentityProperty_Int32 DataType_Int32 DataType_DateTimeClassType_Class

++-+-+-+++++DataType_Double

--++-+++++++IdentityProperty_String

-+-+-+-+++++DataType_Int16 DataType_Single IdentityProperty_Int16

-+--++-+++++SupportsAutoIdGeneration SupportsNullValueConstraints

-++-+-+++++-SupportsSchemaOverrides

-+-+++-++++-DataType_Decimal DataType_Boolean

++--++--+-++AutoGenerated_Int32

-+++-+++-+--SupportsInheritance

-+-+-+-++++-DataType_Byte IdentityProperty_Int64 DataType_Int64

---+-+-+++++IdentityProperty_Double IdentityProperty_DateTime Identi-tyProperty_Single

-+-+--++-+++SupportsMultipleSchemas

-+-+-+-+++--SupportsCompositeId

82 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+ReservedCharactersForName

----++-++++-SupportsSchemaModification

-+--+--+++-+MaximumDecimalPrecision MaximumDecimalScale

---+-+-++++-IdentityProperty_Boolean IdentityProperty_Decimal Identi-tyProperty_Byte

-------+++-+SupportsCompositeUniqueValueConstraints SupportsUnique-ValueConstraints

-+-----+++--AutoGenerated_Int64 SupportsDefaultValue

---+-+-+-+--SupportsAssociationProperties

--+---+----+DataType_BLOB

---+---+-+--SupportsObjectProperties

-------+-+--SupportsDataStoreScopeUniqueIdGeneration

-----+-+----SupportsValueConstraintsList SupportsExclusiveValueRangeCon-straints SupportsInclusiveValueRangeConstraints

Not Expressible as a Boolean

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

3838ArcSDE

Schema | 83

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

6565MySQL

10001000nullPostGIS

3838SQLServerSpa-tial

nullnullSDF

255255SHP

2828ODBC

84 | Chapter 6 FDO Capabilities

Schema Management

This chapter describes how to create and work with schemas and explains some issues relatedto schema management For example you can use the FDO feature schema to specify howto represent geospatial features

Schema PackageThe FDO feature schema provides a logical mechanism for specifying how torepresent geospatial features FDO providers are responsible for mapping thefeature schema to some underlying physical data store The FDO feature schemais based somewhat on a subset of the OpenGIS and ISO feature models Itsupports both non-spatial features and spatial features

The Schema package contains a collection of classes that define the logicalfeature schema These classes can be used to set up a feature schema and tointerrogate the metadata from a provider using an object-oriented structureThe logical feature schema provides a logical view of geospatial feature data thatis fully independent from the underlying storage schema All data operationsin FDO are performed against the classes and relationships defined by the logicalfeature schema For example different class types in the feature schema are usedto describe different types of geospatial objects and spatial features

Base Properties

All classes in the feature schema support the concept of base properties whichare properties that are pre-defined either by the FDO API or by a specific FDOfeature provider For example all classes in the schema have two base propertiesClassName and SchemaName These properties can be used to query across aninheritance hierarchy or to process the results of heterogeneous queries FDO

7

85

feature providers can also predefine base properties The following baseproperties are predefined by the FDO API

DescriptionRequiredProperty Name

Name of the schema to which objects of the classbelong read-only string

YSchemaName

Name of the class that defines the object read-onlystring

YClassName

Revision number of the object read-only 64-bit in-teger

NRevisionNumber

NOTE Some providers may use this property tosupport optimistic locking

Cross-Schema References

Some FDO feature providers may support multiple schemas For these providersthe feature schema supports the concept of cross-schema references for classesThis means that a class in one schema may derive from a class in anotherschema relate to a class in another schema or contain an object propertydefinition that is based on a class in another schema

Parenting in the Schema Classes

The feature schema object model defined in the FDO API supports fullnavigation through parenting That is once a schema element is added to anFdoFeatureSchema class it can navigate the object hierarchy upward to theroot FdoFeatureSchema and from there to any other element in the featureschema This parenting support is fully defined in the FdoSchemaElementabstract base class

When inserting features that have object collections the parent object instancemust be identified when inserting the child objects (for example a parentclass ldquoRoadrdquo has an object property called ldquosidewalksrdquo of type ldquoSidewalkrdquo)For more information see Data Maintenance on page 119

Physical Mappings

Each feature provider maps the logical feature schema to an underlyingphysical data store Some feature providers may provide some level of control

86 | Chapter 7 Schema Management

over how the logical schema gets mapped to the underlying physical storageFor example an RDBMS-based feature provider may allow table and columnnames to be specified for classes and properties Since this is entirelyprovider-dependent the FDO API simply provides abstract classes for passingphysical schema and class mappings to the provider(FdoPhysicalSchemaMapping FdoPhysicalClassMappingFdoPhysicalPropertyMapping and FdoPhysicalElementMapping respectively)The implementation of these abstract classes is up to each feature provider

Schema MappingsWhen a provider connects to a data source that it did not create and does adescribe schema command it will map FDO data types to the physical entitescontained in the data source This mapping is called the default schemamapping or alternatively the physical to logical schema mapping

When reverse engineering an existing schema FDO uses the following rulesto select the column(s) to use as the identity property

1 Use the primary key

2 Use a unique index

3 Treat the data as read-only

NOTE When reverse engineering a view FDO will apply rules 1 and 2 to the viewand then if necessary to the base tables

NOTE If FDO detects more than one unique index it calculates a weight for eachindex and selects the lightest one The weight of each index is the sum of theweights of its columns Column weight depends on column type as follows Indexeswith Blobs or Clobs are not chosen If FDO picks a multi-column index as theunique index it creates an identity property for each column in the index

1 for Boolean or Byte

2 for Int16

4 for Int32

8 for Int64 Decimal Double or Float

50 for DateTime

length for String

Schema Mappings | 87

After you use FDO to create a feature schema you can use external means toaccess the data store to inspect what native data types FDO uses for its logicaltypes This mapping is called the logical to physical schema mapping

The following mappings have been documented in the provider appendices

physical to logical schema mappings for ODBC connections to a MicrosoftAccess database an Excel spreadsheet and a text file

physical to logical and logical to physical schema mappings for OracleMySQL Sql Server and Sql Server Spatial

The mechanism for overriding the default schema mapping is described inthe next topic Sample code is located in the FDO Cookbook chapter of thisdocument

Schema OverridesUsing schema overrides FDO applications can customize the mappingsbetween Feature (logical) Schemas and the Physical Schema of the providerdata store

Schema overrides are provider-specific because different FDO providers supportFDO data stores with widely different physical formats Therefore the typesof schema mappings in these overrides also vary between providers Forexample an RDBMS-type provider might provide a mapping to index a set ofcolumns in a class table However other providers would not necessarily beable to work with the concept of an index For information about schemaoverrides support by a specific provider see the appropriate appendix in thisdocument and The Essential FDO

NOTE Some providers support only default schema mappings

Working with SchemasThere are three primary operations involved with schema management

Creating a schema

Describing a schema

Modifying a schema

88 | Chapter 7 Schema Management

Creating a Schema

The following basic steps are required to create a schema (some steps areoptional some may be done in an alternate order to achieve the same result)

Use the FdoFeatureSchemaCreate(ldquoSchemaNamerdquo ldquoFeatureSchemaDescriptionrdquo) method to create a schema

Use the FdoFeatureSchemaGetClasses() method to return a class collection

Use the FdoClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) orFdoFeatureClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) method to createFdoClass or FdoFeatureClass type objects

Use the FdoClassCollectionAdd(class) method to add FdoClass orFdoFeatureClass objects to the class collection

Use the FdoGeometricPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoGeometryProperty

Use the FdoDataPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo) methodto create FdoDataProperty

Use the FdoObjectPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoObjectProperty

Use the FdoClassDefinitionGetProperties() and Add(property) methodsto add property to class definition

Use the FdoIApplySchemaCommandSetFeatureSchema(feature schema)method to set the schema object for the IFdoApplySchemaCommand

Use the FdoAssociationPropertydefinition class to represent the associationbetween two classes The class of the associated class must already bedefined in the feature schema and cannot be abstract

Use the FdoIApplySchemaCommandExecute() method to execute changesto the feature schema

For an example of schema creation see Example Creating a Feature Schemaon page 111

Use the FdoClassDefinitionGetIdentityProperties() and Add(Property Object)methods to set the property as FdoClass or FdoFeatureClass Identifier FDOallows multiple Identifiers for both types of classes although Identifiers haveslight differences in both cases

Working with Schemas | 89

FDOFeatureClassFdoFeatureClass is a class that defines features In the case of GIS they wouldoften be spatial features having some sort of geometry associated with themIn most providers FdoFeatureClass requires a unique identifier to distinguishthe features

However there are identifiers only if no base class exists If the base class hasan identifier the child class does not have one You cannot set an identifierto the child class Any class definition that has a base class cannot also haveany identity properties because it inherits from the base class

Therefore you cannot send an identifier when a feature class is a child sinceit always inherits the identifier from the base class

FDOClassThis class is used for non-spatial data It can act as a stand-alone class whereit would have no association with any other class or if the FdoClass is beingused as an ObjectProperty it can be used to define properties of some otherFdoClass or FdoFeatureClass

ObjectProperty Types

ObjectProperties have the following types

Value

Collection

OrderedCollection

The Value ObjectProperty type has a relationship of one-to-one providing asingle value for each property

The Collection and OrderedCollection ObjectProperty types have aone-to-many relationship where many ObjectProperties may be associatedwith one property Ordered Collections can be stored in an ascending ordescending order

90 | Chapter 7 Schema Management

At least one Identifier will be required if the FdoClass is to be used as astand-alone Class

All Identifiers for FdoDataType_Int64 must not be Read-Only since noneof these will be an auto-generated property value

If creating multiple Identifiers all Identifiers must be set to NOT NULL

Non-Feature Class IssuesA non-feature class in FDO can be created as a stand-alone class a containedclass or both As a contained class it defines a property of another class orfeature class (see FdoFeatureClass and FdoClassType Global Enum) How thisnon-feature class is created affects the way the data is inserted queried andupdated

Stand-alone Class

This type of class stores non-feature data (for example manufacturers) TheFdoClassType_Class must be created with one or more identity properties (seeFdoObjectPropertyDefinition) which is required in order that the class has aphysical container (that is a table in the RDBMS) associated with it If theclass is created without specifying an IdentityProperty only the definition isstored in the metadata which prevents any direct data inserts

Contained Class

This type of class stores non-feature data that defines a property of anotherclass or feature class (for example Sidewalk could be a property of a Roadfeature class the Sidewalk class defines the RoadSidewalk property) In thiscase the FdoClassType_Class does not need to be created with one or moreidentity properties although it can be

Class With IdentityProperty Used as ObjectProperty

This type of class reacts like a stand-alone class however with this type it ispossible to do direct data inserts It can also be populated through a containerclass (for example RoadSidewalk) since it defines an object property (seeFdoObjectPropertyDefinition) If this class is queried directly only the datainserted into the class as a stand-alone is returned The data associated withthe ObjectProperty can only be queried through the container class (forexample RoadSidewalk)

Non-Feature Class Issues | 91

Class Without a Defined IdentityProperty Used as ObjectProperty

Because this class has no defined IdentityProperty it can only be populatedthrough the container class (for example RoadSidewalk) since it definesObjectProperty This class cannot be queried directly The data associated withthe object property can only be queried through the container class (forexample RoadSidewalk) As an object property it is defined as one of thefollowing

Value type property Does not need any identifier since it has a one-to-onerelationship with the container class

Collection type property Requires a local identifier which is an identifierdefined when creating the ObjectProperty object

Ordered Collection type property Requires a local identifier which is anidentifier defined when creating the ObjectProperty object

When defining either a Collection or Ordered Collection type ObjectPropertyyou must set an IdentityProperty attribute for that object property ThisObjectClassIdentityProperty acts only as a local identifier compared to theIdentityProperty set at the class level As a local identifier it acts to uniquelyidentify each item within each collection (for example if the local identifierfor RoadSidewalk is Side there can be multiple sidewalks with Side=rdquoLeftrdquobut only one per Road)

Describing a Schema

Use the FdoIDescribeSchemaExecute function to retrieve anFdoFeatureSchemaCollection in order to obtain any information about existingschema(s) The FdoFeatureSchemaCollection consists of all FdoFeatureSchemasin the data store and can be used to obtain information about any schemaobject including FdoFeatureSchema FdoClass FdoFeatureClass and theirrespective properties The following functions return the main collectionsrequired to obtain information about all schema objects

FdoFeatureSchemaGetClasses method obtains FdoClass andFdoFeatureClasses

FdoClassDefinitionGetProperties method obtains aFdoPropertyDefinitionCollection

FdoClassDefinitionGetBaseProperties method obtains aFdoPropertyDefinitionCollection of the properties inherited from the baseclasses

92 | Chapter 7 Schema Management

NOTE Even if your schema has no base classes (inheritance) all classes will inheritsome properties from system classes

Use these functions throughout the application to obtain any informationabout schema objects For example in order to insert data into a class youmust use these functions to determine what data type is required Descriptionof the data is separate from actions

The example in the following link is a simple function that shows how to useFdoIDescribeSchema and loop through the schema and class containers tosearch for duplicate class names It searches all schemas to ensure that theclass name does not exist in any schema in the data store Class names mustbe unique across the entire FDO database

For a schema description example see Example Describing a Schema andWriting It to an XML File on page 114 NO LABEL

FDO Schema Element Class Diagram

Non-Feature Class Issues | 93

Modifying ModelsAdd schema elements to a model by inserting them into the appropriatecollection

Elements are removed from the model by using either of the followingmethods

Call the FdoSchemaElementDelete() method This flags the element fordeletion when the changes are accepted (generally throughFdoIApplySchema) but the element remains a member of all collectionsuntil that time

Remove the element from the appropriate collection via theFdoSchemaCollectionRemove() or FdoSchemaCollectionRemoveAt()methods This immediately disassociates the element from the collection

Schema Element StatesAll elements within the model maintain a state flag This flag can be retrievedby calling FdoSchemaElementGetElementState() but it cannot be directlyset Instead its state changes in reaction to the changes made to the model

Unchanged When a schema model is retrieved via FdoIDescribeSchemaall elements are initially marked Unchanged

Detached Removing an element from an owning collection sets its stateto Detached

Deleted Calling the Delete() method on an element sets its state to Deleted

Added Placing an element within a collection marks the element as Added

Modified When adding or removing a sub-element such as a propertyelement from a class the class element state will be changed to Modified

Additionally when an element that is contained by another element is changedin any way the containing element is also marked as Modified So for exampleif a new value is added to the SchemaAttributeDictionary of the ldquoClass3rdquoelement in our model both the ldquoClass3rdquo FdoClass object and theFdoFeatureSchema object would be marked as Modified

94 | Chapter 7 Schema Management

The state flags are maintained until the changes are accepted that is whenIApplySchema is executed At that time all elements marked Deleted arereleased and all other elements are set to Unchanged

NOTE When you remove an element from an owning collection its state is markedas Detached All collections currently in FDO are owning collections except forone the collections FdoClassDefinitionGetIdentityProperties()

Rollback MechanismThe FdoFeatureSchema contains a mechanism that allows you to ldquoroll backrdquomodel changes to the last accepted state For example a model retrieved viaFdoIDescribeSchema can have classes added attributes deleted or names anddefault values changed All of these changes are thrown out and the modelreturned to its unmodified state by calling FdoFeatureSchemaRejectChanges()

The converse of this operation is the FdoFeatureSchemaAcceptChanges()method which removes all of the elements with a status of Deleted and setsthe state flag of all other elements to Unchanged Generally this method isonly invoked by FDO provider code after it has processed anFdoIApplySchemaExecute() command Normal FDO clients should not callthis method directly

FDO XML FormatFDO feature schemas can be written to an XML file The FdoFeatureSchemaand FdoFeatureSchemaCollection classes support the FdoXmlSerializableinterface The sample code shows an FdoFeatureSchema object calling theWriteXml() method to generate an XML file containing the feature schemacreated by the sample code

FDO feature schemas can also be read from an XML file TheFdoFeatureSchemaCollection class supports the FdoXmlDeserializable interfaceThe sample code shows an FdoFeatureSchemaCollection object calling theReadXml() method to read a set of feature schemas into memory from an XMLfile The code shows the desired schema being retrieved from the collectionand applied to the data store

The XML format used by FDO is a subset of the Geography Markup Language(GML) standardized by the Open GIS Consortium (OGC) One thing shownin the sample code is a round-trip conversion from FDO feature schema toGML schema back to FDO feature schema To accomplish this round-trip the

Rollback Mechanism | 95

ReadXml() method supports a superset of the GML that is written by theWriteXml() method

The following table specifies the mapping of FDO feature schema elementsto GML elements and attributes This mapping is sufficient to understand theXML file generated from the schema defined by the sample code It alsoprovides a guide for writing a GML schema file by hand This file can then beread in and applied to a data store For more information see ExampleCreating a Schema Read In from an XML File on page 114

Another form of round-trip translation would be from a GML schema producedby another vendorrsquos tool to an FDO feature schema and then back to a GMLschema However the resemblance the of resulting GML schema to the originalGML schema might vary from only roughly equivalent to being exactly thesame

Map FDO Element to GML Schema Fragment

GML Schema FragmentFDO Element

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaN

amegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgisdschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFea

tureSchemaNamegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

see ltMetaDatagt

optional xsimport element to enable schema validation

ltxsimport namespace=httpfdoosgeoorgschema

schemaLocation=ltFDO SDK Install LocationgtdocsXmlS

chemaFdoDocumentxsdgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

FeatureSchema

96 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxsfield xpath=rdquordquogt

ltxsfield xpath=rdquoltidentityPropertyltngtNamegtrdquo

ltxskeygt

ltxselementgt

ClassDefinition(with identity prop-erties)

ltxselement see ClassDefinition (with identity proper

ties)ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

see FeatureClassGeometryProperty

gt

see ltMetaDatagt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

gt

ltxssequencegt

list of properties see DataProperty Geometric

Property

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

FeatureClass

FDO XML Format | 97

GML Schema FragmentFDO Element

lt-- these attributes belong to the xscomplexType element

--gt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

FeatureClass Geo-metryProperty

lt--

minOccurs attribute generated only if value is 1

default attribute generated only if a default value exists

fdoreadOnly attribute generated only if value is true

--gt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxssimpleTypegt

see DataType String or DataType Decimal

ltxssimpleTypegt

ltxselementgt

DataProperty(decimal or string)

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxselementgt

DataProperty (oth-er type)

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

DataType String

98 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxsrestriction base=rdquoxsdecimalrdquogt

ltxstotalDigits value=rdquoltprecisiongtrdquogt

ltxsfractionDigits value=rdquoltscalegtrdquogt

ltxsrestrictiongt

DataType Decimal

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquogmlAbstractGeometryTyperdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

see ltMetaDatagt

ltxselementgt

GeometricProperty(not a defining Fea-tureClass Geo-metryProperty)

FDO XML Format | 99

GML Schema FragmentFDO Element

lt-- the pattern referenced in the xsschema element for

FeatureSchema--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeatureS

chemaCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xselement element for

DataProperty --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoDataProp

ertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt--

the pattern referenced in the xselement element for a

non-feature-defining

GeometricProperty

--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xscomplexType element

for FeatureClass --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeature

ClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

MetaData

Map FDO Datatype to GML Type

GML TypeFDO Datatype

xsbooleanBoolean

fdoByteByte

xsdateTimeDateTime

100 | Chapter 7 Schema Management

GML TypeFDO Datatype

xsdoubleDouble

fdoInt16Int16

fdoInt32Int32

fdoInt64Int64

xsfloatSingle

xsbase64BinaryBLOB

xsstringCLOB

Creating and Editing a GML Schema FileThe sample in this section illustrates the creation of a GML schema filecontaining the definition of an FDO feature schema that contains one featureThe name of this file will have the standard XML schema extension namexsd This means that it contains only one schema and that the root elementis xsschema The ReadXml() method will take a filename argument whoseextension is either xsd or xml In the latter case the file could contain manyschema definitions If it does each schema is contained in an xsschemaelement and all xsschema elements are contained in the fdoDataStoreelement If there is only one schema in the xml file then the fdoDataStoreelement is not used and the root element is xsschema

You may want to validate the schema that you create To do so you mustinclude the optional xsimport line specified in the GML schema fragmentfor FeatureSchema

The sample feature implements a table definition for the Buildings feature inthe Open GIS Consortium document 98-046r1 This table definition isexpressed in an XML format on page 14 of the document and is reproducedas follows

Creating and Editing a GML Schema File | 101

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtbuildingsltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtaddressltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtpositionltnamegt

lttypegtPOINTlttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtfootprintltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

Add GML for the FDO Feature Schema

Start with the skeleton GML for an FDO Feature Schema with the ltMetaDatagtreference replaced by the valid pattern

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaNamegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFeatureSchema

Namegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgt

description arg to static FdoFeatureSchemaCreate()

ltxsdocumentationgt

ltxsannotationgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

102 | Chapter 7 Schema Management

For ltcustomer_urlgt substitute ldquofdo_customerrdquo For ltFeatureSchemaNamegtsubstitute ldquoOGC980461FSrdquo and for description arg substitute ldquoOGCSimple Features Specification for SQLrdquo

Add GML for an FDO Feature Class

Start with the GML that is already written and add the skeleton for an FDOFeature Class which includes the skeleton for a class definition with identityproperties The ltMetaDatagt is replaced with the valid pattern

Creating and Editing a GML Schema File | 103

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoFeatureClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

104 | Chapter 7 Schema Management

gt

ltxssequencegt

list of properties see DataProperty GeometricProperty

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For ltclassNamegt substitute ldquobuildingsrdquo

Set the value of the xselement abstract attribute to false

For ltidentityPropertyNamegt substitute ldquofidrdquo A data property whose nameis ldquofidrdquo will be added

Set the value of the xscomplexType abstract attribute to false

For ltgeometryPropertyNamegt substitute ldquofootprintrdquo

For ltlist of FdoGeometricTypesgt substitute ldquosurfacerdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoFeatureClassCreate() substitute ldquoOGC 98-046r1buildingsrdquo

For lturigt substitute ldquohttpfdoosgeoorgschemardquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoa polygon defines a building perimeterrdquo

This class has no base class so set the value of the xsextension base attributeto lsquogmlAbstractFeatureTypersquo

Add GML for Property Definitions

An integer data property whose name is ldquofidrdquo will be added This property isalready identified as an identity property in the xskey element A string dataproperty whose name is ldquonamerdquo and a geometry property whose name isldquopositionrdquo will also be added

Creating and Editing a GML Schema File | 105

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquoalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquoltpropertyNamegtrdquo

106 | Chapter 7 Schema Management

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

Creating and Editing a GML Schema File | 107

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For the first data property ltpropertyNamegt substitute ldquofidrdquo

For the first data property ltdataTypegt substitute ldquofdoint32rdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquofidrdquo to false

Set the content for xsdocumentation for ldquofidrdquo to ldquofeature idrdquo

For the second data property ltpropertyNamegt substitute ldquoaddressrdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquonamerdquo to false

Set the content for xsdocumentation for ldquoaddressrdquo to ldquoaddress of thebuildingrdquo

For ltlengthgt substitute ldquo64rdquo

For the geometry property ltpropertyNamegt substitute ldquopositionrdquo

For ltlist of FdoGeometricTypesgt substitute ldquopointrdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoposition of the buildingrdquo

The Final Result

After all the required substitutions the GML for the schema containing theBuildings feature is as follows

108 | Chapter 7 Schema Management

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquofidrdquo

Creating and Editing a GML Schema File | 109

type=rdquofdoint32rdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtfeature id

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoaddressrdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtaddress of the building

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquo64rdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquopositionrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquopositionrdquo

fdogeometricTypes=rdquopointrdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtposition of the buildingltxsdocu

mentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

110 | Chapter 7 Schema Management

Schema Management ExamplesExample Creating a Feature Schema

The following sample code creates an FdoFeatureSchema object calledldquoSampleFeatureSchemardquo The schema contains one class which has threeproperties The class and its properties conform to the table definition for theLakes feature in the Open GIS Consortium document 98-046r1 This tabledefinition is expressed in an XML format on page 10 of the document and isreproduced as follows

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtlakesltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstgraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtnameltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtshoreltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

The table definition whose name is ldquolakesrdquo is mapped to an FdoFeatureClassobject called ldquoSampleFeatureClassrdquo The column definition whose name isldquofidrdquo is mapped to an FdoDataPropertyDefinition object calledldquoSampleIdentityDataPropertyrdquo The column definition whose name is ldquonamerdquois mapped to an FdoDataPropertyDefinition object calledldquoSampleNameDataPropertyrdquo The column definition whose name is ldquoshorerdquois mapped to an FdoGeometricPropertyDefinition object calledldquoSampleGeometricPropertyrdquo

Schema Management Examples | 111

Create the ApplySchema command

FdoPtrltFdoIApplySchemagt sampleApplySchema

sampleApplySchema = (FdoIApplySchema )

connection-gtCreateCommand(FdoCommandType_ApplySchema)

Create the feature schema

FdoPtrltFdoFeatureSchemagt sampleFeatureSchema

sampleFeatureSchema = FdoFeatureSchemaCreate(LSampleFeatureS

chema LSample Feature Schema Description)

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

create a feature class ie a class containing a geometric

property set some class level properties

FdoPtrltFdoFeatureClassgt sampleFeatureClass

sampleFeatureClass = FdoFeatureClassCreate(LSampleFeatureClass

LSample Feature Class Description)

sampleFeatureClass-gtSetIsAbstract(false)

get a pointer to the feature classs property collection

this pointer is used to add data and other properties to the

class

FdoPtrltFdoPropertyDefinitionCollectiongt sampleFeatureClassProper

ties

sampleFeatureClassProperties = sampleFeatureClass-gtGetProperties()

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

get a pointer to the feature classs identity property collec

tion

this property is used to add identity properties to the feature

class

FdoPtrltFdoDataPropertyDefinitionCollectiongt sampleFeatureClassId

entityProperties

sampleFeatureClassIdentityProperties = sampleFeatureClass-

gtGetIdentityProperties()

create a data property that is of type Int32 and identifies

the feature uniquely

FdoPtrltFdoDataPropertyDefinitiongt sampleIdentityDataProperty

sampleIdentityDataProperty = FdoDataPropertyDefinitionCre

ate(LSampleIdentityDataProperty LSample Identity Data Property

Description)

sampleIdentityDataProperty-gtSetDataType(FdoDataType_Int32)

112 | Chapter 7 Schema Management

sampleIdentityDataProperty-gtSetReadOnly(false)

sampleIdentityDataProperty-gtSetNullable(false)

sampleIdentityDataProperty-gtSetIsAutoGenerated(false)

add the identity property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleIdentityDataProperty)

sampleFeatureClassIdentityProperties-gtAdd(sampleIdentityDataProp

erty)

create a data property that is of type String and names the

feature

FdoPtrltFdoDataPropertyDefinitiongt sampleNameDataProperty

sampleNameDataProperty = FdoDataPropertyDefinitionCreate(LSam

pleNameDataProperty LSample Name Data Property Description)

sampleNameDataProperty-gtSetDataType(FdoDataType_String)

sampleNameDataProperty-gtSetLength(64)

sampleNameDataProperty-gtSetReadOnly(false)

sampleNameDataProperty-gtSetNullable(false)

sampleNameDataProperty-gtSetIsAutoGenerated(false)

add the name property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleNameDataProperty)

create a geometric property

FdoPtrltFdoGeometricPropertyDefinitiongt sampleGeometricProperty

sampleGeometricProperty = FdoGeometricPropertyDefinitionCre

ate(LSampleGeometricProperty LSample Geometric Property Descrip

tion)

sampleGeometricProperty-gtSetGeometryTypes(FdoGeometricType_Sur

face)

sampleGeometricProperty-gtSetReadOnly(false)

sampleGeometricProperty-gtSetHasMeasure(false)

sampleGeometricProperty-gtSetHasElevation(false)

add the geometric property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleGeometricProperty)

identify it as a geometry property

sampleFeatureClass-gtSetGeometryProperty(sampleGeometricProperty)

add the feature class to the schema

sampleClassCollection-gtAdd(sampleFeatureClass)

point the ApplySchema command at the newly created feature

schema and execute

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

Schema Management Examples | 113

Example Describing a Schema and Writing It to an XML File

The following sample code demonstrates describing a schema and writing itto an XML file

create the DescribeSchema command

FdoPtrltFdoIDescribeSchemagt sampleDescribeSchema

sampleDescribeSchema = (FdoIDescribeSchema )

connection-gtCreateCommand(FdoCommandType_DescribeSchema)

executing the DescribeSchema command returns a feature

schema collection that is the set of feature schema which

reside in the DataStore

FdoPtrltFdoFeatureSchemaCollectiongt sampleFeatureSchemaCollection

sampleFeatureSchemaCollection = sampleDescribeSchema-gtExecute()

find the target feature schema in the collection write it

to an xml file and clear the collection

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleFeatureSchema-gtWriteXml(LSampleFeatureSchemaxml)

sampleFeatureSchemaCollection-gtClear()

Example Destroying a Schema

The following sample code demonstrates destroying a schema

create the DestroySchema command

FdoPtrltFdoIDestroySchemagt sampleDestroySchema

sampleDestroySchema = (FdoIDestroySchema )

connection-gtCreateCommand(FdoCommandType_DestroySchema)

destroy the schema

sampleDestroySchema-gtSetSchemaName(LSampleFeatureSchema)

sampleDestroySchema-gtExecute()

Example Creating a Schema Read In from an XML File

The following sample code demonstrates creating a schema read in from anXML file

sampleFeatureSchemaCollection-gtReadXml(LSampleFeatureSchemaxml)

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

sampleFeatureSchemaCollection-gtClear()

114 | Chapter 7 Schema Management

SampleFeatureSchemaxml

The following sample XML schema is the contents of the file written out bythe WriteXml method belonging to the FdoFeatureSchema class object thatwas created in the preceding sample code

Schema Management Examples | 115

ltxml version=10 encoding=UTF-8 gt

ltxsschema xmlnsxs=httpwwww3org2001XMLSchema

targetNamespace=httpfdo_customerSampleFeatureSchema

xmlnsfdo=httpfdoosgeoorgschema

xmlnsgml=httpwwwopengisnetgml

xmlnsSampleFeatureSchema=httpfdo_customer

SampleFeatureSchema

elementFormDefault=qualified

attributeFormDefault=unqualifiedgt

ltxsannotationgt

ltxsdocumentationgtSample Feature Schema Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsannotationgt

ltxselement name=SampleFeatureClass

type=SampleFeatureSchemaSampleFeatureClassType

abstract=false substitutionGroup=gml_Featuregt

ltxskey name=SampleFeatureClassKeygt

ltxsselector xpath=SampleFeatureClass gt

ltxsfield xpath=SampleIdentityDataProperty gt

ltxskeygt

ltxselementgt

ltxscomplexType name=SampleFeatureClassType

abstract=false

fdogeometryName=SampleGeometricProperty

fdohasMeasure=false

fdohasElevation=false

fdosrsName=SC_0

fdogeometricTypes=surfacegt

ltxsannotationgt

ltxsdocumentationgtSample Feature Class Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsdocumentationgtSample Geometric Property Descrip

tionltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=gmlAbstractFeatureTypegt

ltxssequencegt

ltxselement name=SampleIdentityDataProperty

default=

type=fdoint32gt

ltxsannotationgt

116 | Chapter 7 Schema Management

ltxsdocumentationgt

Sample Identity Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=SampleNameDataProperty

default=gt

ltxsannotationgt

ltxsdocumentationgt

Sample Name Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=xsstringgt

ltxsmaxLength value=64 gt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

Schema Management Examples | 117

118

Data Maintenance

This chapter provides information about using the FDO API to maintain data

Data Maintenance OperationsThe primary operations associated with data maintenance are

Inserting

Updating

Deleting

Transactions

Locking

NOTE Discussion of Transactions and Locking is deferred to a future release of thisdocument

Inserting Values

Preconditions

In a previous chapter we created a feature schema and added a feature class toit The feature class had three properties an integer data property a string dataproperty and a geometric property We applied this feature schema to the datastore We are now ready to create feature data objects which are instances ofthe feature class and insert them into the data store

8

119

Property Values in General

We can now create feature data objects which are instances of the featureclass by defining a set of property values corresponding to the propertiesdefined for the class and then inserting them into the data store

An FDO class correspondends roughly to a table definition in a relationaldatabase and a property of a class corresponds roughly to a column definitionin a table Adding the property values corresponds roughly to adding a rowin the table

The main distinction between a data value or geometry value and a propertyvalue is the order in which they are created A data value or geometry valueobject is created first and is then used to create a property value object Theproperty value object is then added to the value collection object belongingto the Insert command object Then the command is executed

An insert operation consists of the following steps

1 Create the insert command object (type FdoIInsert) this object can bereused for multiple insert operations

2 Point the insert command object at the feature class to which you areadding values (call the SetFeatureClassName(ltclassNamegt) method)

3 From the insert command object obtain a pointer using theGetPropertyValues() method to a value collection object (typeFdoPropertyValueCollection) You will add property values to the insertcommand object by adding values to the collection object

4 Create a data value (type FdoDataValue) or geometry value (typeFdoGeometryValue) object Creating the data value is straightforwardyou pass the string or integer value to a static Create() method Creatingthe geometry value is described in Geometry Property Values on page 121

5 Create a property value (type FdoPropertyValue) object which involvespassing the data value or geometry value object as an argument to a staticCreate() method

6 Add the property value object to the value collection object

7 Execute the Insert command

Data Property Values

A data value object contains data whose type is one of the following

Boolean

120 | Chapter 8 Data Maintenance

Byte

DateTime

Decimal

Double

Int16

Int32

Int64

Single (another floating point type)

String

Binary large object (BLOB)

Character large object (CLOB)

The data value object is added to the data property value object The dataproperty value object is added to the property value collection belonging tothe Insert command

Geometry Property Values

A geometry property value object contains a geometry in the form of a bytearray A geometry can be relatively simple for example a point (a single pairof ordinates) or quite complex for example a polygon (one or more arraysof ordinates) In the latter case a number of geometry objects are created andthen combined together to form the target geometry Finally the targetgeometry is converted to a byte array and incorporated into the geometryproperty value object

Creating a geometry value object consists of the following steps

1 Create a geometry value object (type FdoGeometryValue) using a staticCreate() method

2 Create a geometry factory object (type FdoAgfGeometryFactory) using astatic GetInstance() method This object is used to create the geometryobject or objects which comprise the target geometry

3 Create the required geometry object or objects using the appropriateCreateltgeometrygt method() belonging to the geometry factory object

Inserting Values | 121

4 Use the geometry factory object to convert the target geometry object toa byte array

5 Incorporate the byte array into the geometry property value object

Example Inserting an Integer a String and a Geometry Value

The following sample code shows how to insert an integer a string and ageometry value

122 | Chapter 8 Data Maintenance

create the insert command

FdoPtrltFdoIInsertgt sampleInsert

sampleInsert = (FdoIInsert )

connection-gtCreateCommand(FdoCommandType_Insert)

index returned by the operation which adds a value to the value

collection

FdoInt32 valueCollectionIndex = 0

point the Insert command to the target class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleInsert-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

get the pointer to the value collection used to add properties

to the Insert command

FdoPtrltFdoPropertyValueCollectiongt samplePropertyValues

samplePropertyValues = sampleInsert-gtGetPropertyValues()

create an FdoDataValue for the identity property value

FdoPtrltFdoDataValuegt sampleIdentityDataValue

sampleIdentityDataValue = FdoDataValueCreate(101)

add the FdoDataValue to the identity property value

FdoPtrltFdoPropertyValuegt sampleIdentityPropertyValue

sampleIdentityPropertyValue =

FdoPropertyValueCreate(LSampleIdentityDataProperty

sampleIdentityDataValue)

add the identity property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleIdentityPropertyValue)

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LBlue Lake)

add the FdoDataValue to the name property value

FdoPtrltFdoPropertyValuegt sampleNamePropertyValue

sampleNamePropertyValue =

FdoPropertyValueCreate(LSampleNameDataProperty

sampleNameDataValue)

add the name property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleNamePropertyValue)

create an FdoGeometryValue for the geometry property value

this polygon represents a lake which has an island

the outer shoreline of the lake is defined as a linear ring

the shoreline of the island is defined as a linear ring

the outer shoreline is the external boundary of the polygon

Inserting Values | 123

the island shoreline is an internal linear ring

a polygon geometry can have zero or more internal rings

FdoPtrltFdoGeometryValuegt sampleGeometryValue

sampleGeometryValue = FdoGeometryValueCreate()

create an instance of a geometry factory used to create the

geometry objects

FdoPtrltFdoFgfGeometryFactorygt sampleGeometryFactory

sampleGeometryFactory = FdoFgfGeometryFactoryGetInstance()

define the external boundary of the polygon the shoreline of

Blue Lake

FdoPtrltFdoILinearRinggt exteriorRingBlueLake

FdoInt32 numBlueLakeShorelineOrdinates = 10

double blueLakeExteriorRingOrdinates[] = 520 180 660 230

730 90 480 60 520 180

exteriorRingBlueLake = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numBlueLakeShorelineOrdinates

blueLakeExteriorRingOrdinates)

define the shoreline of Goose Island which is on Blue Lake

this is the sole member of the list of interior rings

FdoPtrltFdoILinearRinggt linearRingGooseIsland

FdoInt32 numGooseIslandShorelineOrdinates = 10

double gooseIslandLinearRingOrdinates[] = 590 180 670 180

670 130 590 130 590 180

linearRingGooseIsland = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numGooseIslandShorelineOrdinates

gooseIslandLinearRingOrdinates)

add the Goose Island linear ring to the list of interior rings

FdoPtrltFdoLinearRingCollectiongt interiorRingsBlueLake

interiorRingsBlueLake = FdoLinearRingCollectionCreate()

interiorRingsBlueLake-gtAdd(linearRingGooseIsland)

create the Blue Lake polygon

FdoPtrltFdoIPolygongt blueLake

blueLake =

sampleGeometryFactory-gtCreatePolygon(exteriorRingBlueLake

interiorRingsBlueLake)

convert the Blue Lake polygon into a byte array

and set the geometry value to this byte array

FdoByteArray geometryByteArray =

sampleGeometryFactory-gtGetAgf(blueLake)

sampleGeometryValue-gtSetGeometry(geometryByteArray)

add the Blue Lake FdoGeometryValue to the geometry property

value

FdoPtrltFdoPropertyValuegt sampleGeometryPropertyValue

124 | Chapter 8 Data Maintenance

sampleGeometryPropertyValue =

FdoPropertyValueCreate(LSampleGeometryProperty

sampleGeometryValue)

add the geometry property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleGeometryPropertyValue)

do the insertion

the command returns an FdoIFeatureReader

FdoPtrltFdoIFeatureReader sampleFeatureReader

sampleFeatureReader = sampleInsert-gtExecute()

Updating Values

After inserting (see Inserting Values on page 119) you can update the valuesThe update operation involves identifying a feature class (ldquotablerdquo) a featureclass object (ldquorowrdquo) and an object property (ldquocolumn in a rowrdquo) to be changedand supplying a new value for the object property to replace the old

First create an FdoIUpdate command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class object whose properties we want to updateand use the command objectrsquos SetFilter() method to attach the command toit Filters are discussed in Filter and Expression Languages on page 139

One of the data properties in the example SampleFeatureClass class definitionis an identity property whose name is ldquoSampleIdentityDataPropertyrdquo andwhose type is fdoInt32 This means that its value uniquely identifies thefeature class object that is the ldquorowrdquo Use the name of the identity propertyin the filter In the Insert operation the value of the identity property was setto be lsquo101rsquo The value of the filter that is needed is ldquo(SampleIdentityDataProperty = 101 )rdquo

Finally create a property value which contains the new value attach it tothe command object and then execute the command

Example Updating Property Values

The following is an example of updating property values

Updating Values | 125

FdoPtrltFdoIUpdategt sampleUpdate

sampleUpdate =

(FdoIUpdate )connection-gtCreateCommand(FdoCommandType_Update)

FdoInt32 numUpdated = 0

point the Update command at the target feature class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleUpdate-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

set the filter to identify which set of properties to update

sampleUpdate-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

get the pointer to the value collection used to add properties

to the Update command

we are reusing the samplePropertyValues object that we used

for the insert operation

samplePropertyValues = sampleUpdate-gtGetPropertyValues()

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LGreen Lake)

set the name and value of the property value

sampleNamePropertyValue-gtSetName(LSampleNameDataProperty)

sampleNamePropertyValue-gtSetValue(sampleNameDataValue)

add the name property value to the property value collection

owned by the Update command

samplePropertyValues-gtAdd(sampleNamePropertyValue)

execute the command

numUpdated = sampleUpdate-gtExecute()

Deleting Values

In addition to inserting (see Inserting Values on page 119) and updating (seeUpdating Values on page 125) values you can delete the values The deletionoperation involves identifying a feature class (ldquotablerdquo) whose feature classobjects (ldquorowsrdquo) are to be deleted

First create an FdoIDelete command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class objects that you want to delete and use thecommand objectrsquos SetFilter() method to attach the filter to it You can use thesame filter that was specified in the preceding section Updating Values onpage 125 Finally execute the command

126 | Chapter 8 Data Maintenance

Example Deleting Property Values

FdoPtrltFdoIDeletegt sampleDelete

sampleDelete =

(FdoIDelete )connection-gtCreateCommand(FdoCommandType_Delete)

FdoInt32 numDeleted = 0

sampleDelete-gt

SetFeatureClassName(LSampleFeatureSchemaSampleFeatureClass)

sampleDelete-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

numDeleted = sampleDelete-gtExecute()

Related Class TopicsThe following classes are used in the preceding Data Maintenance examples

FdoIInsert

FdoPropertyValueCollection

FdoDataValue

FdoPropertyValue

FdoGeometryValue

FdoFgfGeometryFactory

FdoILinearRing

FdoLinearRingCollection

FdoIPolygon

FdoByteArray

FdoIDelete

FdoIUpdate

For more information see FDO API Reference Help

Related Class Topics | 127

128

Performing Queries

This chapter describes how to create and perform queries In the FDO API you can use queriesto retrieve specific features from a data store

Creating a QueryYou create and perform queries using the FdoISelect class which is a memberof the Feature sub-package of the Commands package Queries are used toretrieve features from the data store and are executed against one class at atime The class is specified using the SetFeatureClassName() method inFdoIFeatureCommand The SetFeatureClassName can be used with feature andnon-feature classes

FdoISelect supports the use of filters to limit the scope of features returned bythe command This is done through one of the SetFilter methods available inthe FdoIFeatureCommand class The filter is similar to the SQL WHERE clausewhich specifies the search conditions that are applied to one or more classproperties

Search conditions include spatial and non-spatial conditions Non-spatial queriescreate a condition against a data property such as an integer or string Basiccomparisons (= lt gt gt= lt= =) pattern matching (like) and lsquoInrsquo comparisonscan be specified Spatial queries create a spatial condition against a geometryproperty Spatial conditions are enumerated in FdoSpatialCondition andFdoDistanceCondition

The feature reader (FdoIFeatureReader) is used to retrieve the results of a queryfor feature and non-feature classes To retrieve the features from the readeriterate through the reader using the FdoIFeatureReaderReadNext method()

9

129

Query ExampleIn the Data Maintenance chapter we created an instance of theFdoFeatureClass SampleFeatureClass and assigned values to its integer stringand geometry properties (see Example Inserting an Integer a String and aGeometry Value on page 122) The sample code in the following query exampleselects this instance and retrieves the values of its properties Specifically thesample code does the following

1 Creates the select command and

2 Points the select command at the target FdoFeatureClassSampleFeatureClass and

3 Creates a filter to identify which instance of SampleFeatureClass to selectand

4 Points the select command at the filter and

5 Executes the command which returns an FdoIFeatureReader object and

6 Loops through the feature reader object which contains one or morequery results depending on the filter arguments In the sample codeprovided there is only one result

7 Finally the code extracts the property values from each query result

130 | Chapter 9 Performing Queries

we have one FdoFeatureClass object in the DataStore

create a query that returns this object

create the select command

FdoPtrltFdoISelectgt sampleSelect

sampleSelect = (FdoISelect )

connection-gtCreateCommand(FdoCommandType_Select)

point the select command at the target FdoFeatureClass

SampleFeatureClass

sampleSelect-gtSetFeatureClassName(LSampleFeatureClass)

create the filter by

1 creating an FdoIdentifier object containing the name of

the identity property

FdoPtrltFdoIdentifiergt queryPropertyName

queryPropertyName =

FdoIdentifierCreate(LSampleIdentityDataProperty)

2 creating an FdoDataValue object containing the value of the

identity property

FdoPtrltFdoDataValuegt queryPropertyValue

queryPropertyValue = FdoDataValueCreate(101)

3 calling FdoComparisonConditionCreate() passing in the

the queryPropertyName an enumeration constant signifying an

equals comparison operation and the queryPropertyValue

FdoPtrltFdoFiltergt filter

filter = FdoComparisonConditionCreate(queryPropertyName

FdoComparisonOperations_EqualTo queryPropertyValue)

point the select command at the filter

sampleSelect-gtSetFilter(filter)

execute the select command

FdoPtrltFdoIFeatureReadergt queryResults

queryResults = sampleSelect-gtExecute()

declare variables needed to capture query results

FdoPtrltFdoClassDefinitiongt classDef

FdoPtrltFdoPropertyDefinitionCollectiongt properties

FdoInt32 numProperties = 0

FdoPropertyDefinition propertyDef

FdoPropertyType propertyType

FdoDataType dataType

FdoDataPropertyDefinition dataPropertyDef

FdoString propertyName = NULL

FdoPtrltFdoByteArraygt byteArray

FdoIGeometry geometry = NULL

FdoGeometryType geometryType = FdoGeometryType_None

FdoIPolygon polygon = NULL

Query Example | 131

FdoILinearRing exteriorRing = NULL

FdoILinearRing interiorRing = NULL

FdoIDirectPosition position = NULL

FdoInt32 dimensionality = FdoDimensionality_XY

FdoInt32 numPositions = 0

FdoInt32 numInteriorRings = 0

loop through the query results

while (queryResults-gtReadNext())

get the feature class object and its properties

classDef = queryResults-gtGetClassDefinition()

properties = classDef-gtGetProperties()

loop through the properties

numProperties = properties-gtGetCount()

for(int i = 0 i lt numProperties i++)

propertyDef = properties-gtGetItem(i)

get the property name and property type

propertyName = propertyDef-gtGetName()

propertyType = propertyDef-gtGetPropertyType()

switch (propertyType)

itrsquos a data property

case FdoPropertyType_DataProperty

dataPropertyDef =

dynamic_castltFdoDataPropertyDefinition gt

(propertyDef)

dataType = dataPropertyDef-gtGetDataType()

switch (dataType)

case FdoDataType_Boolean

break

case FdoDataType_Int32

break

case FdoDataType_String

break

default

break

itrsquos a geometric property

convert the byte array to a geometry

and determine the derived type of the geometry

case FdoPropertyType_GeometricProperty

byteArray = queryResults-gtGetGeometry(propertyName)

geometry =

sampleGeometryFactory-gtCreateGeometryFromAgf

(byteArray)

132 | Chapter 9 Performing Queries

geometryType = geometry-gtGetDerivedType()

resolve the derived type into a list of ordinates

switch (geometryType)

case FdoGeometryType_None

break

case FdoGeometryType_Point

break

case FdoGeometryType_LineString

break

case FdoGeometryType_Polygon

polygon = dynamic_castltFdoIPolygon gt(geometry)

exteriorRing = polygon-gtGetExteriorRing()

dimensionality = exteriorRing-

gtGetDimensionality()

numPositions = exteriorRing-gtGetCount()

double X Y Z M

for(int i=0 iltnumPositions i++)

position = exteriorRing-gtGetItem(i)

if (dimensionality amp FdoDimensionality_Z ampamp

dimensionality amp FdoDimensionality_M)

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

M = position-gtGetM()

else if (dimensionality amp FdoDimensionality_Z

ampamp (dimensionality amp FdoDimensionality_M))

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

else

X = position-gtGetX()

Y = position-gtGetY()

numInteriorRings = polygon-

gtGetInteriorRingCount()

for(int i=0 iltnumInteriorRings i++)

interiorRing = polygon-gtGetInteriorRing(i)

do same for interior ring as exterior ring

break

case FdoGeometryType_MultiPoint

break

Query Example | 133

case FdoGeometryType_MultiLineString

break

case FdoGeometryType_MultiPolygon

break

case FdoGeometryType_MultiGeometry

break

case FdoGeometryType_CurveString

break

case FdoGeometryType_CurvePolygon

break

case FdoGeometryType_MultiCurveString

break

case FdoGeometryType_MultiCurvePolygon

break

default

break

default

134 | Chapter 9 Performing Queries

Long TransactionProcessing

This chapter defines long transactions (LT) and long transaction interfaces and explains howto implement LT processing in your application

NOTE For this release the providers that support long transaction processing are AutodeskFDO Provider for Oracle and OSGeo FDO Provider for ArcSDE

What Is Long Transaction ProcessingA long transaction (LT) is an administration unit that is used to groupconditional changes to objects Depending on the situation such a unit cancontain conditional changes to one or to many objects Long transactions areused to modify as-built data in the database without permanently changing theas-built data Long transactions can be used to apply revisions or alternates toan object

A root long transaction is a long transaction that represents permanent dataand that has descendents Any long transaction has a root long transaction asan ancestor in its long transaction dependency graph A leaf long transactiondoes not have descendents

For more information about Oracle-specific long transaction versions andlocking see Locking and Long Transactions

10

135

Supported InterfacesIn the current release of FDO the following long transaction interfaces aresupported

FDOIActivateLongTransaction

FDOIDeactivateLongTransaction

FDOIRollbackLongTransaction

FDOICommitLongTransaction

FDOICreateLongTransaction

FDOIGetLongTransaction

These interfaces are summarized below For more information about theirusage supported methods associated enumerations and readers see the FDOAPI Reference Help

FDOIActivateLongTransaction

The FdoIActivateLongTransaction interface defines theActivateLongTransaction command which activates a long transaction wherefeature manipulation and locking commands operate on it Input to theactivate long transaction command is the long transaction name The Executeoperation activates the identified long transaction

FDOIDeactivateLongTransaction

The FdoIDeactivateLongTransaction interface defines theDeactivateLongTransaction command which deactivates the active longtransaction where feature manipulation and locking commands operate onit If the active long transaction is the root long transaction then no longtransaction will be deactivated

FDOIRollbackLongTransaction

The FdoIRollbackLongTransaction interface defines theRollbackLongTransaction command which allows a user to execute rollbackoperations on a long transaction Two different rollback operations areavailable Full and Partial

136 | Chapter 10 Long Transaction Processing

The operation is executed on all data within a long transaction and on all itsdescendents The data is removed from the database and all versions involvedin the process deleted

NOTE If the currently active long transaction is the same as the one beingcommitted or rolled back then if the commit or rollback succeeds the providerresets the current active long transaction to be the root long transaction If it doesnot succeed the active long transaction is left alone and current If the currentlyactive long transaction is not the same as the one being committed or rolled backthen it is not affected

FDOICommitLongTransaction

The FdoICommitLongTransaction interface defines theCommitLongTransaction command which allows a user to execute commitoperations on a long transaction Two different commit operations areavailable Full and Partial

The commit operation can be performed on a leaf long transaction only Along transaction is a leaf long transaction if it does not have descendents

FDOICreateLongTransaction

The FdoICreateLongTransaction interface defines the CreateLongTransactioncommand which creates a long transaction that is based on the currentlyactive long transaction There is always an active long transaction If the userhas not activated a user-defined long transaction then the root longtransaction is active

Input to the CreateLongTransaction command includes a name and descriptionfor the new long transaction The long transaction name submitted to thecommand has to be unique If it is not unique an exception is thrown

FDOIGetLongTransactions

The FdoIGetLongTransactions interface defines the GetLongTransactionscommand which allows the user to retrieve long transaction information Ifa long transaction name is submitted the command returns the informationfor the named long transaction only If no long transaction name is giventhe command retrieves the names of all available long transactions

For each returned long transaction the user has the option to retrieve a listof descendents andor ancestors

Supported Interfaces | 137

138

Filter and ExpressionLanguages

This chapter discusses the use of filters and filter expressions You can use filters and expressionsto specify to an FDO provider how to identify a subset of the objects in a data store

For more information and implementation details about the expression functions signaturesthe RDBMS-specific built-in support for some of the functions and the provider-specificsupport see the appendix Expression Functions

FiltersFDO uses filters through its commands (including provider-specific commands)to select certain features and exclude others

A filter is a construct that an application specifies to an FDO provider to identifya subset of objects of an FDO data store For example a filter may be used toidentify all Road type features that have 2 lanes and that are within 200 metresof a particular location Many FDO commands use filter parameters to specifythe objects to which the command applies For example a select commandtakes a filter to identify the objects that the application wants to retrieve or adelete command takes a filter to identify the objects that the application wantsto delete from the data store

When a command executes the filter is evaluated for each feature instance andthat instance is included in the scope of the command only if the filter evaluatesto True Filters may be specified either as text or as an expression tree Featureproviders declare their level of support for filters through the filter capabilitiesmetadata Query builders should configure themselves based on the filtercapabilities metadata in order to provide users with a robust user interface Formore information see What Is an Expression on page 19

11

139

ExpressionsFDO uses expressions through its commands (including provider-specificcommands) to specify input values in order to filter features In generalcommands in FDO do not support the SQL command language (the oneexception is the optional SQLCommand) However to facilitate ease of usefor application developers expressions in FDO can be specified using a textualnotation that is based syntactically on expressions and SQL WHERE clausesIn FDO expressions are not intended to work against tables and columns butagainst feature classes properties and relationships For example an expressionto select roads with four or more lanes might look like this

Lanes gt= 4

An expression is a construct that an application can use to build up a filterIn other words an expression is a clause of a filter or larger expression Forexample ldquoLanes gt=4 and PavementType = Asphaltrdquo takes two expressionsand combines them to create a filter

Filter and Expression TextIn general commands in FDO do not support the SQL command language(the one exception is the optional SQLCommand) However to facilitate easeof use for application developers expressions and filters in FDO can be specifiedusing a textual notation that is based syntactically on expressions and SQLWHERE clauses The biggest difference between this approach and SQL is thatthese clauses are not intended to work against tables and columns but againstfeature classes properties and relationships For example a filter to selectroads with four or more lanes might look like

Lanes gt= 4

Similarly a filter to select all PipeNetworks that have at least one Pipe in theproposed state might look like

Pipesstate = proposed

Furthermore a filter to select all existing parcels whose owner contains thetext ldquoSmithrdquo might look like

state = existing and owner like Smith

Finally a filter to select all parcels that are either affected or encroached uponby some change might look like

140 | Chapter 11 Filter and Expression Languages

state in (affected encroached)

Language IssuesThere are a number of language issues to be considered when working withclasses in the Filter Expression and Geometry packages

Provider-specific constraints on text

Filter grammar

Expression grammar

Filter and Expression keywords

Data types

Operators

Special characters

Geometry value

Provider-Specific Constraints on Filter andExpression Text

Some providers may have reserved words that require special rules when usedwith filters and expressions For more information see Oracle Reserved WordsUsed with Filter and Expression Text

Filter Grammar

The rules for entering filter expressions are described in the following sectionsusing BNF notation For more information about BNF notation seehttpcuiunigechdb-researchEnseignementanalyseinfoAboutBNFhtml

The FdoFilterParse() method supports the following filter grammar

Language Issues | 141

ltFiltergt = ( Filter )

| ltLogicalOperatorgt

| ltSearchConditiongt

ltLogicalOperatorgt = ltBinaryLogicalOperatorgt

| ltUnaryLogicalOperatorgt

ltBinaryLogicalOperatorgt =

ltFiltergt ltBinaryLogicalOperationsgt ltFiltergt

ltSearchConditiongt = ltInConditiongt

| ltComparisonConditiongt

| ltGeometricConditiongt

| ltNullConditiongt

ltInConditiongt = ltIdentifiergt IN ( ValueExpressionCollection

)

ltValueExpressionCollectiongt = ltValueExpressiongt

| ltValueExpressionCollectiongt ltValueExpressiongt

ltComparisonConditiongt =

ltExpressiongt ltComparisonOperationsgt ltExpressiongt

ltGeometricConditiongt = ltDistanceConditiongt

| ltSpatialConditiongt

ltDistanceConditiongt =

ltIdentifiergt ltDistanceOperationsgt ltExpressiongt ltdistancegt

ltNullConditiongt = ltIdentifiergt NULL

ltSpatialConditiongt =

ltIdentifiergt ltSpatialOperationsgt ltExpressiongt

ltUnaryLogicalOperatorgt = NOT ltFiltergt

ltBinaryLogicalOperationsgt = AND | OR

ltComparisionOperationsgt =

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

LIKE Like

ltDistanceOperationsgt = BEYOND | WITHINDISTANCE

ltdistancegt = DOUBLE | INTEGER

ltSpatialOperationsgt = CONTAINS | CROSSES | DISJOINT

| EQUALS | INTERSECTS | OVERLAPS | TOUCHES | WITHIN | COVEREDBY |

INSIDE

142 | Chapter 11 Filter and Expression Languages

Expression Grammar

The FdoExpressionParse() method supports the following expression grammar

ltExpressiongt = ( Expression )

| ltUnaryExpressiongt

| ltBinaryExpressiongt

| ltFunctiongt

| ltIdentifiergt

| ltValueExpressiongt

ltBinaryExpressiongt =

ltExpressiongt + ltExpressiongt

| ltExpressiongt - ltExpressiongt

| ltExpressiongt ltExpressiongt

| ltExpressiongt ltExpressiongt

ltDataValuegt =

TRUE

| FALSE

| DATETIME

| DOUBLE

| INTEGER

| STRING

| BLOB

| CLOB

| NULL

ltFunctiongt = ltIdentifiergt ( ltExpressionCollectiongt )

ltExpressionCollectiongt =

| ltExpressiongt

| ltExpressionCollectiongt ltExpressiongt

ltGeometryValuegt = GEOMFROMTEXT ( STRING )

ltIdentifiergt = IDENTIFIER

ltValueExpressiongt = ltLiteralValuegt | ltParametergt

ltLiteralValuegt = ltGeometryValuegt | ltDataValuegt

ltParametergt = PARAMETER | STRING

ltUnaryExpressiongt = - ltExpressiongt

Expression Operator Precedence

The precedence is shown in YACC notation that is the highest precedenceoperators are at the bottom

left Add Subtract

left Multiply Divide

left Negate

Expression Grammar | 143

Filter and Expression Keywords

The following case-insensitive keywords are reserved in the language that isthey cannot be used as identifier or function names

AND BEYOND COMPARE CONTAINS COVEREDBY CROSSES DATE

DISJOINT DISTANCE EQUALS FALSE GeomFromText IN INSIDE

INTERSECTS LIKE NOT NULL OR OVERLAPS RELATE SPATIAL TIME

TIMESTAMP TOUCHES TRUE WITHIN WITHINDISTANCE

Data Types

The available data types are described in this section

Identifier

An identifier can be any alphanumeric sequence of characters other than akeyword Identifiers can be enclosed in double quotes to allow specialcharacters and white space If you need to include a double quote characterinside an identifier double the character for example abcdef

Parameter

Parameters are defined by a colon followed by alphanumeric characters TheFDO filter language extends SQL to allow for a literal string to follow the colonto allow blanks (and other possibilities) for example Enter Name

Determine whether parameters are supported by the FDO Provider you areusing by checking SupportParameters on the Connection interface

String

Strings are literal constants enclosed in single quotes The FDO filter languagealso supports the special characters (left and right single quotes) that MicrosoftWord uses to automatically replace the single quote character typed from thekeyboard If you need to include a single quote character inside a string youcan double the character for example aaabbb

144 | Chapter 11 Filter and Expression Languages

Integer

Integers allow only decimal characters with an optional unary minus signUnary plus is not supported

(-)[0-9]

Double

Floating point numbers have a decimal point can be signed (-) and includean optional exponent (e[0-9])

NOTE If an integer is out of the 32-bit precision range it is converted to floatingpoint

Examples

-34

12345678901234567

12e13

DateTime

Date and time are parsed using the standard SQL literal strings

DATE YYYY-MM-DD

TIME HHMMSS[sss]

TIMESTAMP YYYY-MM-DD HHMMSS[sss]

For example

DATE 1971-12-24

TIMESTAMP 2003-10-23 110002

NOTE The BLOB and CLOB strings are currently not supported If you need tosupport binary input use parameters

Data Types | 145

Operators

The following operators are special characters common to SQL and mostprogramming languages

BinaryOperations

These binary operations are available

+ Add (for compatibility with SQL string concatenation may also be definedusing ldquo||rdquo)

- Subtract

Multiply

Divide

UnaryOperations

These unary operation are available

- Negate

Comparison Operations

These comparison operations are available

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

Operator Precedence

The following precedence is shown from highest to lowest

Negate NOT

Multiply Divide

Add Subtract

146 | Chapter 11 Filter and Expression Languages

EQ NE GT GE LT LE

AND

OR

Special Character

The following special characters are used in ExpressionCollections andValueExpressions to define function arguments and IN conditions

( Left Parenthesis

Comma

) Right Parenthesis

The Colon () is used in defining parameters and the Dot () can be includedin real numbers and identifiers

Geometry Value

Geometry values are handled using a function call GeomFromText(FGF Textstring) as is typical in an SQL query

The Autodesk extension to WKT referred to as FGF Text is a superset of WKT(that is you can enter WKT as valid FGF Text strings) Dimensionality isoptional It can be XY XYM XYZ or XYZM If it is not specified it is assumedto be XY For more information about FGF Text see FGF Text on page 158

NOTE Extra ordinates are ignored rather than generating an error during FGFtext parsing For example in the string ldquoPOINT (10 11 12)rdquo the lsquo12rsquo is ignoredbecause the dimensionality is assumed to be XY

The following is the grammar definition for FGF Text

ltFGF Textgt = POINT ltDimensionalitygt ltPointEntitygt

| LINESTRING ltDimensionalitygt ltLineStringgt

| POLYGON ltDimensionalitygt ltPolygongt

| CURVESTRING ltDimensionalitygt ltCurveStringgt

| CURVEPOLYGON ltDimensionalitygt ltCurvePolygongt

| MULTIPOINT ltDimensionalitygt ltMultiPointgt

Special Character | 147

| MULTILINESTRING ltDimensionalitygt ltMultiLineStringgt

| MULTIPOLYGON ltDimensionalitygt ltMultiPolygongt

| MULTICURVESTRING ltDimensionalitygt ltMultiCurveStringgt

| MULTICURVEPOLYGON ltDimensionalitygt ltMultiCurvePolygongt

| GEOMETRYCOLLECTION ltGeometryCollectiongt

ltPointEntitygt = ( ltPointgt )

ltLineStringgt = ( ltPointCollectiongt )

ltPolygongt = ( ltLineStringCollectiongt )

ltMultiPointgt = ( ltPointCollectiongt )

ltMultiLineStringgt = ( ltLineStringCollectiongt )

ltMultiPolygongt = ( ltPolygonCollectiongt )

ltGeometryCollection ( ltFGF Collection Textgt )

ltCurveStringgt = ( ltPointgt ( ltCurveSegmentCollectiongt ) )

ltCurvePolygongt = ( ltCurveStringCollectiongt )

ltMultiCurveStringgt = ( ltCurveStringCollectiongt )

ltMultiCurvePolygongt = ( ltCurvePolygonCollectiongt )

ltDimensionalitygt = default to XY

| XY

| XYZ

| XYM

| XYZM

ltPointgt = DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE DOUBLE

ltPointCollectiongt = ltPointgt

| ltPointCollection ltPointgt

ltLineStringCollectiongt = ltLineStringgt

| ltLineStringCollectiongt ltLineStringgt

ltPolygonCollectiongt = ltPolygongt

148 | Chapter 11 Filter and Expression Languages

| ltPolygonCollectiongt ltPolygongt

ltFGF Collection Textgt = ltFGF Textgt

| ltFGF Collection Textgt ltFGF Textgt

ltCurveSegmentgt = CIRCULARARCSEGMENT ( ltPointgt ltPointgt )

| LINESTRINGSEGMENT ( ltPointCollectiongt )

ltCurveSegmentCollectiongt = ltCurveSegmentgt

| ltCurveSegmentCollectiongt ltCurveSegmentgt

ltCurveStringCollectiongt = ltCurveStringgt

| ltCurveStringCollectiongt ltCurveStringgt

ltCurvePolygonCollectiongt = ltCurvePolygongt

| ltCurvePolygonCollectiongt ltCurvePolygongt

The only other token type is DOUBLE representing a double precision floatingpoint values Integer (non-decimal point) input is converted to DOUBLE inthe lexical analyzer

Examples of the Autodesk extensions include

POINT XY (10 11) equivalent to POINT (10 11)

POINT XYZ (10 11 12)

POINT XYM (10 11 12)

POINT XYZM (10 11 12 12)

GEOMETRYCOLLECTION (POINT xyz (10 11 12)POINT XYM (30 20 18)LINESTRING XYZM(1 2 3 4 3 5 15 3 20 20))

CURVESTRING (0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40))))

CURVESTRING (0 0 (CIRCULARARCSEGMENT (11 11 12 12)LINESTRINGSEGMENT (10 10 20 20 30 40)))

CURVESTRING (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 30 40)))

CURVESTRING XYZ (0 0 0 (LINESTRINGSEGMENT (10 10 1 20 20 1 30 401)))

MULTICURVESTRING ((0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40)))(00 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 20 20 30 40))))

Geometry Value | 149

CURVEPOLYGON ((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20) ARC(20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 40 40 90 90))))

MULTICURVEPOLYGON (((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90))))((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90)))))

150 | Chapter 11 Filter and Expression Languages

The Geometry API

This chapter describes the FdoGeometry API (hereafter called the ldquoGeometry APIrdquo) and explainsthe various geometry types and formats

IntroductionThe Geometry API supports specific Autodesk applications and APIs includingFDO (Feature Data Objects) This API consists of the following components

a Geometry Type package (all through fully encapsulated interfaces)

an Abstract Geometry Factory

a Concrete Geometry Factory for FGF

You can work with the Geometry API in several different ways

FGF (Feature Geometry Format)

FGF Text

Abstract Geometry Factory

FGF and WKBWKB is a memory layout used to store geometry features This format was createdby the OpenGIS organization to allow the efficient exchange of geometry databetween different components in an FDO system Most pieces of the originalspecification defining the WKB format are in the document 99-050pdf theOpenGIS Simple feature specification for OLECOM that can be found atwwwopengisorg

12

151

FGF is an extended version of the Well Known Binary (WKB) format The twoformats differ in the following ways

WKB defines a byte order of the data in every piece of geometry This isstored as a byte field which may change the memory alignment fromword to byte In FGF only one memory alignment type is supported whichis the same alignment type used by the NET framework and Windowsthe encoding uses the little-endian byte order format As a result the byteflag does not need to be stored

WKB is defined as a 2D format only This is insufficient to represent 3Dpoints polylines and polygons In FGF the dimension flag has been addedIn particular a flag is included for each geometry piece to indicate whetherthe geometry is 2D 3D or even 4D (storing a measure value as used bydynamic segmentation

FGF includes geometry types that are not yet covered by any WKBspecification

FGF Binary SpecificationIn this section the memory layout of each simple geometry type is describedThe format is based on the OGC specification which is built on the memorylayout of a C++ struct All arrays have a computable size and are inline theydo not point to a different location in memory This format allows streamingof geometry data

First the different data types their size and memory layout are discussed

152 | Chapter 12 The Geometry API

double == 8byte IEEE double number in little endian encoding

int == 4 byte integer in little endian encoding

the type of the geometry

enum GeometryType int

None = 0

Point = 1

LineString = 2

Polygon = 3

MultiPoint = 4

MultiLineString = 5

MultiPolygon = 6

MultiGeometry = 7

CurveString = 10

CurvePolygon = 11

MultiCurveString = 12

MultiCurvePolygon = 13

Coordinate Types

This is a bit field for example xym == coordinateDimensionalityXY |CoordinateDimensionalityM The following sequence defines the type ofcoordinates used for this object

enum CoordinateDimensionality FdoInt32

XY = 0

Z = 1

M = 2

Basic Geometry

The following sequence establishes the basic pure geometry

struct Geometry

int geomType

CoordinateDimensionality type

FGF Binary Specification | 153

Notation Definition

The following sequence defines a notation used to specify geometries withina byte stream

154 | Chapter 12 The Geometry API

Define a notation within this specification

int PositionSize(geometry)

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM ||

geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityZ)

return 3

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM | CoordinateDimensionalityZ)

return 4

return 2

struct Point Geometry

int geomType == GeometryTypePoint

CoordinateDimensionality type all types allowed

double[] coords size = PositionSize(this)

struct LineString

int geomType

CoordinateDimensionality type

int numPts gt0

double[] coords size = numPts PositionSize(this)

struct MultiPoint

int geomType

int numPoints gt 0

Point[] points size = numPoints

struct MultiLineString

int geomType

int numLineStrings gt= 0

LineString[] lineStrings size = numLineStrings

building block for polygons not geometry by itself

struct LinearRing

int numPts gt0

double[] coords size = numPts PositionSize(polygon)

FGF Binary Specification | 155

struct Polygon

int geomType

CoordinateDimensionality type

int numRings gt= 1 as there has to be at least one ring

LinearRing[] lineStrings size = numRings

struct MultiPolygon

int geomType

int numPolygons gt= 0

Polygon[] polygons size = numPolygons

struct MultiGeometry

int geomType

int numGeom gt= 0

Geometry[] geometry size = numGeom

enum CurveElementType int

LineString = 1

CircularArc = 2

struct CurveStringElement

int CurveElementType

struct LinearCurveStringElement

int CurveElementType

int length

double[] coords size = thislength PositionSize (this)

struct CircularArcCurveStringElement

int CurveElementType == CurveElmentTypeArc

double[] coords size = 2 PositionSize(this)

struct CurveString

int geomType

156 | Chapter 12 The Geometry API

CoordinateDimensionality type all types allowed

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct Ring

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct MultiCurveString

int geomType

int numCurveStrings gt= 0

CurveString[] curveStrings size = numCurveStrings

struct CurvePolygon

int geomType

CoordinateDimensionality type

int numRings gt=1 as there has to be at least one ring

Ring[] rings size = numRings

struct MultiCurvePolygon

int geomType

int numPolygons gt=0

CurvePolygon[] polygons size = numElements

In the following example a polygon is formatted within a byte arrayrepresenting the stream according to the FGF specification

FGF Binary Specification | 157

T = 3 stands for GeometryType == GeometryTypePolygon

CT = 0 stands for CoordinateDimensionality == CoordinateDimensionalityXY

NR = 2 stands for number of rings = 2

NP =3 stands for number of points = 3

FGF TextFGF Text is the textual analogue to the binary FGF format It is a superset ofthe OGC WKT format XY dimensionality is the default and is optional FGFText can be used to represent any geometry value in the Geometry API whetheror not it originates from the FGF geometry factory Conversions are done withthe following methods

FdoGeometryFactoryAbstract CreateGeometry(FdoString text)

FdoIGeometry GetText()rdquo

A BNF for the FGF textual specification is contained in the topic GeometryValue on page 147

Abstract and Concrete ClassesThe Geometry API is almost completely abstract It provides an object-orientedinterface to geometry values All objects in the Geometry API have factorymethods in the FdoGeometryFactorytAbstract class One defaultimplementation is provided based on FGF in-memory binary storage It isaccessible via the concrete class FdoFgfGeometryFactory

NOTE The FdoFgfGeometryFactory employes object pooling for many of the datatypes in the API While many methods appear to be executing ldquoCreaterdquo or ldquoGetrdquoactions they are in fact accessing object pools thus avoiding costly operationson the memory heap

All of the other classes in the Geometry API with the exception of two relateto the main abstract type FdoIGeometry They either derive from it or arecomponents of it

158 | Chapter 12 The Geometry API

The two exception concrete classes are

FdoDirectPositionImpl a small helper class implementingFdoIDirectPosition

FdoEnvelopeImpl a small helper class implementing FdoIEnvelope

Geometries in FGF format can be exchanged between software componentswithout depending on the Geometry API itself because they are not genuinegeometry ldquoobjectsrdquo FGF content is based on byte arrays It is handled througha simple FdoByteArray class that is not specific to geometry

Geometry TypesThe Geometry types comprise the Global Enum FdoGeometryType Thefollowing are Geometry types

0 FdoGeometryType_None Indicates no specific type used for ldquounknownrdquoldquodo not carerdquo or an incompletely constructed Geometry object

NOTE FdoGeometryType_ None does not represent an instantiable type An FDOclient should not expect an FDO provider to list support for it in its capabilities

1 FdoGeometryType_Point Point type (FdoIPoint)

2 FdoGeometryType_LineString LineString type (FdoILineString)

3 FdoGeometryType_Polygon Polygon type (FdoIPolygon)

4 FdoGeometryType_MultiPoint MultiPoint type (FdoIMultiPoint)

5 FdoGeometryType_MultiLineString MultiLineString type(FdoIMultiLineString)

6 FdoGeometryType_MultiPolygon MultiPolygon type (FdoIMultiPolygon)

7 FdoGeometryType_MultiGeometry MultiGeometry type(FdoIMultiGeometry)

10 FdoGeometryType_CurveString CurveString type (FdoICurveString)

11 FdoGeometryType_CurvePolygon CurvePolygon type(FdoICurvePolygon)

Geometry Types | 159

12 FdoGeometryType_MultiCurveString MultiCurveString type(FdoIMultiCurveString)

13 FdoGeometryType_MultiCurvePolygon MultiCurvePolygon type(FdoIMultiCurvePolygon

Mapping Between Geometry and GeometricTypes

The FDO API GeometricType enumeration of GeometricProperty gives theclient application some knowledge of which geometry types comprise thegeometric property so that it can present the user with an intelligent editorfor selecting styles for rendering the geometry In particular GeometricTyperelates to shape dimensionality of geometries allowed in FDO geometricproperties The nearest analogues in the Geometry API are

FdoDimensionality which pertains to ordinate (not shape) dimensionalityof geometry values

FdoGeometryType which has types whose abstract base types map toGeometric Type

The GeometricType enumeration is as follows

Point = 0x01 Point Type Geometry

Curve = 0x02 Line and Curve Type Geometry

Surface = 0x04 Surface (or Area) Type Geometry

Solid = 0x08 Solid Type Geometry

NOTE The enumeration defines a bit mask and the GetGeometricTypes andSetGeometricTypes methods take and return an integer This is to allow a geometryproperty to be of more than one type For example the callgeometricPropertySetGeometricTypes(Point | Surface)

would allow the geometric property to represent either point type geometry orsurface type geometry (polygons)

160 | Chapter 12 The Geometry API

Spatial ContextSpatial Context is a coordinate system with an identity Any geometries thatare to be spatially related must be in a common spatial context

Providing an identify for each coordinate system supports separate workspacessuch as schematic diagrams which are non-georeferenced However thereare also georeferenced cases In general two users may create drawings usingthe same default spatial parameters (for example rectangular and10000x10000) that have nothing to do with each other If their drawingsare to be put into a common database the spatial context capability of FDOpreserves the container aspect of the data along wih the spatial parameters

The FDO Spatial Context Commands are part of the FDO API They supportcontrol over Spatial Contexts in the following ways

Metadata control Creates and deletes Spatial Contexts

Active Spatial Context A session setting to specify which Spatial Contextto use by default while storingretrieving geometries and performing spatialqueries

There is a default Spatial Context for each database Its attributes (such ascoordinate system) are specified when the database is created This SpatialContext is the active one in any FDO session until a Spatial Context Commandis used to change this state The default Spatial Contextrsquos identifier numberis 0 (zero)

Spatial contexts have two tolerance attributes XYTolerance and ZToleranceThe tolerances are in distance units that depend on the coordinate system inuse Geodetic coordinate systems typically have ldquoon the groundrdquo linear distanceunits instead of the angular (that is degrees minutes or seconds) units usedfor positional ordinates The meter is the most common unit Mostnon-geodetic systems are rectilinear and use the same unit for positionalordinates and distances for example meters or feet

Specify Dimensionality When CreatingGeometries Using String Specifications

When creating a 3D geometry from string specifications you must specify theDimensionality argument XYZ explicitly because the default dimensionalityis XY and the geometry factory code will only process the first two ordinates

Spatial Context | 161

The following code successfully creates pointOne as a 3D point whereaspointTwo is created as a 2D point

FdoFgfGeometryFactory geometryFactory = FdoFgfGeometryFact

oryGetInstance()

FdoIPoint pointOne

pointOne = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT XYZ (1 2 3)rsquo)rdquo))

FdoPoint pointTwo

pointTwo = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT (1 2 3)rsquo)rdquo))

xmlFeatureFlags = FdoXmlFeatureFlagsCreate( None FdoXmlFlagsEr

rorLevel_Normal True FdoXmlFeatureFlagsConflictOption_Add )

Inserting Geometry ValuesFor information about geometry property values see Geometry Property Valueson page 121

See Example Inserting an Integer a String and a Geometry Value on page122 for a code example that shows how to insert a Geometry value

162 | Chapter 12 The Geometry API

FDO Cookbook

IntroductionThis chapter contains code samples of common operations

Some operations like connection must discuss differences among providersReferences are made to both Autodesk proprietary providers and open sourceproviders Providers whose name begins with ldquoAutodeskrdquo are available only incommercial releases of Autodesk products Providers whose name begins withldquoOSGeordquo are available in releases of open source software at httpfdoosgeoorgSome of the open source providers are also available in commercial releases ofAutodesk products

Recommendations

After iterating through readers such IFeatureReader IDataReaderISQLDataReader or DbUserReader call the Close() or Dispose() method Notdoing so may cause unhandled exceptions at some future time Be sure toenclose the statement that returns a reader in a try block so that you canclose the reader in the catch block

RegistryThe registry contains the list of providers that are available in a particular FDOinstallation FDO initializes the registry using the contents of the providersxmlfile that is co-located with the FDO binaries

13

163

The FeatureProviderRegistryFeatureProviderName elements in theprovidersxml file contain fully qualified provider names A fully qualifiedprovider name has four parts which are separated by dot (lsquorsquo) characters Theparts areltdomaingtltshortNamegtltmajorReleaseNumbergtltminorReleaseNumbergtThere are two domains Autodesk and OSGeo The former indicates proprietaryand the latter open source software

Use Cases

Get a fully qualified provider name in order to create a a connection Thefully qualified name contains version numbers so having a dictionary thatmaps generic provider names to the currently loaded fully qualified nameis useful

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager andProviderCollection

OSGeoFDO for IProviderRegistry

IProviderRegistry registry = FeatureAccessManagerGetProviderRe

gistry()

ProviderCollection providers = registryGetProviders()

Map provider short name to fully qualified name

Dictionaryltstring stringgt providerAbbrToFullName = new Diction

aryltstring stringgt()

string shortName = null

foreach (Provider provider in providers)

shortName = providerNameSplit()[1]

providerAbbrToFullName[shortName] = providerName

ConnectionThe connection object contains a connection string property that containsthe connection parameter names and values The connection string propertycan be set by using a connection property dictionary or by assigning a

164 | Chapter 13 FDO Cookbook

connection string directly to it The property dictionaryrsquos methods tell youthe names of the connection parameters their current values and theiroptionality

Some parameters must always be set for a connection to succeed for examplethe OSGeoSDF File parameter and the AutodeskOracle Username Passwordand Service parameters Some parameters need not be set if you accept thedefault value For example the SDF ReadOnly parameter has a default settingof false The Oracle DataStore parameter need not be set if your objective isto obtain the names of the available data stores within the data source In thiscase connecting with Username Password and Service parameters results ina pending connection You can then query the DataStore parameter to getthe list of available data stores set the DataStore parameter to the value ofone of the list members and open the connection again but this time to afully operational state If you already know the name of the data store thatyou want you can set its value at the outset and open the connection fullywithout the intervening step

The following table sets out the names of the connection parameters for eachprovider

Connection ParametersProvider

Username Password Service DataStoreAutodeskOracle

DefaultRasterFileLocationAutodeskRaster

Username Password Service DataStoreAutodeskSqlServer

Server Instance Username Password DatastoreOsGeoArcSDE

DefaultRasterFileLocationOSGeoGdal

Username Password Service OracleSchema KingFdoClassOSGeoKingOracle

Username Password Service DataStoreOSGeoMySQL

UserId Password DataSourceName ConnectionStringGenerateDefaultGeometryProperty

OSGeoODBC

DataSource ReadOnlyOSGeoOGR

Connection | 165

Connection ParametersProvider

Username Password Service DataStoreOSGeoPostGIS

File ReadOnlyOSGeoSDF

DefaultFileLocationOSGeoSHP

Username Password Service DataStoreOSGeoSQLServerSpatial

FeatureServer Username PasswordOSGeoWFS

FeatureServer Username Password DefaultImageHeightOSGeoWMS

Use Cases

Create a connection to get the provider capabilities See the Capabilitieson page 168 topic

Get a list of the connection parameters

Determine the optionality of a parameter

Set the value of a parameter

Open and close connections

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager

OSGeoFDO for IConnectionManager

OSGeoFDOConnections for IConnectionImp IConnectionInfoIConnectionPropertyDictionary ConnectionState

Create a Connection

The connection is created in the closed state

166 | Chapter 13 FDO Cookbook

IConnectionManager connMgr = FeatureAccessManagerGetConnectionMan

ager()

string fullName = providerAbbrToFullName[ldquoOraclerdquo]

IConnectionImp conn = connMgrCreateConnection(fullName) as ICon

nectionImp

Determine the Names of the Parameters

Before a connection can be opened the connection parameters must beidentified and given values You can query a connection to identify theseparameters The code block shows the retrieval of the connection parameternames into a string array

IConnectionInfo connInfo = connectionConnectionInfo

IConnectionPropertyDictionary properties = connInfoConnectionProp

erties

string[] names = propertiesPropertyNames

Determine the Optionality of a Parameter

The code block shows determining the optionality of the first connectionparameter

Boolean isRequired = propertiesIsPropertyRequired(names[0])

Set a Parameter

The code block shows the setting of the Username parameter

propertiesSetProperty(ldquoUsernamerdquo ldquoEXISTINGUSERrdquo)

Get the Connection String

The code block shows getting the connection string value from the connection

string connectionString = connectionConnectionString

Open and Close a Connection

The code block shows opening and closing a connection Valid connectionstates are Busy Closed Open and Pending

ConnectionState connState = connectionOpen()

ConnectionState connState = connectionClose()

Connection | 167

CapabilitiesThe following code samples are a representative listing of the capabilitymethods in each category For a complete listing consult the API referencedocumentation

The capabilities for a provider are statically defined You create a connectionobject for the provider and use this object to query the capabilities Theconnection does not have to be open

Some capabilities are defined as booleans for example support for theDISTINCT operator in a SQL SELECT statement Sample code for this is shownin the Command section Some capabilities are defined by arrays of enumeratedtype values for example the feature commands The presence of the capabilityis determined by testing each value in the array for its equality with one ofthe values in the enumerated type range sample code that tests for thepresence of the create data store command is shown in the Command section

The schema capabilities include a string type that defines the characters thatmay not appear in a schema name and two integer types that define themaximum decimal precision and scale

Use Cases

Get the capabilities of a provider

Write code that executes if the provider currently in use supports it

C

The following namespaces and types are used

OSGeoFDOCommands for CommandType

OSGeoFDOCommandsLocking for LockType

OSGeoFDOCommandsSpatialContext for SpatialContextExtentType

OSGeoFDOCommon for GeometryComponentType GeometryType

OSGeoFDOConnectionsCapabilities for ICommandCapabiltiesIConnectionCapabilities IExpressionCapabilities IFilterCapabilitiesIGeometryCapabilities IRasterCapabilities ISchemaCapabilitiesFunctionDefinitionCollection FunctionDefinitionReadOnlySignatureDefinitionCollection SignatureDefinition

168 | Chapter 13 FDO Cookbook

ReadOnlyArgumentDefinitionCollection ArgumentDefinitionThreadCapability

OSGeoFDOExpression for ExpressionType

OSGeoFDOFilter for ConditionType DistanceOperationsSpatialOperations

OSGeoFDOSchema for ClassType DataType PropertyType

Command

ICommandCapabilities cmdCapabilities = connCommandCapabilities

int[] commands = cmdCapabilitiesCommands

Boolean supportsSelectDistinct = cmdCapabilitiesSupportsSelectDis

tinct()

CommandType cmdType = (CommandType)commands[0]

Boolean supportsCreateDataStore = false

for (int i = 0 i lt commandsGetLength(0) i++)

if (commands[i] == (int)CommandTypeCommandType_CreateDataStore)

supportsCreateDataStore = true

Connection

IConnectionCapabilities connCapabilities = connConnectionCapabil

ities

LockType[] lockTypes = connCapabilitiesLockTypes

SpatialContextExtentType[] spatialContextExtentTypes = connCapab

ilitiesSpatialContextTypes

ThreadCapability threadCapability = connCapabilitiesThreadCapab

ility

Boolean supportsConfiguration = connCapabilitiesSupportsConfigur

ation()

Capabilities | 169

Expression

IExpressionCapabilities exprCapabilities = connectionExpression

Capabilities

ExpressionType[] expressionTypes = exprCapabilitiesExpression

Types

FunctionDefinitionCollection functions = exprCapabilitiesFunc

tions

FunctionDefinition function = functions[0]

ReadOnlySignatureDefinitionCollection signatureDefs = functionSig

natures

SignatureDefinition signatureDef = signatureDefs[0]

PropertyType returnPropertyType = signatureDefReturnPropertyType

if (returnPropertyType == PropertyTypePropertyType_DataProperty)

DataType returnDataType = signatureDefReturnType

ReadOnlyArgumentDefinitionCollection arguments = signatureDefAr

guments

ArgumentDefinition argDef = arguments[0]

PropertyType argPropertyType = argDefPropertyType

if (argPropertyType == PropertyTypePropertyType_DataProperty)

DataType argDataType = argDefDataType

Filter

IFilterCapabilities filterCapabilities = connFilterCapabilities

Boolean supportsGeodesicDistance = filterCapabilitiesSupports

GeodesicDistance()

ConditionType[] conditionTypes = filterCapabilitiesConditionTypes

DistanceOperations[] distanceOperations = filterCapabilitiesDis

tanceOperations

SpatialOperations[] spatialOperations = filterCapabilitiesSpatia

lOperations

170 | Chapter 13 FDO Cookbook

Geometry

IGeometryCapabilities geometryCapabilities = connGeometryCapabil

ities

GeometryType[] geometryTypes = geometryCapabilitiesGeometryTypes

GeometryComponentType[] geometryComponentTypes = geometryCapabil

itiesGeometryComponentTypes

int dimensionalities = geometryCapabilitiesDimensionalities

Boolean HasZ = (dimensionalities amp 1) == 1

Boolean HasM = (dimensionalities amp 2) == 2

NOTE The dimensionalities integer contains bit-field definitions XY is 0 becauseall spatial data has at least an X and Y coordinate Z is 1 and M is 2 Use bitwiseAND (amp) to combine and bitwise OR (|) to separate

Raster

IRasterCapabilities rasterCapabilities = connRasterCapabilities

Boolean supportsRaster = rasterCapabilitiesSupportsRaster()

Schema

ISchemaCapabilities schemaCapabilities = connSchemaCapabilities

DataType[] dataTypes = schemaCapabilitiesDataTypes

ClassType[] classTypes = schemaCapabilitiesClassTypes

string reservedCharactersForName = schemaCapabilitiesReservedChar

actersForName

int maximumDecimalPrecision = schemaCapabilitiesMaximumDecimalPre

cision

DataType[] supportedAutoGeneratedTypes = schemaCapabilitiesSuppor

tedAutoGeneratedTypes

DataType[] supportedIdentityPropertyTypes = schemaCapabilitiesSup

portedIdentityPropertyTypes

Boolean supportsAutoIdGeneration = schemaCapabilitiesSupportsAut

oIdGeneration

Data StoreThe Sql Server SQL Server Spatial Oracle MySQL PostGIS and SDF providerssupport the following data store commands create destroy and with theexception of SDF list SDF is a file-based provider and the rest areRDBMS-based

Data Store | 171

By default the Sql Server Oracle MySQL and SDF providers create data storesthat contain FDO metadata By default the SQL Server Spatial provider createsa data store that does not contain the FDO metadata To make this providercreate a data store that does contain the FDO metadata you must set theIDataStorePropertyDictionary property IsFdoEnabled to true The PostGISprovider creates a data store without the FDO metadata

A provider uses the FDO metadata to

Assign a default spatial context to a Geometric Property Definition duringschema creation

When connected to the SDF Provider the CreateDataStore command createsan SDF file and the DestroyDataStore command deletes it There cannot bemultiple data stores in an SDF file and so there is no need for the list commandUnlike the RDBMS-based providers you do not have to open a pendingconnection in order to create and execute the CreateDataStore commandBefore executing the DestroyDataStore command close the connection

For the RDBMS-based providers creating a data store means creating a containerwithin a database There can be many data stores within a database and thelist command lists them

To create a data store in one of these RDBMS-based providers you open apending connection using an administrator account name and password andthen execute the CreateDataStore command Once you have created the datastore you close the administrator connection and open a normal userconnection This time you give a value to the DataStore connection parameterand open the connection to a fully operational state Before executing theDestroyDataStore command close the connection unset the DataStoreconnection parameter and reopen it using the administrator account nameand password in the pending state

C

The following namespaces are used

OSGeoFDOCommandsDataStore

OSGeoFDOCommands

172 | Chapter 13 FDO Cookbook

ICreateDataStore createDS = connCreateCommand(CommandTypeCom

mandType_CreateDataStore) as ICreateDataStore

IDataStorePropertyDictionary properties = createDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

createDSExecute()

IListDataStores listDS = connCreateCommand(CommandTypeCommand

Type_ListDataStores) as IListDataStores

IDataStoreReader reader = listDSExecute()

IDestroyDataStore destroyDS = connCreateCommand(CommandTypeCom

mandType_DestroyDataStore) as IDestroyDataStore

IDataStorePropertyDictionary properties = destroyDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

destroyDSExecute()

User ManagementThe providers may be categorized into five groups with respect to usermanagement The grouping criteria is the method used to create the username

The first group consists of the AutodeskOracle provider which has access toan FDO API for user management

The second group consists of MySQL SqlServer and SQLServerSpatial Theseproviders support the SQLCommand which can be used to create users

The third group consists of ODBC A username and password may be quiredto connect depending on the back-end data store On XP you use the ODBCData Source Administrator tool to configure the username

The third group consists of the web server providers WFS and WMS Ausername and password may be required depending on the site

The fourth group consists of the file-based providers which do not require ausername and password

The FDO User Management API

The AutodeskOracle provider has access to an FDO API for user managementBefore you can add a user you must have added the f_user_role to the databaseas described in the Preparations topic at the beginning of this chapter Duringthe add user operation the f_user_role is assigned to the new user You must

User Management | 173

open a pending connection using an administrator account name and passwordto add or drop a user

C

The AutodeskFdoFdoUtilitiesUserMgr namespace is used

IUserManagerImp userMgr = new IUserManagerImp(connection)

userMgrAddUser(AUserName APassword)

DbUserReader reader = userMgrGetDbUsers()

userMgrDropUser(AUserName)

The SQLCommand Method for User Management

List usersDrop a userAdd a userProvider

SELECT user FROM mysqluserWHERE user = lsquoAUserNamersquo

DROP USER lsquoAUser-Namersquo

CREATE USER lsquoAUserNamersquoIDENTIFIED BY lsquoAPasswordrsquo

MySQL

GRANT ALL ON TO lsquoAUs-erNamersquo

SELECT name FROM sysserv-er_principals WHERE name =lsquoAUserNamersquo

EXEC sp_droploginloginame = lsquoAUser-Namersquo

CREATE LOGIN AUserNameWITH password = lsquoAPass-wordrsquo EXEC sp_addsrvrole-

SqlServer andSQLServerSpa-tial

member loginame = lsquoAUs-erNamersquo rolename =lsquosysadminrsquo

C

The code samples use the SQL syntax supported by MySQL in the stringspassed to the FDO API command calls

The following namespaces are used

OSGeoFDOCommandsSQL

OSGeoFDOCommands

174 | Chapter 13 FDO Cookbook

create a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = create user AUserName identified by

APassword

int returnVal = sqlCommandExecuteNonQuery()

sqlCommandSQLStatement = grant all on to AUserName

returnVal = sqlCommandExecuteNonQuery()

drop a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = drop user AUserName

int returnVal = sqlCommandExecuteNonQuery()

list users

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = select user from mysqluser where user

= AUserName

ISQLDataReader reader = sqlCommandExecuteReader()

readerClose()

Spatial ContextA spatial context specifies a coordinate system and an extent for a set ofgeometries The spatial context object has a Name property The value of theName property is assigned to the SpatialContextAssociation property of theGeometricPropertyDefinition object that defines a feature or non-featuregeometry belonging to a feature class In this way a coordinate system andextent is associated with geometry values inserted into the data store as partof instances of the class Example code showing this association is containedin the Basic Schema Operations on page 178 topic

NOTE It is worth emphasizing that each geometric property definiton in a featureclass definition can have a different spatial context This mechanism replaces thatof the active spatial context

The data stores created by the Oracle Sql Server MySQL and optionally theSQL Server Spatial providers contain metadata that supports the assignmentof a default spatial context to a Geometric Property Definition during schema

Spatial Context | 175

creation in the event that the user has not explicitly assigned one The attributevalues of the default spatial context are set out in the following table

ValueAttribute

DefaultName

ltno valuegtCoordinateSystem

ltno valuegtCoordinateSystemWkt

SpatialContextExtentType_StaticExtentType

POLYGON((-2000000 -2000000 2000000 -20000002000000 2000000 -2000000 2000000 -2000000 -2000000))

Extent

C

The code samples show how to create a spatial context and how to get thespatial contexts from a data store

The following namespaces are used

OSGeoFDOCommandsSpatialContext

OSGeoFDOGeometry

OSGeoFDOConnections

176 | Chapter 13 FDO Cookbook

get the spatial contexts from a data store

IGetSpatialContexts getSpatialContexts = connectionCreateCom

mand(CommandTypeCommandType_GetSpatialContexts) as IGetSpatialCon

texts

ISpatialContextReader reader = getSpatialContextsExecute()

string name = null

string coordSys = null

string wellKnownText = null

string desc = null

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IGeometry geom = null

string extent = null

SpatialContextExtentType extentType

double xyTolerance

double zTolerance

while (readerReadNext())

name = readerGetName()

coordSys = readerGetCoordinateSystem()

wellKnownText = readerGetCoordinateSystemWkt()

desc = readerGetDescription()

geom = geomFactoryCreateGeometryFromFgf(readerGetExtent())

extent = geomText

extentType = readerGetExtentType()

xyTolerance = readerGetXYTolerance()

zTolerance = readerGetZTolerance()

readerDispose()

Spatial Context | 177

create a spatial context whose coordinate system is WGS84 and

whose extent is the maximum

create the extent

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

ICreateSpatialContext createSpatialContext = connectionCreateCom

mand(CommandTypeCommandType_CreateSpatialContext) as ICreateSpa

tialContext

createSpatialContextCoordinateSystem =

createSpatialContextCoordinateSystemWkt = wgs84Wkt

createSpatialContextDescription = This Coordinate System is used

for GPS

a static extent is defined once and never changed

a dynamic extent grows to accommodate the geometries added to

the data store

createSpatialContextExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

createSpatialContextExtent = extent

the value of Name is assigned to the SpatialContextAssociation

attribute of a GeometricPropertyDefinition object during the

creation of the logical feature schema

in this way a coordinate system and extent is associated with

the geoemtries

createSpatialContextName = WGS84 Spatial Context

createSpatialContextExecute()

Basic Schema OperationsAll providers allow you to describe a schema but only SDF SHP MySQLPostGIS SqlServer SQLServerSpatial KingOracle and Oracle allow you toapply and destroy a schema

178 | Chapter 13 FDO Cookbook

C

The code samples show how to describe apply and destroy a schema

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommands

OSGeoFDOSchema

describe a schema

IDescribeSchema descSchema = connCreateCommand(CommandTypeCom

mandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

FeatureSchema schema = schemas[0]

ClassCollection classes = schemaClasses

Class featureClass = classes[0]

PropertyDefinitionCollection properties = featureClassProperties

PropertyDefinition property = properties[0]

PropertyType propertyType = propertyPropertyType

if (propertyType == PropertyTypePropertyType_DataProperty)

DataPropertyDefinition dataPropDef = property as DataPropertyDefin

ition

DataType dataType = dataPropDefDataType

Basic Schema Operations | 179

create and apply a schema

FeatureSchema schema = new FeatureSchema(AnApplicationSchema

This schema contains one feature class)

FeatureClass featClass = new FeatureClass(AFeatureClass This

feature class contains one identity property one data property and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(ID

This is the identity property)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = true

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition int32Prop = new DataPropertyDefini

tion(Int32Prop This is an Int32 property)

int32PropDataType = DataTypeDataType_Int32

propertiesAdd(int32Prop)

add the feature geometry

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(FeatGeomProp This is the feature geometry)

associate this geometric property with a spatial context

you must have already added the named context to the data store

if this property is not set it is assigned the default spatial

context

see the Spatial Context topic to read a description of the de

fault spatial context

featGeomPropSpatialContextAssociation = XY-M Spatial Context

by default this geometric property can contain geometries that

may be classified as point curve surface or solid

also by default this geometric property cannot contain geomet

ries that have a Z ordinate or a measure attribute

propertiesAdd(featGeomProp)

without the following line you would be adding a non-feature

geometry

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

apply the schema

180 | Chapter 13 FDO Cookbook

IApplySchema applySchema = connCreateCommand(CommandTypeCommand

Type_ApplySchema) as IApplySchema

applySchemaFeatureSchema = schema

applySchemaExecute()

destroy the schema

IDestroySchema destroySchema = connCreateCommand(CommandTypeCom

mandType_DestroySchema) as IDestroySchema

destroySchemaSchemaName = AnApplicationSchema

destroySchemaExecute()

Insert DataAll providers except Gdal Raster WFS and WMS allow you to insert data

C

The code sample shows how to insert a feature consisting of a data value anda geometry value

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOGeometry

Insert Data | 181

Identifier className = new Identifier(FeatureClass)

IInsert insert = connCreateCommand(CommandTypeCommandType_Insert)

as IInsert

insertFeatureClassName = className

PropertyValueCollection values = insertPropertyValues

add the Int32 value to the insert command

int32Value = new Int32Value(5)

int32PropVal = new PropertyValue(Int32Prop int32Value)

valuesAdd(int32PropVal)

add the feature geometry to the insert command

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

DirectPositionImpl position1 = new DirectPositionImpl(10 10)

IPoint point = geomFactoryCreatePoint(position1)

GeometryValue geomVal = new GeometryValue(geomFactoryGet

Fgf(point))

PropertyValue geomPropVal = new PropertyValue(FeatGeomProp

geomVal)

valuesAdd(geomPropVal)

insert the feature

IFeatureReader reader = insertExecute()

readerClose()

Select DataAll providers allow you to select data

C

In the following code sample the filter is set to retrieve values for each featurein the database Without adding a computed identifier to the select commandrsquosproperty collection the select command would return all of the propertyvalues for each feature in the database In this example the computed identifiercontains a function expression that converts the DateTime value in theDateTimeProp property to a string and returns the string So the select returnsa set of DateTime strings

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

182 | Chapter 13 FDO Cookbook

OSGeoFDOFilter

Identifier className = new Identifier(FeatureClass)

ISelect select = connCreateCommand(CommandTypeCommandType_Select)

as ISelect

selectFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectFilter = filter

ComputedIdentifier computedId = ExpressionParse((ToString(Date

TimeProp) as computedId)) as ComputedIdentifier

selectPropertyNamesAdd(computedId)

IFeatureReader reader = selectExecute()

readerClose()

Select Aggregate DataAll providers except the PostGIS provider allow you to select aggregate data

C

In the following code sample the filter is set to retrieve values for each featurein the database The computed identifier contains a function expression thattakes the average of all of the values in the property whose name is Int32Propand returns a double

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

Select Aggregate Data | 183

Identifier className = new Identifier(FeatureClass)

ISelectAggregates selectAggregates = connCreateCommand(Command

TypeCommandType_SelectAggregates) as ISelectAggregates

selectAggregatesFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectAggregatesFilter = filter

ComputedIdentifier computedId = ExpressionParse((Avg(Int32Prop)

as computedId)) as ComputedIdentifier

selectAggregatesPropertyNamesAdd(computedId)

IDataReader reader = selectAggregatesExecute()

readerClose()

Delete DataAll providers except Gdal Raster WFS and WMS allow you to delete data

C

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

delete all of the data

ID is the name of the identity property

Filter filter = FilterParse(ID gt= 0)

Identifier className = new Identifier(FeatureClass)

IDelete delete = connCreateCommand(CommandTypeCommandType_Delete)

as IDelete

deleteFeatureClassName = className

deleteFilter = filter

int numDeleted = deleteExecute()

Schema OverridesWhen FDO connects to a datastore with an existing schema and describes theschema it maps the native data types to FDO data types to create a default

184 | Chapter 13 FDO Cookbook

physical to logical schema mapping You can create a schema mapping thatoverrides the default FDO mapping This schema override must be appliedevery time that you connect to the data store Use the providerrsquos SchemaOverride API to write a program that defines the overrides and writes themto an XML configuration file Thereafter before opening the connection tothe provider set the connection objectsrsquos configuration property to point tothe XML configuration file

The key elements to a schema override are an FDO feature schema and amapping of column names in the existing table to property names in the FDOfeature schema The ODBC provider supports the mapping of two columnnames in an existing table to a 2D FDO point geometry property and optionallysupports the mapping of three columns to a 3D point geometry property Inthe event that the mapping includes an FDO geometry property a spatialcontext definition should be provided

The description given here is based on sample code written to define a schemaoverride for a table in a Microsoft Access database The following table showsthe name of the column in the Access database which is the same as thedefault FDO property name the FDO property name assigned by the schemaoverride a description of the contents of the column the FDO data typeassigned by the default schema mapping and the FDO data type assigned bythe schema override

The default schema mapping of the CITY_ID and POPULATION columns areoverriden to assign them different data types than the default ones and togive them different names A change in case counts as a change in name Thedefault schema mapping of the LATITUDE and LONGITUDE columns areoverriden because they are combined into a single property that has a differentname and a different type than the defaults The default schema mapping ofthe NAME COUNTRY and CAPITAL columns are overriden to assign themdifferent names than the defaults The default schema mapping of the URLcolumn is not overriden and retains its default type and name

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

Int64Int16consecutive sequence of integersfrom 1 to lt 1000

IdCITY_ID

StringStringNamesNameNAME

StringStringNamesCountryCOUNTRY

Schema Overrides | 185

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

StringStringlsquoNrsquo or lsquoYrsquoCaptialCAPITAL

Not over-riden

StringnullNot over-riden

URL

Int32Doublepositive integers lt 17000000PopulationPOPULATION

GeometryDoublepositive and negative decimalsGeometryLATITUDE

GeometryDoublepositive and negative decimalsGeometryLONGITUDE

First a conceptual view of how to create the XML configuration file for aschema override is presented and then a code view is presented The overrideincludes a geometry property and so a spatial context is defined as well

1 Open the XML file

2 Create a spatial context for the geometry and write it to the XML file

3 Create the FDO feature schema and write it to the XML file

4 Create a connection to the provider and get a reference to theconnectionrsquos physical schema mapping

5 Use the reference to the connectionrsquos physical schema mapping and theSchema Override API to create the schema override whereby the logicalfields in the feature schema are associated with columns in the databasetable

6 Write the schema override to the XML file

7 Close the XML file

C

The following namespaces are used

OSGeoFDOCommonIo

OSGeoFDOCommonXml

186 | Chapter 13 FDO Cookbook

OSGeoFDOGeometry

OSGeoFDOSchema

Create the XML Schema Override Configuration File

Open the XML File

IoFileStream writeFileStream = new IoFileStream(Citiesxml w)

XmlWriter writer = new XmlWriter(writeFileStream)

Create a Spatial Context and Write It to the XML File

XmlSpatialContextFlags flags = new XmlSpatialContextFlags()

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(writer flags)

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

spatialContextWriterCoordinateSystem = WGS 84

spatialContextWriterCoordinateSystemWkt = GEOGCS [ Longitude

Latitude (WGS 84) DATUM [WGS 84 SPHEROID [WGS 84

6378137 298257223563]] PRIMEM [ Greenwich 0000000 ] UNIT

Decimal Degree 001745329251994330]]

spatialContextWriterDescription = This Coordinate System is used

for GPS

spatialContextWriterExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

spatialContextWriterExtent = extent

spatialContextWriterName = WGS84

spatialContextWriterXYTolerance = 0001

the next line writes the XML declaration the opening tag for

the fdoDataStore element

and the gmlDerivedCRS element to the XML file

spatialContextWriterWriteSpatialContext()

Schema Overrides | 187

Create the Feature Schema and Write It to the XML File

188 | Chapter 13 FDO Cookbook

FeatureSchema schema = new FeatureSchema(World Logical feature

schema)

FeatureClass featClass = new FeatureClass(Cities This feature

class contains one identity property many data properties and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(Id

This is the unique id number for the city)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = false

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition nameProp = new DataPropertyDefini

tion(Name This is the name of the City)

namePropDataType = DataTypeDataType_String

namePropLength = 64

propertiesAdd(nameProp)

DataPropertyDefinition countryProp = new DataPropertyDefini

tion(Country This is country that contains the city)

countryPropDataType = DataTypeDataType_String

countryPropLength = 64

propertiesAdd(countryProp)

DataPropertyDefinition populationProp = new DataPropertyDefini

tion(Population This is the population of the city)

populationPropDataType = DataTypeDataType_Int32

propertiesAdd(populationProp)

DataPropertyDefinition capitalProp = new DataPropertyDefini

tion(Capital This is Y or N to say whether the city is the

capital of the country)

capitalPropDataType = DataTypeDataType_String

capitalPropLength = 1

propertiesAdd(capitalProp)

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(Geometry This is the feature geometry)

featGeomPropGeometryTypes = (int)GeometricTypeGeometric

Type_Point

featGeomPropHasElevation = false

featGeomPropHasMeasure = false

propertiesAdd(featGeomProp)

Schema Overrides | 189

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

the next line writes the xsschema element to the XML file

schemaWriteXml(writer)

190 | Chapter 13 FDO Cookbook

Create the Physical Schema Mapping and Write It to the XML File

Schema Overrides | 191

set the connection to point

at the Microsoft Access database file

whose Data Source Name (DSN) has been

defined using the Data Sources (ODBC)

Windows XP administrative tool

connectionConnectionString = DataSourceName= + dataSourceName

get a reference to the PhysicalSchemaMapping object contained

in the connection

PhysicalSchemaMapping connectionSchemaMapping = connectionCreateS

chemaMapping()

use that reference to create an override physical schema mapping

the override definition associates columns in the columns of

the Access database with property names in the FDO feature schema

OvPhysicalSchemaMapping mapping = new OvPhysicalSchemaMapping(con

nectionSchemaMapping false)

mappingName = World

OvClassCollection overrideClasses = mappingClasses

OvClassDefinition overrrideClassDef = new OvClassDefinition(Cit

ies)

OvPropertyDefinitionCollection overrideProperties = overrride

ClassDefProperties

associate the table in the Access database with the override

class definition

OvTable table = new OvTable(Cities)

overrrideClassDefTable = table

associate the columns in the table in the Access database with

the properties in the FDO feature schema

OvColumn column = null

OvGeometricPropertyDefinition overridGeomProp = new OvGeometric

PropertyDefinition(Geometry)

overridGeomPropGeometricColumnType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricColumnTypeOvGeometricColumnType_Double

overridGeomPropGeometricContentType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricContentTypeOvGeometricContentType_Ordin

ates

overridGeomPropXColumnName = LONGITUDE

overridGeomPropYColumnName = LATITUDE

overridePropertiesAdd(overridGeomProp)

OvDataPropertyDefinition overrideIdProp = new OvDataPropertyDefin

ition(Id)

column = new OvColumn(CITY_ID) overrideIdPropColumn = column

overridePropertiesAdd(overrideIdProp)

192 | Chapter 13 FDO Cookbook

OvDataPropertyDefinition overrideNameProp = new OvDataPropertyDefin

ition(Name)

column = new OvColumn(NAME)

overrideNamePropColumn = column

overridePropertiesAdd(overrideNameProp)

OvDataPropertyDefinition overrideCountryProp = new OvDataProperty

Definition(Country)

column = new OvColumn(COUNTRY)

overrideCountryPropColumn = column

overridePropertiesAdd(overrideCountryProp)

OvDataPropertyDefinition overridePopulationProp = new OvDataProp

ertyDefinition(Population)

column = new OvColumn(POPULATION)

overridePopulationPropColumn = column

overridePropertiesAdd(overridePopulationProp)

OvDataPropertyDefinition overrideCapitalProp = new OvDataProperty

Definition(Capital)

column = new OvColumn(CAPITAL)

overrideCapitalPropColumn = column

overridePropertiesAdd(overrideCapitalProp)

overrideClassesAdd(overrideClassDef)

write the override definition to the XML file

XmlFlags flags = new XmlFlags()

the next line writes the SchemaMapping element to the XML file

mappingWriteXml(writer flags)

mappingDispose()

Write the Closing Tag and Close the XML File

the next line writes the closing tag of the fdoDataStore ele

ment to the XML file

writerWriteEndElement()

writerClose()

writerDispose()

writeFileStreamClose()

writeFileStreamDispose()

Configure a Connection to Use the Schema Override

The connection object contains a property whose value points to the XMLconfiguration file

Schema Overrides | 193

IConnection connection = connMgrCreateConnection(providerName)

IoFileStream configurationFileStream = new IoFileStream(Cit

iesxml r)

connectionConfiguration = configurationFileStream

connectionConnectionString = DataSourceName= + dataSourceName

connectionOpen()

Xml SerializeDeserializeThis code sample serializes the spatial context and feature schema of a datastore to an xml file and then deserializes it in another data store

C

This is the C code

Namespaces

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommonIo

OSGeoFDOCommonXml

OSGeoFDOSchema

OSGeoFDOXml

194 | Chapter 13 FDO Cookbook

Serialize

open the xml file

XmlWriter xmlWriter = new XmlWriter(xmlFilename)

serial the spatial contexts

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(xmlWriter)

XmlSpatialContextSerializerXmlSerialize(connection spatialContex

tWriter)

serialize the feature schemas

IDescribeSchema descSchema = connectionCreateCommand(Command

TypeCommandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

schemasWriteXml(xmlWriter)

clean up

spatialContextWriterDispose()

xmlWriterDispose()

C | 195

Deserialize

deserialize the spatial contexts

IoFileStream fileStream = new IoFileStream(xmlFilename r)

XmlReader xmlReader = new XmlReader(fileStream)

XmlSpatialContextReader xScReader = new XmlSpatialContextReader(xm

lReader)

XmlSpatialContextSerializerXmlDeserialize(connection xScReader)

fileStreamReset()

deserialize the schema

FeatureSchemaCollection schemas = new FeatureSchemaCollec

tion(null)

schemasReadXml(fileStream)

IApplySchema applySchema = connectionCreateCommand(CommandTypeCom

mandType_ApplySchema) as IApplySchema

FeatureSchema schema = null

for (int i = 0 i lt schemasCount i++)

schema = schemasget_Item(i)

applySchemaFeatureSchema = schema

applySchemaExecute()

fileStreamReset()

clean up

xmlReaderDispose()

fileStreamClose()

GeometryThe geometry code samples are divided into two parts The first is constructinggeometries The second is deconstructing them that is extracting informationfrom the geometry objects

Construction

Geometries can be constructed using a set of scaffolding classes which includesa geometry factory class or they can be constructed using the geometry factoryclass from text specifications The syntax for the text specifications is describedin the Geometry Value section in the Filter and Expression Languages chapter

196 | Chapter 13 FDO Cookbook

What follows here is a description of geometry construction using thescaffolding classes

Some geometries are constructed using a two step procedure First createcoordinates and then create the geometry Some geometries require anintermediate step Use the coordinates to create subcomponents and then usethe subcomponents to create the geometry The construction of somegeometries requires the use of helper collection classes Some of these classesare collections of geometries and some are collections of geometrysubcomponents

Simple geometries like point and line are constructed directly from coordinatesComplex geometries like curved lines and polygons are constructed fromgeometry subcomponents like arc and line segments and rings In generalsubcomponents are constructed from coordinates The exception is the ringwhich is constructed from arc and line segments The glue is the helpercollection classes for coordinates segments and rings

A geometry object may consist of homogeneous or heterogeneous aggregationsof points lines and polygons The glue is helper collection classes for pointslines and polygons

C Namespaces

The following namespaces are used

OSGeoFDOCommon

OSGeoFDOGeometry

C Geometry Scaffolding Classes

The scaffolding classes used to construct the simple complex and aggregategeometries are the following

the IDirectionPosition class used to construct positions (coordinates)

the FgfGeometryFactory class used to construct the geometrysubcomponents and geometries

the geometry subcomponent classes ILineStringSegmentICircularArcSegment ILinearRing and IRing

Construction | 197

the helper collection classes PointCollection LineStringCollectionCurveSegmentCollection LinearRingCollection RingCollectionPolygonCollection CurvePolygonCollection and GeometryCollection

IDirectPositionImpl

The IDirectPosition is the basic building block of geometries Use its constructorto define a coordinate Use instances of it to define the IPoint and ILineStringgeometries or to define the geometry subcompoonents ILinearRingICircularArcSegment and ILineStringSegment

DirectPositionImpl pos00 = new DirectPositionImpl(00 00)

FgfGeometryFactory

Use an instance of this class to do the following

create geometry subcomponents used to construct IGeometry-based objects

create IGeometry-based objects

convert IGeometry-based objects into binary-formatted geometries usedfor data store inserts

convert binary-formatted geometries retrieved during data store queriesinto IGeometry-based objects

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

Geometry Subcomponents

The following subcomponents are used in the construction of geometries andgeometry subcomponents

The ICircularArcSegment and ILineStringSegment subcomponents are usedto construct the ICurveString geometry and the IRing geometrysubcomponent

The ILinearRing subcomponent is used to contruct the IPolygon geometry

The IRing subcomponent is used to construct the ICurvePolygon geometry

198 | Chapter 13 FDO Cookbook

ICircularArcSegment

The creation of an instances uses IDirectPositionImpl objects whichrespectively define a start position a mid point and an end position for thearc

ICircularArcSegment as012122 = geomFactoryCreateCircularArcSeg

ment(pos01 pos21 pos22)

ILineStringSegment

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos23)

positionsAdd(pos30)

positionsAdd(pos33)

ILineStringSegment ls233033 = geomFactoryCreateLineStringSeg

ment(positions)

positionsClear()

ILinearRing

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos01)

positionsAdd(pos21)

positionsAdd(pos12)

positionsAdd(pos01)

ILinearRing lr01211201 = geomFactoryCreateLinearRing(positions)

positionsClear()

IRing

An IRing is constructed using a CurveSegmentCollection This collection cancontain ICircularArcSegment and ILineStringSegment objects

curveSegmentsAdd(as1340n20)

curveSegmentsAdd(lsn2013)

IRing rAs1340n20Lsn2013 = geomFactoryCreateRing(curveSegments)

curveSegmentsClear()

Construction | 199

Collection Classes

The following collection classes are used during the construction of the variousgeometries

Contains IDirectPositionImpl ojbects

DirectPositionCollection positions = new DirectPositionCollec

tion()

Contains IPoint objects

PointCollection points = new PointCollection()

Contains ILineString objects

LineStringCollection lines = new LineStringCollection()

Contains ICircularArcSegment and ILineStringSegment objects

CurveSegmentCollection curveSegments = new CurveSegmentCollec

tion()

Contains ICurveString objects

CurveStringCollection curves = new CurveStringCollection()

Contains ILinearRing objects

LinearRingCollection linearRings = new LinearRingCollection()

Contains IRing objects

RingCollection curveRings = new RingCollection()

Contains IPolygon objects

PolygonCollection linearPolygons = new PolygonCollection()

Contains ICurvePolygon objects

CurvePolygonCollection curvePolygons = new CurvePolygonCollec

tion()

GeometryCollection geometries = new GeometryCollection()

C Geometries Constructed usingIDirectPositionImpl

These geometries are IPoint and ILineString

IPoint

The creation of an instances uses an IDirectionPositionImpl object

IPoint pt00 = geomFactoryCreatePoint(pos00)

200 | Chapter 13 FDO Cookbook

ILineString

The creation of an instances uses a DirectPositionCollection object which iscomposed of IDirectionPositionImpl object

positionsAdd(pos01)

positionsAdd(pos21)

ILineString line0121 = geomFactoryCreateLineString(positions)

positionsClear()

C Geometries Constructed Using GeometrySubcomponents

These geometries are ICurveString IPolygon and ICurvePolygon

ICurveString

The creation of an instance uses a CurveSegmentCollection object whichcontains an ICircularArcSegment object and an ILineStringSegment object

ICurveString composed of a circular arc segment and a line

string segment

curveSegmentsAdd(as022223)

curveSegmentsAdd(ls233033)

ICurveString csAs022223Ls233033 = geomFactoryCreateCur

veString(curveSegments)

curveSegmentsClear()

IPolygon

The creation of an instance uses an ILinearRing object for the exterior ringand a LinearRingCollection object composed of ILinearRing objects for theinterior rings

IPolygon with one exterior ring and no interior rings

IPolygon polyEr01211201 = geomFactoryCreatePolygon(lr01211201

null)

IPolygon with one exterior ring and one interior ring

linearRingsAdd(lr01211201)

polyEr13n204013Ir01211201 = geomFactoryCreatePolygon(lr13n204013

linearRings)

linearRingsClear()

Construction | 201

ICurvePolygon

The creation of an instance uses an IRing object for the exterior ring and aRingCollection object composed of an IRing object for the interior rings

ICurvePolygon with one exterior ring rAs1340n20Lsn2013 which

is composed of an arc segment and a line segment

and one interior ring rLs0121Ls2112Ls1201 which is a triangle

made of three line segments

curveRingsAdd(rLs0121Ls2112Ls1201)

ICurve Polygon curvPolyErAs1340n20Lsn2013IrLs0121Ls2112Ls1201 =

geomFactoryCreateCurvePolygon(rAs1340n20Lsn2013 curveRings)

curveRingsClear()

C Aggregate Geometries

The aggregate geometries are IMultiPoint IMultiLineString IMultiCurveStringIMultiPolygon IMultiCurvePolygon and IMultiGeometry

IMultiPoint

The creation of an instance uses a PointCollection object

pointsAdd(pt00)

pointsAdd(pt11)

IMultiPoint pt00pt11 = geomFactoryCreateMultiPoint(points)

pointsClear()

IMultiLineString

The creation of an instance uses a LineStringCollection object

linesAdd(line0121)

linesAdd(line0222)

IMultiLineString line0121line0222 = geomFactoryCreateMultiLineS

tring(lines)

linesClear()

IMultiCurveString

The creation of an instance uses a CurveStringCollection object

202 | Chapter 13 FDO Cookbook

curvesAdd(csAs012122)

curvesAdd(csAs022223Ls233033)

IMultiCurveString aMultiCurvePolygon = geomFactoryCreateMultiCur

veString(curves)

curvesClear()

IMultiPolygon

The creation of an instance uses a PolygonCollection object

linearPolygonsAdd(polygonNum1)

linearPolygonsAdd(polygonNum2)

IMultiPolygon aMultiPolygon = geomFactoryCreateMultiPolygon(lin

earPolygons)

linearPolygonsClear()

IMultiCurvePolygon

The creation of an instance uses a CurvePolygonCollection object

curvePolygonsAdd(curvePolygonNum1)

curvePolygonsAdd(curvePolygonNum2)

IMultiCurvePolygon aMultiCurvePolygon = geomFactoryCreateMultiC

urvePolygon(curvePolygons)

curvePolygonsClear()

IMultiGeometry

The creation of an instance uses a GeometryCollection object

geometriesAdd(aPoint)

geometriesAdd(aMultiPoint)

geometriesAdd(aLineString)

geometriesAdd(aMultiLineString)

geometriesAdd(aCurveString)

geometriesAdd(aMultiCurveString)

geometriesAdd(aPolygon)

geometriesAdd(aMultiPolygon)

geometriesAdd(aCurvePolygon)

geometriesAdd(aMultiCurvePolygon)

IMultiGeometry aMultiGeometry = geomFactoryCreateMultiGeometry(geo

metries)

geometriesClear()

Construction | 203

C Geometries from Text Specifications

You can use the geometry factoryrsquos CreateGeometry method to creategeometries from text specifications Herersquos an IPoint example

IPoint pt11 = geomFactoryCreatePoint(pos11)

IPoint aSecondPt11 = geomFactoryCreateGeometry(pt11Text) as

IPoint

aThirdPt11 = geomFactoryCreateGeometry(POINT (1 1)) as IPoint

Deconstruction

Deconstruction means getting information such as dimensionality envelopetext specification geometry geometry subcomponents and positions(coordinates) The following table specifies the information available fromthe classes

Position means coordinate values Dimensionality values are XY XYZ XYMor XYZM Envelope means bounding rectangle The envelope for an aggregategeometry contains all of the included geometries Text means FGF well-knowntext specification IsClosed is a boolean specifying whether or not the startand end coordinates are identical

Information availableClass

position dimensionalityIDirectPosition

position dimensionality envelope textIPoint

dimensionality envelope text IPointIMultiPoint

position dimensionality envelope textILineString

dimensionality envelope text ILineStrinIMultiLineString

IsClosed position dimensionality envelopeILineStringSegment

IsClosed position dimensionality envelopeICircularArcSegment

204 | Chapter 13 FDO Cookbook

Information availableClass

position dimensionality envelope text ICircularArcSegment ILineStringSegmentICurveString

dimensionality envelope text ICurveStringIMultiCurveString

position dimensionality envelopeILinearRing

dimensionality envelope text ILinearRingIPolygon

dimensionality envelope text IPolygonIMultiPolygon

position dimensionality ICircularArcSegment ILineStringSegmentIRing

dimensionality envelope text IRingICurvePolygon

dimensionality envelope text ICurvePolygonIMultiCurvePolygon

dimensionality envelope text IPoint IMultiPoint ILineString IMultiLineStringICurveString IMultiCurveString IPolygon IMultiPolygon ICurvePolygon IMulti-CurvePolygon

IMultiGeometry

Coordinates

IDirectPosition aPosition

double X = aPositionX

double Y = aPositionY

double Z

double M

int dim = aPositionDimensionality

if ((dim amp 1) == 1)

Z = aPositionZ

if ((dim amp 2) == 2)

M = aPositionM

Deconstruction | 205

IDirectPosition (IPoint ILineString ICircularArcSegmentILineStringSegment ILinearRing)

IPoint aPoint

IDirectPosition position = aPointPosition

ILineString line

IDirectPosition aPosition = null

IDirectPosition startPosition = lineStartPosition

IDirectPosition endPosition = lineEndPosition

for (int i = 0 i lt lineCount i++)

aPosition = lineget_Item(i)

ICircularArcSegment arcSegment

IDirectPosition startPosition = arcSegmentStartPosition

IDirectPosition midPoint = arcSegmentMidPoint

IDirectPosition endPosition = arcSegmentEndPosition

ILineStringSegment lineSegment

IDirectPosition startPosition = lineSegmentStartPosition

IDirectPosition endPosition = lineSegmentEndPosition

DirectPositionCollection positions = lineSegmentPositions

foreach(IDirectPosition position in positions)

ICurveString curve

IDirectPosition startPosition = curveStartPosition

IDirectPosition endPosition = curveEndPosition

ILinearRing linearRing

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

ILinearRing ring

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

Dimensionality Envelope and Text

int dimensionality = aPointDimensionality

IEnvelope envelope = aPointEnvelope

string text = aPointText

206 | Chapter 13 FDO Cookbook

IsClosed (ICircularArcSegment and ILineStringSegment)

ICircularArcSegment arcSegment

bool isClosed = arcSegmentIsClosed

ILineStringSegment lineSegment

bool isClosed = lineSegmentIsClosed

IPoint and IMultiPoint

IMultiPoint aMultiPoint

IPoint aPoint = null

for (int i = 0 i lt aMultiPointCount i++)

aPoint = aMultiPointget_Item(i)

ILineString and IMultiLineString

IMultiLineString aMultiLineString

ILineString line = null

for (int i = 0 i lt aMultiLineStringCount i++)

line = aMultiLineStringget_Item(i)

ICurveString and IMultiCurveString

IMultiCurveString aMultiCurveString

ICurveString curve = null

for (int i = 0 i lt aMultiCurveStringCount i++)

curve = aMultiCurveStringget_Item(i)

Deconstruction | 207

ICircularArcSegment and ILineStringSegment (ICurveString andIRing)

ICurveString aCurveString

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt aCurveStringCount i++)

curveSegment = aCurveStringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

IRing ring

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt ringCount i++)

curveSegment = ringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

ILinearRing (IPolygon)

IPolygon aPolygon

ILinearRing anExteriorRing = aPolygonExteriorRing

ILinearRing anInteriorRing = null

for (int i = 0 i lt aPolygonInteriorRingCount i++)

anInteriorRing = aPolygonGetInteriorRing(i)

208 | Chapter 13 FDO Cookbook

IPolygon and IMultiPolygon

IMultiPolygon aMultiPolygon

IPolygon aPolygon = null

for (int i = 0 i lt aMultiPolygonCount i++)

aPolygon = aMultiPolygonget_Item(i)

IRing (ICurvePolygon)

ICurvePolygon aCurvePolygon

IRing anExteriorRing = aCurvePolygonExteriorRing

IRing anInteriorRing = null

for (int i = 0 i lt count i++)

anInteriorRing = aCurvePolygonget_InteriorRing(i)

ICurvePolygon and IMultiCurvePolygon

IMultiCurvePolygon aMultiCurvePolygon

ICurvePolygon aCurvePolygon = null

for (int i = 0 i lt aMultiCurvePolygonCount i++)

aCurvePolygon = aMultiCurvePolygonget_Item(i)

Deconstruction | 209

IMultiGeometry

IMultiGeometry aMultiGeometry

IGeometry geom = null

GeometryType geomType

IPoint pt = null

IMultiPoint mpt = null

ILineString line = null

IMultiLineString mline = null

ICurveString curve = null

IMultiCurveString mcurve = null

IPolygon poly = null

IMultiPolygon mpoly = null

ICurvePolygon curvPoly = null

IMultiCurvePolygon mCurvPoly = null

for (int i = 0 i lt aMultiGeometryCount i++)

geom = aMultiGeometryget_Item(i)

geomType = geomDerivedType

switch (geomType)

case GeometryTypeGeometryType_Point pt = geom as IPoint break

case GeometryTypeGeometryType_MultiPoint mpt = geom as IMulti

Point break

case GeometryTypeGeometryType_LineString line = geom as ILin

eString break

case GeometryTypeGeometryType_MultiLineString mline = geom as

IMultiLineString break

case GeometryTypeGeometryType_CurveString curve = geom as

ICurveString break

case GeometryTypeGeometryType_MultiCurveString mcurve = geom

as IMultiCurveString break

case GeometryTypeGeometryType_Polygon poly = geom as IPolygon

break

case GeometryTypeGeometryType_MultiPolygon mpoly = geom as

IMultiPolygon break

case GeometryTypeGeometryType_CurvePolygon curvPoly = geom as

ICurvePolygon break

case GeometryTypeGeometryType_MultiCurvePolygon mCurvPoly =

geom as IMultiCurvePolygon break

default break

210 | Chapter 13 FDO Cookbook

OSGeo FDO Provider forArcSDE

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ArcSDE

What Is FDO Provider for ArcSDEThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store A provider is a specific implementation of theFDO API that provides access to data in a particular data store ESRIreg ArcSDEreg

(Spatial Database Engine) is part of the ArcGIS 9 system ArcSDE manages theexchange of information between an (ArcGIS 9 Desktop) application and arelational database management system FDO Provider for ArcSDE provides FDOwith access to an ArcSDE 9-based data store which in this case must be Oracle9i (9206)

FDO Provider for ArcSDE SoftwareRequirements

Installed Components

FDO Provider for ArcSDE dynamically linked libraries are installed with the FDOSDK They are located in ltFDO SDK Install LocationgtFDObin You do nothave to do anything to make these DLLs visible

A

211

External Dependencies

The operation of FDO Provider for ArcSDE is dependent on the presence ofArcSDE 9 and a supported data source such as Oracle 9i in the networkenvironment The host machine running FDO Provider for ArcSDE must alsohave the required DLLs present which are available by installing either anArcGIS 91 Desktop application or the ArcSDE SDK For example the requiredDLLs are present if either ArcViewreg ArcEditorreg or ArcInforeg are installed Formore information about ArcGIS 91 Desktop applications and the ArcSDE SDKrefer to the ESRI documentation

Specifically in order for FDO Provider for ArcSDE to run three dynamicallylinked libraries sde91dll sg91dll and pe91dll are required and you mustensure that the PATH environment variable references the local foldercontaining these DLLs For example in Microsoft Windows if ArcGIS 91Desktop is installed to CProgram FilesArcGIS then the required ArcSDEbinaries are located at CProgram FilesArcGISArcSDEbin Similarly if theArcSDE SDK is installed to the default location then the required ArcSDEbinaries are located at CArcGisArcSDEbin The absence of thisconfiguration may cause the following exception message The ArcSDE runtimewas not found

FDO Provider for ArcSDE LimitationsThe FDO Provider for ArcSDE is based on a subset of the ArcSDE API Thissubset does not include the following

Raster functionality

Native ArcSDE metadata

The annotation data with the exception of the ANNO_TEXT column

ArcSDE LimitationsFDO Provider for ArcSDE must abide by limitations of the ArcSDE technologyto which it connects This section discusses these limitations

212 | Appendix A OSGeo FDO Provider for ArcSDE

Relative to ArcObjects API and ArcGIS Server API

The ArcSDE API does not support the following advanced functionality foundin the ArcObjects API and the newer ArcGIS Server API

Advanced geometries such as Bezier curves and ellipses

Relationships

Topology

Networks

Analysis

Linear referencing

Curved Segments

If ArcSDE encounters curved segments it will automatically tessellate themThis means that if you create a geometry containing an arc segment in anArcSDE table using ArcObjects API and then you try to read that geometryback using the ArcSDE API you will get a series of line segments thatapproximate the original arc segment That is you get an approximation ofthe original geometry

Locking and Versioning

ArcSDE permits row locks or table versioning provided that the ID columnwhich uniquely identifies the row is maintained by ArcSDE If there is no IDcolumn or the ID column is maintained by the user ArcSDE does not permitrow locking or table versioning to be enabled

NOTE In ArcSDE you can either lock rows in a table or version a table but youcannot do both at the same time To do either you must alter the tablersquosregistration

The following sections illustrate these three steps

1 The creation of a table

Relative to ArcObjects API and ArcGIS Server API | 213

2 The alteration of the table registration to identify one of the columndefinitions as the row ID column and to enable row locking

3 The alteration of the table registration to disable row locking and toenable versioning

Table Creation

The command is

sdetable -o create -t hassdemaintainedrowid -d name string(20)

fid integer(9) -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The Row Lock has no value and the value of Dependent Objects is None

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column

Row ID Column Type

Row Lock

Minimum Row ID

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Identity Row ID Column and Enable Row Locking

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -c fid -C sde -L

on -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

214 | Appendix A OSGeo FDO Provider for ArcSDE

NOTE The Row ID Column value is FID the Row ID Column Type value is SDEMaintained and the Row Lock value is Enable

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Enable

Minimum Row ID 1

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Disable Row Locking and Enable Versioning

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -L off -V MULTI -u

t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The ldquoRow Lockrdquo is ldquoNot Enablerdquo and ldquoDependent Objectsrdquo is ldquoMultiversionTablerdquo

Locking and Versioning | 215

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Not Enable

Minimum Row ID 1

Dependent Objects Multiversion Table

Dependent Object Names A18111 D18111

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

FDO Provider for ArcSDE ConnectionThis information supplements the Establishing a Connection chapter Youconnect to an ArcSDE data store indirectly through the ArcSDE server Theunderlying data source for the data store is a database such as Oracle TheArcSDE server is connected to the data source and mediates the requests thatyou send it

You can connect to FDO Provider for ArcSDE in one step if you already knowthe name of the data store that you want to use Otherwise you must connectin two steps

The minimum required connection properties for the initial call to Open()are server instance username and password Multiple users can access thedata store However access is password-protected The server property is thename of the machine hosting the ArcSDE server The instance property actsas an index into an entry in the services file An entry contains port andprotocol information used to connect to the ArcSDE server On a Windowsmachine the services file is located in CWINDOWSsystem32driversetcAssuming that the instance name is ldquoesri_sderdquo an entry would look somethinglike this ldquoesri_sde 5151tcp ArcSDE Server Listening Portrdquo

An ArcSDE data source may contain more than one data store For the firstcall to Open() a data store name is optional If successful the first call toOpen() results in the data store parameter becoming a required parameter anda list of the names of the data stores in the data source becoming availableYou must choose a data store and call Open() again

216 | Appendix A OSGeo FDO Provider for ArcSDE

If the data source supports multiple data stores the list returned by the firstcall to Open() will contain a list of all of the data stores resident in the datasource Otherwise the list will contain one entry ldquoDefault Data Storerdquo

If you know the name of the data store you can provide it for the first call toOpen() and make the connection in one step

Data Type MappingsThis section shows the mappings from FDO data types to ArcSDE data typesto Oracle data types

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDataType_Boolean

Not supportedNot supportedFdoDataType_Byte

DATEdateFdoDataType_DateTime

Not supportedNot supportedFdoDataType_Decimal

NUMBER(388)double(388)FdoDataType_Double

NUMBER(4)integer(4)FdoDataType_Int16

NUMBER(10)integer(10)FdoDataType_Int32

Not supportedNot supportedFdoDataType_Int64

NUMBER(62)float(62) typicalFdoDataType_SingleNUMBER(n8)float(0ltnlt=6 oltmltDBMSLimit)) possible

VARCHAR2(ltlengthgt)string(ltlengthgt)FdoDataType_String

LONG RAWblobFdoDataType_BLOB

Not supportedNot supportedFdoDataType_CLOB

Data Type Mappings | 217

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDatatype_UniqueID

Creating a Feature SchemaThis section describes the creation of the SampleFeatureSchema which is theexample feature schema described in the Schema Management chapter It alsodescribes the creation of the OGC980461FS schema which is the schemadefined in the OpenGIS project document 98-046r1

FDO Provider for ArcSDE does not support the creation or destruction offeature schema (that is does not support the FdoIApplySchema andFdoIDestroySchema commands) However it does support theFdoIDescribeSchema command The intended use of FDO Provider for ArcSDEis to operate on already existing feature schemas FDO Provider for ArcSDEsupports inserting selecting updating and deleting data in existing schemas

You can use FDO Provider for ArcSDE to operate on a new feature schemaHowever you must create the schema using ArcSDE tools In particular youuse the sdetable and sdelayer commands which can be used to create a schemain any of the data store technologies used by ArcSDE This part of thedescription is generic Other parts of the description are specific to Oracle andto Windows XP because Oracle is the data store technology and Windows XPis the operating system for this exercise

First you must create an Oracle username for the feature schema (that is thename of the Oracle user is the name of the feature schema) To do this youconnect as system administrator to the Oracle instance used by the ArcSDEserver The following command creates the user and grants to that user theprivileges necessary for the ArcSDE tool commands to succeed

grant connectresource to ltschemaNamegt identified by ltpasswordgt

Secondly you must log in to the host where the ArcSDE server is runningArcSDE tools are on the host machine where the ArcSDE server resides

TIP NetMeeting can be used to remotely login to where the ArcSDE Server isrunning and launch a command window (that is in the Run dialog box entercmd) The ArcSDE tool commands can be executed through the command windowDo not use CWINDOWSSYSTEM32COMMANDCOM because the line bufferis too short to contain the entire text of some of the SDE tool command strings

218 | Appendix A OSGeo FDO Provider for ArcSDE

Finally execute the sdetable and sdelayer commands in a command windowto create each of the classes Since you are executing these commands on thehost where the ArcSDE server is located you can omit the server name optionIf the ArcSDE server is connected to only one data store you can omit theservice option For more information about all of the ArcSDE commandsconsult the ArcSDE Developer Help Guide

SampleFeatureSchema

In this sample a feature schema called SampleFeatureSchema is created whichcontains one feature class called SampleFeatureClass This feature class hasthe following three properties

An Int32 called SampleIdentityDataProperty

A string called SampleNameDataProperty

A polygon geometry called SampleGeometricProperty

First use the sdetable -o create command to add the integer and stringproperties to SampleFeatureClass Then use the sdetable -o alter_reg commandto identify the SampleIdentityDataProperty as an identity property Finallyuse the sdelayer -o add command to add the geometric property toSampleFeatureClass This assumes that only one ArcSDE server service isrunning so that the -i option is optional The -i option takes a service nameas an argument

The sdetable -o create command can be invoked as follows

sdetable -o create -t SampleFeatureClass -d ldquoSampleIdentityData

Property INTEGER(10) SampleNameDataProperty STRING(64)rdquo -u

SampleFeatureSchema -p test

The -o option takes the command option name The -d option takes thecolumn definitions which is a quoted list of column namecolumn type pairsdelimited by commas The -u option takes an Oracle database user namewhich becomes the feature schema name The -p option takes a password

The sdetable -o alter_reg command is invoked as follows

sdetable -o alter_reg -t SampleFeatureClass -c SampleIdentityData

Property -C USER -u SampleFeatureSchema -p test

The -c option identifies the column name that will be the identity propertyThe -C option indicates whether SDE is supposed to generate the value orobtain it from the user You will be prompted to confirm that you want toalter the registration of the table

Creating a Feature Schema | 219

The sdelayer command is invoked as follows

sdelayer -o add -l SampleFeatureClassSampleGeometricProperty -E

0010050 -e a -u SampleFeatureSchema -p test

The -o option takes the command option name The -l option identifies thetable and column The -E option identifies the extents the arguments areltxminyminxmaxymaxgt The -e option identifies the geometry type withlsquoarsquo indicating an area shape

OGC980461FS

This schema contains the ten classes defined in the OpenGIS Project Document980946r1 The types of the properties belonging to the classes is similar tothat of SampleFeatureClass namely an integer a string and a geometry Onedifference is that the geometry in three of the classes is multipart Two ofthem have MULTIPOLYGON geometries and one of them has aMULTILINESTRING geometry A multipart geometry is indicated by addinga lsquo+rsquo to the entity argument to the -e option in the sdelayer command AMULTIPOLYGON geometry is indicated by ldquo-e a+rdquo and a MULTILINESTRINGgeometry is indicated by ldquo-e l+rdquo

An ArcSDE table cannot have two geometries This restriction impacts thedefinition of the buildings class which has a POLYGON and a POINTgeometry We have chosen to add the POINT geometry The OpenGIS 98-046r1document defines one query that references building objects and the POINTgeometry supports this query

NOTE The use of -E option in the sdelayer command defines the extents Thearguments are ltxminyminxmaxymaxgt The values provided below ensure thatyou will not receive any ldquoordinate out of boundsrdquo errors when inserting the98046r1 data

220 | Appendix A OSGeo FDO Provider for ArcSDE

ArcSDE Commands That Define the OGC980461FS Classes

Creating a Feature Schema | 221

sdetable -o create -t lakes -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t lakes -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l lakesshore -E 0010050 -e a -u OGC980461FS

-p test

sdetable -o create -t road_segments -d fid integer(10) name

string(64) aliases string(64) num_lanes integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t road_segments -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l road_segmentscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t divided_routes -d fid integer(10) name

string(64) num_lanes integer(10) -u OGC980461FS -p test

sdetable -o alter_reg -t divided_routes -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l divided_routescenterlines -E 0010050 -e l+

-u OGC980461FS -p test

sdetable -o create -t forests -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t forests -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l forestsboundary -E 0010050 -e a+ -u

OGC980461FS -p test

sdetable -o create -t bridges -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t bridges -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l bridgesposition -E 0010050 -e p -u

OGC980461FS -p test

sdetable -o create -t streams -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t streams -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l streamscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t buildings -d fid integer(10) address

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t buildings -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l buildingsposition -E 0010050 -e p -u

OGC980461FS -p test

222 | Appendix A OSGeo FDO Provider for ArcSDE

sdetable -o create -t ponds -d fid integer(10) name string(64)

type string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t ponds -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l pondsshores -E 0010050 -e a+ -u OGC980461FS

-p test

sdetable -o create -t named_places -d fid integer(10) name

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t named_places -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l named_placesboundary -E 0010050 -e a -u

OGC980461FS -p test

sdetable -o create -t map_neatlines -d fid integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t map_neatlines -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l map_neatlinesneatline -E 0010050 -e a -u

OGC980461FS -p test

Logical to Physical Schema MappingThis mapping does not apply because the ArcSDE provider does not supportthe ApplySchema command

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data types TheArcSDE provider talks to the ArcSDE server The server uses either Oracle orSql Server as the back-end data store technology So two schema mappins aredescribed here

Oracle 10gR2 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter The class name is the name of the tablecreated using the sdetable command The property names are the columnnames

Logical to Physical Schema Mapping | 223

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoSrdquo means that the storage typeused for the geometry is Oracle Spatial The -G argument ldquo26910rdquo is the SRID ofa coordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N The sqlplus command select cs_name from mdsyscs_srs where srid =

26910 returns NAD83 UTM zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde -u existinguser -p test -G 26910 -P 32 -t S

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int16NUMBER(4)SE_INT16 4SMINT4COL

UnmappedCHAR(38)SE_UUID 38ID

Int16NUMBER(4)SE_INT16 4INT16COL

224 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int32NUMBER(38)SE_INT32 10INT32COL

SingleNUMBER(62)SE_FLOAT32 6 2FLOAT32COL

DoubleNUMBER(154)SE_FLOAT64 7 2FLOAT64COL

Int32NUMBER(10)SEINT32 10INT10

SingleNUMBER(44)SE_FLOAT32 4 4FLOAT4_4

DoubleNUMBER(72)SE_FLOAT64 7 2DOUBLE7_2

StringVARCHAR2(64)SE_STRING 64STRING64

BLOBBLOBSE_BLOB 0BLOBCOL

UnmappedCLOBSE_CLOB 0CLOBCOL

StringNVARCHAR2(255)SE_NSTRING 255NSTRINGCOL

UnmappedNCLOBSE_NCLOB 0NCLOBCOL

DateTimeDATESE_DATE 0DATECOL

GeometryMDSYSSDO_GEOMETRYSE_SHAPE 0FEATGEOM

Int32NUMBER(38)SE_INT32 10OBJECTID

NOTE The OBJECTID column was not specified in the -d arguments of the sdetablecommand

Sql Server 2005 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter prefixed by ldquoSDE_rdquo The class name is the

Physical to Logical Schema Mapping | 225

name of the table created using the sdetable command The property namesare the column names

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoBrdquo means that the storage typeused for the geometry is Esri Binary The -G argument ldquo26910rdquo is the SRID of acoordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde_ss

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde_ss -u existinguser -p test -G 26910 -P 32 -t B

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int16smallintSE_INT16 4SMINT4COL

UnmappeduniqueidentifierSE_UUID 38ID

Int16smallintSE_INT16 4INT16COL

226 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int32intSE_INT32 10INT32COL

SinglerealSE_FLOAT32 6 2FLOAT32COL

DoublefloatSE_FLOAT64 7 2FLOAT64COL

Int32intSEINT32 10INT10

Singlenumeric(44)SE_FLOAT32 4 4FLOAT4_4

Singlenumeric(72)SE_FLOAT64 7 2DOUBLE7_2

Stringvarchar(64)SE_STRING 64STRING64

BLOBimageSE_BLOB 0BLOBCOL

UnmappedtextSE_CLOB 0CLOBCOL

Stringnvarchar(255)SE_NSTRING 255NSTRINGCOL

UnmappedntextSE_NCLOB 0NCLOBCOL

DateTimedateSE_DATE 0DATECOL

GeometryintSE_SHAPE 0FEATGEOM

FDO Provider for ArcSDE CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

FDO Provider for ArcSDE Capabilities | 227

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

locking

exclusive locking type

transactions

long transactions

SQL

multiple spatial contexts

specifying coordinate systems by name or ID without specifying WKT

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

228 | Appendix A OSGeo FDO Provider for ArcSDE

The following capabilities are supported

class and feature class class types

DateTime data type with a maximum length of 12 bytes

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 4294967296

BLOB data type with a maximum length of 4294967296

Int32 auto-generated data type

Identity properties of type DateTime Double Int16 Int32 Single Stringand BLOB

Name size limitation of 123 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 65 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 160 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 32 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite unique value constraints

Multiple schemas

Null value constraints

Unique value constraints

FDO Provider for ArcSDE Capabilities | 229

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ActivateSpatialContext

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLComnmand

FdoCommandType_AcquireLock

FdoCommandType_GetLockInfo

FdoCommandType_GetLockedObjects

FdoCommandType_GetLockOwners

FdoCommandType_ReleaseLock

FdoCommandType_ActivateLongTransaction

FdoCommandType_DeactivateLongTransaction

FdoCommandType_CommitLongTransaction

FdoCommandType_CreateLongTransaction

FdoCommandType_GetLongTransactions

230 | Appendix A OSGeo FDO Provider for ArcSDE

FdoCommandType_RollbackLongTransaction

FdoCommandType_ListDataStores

The following capabilities are supported

command parameterization

simple functions in Select and SelectAggregate commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

the Beyond and Within distance operations

spatial operations of type Contains Crosses Disjoint Equals IntersectsOverlaps Touches Within CoveredBy Inside and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic expressions are supported

The following functions are supported

Double Sum(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Int64 Count(lttypegt value) where lttypegt is one of Boolean Double SingleDecimal Byte DateTime Int16 Int32 Int64 String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

FDO Provider for ArcSDE Capabilities | 231

Double Avg(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double Max(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double StdDev(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

232 | Appendix A OSGeo FDO Provider for ArcSDE

OSGeo FDO Provider forMySQL

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor MySQL

What Is FDO Provider for MySQLThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for MySQL provides FDO withaccess to a MySQL-based data store

The FDO Provider for MySQL API provides custom commands that arespecifically designed to work with the FDO API For example using thesecommands you can do the following

Gather information about a provider

Transmit client services exceptions

Get lists of accessible data stores

Create connection objects

Create and execute spatial queries

The MySQL architecture supports different storage engines Choose an engineas needed depending on its characteristics and capabilities such as the following

MyISAM is a disk-based storage engine It does not support transactions

InnoDB is a disk-based storage engine It has full ACID transaction capability

B

233

Memory (Heap) is a storage engine utilizing only RAM It is very fast

NDB is the MySQL Cluster storage engine

MERGE is a variation of MyISAM A MERGE table is a collection of identicalMyISAM tables which means that all tables have the same columnscolumn types indexes and so on

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for MySQL API Reference Help(MySQL_Provider_APIchm)

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in thecommandrsquos class collection The mapping of logical FDO data types to nativetypes is described here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the numberof digits to the right of the decimal point The maximum number of digits in thenative type is 64

NOTE The definition of the FDO String data type requires that the length propertybe set

Native Data TypeFDO Data Type

tinyint(4)Boolean

tinyint(3) unsignedByte

datetimeDateTime

decimal(204)Decimal (precision = 20 scale = 4)

doubleDouble

smallint(6)Int16

234 | Appendix B OSGeo FDO Provider for MySQL

Native Data TypeFDO Data Type

int(11)Int32

bigint(20)Int64

doubleSingle

varchar(64)String (length is 64)

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The name of the schema is the concatenation of lsquoFdorsquo and the name of thedatabase This is the database created using the lsquoCREATE DATABASErsquo commandand containing the existing table(s) The table names are the class names andthe column names are the property names

NOTE The length of a bit field is in the range 1-64 A row in a column of typebit(64) can hold 64 bit values

NOTE The following native types are not mapped to FDO data types float floatunsigned real unsigned double unsigned binary varbinary tinyblob blobmediumblob longblob tinytext mediumtext and longtext

FDO Data TypeDefaultsNative Type

Booleanlength = 1bit(

Bytebit(2)

Int64bit(64)

Int16length = 4tinyint

Physical to Logical Schema Mapping | 235

FDO Data TypeDefaultsNative Type

Bytelength = 3tinyint unsigned

Int16length = 6smallint

Int32length = 5smallint unsigned

Int32length = 9mediumint

Int32length = 8mediumint unsigned

Int32length = 11int

Int64length = 10int unsigned

Int64length = 20bigint

Int64length = 20bigint unsigned

Doublereal

Doubledouble

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric unsigned

DateTimedate

DateTimedatetime

DateTimetimestamp

Int32year

236 | Appendix B OSGeo FDO Provider for MySQL

FDO Data TypeDefaultsNative Type

String (length = 192)char(64)

String (length = 192)varchar(64)

Stringenum

Stringset

FDO Provider for MySQL CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

transactions

FDO Provider for MySQL Capabilities | 237

SQL

multiple spatial contexts

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 95 digits (maximum decimalprecision of 65 and maximum decimal scale of 30)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 2147483647

Int64 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Datastore

238 | Appendix B OSGeo FDO Provider for MySQL

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Composite unique value constraints

Datastore scope unique ID generation

Default value

Exclusive value range constraints

Inclusive value range constraints

Inheritance

Multiple schemas

Null value constraints

Object properties

Unique value constraints

Schema modification

Schema overrides

Unique value constraints

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()

FDO Provider for MySQL Capabilities | 239

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

FdoCommandType_ListDataStores

FdoCommandType_DescribeSchemaMapping

FdoCommandType_SQLComnmand

FdoRdbmsCommandType_CreateSpatialIndex

FdoRdbmsCommandType_DestroySpatialIndex

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

240 | Appendix B OSGeo FDO Provider for MySQL

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

spatial operations of type Intersects and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic function and parameter expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Decimal Double SingleInt16 Int32 or Int64

Decimal Ceil(lttypegt value) where lttypegt is one of Decimal or Double

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single or String

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

FDO Provider for MySQL Capabilities | 241

Byte Min(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

Double Sum(lttypegt value) where lttypegt is one of Decimal Double Int16Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

242 | Appendix B OSGeo FDO Provider for MySQL

OSGeo FDO Provider forODBC

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ODBC

What Is FDO Provider for ODBCThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for ODBC provides FDO withaccess to an ODBC-based data store

The FDO Provider for ODBC can access simple x y z feature objects that canrun in a multi-platform environment including Windows Linux and UNIX

The FDO Provider for ODBC has the following characteristics

The FDO Provider for ODBC supports the definition of one or more featureclasses in terms of any relational database table that contains an X Y andoptionally Z columns

Metadata which maps the table name and X Y and optionally Z columnsto a feature class is maintained outside the database in a configuration fileThis information in conjunction with the table structure in the databaseprovides the definition of the feature class

The x y and z locations of objects are stored in separate properties in theprimary object definition of a feature but are accessible through a singleclass property lsquoGeometryrsquo

C

243

Read-only access is provided to pre-existing data defined and populatedthrough 3rd party applications (that is FDO Provider for ODBC will notbe responsible for defining the physical schema of the data store nor forpopulating the object data)

The schema configuration of the data store is provided to the FDO Providerfor ODBC through an optional XML file containing the Geographic MarkupLanguage (GML) definition of the schema that maps lsquotablesrsquo and lsquocolumnsrsquoin the data store to feature classes and property mappings in the FDO datamodel

NOTE Microsoft Excel (must have at least one named range do not use DATABASEor other reserved words as a range name)

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for ODBC API Reference Help (ODBC_Provider_APIchm)

Physical to Logical Schema MappingsMappings of data in three data sources a Microsoft Access database (an accdbfile) an Excel spreadsheet (xlsx file) and a text file to FDO data types areshown

Microsoft Access

Use the ODBC provider to connect to a Microsoft Access database

The schema name is ldquoFdordquo There is only one database per file so there canbe only one schema The table names are used for class names Column namesare used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are AutoNumberReplication ID NumberReplication ID and OLE objectThe mapping of the rest of the native data types is in the following table

244 | Appendix C OSGeo FDO Provider for ODBC

NOTE The AutoNumber Number and DateTime native types are sub-typed Ifa column named X and a column named Y both typed NumberDouble arepresent they are mapped to an FDO geometric property whose type is Point andwhose spatial context association property is ldquoDefaultrdquo

FDO TypeNative TypeSubType

Int32AutoNumberLong Integer

Notmapped

AutoNumberReplication ID

StringText

StringMemo

ByteNumberByte

Int16NumberInteger

Int32NumberLong Integer

SingleNumberSingle

DoubleNumberDouble

DecimalNumberDecimal

Notmapped

NumberReplication ID

DateTimeDateTimeGeneral Date

DateTimeDateTimeLong Date

DateTimeDateTimeMedium Date

DateTimeDateTimeShort Date

Physical to Logical Schema Mappings | 245

FDO TypeNative TypeSubType

DateTimeDateTimeLong Time

DateTimeDateTimeMedium Time

DateTimeDateTimeShort Time

DecimalCurrency

BooleanYesNo

Notmapped

OLE object

StringHyperlink

StringAttachment

Microsoft Excel

Use the ODBC provider to connect to an Excel file

The schema name is ldquoFdordquo There is only one schema per file The range namesare used for class names Column names are used for property names A columnname is a text entry in a cell that is at the top of a column as defined by theboundaries of the named range

If a column named X and a column named Y are present they are mappedto an FDO geometric property whose type is Point and whose spatial contextassociation property is ldquoDefaultrdquo

Three approaches were used to explore the mapping The first approach lookedat the effect of cell content the second approach looked at the effect of cellformat the third approach looked at the effect of both

The first approach involved copying data from a Microsoft Access databaseinto an Excel spreadsheet The copy operation created a named range thatincluded all of the copied data The name for the range came from the Accessdatabase By default all of the Excel cells have a format type of ldquoGeneralrdquo The

246 | Appendix C OSGeo FDO Provider for ODBC

accompanying table shows the mapping of sample cell content to FDO datatype

FDO TypeCell Content

Double2

Double6452067

StringRussia

Stringltemptygt

StringN

NOTE All of the data in each column was consistent The column containing ldquo2rdquocontained only positive integers The column containing ldquo6452067rdquo containedonly similar numbers including negative values The column containing the lsquoNrsquocontained only single characters that were either lsquoNrsquo or lsquoYrsquo The column containingldquoRussiardquo contained only names The column containing an empty cell containedonly empty cells

The second approach involved setting up a named range consisting of 9columns by 2 rows The cells of the first row are formatted as ldquoGeneralrdquo andcontain column labels The cells of the second row are formatted respectivelyldquoGeneralrdquo ldquoNumberrdquo ldquoCurrencyrdquo ldquoAccountingrdquo ldquoDaterdquo ldquoTimerdquoldquoPercentagerdquo ldquoFractionrdquo ldquoScientificrdquo and ldquoTextrdquo No cell in the second rowhas content The accompanying table shows the mapping of cell format toFDO data type

FDO TypeExcel Cell Format

StringGeneral

DoubleNumber

DecimalCurrency

DecimalAccounting

Physical to Logical Schema Mappings | 247

FDO TypeExcel Cell Format

DateTimeDate

DateTimeTime

DoublePercentage

DoubleFraction

DoubleScientific

StringText

The intent of the third approach is to understand how the mapping wouldbe affected by content that violated the cellrsquos format or was inconsistent withthe data in the rest of the column

Inserting ldquohererdquo in the cells formatted as Number Currency AccountingDate Time Percentage Fraction and Scientific caused them to be mapped toString

Inserting -1225 in the cell formatted as Currency caused no change in themapping to Decimal

Inserting 1225 in the cell formatted as Date caused no change in the mappingto DateTime Excel converted 1225 to ldquo1121900 60000 AMrdquo

Inserting ldquohererdquo in one of the cells in the column of integers copied from theAccess database resulted in no change to the mapping to Double This maybe a bug

Text File

Use the ODBC provider to connect to a text file You must first create a DSNusing the XP Data Sources (ODBC) administrative tool The DSN maps to adirectory not a file Each file in the directory is mapped to an FDO class

248 | Appendix C OSGeo FDO Provider for ODBC

NOTE When selecting the directory for the DSN you will notice a listing of thefiles recognized as text files by the driver It will recognize Vim backup files forexample Citiestxt~ as text files The execution of a describe schema commandon a directory containing a Vim backup file caused an exception whose messageis ldquoRDBMS [Microsoft][ODBC Text Driver] Cannot update Database or object isread-onlyrdquo Removal of the Vim backup file prevented this exception

The schema name is ldquoFdordquo There is only one schema per directory The classname is the name of the file for example ldquoCities_txtrdquo The property namesare taken from the first line in the file Here are the first two lines from acomma-delimited text file The property names are ldquoCITY_IDrdquo ldquoNAMErdquo etcThe table shows the mapping of the sample text to FDO data type

CITY_IDNAMECOUNTRYPOPULATIONCAPITALLATITUDELON

GITUDEURLFOUNDED

1MurmanskRussia468000N689633087172008 00000

FDO Data TypeSample Text

Int32468000

StringRussia

Double6896

Stringltemptygt

NOTE Changing ldquoLATITUDErdquo to ldquoYrdquo and ldquoLONGITUDErdquo to ldquoXrdquo causes these twofields to be mapped to a geometric property called ldquoGeometryrdquo whose spatialcontext association is to a spatial context called ldquoDefaultrdquo

FDO Provider for ODBC CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

FDO Provider for ODBC Capabilities | 249

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

SQL

XML configuration

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 56 digits (maximum decimalprecision of 28 and maximum decimal scale of 28)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

250 | Appendix C OSGeo FDO Provider for ODBC

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Auto-generated data types Int16 and Int64

Identity properties of type Boolean Byte and DateTime

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite ID

Default value

Inheritance

Multiple schemas

Null value constraints

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaning

FDO Provider for ODBC Capabilities | 251

of the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLCommand

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Intersects Within Inside and EnvelopeIntersects

252 | Appendix C OSGeo FDO Provider for ODBC

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The full range of expression functions are supported as set out in theCapabilities chapter

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZ is supported The Point geometry types is supported

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for ODBC Capabilities | 253

254

OSGeo FDO Provider forSDF

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SDF

What Is FDO Provider for SDFThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SDF is a standalone fileformat that supports GIS data

The FDO Provider for SDF uses Autodesks spatial database format which is afile-based personal geodatabase that supports multiple featuresattributes spatialindexing interoperability file-locking and high performance for large datasets

The SDF file format has the following characteristics

SDF files can be read on different platforms

The SDF file has its own spatial indexing

SDF files can store geometric and non-geometric data with minimumoverhead

Although it does not support concurrency control (locking) the SDF fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SDF API Reference Help (SDF_Provider_APIchm)

D

255

FDO Provider for SDF CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per command threaded

dynamic spatial content extent type

Write

Flush

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

256 | Appendix D OSGeo FDO Provider for SDF

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Int32 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Exclusive value range constraints

FDO Provider for SDF Capabilities | 257

Inclusive value range constraints

Inheritance

Null value constraints

Schema modification

Value constraints list

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

SdfCommandType_ExtendedSelect

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

258 | Appendix D OSGeo FDO Provider for SDF

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Contains Disjoint Inside Intersects Withinand EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty geomValue)

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBGeometricProperty AssociationProperty

Double Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

FDO Provider for SDF Capabilities | 259

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeometry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

260 | Appendix D OSGeo FDO Provider for SDF

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SDF Capabilities | 261

262

OSGeo FDO Provider forSHP

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SHP

What Is FDO Provider for SHPThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SHP provides FDO withaccess to an SHP-based data store

The FDO Provider for SHP uses a standalone file format that supports GIS dataThe FDO Provider for SHP (Shape) has the following characteristics

Read-only access is provided to pre-existing spatial and attribute data froman Environmental Systems Research Institute (ESRI) Shape file (SHP)

The FDO Provider for SHP can run in a multi-platform environmentincluding Windows and Linux

A Shape file consists of three separate files SHP (shape geometry) SHX (shapeindex) and DBF (shape attributes in dBASE format)

The FDO Provider for SHP accesses the information in each of the threeseparate files and treats each SHP and its associated DBF file as a featureclass with a single geometry property and optionally with data attributeproperties

Schema configuration of the data store is provided to the FDO Provider forSHP through an XML file containing the Geographic Markup Language

E

263

(GML) definition of the schema that maps SHP and DBF data in the datastore to feature classes and property mappings in the FDO data model

Although it does not support concurrency control (locking) the SHP fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SHP API Reference Help (SHP_Provider_APIchm)

Creating SHP Files for the Logical to PhysicalSchema Mapping

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The shape files used for the purpose of mapping FDO logical types to shapenative types were created using the following method The path argument isthe path to a filename whose pattern is ltbasegtshp The type argument specifiesthe type of the shape filersquos geometry for example ShapLibShapeTypePointExecution of the method creates the named ltbasegtshp file as well as altbasegtshx file

using MapTools

public bool CreateShpFile(string path ShapeLibShapeType type)

IntPtr hShp = ShapeLibSHPCreate(path type)

if (hShpEquals(IntPtrZero)) return false

else

ShapeLibSHPClose(hShp)

return true

The FDO ApplySchema creates the ltbasegtdbf and ltbasegtcpg It will alsocreate the ltbasegtprj file if a spatial context has been created and the nameof the coordinate system referenced by the spatial context definition has beenassigned to the feature geometric property definitionrsquos spatial contextassociation property

264 | Appendix E OSGeo FDO Provider for SHP

Creating SHP Files for the Physical to LogicalSchema Mapping

To do the physical to logical schema mapping requires shp files containingall possible shp data types Two approaches for creating such shp files havebeen used The first approach is to use the ArcSDE sde2shp command toconvert an ArcSDE schema to a shapefile schema The second approach is touse the ShapeLib C library to create the shapefiles

sde2shp

This command converts the contents of an ArcSDE data store into a set ofshape files The conversion is guided by a text specification that maps anArcSDE column name to a tuple consisting of a shape table column name ashape column type identifier a column width and optionally the number ofdeciaml places

The source ArcSDE data store for this exercise is that specified in the ArcSDEappendix in the topic about physical to logical schema mapping The datastore contained a table called ldquoExistingTablerdquo This table containing a geometrycolumn called ldquofeatgeomrdquo The featgeom column allows only point geometriesto be stored A shape geometry can only be of one type So for the conversionto work the ArcSDE geometry column has to be restricted to contain onlyone geometry type The source ArcSDE data store contained no data TheArcSDE geometry was created with a coordinate system specified

The syntax of the command follows sde2shp -o init -l

ExistingTablefeatgeom -f points -a file=pointstxt -t point -i

esri_sde_ss -u sde -p fdotest The -f argument becomes the root name ofthe shape files that are created by the command (pointsshp pointsshxpointsdbf pointsidx and pointsprj) The -t argument is the shape geometrytype The -i argument is the name of the ArcSDE server instance the symbolicname is mapped to a TCP port in theCWINDOWSsystem32driversetcservices file The -u and -p argumentsidentify a username and password in the data store The -a argument identifiesthe file used to specify the conversion of the non-geometry columnconversions

The contents of the pointstxt conversion file are as follows

Creating SHP Files for the Physical to Logical Schema Mapping | 265

smInt4Col smInt4 N 4

int16Col int16Col N 4

int32Col int32Col N 10

float32Col float32C N 6 2

float64Col float64C N 15 4

int10 Int10 N 10

float4_4 float4_4 N 4 3

double7_4 doubl7_2 N 7 2

string64 str64 C 64

nStringCol nStrCol C 254

dateCol dateCol D 8

NOTE Initial values for column widths and number of decimal places were takenfrom the output of the sdetable -o describe command These values were changedover the course of several executions of the sde2shp in response to warning anderror messages issued by the sde2shp command

ShapeLib

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The ltbasegtshp and ltbasegtshx files are created by the ShapeLibSHPCreatemethod

The ltbasegtprj file is created by using a text editor to create the file andinserting the WKT string specification for the coordinate system

The ltbasegtdbf file is created by the following code

IntPtr dbfFile = MapToolsShapeLibDBFCre

ate(Pointspointsdbf)

int logicalColNum = MapToolsShapeLibDBFAddField(dbfFile Logic

alCol ShapeLibDBFFieldTypeFTLogical 1 0)

int strColNum = MapToolsShapeLibDBFAddField(dbfFile StrCol

ShapeLibDBFFieldTypeFTString 64 0)

int dateColNum = MapToolsShapeLibDBFAddField(dbfFile DateCol

ShapeLibDBFFieldTypeFTDate 8 0)

int integer20_0Num = MapToolsShapeLibDBFAddField(dbfFile In

teger20 ShapeLibDBFFieldTypeFTInteger 20 0)

int double18_4Num = MapToolsShapeLibDBFAddField(dbfFile

Double18_4 ShapeLibDBFFieldTypeFTDouble 18 4)

MapToolsShapeLibDBFClose(dbfFile)

266 | Appendix E OSGeo FDO Provider for SHP

Logical to Physical Schema MappingThe SHP provider supports the DestroySchema and ApplySchema commandsSo it is possible to create shape files whose schema has been defined usingFDO and then map the logical FDO data types to the shape native types Thismapping is described here The creation of the shape file used for this purposeis described in this appendix

Native Type Column Width Decimal PlacesFDO Type

L 1Boolean

D 8DateTime

N gt0 gt0Decimal

N 11Int32

C gt0String

Physical to Logical Schema MappingWhen FDO describes the schema of an existing shapefile that was not createdby the ApplySchema command it maps native data types to FDO data typesTwo shapfiles have been mapped One shapfile has been created using theArcSDE command sde2shp The creation of the source ArcSDE schema isdescribed in the appendix for the ArcSDE provider The other shapfile hasbeen created using a NET wrapper for the ShapeLib C Library These twomethods for creating shapefiles are described in this appendix

The schema name is ldquoDefaultrdquo The class name is the root name of the fileFor example if the filename is ldquopointsshprdquo the class name is ldquopointsrdquo Theattribute property names are the dBASE column names The geometry propertyname is ldquoGeometryrdquo The value of the feature classrsquos SpatialContextAssociationproperty is the name of the coordinate system specified in the prj file Forexample if the coordinate system specification in the prj has the patternldquoPROJCS[]rdquo the value of the SpatialContextAssociation proerty is the valueof the ltnamegt parameter in the pattern ldquoPROJCS[ltnamegt]rdquo

Logical to Physical Schema Mapping | 267

sde2shp

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat came from the conversion of an ArcSDE schema is in the following table

FDO Data TypeNative Type Column Width DecimalPlaces

DecimalN 4

DecimalN 10

DecimalN 6 2

DecimalN 15 4

DecimalN 4 3

DecimalN 7 2

StringC

DateTimeD

ShapeLib

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat was created by a ShapeLib program is in the following table

FDO Data TypeNative Type Column Width Decimal Places

BooleanL 1

StringC 64

DateTimeD 8

DecimalN 20 0

268 | Appendix E OSGeo FDO Provider for SHP

FDO Data TypeNative Type Column Width Decimal Places

DecimalN 18 4

FDO Provider for SHP CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

multiple spatial contexts

Write

Multi-user write

Flush

FDO Provider for SHP Capabilities | 269

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 255 digits (maximum decimalprecision of 255 and maximum decimal scale of 255)

Int32 data type with a maximum length of 4 bytes

String data type with a maximum length of 255

Int32 auto-generated data type

Identity properties of type Int32

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 7 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 11 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 0 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Multiple schemas

Null value constraints

270 | Appendix E OSGeo FDO Provider for SHP

Schema modification

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

FDO Provider for SHP Capabilities | 271

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Within Inside Intersects EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleSingle Int16 Int32 or Int64

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

272 | Appendix E OSGeo FDO Provider for SHP

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

GeometricProperty SpatialContexts(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SHP Capabilities | 273

274

OSGeo FDO Provider forSQL Server Spatial

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in the commandrsquosclass collection The mapping of logical FDO data types to native types isdescribed here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the number ofdigits to the right of the decimal point The maximum number of digits in the nativetype is 38

NOTE The definition of the FDO String data type requires that the length propertybe set

Native TypeFDO Data Type

bitBoolean

tinyintByte

datetimeDateTime

decimal(204)Decimal (precision property is set to 20and scale property is set to 4)

F

275

Native TypeFDO Data Type

floatDouble

smallintInt16

intInt32

bigintInt64

realSingle

nvarchar(64)String (length property set to 64)

geographygeometry with a geodetic coordinate sys-tem

geometrygeometry with a Euclidean coordinate sys-tem

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The database name is used for the feature schema name The table names areused for class names Column names are used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are date datetim2(7) datetimeoffset(7) hierarchyid sql_variatn time(7)and xml The mapping of the rest of the native data types is in the followingtable

276 | Appendix F OSGeo FDO Provider for SQL Server Spatial

NOTE The geography and geometric native types map to the geometric propertytype FDO properties are classified as data geometric object association or rasterOnly the data properties are further classified

FDO TypeNative Type

Int64bigint

BLOBbinary(50)

Booleanbit

Stringchar(10)

DateTimedatetime

Decimaldecimal(180)

Doublefloat

Geometricgeography

Geometricgeometry

BLOBimage

Int32int

Decimalmoney

Stringnchar(10)

Stringntext

Decimalnumeric(180)

Stringnvarchar(50)

Physical to Logical Schema Mapping | 277

FDO TypeNative Type

Stringnvarchar(MAX)

Singlereal

DateTimesmalldatetime

Int16smallint

Decimalsmallmoney

Stringtext

DateTimetimestamp

Bytetinyint

Stringuniqueidentifier

BLOBvarbinary(50)

Stringvarchar(50)

BLOBvarbinary(MAX)

278 | Appendix F OSGeo FDO Provider for SQL Server Spatial

OSGeo FDO Provider forWFS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WFS

What Is FDO Provider for WFSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WFS provides FDO withaccess to a WFS-based data store

An OGC Web Feature Service (WFS) provides access to geographic features thatare stored in an opaque data store in a clientserver environment A client usesWFS to retrieve geospatial data that is encoded in Geography Markup Language(GML) from a single or multiple Web Feature Service The communicationbetween client and server is encoded in XML If the WFS response includesfeature geometries it is encoded in Geography Markup Language (GML) whichis specified in the OpenGIS Geographic Markup Language ImplementationSpecification

Using FDO Provider for WFS data manipulation operations you can do thefollowing

Query features based on spatial and non-spatial constraints

Create new feature instances

Delete feature instances

Update feature instances

G

279

Lock feature instances

For more information see The Essential FDO (FET_TheEssentialFDOpdf)

NOTE There is no public API documentation for the FDO Provider for WFSfunctionality is available through the main FDO API

FDO Provider for WFS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threaded

static spatial content extent type

multiple spatial contexts

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()

280 | Appendix G OSGeo FDO Provider for WFS

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of unknown bytes

Byte data type with a maximum length of unknown bytes

DateTime data type with a maximum length of unknown bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of unknown bytes

Int16 data type with a maximum length of unknown bytes

Int32 data type with a maximum length of unknown bytes

Int64 data type with a maximum length unknown 8 bytes

Single data type with a maximum length of unknown bytes

String data type with a maximum length of unknown

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name (null)

Composite ID

FDO Provider for WFS Capabilities | 281

Multiple schemas

Object properties

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_GetSpatialContexts

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

use of expressions for properties in Select and SelectAggregates commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

282 | Appendix G OSGeo FDO Provider for WFS

Basic expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeoemtry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

FDO Provider for WFS Capabilities | 283

No Raster capabilities are supported

284 | Appendix G OSGeo FDO Provider for WFS

OSGeo FDO Provider forWMS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WMS

What Is FDO Provider for WMSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WMS provides FDO withaccess to a WMS-based data store

An Open Geospatial Consortium (OGC) Web Map Service (WMS) producesmaps of spatially referenced data dynamically from geographic informationThis international standard defines a map to be a portrayal of geographicinformation as a digital image file suitable for display on a computer screen Amap is not the data itself Maps by WMS are generally rendered in a pictorialformat such as PNG GIF or JPEG or occasionally as vector-based graphicalelements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile(WebCGM) formats

The FDO Provider for WMS has the following characteristics

The FDO Provider for WMS serves up map information originating from anOGC Basic Web Map Service that provides pictorially formatted images suchas PNG GIF or JPEG

WMS map data is exposed through an FDO feature schema whose classescontain an FDO Raster property definition The FDO schema exposed fromthe FDO Provider for WMS conforms to a pre-defined FDO schema that is

H

285

specific to WMS and that acts as the basis for all FDO interaction withWMS data regardless of the originating source of the WMS images

WMS data manipulation operations are limited to querying features basedon spatial and non-spatial constraints Schema manipulation operationsare not supported

The FDO Provider for WMS can run in a multi-platform environmentincluding Windows and Linux

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for WMS API Reference Help (WMS_Provider_APIchm)

FDO Provider for WMS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

286 | Appendix H OSGeo FDO Provider for WMS

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

String data type with a maximum length of unknown

BLOB data type with a maximum length of unknown bytes

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Inheritance

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FDO Provider for WMS Capabilities | 287

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_GetSpatialContexts

The following capabilities are supported

simple functions in Select and SelectAggregate commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No filter capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Function expressions are supported

The following functions are supported

BLOB RESAMPLE(BLOB raster Double minX Double minY Double maxXDouble maxY Int32 height Int32 width)

BLOB CLIP(BLOB raster Double minX Double minY Double maxX DoublemaxY)

GeometricProperty SpatialExtents(BLOB raster)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaning

288 | Appendix H OSGeo FDO Provider for WMS

of the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Polygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

The Raster capability is supported The following raster data models aresupported

Bitonal1-bitpixelUnsigned Integer

Gray8-bitpixelUnsigned Integer

RGB24-bitpixelUnsigned Integer

RGBA32-bitpixelUnsigned Integer

Palette8-bitpixelUnsigned Integer

FDO Provider for WMS Capabilities | 289

290

Index

A

AGF 152API

defined 5FDO 5

application development 11architecture and packages 8ArcSDE

limitations 212ArcSDE Provider 211

Capabilities 227 237 249 256 269 280 286

Software Requirements 211association property 15Autodesk Geometry Format (AGF) 152

B

behaviors GisPtr 25BinaryOperations 146

C

calls chain 25capabilities

FDO Provider for ArcSDE 227 237 249 256 269 280 286

classcontained 91feature 14IdentityProperty and

ObjectProperty 91ndash92standalone 91

Class Diagram FDO Schema Element 93class type 14collection classes 23comparison operations 146connection

ArcSDE 216establishing 29

semantics 27constraints expression text 141constraints filter text 141constraints provider-specific 141Contained Class 91context spatial 18

D

data concepts 13data property

defined 15data sources and data stores 27data store 18

defined 18FDO Provider for ArcSDE 211FDO Provider for MySQL 233FDO Provider for ODBC 243FDO Provider for SDF 255FDO Provider for SHP 263FDO Provider for WMS 285filtering 19 139locking 19querying 129schemas and the 85transactions 20

data stores data sources and 27data type

DATETIME 145DOUBLE 145IDENTIFIER 144INTEGER 145PARAMETER 144STRING 144

data type mappings 217data types 144DataStore

FDO Provider for ArcSDE 211develop applications 11dimensionality defined 15

Index | 291

E

edit a GML schema file 101element states schema 94elements of a schema 14example

creating a schema 111creating a schema read in from an

XML file 114deleting property values 127describing a schema 114destroying a schema 114inserting an Integer a string and a

Geometry Value 122query 130schema management 111updating property values 125

expression grammar 143expression text 140Expression defined 19expressions 140

F

factory abstract geometry 159FDO

architecture and packages 8FDO API

defined 5FDO concepts

commands 18data store 18expression 19feature class 14filter 19geometry property 16locking 19object property 17property 15spatial context 18transactions 20

FDO In General 161FDO Provider for ArcSDE

capabilities 227 237 249 256 269 280 286

connection 216

defined 211software requirements 211

FDO Provider for MySQLdefined 233

FDO Provider for ODBCdefined 243

FDO Provider for SDF 255defined 255

FDO Provider for SDF defined 255FDO Provider for SHP

defined 263FDO Provider for WMS

defined 285FDO schema element class diagram 93FDO XML format 95FDOClass 90FDOFeatureClass 90FDOIActivateLongTransaction 136FDOICommitLongTransaction 137FDOICreateLongTransaction 137FDOIDeactivateLongTransaction 136FDOIGetLongTransactions 137FDOIRollbackLongTransaction 136feature class 14feature schema creating a 218filter

grammar 141Filter 139

defined 19filter text 140filters 19

G

geometric types mapping betweenGeometry and 160

geometry 16Geometry

basic or pure 152properties 16types 159value 147working with 151

geometry and geometric types mappingbetween 160

Geometry API 151

292 | Index

GIS_SAFE_RELEASE (ptr) 21ndash22GisPtr 22GML schema file creating and

editing 101

H

handler exception 23

K

keywords filter and expression 144

L

locking 19ArcSDE limitations 213defined 19

long transactiondefined 135leaf 135root 20 135ndash136

M

mappingsdata type 217physical 86

memory management 21models modifying 94

N

non-feature class issues 91non-smart ptr 26

O

object propertydefined 17

ObjectProperty types 90OGC WKT 151operations comparison 146operations data maintenance 119

operator precedence 146operators 146overrides

schema 88

P

packageconnections 27Schema 85

packages FDO 8parent in the schema classes 86properties

base 85Geometry 16

propertyassociation 15data 15defined 15object 17Raster 17

property definitions adding GMLfor 105

property values 120data 120geometry 121

Provider for ArcSDEconnection 216defined 211

Provider for MySQLdefined 233

Provider for ODBCdefined 243

Provider for SHPdefined 263

provider defined 9

Q

querycreating 129example 130

Index | 293

R

raster propertydefined 17

references cross-schema 86requirements

FDO Provider for ArcSDE 211rollback mechanism schema 95root long transaction defined 20

S

SampleFeatureSchemaxml 115schema

defined 13schema elements 14

schema management 111schema mapping defined 14schema overrides 14schema create 89 218schemas

describing 92element states 94modifying models 94rollback mechanism 95working with 88

SDFFDO Provider for 255

software requirements 211spatial context 161spatial context defined 18special characters 147

standalone class 91states schema element 94supported interfaces LT 136

T

text expression 140text filter 140transaction long 20types

Geometry 159ObjectProperty 90

U

UnaryOperations 146

V

valuesdeleting 126updating 125

W

WKT 151

X

XML Format FDO 95

294 | Index

  • Contents
  • About This Guide
    • Audience and Purpose
    • How This Guide Is Organized
    • Whatrsquos New
      • Introduction
        • What Is the FDO API
          • From the Perspective of the Client Application User
          • From the Perspective of the Client Application Engineer
            • Getting Started
            • FDO Architecture and Providers
            • What Is a Provider
            • Developing Applications
              • FDO Concepts
                • Data Concepts
                • Operational Concepts
                  • Development Practices
                    • Memory Management
                    • Collections
                    • Exception Handling
                    • Exception Messages
                    • Managing FdoPtr Behaviors
                      • Establishing a Connection
                        • Connection Semantics
                        • Establishing a Connection
                          • FDO Capabilities
                            • FDO Capabilities
                              • Introduction
                              • Provider Type
                              • Command
                              • Connection
                              • Expression
                              • Filter
                              • Geometry
                              • Raster
                              • Schema
                                • Expressible as Boolean
                                • Not Expressible as a Boolean
                                  • Schema Management
                                    • Schema Package
                                    • Schema Mappings
                                    • Schema Overrides
                                    • Working with Schemas
                                    • FDOFeatureClass
                                    • FDOClass
                                    • Non-Feature Class Issues
                                    • Modifying Models
                                    • Schema Element States
                                    • Rollback Mechanism
                                    • FDO XML Format
                                    • Creating and Editing a GML Schema File
                                    • Schema Management Examples
                                      • Data Maintenance
                                        • Data Maintenance Operations
                                          • Inserting Values
                                          • Updating Values
                                          • Deleting Values
                                            • Related Class Topics
                                              • Performing Queries
                                                • Creating a Query
                                                • Query Example
                                                  • Long Transaction Processing
                                                    • What Is Long Transaction Processing
                                                    • Supported Interfaces
                                                      • Filter and Expression Languages
                                                        • Filters
                                                        • Expressions
                                                        • Filter and Expression Text
                                                        • Language Issues
                                                          • Provider-Specific Constraints on Filter and Expression Text
                                                          • Filter Grammar
                                                          • Expression Grammar
                                                          • Filter and Expression Keywords
                                                          • Data Types
                                                            • Identifier
                                                            • Parameter
                                                            • String
                                                            • Integer
                                                            • Double
                                                            • DateTime
                                                              • Operators
                                                              • Special Character
                                                              • Geometry Value
                                                                  • The Geometry API
                                                                    • Introduction
                                                                    • FGF and WKB
                                                                    • FGF Binary Specification
                                                                    • FGF Text
                                                                    • Abstract and Concrete Classes
                                                                    • Geometry Types
                                                                    • Mapping Between Geometry and Geometric Types
                                                                    • Spatial Context
                                                                    • Specify Dimensionality When Creating Geometries Using String Specifications
                                                                    • Inserting Geometry Values
                                                                      • FDO Cookbook
                                                                        • Introduction
                                                                        • Recommendations
                                                                        • Registry
                                                                        • Connection
                                                                        • Capabilities
                                                                        • Data Store
                                                                        • User Management
                                                                        • Spatial Context
                                                                        • Basic Schema Operations
                                                                        • Insert Data
                                                                        • Select Data
                                                                        • Select Aggregate Data
                                                                        • Delete Data
                                                                        • Schema Overrides
                                                                        • Xml SerializeDeserialize
                                                                          • C
                                                                            • Geometry
                                                                              • Construction
                                                                                • C Namespaces
                                                                                • C Geometry Scaffolding Classes
                                                                                • C Geometries Constructed using IDirectPositionImpl
                                                                                • C Geometries Constructed Using Geometry Subcomponents
                                                                                • C Aggregate Geometries
                                                                                • C Geometries from Text Specifications
                                                                                  • Deconstruction
                                                                                      • OSGeo FDO Provider for ArcSDE
                                                                                        • What Is FDO Provider for ArcSDE
                                                                                        • FDO Provider for ArcSDE Software Requirements
                                                                                          • Installed Components
                                                                                          • External Dependencies
                                                                                            • FDO Provider for ArcSDE Limitations
                                                                                            • ArcSDE Limitations
                                                                                              • Relative to ArcObjects API and ArcGIS Server API
                                                                                                • Curved Segments
                                                                                                  • Locking and Versioning
                                                                                                    • Table Creation
                                                                                                    • Identity Row ID Column and Enable Row Locking
                                                                                                    • Disable Row Locking and Enable Versioning
                                                                                                        • FDO Provider for ArcSDE Connection
                                                                                                        • Data Type Mappings
                                                                                                        • Creating a Feature Schema
                                                                                                        • Logical to Physical Schema Mapping
                                                                                                        • Physical to Logical Schema Mapping
                                                                                                        • FDO Provider for ArcSDE Capabilities
                                                                                                          • OSGeo FDO Provider for MySQL
                                                                                                            • What Is FDO Provider for MySQL
                                                                                                            • Logical to Physical Schema Mapping
                                                                                                            • Physical to Logical Schema Mapping
                                                                                                            • FDO Provider for MySQL Capabilities
                                                                                                              • OSGeo FDO Provider for ODBC
                                                                                                                • What Is FDO Provider for ODBC
                                                                                                                • Physical to Logical Schema Mappings
                                                                                                                • FDO Provider for ODBC Capabilities
                                                                                                                  • OSGeo FDO Provider for SDF
                                                                                                                    • What Is FDO Provider for SDF
                                                                                                                    • FDO Provider for SDF Capabilities
                                                                                                                      • OSGeo FDO Provider for SHP
                                                                                                                        • What Is FDO Provider for SHP
                                                                                                                        • Creating SHP Files for the Logical to Physical Schema Mapping
                                                                                                                        • Creating SHP Files for the Physical to Logical Schema Mapping
                                                                                                                        • Logical to Physical Schema Mapping
                                                                                                                        • Physical to Logical Schema Mapping
                                                                                                                        • FDO Provider for SHP Capabilities
                                                                                                                          • OSGeo FDO Provider for SQL Server Spatial
                                                                                                                            • Logical to Physical Schema Mapping
                                                                                                                            • Physical to Logical Schema Mapping
                                                                                                                              • OSGeo FDO Provider for WFS
                                                                                                                                • What Is FDO Provider for WFS
                                                                                                                                • FDO Provider for WFS Capabilities
                                                                                                                                  • OSGeo FDO Provider for WMS
                                                                                                                                    • What Is FDO Provider for WMS
                                                                                                                                    • FDO Provider for WMS Capabilities
                                                                                                                                      • Index
Page 5: here - OSGeo Download Server

Chapter 9 Performing Queries 129Creating a Query 129Query Example 130

Chapter 10 Long Transaction Processing 135What Is Long Transaction Processing 135Supported Interfaces 136

Chapter 11 Filter and Expression Languages 139Filters 139Expressions 140Filter and Expression Text 140Language Issues 141

Provider-Specific Constraints on Filter and Expression Text 141Filter Grammar 141Expression Grammar 143Filter and Expression Keywords 144Data Types 144

Identifier 144Parameter 144String 144Integer 145Double 145DateTime 145

Operators 146Special Character 147Geometry Value 147

Chapter 12 The Geometry API 151Introduction 151FGF and WKB 151FGF Binary Specification 152FGF Text 158Abstract and Concrete Classes 158Geometry Types 159Mapping Between Geometry and Geometric Types 160Spatial Context 161Specify Dimensionality When Creating Geometries Using String

Specifications 161Inserting Geometry Values 162

Chapter 13 FDO Cookbook 163Introduction 163

Contents | v

Recommendations 163Registry 163Connection 164Capabilities 168Data Store 171User Management 173Spatial Context 175Basic Schema Operations 178Insert Data 181Select Data 182Select Aggregate Data 183Delete Data 184Schema Overrides 184Xml SerializeDeserialize 194

C 1 9 4Geometry 196

Construction 196C Namespaces 197C Geometry Scaffolding Classes 197C Geometries Constructed using

IDirectPositionImpl 200C Geometries Constructed Using Geometry

Subcomponents 201C Aggregate Geometries 202C Geometries from Text Specifications 204

Deconstruction 204

Appendix A OSGeo FDO Provider for ArcSDE 211What Is FDO Provider for ArcSDE 211FDO Provider for ArcSDE Software Requirements 211

Installed Components 211External Dependencies 212

FDO Provider for ArcSDE Limitations 212ArcSDE Limitations 212

Relative to ArcObjects API and ArcGIS Server API 213Curved Segments 213

Locking and Versioning 213Table Creation 214Identity Row ID Column and Enable Row Locking 214Disable Row Locking and Enable Versioning 215

FDO Provider for ArcSDE Connection 216Data Type Mappings 217Creating a Feature Schema 218Logical to Physical Schema Mapping 223Physical to Logical Schema Mapping 223FDO Provider for ArcSDE Capabilities 227

vi | Contents

Appendix B OSGeo FDO Provider for MySQL 233What Is FDO Provider for MySQL 233Logical to Physical Schema Mapping 234Physical to Logical Schema Mapping 235FDO Provider for MySQL Capabilities 237

Appendix C OSGeo FDO Provider for ODBC 243What Is FDO Provider for ODBC 243Physical to Logical Schema Mappings 244FDO Provider for ODBC Capabilities 249

Appendix D OSGeo FDO Provider for SDF 255What Is FDO Provider for SDF 255FDO Provider for SDF Capabilities 256

Appendix E OSGeo FDO Provider for SHP 263What Is FDO Provider for SHP 263Creating SHP Files for the Logical to Physical Schema Mapping 264Creating SHP Files for the Physical to Logical Schema Mapping 265Logical to Physical Schema Mapping 267Physical to Logical Schema Mapping 267FDO Provider for SHP Capabilities 269

Appendix F OSGeo FDO Provider for SQL Server Spatial 275Logical to Physical Schema Mapping 275Physical to Logical Schema Mapping 276

Appendix G OSGeo FDO Provider for WFS 279What Is FDO Provider for WFS 279FDO Provider for WFS Capabilities 280

Appendix H OSGeo FDO Provider for WMS 285What Is FDO Provider for WMS 285FDO Provider for WMS Capabilities 286

Index 291

Contents | vii

viii

About This Guide

The FDO Developerrsquos Guide introduces the Feature Data Objects (FDO) application programminginterface (API) and explains how to use its customization and development features

NOTE For detailed information about installing the FDO SDK and getting started usingthe FDO API see The Essential FDO (FET_TheEssentialFDO)

Audience and PurposeThis guide is intended to be used by developers of FDO applications It introducesthe FDO API explains the role of a feature provider and provides detailedinformation and examples about how to code your application

How This Guide Is OrganizedThis guide consists of the following chapters and appendixes

Introduction provides an overview of the FDO API and the function of FDOfeature providers

FDO Concepts on page 13 describes the key data and operational conceptsupon which FDO is constructed

Development Practices on page 21 discusses the best practices to followwhen using FDO for application development

Establishing a Connection on page 27 describes how to establish aconnection to an FDO provider

1

1

Capabilities discusses the Capabilities API which is used to determine thecapabilities of a particular provider

Schema Management on page 85 describes how to create and work withschemas and presents the issues related to schema management

Data Maintenance on page 119 provides information about using the FDOAPI to maintain the data

Performing Queries on page 129 describes how to create and performqueries

Long Transaction Processing on page 135 discusses long transactions (LT)and how to implement LT processing in your application

Filter and Expression Languages on page 139 discusses the use of filterexpressions to specify to an FDO provider how to identify a subset of theobjects of an FDO data store

The Geometry API on page 151 discusses the various Geometry types andformats and describes how to work with the Geometry API to developFDO-based applications

OSGeo FDO Provider for ArcSDE on page 211 discusses development issuesthat apply when using FDO Provider for ESRIreg ArcSDEreg

OSGeo FDO Provider for MySQL on page 233 discusses development issuesthat apply when using FDO Provider for MySQL

OSGeo FDO Provider for ODBC on page 243 discusses development issuesthat apply when using FDO Provider for ODBC

OSGeo FDO Provider for SDF on page 255 discusses development issuesthat apply when using FDO Provider for SDF

OSGeo FDO Provider for SHP on page 263 discusses development issuesthat apply when using FDO Provider for SHP (Shape)

OSGeo FDO Provider for WFS on page 279 discusses development issuesthat apply when using FDO Provider for WFS

OSGeo FDO Provider for WMS on page 285 discusses development issuesthat apply when using FDO Provider for WMS

Expression Functions outlines the signatures and implementation detailsfor the enhanced expression functions

2 | Chapter 1 About This Guide

Whatrsquos NewThis section summarizes the changes and enhancements you will find in thisversion of FDO

Enhanced Set of Expression Functions

The enhanced set includes aggregate conversion date mathematical numericstring and geometry functions All functions are supported by all providerswith the exception of the Raster WFS and WMS providers

For more information and implementation details about the expressionfunction signatures the RDBMS-specific built-in support for some of thefunctions and the provider-specific support see the appendix ExpressionFunctions

Whatrsquos New | 3

4

Introduction

You can use the APIs in the FDO API to manipulate define and analyze geospatial information

This chapter introduces application development with the FDO API and explains the role ofa feature provider

What Is the FDO API

From the Perspective of the Client Application User

The FDO API is a set of APIs used for creating managing and examininginformation enabling Autodesk GIS products to seamlessly share spatial andnon-spatial information with minimal effort

FDO is intended to provide consistent access to feature data whether it comesfrom a CAD-based data source or from a relational data store that supports richclassification To achieve this FDO supports a model that can readily supportthe capabilities of each data source allowing consumer applications functionalityto be tailored to match that of the data source For example some data sourcesmay support spatial queries while others do not Also a flexible metadata modelis required in FDO allowing clients to adapt to the underlying feature schemaexposed by each data source

From the Perspective of the Client ApplicationEngineer

The FDO API provides a common general purpose abstraction layer for accessinggeospatial data from a variety of data sources The API is in part an interface

2

5

specification of the abstraction layer A provider such as OSGeo FDO Providerfor MySQL is an implementation of the interface for a specific type of datasource (for example for a MySQL relational database) The API supports thestandard data store manipulation operations such as querying updatingversioning locking and others It also supports analysis

The API includes an extensive set of methods that return information aboutthe capabilities of the underlying data source For example one methodindicates whether the data source supports the creation of multiple schemasand another indicates whether the data source supports schema modification

A core set of services for providers is also available in the API such as providerregistration schema management filter and expression construction andXML serialization and deserialization

The API uses an object-oriented model for the construction of feature schemaA feature is a class and its attributes including its geometry are a propertyof the class The instantiation of a feature class a Feature Data Object (FDO)can contain other FDOs

Getting StartedFor detailed information to help you install and get started using Feature DataObjects (FDO) see The Essential FDO It provides details about connecting toand configuring providers data store management (createdelete) user IDs(create grant permissions) and spatial context

6 | Chapter 2 Introduction

FDO Architecture and ProvidersThe following diagram shows the high-level overview architecture of the FDOAPI and included FDO providers

FDO Architecture and Providers | 7

FDO Architecture and Providers

FDO Packages

FDO is assembled in conceptual packages of similar functionality Thisconceptual packaging is reflected in the substructure of the FDO SDK ldquoincludesrdquofolder For more information about the structure see The Essential FDO

FDO commands provider-specific commands and connections and capabilitiesprovide access to native data stores through each different FDO providerSchema management (through XML) client services and filters and expressionsare provider-independent packages that tie into the FDO API Each of theseare explained in more detail in subsequent sections

8 | Chapter 2 Introduction

The FDO API consists of classes grouped within the following packages

Commands package Contains a collection of classes that provide thecommands allowing the application to select and update features definenew types of feature classes lock features and perform analysis on featuresEach Command object executes a specific type of command against theunderlying data store In addition FDO providers expose one or moreCommand objects

ConnectionsCapabilities Contains a collection of classes that establishand manage the connection to the underlying data store Connectionobjects implement the FdoIConnection interface Capabilities API providesthe code for retrieving the various FDO provider capability categories suchas connection or schema capabilities You can use this this API to determinethe capabilities of a particular provider

Filters and Expression package Contains a collection of classes that definefilters and expression in FDO which are used to identify a subset of objectsof an FDO data store

Client Services package Contains a collection of classes that define theclient services in FDO that for example enable support for dynamiccreation of connection objects given a provider name

Schema package and FDO XML Contains a collection of classes thatprovides a logical mechanism for specifying how to represent geospatialfeatures The FDO feature schema is based somewhat on a subset of theOpenGIS and ISO feature models FDO feature schemas can be written toan XML file The FdoFeatureSchema and FdoFeatureSchemaCollectionclasses support the FdoXmlSerializable interface

In addition FDO is integrated with the Geometry API which includes theclasses that support specific Autodesk applications and APIs including FDO

For more information about each of the FDO packages see FDO API ReferenceHelp and subsequent chapters in this guide

Provider API(s) complete the FDO API configuration Each provider has aseparate API reference Help

What Is a ProviderA provider is a specific implementation of the FDO API It is the softwarecomponent that provides access to data in a particular data store

What Is a Provider | 9

For this release the providers that are included are as follows

NOTE For more information see the Open Source Geospatial Foundation websiteat wwwOSGeoorg

OsGeo FDO Provider for ArcSDE Readwrite access to feature data in anESRI ArcSDE-based data store (that is with an underlying Oracle or SQLServer database) Supports describing schema and inserting selectingupdating and deleting feature data in existing schemas does not supportcreating or deleting schemas

OsGeo FDO Provider for MySQL Readwrite access to feature data in aMySQL-based data store Supports spatial data types and spatial queryoperations A custom API can gather information transmit exceptions listdata stores and create connection objects MySQL architecture supportsvarious storage engines characteristics and capabilities

OsGeo FDO Provider for ODBC Readwrite access to feature data in anODBC-based data store Supports XYZ feature objects and can define featureclasses for any relational database table with X Y and optionally Zcolumns does not support creating or deleting schema Object locationsare stored in separate properties in the object definition

OsGeo FDO Provider for SDF Read-write access to feature data in anSDF-based data store Autodeskrsquos geospatial file format SDF supportsmultiple featuresattributes provides high performance for large data setsand interoperability with other Autodesk products and spatial indexingThe SDF provider a valid alternative to database storage Note that thisrelease of the SDF provider supports version 30 of the SDF file format

OsGeo FDO Provider for SHP Readwrite access to existing spatial andattribute data in an ESRI SHP-based data store which consists of separateshape files for geometry index and attributes Each SHP and its associatedDBF file is treated as a feature class with a single geometry property Thisis a valid alternative to database storage but does not support locking

OsGeo FDO Provider for WFS Read-only access to feature data in an OGCWFS-based data store Supports clientserver environment and retrievesgeospatial data encoded in GML from one or more Web Feature Servicessites Clientserver communication is encoded in XML with the exceptionof feature geometries which are encoded in GML Note that there is nopublic API documentation for this provider all functionality is accessiblevia the base FDO API

10 | Chapter 2 Introduction

OsGeo FDO Provider for WMS Read-only access to feature data in an OGCWMS-based data store Web Map Service (WMS) produces maps of spatiallyreferenced data dynamically from geographic information which aregenerally rendered in PNG GIF or JPEG or as vector-based Scalable VectorGraphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats

FDO supports retrieval and update of spatial and non-spatial GIS feature datathrough a rich classification model that is based on OpenGIS and ISOstandards

An overview of the relationships between providers data sources data storesand schemas is presented in the FDO Architecture and Providers graphic

For more detailed information about the providers see the appropriateappendix in this document Data sources and data stores are discussed in theEstablishing a Connection on page 27 chapter Schema concepts are discussedin the Schema Management on page 85 chapter

Developing ApplicationsYou will need to perform several major tasks in using the FDO API to developa custom application Each of these tasks breaks down into a number of moredetailed coding issues

The major development tasks are

Working with the Build Environment

Establishing a Connection

Schema Management

Data Maintenance

Creating Queries

Using Custom Commands (Provider-Specific)

These tasks are explored in detail in the chapters that follow

Developing Applications | 11

12

FDO Concepts

Before you can work properly with the FDO API you need to have a good understanding ofits basic underlying concepts This chapter defines the essential constructs and dynamicsthat comprise the FDO API The definitions of these constructs and dynamics are groupedinto two interdependent categories

Data Concepts Definitions of the data constructs that comprise the FDO API

Operational Concepts Definitions of the operations that are used to manage andmanipulate the data

Data ConceptsAll concepts that are defined in this section relate to the data that FDO isdesigned to manage and manipulate

What Is a Feature

A feature is an abstraction of a natural or man-made real world object It isrelated directly or indirectly to geographic locations A spatial feature has oneor more geometric properties For example a road feature might be representedby a line and a hydrant might be represented by a point A non-spatial featuredoes not have geometry but can be related to a spatial feature which does Forexample a road feature may contain a sidewalk feature that is defined as notcontaining a geometry

What Is a Schema

A schema is a logical description of the data types used to model real-worldobjects A schema is not the actual data instances (that is not a particular roador land parcel) rather it is metadata A schema is a model of the types of data

3

13

that would be found in a data store For example a schema which models thelayout of city streets has a class called Road and this class has a property calledName The definition of Road and its associated classes constitute the schema

What Is a Schema Override

A schema override comprises instructions to override the default schemamappings For example an RDBMS-type FDO provider could map a featureclass to a table of the same name by default A schema override might mapthe class to a differently named table for example by mapping the poleclass to the telco_pole table

What is a Schema Mapping

A Schema Mapping is a correspondence between a Schema Element and aphysical object in a data store For example OSGeo FDO Provider for MySQLmaps each Feature Class onto a table in the MySQL database where the datastore resides The physical structure of data stores for each FDO provider canvary greatly so the types of Schema Mappings can also vary between providersEach provider defines a set of default schema mappings For example OSGeoFDO Provider for MySQL maps a class to a table of the same name by defaultThese defaults can be overridden by specifying Schema Overrides

What Are Elements of a Schema

A schema consists of a collection of schema elements In the FDO API schemaelements are related to one another by derivation and by aggregation Anelement of a schema defines a particular type of data such as a feature classor a property or an association For example a feature class definition for aroad includes the class name (for example Road) and the class properties (forexample Name NumberLanes PavementType and Geometry)

What Is a Class Type

A class type is a specialization of the base FDO class definition(FdoClassDefinition) It is used to represent the complex properties of spatialand non-spatial features

What is a Feature Class

A feature class is a schema element that describes a type of real-world objectIt includes a class name and property definitions including zero or moregeometric properties It describes the type of data that would be included inobject instances of that type

14 | Chapter 3 FDO Concepts

What Is a Property

A property is a single attribute of a class and a class is defined by one or moreproperty definitions For example a Road feature class may have propertiescalled Name NumberLanes or Location A property has a particular typewhich can be a simple type such as a string or number or a complex typedefined by a class such as an Address type which itself is defined by a set ofproperties such as StreetNumber StreetName or StreetType

There are five kinds of properties association properties data propertiesgeometric properties object properties and raster properties

Individual properties are defined in the following sections

What Is an Association Property

The FdoAssociationPropertyDefinition class is used to model a peer-to-peerrelationship between two classes This relationship is defined at schemacreation time and instantiated at object creation time The association propertysupports various cardinality settings cascading locks and differing deleterules An FDO filter can be based on association properties andFdoIFeatureReader can handle associated objects through the GetObject()method

What Is a Data Property

A data property is a non-spatial property An instance of a data propertycontains a value whose type is either boolean byte datetime decimal singledouble Int16 Int32 Int64 string binary large object or character large object

What Is Dimensionality

Dimensionality and the concept of dimension has two different meaningsin the discussion of geometry and geometric property

The first is called shape dimensionality and it is defined by theFdoGeometricType enumeration The four shapes are point (0 dimensions)curve (1 dimensions) surface (2 dimensions) and solid (3 dimensions)

The other is called ordinate dimensionality and it is defined by theFdoDimensionality enumeration There are four ordinate dimensions XYXYZ XYM and XYZM M stands for measure

Data Concepts | 15

What Is a Geometric Property

An instance of a geometric property contains an object that represents ageometry value The definition of the geometric property may restrict anobject to represent a geometry that always has the same shape such as a pointor it could allow different object instances to have different dimensions Forexample one geometric property object could represent a point and anothercould represent a line Any combination of shapes is permissible in thespecification of the geometric types that a geometry property definitionpermits The default geometric property specifies that an object could representa geometry that is any one of the four shapes

With respect to ordinate dimensionality all instances of a geometric propertymust have the same ordinate dimension The default is XY

Geometric property definitions have two attributes regarding ordinatedimensionality HasElevation for Z and HasMeasure for M

What is a Geometry

A geometry is represented using geometric constructs either defined as listsof one or more XY or XYZ points or defined parametrically for example asa circular arc While geometry typically is two- or three-dimensional it mayalso contain the measurement dimension (M) to provide the basis for dynamicsegments

The geometry types are denoted by the FdoGeometryType enumeration anddescribe the following

Point

LineString (one or more connected line segments defined by positions atthe vertices)

CurveString (a collection of connected circular arc segments and linearsegments)

Polygon (a surface bound by one outer ring and zero or more interior ringsthe rings are closed connected line segments defined by positions at thevertices)

CurvePolygon (a surface bound by one outer ring and zero or more interiorrings the rings are closed connected curve segments)

MultiPoint (multiple points which may be disjoint)

MultiLineString (multiple LineStrings which may be disjoint)

16 | Chapter 3 FDO Concepts

MultiCurveString (multiple CurveStrings which may be disjoint)

MultiPolygon (multiple Polygons which may be disjoint)

MultiCurvePolygon (multiple CurvePolygons which may be disjoint)

MultiGeometry (a heterogenous collection of geometries which may bedisjoint)

Most geometry types are defined using either curve segments or a series ofconnected line segments Curve segments are used where non-linear curvesmay appear The following curve segment types are supported

CircularArcSegment (circular arc defined by three positions on the arc)

LineStringSegment ( a series of connected line segments defined bypositions are the vertices)

There are currently no geometries of type ldquosolidrdquo (3D shape dimensionality)supported

The FdoIConnectionGetGeometryCapabilities() method can be used to querywhich geometry types and ordinate dimensionalities are supported by aparticular provider

What Is an Object Property

An object property is a complex property type that can be used within a classand an object property itself is defined by a class definition For examplethe Address type example described previously in the Property definition Anobject property may define a single instance for each class object instance (forexample an address property of a land parcel) or may represent a list ofinstances of that class type per instance of the owning class (for exampleinspection records as a complex property of an electrical device feature class)

What is a Raster Property

A raster property defines the information needed to process a raster imagefor example the number of bits of information per pixel the size in pixels ofthe X dimension and the size in pixels of the Y dimension needed to processa raster image

Data Concepts | 17

What Is a Spatial Context

A spatial context describes the general metadata or parameters within whichgeometry for a collection of features resides In particular the spatial contextincludes the definition of the coordinate system spheroid parameters unitsspatial extents and so on for a collection of geometries owned by features

Spatial context can be described as the ldquocoordinate system plus identityrdquo Anygeometries that are to be spatially related must be in a common spatial context

The identity component is required in order to support separate workspacessuch as schematic diagrams which are non-georeferenced Also it supportsgeoreferenced cases For example two users might create drawings using somedefault spatial parameters (for example rectangular and 10000x10000)although each drawing had nothing to do with the other If the drawings wereput into a common database the users could preserve not only the spatialparameters but also the container aspect of their data using spatial context

For more information about spatial context see Spatial Context on page 161

What is a Data Store

A data store is a repository of an integrated set of objects The objects in a datastore are modeled either by classes or feature classes defined within one ormore schemas For example a data store may contain data for both a LandUseschema and a TelcoOutsidePlant schema Some data stores can represent datain only one schema while other data stores can represent data in manyschemas (for example RDBMS-based data stores such as MySQL)

Operational ConceptsThe concepts that are defined in this section relate to the FDO operations usedto manage and manipulate data

What Is a Command

In FDO the application uses a command to select and update features definenew types of feature classes lock features version features and perform someanalysis of features Each Command object executes a specific type of commandagainst the underlying data store Interfaces define the semantics of eachcommand allowing them to be well-defined and strongly typed Because FDOuses a standard set of commands providers can extend existing commandsand add new commands specific to that provider Feature commands execute

18 | Chapter 3 FDO Concepts

against a particular connection and may execute within the scope of atransaction

An FDO command is a particular FDO interface that is used by the applicationto invoke an operation against a data store A command may retrieve datafrom a data store (for example a Select command) may update data in a datastore (for example an Update or Delete command) may perform some analysis(for example an Activate Spatial Context command) or may cause some otherchange in a data store or session (for example a Begin Transaction command)

What Is an Expression

An expression is a construct that an application can use to build up a filterAn expression is a clause of a filter or larger expression For example ldquoLanesgt=4 and PavementType = Asphaltrdquo takes two expressions and combines themto create a filter

For more information about using expressions with FDO see Filter andExpression Languages on page 139

What Is a Filter

A filter is a construct that an application specifies to an FDO provider toidentify a subset of objects of an FDO data store For example a filter may beused to identify all Road type features that have 2 lanes and that are within200 metres of a particular location Many FDO commands use filter parametersto specify the objects to which the command applies For example a Selectcommand uses a filter to identify the objects that the application wants toretrieve Similarly a Delete command uses a filter to identify the objects thatthe application wants to delete from the data store

For more information about using filters with FDO see Filter and ExpressionLanguages on page 139

What Is Locking

A user can use locking to gain update control of an object in the data store tothe exclusion of other users There are two general types of locksmdashtransactionlocks and persistent locks Transaction locks are temporary and endure onlyfor the duration of the transaction (see What Is a Transaction on page 20)

Persistent locks applied to objects by a user remain with the object until eitherthat user removes those locks or the locks are removed by another user withthe appropriate authority

Operational Concepts | 19

What Is a Transaction

A transaction changes the data store in some way The way these changesaffect the data store is determined by the transactionrsquos properties For examplethe Atomic property specifies that either all changes happen or non happenIn transaction processing the data store treats a series of commands as a singleatomic unit of change to that data store Either all changes generated by thecommands are successful or the whole set is cancelled A transaction is a singleatomic unit of changes to a data store The application terminates a transactionwith either a ldquocommitrdquo which applies the set of changes or a ldquorollbackrdquowhich cancels the set of changes Further the data store may automaticallyroll back a transaction if it detects a severe error in any of the commandswithin the transaction A transaction has the following properties

Atomic Either all changes generated by the commands within a transactionhappen or none happen

Consistent The transaction leaves the data store in a consistent stateregarding any constraints or other data integrity rules

Isolated Changes being made within a transaction by one user are notvisible to other users until after that transaction is committed

Durable After a transaction is completed successfully the changes arepersistent in the data store on disk and cannot be lost if the program orprocessor fails

What Is a Long Transaction

A long transaction (LT) is an administration unit used to group conditionalchanges to objects Depending on the situation such a unit might containconditional changes to one or to many objects Long transactions are used tomodify as-built data in the database without permanently changing the as-builtdata Long transactions can be used to apply revisions or alternates to anobject

What Is a Root Long Transaction

A root long transaction is a long transaction that represents permanent dataAny long transaction has a root long transaction as an ancestor in its longtransaction dependency graph

20 | Chapter 3 FDO Concepts

Development Practices

This chapter explains several practices to follow when working with the FDO API and providesexamples of how to follow these practices

Memory ManagementSome FDO functions (for example the Create methods) allocate memory whenthey are called This memory needs to be freed to prevent memory leaks Alldestructors on FDO classes are protected so you must call a Release() functionto destroy them (thus freeing their allocated memory) Each class inherits fromthe FdoIDisposable class which defines the Release() method and the AddRef()method

In addition these classes are reference counted and the count is increased (byAddRef()) when you retrieve them through a Get function After finishing withthe object you need to release it (just as with COM objects) The object isdestroyed only when the reference count hits 0 Two macros are defined to helpin the use of the Release() and AddRef() methods

FDO_SAFE_RELEASE (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_RELEASE calls the release() methodof the object pointed to by the ldquoptrrdquo argument and then sets the local pointerto the object to NULL The macro definition is define FDO_SAFE_RELEASE(x)

if (x) (x)-gtRelease() (x) = NULL

FdoFeatureClass pBase = myClass-gtGetBaseClass()

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

4

21

FDO_SAFE_ADDREF (ptr)

If the ldquoptrrdquo argument is not null FDO_SAFE_ADDREF calls the AddRef()method of the object pointed to by the ldquoptrrdquo argument The macro definitionis define FDO_SAFE_ADDREF(x) ((x = NULL) (x)-gtAddRef() (x)

(NULL))

return FDO_SAFE_ADDREF(value)returns NULL if value equals NULL orincrements the reference count of the object that value points to andreturns value

m_list[index] = FDO_SAFE_ADDREF(value) assigns NULL to the arrayentry if value is NULL or increments the reference count of the object thatvalue points to and assigns value to the array entry

FdoPtr

An FdoPtr smart pointer is provided to help manage memory You wrap anFDO object in a FdoPtr The requirement is that the objectrsquos type must inheritfrom FdoIDisposable The object is then released automatically when theFdoPtr goes out of scope The following code illustrates how to use FdoPtr

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

No need to call FDO_SAFE_RELEASE

Before it is destroyed pBase calls Release() on the FdoFeature

Class object

NOTE If for some reason you wanted to use FDO_SAFE_RELEASE on an FdoPtryou would have to use an FdoPtr method to get a pointer to the object that FdoPtrwraps and pass that pointer to FDO_SAFE_RELEASE

You can use FdoPtr for your own classes by inheriting from the abstract classFdoIDisposable and providing an implementation for the Dispose() method(typically delete this)

FdoPtr Typedefs

Typedefs are provided that define identifiers representing Fdo classes wrappedbyFdoPtr An example is typedef FdoPtrltFdoClassgt FdoClassP

22 | Chapter 4 Development Practices

CollectionsYou can use FDO collection template classes to store your own objects Therequirements for your collection class and the class used to instantiate thetemplate are the same as those for wrapping a class in a FdoPtr

Exception HandlingIn the FDO API FdoCommandException class is the exception type thrownfrom classes in the Commands package and FdoConnectionException classis the exception type thrown from classes in the Connections package Bothof these exception types derive from a language-level exception class that isenvironment-specific

All exceptions are derived from the FdoException class To catch and processspecific exception types nest catch statements as in the following example

try

code

catch (FdoCommandException ex)

process message

catch (FdoException ex)

process message

In some cases underneath an FDO command the FDO level throws anFdoException The FDO command then traps the FdoException and wraps itin an FdoCommandException (or FdoSchemaException for a schemacommand) In this case several messages are returned by one exception Thefollowing example shows how to process multiple messages from oneexception

catch ( FdoSchemaException ex )

Loop through all the schema messages

FdoException currE = ex

while ( currE )

CW2A msg(currE-gtGetExceptionMessage())

acutPrintf (FdoConnectionException sn msg)

currE = currE-gtGetCause()

Collections | 23

An application function may need to catch and then re-throw exceptions inorder to clean up memory However the need to do this can be eliminatedby using FdoPtr The following example cleans up memory on error

FdoFeatureClass pBase = NULL

try

pBase = myClass-gtGetBaseClass()

catch ()

FDO_SAFE_RELEASE(pBase)

throw

Must release reference added by GetBaseClass when done

FDO_SAFE_RELEASE(pBase)

The catch and rethrow is unnecessary when FdoPtr is used

FdoPtrltFdoFeatureClassgt pBase = myClass-gtGetBaseClass()

Exception MessagesException messages are localized On Windows the localized strings are inresource-only DLLs and on Linux they are in catalogs The message DLLs arein the bin folder the DLL name contains Message or Msg The catalog filesare in the usrlocalfdo-320nls directory the names of these files ends in catNLS stands for National Language Support

On Linux set the NLSPATH environment variable so that the runtime codecan locate the message catalogs For example exportNLSPATH=usrlocalfdo-320nlsN

On Windows you do not have do anything special to enable the runtime codeto locate the message DLLs

The contents of the exception message files are indexed When you call oneof the FdoExceptionNLSGetMessage methods declared in Exceptionh youprovide a message number argument You may also provide a default messagestring argument In the event that the exception message resource file cannotbe found the default message is subsituted instead If the default messagestring is not provided and the resource file cannot be found the messagenumber is used as the exception message Not finding the resource file canonly happend on Linux and only if the NLSPATH envrionment variable is notset

24 | Chapter 4 Development Practices

The following two examples when called on Linux with the NLSPATHenvironment variable not set show the use of the default message and themessage number in the exception message

The following is an example of using the default string throwFdoSchemaExceptionCreate(NlsMsgGet1(FDORDBMS_333 Class 1$lsnot

found value-gtGetText()))

The following is an example of not setting the default string and using themessage number instead FdoSchemaException pNewException =

FdoSchemaExceptionCreate(

FdoSmErrorNLSGetMessage(FDO_NLSID(FDOSM_221)

pFeatSchema-gtGetName()) pException)

Managing FdoPtr BehaviorsThe topics in this section describe several ways that you can manager FdoPtrbehavior For more information about managing FdoPtr behavior see therelated topics ldquoFdoPtr ltTgt Class Template Referencerdquo and ldquoFdoIDisposableClass Referencerdquo in the FDO Reference Help and The Essential FDO

Chain Calls

Do not chain calls If you do returned pointers will not be released Forexample given an FdoClassDefinition pclassDef

psz = pclassDef -gtGetProperties()-gtGetItem(0)-gtGetName())

The above code would result in two memory leaks Instead use

FdoPropertyDefinitionCollection pprops = pclassDef -gt GetProper

ties()

FdoPropertyDefinition ppropDef = pprops-gtGetItem(0)

psz = propDef-gtGetName()

ppropDef-gtRelease()

pprops-gtRelease()

or (with FdoPtr)

FdoPtrltFdoPropertyDefinitionCollectiongt pprops = pclassDef-gt Get

Properties()

FdoPtrltFdoPropertyDefinitiongt ppropDef = pprops-gt GetItem(0)

psz = propDef-gtGetName()

or (also with FdoPtr)

Managing FdoPtr Behaviors | 25

psz = FdoPtr ltFdoPropertyDefinitiongt (FdoPtr ltFdoPropertyDefini

tionCollectiongt(pclassDef-gtGetProperties())-gt GetItem(0))-gtGet

Name()

Assigning Return Pointer of an FDO Function Call to a Non-SmartPointer

If you are assigning the return pointer of an FDO function call to a non-smartpointer then you should assign that pointer to a FdoPtr For example

FdoLineString P = gfCreateLineString()

FdoPtr ltFdoLineStringgt p2 = FDO_SAFE_ADDREF(p)

26 | Chapter 4 Development Practices

Establishing aConnection

This chapter explains how to establish a connection to an FDO provider and provides aconnection example

Connection SemanticsData Sources and Data Stores

The FDO API uses connection semantics to implement access to feature schemadata The term data store is used to refer to a collection of zero or more objectswhich instantiate class definitions belonging to one or more FDO feature schemaThe connection is to a data store because that is where data objects are storedThe underlying data source technologies used to hold data stores can berelational databases such as a MySQL database or a file-based solution suchas an SDF file

The mapping of a data store to data source technology can be one-to-one ormany-to-one For example it is

One-to-one when the connection is made by way of the OSGeo FDO Providerfor ArcSDE and the ArcSDE server is using an Oracle database

Many-to-one when the data source is a MySQL database and the connectionis made by way of the OSGeo FDO Provider for MySQL (in this case the datastore is like a container within a container)

When many-to-one mapping is possible a connection can be made in one ortwo steps For more information see Establishing a Connection on page 29 andThe Essential FDO

5

27

The underlying data source technologies differ in the connection parametersused for connecting to a particular provider The values for these parametersare generated during the installation and configuration of the containertechnologies For more information about these values and the process ofinstalling and configuring the associated data source technologies see theappropriate appendix in this document and The Essential FDO

Providers

You connect to a data store by way of a provider

The FDO API contains a registry interface that you can use to register orderegister a provider See the class FdoProviderRegistry inIncFdoClientServicesProviderRegistryh

The providers are registered during the initialization of the FDO SDK In orderto connect to a provider you will need the name of the provider in a particularformat ltCompanyFoundationOriginatorgtltProvidergtltVersiongt TheltCompanyFoundationOriginatorgt and ltProvidergt values are invariable Forspecific values see The Essential FDO

In order to connect you will need the full name including the ltVersiongtvalue You can retrieve the full name from the registry and display the set ofprovider names in a connection menu list If for whatever reason youderegister a provider save the registry information for that provider in caseyou want to reregister it again The provider object returned by the registryhas a Set() method to allow you to change values However the only valueyou can safely change is the display name Sample code for using the providerregistry is located in Establishing a Connection on page 29

The registry contains the following information about a provider

Name The unique name of the feature provider This name should be ofthe form ltCompanyFoundationOriginatorgtltProvidergtltVersiongt forexample AutodeskOracle30 or OSGeoMySQL30

DisplayName A user-friendly display name of the feature provider Theinitial values of this property for the pre-registered providers are ldquoAutodeskFDO Provider for Oraclerdquo ldquoOSGeo FDO Provider for SDFrdquo etc or theequivalent in the language of the country where the application is beingused

Description A brief description of the feature provider For example thethe OsGeo FDO Provider for SDF description is ldquoReadwrite access toAutodesks spatial database format a file-based personal geodatabase thatsupports multiple featuresattributes spatial indexing and file-lockingrdquo

28 | Chapter 5 Establishing a Connection

Version The version of the feature provider The version number stringhas the form ltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgtfor example 3000

FDOVersion The version of the feature data objects specification to whichthe feature provider conforms The version number string has the formltVersionMajorgtltVersionMinorgtltBuildMajorgtltBuildMinorgt for example3010

libraryPath The FULL library path including the library name of theprovider for example ltFDO SDK Install LocationgtbinFdoRdbmsdll

isManaged A flag indicating whether the provider is a managed orunmanaged NET provider

Establishing a ConnectionAs mentioned in a previous section Connection Semantics on page 27 theFDO API uses a provider to connect to a data store and its underlying datasource technology These data source technologies must be installed andconfigured Certain values generated during data source installation andconfiguration are used as arguments during the connection process Becausethe FDO API does not provide any methods to automate the collection andpresentation of these configuration values either the application developermust request the user to input these configuration values during theconnection process or the application developer can provide an applicationconfiguration interface which would populate the application with thecontainer configuration values and thus allow the user to choose them fromlists

NOTE For more information about connecting see The Essential FDO

A connection can be made in either one or two steps

One-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method once the returned stateis FdoConnectionState_Open no additional information is needed

Two-step connection If the user sets the required connection propertiesand calls the connection objectrsquos Open() method the returned state isFdoConnectionState_Pending additional information is needed to completethe connection In this case the first call to Open() has resulted in theretrieval of a list of values for a property that becomes a required property

Establishing a Connection | 29

for the second call to the Open() method After the user has selected oneof the values in the list the second call to Open() should result inFdoConnectionState_Open

Connecting to a data store by way of the MySQL or the ArcSDE provider forexample can be done in either one or two steps In the first step the datastore parameter is not required If the user does not give the data storeparameter a value the FDO will retrieve the list of data store values from thedata source so that the user can choose from them during the second stepOtherwise the user can give the data store a value in the first step andassuming that the value is valid the connection will be completed in onestep

For the purpose of this example letrsquos assume that the user has installed MySQLon his local machine During the installation he was prompted to assign apassword to the system administrator account whose name is lsquorootrsquo He setthe password to lsquotestrsquo

The following steps are preliminary to establishing a connection

1 Get the list of providers

FdoPtrltFdoProviderRegistrygt registry = (FdoProviderRegistry

)FdoFeatureAccessManagerGetProviderRegistry()

FdoProviderCollection providers = registry-gtGetProviders()

2 Get the display names for all of the providers in the registry An exampleof a display name might be OSGeo FDO Provider for MySQL

FdoStringP displayName

FdoStringP internalName

FdoPtrltFdoProvidergt provider

int count = providers-gtGetCount()

for(int i = 0 i lt count i++)

provider = providers-gtGetItem(i)

internalName = provider-gtGetName()

displayName = provider-gtGetDisplayName()

add displayName to your list

3 Use the display names to create a menu list from which the user willselect from when making a connection

After the user initiates a provider display name from the connection menudo the following

30 | Chapter 5 Establishing a Connection

1 Loop through the providers in the registry until you match the displayname selected by the user from the connection menu with a providerdisplay name in the registry and retrieve the internal name for thatprovider An example of an internal could be OSGeoMySQL32

FdoStringP internalName = provider-gtGetName()

2 Get an instance of the connection manager

FdoPtrltFdoConnectionManagergt connectMgr = (FdoConnectionManager

)FdoFeatureAccessManagerGetConnectionManager()

3 Call the managerrsquos CreateConnection() method using the provider internalname as an argument to obtain a connection object

FdoPtrltFdoIConnectiongt fdoConnection = connectMgr-gtCreateConnec

tion(LrdquoOsGeoMySQL32rdquo)

4 Obtain a connection info object by calling the connection objectrsquosGetConnectionInfo() method

FdoPtrltFdoIConnectionInfogt info = fdoConnection-gtGetConnection

Info()

5 Obtain a connection property dictionary object by calling the connectioninfo objectrsquos GetConnection Properties() method and use this dictionaryto construct a dialog box requesting connection information from theuser

FdoPtrltFdoIConnectionPropertyDictionarygt ConnDict = info-gtGetCon

nectionProperties()

6 Get a list of connection property names from the dictionary and use thislist to get information about the property The following code loopsthrough the dictionary getting all of the possible information

NOTE An attempt to get the values of an enumerable property is made onlyif the property is required

FdoInt32 count = 0

FdoString names = NULL

FdoStringP name

FdoStringP localname

FdoStringP val

FdoStringP defaultVal

bool isRequired = false

bool isProtected = false

bool isFilename = false

bool isFilepath = false

Establishing a Connection | 31

bool isDatastorename = false

bool isEnumerable = false

FdoInt32 enumCount = 0

FdoString enumNames = NULL

FdoStringP enumName

names = ConnDict-gtGetPropertyNames(count)

for(int i = 0 i lt count i++)

name = names[i]

val = dict-gtGetProperty(name)

defaultVal = dict-gtGetPropertyDefault(name)

localname = dict-gtGetLocalizedName(name)

isRequired = dict-gtIsPropertyRequired(name)

isProtected = dict-gtIsPropertyProtected(name)

isFilename = dict-gtIsPropertyFileName(name)

isFilepath = dict-gtIsPropertyFilePath(name)

isDatastorename = dict-gtIsPropertyDatastoreName(name)

isEnumerable = dict-gtIsPropertyEnumerable(name)

if (isEnumerable)

if (isRequired)

enumNames = dict-gtEnumeratePropertyValues(name enumCount)

for(int j = 0 j lt enumCount j++)

enumName = enumNames[j]

7 Use the GetLocalizedName method to obtain the name of the propertyto present to the user Calls to dictionary methods need the value of theinternal name in the string array returned by GetPropertyNames() Sowhen the user selects the localized name in the menu the program mustmap the localized name to the internal name

8 Use the IsPropertyRequired method to determine whether to mark theline as either required or optional the dialog box handler should notpermit the user to click OK in the dialog box unless a required field hasa value

9 Use the IsPropertyProtected method to determine whether the dialogbox handler should process the field value as protected data for examplea password

10 Use the IsPropertyEnumerable and IsRequired methods to determinewhether to call the EnumeratePropertyValues method to get a list of validvalues

32 | Chapter 5 Establishing a Connection

NOTE Call the EnumeratePropertyValues method only if both methods returntrue Otherwise be prepared to catch an exception if there is no pendingconnection The assumption is that a connection exists and the program isretrieving values from the data store

As shown in the code lines above the EnumeratePropertyValues method takesa property name and an updates integer argument and returns a string arrayThe updates integer will say how many values are in the returned array Presentthe list of choices to the user

If the property is not enumerable present the values returned by either theGetProperty or GetPropertyDefault methods to the user

Now that the user has seen the set of properties in the dictionary she canset the required properties A property is set by calling the dictionaryrsquosSetProperty method The MySQL connection property names are UsernamePassword Service and DataStore The dictionary tells us that UsernamePassword and Service are required properties and that DataStore is not requiredLetrsquos connect to the MySQL as root

ConnDict-gtSetProperty(LrdquoUsernamerdquo Lrdquorootrdquo)

ConnDict-gtSetProperty(LrdquoPasswordrdquo Lrdquotestrdquo)

ConnDict-gtSetProperty(LrdquoServicerdquo Lrdquolocalhostrdquo)

NOTE fdoconnection-gtGetConnectionString() returnsUsername=rootPassword=testService=localhostfdoconnection-gtSetConnectionString(LrdquoUsername=rootPassword=testService=localhostrdquo)

would set the connection properties to the same values as the three calls aboveto the connection dictionaryrsquos SetProperty() method

Open the connection

FdoConnectionState state = fdoConnection-gtOpen()

The value of state is FdoConnectionState_Pending An examination of theconnection dictionary will reveal that the DataStore property is now required

When the user checks the command capabilities he discovers that he cancreate a data store

Establishing a Connection | 33

FdoPtrltFdoICommandCapabilitiesgt commandCapabilities = fdoConnec

tion-gtGetCommandCapabilities()

bool bSupportsCreateDatastore = false

FdoInt32 numCommands

FdoIn32 commands = commandCapabilities-gtGetCommands(numCommands)

for(int i = 0 i lt numCommands i++)

switch(commands[i])

case FdoCommandType_CreateDataStore bSupportsCreateDatastore

= true

He can use the pending connection to MySQL to create the datastore Use theconnection object to create the FdoICreateDataStore command object Usethe command object to create the FdoIDataStorePropertyDictionary objectand find out from this object what properties you must define Use thedictionary object to set the required properties and then execute the commandto create the lsquofdo_userrsquo data store The only required property is DataStore

NOTE The FdoIDataPropertyDictionary and the FdoIConnectionPropertyDictionaryclasses are both derived from FdoIPropertyDictionary The code used above toaccess the FdoIConnectionPropertyDictionary object works for theFdoIDataPropertyDictionary

FdoPtrltFdoICreateDataStoregt createDataStoreCmd = dynam

ic_castltFdoICreateDataStore gt (fdoConnection-gtCreateCommand(Fdo

CommandType_CreateDataStore))

FdoPtrltFdoIDataStorePropertyDictionarygt createDsDict = createData

StoreCmd-gtGetDataStoreProperties()

createDsDict-gtSetProperty(LrdquoDataStorerdquo Lrdquofdo_userrdquo)

createDataStoreCmd-gtExecute()

Now use the connection property dictionary to set the DataStore property tolsquofdo_userrsquo and call the Open() method on the connection object This methodshould return FdoConnectionState_Open

34 | Chapter 5 Establishing a Connection

FDO Capabilities

FDO Capabilities

Introduction

The FDO capabilities are statically defined They are accessed through aconnection object in the closed state The following code illustrates how to geta connection object in the closed state

If you are using C you will find the capability definitions in theOSGeoFDOConnectionsCapabilities namespace If you are using C++ youwill find the headers in the FdoConnectionsCapabilties directory

In C you access them using the OSGeoFDOConnectionsIConnection objectIn C++ you access them using the IConnection object whose header is in theFdoConnections directory

The information in the capabilities tables reflects the state of the FDO providercapabilities as of the commercial release of Map 3D 2009

For the most part FDO defines capabilities in three ways booleans enumerationsor integers representing enumerated values and collections One schemacapability is defined as a string and two other schema capabilities as integersFor example the Command capability SupportsParameters is a boolean andthe Command capability Commands is a set of integers whose meaning isdefined by the C CommandType enumeration and the C++ FdoCommandTypeenumeration Function capabilities are defined as collections of functionsignatures The C type isOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionThe C++ type is FdoReadOnlySignatureDefinitionCollection The latter is

6

35

defined in FdoConnectionsCapabilitiesSignatureDefinitionh Each booleanenumeration and signature value is shown in the tables

In general where a number of capabilities are supported by the same set ofproviders the capabilities are aggregated into one line in the table This ruleis modified in the function category tables in the Expression section

In some cases for example the CLIP raster function there is only one signatureAt the other end of the spectrum is the Concat string function which hasalmost 100 signatures The same set of providers supports an enormous numberof functions and so the rule for presenting aggregations of capabilities had tobe modfied for functions The rule for functions is to present all of thesignatures for one function on a line in the table A handful of functions hadso many signatures that their presentation had to be split over two lines

Provider Type

A provider can be one of four types Database Server File Web Server orUnknown The type information is available from the connection object inthe closed state The ldquoUnknownrdquo type indicates that the provider can connectto more than one type of data store technology The ODBC and OGR providerscan connect either to a file-based or RDBMS-based data store technologywhich is not known until the connection is in the open state

In C the ProviderDatastoreType enumeration is in theOSGeoFDOConnections namespace The ProviderDatastoreType property isaccessible through the OSGeoFDOConnectionsIConnection object(connectionConnectionInfoProviderDatastoreType)

In C++ the FdoProviderDatastoreType enumeration is defined in theltFdoConnectionsProviderDatastoreTypehgt header file TheFdoProviderDatastoreType value is accessible through the IConnection object(connection-gtGetConnectionInfo()-gtGetProviderDatastoreType())

TypeProvider

DatabaseServerOSGeoArcSDE33

DatabaseServerOSGeoKingOracle33

DatabaseServerOSGeoMySQL33

36 | Chapter 6 FDO Capabilities

TypeProvider

DatabaseServerOSGeoPostGIS33

DatabaseServerOSGeoSQLServerSpatial33

FileOSGeoGdal33

FileOSGeoSDF33

FileOSGeoSHP33

WebServerOSGeoWFS33

WebServerOSGeoWMS33

UnknownOSGeoODBC33

UnknownOSGeoOGR33

NOTE A provider name with OSGeo at the beginning indicates that the provideris available as open source from httpfdoosgeoorg

Command

In C you access theOSGeoFDOConnectionsCapabilitiesICommandCapabilities using theIConnection object (connectionCommandCapabilities)

In C++ you access the FdoICommandCapabilities using the IConnection object(connection-gtGetCommandCapabilities())

DescriptionCommand

Locks feature instances of a given class that match thespecified criteria

AcquireLock

Command | 37

DescriptionCommand

Activates a long transaction so that features can be ver-sioned

ActivateLongTransaction

Activates a specified spatial contextActivateSpatialContext

Creates or updates a feature schema within the datastore Optionally a provider-specificmapping of featureschema elements to physical storage can be specified

ApplySchema

Commits all of the data within a leaf long transaction(one that does not have descendent long transactions)

CommitLongTransaction

to the parent long transaction and removes the longtransaction Requires access commit and remove priv-ileges to the long transaction and the access privilegeto the parent long transaction

Creates anew provider specific datastoreCreateDataStore

Creates a long transaction as a child of the currentlyactive long transaction

CreateLongTransaction

Creates a new spatial context Input to the commandincludes the name description coordinate system ex-tent type and extent for the new context

CreateSpatialContext

Deactivates the active long transaction and automaticallyactivates the root long transaction If the root long

DeactivateLongTransaction

transaction is the active one the deactivation has noeffect

Deletes the instances of a given class that match thespecified criteria The instances can be at global scopeor contained within an object collection

Delete

Describe a single schema or all schemas available fromtheconnection

DescribeSchema

38 | Chapter 6 FDO Capabilities

DescriptionCommand

Describes the logical to physical schema mappings forone or all feature schemas available from the connection

DescribeSchemaMapping

Remove a data storeDestroyDataStore

Destroys a schema definition including all class defini-tions relationship definitions and instance data within

DestroySchema

it If elements in other schemas referto the schema tobe destroyed execution will fail

Destroys an existing spatial context which destroys alldata stored in that context

DestroySpatialContext

Gets a list of all objects that are currently locked by aparticular user

GetLockedObjects

Gets lock information for the feature instances of a givenclass that match the specified filter

GetLockInfo

Gets a list of all lock ownersGetLockOwners

Gets one specific long transaction or all available longtransactions

GetLongTransactions

Enumerates the existing measurement unitsGetMeasureUnits

Gets all spatial contexts or just the active oneGetSpatialContexts

inserts a new instance of a given class The instance canbe at global scope or contained within an object collec-tion

Insert

Gets a list of datastores at a particular serverListDataStores

Create a spatial index for the specified spatial contextOracleCreateSpatialIndex

Command | 39

DescriptionCommand

Drop the specified spatial indexOracleDestroySpatialIndex

Enumerate the existing spatial indexesOracleGetSpatialIndexes

Releases locks from feature instances of a given class thatmatch the specified criteria

ReleaseLock

Removes all of the data within a long transaction andremoves the long transaction as well Requires access

RollbackLongTransaction

commit and remove privileges to the long transactionand the access privilege to the parent long transaction

creates a new SDF+ file with a specified location and filename and a given spatial coordinate system This com-

SDFCreateSDFFile

mand has been superceded by the CreateDataStorecommand

Supports the selection and ordering of feature instancesof a given class according to the specified criteria Theresults of the select are written to an SDF file

SDFExtended_Select

Queries for features of a given class that match the spe-cified criteria

Select

Queries for features of a given class that match the spe-cified criteria The criteria can specify that feature values

SelectAggregates

from multiple instances be aggregated be distinct orbe grouped

Supports the execution of a SQL statement against anunderlying RDBMS Two execute methods are provided

SQLCommand

to distinguish between statements that return table dataversus those that execute non query type operations

Modifies instances of a given class that match the spe-cified criteria The instance can be at global scope orcontained within an object collection

Update

40 | Chapter 6 FDO Capabilities

DescriptionCommand

Gets the image formats supported by the connectionWMSGetImageFormats

Gets the layer styles available for the specified featureclass

WMSGetFeatureClassStyles

Gets the CRS names available for the specified featureclass

WMSFeatureClassCRS-Names

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports the use of distinct in SelectAggreg-ates commands

SupportsSelectDistinct

Indicates whether or not a provider sup-ports the use of expressions for propertiesin Select and SelectAggregate commands

SupportsSelectExpressions

Indicates whether or not a provider sup-ports the use of functions in Select and

SupportsSelectFunctions

SelectAggregates command Only aggreg-ate functions can be used in the SelectAg-gregates command

Indicates whether or not a provider sup-ports the use of grouping criteria in theSelectAggregates command

SupportsSelectGrouping

Indicates whether or not a provider sup-ports ordering in the Select and SelectAg-gregates command

SupportsSelectOrdering

Command | 41

DescriptionBoolean Capability

Indicates whether or not a provider sup-ports parameter substitution

SupportsParameters

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++Select DescribeSchema GetSpatialContexts

++++++++-+++SelectAggregates

+++-++-+++++SupportsSelectFunctions

++--++-+++++SupportsSelectDistinct Insert Update Delete

++-+++-++++-SupportsSelectExpressions

----++-+-+++CreateSpatialContext

-++-+-++-+--DescribeSchemaMapping

-+-----+++++SQLCommand

----++-++++-ApplySchema

-----+-++++-CreateDataStore

-+-----++++-SupportsSelectOrdering

-------+++-+ListDataStores

-+-----+-++-SupportsSelectGrouping

-----+-+++--DestroyDataStore

42 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

----+--+-+--DestroySchema

--------+-++SupportsParameters

-------+-+-+DestroySpatialContext

----++------SDFCreateSDFFile

-------+---+ActivateSpatialContext

-------+----OracleGetSpatialIndexes OracleCreateSpatialIndex Or-acleDestroySpatialIndex

-----+------SDFExtended_Select

--+---------WMSFeatureClassCRSNames WMSGetImageFormatsWMSGetFeatureClassStyles

-----------+AcquireLock CreateLongTransaction DeactivateLongTrans-action RollbackLongTransaction CommitLongTransactionGetLockOwners ReleaseLock GetLongTransactions Get-LockedObjects ActivateLongTransaction GetLockInfo

Connection

In C you access theOSGeoFDOConnectionsCapabilitiesIConnectionCapabilities using theIConnection object (connectionConnectionCapabilities)

Connection | 43

In C++ you access the FdoIConnectionCapabilities using the IConnectionobject (connection-gtGetConnectionCapabilities())

DescriptionCapability

Indicates that only this user can modify this object in thislong transaction No user not even the user locking the

LockType_AllLongTransactionExclusive

object can modify the object in any long transaction createdas a descendent of the one containing the object beinglocked When not in a long transaction situation (for ex-ample if only a root long transaction exists) the lock be-haves like an Exclusive lock

Indicates that only this user can modify this object In a longtransaction situation any user can modify the object in any

LockType_Exclusive

other long transaction including the root long transactionif it is not the current long transaction

Indicates that only this user can modify this object in thelong transaction containing the object or any long transac-

LockType_LongTransactionExclusive

tion created as a descendent of that one When not in along transaction situation (for example if only a root longtransaction exists) the lock behaves like an Exclusive lock

Indicates a shared lock typeLockType_Shared

Indicates that a transaction lock should be applied to anobject

LockType_Transaction

Indicates whether or not a provider can specify on a closedconnection an XML source to be used to configure the datastore

SupportsConfiguration

Indicates that the spatial extent of the context is dynamicand changes as data is added and removed from the con-text

SpatialContextExtentType_Dynamic

Indicates that the spatial extent of the context is static andmust be specified when the context is created

SpatialContextExtentType_Static

44 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the specifica-tion of a coordinate system during the creation of a spatial

SupportsCSysWKTFromCSysName

context using only the coordinate system name The pro-vider maps the name to the WKT internally

Indicates whether or not a provider supports the forcedwrite of cached data associated with a connection to thetarget data store

SupportsFlush

Indicates whether or not a provider supports the set oflocking commands acquire get locked objects get lockowners get lock info and release

SupportsLocking

Indicates whether or not a provider supports the set of longtransaction commands activate commit create deactivateand get

SupportsLongTransactions

Indicates that the data store can contain multiple spatialcontexts but the provider does not necessarily support thecreate spatial context command

SupportsMultipleSpatialContexts

Indicates whether or not a provider supports the SQL com-mand

SupportsSQL

Indicates whether or not a provider supports the creationof a transaction associated with a connection to a data store

SupportsTransactions

Indicates that the provider supports a single thread perconnection Multiple concurrent threads cannot access the

ThreadCapability_PerConnectionThreaded

same connection object and only one command can beexecuting per connection Multiple connections can beactive concurrently as long as each is executing on its ownthread

Indicates that the provider supports a single thread percommand Multiple concurrent threads cannot access the

ThreadCapability_PerCommandThreaded

same command object however multiple commands canbe executing concurrently against a single connection

Connection | 45

DescriptionCapability

Indicates that the provider is not thread safeThreadCapability_SingleThreaded

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-++++-++++++SpatialContextExtentType_Static

++++++-+++-+ThreadCapability_PerConnectionThreaded

--+++-++++++SupportsMultipleSpatialContexts

-+-----+++++SupportsSQL

-++-+-+---+-SupportsConfiguration

-------++--+SupportsTransactions

----------++LockType_Exclusive

+----+------SpatialContextExtentType_Dynamic

----++------SupportsFlush

--------+-+-LockType_Transaction

----------+-LockType_AllLongTransactionExclusive LockType_LongTrans-actionExclusive ThreadCapability_PerCommandThreadedLockType_Shared

-----------+SupportsLocking SupportsCSysWKTFromCSysName Sup-portsLongTransactions

------+-----ThreadCapability_SingleThreaded

46 | Chapter 6 FDO Capabilities

Expression

In C you access theOSGeoFDOConnectionsCapabilitiesIExpressionCapabilities and theOSGeoFDOConnectionsCapabilitiesFunctionDefinitionCollectionusingthe IConnection object connectionExpressionCapabilities andconnectionExpressionCapabilitiesFunctions respectively EachOSGeoFDOConnectionsCapabilitiesFunctionDefinition in the collectionhas has aOSGeoFDOConnectionsCapabilitiesReadOnlySignatureDefinitionCollectionwhich is accessed by functionDefSignatures

In C++ you access the FdoIExpressionCapabilities and theFdoFunctionDefinitionCollection using the IConnection objectconnection-gtGetExpressionCapabilities()expression_capabilities-gtGetFunctions() respectively EachFdoFunctionDefinition in the collection has anFdoReadOnlySignatureDefinitionCollection which is accessed byfunctionDef-gtGetSignatures()

The functions can be broadly divided into two groups according to the modeof their implementation The largest group contains the functions whoseunderlying implementation is based on the Expression Builder The first releaseof the Expression Builder component is in FDO 33 The remaining functionsare those whose implementation was not touched by the introduction of theExpression Builder component

The functions whose implementation is based on the Expression Builder arefurther categorized for UI purposes into 7 groups aggregate conversion dategeometry math numeric and string These UI categories are used in thisdocument to group the presentation of the functions

General Capabilities

DescriptionCapability

Indicates whether or not the provider supports basicarithmetic expressions for example + - negate andstring concatenation

ExpressionType_Basic

Indicates whether or not the provider supports functionevaluations

ExpressionType_Function

Expression | 47

DescriptionCapability

Indicates whether or not the provider supports parametersubstitution An expression can be constructed using

ExpressionType_Parameter

named parameters and values bound to the parameter ata later time This allows the constructed expression to bereused

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ExpressionType_Function

++-+++-+++++ExpressionType_Basic

-------+-+--ExpressionType_Parameter

Argument and Return Types

Tthe following tables specify the function name arguments and the type ofthe return value An argument is optional if it is enclosed in square bracketsAn argument may be a literal such as ldquoALLrdquo or ldquoDISTINCTrdquo or a featureproperty name Where the argument value is a feature property name thetype of the feature property is specified The set of valid alternatives for anargument value is indicated by enclosing the set of ORrsquod property types orliteral values in parentheses For brevityrsquos sake a lsquonumericrsquo property typeindicates the set of numeric property types namely Byte | Decimal | Double| Int16 | Int32 | Int 64 | Single The other property types BLOB BooleanCLOB DateTime Geometry and String are indicated directly in the argumentspecification

Some functions have more than one return type The general rule is that thereturn type matches the argument type

48 | Chapter 6 FDO Capabilities

Aggregate Expression Functions

These functions can be used with the SelectAggregates command

DescriptionFunctionName

Returnsa double which is the average of the values identified by theprovided expression Avg ([ALL | DISTINCT ] numeric)

Avg

Returns an Int64 which is the number of rows returned by a queryidentified by the provided expression Count ([ALL | DISTINCT ]bool | DateTime | numeric | string | blob | clob | geometry)

Count

Returns a DateTime numeric or string in agreement with the typeof the argument which is the maximum value of the provided expres-sion Max ([ALL | DISTINCT ] DateTime | numeric | string)

Max

Represents an inverse distribution function that assumes a continuousdistribution model It takes a numeric or date-time value and returns

Median

a Double which is the middle value or an interpolated value thatwould be the middle value once the values are sorted Median (nu-meric)

Returns a DateTime numeric or string in agreement with the typeof the argument which is the minimum value of the provided expres-sion Min ([ALL | DISTINCT ] DateTime | numeric | string)

Min

Returns a Double which is the sample standard deviation of theprovided expression Stddev ([ALL | DISTINCT ] numeric)

Stddev

Returns a Double which is the sum of the values identified by theprovided expression Sum ([ALL | DISTINCT ] numeric)

Sum

Returns a byte array which yields the spatial extent of a set of geo-metries The argument is the name of geometry property SpatialEx-

Spatial Extent

tent (ltgeometriesgt) For example given these geometries POINT(11) LINESTRING(01 21) and POLYGON((01 21 12 01)) it returnsPOLYGON((01 21 22 02 01))

Expression | 49

NOTE The median is selected or calculated by doing the following

1 Sort the sample in ascending order

2 Calculate the Row of Interest (roi) using the forumula roi = (1 +((ltsample_sizegt - 1) 2))

3 Compare three values roi Ceil(roi) and Floor(roi) If they are equal themedian is the value in the Row Of Interest If they are not equal themedian is calculated by averaging the values in the rows preceding andsucceeding the Row of Interest

NOTE The value returned by the StdDev function is known as the sample standarddeviation and represents an estimate of the standard deviation of a populationbased on a random sample of that population See the Wikipedia entry for furtherdiscussion and a definition of the formula for sample standard deviationhttpenwikipediaorgwikiStandard_deviation

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++-+++++Double Avg(Double)

++--++-+++++Int64 Count(Int64)

++--++-+++++Double Max(Double)

++--++-+++++Double Min(Double)

++--++-+++++Double Sum(Double)

-+-+++-+-+++BLOB SpatialExtents(BLOB)

-+--++-+-+-+Double Avg(Byte) Double Avg(Decimal) Double Avg(Int16)Double Avg(Int32) Double Avg(Int64) Double Avg(Single)Double Avg(StringByte) Double Avg(StringDecimal) DoubleAvg(StringDouble) Double Avg(StringInt16) Double

50 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Avg(StringInt32) Double Avg(StringInt64) DoubleAvg(StringSingle)

-+--++-+-+-+Int64 Count(BLOB) Int64 Count(Boolean) Int64 Count(Byte)Int64 Count(CLOB) Int64 Count(DateTime) Int64Count(Decimal) Int64 Count(Double) Int64 Count(Int16) Int64Count(Int32) Int64 Count(Single) Int64 Count(String) Int64Count(StringBoolean) Int64 Count(StringByte) Int64Count(StringDateTime) Int64 Count(StringDecimal) Int64Count(StringDouble) Int64 Count(StringInt16) Int64Count(StringInt32) Int64 Count(StringInt64) Int64Count(StringSingle) Int64 Count(StringString)

-+--++-+-+-+Byte Max(Byte) Byte Max(StringByte) DateTime Max(Date-Time) DateTime Max(StringDateTime) Decimal Max(Decimal)Decimal Max(StringDecimal) Double Max(StringDouble) Int16Max(Int16) Int16 Max(StringInt16) Int32 Max(Int32) Int32Max(StringInt32) Int64 Max(Int64) Int64 Max(StringInt64)Single Max(Single) Single Max(StringSingle) StringMax(String) String Max(StringString)

-+--++-+-+-+Double Median(Byte) Double Median(Decimal) Double Medi-an(Double) Double Median(Int16) Double Median(Int32)Double Median(Int64) Double Median(Single)

-+--++-+-+-+Byte Min(Byte) Byte Min(StringByte) DateTime Min(DateTime)DateTime Min(StringDateTime) Decimal Min(Decimal)Decimal Min(StringDecimal) Double Min(StringDouble) Int16Min(Int16) Int16 Min(StringInt16) Int32 Min(Int32) Int32Min(StringInt32) Int64 Min(Int64) Int64 Min(StringInt64)Single Min(Single) Single Min(StringSingle) String Min(String)String Min(StringString)

-+--++-+-+-+Double Stddev(Byte) Double Stddev(Decimal) DoubleStddev(Double) Double Stddev(Int16) Double Stddev(Int32)Double Stddev(Int64) Double Stddev(Single) Double

Expression | 51

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Stddev(StringByte) Double Stddev(StringDecimal) DoubleStddev(StringDouble) Double Stddev(StringInt16) DoubleStddev(StringInt32) Double Stddev(StringInt64) DoubleStddev(StringSingle)

-+--++-+-+-+Double Sum(Byte) Double Sum(Decimal) Double Sum(Int16)Double Sum(Int32) Double Sum(Int64) Double Sum(Single)Double Sum(StringByte) Double Sum(StringDecimal) DoubleSum(StringDouble) Double Sum(StringInt16) DoubleSum(StringInt32) Double Sum(StringInt64) DoubleSum(StringSingle)

Conversion Expression Functions

DescriptionFunction Name

Evaluates two expressions and returns the first one if it does notevaluate to NULL the second otherwise The signatures without

NullValue

function name are Boolean(BooleanBoolean) Byte(ByteByte)DateTime(DateTimeDateTime) Decimal(DecimalDecimal)Double(DecimalDouble) Decimal(DecimalInt16 | Int32)Double(DecimalInt64) Single(DecimalSingle)Double(DoubleDecimal | Double | Int16 | Int32 | Int64 | Single)Double(Int16Decimal | Double) Int16(Int16Int16)Int32(Int16Int32) Int64(Int16Int64) Single(Int16Single)Double(Int32Decimal | Double) Int32(Int32Int16 | Int32)Int64(Int32Int64) Double(Int32Single)Double(Int64Decimal |Double | Single) Int64(Int64Int16 | Int32 | Int64)Double(SingleDecimal | Double | Int32 | Int64) Single(SingleInt16| Single) String(StringDecimal | Double | Int16 | Int32 | Int64 |Single | String)

Converts a string with datetime information to a date ToDate(date_string [ format_string]) The default format_string is ldquoDDMON YYYY h24 mm ssrdquo

ToDate

52 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Converts a numeric or string expression to a double ToDouble(numeric | string)

ToDouble

Converts a numeric or string expression to a float ToFloat (numeric| string)

ToFloat

Converts a numeric or string expression to an int32 ToInt32 (nu-meric | string)

ToInt32

Converts a numeric or string expression to an int64 ToInt64 (nu-meric | string)

ToInt64

Converts a numeric or date expression to a string ToString(numer-ic) ToString (DateTime [ format_string]) The default format_stringis ldquoDD-MON-YYYY h24mmssrdquo

ToString

The ToDate function takes a string value representing date andor timeinformation and converts it to a date object The optional format specificationparameter defines the format used in the string to represent the date usingthe abbreviations described in the following table For example for a stringcontaining the date April 2 1998 the format specification should containMonth DD YYYY

The ToString function takes a date value and creates a representation of it ina string The optional format specification parameter allows the user to definethe structure of the string to be created using the abbreviations described inthe following table

DescriptionAbbrevi-ation

Indicates that a year is defined as a two digit number (example 07)YY

Indicates that a year is defined as a four digit number (example 2007)YYYY

Indicates that a month is defined by its name all in uppercase letters (example APRIL)MONTH

Indicates that a month is defined by its name all in lowercase letters (example april)month

Expression | 53

DescriptionAbbrevi-ation

Indicates that a month is defined by its name with the first letter being an uppercaseletter (example April)

Month

Indicates that a month is defined by its abbreviation all in uppercase letters (exampleAPR)

MON

Indicates that a month is defined by its abbreviation all in lowercase letters (exampleapr)

mon

Indicates that a month is defined by its number (example 04)MM

Indicates that a day is defined by its number (example 04)DD

Indicates that a hour is defined by its number in the range [0-24]hh24

Indicates that a hour is defined by its number in the range [1-12]hh12

Represents a default representation of an hour Defaults to hh24hh

Indicates a minute definitionmm

Indicates a second definitionss

Indicates a millisecond definitionms

The meridiem Only considered if used with the time range [1-12] (format hh12)am | pm

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Boolean NullValue(BooleanBoolean) Byte NullValue(ByteByte)DateTime NullValue(DateTimeDateTime) Decimal Null-Value(DecimalDecimal) Decimal NullValue(DecimalInt16)

54 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Decimal NullValue(DecimalInt32) Double NullValue(Decim-alDouble) Double NullValue(DecimalInt64) Double Null-Value(DoubleDecimal) Double NullValue(DoubleDouble)Double NullValue(DoubleInt16) Double NullValue(DoubleInt32)Double NullValue(DoubleInt64) Double Null-Value(DoubleSingle) Double NullValue(Int16Decimal) DoubleNullValue(Int16Double) Double NullValue(Int32Decimal)Double NullValue(Int32Double) Double NullValue(Int32Single)Double NullValue(Int64Decimal) Double Null-Value(Int64Double) Double NullValue(Int64Single) DoubleNullValue(SingleDecimal) Double NullValue(SingleDouble)Double NullValue(SingleInt32) Double NullValue(SingleInt64)Int16 NullValue(Int16Int16) Int32 NullValue(Int16Int32) Int32NullValue(Int32Int16) Int32 NullValue(Int32Int32) Int64 Null-Value(Int16Int64) Int64 NullValue(Int32Int64) Int64 Null-Value(Int64Int16) Int64 NullValue(Int64Int32) Int64 Null-Value(Int64Int64) Single NullValue(DecimalSingle) SingleNullValue(Int16Single) Single NullValue(SingleInt16) SingleNullValue(SingleSingle) String NullValue(StringDecimal) StringNullValue(StringDouble) String NullValue(StringInt16) StringNullValue(StringInt32) String NullValue(StringInt64) StringNullValue(StringSingle) String NullValue(StringString)

-+--++-+-+-+DateTime ToDate(String) DateTime ToDate(StringString)

-+--++-+-+-+Double ToDouble(Byte) Double ToDouble(Decimal) DoubleToDouble(Double) Double ToDouble(Int16) Double To-Double(Int32) Double ToDouble(Int64) Double To-Double(Single) Double ToDouble(String)

-+--++-+-+-+Single ToFloat(Byte) Single ToFloat(Decimal) Single To-Float(Double) Single ToFloat(Int16) Single ToFloat(Int32) SingleToFloat(Int64) Single ToFloat(Single) Single ToFloat(String)

Expression | 55

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Int32 ToInt32(Byte) Int32 ToInt32(Decimal) Int32ToInt32(Double) Int32 ToInt32(Int16) Int32 ToInt32(Int32)Int32 ToInt32(Int64) Int32 ToInt32(Single) Int32 ToInt32(String)

-+--++-+-+-+Int64 ToInt64(Byte) Int64 ToInt64(Decimal) Int64ToInt64(Double) Int64 ToInt64(Int16) Int64 ToInt64(Int32)Int64 ToInt64(Int64) Int64 ToInt64(Single) Int64 ToInt64(String)

-+--++-+-+-+String ToString(Byte) String ToString(DateTime) String To-String(DateTimeString) String ToString(Decimal) String To-String(Double) String ToString(Int16) String ToString(Int32)String ToString(Int64) String ToString(Single)

Date Expression Functions

DescriptionFunction Name

Adds a specified number of months to agiven date expression and returns a Date-Time AddMonths (date_time numeric)

AddMonths

Returns the current date CurrentDate ()CurrentDate

Extracts a specified portion of a date andreturns a DateTime Extract (YEAR|

Extract

MONTH | DAY | HOUR | MINUTE |SECOND date_time)

Calculates the number of months betweentwo provide date expressions and returns

MonthsBetween

56 | Chapter 6 FDO Capabilities

DescriptionFunction Name

a Double MonthsBetween (date_timedate_time)

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+DateTime AddMonths(DateTimeByte) DateTimeAddMonths(DateTimeDecimal) DateTime AddMonths(Date-TimeDouble) DateTime AddMonths(DateTimeInt16) DateTimeAddMonths(DateTimeInt32) DateTime AddMonths(Date-TimeInt64) DateTime AddMonths(DateTimeSingle)

-+--++-+-+-+DateTime CurrentDate()

-+--++-+-+-+DateTime Extract(StringDateTime)

-+--++-+-+-+Double MonthsBetween(DateTimeDateTime)

Geometry Expression Functions

DescriptionFunction Name

Returns a Double which is the area of ageometry Area2D (ltgeometrygt)

Area2D

Returns a Double which is the length of ageometry Length2D (ltgeometrygt)

Length2D

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Area2D(BLOB)

Expression | 57

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Length2D(BLOB)

Mathematical Expression Functions

DescriptionFunction Name

Returns the absolute value of a numeric expression Abs (numeric)The return type is the same as the argument type

Abs

Returns a Double which is the arc cosine of a numeric expressionAcos (numeric)

Acos

Returns a Double which is the arc sine of a numeric expressionAsin (numeric)

Asin

Returns a Double which is the arc tangent of a numeric expressionAtan (numeric)

Atan

Returns a Double which is the arc tangent based on two numericexpressions Atan2 (numeric numeric)

Atan2

Returns a Double which is the cosine of a numeric expression Cos(numeric)

Cos

Returns a Double which is e raised to the power of a numeric ex-pression Exp (numeric)

Exp

Returns a Double which is the natural logarithm of a numeric ex-pression Ln (numeric)

Ln

Returns a Double which is the logarithm of a numeric expressionusing the provided base Log (base_numeric numeric)

Log

58 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Returns the remainder of the division of two numeric expressionsMod (numeric divisior_numeric) The implementation alogirthm

Mod

is Mod (m n) = (sign(m) (abs(m) - (abs(n) Floor(mn)))))mod(154) returns 3 mod(150) returns 15 mod(1162) returns16 mod(11621) returns 11 mod(-154) returns -3 mod(-150)returns -15 The return signatures without the function name areByte(ByteByte | Int16 | Int32 | Int64) Double(ByteDecimal |Double) Single(ByteSingle) Double(Decimal | DoubleByte |Decimal | Double | Int16 | Int32 | Int64 | Single) Int16(Int16Byte| Int16 | Int32 | Int64) Double(Int16Decimal | Double)Single(Int16Single) Int32(Int32Byte) Double(Int32Decimal |Double) Int16(Int32Int16) Int32(Int32Int32 | Int64)Single(Int32Single) Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single) Double(SingleDecimal | Double)

Returns a Double which is the result of a numeric expression raisedto the power of another numeric expression Power (numericpower_numeric)

Power

Returns the remainder of the division of two numeric expressionsRemainder (numeric divisor_numeric) The implementation al-

Remainder

gorithm is Remainder (mn) = (sign(m) (abs(m) - (abs(n) Round(mn)))) remainder(156) returns 3 remainder(155) returns0 remainder(154) returns -1 remainder(1162) returns -04 re-mainder(11621) returns -1 remainder(-154) returns 1 The sig-natures without function name are Int16(ByteByte | Int16)Double(ByteDecimal | Double) Int32(ByteInt32)Int64(ByteInt64) Single(ByteSingle) Double(Decimal |DoubleByte | Decimal | Double | Int16 | Int32 | Int64 | Single)Int16(Int16Byte | Int16 | Int32 | Int32) Double(Int16Decimal |Double) Single(Int16Single) Int32(Int32Byte | Int32 | Int64)Double(Int32Decimal | Double) Int16(Int32Int16)Single(Int32Single)Int64(Int64Byte | Int64)Double(Int64Decimal | Double) Int16(Int64Int16)Int32(Int64Int32) Single(Int64Single) Single(SingleByte | Int16| Int32 | Int64 | Single))

Expression | 59

DescriptionFunction Name

Returns a Double which is the sine of a numeric expression Sin(numeric)

Sin

Returns a Double which is the square root of a numeric expressionSqrt (numeric)

Sqrt

Returns a Double which is the tangent of a numeric expressionTan (numeric)

Tan

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Byte Abs(Byte) Decimal Abs(Decimal) Double Abs(Double)Int16 Abs(Int16) Int32 Abs(Int32) Int64 Abs(Int64) SingleAbs(Single)

-+--++-+-+-+Double Acos(Byte) Double Acos(Decimal) Double Acos(Double)Double Acos(Int16) Double Acos(Int32) Double Acos(Int64)Double Acos(Single)

-+--++-+-+-+Double Asin(Byte) Double Asin(Decimal) Double Asin(Double)Double Asin(Int16) Double Asin(Int32) Double Asin(Int64)Double Asin(Single)

-+--++-+-+-+Double Atan(Byte) Double Atan(Decimal) Double Atan(Double)Double Atan(Int16) Double Atan(Int32) Double Atan(Int64)Double Atan(Single)

-+--++-+-+-+Double Atan2(ByteByte) Double Atan2(ByteDecimal) DoubleAtan2(ByteDouble) Double Atan2(ByteInt16) DoubleAtan2(ByteInt32) Double Atan2(ByteInt64) DoubleAtan2(ByteSingle) Double Atan2(DecimalByte) DoubleAtan2(DecimalDecimal) Double Atan2(DecimalDouble) DoubleAtan2(DecimalInt16) Double Atan2(DecimalInt32) DoubleAtan2(DecimalInt64) Double Atan2(DecimalSingle) Double

60 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Atan2(DoubleByte) Double Atan2(DoubleDecimal) DoubleAtan2(DoubleDouble) Double Atan2(DoubleInt16) DoubleAtan2(DoubleInt32) Double Atan2(DoubleInt64) DoubleAtan2(DoubleSingle) Double Atan2(Int16Byte) DoubleAtan2(Int16Decimal) Double Atan2(Int16Double) DoubleAtan2(Int16Int16) Double Atan2(Int16Int32) DoubleAtan2(Int16Int64) Double Atan2(Int16Single) DoubleAtan2(Int32Byte) Double Atan2(Int32Decimal) DoubleAtan2(Int32Double) Double Atan2(Int32Int16) DoubleAtan2(Int32Int32) Double Atan2(Int32Int64) DoubleAtan2(Int32Single) Double Atan2(Int64Byte) DoubleAtan2(Int64Decimal) Double Atan2(Int64Double) DoubleAtan2(Int64Int16) Double Atan2(Int64Int32) DoubleAtan2(Int64Int64) Double Atan2(Int64Single) DoubleAtan2(SingleByte) Double Atan2(SingleDecimal) DoubleAtan2(SingleDouble) Double Atan2(SingleInt16) DoubleAtan2(SingleInt32) Double Atan2(SingleInt64) DoubleAtan2(SingleSingle)

-+--++-+-+-+Double Cos(Byte) Double Cos(Decimal) Double Cos(Double)Double Cos(Int16) Double Cos(Int32) Double Cos(Int64)Double Cos(Single)

-+--++-+-+-+Double Exp(Byte) Double Exp(Decimal) Double Exp(Double)Double Exp(Int16) Double Exp(Int32) Double Exp(Int64)Double Exp(Single)

-+--++-+-+-+Double Ln(Byte) Double Ln(Decimal) Double Ln(Double)Double Ln(Int16) Double Ln(Int32) Double Ln(Int64) DoubleLn(Single)

-+--++-+-+-+Double Log(ByteByte) Double Log(ByteDecimal) DoubleLog(ByteDouble) Double Log(ByteInt16) DoubleLog(ByteInt32) Double Log(ByteInt64) DoubleLog(ByteSingle) Double Log(DecimalByte) DoubleLog(DecimalDecimal) Double Log(DecimalDouble) Double

Expression | 61

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Log(DecimalInt16) Double Log(DecimalInt32) DoubleLog(DecimalInt64) Double Log(DecimalSingle) DoubleLog(DoubleByte) Double Log(DoubleDecimal) DoubleLog(DoubleDouble) Double Log(DoubleInt16) DoubleLog(DoubleInt32) Double Log(DoubleInt64) DoubleLog(DoubleSingle) Double Log(Int16Byte) DoubleLog(Int16Decimal) Double Log(Int16Double) DoubleLog(Int16Int16) Double Log(Int16Int32) DoubleLog(Int16Int64) Double Log(Int16Single) DoubleLog(Int32Byte) Double Log(Int32Decimal) DoubleLog(Int32Double) Double Log(Int32Int16) DoubleLog(Int32Int32) Double Log(Int32Int64) DoubleLog(Int32Single) Double Log(Int64Byte) DoubleLog(Int64Decimal) Double Log(Int64Double) DoubleLog(Int64Int16) Double Log(Int64Int32) DoubleLog(Int64Int64) Double Log(Int64Single) DoubleLog(SingleByte) Double Log(SingleDecimal) DoubleLog(SingleDouble) Double Log(SingleInt16) DoubleLog(SingleInt32) Double Log(SingleInt64) DoubleLog(SingleSingle)

-+--++-+-+-+Byte Mod(ByteByte) Byte Mod(ByteInt16) ByteMod(ByteInt32) Byte Mod(ByteInt64) DoubleMod(ByteDecimal) Double Mod(ByteDouble) DoubleMod(DecimalByte) Double Mod(DecimalDecimal) DoubleMod(DecimalDouble) Double Mod(DecimalInt16) DoubleMod(DecimalInt32) Double Mod(DecimalInt64) DoubleMod(DecimalSingle) Double Mod(DoubleByte) DoubleMod(DoubleDecimal) Double Mod(DoubleDouble) DoubleMod(DoubleInt16) Double Mod(DoubleInt32) DoubleMod(DoubleInt64) Double Mod(DoubleSingle) DoubleMod(Int16Decimal) Double Mod(Int16Double) DoubleMod(Int32Decimal) Double Mod(Int32Double) DoubleMod(Int64Decimal) Double Mod(Int64Double) DoubleMod(SingleDecimal) Double Mod(SingleDouble) Int16Mod(Int16Byte) Int16 Mod(Int16Int16) Int16Mod(Int16Int32) Int16 Mod(Int16Int64) Int16

62 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Mod(Int32Int16) Int16 Mod(Int64Int16) Int32Mod(Int32Byte) Int32 Mod(Int32Int32) Int32Mod(Int32Int64) Int32 Mod(Int64Int32) Int64Mod(Int64Byte) Int64 Mod(Int64Int64) SingleMod(ByteSingle) Single Mod(Int16Single) SingleMod(Int32Single) Single Mod(Int64Single) SingleMod(SingleByte) Single Mod(SingleInt16) SingleMod(SingleInt32) Single Mod(SingleInt64) SingleMod(SingleSingle)

-+--++-+-+-+Double Power(ByteByte) Double Power(ByteDecimal) DoublePower(ByteDouble) Double Power(ByteInt16) DoublePower(ByteInt32) Double Power(ByteInt64) DoublePower(ByteSingle) Double Power(DecimalByte) DoublePower(DecimalDecimal) Double Power(DecimalDouble) DoublePower(DecimalInt16) Double Power(DecimalInt32) DoublePower(DecimalInt64) Double Power(DecimalSingle) DoublePower(DoubleByte) Double Power(DoubleDecimal) DoublePower(DoubleDouble) Double Power(DoubleInt16) DoublePower(DoubleInt32) Double Power(DoubleInt64) DoublePower(DoubleSingle) Double Power(Int16Byte) DoublePower(Int16Decimal) Double Power(Int16Double) DoublePower(Int16Int16) Double Power(Int16Int32) DoublePower(Int16Int64) Double Power(Int16Single) DoublePower(Int32Byte) Double Power(Int32Decimal) DoublePower(Int32Double) Double Power(Int32Int16) DoublePower(Int32Int32) Double Power(Int32Int64) DoublePower(Int32Single) Double Power(Int64Byte) DoublePower(Int64Decimal) Double Power(Int64Double) DoublePower(Int64Int16) Double Power(Int64Int32) DoublePower(Int64Int64) Double Power(Int64Single) DoublePower(SingleByte) Double Power(SingleDecimal) DoublePower(SingleDouble) Double Power(SingleInt16) DoublePower(SingleInt32) Double Power(SingleInt64) DoublePower(SingleSingle)

Expression | 63

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Remainder(ByteDecimal) Double Re-mainder(ByteDouble) Double Remainder(DecimalByte) DoubleRemainder(DecimalDecimal) Double Remainder(Decim-alDouble) Double Remainder(DecimalInt16) Double Re-mainder(DecimalInt32) Double Remainder(DecimalInt64)Double Remainder(DecimalSingle) Double Re-mainder(DoubleByte) Double Remainder(DoubleDecimal)Double Remainder(DoubleDouble) Double Re-mainder(DoubleInt16) Double Remainder(DoubleInt32)Double Remainder(DoubleInt64) Double Re-mainder(DoubleSingle) Double Remainder(Int16Decimal)Double Remainder(Int16Double) Double Re-mainder(Int32Decimal) Double Remainder(Int32Double)Double Remainder(Int64Decimal) Double Re-mainder(Int64Double) Double Remainder(SingleDecimal)Double Remainder(SingleDouble) Int16 Remainder(ByteByte)Int16 Remainder(ByteInt16) Int16 Remainder(Int16Byte) Int16Remainder(Int16Int16) Int16 Remainder(Int16Int32) Int16Remainder(Int16Int64) Int16 Remainder(Int32Int16) Int16Remainder(Int64Int16) Int32 Remainder(ByteInt32) Int32 Re-mainder(Int32Byte) Int32 Remainder(Int32Int32) Int32 Re-mainder(Int32Int64) Int32 Remainder(Int64Int32) Int64 Re-mainder(ByteInt64) Int64 Remainder(Int64Byte) Int64 Re-mainder(Int64Int64) Single Remainder(ByteSingle) Single Re-mainder(Int16Single) Single Remainder(Int32Single) SingleRemainder(Int64Single) Single Remainder(SingleByte) SingleRemainder(SingleInt16) Single Remainder(SingleInt32) SingleRemainder(SingleInt64) Single Remainder(SingleSingle)

-+--++-+-+-+Double Sin(Byte) Double Sin(Decimal) Double Sin(Double)Double Sin(Int16) Double Sin(Int32) Double Sin(Int64) DoubleSin(Single)

-+--++-+-+-+Double Sqrt(Byte) Double Sqrt(Decimal) Double Sqrt(Double)Double Sqrt(Int16) Double Sqrt(Int32) Double Sqrt(Int64)Double Sqrt(Single)

64 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+Double Tan(Byte) Double Tan(Decimal) Double Tan(Double)Double Tan(Int16) Double Tan(Int32) Double Tan(Int64)Double Tan(Single)

Numeric Expression Functions

DescriptionFunction Name

Returns the smallest integer greater than or equal to a numeric ex-pression The return type is the same as the argument type Where

Ceil

the argument is a Decimal Double or Single the returned value isan integral number Ceil(numeric)

Returns the largest integer less than or equal to a numeric expres-sion The return type is the same as the argument type Where the

Floor

argument is a Decimal Double or Single the returned value is anintegral number Floor (numeric)

Returns the rounded value of a numeric expression The return typeis the same as the type of the first argument Round (numeric [number_of_decimals_numeric])

Round

Returns and Int32 which is -1 if the provided numeric expressionevaluates to a value less than 0 0 if the expression evaluates to 0

Sign

and 1 if the expression evaluates to a value bigger than 0 Sign(numeric)

Truncates a numeric or date expression The return type is the sameas the type of the first argument Trunc (date_time YEAR | MONTH

Trunc

Expression | 65

DescriptionFunction Name

| DAY | HOUR | MINUTE) Trunc (numeric [ number_of_decim-als_numeric])

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+++Int64 Ceil(Int64)

-+--++-+-+++Int64 Floor(Int64)

-+--++-+-+-+Byte Ceil(Byte) Decimal Ceil(Decimal) Double Ceil(Double)Int16 Ceil(Int16) Int32 Ceil(Int32) Single Ceil(Single)

-+--++-+-+-+Byte Floor(Byte) Decimal Floor(Decimal) DoubleFloor(Double) Int16 Floor(Int16) Int32 Floor(Int32) SingleFloor(Single)

-+--++-+-+-+Byte Round(Byte) Byte Round(ByteByte) ByteRound(ByteDecimal) Byte Round(ByteDouble) ByteRound(ByteInt16) Byte Round(ByteInt32) ByteRound(ByteInt64) Byte Round(ByteSingle) DecimalRound(Decimal) Decimal Round(DecimalByte) DecimalRound(DecimalDecimal) Decimal Round(DecimalDouble)Decimal Round(DecimalInt16) Decimal Round(Decim-alInt32) Decimal Round(DecimalInt64) DecimalRound(DecimalSingle) Double Round(Double) DoubleRound(DoubleByte) Double Round(DoubleDecimal) DoubleRound(DoubleDouble) Double Round(DoubleInt16) DoubleRound(DoubleInt32) Double Round(DoubleInt64) DoubleRound(DoubleSingle) Int16 Round(Int16) Int16Round(Int16Byte) Int16 Round(Int16Decimal) Int16Round(Int16Double) Int16 Round(Int16Int16) Int16Round(Int16Int32) Int16 Round(Int16Int64) Int16Round(Int16Single) Int32 Round(Int32) Int32Round(Int32Byte) Int32 Round(Int32Decimal) Int32Round(Int32Double) Int32 Round(Int32Int16) Int32

66 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Round(Int32Int32) Int32 Round(Int32Int64) Int32Round(Int32Single) Int64 Round(Int64) Int64Round(Int64Byte) Int64 Round(Int64Decimal) Int64Round(Int64Double) Int64 Round(Int64Int16) Int64Round(Int64Int32) Int64 Round(Int64Int64) Int64Round(Int64Single) Single Round(Single) SingleRound(SingleByte) Single Round(SingleDecimal) SingleRound(SingleDouble) Single Round(SingleInt16) SingleRound(SingleInt32) Single Round(SingleInt64) SingleRound(SingleSingle)

-+--++-+-+-+Int32 Sign(Byte) Int32 Sign(Decimal) Int32 Sign(Double)Int32 Sign(Int16) Int32 Sign(Int32) Int32 Sign(Int64) Int32Sign(Single)

-+--++-+-+-+Byte Trunc(Byte) Byte Trunc(ByteByte) ByteTrunc(ByteDecimal) Byte Trunc(ByteDouble) ByteTrunc(ByteInt16) Byte Trunc(ByteInt32) ByteTrunc(ByteInt64) Byte Trunc(ByteSingle) DateTimeTrunc(DateTimeString) Decimal Trunc(Decimal) DecimalTrunc(DecimalByte) Decimal Trunc(DecimalDecimal)Decimal Trunc(DecimalDouble) Decimal Trunc(Decim-alInt16) Decimal Trunc(DecimalInt32) DecimalTrunc(DecimalInt64) Decimal Trunc(DecimalSingle) DoubleTrunc(Double) Double Trunc(DoubleByte) DoubleTrunc(DoubleDecimal) Double Trunc(DoubleDouble)Double Trunc(DoubleInt16) Double Trunc(DoubleInt32)Double Trunc(DoubleInt64) Double Trunc(DoubleSingle)Int16 Trunc(Int16) Int16 Trunc(Int16Byte) Int16Trunc(Int16Decimal) Int16 Trunc(Int16Double) Int16Trunc(Int16Int16) Int16 Trunc(Int16Int32) Int16Trunc(Int16Int64) Int16 Trunc(Int16Single) Int32Trunc(Int32) Int32 Trunc(Int32Byte) Int32Trunc(Int32Decimal) Int32 Trunc(Int32Double) Int32Trunc(Int32Int16) Int32 Trunc(Int32Int32) Int32Trunc(Int32Int64) Int32 Trunc(Int32Single) Int64Trunc(Int64) Int64 Trunc(Int64Byte) Int64

Expression | 67

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

Trunc(Int64Decimal) Int64 Trunc(Int64Double) Int64Trunc(Int64Int16) Int64 Trunc(Int64Int32) Int64Trunc(Int64Int64) Int64 Trunc(Int64Single) SingleTrunc(Single) Single Trunc(SingleByte) SingleTrunc(SingleDecimal) Single Trunc(SingleDouble) SingleTrunc(SingleInt16) Single Trunc(SingleInt32) SingleTrunc(SingleInt64) Single Trunc(SingleSingle)

String Expression Functions

All of these functions return a string

DescriptionFunction Name

Returns the concatenation of two string expressions Concat(boolean | date | numeric | string boolean | date | numeric |string)

Concat

Returns an Int64 which is the position of a substring in a stringexpression Instr(stringstring)

Instr

Returns an Int64 which is the length of a string expressionLength(string)

Length

Converts all uppercase letters in a string expression into lowercaseletters string Lower (string)

Lower

Pads a string expression to the left to a predefined string lengthstring Lpad (string TotalLengthOfResult [ pad-string]) If used withtwo parameters only the pad-string is a single space character

Lpad

Removes leading blanks from a string expression string Ltrim(string)

Ltrim

68 | Chapter 6 FDO Capabilities

DescriptionFunction Name

Pads a string expression to the right to a predefined string lengthstring Rpad (string TotalLengthOfResult [ pad-string]) If used

Rpad

with two parameters only the pad-string is a single space character

Removes trailing blanks from a string expression string Rtrim(string)

Rtrim

Returns a string which is the phonetic representation of a stringexpression See the entry in Wikipedia for more information ht-

Soundex

tpenwikipediaorgwikiSoundex Soundex (string) Soun-dex(lsquoeightrsquo) returns ldquoE230rdquo and Soundex(lsquoexpressionrsquo) returnsldquoE216rdquo

Extracts a substring from a string expression string Substr (stringstart_pos [ length])

Substr

Replaces a set of letters in a string Translate (string from_set_stringto_set_string) If string is ldquoSQLPlus Users Guiderdquo and

Translate

from_set_string is thatis lsquospaceasteriskforward slashsingle quotesingle quotersquo and the to_set_string is___ that islsquounderscoreunderscoreunderscorersquo then the returned stringis lsquoSQL_PLus_Users_Guidersquo Translate looks for each character inthe from_set_string in the string argument and replaces it with thecorresponding character from the to_set_string In this case twospaces are replace by underscores and an asterisk is replaced by nunderscore There is no forward slash in the target string to be re-placed and there is no replacement character in the to_set_stringcorresponding to the single apostrophe character in thefrom_set_string When there is no replacement character in theto_set_string corresponding to a character in the from_set_stringthe character in the from_set_string is removed wherever it is foundin the target string

Removes leading andor trailing blanks from a string expressionTrim ([BOTH | LEADING | TRAILING ] string)

Trim

Expression | 69

DescriptionFunction Name

Converts all lowercase letters in a string expression into uppercaseletters Upper (string)

Upper

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+++++String Concat(StringString)

-+--++-+-+-+String Concat(BooleanBoolean) String Concat(BooleanByte)String Concat(BooleanDateTime) String Concat(BooleanDecim-al) String Concat(BooleanDouble) String Concat(BooleanInt16)String Concat(BooleanInt32) String Concat(BooleanInt64) StringConcat(BooleanSingle) String Concat(BooleanString) StringConcat(ByteBoolean) String Concat(ByteByte) String Con-cat(ByteDateTime) String Concat(ByteDecimal) String Con-cat(ByteDouble) String Concat(ByteInt16) String Con-cat(ByteInt32) String Concat(ByteInt64) String Con-cat(ByteSingle) String Concat(ByteString) String Concat(Date-TimeBoolean) String Concat(DateTimeByte) String Concat(Dat-eTimeDateTime) String Concat(DateTimeDecimal) StringConcat(DateTimeDouble) String Concat(DateTimeInt16) StringConcat(DateTimeInt32) String Concat(DateTimeInt64) StringConcat(DateTimeSingle) String Concat(DateTimeString) StringConcat(DecimalBoolean) String Concat(DecimalByte) StringConcat(DecimalDateTime) String Concat(DecimalDecimal)String Concat(DecimalDouble) String Concat(DecimalInt16)String Concat(DecimalInt32) String Concat(DecimalInt64)String Concat(DecimalSingle) String Concat(DecimalString)String Concat(DoubleBoolean) String Concat(DoubleDateTime)String Concat(DoubleDecimal) String Concat(DoubleDouble)String Concat(DoubleInt16) String Concat(DoubleInt32) StringConcat(DoubleInt64) String Concat(DoubleSingle) StringConcat(DoubleString) String Concat(Int16Boolean) StringConcat(Int16Byte) String Concat(Int16DateTime) String Con-cat(Int16Decimal) String Concat(Int16Double) String Con-cat(Int16Int16) String Concat(Int16Int32) String Con-cat(Int16Int64) String Concat(Int16Single) String Con-

70 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

cat(Int16String) String Concat(Int32Boolean) String Con-cat(Int32Byte) String Concat(Int32DateTime) String Con-cat(Int32Decimal) String Concat(Int32Double) String Con-cat(Int32Int16) String Concat(Int32Int32) String Con-cat(Int32Int64) String Concat(Int32Single) String Con-cat(Int32String) String Concat(Int64Boolean) String Con-cat(Int64Byte) String Concat(Int64DateTime) String Con-cat(Int64Decimal) String Concat(Int64Double) String Con-cat(Int64Int16) String Concat(Int64Int32) String Con-cat(Int64Int64) String Concat(Int64Single) String Con-cat(Int64String) String Concat(SingleBoolean) String Con-cat(SingleByte) String Concat(SingleDateTime) String Con-cat(SingleDecimal) String Concat(SingleDouble) String Con-cat(SingleInt16) String Concat(SingleInt32) String Con-cat(SingleInt64) String Concat(SingleSingle) String Con-cat(SingleString) String Concat(StringBoolean) String Con-cat(StringByte) String Concat(StringDateTime) String Con-cat(StringDecimal) String Concat(StringDouble) String Con-cat(StringInt16) String Concat(StringInt32) String Con-cat(StringInt64) String Concat(StringSingle)

-+--++-+-+-+Int64 Instr(StringString)

-+--++-+-+-+Int64 Length(String)

-+--++-+-+-+String Lower(String)

-+--++-+-+-+String Lpad(StringByte) String Lpad(StringByteString) StringLpad(StringDecimal) String Lpad(StringDecimalString) StringLpad(StringDouble) String Lpad(StringDoubleString) StringLpad(StringInt16) String Lpad(StringInt16String) StringLpad(StringInt32) String Lpad(StringInt32String) StringLpad(StringInt64) String Lpad(StringInt64String) StringLpad(StringSingle) String Lpad(StringSingleString)

-+--++-+-+-+String Ltrim(String)

Expression | 71

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+String Rpad(StringByte) String Rpad(StringByteString) StringRpad(StringDecimal) String Rpad(StringDecimalString) StringRpad(StringDouble) String Rpad(StringDoubleString) StringRpad(StringInt16) String Rpad(StringInt16String) StringRpad(StringInt32) String Rpad(StringInt32String) StringRpad(StringInt64) String Rpad(StringInt64String) StringRpad(StringSingle) String Rpad(StringSingleString)

-+--++-+-+-+String Rtrim(String)

-+--++-+-+-+String Soundex(String)

-+--++-+-+-+String Substr(StringByte) String Substr(StringByteByte) StringSubstr(StringByteDecimal) String Substr(StringByteDouble)String Substr(StringByteInt16) String Substr(StringByteInt32)String Substr(StringByteInt64) String Substr(StringByteSingle)String Substr(StringDecimal) String Substr(StringDecimalByte)String Substr(StringDecimalDecimal) String Substr(StringDecim-alDouble) String Substr(StringDecimalInt16) String Sub-str(StringDecimalInt32) String Substr(StringDecimalInt64)String Substr(StringDecimalSingle) String Substr(StringDouble)String Substr(StringDoubleByte) String Sub-str(StringDoubleDecimal) String Substr(StringDoubleDouble)String Substr(StringDoubleInt16) String Sub-str(StringDoubleInt32) String Substr(StringDoubleInt64) StringSubstr(StringDoubleSingle) String Substr(StringInt16) StringSubstr(StringInt16Byte) String Substr(StringInt16Decimal)String Substr(StringInt16Double) String Sub-str(StringInt16Int16) String Substr(StringInt16Int32) StringSubstr(StringInt16Int64) String Substr(StringInt16Single)String Substr(StringInt32) String Substr(StringInt32Byte) StringSubstr(StringInt32Decimal) String Substr(StringInt32Double)String Substr(StringInt32Int16) String Substr(StringInt32Int32)String Substr(StringInt32Int64) String Substr(StringInt32Single)String Substr(StringInt64) String Substr(StringInt64Byte) StringSubstr(StringInt64Decimal) String Substr(StringInt64Double)

72 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

String Substr(StringInt64Int16) String Substr(StringInt64Int32)String Substr(StringInt64Int64) String Substr(StringInt64Single)String Substr(StringSingle) String Substr(StringSingleByte)String Substr(StringSingleDecimal) String Sub-str(StringSingleDouble) String Substr(StringSingleInt16) StringSubstr(StringSingleInt32) String Substr(StringSingleInt64)String Substr(StringSingleSingle)

-+--++-+-+-+String Translate(StringStringString)

-+--++-+-+-+String Trim(String) String Trim(StringString)

-+--++-+-+-+String Upper(String)

----------+-String Lower(StringString)

----------+-String Upper(StringString)

Miscellaneous Expression Functions

The following functions were not affected by the introduction of the ExpressionBuilder component in FDO 33

DescriptionFunction Name

Returns a geometry that is the subset of the geometry argumentdefined by the polygon specified by the coordinate argumentsCLIP(BLOBDoubleDoubleDoubleDouble)

CLIP

Returns a geometry MOSAIC(BLOB)MOSAIC

Returns a geometry RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

RESAMPLE

Expression | 73

DescriptionFunction Name

Returns a geometry SpatialExtent(BLOB)SpatialExtent

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----BLOB CLIP(BLOBDoubleDoubleDoubleDouble)

--+---+-----BLOB RES-AMPLE(BLOBDoubleDoubleDoubleDoubleInt32Int32)

--+---------BLOB SpatialExtents(BLOB)

------+-----BLOB MOSAIC(BLOB)

Filter

In C you access theOSGeoFDOConnectionsCapabilitiesIFilterCapabilities using theIConnection object (connectionFilterCapabilities)

In C++ you access the FdoIFilterCapabilities using the IConnection object(connection-gtGetFilterCapabilities())

DescriptionCapability

Tests if the value of a specified data property is within a givenset of literal values

ConditionType_In

Tests if one expression is equal not equal greater than lessthan greater than or equal to or less than or equal to anotherexpression

ConditionType_Comparison

Tests whether the value of a geometric property is within orbeyond a specified distance of a literal geometric value

ConditionType_Distance

74 | Chapter 6 FDO Capabilities

DescriptionCapability

Tests whether the value of a specified data property matchesa specified pattern

ConditionType_Like

Tests whether the value of a specified data property is nullConditionType_Null

Tests whether the value of a geometric property and a literalgeometric value satisfy the spatial relationship implied by theoperation

ConditionType_Spatial

Tests whether the geometric property value lies beyond aspecified distance of a literal geometric value

DistanceOperations_Beyond

Tests whetherthe geometric property value lies within a spe-cified distance of a literal geometric value

DistanceOperations_Within

Tests whetherthe geometric property value spatially containsthe literal geometric value

SpatialOperations_Contains

Tests whether the geometric property value is covered by theinterior and boundary of the given geometry

SpatialOperations_CoveredBy

Tests whetherthe geometric property value spatially crossesthe given geometry

SpatialOperations_Crosses

Tests whether the geometric property value is spatially disjointfrom the given geometry

SpatialOperations_Disjoint

Tests whether the envelope of the referenced geometricproperty value spatially intersects the given geometry

SpatialOperations_EnvelopeIntersects

Tests whether the geometric property value is spatially equalto the given geometry

SpatialOperations_Equals

Tests whether the geometric property value is inside the in-terior of the given geometry not touching the boundary

SpatialOperations_Inside

Filter | 75

DescriptionCapability

Tests whether the geometric property value spatially intersectsthe given geometry

SpatialOperations_Intersects

Tests whether the geometric property value spatially overlapsthe given geometry

SpatialOperations_Overlaps

Tests whether the geometric property value spatially touchesthe given geometry

SpatialOperations_Touches

Tests whether the geometric property value is spatially withinthe given geometry

SpatialOperations_Within

Tests whether the spatial and distance operations can be ap-plied between two geometric properties Returns false if spatial

SupportsNonLiteralGeometricOperations

and distance operations can be applied only between a geo-metric property and a literal geometry Returns true if spatialand distance operations can be applied

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++--++++++++SpatialOperations_EnvelopeIntersects ConditionType_In Condi-tionType_Spatial

-+--++++++++SpatialOperations_Intersects

++--++-+++++ConditionType_Null ConditionType_Comparison Condition-Type_Like

-+--+++++-++SpatialOperations_Inside

-+--+++-+-++SpatialOperations_Within

-------+++-+ConditionType_Distance

76 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-----+--+-++SpatialOperations_Disjoint SpatialOperations_Contains

--------+-++SpatialOperations_CoveredBy SpatialOperations_Crosses Spa-tialOperations_Touches SpatialOperations_Equals SpatialOper-ations_Overlaps

--------+--+DistanceOperations_Beyond DistanceOperations_Within

---+--------SupportsNonLiteralGeometricOperations

------------SupportsGeodesicDistance

Geometry

In C you access theOSGeoFDOConnectionsCapabilitiesIGeometryCapabilities using theIConnection object (connectionGeometryCapabilities)

In C++ you access the FdoIGeometryCapabilities using the IConnectionobject (connection-gtGetGeometryCapabilities())

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++FdoDimensionality_XY

+-++++-+++++GeometryType_Polygon GeometryComponentType_Linear-Ring

++-+++-+++++GeometryType_Point

Geometry | 77

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

+--+++-+++++GeometryType_MultiLineString GeometryType_MultiPointGeometryType_LineString

+--+-+-+++++GeometryType_MultiPolygon

+--+++-+--++GeometryComponentType_LineStringSegment

---+++--+-++FdoDimensionality_M FdoDimensionality_Z

+--+-+-+--+-GeometryComponentType_Ring

+--+-+--+-+-GeometryType_MultiGeometry

---+-+-+--+-GeometryType_CurvePolygon GeometryComponentType_Cir-cularArcSegment GeometryType_CurveString Geometry-Type_MultiCurvePolygon GeometryType_MultiCurveString

Raster

In C you access theOSGeoFDOConnectionsCapabilitiesIRasterCapabilities using theIConnection object (connectionRasterCapabilities)

In C++ you access the FdoIRasterCapabilities using the IConnection object(connection-gtGetRasterCapabilities())

DescriptionCapability

Indicates whether or not a provider supports the retrieval andmanipulation of image data

SupportsRaster

Indicates whether or not a provider supports the reduction ofthe amount of detail and data in the image

SupportsSubsampling

78 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the compositionof multiple raster images

SupportsStitching

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

--+---+-----SupportsRaster SupportsSubsampling

------------SupportsStitching

Schema

In C you access theOSGeoFDOConnectionsCapabilitiesISchemaCapabilities using theIConnection object (connectionSchemaCapabilities)

In C++ you access the FdoISchemaCapabilities using the IConnection object(connection-gtGetSchemaCapabilities())

DescriptionCapability

Indicates whether or not a provider supports auto gener-ation of values for the data types represented by the as-terisk Boolean Byte DateTime and Decimal

AutoGenerated_

Indicates whether or not a provider supports the Classtype which does not have a Geometry property

ClassType_Class

Indicates whether or not a provider supports the Classtype which does have a Geometry property

ClassType_FeatureClass

Indicates whether or not a provider supports the spe-cificdata type that replaces the BLOB Boolean Byte

DataType_

Schema | 79

DescriptionCapability

CLOB DateTime Decimal Double Int16 Int32 Int64Single or String

Indicates whether or not a provider supports the use ofthe property types represented by the asterisk as identity

IdentityProperty_

properties BLOB Boolean Byte DateTime DecimalDouble Int16 Int32 Int64 Single and String

Indicates whether or not a provider supports decimals upto the specified number of digits in length

MaximumDecimalPrecision

Indicates whether or not a provider supports decimalswith up to the specified number of digits to the right ofthe decimal point

MaximumDecimalScale

The set of characters which cannot be used in schemaelement names

ReservedCharactersForName

Indicates whether or not a provider supports the associ-ation property

SupportsAssociationProperties

Indicates whether or not a provider supports the automat-ic generation of id property values

SupportsAutoIdGeneration

Indicates whether or not a provider supports multipleidentity properties per class

SupportsCompositeId

Indicates whether or not a provider supports unique valueconstraints on a set of columns

SupportsCompositeUniqueValueConstraints

Indicates whether or not a provider supports the automat-ic generation of ID values that are unique for the entiredatastore rather than just for a particular class

SupportsDataStoreScopeUniqueIdGeneration

Indicates whether or not a provider supports the specific-ation of default values for property definitions

SupportsDefaultValue

80 | Chapter 6 FDO Capabilities

DescriptionCapability

Indicates whether or not a provider supports the settingof minimums that the input data must greater than andmaximums that the input data must be less than

SupportsExclusiveValueRangeConstraints

Indicates whether or not a provider supports the settingof minimums that the input data must greater than or

SupportsInclusiveValueRangeConstraints

equal to and maximums that the input data must be lessthan or equal to

Indicates whether or not a provider supports class hier-archies in the feature schema

SupportsInheritance

Indicates whether or not a provider supports the definitionof more than one feature schema in the data store

SupportsMultipleSchemas

Indicates whether or not a provider allows property valuesto be null

SupportsNullValueConstraints

Indicates whether or not a provider supports objectproperties A class instance can contain an instance ofanother class

SupportsObjectProperties

Indicates whether or not a provider supports the modific-ation of a schema after its intitial creation

SupportsSchemaModification

Indicates whether or not a provider supports the overrid-ing of the default rules for mapping feature schemas toprovider-specific physical schemas

SupportsSchemaOverrides

Indicates whether or not a provider supports requiringthat a column contain unique values

SupportsUniqueValueConstraints

Indicates whether or not a provider supports requiringthat a column contain values that belong to a value con-straints list

SupportsValueConstraintsList

Schema | 81

Expressible as Boolean

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

++++++++++++ClassType_FeatureClass DataType_String

++-+++-+++++IdentityProperty_Int32 DataType_Int32 DataType_DateTimeClassType_Class

++-+-+-+++++DataType_Double

--++-+++++++IdentityProperty_String

-+-+-+-+++++DataType_Int16 DataType_Single IdentityProperty_Int16

-+--++-+++++SupportsAutoIdGeneration SupportsNullValueConstraints

-++-+-+++++-SupportsSchemaOverrides

-+-+++-++++-DataType_Decimal DataType_Boolean

++--++--+-++AutoGenerated_Int32

-+++-+++-+--SupportsInheritance

-+-+-+-++++-DataType_Byte IdentityProperty_Int64 DataType_Int64

---+-+-+++++IdentityProperty_Double IdentityProperty_DateTime Identi-tyProperty_Single

-+-+--++-+++SupportsMultipleSchemas

-+-+-+-+++--SupportsCompositeId

82 | Chapter 6 FDO Capabilities

1=OSGeoArcSDE 2=OSGeoKingOracle 3=OSGeoMySQL 4=OSGeoPostGIS 5=OS-GeoSQLServerSpatial 6=OSGeoGdal 7=OSGeoSDF 8=OSGeoSHP 9=OSGeoWFSA=OSGeoWFS B=OSGeoWMS C=OSGeoOGR

CBA987654321Capability

-+--++-+-+-+ReservedCharactersForName

----++-++++-SupportsSchemaModification

-+--+--+++-+MaximumDecimalPrecision MaximumDecimalScale

---+-+-++++-IdentityProperty_Boolean IdentityProperty_Decimal Identi-tyProperty_Byte

-------+++-+SupportsCompositeUniqueValueConstraints SupportsUnique-ValueConstraints

-+-----+++--AutoGenerated_Int64 SupportsDefaultValue

---+-+-+-+--SupportsAssociationProperties

--+---+----+DataType_BLOB

---+---+-+--SupportsObjectProperties

-------+-+--SupportsDataStoreScopeUniqueIdGeneration

-----+-+----SupportsValueConstraintsList SupportsExclusiveValueRangeCon-straints SupportsInclusiveValueRangeConstraints

Not Expressible as a Boolean

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

3838ArcSDE

Schema | 83

Maximum DecimalScale

Maximum DecimalPrecision

Reserved Charac-ters for Name

Provider

6565MySQL

10001000nullPostGIS

3838SQLServerSpa-tial

nullnullSDF

255255SHP

2828ODBC

84 | Chapter 6 FDO Capabilities

Schema Management

This chapter describes how to create and work with schemas and explains some issues relatedto schema management For example you can use the FDO feature schema to specify howto represent geospatial features

Schema PackageThe FDO feature schema provides a logical mechanism for specifying how torepresent geospatial features FDO providers are responsible for mapping thefeature schema to some underlying physical data store The FDO feature schemais based somewhat on a subset of the OpenGIS and ISO feature models Itsupports both non-spatial features and spatial features

The Schema package contains a collection of classes that define the logicalfeature schema These classes can be used to set up a feature schema and tointerrogate the metadata from a provider using an object-oriented structureThe logical feature schema provides a logical view of geospatial feature data thatis fully independent from the underlying storage schema All data operationsin FDO are performed against the classes and relationships defined by the logicalfeature schema For example different class types in the feature schema are usedto describe different types of geospatial objects and spatial features

Base Properties

All classes in the feature schema support the concept of base properties whichare properties that are pre-defined either by the FDO API or by a specific FDOfeature provider For example all classes in the schema have two base propertiesClassName and SchemaName These properties can be used to query across aninheritance hierarchy or to process the results of heterogeneous queries FDO

7

85

feature providers can also predefine base properties The following baseproperties are predefined by the FDO API

DescriptionRequiredProperty Name

Name of the schema to which objects of the classbelong read-only string

YSchemaName

Name of the class that defines the object read-onlystring

YClassName

Revision number of the object read-only 64-bit in-teger

NRevisionNumber

NOTE Some providers may use this property tosupport optimistic locking

Cross-Schema References

Some FDO feature providers may support multiple schemas For these providersthe feature schema supports the concept of cross-schema references for classesThis means that a class in one schema may derive from a class in anotherschema relate to a class in another schema or contain an object propertydefinition that is based on a class in another schema

Parenting in the Schema Classes

The feature schema object model defined in the FDO API supports fullnavigation through parenting That is once a schema element is added to anFdoFeatureSchema class it can navigate the object hierarchy upward to theroot FdoFeatureSchema and from there to any other element in the featureschema This parenting support is fully defined in the FdoSchemaElementabstract base class

When inserting features that have object collections the parent object instancemust be identified when inserting the child objects (for example a parentclass ldquoRoadrdquo has an object property called ldquosidewalksrdquo of type ldquoSidewalkrdquo)For more information see Data Maintenance on page 119

Physical Mappings

Each feature provider maps the logical feature schema to an underlyingphysical data store Some feature providers may provide some level of control

86 | Chapter 7 Schema Management

over how the logical schema gets mapped to the underlying physical storageFor example an RDBMS-based feature provider may allow table and columnnames to be specified for classes and properties Since this is entirelyprovider-dependent the FDO API simply provides abstract classes for passingphysical schema and class mappings to the provider(FdoPhysicalSchemaMapping FdoPhysicalClassMappingFdoPhysicalPropertyMapping and FdoPhysicalElementMapping respectively)The implementation of these abstract classes is up to each feature provider

Schema MappingsWhen a provider connects to a data source that it did not create and does adescribe schema command it will map FDO data types to the physical entitescontained in the data source This mapping is called the default schemamapping or alternatively the physical to logical schema mapping

When reverse engineering an existing schema FDO uses the following rulesto select the column(s) to use as the identity property

1 Use the primary key

2 Use a unique index

3 Treat the data as read-only

NOTE When reverse engineering a view FDO will apply rules 1 and 2 to the viewand then if necessary to the base tables

NOTE If FDO detects more than one unique index it calculates a weight for eachindex and selects the lightest one The weight of each index is the sum of theweights of its columns Column weight depends on column type as follows Indexeswith Blobs or Clobs are not chosen If FDO picks a multi-column index as theunique index it creates an identity property for each column in the index

1 for Boolean or Byte

2 for Int16

4 for Int32

8 for Int64 Decimal Double or Float

50 for DateTime

length for String

Schema Mappings | 87

After you use FDO to create a feature schema you can use external means toaccess the data store to inspect what native data types FDO uses for its logicaltypes This mapping is called the logical to physical schema mapping

The following mappings have been documented in the provider appendices

physical to logical schema mappings for ODBC connections to a MicrosoftAccess database an Excel spreadsheet and a text file

physical to logical and logical to physical schema mappings for OracleMySQL Sql Server and Sql Server Spatial

The mechanism for overriding the default schema mapping is described inthe next topic Sample code is located in the FDO Cookbook chapter of thisdocument

Schema OverridesUsing schema overrides FDO applications can customize the mappingsbetween Feature (logical) Schemas and the Physical Schema of the providerdata store

Schema overrides are provider-specific because different FDO providers supportFDO data stores with widely different physical formats Therefore the typesof schema mappings in these overrides also vary between providers Forexample an RDBMS-type provider might provide a mapping to index a set ofcolumns in a class table However other providers would not necessarily beable to work with the concept of an index For information about schemaoverrides support by a specific provider see the appropriate appendix in thisdocument and The Essential FDO

NOTE Some providers support only default schema mappings

Working with SchemasThere are three primary operations involved with schema management

Creating a schema

Describing a schema

Modifying a schema

88 | Chapter 7 Schema Management

Creating a Schema

The following basic steps are required to create a schema (some steps areoptional some may be done in an alternate order to achieve the same result)

Use the FdoFeatureSchemaCreate(ldquoSchemaNamerdquo ldquoFeatureSchemaDescriptionrdquo) method to create a schema

Use the FdoFeatureSchemaGetClasses() method to return a class collection

Use the FdoClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) orFdoFeatureClassCreate(ldquoclassNamerdquo ldquoclassDescriptionrdquo) method to createFdoClass or FdoFeatureClass type objects

Use the FdoClassCollectionAdd(class) method to add FdoClass orFdoFeatureClass objects to the class collection

Use the FdoGeometricPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoGeometryProperty

Use the FdoDataPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo) methodto create FdoDataProperty

Use the FdoObjectPropertyDefinitionCreate(ldquonamerdquo ldquoDescriptionrdquo)method to create FdoObjectProperty

Use the FdoClassDefinitionGetProperties() and Add(property) methodsto add property to class definition

Use the FdoIApplySchemaCommandSetFeatureSchema(feature schema)method to set the schema object for the IFdoApplySchemaCommand

Use the FdoAssociationPropertydefinition class to represent the associationbetween two classes The class of the associated class must already bedefined in the feature schema and cannot be abstract

Use the FdoIApplySchemaCommandExecute() method to execute changesto the feature schema

For an example of schema creation see Example Creating a Feature Schemaon page 111

Use the FdoClassDefinitionGetIdentityProperties() and Add(Property Object)methods to set the property as FdoClass or FdoFeatureClass Identifier FDOallows multiple Identifiers for both types of classes although Identifiers haveslight differences in both cases

Working with Schemas | 89

FDOFeatureClassFdoFeatureClass is a class that defines features In the case of GIS they wouldoften be spatial features having some sort of geometry associated with themIn most providers FdoFeatureClass requires a unique identifier to distinguishthe features

However there are identifiers only if no base class exists If the base class hasan identifier the child class does not have one You cannot set an identifierto the child class Any class definition that has a base class cannot also haveany identity properties because it inherits from the base class

Therefore you cannot send an identifier when a feature class is a child sinceit always inherits the identifier from the base class

FDOClassThis class is used for non-spatial data It can act as a stand-alone class whereit would have no association with any other class or if the FdoClass is beingused as an ObjectProperty it can be used to define properties of some otherFdoClass or FdoFeatureClass

ObjectProperty Types

ObjectProperties have the following types

Value

Collection

OrderedCollection

The Value ObjectProperty type has a relationship of one-to-one providing asingle value for each property

The Collection and OrderedCollection ObjectProperty types have aone-to-many relationship where many ObjectProperties may be associatedwith one property Ordered Collections can be stored in an ascending ordescending order

90 | Chapter 7 Schema Management

At least one Identifier will be required if the FdoClass is to be used as astand-alone Class

All Identifiers for FdoDataType_Int64 must not be Read-Only since noneof these will be an auto-generated property value

If creating multiple Identifiers all Identifiers must be set to NOT NULL

Non-Feature Class IssuesA non-feature class in FDO can be created as a stand-alone class a containedclass or both As a contained class it defines a property of another class orfeature class (see FdoFeatureClass and FdoClassType Global Enum) How thisnon-feature class is created affects the way the data is inserted queried andupdated

Stand-alone Class

This type of class stores non-feature data (for example manufacturers) TheFdoClassType_Class must be created with one or more identity properties (seeFdoObjectPropertyDefinition) which is required in order that the class has aphysical container (that is a table in the RDBMS) associated with it If theclass is created without specifying an IdentityProperty only the definition isstored in the metadata which prevents any direct data inserts

Contained Class

This type of class stores non-feature data that defines a property of anotherclass or feature class (for example Sidewalk could be a property of a Roadfeature class the Sidewalk class defines the RoadSidewalk property) In thiscase the FdoClassType_Class does not need to be created with one or moreidentity properties although it can be

Class With IdentityProperty Used as ObjectProperty

This type of class reacts like a stand-alone class however with this type it ispossible to do direct data inserts It can also be populated through a containerclass (for example RoadSidewalk) since it defines an object property (seeFdoObjectPropertyDefinition) If this class is queried directly only the datainserted into the class as a stand-alone is returned The data associated withthe ObjectProperty can only be queried through the container class (forexample RoadSidewalk)

Non-Feature Class Issues | 91

Class Without a Defined IdentityProperty Used as ObjectProperty

Because this class has no defined IdentityProperty it can only be populatedthrough the container class (for example RoadSidewalk) since it definesObjectProperty This class cannot be queried directly The data associated withthe object property can only be queried through the container class (forexample RoadSidewalk) As an object property it is defined as one of thefollowing

Value type property Does not need any identifier since it has a one-to-onerelationship with the container class

Collection type property Requires a local identifier which is an identifierdefined when creating the ObjectProperty object

Ordered Collection type property Requires a local identifier which is anidentifier defined when creating the ObjectProperty object

When defining either a Collection or Ordered Collection type ObjectPropertyyou must set an IdentityProperty attribute for that object property ThisObjectClassIdentityProperty acts only as a local identifier compared to theIdentityProperty set at the class level As a local identifier it acts to uniquelyidentify each item within each collection (for example if the local identifierfor RoadSidewalk is Side there can be multiple sidewalks with Side=rdquoLeftrdquobut only one per Road)

Describing a Schema

Use the FdoIDescribeSchemaExecute function to retrieve anFdoFeatureSchemaCollection in order to obtain any information about existingschema(s) The FdoFeatureSchemaCollection consists of all FdoFeatureSchemasin the data store and can be used to obtain information about any schemaobject including FdoFeatureSchema FdoClass FdoFeatureClass and theirrespective properties The following functions return the main collectionsrequired to obtain information about all schema objects

FdoFeatureSchemaGetClasses method obtains FdoClass andFdoFeatureClasses

FdoClassDefinitionGetProperties method obtains aFdoPropertyDefinitionCollection

FdoClassDefinitionGetBaseProperties method obtains aFdoPropertyDefinitionCollection of the properties inherited from the baseclasses

92 | Chapter 7 Schema Management

NOTE Even if your schema has no base classes (inheritance) all classes will inheritsome properties from system classes

Use these functions throughout the application to obtain any informationabout schema objects For example in order to insert data into a class youmust use these functions to determine what data type is required Descriptionof the data is separate from actions

The example in the following link is a simple function that shows how to useFdoIDescribeSchema and loop through the schema and class containers tosearch for duplicate class names It searches all schemas to ensure that theclass name does not exist in any schema in the data store Class names mustbe unique across the entire FDO database

For a schema description example see Example Describing a Schema andWriting It to an XML File on page 114 NO LABEL

FDO Schema Element Class Diagram

Non-Feature Class Issues | 93

Modifying ModelsAdd schema elements to a model by inserting them into the appropriatecollection

Elements are removed from the model by using either of the followingmethods

Call the FdoSchemaElementDelete() method This flags the element fordeletion when the changes are accepted (generally throughFdoIApplySchema) but the element remains a member of all collectionsuntil that time

Remove the element from the appropriate collection via theFdoSchemaCollectionRemove() or FdoSchemaCollectionRemoveAt()methods This immediately disassociates the element from the collection

Schema Element StatesAll elements within the model maintain a state flag This flag can be retrievedby calling FdoSchemaElementGetElementState() but it cannot be directlyset Instead its state changes in reaction to the changes made to the model

Unchanged When a schema model is retrieved via FdoIDescribeSchemaall elements are initially marked Unchanged

Detached Removing an element from an owning collection sets its stateto Detached

Deleted Calling the Delete() method on an element sets its state to Deleted

Added Placing an element within a collection marks the element as Added

Modified When adding or removing a sub-element such as a propertyelement from a class the class element state will be changed to Modified

Additionally when an element that is contained by another element is changedin any way the containing element is also marked as Modified So for exampleif a new value is added to the SchemaAttributeDictionary of the ldquoClass3rdquoelement in our model both the ldquoClass3rdquo FdoClass object and theFdoFeatureSchema object would be marked as Modified

94 | Chapter 7 Schema Management

The state flags are maintained until the changes are accepted that is whenIApplySchema is executed At that time all elements marked Deleted arereleased and all other elements are set to Unchanged

NOTE When you remove an element from an owning collection its state is markedas Detached All collections currently in FDO are owning collections except forone the collections FdoClassDefinitionGetIdentityProperties()

Rollback MechanismThe FdoFeatureSchema contains a mechanism that allows you to ldquoroll backrdquomodel changes to the last accepted state For example a model retrieved viaFdoIDescribeSchema can have classes added attributes deleted or names anddefault values changed All of these changes are thrown out and the modelreturned to its unmodified state by calling FdoFeatureSchemaRejectChanges()

The converse of this operation is the FdoFeatureSchemaAcceptChanges()method which removes all of the elements with a status of Deleted and setsthe state flag of all other elements to Unchanged Generally this method isonly invoked by FDO provider code after it has processed anFdoIApplySchemaExecute() command Normal FDO clients should not callthis method directly

FDO XML FormatFDO feature schemas can be written to an XML file The FdoFeatureSchemaand FdoFeatureSchemaCollection classes support the FdoXmlSerializableinterface The sample code shows an FdoFeatureSchema object calling theWriteXml() method to generate an XML file containing the feature schemacreated by the sample code

FDO feature schemas can also be read from an XML file TheFdoFeatureSchemaCollection class supports the FdoXmlDeserializable interfaceThe sample code shows an FdoFeatureSchemaCollection object calling theReadXml() method to read a set of feature schemas into memory from an XMLfile The code shows the desired schema being retrieved from the collectionand applied to the data store

The XML format used by FDO is a subset of the Geography Markup Language(GML) standardized by the Open GIS Consortium (OGC) One thing shownin the sample code is a round-trip conversion from FDO feature schema toGML schema back to FDO feature schema To accomplish this round-trip the

Rollback Mechanism | 95

ReadXml() method supports a superset of the GML that is written by theWriteXml() method

The following table specifies the mapping of FDO feature schema elementsto GML elements and attributes This mapping is sufficient to understand theXML file generated from the schema defined by the sample code It alsoprovides a guide for writing a GML schema file by hand This file can then beread in and applied to a data store For more information see ExampleCreating a Schema Read In from an XML File on page 114

Another form of round-trip translation would be from a GML schema producedby another vendorrsquos tool to an FDO feature schema and then back to a GMLschema However the resemblance the of resulting GML schema to the originalGML schema might vary from only roughly equivalent to being exactly thesame

Map FDO Element to GML Schema Fragment

GML Schema FragmentFDO Element

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaN

amegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgisdschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFea

tureSchemaNamegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

see ltMetaDatagt

optional xsimport element to enable schema validation

ltxsimport namespace=httpfdoosgeoorgschema

schemaLocation=ltFDO SDK Install LocationgtdocsXmlS

chemaFdoDocumentxsdgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

FeatureSchema

96 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxsfield xpath=rdquordquogt

ltxsfield xpath=rdquoltidentityPropertyltngtNamegtrdquo

ltxskeygt

ltxselementgt

ClassDefinition(with identity prop-erties)

ltxselement see ClassDefinition (with identity proper

ties)ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

see FeatureClassGeometryProperty

gt

see ltMetaDatagt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

gt

ltxssequencegt

list of properties see DataProperty Geometric

Property

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

FeatureClass

FDO XML Format | 97

GML Schema FragmentFDO Element

lt-- these attributes belong to the xscomplexType element

--gt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

FeatureClass Geo-metryProperty

lt--

minOccurs attribute generated only if value is 1

default attribute generated only if a default value exists

fdoreadOnly attribute generated only if value is true

--gt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxssimpleTypegt

see DataType String or DataType Decimal

ltxssimpleTypegt

ltxselementgt

DataProperty(decimal or string)

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

see ltMetaDatagt

ltxselementgt

DataProperty (oth-er type)

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

DataType String

98 | Chapter 7 Schema Management

GML Schema FragmentFDO Element

ltxsrestriction base=rdquoxsdecimalrdquogt

ltxstotalDigits value=rdquoltprecisiongtrdquogt

ltxsfractionDigits value=rdquoltscalegtrdquogt

ltxsrestrictiongt

DataType Decimal

ltxselement name=rdquoltpropertyNamegtrdquo

type=rdquogmlAbstractGeometryTyperdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

see ltMetaDatagt

ltxselementgt

GeometricProperty(not a defining Fea-tureClass Geo-metryProperty)

FDO XML Format | 99

GML Schema FragmentFDO Element

lt-- the pattern referenced in the xsschema element for

FeatureSchema--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeatureS

chemaCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xselement element for

DataProperty --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoDataProp

ertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt--

the pattern referenced in the xselement element for a

non-feature-defining

GeometricProperty

--gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

lt-- the pattern referenced in the xscomplexType element

for FeatureClass --gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static FdoFeature

ClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static FdoGeomet

ricPropertyDefinitionCreate()ltxsdocumentationgt

ltxsannotationgt

MetaData

Map FDO Datatype to GML Type

GML TypeFDO Datatype

xsbooleanBoolean

fdoByteByte

xsdateTimeDateTime

100 | Chapter 7 Schema Management

GML TypeFDO Datatype

xsdoubleDouble

fdoInt16Int16

fdoInt32Int32

fdoInt64Int64

xsfloatSingle

xsbase64BinaryBLOB

xsstringCLOB

Creating and Editing a GML Schema FileThe sample in this section illustrates the creation of a GML schema filecontaining the definition of an FDO feature schema that contains one featureThe name of this file will have the standard XML schema extension namexsd This means that it contains only one schema and that the root elementis xsschema The ReadXml() method will take a filename argument whoseextension is either xsd or xml In the latter case the file could contain manyschema definitions If it does each schema is contained in an xsschemaelement and all xsschema elements are contained in the fdoDataStoreelement If there is only one schema in the xml file then the fdoDataStoreelement is not used and the root element is xsschema

You may want to validate the schema that you create To do so you mustinclude the optional xsimport line specified in the GML schema fragmentfor FeatureSchema

The sample feature implements a table definition for the Buildings feature inthe Open GIS Consortium document 98-046r1 This table definition isexpressed in an XML format on page 14 of the document and is reproducedas follows

Creating and Editing a GML Schema File | 101

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtbuildingsltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtaddressltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtpositionltnamegt

lttypegtPOINTlttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtfootprintltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

Add GML for the FDO Feature Schema

Start with the skeleton GML for an FDO Feature Schema with the ltMetaDatagtreference replaced by the valid pattern

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpltcustomer_urlgtltFeatureSchemaNamegtrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsltFeatureSchemaNamegt=rdquohttpltcustomer_urlgtltFeatureSchema

Namegtrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgt

description arg to static FdoFeatureSchemaCreate()

ltxsdocumentationgt

ltxsannotationgt

ltone xselement andor xscomplexType per classgt

ltxsschemagt

102 | Chapter 7 Schema Management

For ltcustomer_urlgt substitute ldquofdo_customerrdquo For ltFeatureSchemaNamegtsubstitute ldquoOGC980461FSrdquo and for description arg substitute ldquoOGCSimple Features Specification for SQLrdquo

Add GML for an FDO Feature Class

Start with the GML that is already written and add the skeleton for an FDOFeature Class which includes the skeleton for a class definition with identityproperties The ltMetaDatagt is replaced with the valid pattern

Creating and Editing a GML Schema File | 103

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquoltclassNamegtrdquo

type=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquoltclassNamegtKeyrdquogt

ltxsselector xpath=rdquoltclassNamegtrdquogt

ltxsfield xpath=rdquoltidentityProperty1Namegtrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquoltclassNamegtTyperdquo

abstract=rdquolttrue | falsegtrdquogt

fdogeometryName=rdquoltgeometryPropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoFeatureClassCreate()ltxsdocumentationgt

ltxsappinfo source=rdquolturigtrdquogt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquobaseClass

baseClassschemanamebaseClassname

lsquogmlAbstractFeatureTypersquo ldquo

104 | Chapter 7 Schema Management

gt

ltxssequencegt

list of properties see DataProperty GeometricProperty

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For ltclassNamegt substitute ldquobuildingsrdquo

Set the value of the xselement abstract attribute to false

For ltidentityPropertyNamegt substitute ldquofidrdquo A data property whose nameis ldquofidrdquo will be added

Set the value of the xscomplexType abstract attribute to false

For ltgeometryPropertyNamegt substitute ldquofootprintrdquo

For ltlist of FdoGeometricTypesgt substitute ldquosurfacerdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoFeatureClassCreate() substitute ldquoOGC 98-046r1buildingsrdquo

For lturigt substitute ldquohttpfdoosgeoorgschemardquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoa polygon defines a building perimeterrdquo

This class has no base class so set the value of the xsextension base attributeto lsquogmlAbstractFeatureTypersquo

Add GML for Property Definitions

An integer data property whose name is ldquofidrdquo will be added This property isalready identified as an identity property in the xskey element A string dataproperty whose name is ldquonamerdquo and a geometry property whose name isldquopositionrdquo will also be added

Creating and Editing a GML Schema File | 105

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquoalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquoltpropertyNamegtrdquo

106 | Chapter 7 Schema Management

type=rdquoltdatatypegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

minOccurs=rdquoisNullable 0 1rdquo

default=rdquoltdefaultValuegtrdquo

fdoreadOnly=rdquolttrue | falsegtrdquo

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoDataPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquoltlengthgtrdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquoltpropertyNamegtrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquoltpropertyNamegtrdquo

fdogeometricTypes=rdquoltlist of FdoGeometricTypesgtrdquo

fdogeometryReadOnly=rdquolttrue | falsegtrdquo

fdohasMeasure=rdquolttrue | falsegtrdquo

fdohasElevation=rdquolttrue | falsegtrdquo

fdosrsName=rdquoltspatialContextNamegtrdquogt

gt

ltxsannotationgt

ltxsdocumentationgtdescription arg to static

FdoGeometricPropertyDefinitionCreate()

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

Creating and Editing a GML Schema File | 107

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

You can make the following changes

For the first data property ltpropertyNamegt substitute ldquofidrdquo

For the first data property ltdataTypegt substitute ldquofdoint32rdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquofidrdquo to false

Set the content for xsdocumentation for ldquofidrdquo to ldquofeature idrdquo

For the second data property ltpropertyNamegt substitute ldquoaddressrdquo

Do not include the minOccurs or default attributes because the value ofminOccurs is 0 which is the default and there is no ltdefaultValuegt

Set the fdoreadOnly attribute for ldquonamerdquo to false

Set the content for xsdocumentation for ldquoaddressrdquo to ldquoaddress of thebuildingrdquo

For ltlengthgt substitute ldquo64rdquo

For the geometry property ltpropertyNamegt substitute ldquopositionrdquo

For ltlist of FdoGeometricTypesgt substitute ldquopointrdquo

Set the values of fdogeometryReadOnly fdohasMeasure andfdohasElevation to false

For ltspatialContextNamegt substitute ldquoSC_0rdquo

For description arg to FdoGeometricPropertyDefinitionCreate() substituteldquoposition of the buildingrdquo

The Final Result

After all the required substitutions the GML for the schema containing theBuildings feature is as follows

108 | Chapter 7 Schema Management

ltxsschema xmlnsxs=rdquohttpwwww3org2001XMLSchemardquo

targetNamespace=rdquohttpfdo_customerOGC980461FSrdquo

xmlnsfdo=rdquohttpfdoosgeoorgschemardquo

xmlnsgml=rdquohttpwwwopengisnetgmlrdquo

xmlnsOGC980461FS=rdquohttpfdo_customerOGC980461FSrdquo

elementFormDefault=rdquoqualifiedrdquo

attributeFormDefault=rdquounqualifiedrdquo

gt

ltxsannotationgt

ltxsdocumentationgtOGC Simple Features Specification for

SQLltxsdocumentationgt

ltxsannotationgt

ltxselement name=rdquobuildingsrdquo

type=rdquobuildingsTyperdquo

abstract=rdquofalserdquo

substitutionGroup=rdquogml_Featurerdquo

gt

ltxskey name=rdquobuildingsKeyrdquogt

ltxsselector xpath=rdquobuildingsrdquogt

ltxsfield xpath=rdquofidrdquogt

ltxskeygt

ltxselementgt

ltxscomplexType name=rdquobuildingsTyperdquo

abstract=rdquofalserdquogt

fdogeometryName=rdquofootprintrdquo

fdogeometricTypes=rdquosurfacerdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtOGC 98-046r1 buildings

ltxsdocumentationgt

ltxsappinfo source=rdquohttpfdoosgeoorgschemardquogt

ltxsdocumentationgta polygon defines the perimeter of a

buildingltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=rdquogmlAbstractFeatureTypeldquo

gt

ltxssequencegt

ltxselement name=rdquofidrdquo

Creating and Editing a GML Schema File | 109

type=rdquofdoint32rdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtfeature id

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=rdquoaddressrdquo

fdoreadOnly=rdquofalserdquo

gt

ltxsannotationgt

ltxsdocumentationgtaddress of the building

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=rdquoxsstringrdquogt

ltxsmaxLength value=rdquo64rdquogt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxselement name=rdquopositionrdquo

ref=rdquogml_Geometryrdquo

fdogeometryName=rdquopositionrdquo

fdogeometricTypes=rdquopointrdquo

fdogeometryReadOnly=rdquofalserdquo

fdohasMeasure=rdquofalserdquo

fdohasElevation=rdquofalserdquo

fdosrsName=rdquoSC_0rdquogt

gt

ltxsannotationgt

ltxsdocumentationgtposition of the buildingltxsdocu

mentationgt

ltxsannotationgt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

110 | Chapter 7 Schema Management

Schema Management ExamplesExample Creating a Feature Schema

The following sample code creates an FdoFeatureSchema object calledldquoSampleFeatureSchemardquo The schema contains one class which has threeproperties The class and its properties conform to the table definition for theLakes feature in the Open GIS Consortium document 98-046r1 This tabledefinition is expressed in an XML format on page 10 of the document and isreproduced as follows

ltogc-sfsql-tablegt

lttable-definitiongt

ltnamegtlakesltnamegt

ltcolumn-definitiongt

ltnamegtfidltnamegt

lttypegtINTEGERlttypegt

ltconstgraintgtNOT NULLltconstraintgt

ltconstraintgtPRIMARY KEYltconstraintgt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtnameltnamegt

lttypegtVARCHAR(64)lttypegt

ltcolumn-definitiongt

ltcolumn-definitiongt

ltnamegtshoreltnamegt

lttypegtPOLYGONlttypegt

ltcolumn-definitiongt

lttable-definitiongt

The table definition whose name is ldquolakesrdquo is mapped to an FdoFeatureClassobject called ldquoSampleFeatureClassrdquo The column definition whose name isldquofidrdquo is mapped to an FdoDataPropertyDefinition object calledldquoSampleIdentityDataPropertyrdquo The column definition whose name is ldquonamerdquois mapped to an FdoDataPropertyDefinition object calledldquoSampleNameDataPropertyrdquo The column definition whose name is ldquoshorerdquois mapped to an FdoGeometricPropertyDefinition object calledldquoSampleGeometricPropertyrdquo

Schema Management Examples | 111

Create the ApplySchema command

FdoPtrltFdoIApplySchemagt sampleApplySchema

sampleApplySchema = (FdoIApplySchema )

connection-gtCreateCommand(FdoCommandType_ApplySchema)

Create the feature schema

FdoPtrltFdoFeatureSchemagt sampleFeatureSchema

sampleFeatureSchema = FdoFeatureSchemaCreate(LSampleFeatureS

chema LSample Feature Schema Description)

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

create a feature class ie a class containing a geometric

property set some class level properties

FdoPtrltFdoFeatureClassgt sampleFeatureClass

sampleFeatureClass = FdoFeatureClassCreate(LSampleFeatureClass

LSample Feature Class Description)

sampleFeatureClass-gtSetIsAbstract(false)

get a pointer to the feature classs property collection

this pointer is used to add data and other properties to the

class

FdoPtrltFdoPropertyDefinitionCollectiongt sampleFeatureClassProper

ties

sampleFeatureClassProperties = sampleFeatureClass-gtGetProperties()

get a pointer to the feature schemas class collection

this object is used to add classes to the schema

FdoPtrltFdoClassCollectiongt sampleClassCollection

sampleClassCollection = sampleFeatureSchema-gtGetClasses()

get a pointer to the feature classs identity property collec

tion

this property is used to add identity properties to the feature

class

FdoPtrltFdoDataPropertyDefinitionCollectiongt sampleFeatureClassId

entityProperties

sampleFeatureClassIdentityProperties = sampleFeatureClass-

gtGetIdentityProperties()

create a data property that is of type Int32 and identifies

the feature uniquely

FdoPtrltFdoDataPropertyDefinitiongt sampleIdentityDataProperty

sampleIdentityDataProperty = FdoDataPropertyDefinitionCre

ate(LSampleIdentityDataProperty LSample Identity Data Property

Description)

sampleIdentityDataProperty-gtSetDataType(FdoDataType_Int32)

112 | Chapter 7 Schema Management

sampleIdentityDataProperty-gtSetReadOnly(false)

sampleIdentityDataProperty-gtSetNullable(false)

sampleIdentityDataProperty-gtSetIsAutoGenerated(false)

add the identity property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleIdentityDataProperty)

sampleFeatureClassIdentityProperties-gtAdd(sampleIdentityDataProp

erty)

create a data property that is of type String and names the

feature

FdoPtrltFdoDataPropertyDefinitiongt sampleNameDataProperty

sampleNameDataProperty = FdoDataPropertyDefinitionCreate(LSam

pleNameDataProperty LSample Name Data Property Description)

sampleNameDataProperty-gtSetDataType(FdoDataType_String)

sampleNameDataProperty-gtSetLength(64)

sampleNameDataProperty-gtSetReadOnly(false)

sampleNameDataProperty-gtSetNullable(false)

sampleNameDataProperty-gtSetIsAutoGenerated(false)

add the name property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleNameDataProperty)

create a geometric property

FdoPtrltFdoGeometricPropertyDefinitiongt sampleGeometricProperty

sampleGeometricProperty = FdoGeometricPropertyDefinitionCre

ate(LSampleGeometricProperty LSample Geometric Property Descrip

tion)

sampleGeometricProperty-gtSetGeometryTypes(FdoGeometricType_Sur

face)

sampleGeometricProperty-gtSetReadOnly(false)

sampleGeometricProperty-gtSetHasMeasure(false)

sampleGeometricProperty-gtSetHasElevation(false)

add the geometric property to the sampleFeatureClass

sampleFeatureClassProperties-gtAdd(sampleGeometricProperty)

identify it as a geometry property

sampleFeatureClass-gtSetGeometryProperty(sampleGeometricProperty)

add the feature class to the schema

sampleClassCollection-gtAdd(sampleFeatureClass)

point the ApplySchema command at the newly created feature

schema and execute

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

Schema Management Examples | 113

Example Describing a Schema and Writing It to an XML File

The following sample code demonstrates describing a schema and writing itto an XML file

create the DescribeSchema command

FdoPtrltFdoIDescribeSchemagt sampleDescribeSchema

sampleDescribeSchema = (FdoIDescribeSchema )

connection-gtCreateCommand(FdoCommandType_DescribeSchema)

executing the DescribeSchema command returns a feature

schema collection that is the set of feature schema which

reside in the DataStore

FdoPtrltFdoFeatureSchemaCollectiongt sampleFeatureSchemaCollection

sampleFeatureSchemaCollection = sampleDescribeSchema-gtExecute()

find the target feature schema in the collection write it

to an xml file and clear the collection

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleFeatureSchema-gtWriteXml(LSampleFeatureSchemaxml)

sampleFeatureSchemaCollection-gtClear()

Example Destroying a Schema

The following sample code demonstrates destroying a schema

create the DestroySchema command

FdoPtrltFdoIDestroySchemagt sampleDestroySchema

sampleDestroySchema = (FdoIDestroySchema )

connection-gtCreateCommand(FdoCommandType_DestroySchema)

destroy the schema

sampleDestroySchema-gtSetSchemaName(LSampleFeatureSchema)

sampleDestroySchema-gtExecute()

Example Creating a Schema Read In from an XML File

The following sample code demonstrates creating a schema read in from anXML file

sampleFeatureSchemaCollection-gtReadXml(LSampleFeatureSchemaxml)

sampleFeatureSchema = sampleFeatureSchemaCollection-gtFind

Item(LSampleFeatureSchema)

sampleApplySchema-gtSetFeatureSchema(sampleFeatureSchema)

sampleApplySchema-gtExecute()

sampleFeatureSchemaCollection-gtClear()

114 | Chapter 7 Schema Management

SampleFeatureSchemaxml

The following sample XML schema is the contents of the file written out bythe WriteXml method belonging to the FdoFeatureSchema class object thatwas created in the preceding sample code

Schema Management Examples | 115

ltxml version=10 encoding=UTF-8 gt

ltxsschema xmlnsxs=httpwwww3org2001XMLSchema

targetNamespace=httpfdo_customerSampleFeatureSchema

xmlnsfdo=httpfdoosgeoorgschema

xmlnsgml=httpwwwopengisnetgml

xmlnsSampleFeatureSchema=httpfdo_customer

SampleFeatureSchema

elementFormDefault=qualified

attributeFormDefault=unqualifiedgt

ltxsannotationgt

ltxsdocumentationgtSample Feature Schema Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsannotationgt

ltxselement name=SampleFeatureClass

type=SampleFeatureSchemaSampleFeatureClassType

abstract=false substitutionGroup=gml_Featuregt

ltxskey name=SampleFeatureClassKeygt

ltxsselector xpath=SampleFeatureClass gt

ltxsfield xpath=SampleIdentityDataProperty gt

ltxskeygt

ltxselementgt

ltxscomplexType name=SampleFeatureClassType

abstract=false

fdogeometryName=SampleGeometricProperty

fdohasMeasure=false

fdohasElevation=false

fdosrsName=SC_0

fdogeometricTypes=surfacegt

ltxsannotationgt

ltxsdocumentationgtSample Feature Class Description

ltxsdocumentationgt

ltxsappinfo source=httpfdoosgeoorgschema gt

ltxsdocumentationgtSample Geometric Property Descrip

tionltxsdocumentationgt

ltxsannotationgt

ltxscomplexContentgt

ltxsextension base=gmlAbstractFeatureTypegt

ltxssequencegt

ltxselement name=SampleIdentityDataProperty

default=

type=fdoint32gt

ltxsannotationgt

116 | Chapter 7 Schema Management

ltxsdocumentationgt

Sample Identity Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxselementgt

ltxselement name=SampleNameDataProperty

default=gt

ltxsannotationgt

ltxsdocumentationgt

Sample Name Data Property Description

ltxsdocumentationgt

ltxsannotationgt

ltxssimpleTypegt

ltxsrestriction base=xsstringgt

ltxsmaxLength value=64 gt

ltxsrestrictiongt

ltxssimpleTypegt

ltxselementgt

ltxssequencegt

ltxsextensiongt

ltxscomplexContentgt

ltxscomplexTypegt

ltxsschemagt

Schema Management Examples | 117

118

Data Maintenance

This chapter provides information about using the FDO API to maintain data

Data Maintenance OperationsThe primary operations associated with data maintenance are

Inserting

Updating

Deleting

Transactions

Locking

NOTE Discussion of Transactions and Locking is deferred to a future release of thisdocument

Inserting Values

Preconditions

In a previous chapter we created a feature schema and added a feature class toit The feature class had three properties an integer data property a string dataproperty and a geometric property We applied this feature schema to the datastore We are now ready to create feature data objects which are instances ofthe feature class and insert them into the data store

8

119

Property Values in General

We can now create feature data objects which are instances of the featureclass by defining a set of property values corresponding to the propertiesdefined for the class and then inserting them into the data store

An FDO class correspondends roughly to a table definition in a relationaldatabase and a property of a class corresponds roughly to a column definitionin a table Adding the property values corresponds roughly to adding a rowin the table

The main distinction between a data value or geometry value and a propertyvalue is the order in which they are created A data value or geometry valueobject is created first and is then used to create a property value object Theproperty value object is then added to the value collection object belongingto the Insert command object Then the command is executed

An insert operation consists of the following steps

1 Create the insert command object (type FdoIInsert) this object can bereused for multiple insert operations

2 Point the insert command object at the feature class to which you areadding values (call the SetFeatureClassName(ltclassNamegt) method)

3 From the insert command object obtain a pointer using theGetPropertyValues() method to a value collection object (typeFdoPropertyValueCollection) You will add property values to the insertcommand object by adding values to the collection object

4 Create a data value (type FdoDataValue) or geometry value (typeFdoGeometryValue) object Creating the data value is straightforwardyou pass the string or integer value to a static Create() method Creatingthe geometry value is described in Geometry Property Values on page 121

5 Create a property value (type FdoPropertyValue) object which involvespassing the data value or geometry value object as an argument to a staticCreate() method

6 Add the property value object to the value collection object

7 Execute the Insert command

Data Property Values

A data value object contains data whose type is one of the following

Boolean

120 | Chapter 8 Data Maintenance

Byte

DateTime

Decimal

Double

Int16

Int32

Int64

Single (another floating point type)

String

Binary large object (BLOB)

Character large object (CLOB)

The data value object is added to the data property value object The dataproperty value object is added to the property value collection belonging tothe Insert command

Geometry Property Values

A geometry property value object contains a geometry in the form of a bytearray A geometry can be relatively simple for example a point (a single pairof ordinates) or quite complex for example a polygon (one or more arraysof ordinates) In the latter case a number of geometry objects are created andthen combined together to form the target geometry Finally the targetgeometry is converted to a byte array and incorporated into the geometryproperty value object

Creating a geometry value object consists of the following steps

1 Create a geometry value object (type FdoGeometryValue) using a staticCreate() method

2 Create a geometry factory object (type FdoAgfGeometryFactory) using astatic GetInstance() method This object is used to create the geometryobject or objects which comprise the target geometry

3 Create the required geometry object or objects using the appropriateCreateltgeometrygt method() belonging to the geometry factory object

Inserting Values | 121

4 Use the geometry factory object to convert the target geometry object toa byte array

5 Incorporate the byte array into the geometry property value object

Example Inserting an Integer a String and a Geometry Value

The following sample code shows how to insert an integer a string and ageometry value

122 | Chapter 8 Data Maintenance

create the insert command

FdoPtrltFdoIInsertgt sampleInsert

sampleInsert = (FdoIInsert )

connection-gtCreateCommand(FdoCommandType_Insert)

index returned by the operation which adds a value to the value

collection

FdoInt32 valueCollectionIndex = 0

point the Insert command to the target class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleInsert-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

get the pointer to the value collection used to add properties

to the Insert command

FdoPtrltFdoPropertyValueCollectiongt samplePropertyValues

samplePropertyValues = sampleInsert-gtGetPropertyValues()

create an FdoDataValue for the identity property value

FdoPtrltFdoDataValuegt sampleIdentityDataValue

sampleIdentityDataValue = FdoDataValueCreate(101)

add the FdoDataValue to the identity property value

FdoPtrltFdoPropertyValuegt sampleIdentityPropertyValue

sampleIdentityPropertyValue =

FdoPropertyValueCreate(LSampleIdentityDataProperty

sampleIdentityDataValue)

add the identity property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleIdentityPropertyValue)

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LBlue Lake)

add the FdoDataValue to the name property value

FdoPtrltFdoPropertyValuegt sampleNamePropertyValue

sampleNamePropertyValue =

FdoPropertyValueCreate(LSampleNameDataProperty

sampleNameDataValue)

add the name property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleNamePropertyValue)

create an FdoGeometryValue for the geometry property value

this polygon represents a lake which has an island

the outer shoreline of the lake is defined as a linear ring

the shoreline of the island is defined as a linear ring

the outer shoreline is the external boundary of the polygon

Inserting Values | 123

the island shoreline is an internal linear ring

a polygon geometry can have zero or more internal rings

FdoPtrltFdoGeometryValuegt sampleGeometryValue

sampleGeometryValue = FdoGeometryValueCreate()

create an instance of a geometry factory used to create the

geometry objects

FdoPtrltFdoFgfGeometryFactorygt sampleGeometryFactory

sampleGeometryFactory = FdoFgfGeometryFactoryGetInstance()

define the external boundary of the polygon the shoreline of

Blue Lake

FdoPtrltFdoILinearRinggt exteriorRingBlueLake

FdoInt32 numBlueLakeShorelineOrdinates = 10

double blueLakeExteriorRingOrdinates[] = 520 180 660 230

730 90 480 60 520 180

exteriorRingBlueLake = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numBlueLakeShorelineOrdinates

blueLakeExteriorRingOrdinates)

define the shoreline of Goose Island which is on Blue Lake

this is the sole member of the list of interior rings

FdoPtrltFdoILinearRinggt linearRingGooseIsland

FdoInt32 numGooseIslandShorelineOrdinates = 10

double gooseIslandLinearRingOrdinates[] = 590 180 670 180

670 130 590 130 590 180

linearRingGooseIsland = sampleGeometryFactory-gtCreateLinearRing(

FdoDimensionality_XY numGooseIslandShorelineOrdinates

gooseIslandLinearRingOrdinates)

add the Goose Island linear ring to the list of interior rings

FdoPtrltFdoLinearRingCollectiongt interiorRingsBlueLake

interiorRingsBlueLake = FdoLinearRingCollectionCreate()

interiorRingsBlueLake-gtAdd(linearRingGooseIsland)

create the Blue Lake polygon

FdoPtrltFdoIPolygongt blueLake

blueLake =

sampleGeometryFactory-gtCreatePolygon(exteriorRingBlueLake

interiorRingsBlueLake)

convert the Blue Lake polygon into a byte array

and set the geometry value to this byte array

FdoByteArray geometryByteArray =

sampleGeometryFactory-gtGetAgf(blueLake)

sampleGeometryValue-gtSetGeometry(geometryByteArray)

add the Blue Lake FdoGeometryValue to the geometry property

value

FdoPtrltFdoPropertyValuegt sampleGeometryPropertyValue

124 | Chapter 8 Data Maintenance

sampleGeometryPropertyValue =

FdoPropertyValueCreate(LSampleGeometryProperty

sampleGeometryValue)

add the geometry property value to the value collection

valueCollectionIndex =

samplePropertyValues-gtAdd(sampleGeometryPropertyValue)

do the insertion

the command returns an FdoIFeatureReader

FdoPtrltFdoIFeatureReader sampleFeatureReader

sampleFeatureReader = sampleInsert-gtExecute()

Updating Values

After inserting (see Inserting Values on page 119) you can update the valuesThe update operation involves identifying a feature class (ldquotablerdquo) a featureclass object (ldquorowrdquo) and an object property (ldquocolumn in a rowrdquo) to be changedand supplying a new value for the object property to replace the old

First create an FdoIUpdate command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class object whose properties we want to updateand use the command objectrsquos SetFilter() method to attach the command toit Filters are discussed in Filter and Expression Languages on page 139

One of the data properties in the example SampleFeatureClass class definitionis an identity property whose name is ldquoSampleIdentityDataPropertyrdquo andwhose type is fdoInt32 This means that its value uniquely identifies thefeature class object that is the ldquorowrdquo Use the name of the identity propertyin the filter In the Insert operation the value of the identity property was setto be lsquo101rsquo The value of the filter that is needed is ldquo(SampleIdentityDataProperty = 101 )rdquo

Finally create a property value which contains the new value attach it tothe command object and then execute the command

Example Updating Property Values

The following is an example of updating property values

Updating Values | 125

FdoPtrltFdoIUpdategt sampleUpdate

sampleUpdate =

(FdoIUpdate )connection-gtCreateCommand(FdoCommandType_Update)

FdoInt32 numUpdated = 0

point the Update command at the target feature class

use a fully qualified class name

whose format is ltschemaNamegtltclassNamegt

sampleUpdate-gt SetFeatureClassName(LSampleFeatureSchemaSampleFea

tureClass)

set the filter to identify which set of properties to update

sampleUpdate-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

get the pointer to the value collection used to add properties

to the Update command

we are reusing the samplePropertyValues object that we used

for the insert operation

samplePropertyValues = sampleUpdate-gtGetPropertyValues()

create an FdoDataValue for the name property value

FdoPtrltFdoDataValuegt sampleNameDataValue

sampleNameDataValue = FdoDataValueCreate(LGreen Lake)

set the name and value of the property value

sampleNamePropertyValue-gtSetName(LSampleNameDataProperty)

sampleNamePropertyValue-gtSetValue(sampleNameDataValue)

add the name property value to the property value collection

owned by the Update command

samplePropertyValues-gtAdd(sampleNamePropertyValue)

execute the command

numUpdated = sampleUpdate-gtExecute()

Deleting Values

In addition to inserting (see Inserting Values on page 119) and updating (seeUpdating Values on page 125) values you can delete the values The deletionoperation involves identifying a feature class (ldquotablerdquo) whose feature classobjects (ldquorowsrdquo) are to be deleted

First create an FdoIDelete command object and use the command objectrsquosSetFeatureClassName() method to identify the feature class Then create afilter to identity the feature class objects that you want to delete and use thecommand objectrsquos SetFilter() method to attach the filter to it You can use thesame filter that was specified in the preceding section Updating Values onpage 125 Finally execute the command

126 | Chapter 8 Data Maintenance

Example Deleting Property Values

FdoPtrltFdoIDeletegt sampleDelete

sampleDelete =

(FdoIDelete )connection-gtCreateCommand(FdoCommandType_Delete)

FdoInt32 numDeleted = 0

sampleDelete-gt

SetFeatureClassName(LSampleFeatureSchemaSampleFeatureClass)

sampleDelete-gtSetFilter(L( SampleIdentityDataProperty = 101 ))

numDeleted = sampleDelete-gtExecute()

Related Class TopicsThe following classes are used in the preceding Data Maintenance examples

FdoIInsert

FdoPropertyValueCollection

FdoDataValue

FdoPropertyValue

FdoGeometryValue

FdoFgfGeometryFactory

FdoILinearRing

FdoLinearRingCollection

FdoIPolygon

FdoByteArray

FdoIDelete

FdoIUpdate

For more information see FDO API Reference Help

Related Class Topics | 127

128

Performing Queries

This chapter describes how to create and perform queries In the FDO API you can use queriesto retrieve specific features from a data store

Creating a QueryYou create and perform queries using the FdoISelect class which is a memberof the Feature sub-package of the Commands package Queries are used toretrieve features from the data store and are executed against one class at atime The class is specified using the SetFeatureClassName() method inFdoIFeatureCommand The SetFeatureClassName can be used with feature andnon-feature classes

FdoISelect supports the use of filters to limit the scope of features returned bythe command This is done through one of the SetFilter methods available inthe FdoIFeatureCommand class The filter is similar to the SQL WHERE clausewhich specifies the search conditions that are applied to one or more classproperties

Search conditions include spatial and non-spatial conditions Non-spatial queriescreate a condition against a data property such as an integer or string Basiccomparisons (= lt gt gt= lt= =) pattern matching (like) and lsquoInrsquo comparisonscan be specified Spatial queries create a spatial condition against a geometryproperty Spatial conditions are enumerated in FdoSpatialCondition andFdoDistanceCondition

The feature reader (FdoIFeatureReader) is used to retrieve the results of a queryfor feature and non-feature classes To retrieve the features from the readeriterate through the reader using the FdoIFeatureReaderReadNext method()

9

129

Query ExampleIn the Data Maintenance chapter we created an instance of theFdoFeatureClass SampleFeatureClass and assigned values to its integer stringand geometry properties (see Example Inserting an Integer a String and aGeometry Value on page 122) The sample code in the following query exampleselects this instance and retrieves the values of its properties Specifically thesample code does the following

1 Creates the select command and

2 Points the select command at the target FdoFeatureClassSampleFeatureClass and

3 Creates a filter to identify which instance of SampleFeatureClass to selectand

4 Points the select command at the filter and

5 Executes the command which returns an FdoIFeatureReader object and

6 Loops through the feature reader object which contains one or morequery results depending on the filter arguments In the sample codeprovided there is only one result

7 Finally the code extracts the property values from each query result

130 | Chapter 9 Performing Queries

we have one FdoFeatureClass object in the DataStore

create a query that returns this object

create the select command

FdoPtrltFdoISelectgt sampleSelect

sampleSelect = (FdoISelect )

connection-gtCreateCommand(FdoCommandType_Select)

point the select command at the target FdoFeatureClass

SampleFeatureClass

sampleSelect-gtSetFeatureClassName(LSampleFeatureClass)

create the filter by

1 creating an FdoIdentifier object containing the name of

the identity property

FdoPtrltFdoIdentifiergt queryPropertyName

queryPropertyName =

FdoIdentifierCreate(LSampleIdentityDataProperty)

2 creating an FdoDataValue object containing the value of the

identity property

FdoPtrltFdoDataValuegt queryPropertyValue

queryPropertyValue = FdoDataValueCreate(101)

3 calling FdoComparisonConditionCreate() passing in the

the queryPropertyName an enumeration constant signifying an

equals comparison operation and the queryPropertyValue

FdoPtrltFdoFiltergt filter

filter = FdoComparisonConditionCreate(queryPropertyName

FdoComparisonOperations_EqualTo queryPropertyValue)

point the select command at the filter

sampleSelect-gtSetFilter(filter)

execute the select command

FdoPtrltFdoIFeatureReadergt queryResults

queryResults = sampleSelect-gtExecute()

declare variables needed to capture query results

FdoPtrltFdoClassDefinitiongt classDef

FdoPtrltFdoPropertyDefinitionCollectiongt properties

FdoInt32 numProperties = 0

FdoPropertyDefinition propertyDef

FdoPropertyType propertyType

FdoDataType dataType

FdoDataPropertyDefinition dataPropertyDef

FdoString propertyName = NULL

FdoPtrltFdoByteArraygt byteArray

FdoIGeometry geometry = NULL

FdoGeometryType geometryType = FdoGeometryType_None

FdoIPolygon polygon = NULL

Query Example | 131

FdoILinearRing exteriorRing = NULL

FdoILinearRing interiorRing = NULL

FdoIDirectPosition position = NULL

FdoInt32 dimensionality = FdoDimensionality_XY

FdoInt32 numPositions = 0

FdoInt32 numInteriorRings = 0

loop through the query results

while (queryResults-gtReadNext())

get the feature class object and its properties

classDef = queryResults-gtGetClassDefinition()

properties = classDef-gtGetProperties()

loop through the properties

numProperties = properties-gtGetCount()

for(int i = 0 i lt numProperties i++)

propertyDef = properties-gtGetItem(i)

get the property name and property type

propertyName = propertyDef-gtGetName()

propertyType = propertyDef-gtGetPropertyType()

switch (propertyType)

itrsquos a data property

case FdoPropertyType_DataProperty

dataPropertyDef =

dynamic_castltFdoDataPropertyDefinition gt

(propertyDef)

dataType = dataPropertyDef-gtGetDataType()

switch (dataType)

case FdoDataType_Boolean

break

case FdoDataType_Int32

break

case FdoDataType_String

break

default

break

itrsquos a geometric property

convert the byte array to a geometry

and determine the derived type of the geometry

case FdoPropertyType_GeometricProperty

byteArray = queryResults-gtGetGeometry(propertyName)

geometry =

sampleGeometryFactory-gtCreateGeometryFromAgf

(byteArray)

132 | Chapter 9 Performing Queries

geometryType = geometry-gtGetDerivedType()

resolve the derived type into a list of ordinates

switch (geometryType)

case FdoGeometryType_None

break

case FdoGeometryType_Point

break

case FdoGeometryType_LineString

break

case FdoGeometryType_Polygon

polygon = dynamic_castltFdoIPolygon gt(geometry)

exteriorRing = polygon-gtGetExteriorRing()

dimensionality = exteriorRing-

gtGetDimensionality()

numPositions = exteriorRing-gtGetCount()

double X Y Z M

for(int i=0 iltnumPositions i++)

position = exteriorRing-gtGetItem(i)

if (dimensionality amp FdoDimensionality_Z ampamp

dimensionality amp FdoDimensionality_M)

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

M = position-gtGetM()

else if (dimensionality amp FdoDimensionality_Z

ampamp (dimensionality amp FdoDimensionality_M))

X = position-gtGetX()

Y = position-gtGetY()

Z = position-gtGetZ()

else

X = position-gtGetX()

Y = position-gtGetY()

numInteriorRings = polygon-

gtGetInteriorRingCount()

for(int i=0 iltnumInteriorRings i++)

interiorRing = polygon-gtGetInteriorRing(i)

do same for interior ring as exterior ring

break

case FdoGeometryType_MultiPoint

break

Query Example | 133

case FdoGeometryType_MultiLineString

break

case FdoGeometryType_MultiPolygon

break

case FdoGeometryType_MultiGeometry

break

case FdoGeometryType_CurveString

break

case FdoGeometryType_CurvePolygon

break

case FdoGeometryType_MultiCurveString

break

case FdoGeometryType_MultiCurvePolygon

break

default

break

default

134 | Chapter 9 Performing Queries

Long TransactionProcessing

This chapter defines long transactions (LT) and long transaction interfaces and explains howto implement LT processing in your application

NOTE For this release the providers that support long transaction processing are AutodeskFDO Provider for Oracle and OSGeo FDO Provider for ArcSDE

What Is Long Transaction ProcessingA long transaction (LT) is an administration unit that is used to groupconditional changes to objects Depending on the situation such a unit cancontain conditional changes to one or to many objects Long transactions areused to modify as-built data in the database without permanently changing theas-built data Long transactions can be used to apply revisions or alternates toan object

A root long transaction is a long transaction that represents permanent dataand that has descendents Any long transaction has a root long transaction asan ancestor in its long transaction dependency graph A leaf long transactiondoes not have descendents

For more information about Oracle-specific long transaction versions andlocking see Locking and Long Transactions

10

135

Supported InterfacesIn the current release of FDO the following long transaction interfaces aresupported

FDOIActivateLongTransaction

FDOIDeactivateLongTransaction

FDOIRollbackLongTransaction

FDOICommitLongTransaction

FDOICreateLongTransaction

FDOIGetLongTransaction

These interfaces are summarized below For more information about theirusage supported methods associated enumerations and readers see the FDOAPI Reference Help

FDOIActivateLongTransaction

The FdoIActivateLongTransaction interface defines theActivateLongTransaction command which activates a long transaction wherefeature manipulation and locking commands operate on it Input to theactivate long transaction command is the long transaction name The Executeoperation activates the identified long transaction

FDOIDeactivateLongTransaction

The FdoIDeactivateLongTransaction interface defines theDeactivateLongTransaction command which deactivates the active longtransaction where feature manipulation and locking commands operate onit If the active long transaction is the root long transaction then no longtransaction will be deactivated

FDOIRollbackLongTransaction

The FdoIRollbackLongTransaction interface defines theRollbackLongTransaction command which allows a user to execute rollbackoperations on a long transaction Two different rollback operations areavailable Full and Partial

136 | Chapter 10 Long Transaction Processing

The operation is executed on all data within a long transaction and on all itsdescendents The data is removed from the database and all versions involvedin the process deleted

NOTE If the currently active long transaction is the same as the one beingcommitted or rolled back then if the commit or rollback succeeds the providerresets the current active long transaction to be the root long transaction If it doesnot succeed the active long transaction is left alone and current If the currentlyactive long transaction is not the same as the one being committed or rolled backthen it is not affected

FDOICommitLongTransaction

The FdoICommitLongTransaction interface defines theCommitLongTransaction command which allows a user to execute commitoperations on a long transaction Two different commit operations areavailable Full and Partial

The commit operation can be performed on a leaf long transaction only Along transaction is a leaf long transaction if it does not have descendents

FDOICreateLongTransaction

The FdoICreateLongTransaction interface defines the CreateLongTransactioncommand which creates a long transaction that is based on the currentlyactive long transaction There is always an active long transaction If the userhas not activated a user-defined long transaction then the root longtransaction is active

Input to the CreateLongTransaction command includes a name and descriptionfor the new long transaction The long transaction name submitted to thecommand has to be unique If it is not unique an exception is thrown

FDOIGetLongTransactions

The FdoIGetLongTransactions interface defines the GetLongTransactionscommand which allows the user to retrieve long transaction information Ifa long transaction name is submitted the command returns the informationfor the named long transaction only If no long transaction name is giventhe command retrieves the names of all available long transactions

For each returned long transaction the user has the option to retrieve a listof descendents andor ancestors

Supported Interfaces | 137

138

Filter and ExpressionLanguages

This chapter discusses the use of filters and filter expressions You can use filters and expressionsto specify to an FDO provider how to identify a subset of the objects in a data store

For more information and implementation details about the expression functions signaturesthe RDBMS-specific built-in support for some of the functions and the provider-specificsupport see the appendix Expression Functions

FiltersFDO uses filters through its commands (including provider-specific commands)to select certain features and exclude others

A filter is a construct that an application specifies to an FDO provider to identifya subset of objects of an FDO data store For example a filter may be used toidentify all Road type features that have 2 lanes and that are within 200 metresof a particular location Many FDO commands use filter parameters to specifythe objects to which the command applies For example a select commandtakes a filter to identify the objects that the application wants to retrieve or adelete command takes a filter to identify the objects that the application wantsto delete from the data store

When a command executes the filter is evaluated for each feature instance andthat instance is included in the scope of the command only if the filter evaluatesto True Filters may be specified either as text or as an expression tree Featureproviders declare their level of support for filters through the filter capabilitiesmetadata Query builders should configure themselves based on the filtercapabilities metadata in order to provide users with a robust user interface Formore information see What Is an Expression on page 19

11

139

ExpressionsFDO uses expressions through its commands (including provider-specificcommands) to specify input values in order to filter features In generalcommands in FDO do not support the SQL command language (the oneexception is the optional SQLCommand) However to facilitate ease of usefor application developers expressions in FDO can be specified using a textualnotation that is based syntactically on expressions and SQL WHERE clausesIn FDO expressions are not intended to work against tables and columns butagainst feature classes properties and relationships For example an expressionto select roads with four or more lanes might look like this

Lanes gt= 4

An expression is a construct that an application can use to build up a filterIn other words an expression is a clause of a filter or larger expression Forexample ldquoLanes gt=4 and PavementType = Asphaltrdquo takes two expressionsand combines them to create a filter

Filter and Expression TextIn general commands in FDO do not support the SQL command language(the one exception is the optional SQLCommand) However to facilitate easeof use for application developers expressions and filters in FDO can be specifiedusing a textual notation that is based syntactically on expressions and SQLWHERE clauses The biggest difference between this approach and SQL is thatthese clauses are not intended to work against tables and columns but againstfeature classes properties and relationships For example a filter to selectroads with four or more lanes might look like

Lanes gt= 4

Similarly a filter to select all PipeNetworks that have at least one Pipe in theproposed state might look like

Pipesstate = proposed

Furthermore a filter to select all existing parcels whose owner contains thetext ldquoSmithrdquo might look like

state = existing and owner like Smith

Finally a filter to select all parcels that are either affected or encroached uponby some change might look like

140 | Chapter 11 Filter and Expression Languages

state in (affected encroached)

Language IssuesThere are a number of language issues to be considered when working withclasses in the Filter Expression and Geometry packages

Provider-specific constraints on text

Filter grammar

Expression grammar

Filter and Expression keywords

Data types

Operators

Special characters

Geometry value

Provider-Specific Constraints on Filter andExpression Text

Some providers may have reserved words that require special rules when usedwith filters and expressions For more information see Oracle Reserved WordsUsed with Filter and Expression Text

Filter Grammar

The rules for entering filter expressions are described in the following sectionsusing BNF notation For more information about BNF notation seehttpcuiunigechdb-researchEnseignementanalyseinfoAboutBNFhtml

The FdoFilterParse() method supports the following filter grammar

Language Issues | 141

ltFiltergt = ( Filter )

| ltLogicalOperatorgt

| ltSearchConditiongt

ltLogicalOperatorgt = ltBinaryLogicalOperatorgt

| ltUnaryLogicalOperatorgt

ltBinaryLogicalOperatorgt =

ltFiltergt ltBinaryLogicalOperationsgt ltFiltergt

ltSearchConditiongt = ltInConditiongt

| ltComparisonConditiongt

| ltGeometricConditiongt

| ltNullConditiongt

ltInConditiongt = ltIdentifiergt IN ( ValueExpressionCollection

)

ltValueExpressionCollectiongt = ltValueExpressiongt

| ltValueExpressionCollectiongt ltValueExpressiongt

ltComparisonConditiongt =

ltExpressiongt ltComparisonOperationsgt ltExpressiongt

ltGeometricConditiongt = ltDistanceConditiongt

| ltSpatialConditiongt

ltDistanceConditiongt =

ltIdentifiergt ltDistanceOperationsgt ltExpressiongt ltdistancegt

ltNullConditiongt = ltIdentifiergt NULL

ltSpatialConditiongt =

ltIdentifiergt ltSpatialOperationsgt ltExpressiongt

ltUnaryLogicalOperatorgt = NOT ltFiltergt

ltBinaryLogicalOperationsgt = AND | OR

ltComparisionOperationsgt =

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

LIKE Like

ltDistanceOperationsgt = BEYOND | WITHINDISTANCE

ltdistancegt = DOUBLE | INTEGER

ltSpatialOperationsgt = CONTAINS | CROSSES | DISJOINT

| EQUALS | INTERSECTS | OVERLAPS | TOUCHES | WITHIN | COVEREDBY |

INSIDE

142 | Chapter 11 Filter and Expression Languages

Expression Grammar

The FdoExpressionParse() method supports the following expression grammar

ltExpressiongt = ( Expression )

| ltUnaryExpressiongt

| ltBinaryExpressiongt

| ltFunctiongt

| ltIdentifiergt

| ltValueExpressiongt

ltBinaryExpressiongt =

ltExpressiongt + ltExpressiongt

| ltExpressiongt - ltExpressiongt

| ltExpressiongt ltExpressiongt

| ltExpressiongt ltExpressiongt

ltDataValuegt =

TRUE

| FALSE

| DATETIME

| DOUBLE

| INTEGER

| STRING

| BLOB

| CLOB

| NULL

ltFunctiongt = ltIdentifiergt ( ltExpressionCollectiongt )

ltExpressionCollectiongt =

| ltExpressiongt

| ltExpressionCollectiongt ltExpressiongt

ltGeometryValuegt = GEOMFROMTEXT ( STRING )

ltIdentifiergt = IDENTIFIER

ltValueExpressiongt = ltLiteralValuegt | ltParametergt

ltLiteralValuegt = ltGeometryValuegt | ltDataValuegt

ltParametergt = PARAMETER | STRING

ltUnaryExpressiongt = - ltExpressiongt

Expression Operator Precedence

The precedence is shown in YACC notation that is the highest precedenceoperators are at the bottom

left Add Subtract

left Multiply Divide

left Negate

Expression Grammar | 143

Filter and Expression Keywords

The following case-insensitive keywords are reserved in the language that isthey cannot be used as identifier or function names

AND BEYOND COMPARE CONTAINS COVEREDBY CROSSES DATE

DISJOINT DISTANCE EQUALS FALSE GeomFromText IN INSIDE

INTERSECTS LIKE NOT NULL OR OVERLAPS RELATE SPATIAL TIME

TIMESTAMP TOUCHES TRUE WITHIN WITHINDISTANCE

Data Types

The available data types are described in this section

Identifier

An identifier can be any alphanumeric sequence of characters other than akeyword Identifiers can be enclosed in double quotes to allow specialcharacters and white space If you need to include a double quote characterinside an identifier double the character for example abcdef

Parameter

Parameters are defined by a colon followed by alphanumeric characters TheFDO filter language extends SQL to allow for a literal string to follow the colonto allow blanks (and other possibilities) for example Enter Name

Determine whether parameters are supported by the FDO Provider you areusing by checking SupportParameters on the Connection interface

String

Strings are literal constants enclosed in single quotes The FDO filter languagealso supports the special characters (left and right single quotes) that MicrosoftWord uses to automatically replace the single quote character typed from thekeyboard If you need to include a single quote character inside a string youcan double the character for example aaabbb

144 | Chapter 11 Filter and Expression Languages

Integer

Integers allow only decimal characters with an optional unary minus signUnary plus is not supported

(-)[0-9]

Double

Floating point numbers have a decimal point can be signed (-) and includean optional exponent (e[0-9])

NOTE If an integer is out of the 32-bit precision range it is converted to floatingpoint

Examples

-34

12345678901234567

12e13

DateTime

Date and time are parsed using the standard SQL literal strings

DATE YYYY-MM-DD

TIME HHMMSS[sss]

TIMESTAMP YYYY-MM-DD HHMMSS[sss]

For example

DATE 1971-12-24

TIMESTAMP 2003-10-23 110002

NOTE The BLOB and CLOB strings are currently not supported If you need tosupport binary input use parameters

Data Types | 145

Operators

The following operators are special characters common to SQL and mostprogramming languages

BinaryOperations

These binary operations are available

+ Add (for compatibility with SQL string concatenation may also be definedusing ldquo||rdquo)

- Subtract

Multiply

Divide

UnaryOperations

These unary operation are available

- Negate

Comparison Operations

These comparison operations are available

= EqualTo (EQ)

ltgt NotEqualTo (NE)

gt GreaterThan (GT)

gt= GreaterThanOrEqualTo (GE)

lt LessThan (LT)

lt= LessThanOrEqualTo (LE)

Operator Precedence

The following precedence is shown from highest to lowest

Negate NOT

Multiply Divide

Add Subtract

146 | Chapter 11 Filter and Expression Languages

EQ NE GT GE LT LE

AND

OR

Special Character

The following special characters are used in ExpressionCollections andValueExpressions to define function arguments and IN conditions

( Left Parenthesis

Comma

) Right Parenthesis

The Colon () is used in defining parameters and the Dot () can be includedin real numbers and identifiers

Geometry Value

Geometry values are handled using a function call GeomFromText(FGF Textstring) as is typical in an SQL query

The Autodesk extension to WKT referred to as FGF Text is a superset of WKT(that is you can enter WKT as valid FGF Text strings) Dimensionality isoptional It can be XY XYM XYZ or XYZM If it is not specified it is assumedto be XY For more information about FGF Text see FGF Text on page 158

NOTE Extra ordinates are ignored rather than generating an error during FGFtext parsing For example in the string ldquoPOINT (10 11 12)rdquo the lsquo12rsquo is ignoredbecause the dimensionality is assumed to be XY

The following is the grammar definition for FGF Text

ltFGF Textgt = POINT ltDimensionalitygt ltPointEntitygt

| LINESTRING ltDimensionalitygt ltLineStringgt

| POLYGON ltDimensionalitygt ltPolygongt

| CURVESTRING ltDimensionalitygt ltCurveStringgt

| CURVEPOLYGON ltDimensionalitygt ltCurvePolygongt

| MULTIPOINT ltDimensionalitygt ltMultiPointgt

Special Character | 147

| MULTILINESTRING ltDimensionalitygt ltMultiLineStringgt

| MULTIPOLYGON ltDimensionalitygt ltMultiPolygongt

| MULTICURVESTRING ltDimensionalitygt ltMultiCurveStringgt

| MULTICURVEPOLYGON ltDimensionalitygt ltMultiCurvePolygongt

| GEOMETRYCOLLECTION ltGeometryCollectiongt

ltPointEntitygt = ( ltPointgt )

ltLineStringgt = ( ltPointCollectiongt )

ltPolygongt = ( ltLineStringCollectiongt )

ltMultiPointgt = ( ltPointCollectiongt )

ltMultiLineStringgt = ( ltLineStringCollectiongt )

ltMultiPolygongt = ( ltPolygonCollectiongt )

ltGeometryCollection ( ltFGF Collection Textgt )

ltCurveStringgt = ( ltPointgt ( ltCurveSegmentCollectiongt ) )

ltCurvePolygongt = ( ltCurveStringCollectiongt )

ltMultiCurveStringgt = ( ltCurveStringCollectiongt )

ltMultiCurvePolygongt = ( ltCurvePolygonCollectiongt )

ltDimensionalitygt = default to XY

| XY

| XYZ

| XYM

| XYZM

ltPointgt = DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE

| DOUBLE DOUBLE DOUBLE DOUBLE

ltPointCollectiongt = ltPointgt

| ltPointCollection ltPointgt

ltLineStringCollectiongt = ltLineStringgt

| ltLineStringCollectiongt ltLineStringgt

ltPolygonCollectiongt = ltPolygongt

148 | Chapter 11 Filter and Expression Languages

| ltPolygonCollectiongt ltPolygongt

ltFGF Collection Textgt = ltFGF Textgt

| ltFGF Collection Textgt ltFGF Textgt

ltCurveSegmentgt = CIRCULARARCSEGMENT ( ltPointgt ltPointgt )

| LINESTRINGSEGMENT ( ltPointCollectiongt )

ltCurveSegmentCollectiongt = ltCurveSegmentgt

| ltCurveSegmentCollectiongt ltCurveSegmentgt

ltCurveStringCollectiongt = ltCurveStringgt

| ltCurveStringCollectiongt ltCurveStringgt

ltCurvePolygonCollectiongt = ltCurvePolygongt

| ltCurvePolygonCollectiongt ltCurvePolygongt

The only other token type is DOUBLE representing a double precision floatingpoint values Integer (non-decimal point) input is converted to DOUBLE inthe lexical analyzer

Examples of the Autodesk extensions include

POINT XY (10 11) equivalent to POINT (10 11)

POINT XYZ (10 11 12)

POINT XYM (10 11 12)

POINT XYZM (10 11 12 12)

GEOMETRYCOLLECTION (POINT xyz (10 11 12)POINT XYM (30 20 18)LINESTRING XYZM(1 2 3 4 3 5 15 3 20 20))

CURVESTRING (0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40))))

CURVESTRING (0 0 (CIRCULARARCSEGMENT (11 11 12 12)LINESTRINGSEGMENT (10 10 20 20 30 40)))

CURVESTRING (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 30 40)))

CURVESTRING XYZ (0 0 0 (LINESTRINGSEGMENT (10 10 1 20 20 1 30 401)))

MULTICURVESTRING ((0 0 (LINESTRINGSEGMENT (10 10 20 20 30 40)))(00 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 20 20 30 40))))

Geometry Value | 149

CURVEPOLYGON ((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20) ARC(20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 10 2020 40 40 90 90))))

MULTICURVEPOLYGON (((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90))))((0 0 (LINESTRINGSEGMENT (10 10 10 20 20 20)ARC (20 15 10 10))) (0 0 (ARC (11 11 12 12) LINESTRINGSEGMENT (10 1020 20 40 40 90 90)))))

150 | Chapter 11 Filter and Expression Languages

The Geometry API

This chapter describes the FdoGeometry API (hereafter called the ldquoGeometry APIrdquo) and explainsthe various geometry types and formats

IntroductionThe Geometry API supports specific Autodesk applications and APIs includingFDO (Feature Data Objects) This API consists of the following components

a Geometry Type package (all through fully encapsulated interfaces)

an Abstract Geometry Factory

a Concrete Geometry Factory for FGF

You can work with the Geometry API in several different ways

FGF (Feature Geometry Format)

FGF Text

Abstract Geometry Factory

FGF and WKBWKB is a memory layout used to store geometry features This format was createdby the OpenGIS organization to allow the efficient exchange of geometry databetween different components in an FDO system Most pieces of the originalspecification defining the WKB format are in the document 99-050pdf theOpenGIS Simple feature specification for OLECOM that can be found atwwwopengisorg

12

151

FGF is an extended version of the Well Known Binary (WKB) format The twoformats differ in the following ways

WKB defines a byte order of the data in every piece of geometry This isstored as a byte field which may change the memory alignment fromword to byte In FGF only one memory alignment type is supported whichis the same alignment type used by the NET framework and Windowsthe encoding uses the little-endian byte order format As a result the byteflag does not need to be stored

WKB is defined as a 2D format only This is insufficient to represent 3Dpoints polylines and polygons In FGF the dimension flag has been addedIn particular a flag is included for each geometry piece to indicate whetherthe geometry is 2D 3D or even 4D (storing a measure value as used bydynamic segmentation

FGF includes geometry types that are not yet covered by any WKBspecification

FGF Binary SpecificationIn this section the memory layout of each simple geometry type is describedThe format is based on the OGC specification which is built on the memorylayout of a C++ struct All arrays have a computable size and are inline theydo not point to a different location in memory This format allows streamingof geometry data

First the different data types their size and memory layout are discussed

152 | Chapter 12 The Geometry API

double == 8byte IEEE double number in little endian encoding

int == 4 byte integer in little endian encoding

the type of the geometry

enum GeometryType int

None = 0

Point = 1

LineString = 2

Polygon = 3

MultiPoint = 4

MultiLineString = 5

MultiPolygon = 6

MultiGeometry = 7

CurveString = 10

CurvePolygon = 11

MultiCurveString = 12

MultiCurvePolygon = 13

Coordinate Types

This is a bit field for example xym == coordinateDimensionalityXY |CoordinateDimensionalityM The following sequence defines the type ofcoordinates used for this object

enum CoordinateDimensionality FdoInt32

XY = 0

Z = 1

M = 2

Basic Geometry

The following sequence establishes the basic pure geometry

struct Geometry

int geomType

CoordinateDimensionality type

FGF Binary Specification | 153

Notation Definition

The following sequence defines a notation used to specify geometries withina byte stream

154 | Chapter 12 The Geometry API

Define a notation within this specification

int PositionSize(geometry)

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM ||

geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityZ)

return 3

if (geometrytype == CoordinateDimensionalityXY |

CoordinateDimensionalityM | CoordinateDimensionalityZ)

return 4

return 2

struct Point Geometry

int geomType == GeometryTypePoint

CoordinateDimensionality type all types allowed

double[] coords size = PositionSize(this)

struct LineString

int geomType

CoordinateDimensionality type

int numPts gt0

double[] coords size = numPts PositionSize(this)

struct MultiPoint

int geomType

int numPoints gt 0

Point[] points size = numPoints

struct MultiLineString

int geomType

int numLineStrings gt= 0

LineString[] lineStrings size = numLineStrings

building block for polygons not geometry by itself

struct LinearRing

int numPts gt0

double[] coords size = numPts PositionSize(polygon)

FGF Binary Specification | 155

struct Polygon

int geomType

CoordinateDimensionality type

int numRings gt= 1 as there has to be at least one ring

LinearRing[] lineStrings size = numRings

struct MultiPolygon

int geomType

int numPolygons gt= 0

Polygon[] polygons size = numPolygons

struct MultiGeometry

int geomType

int numGeom gt= 0

Geometry[] geometry size = numGeom

enum CurveElementType int

LineString = 1

CircularArc = 2

struct CurveStringElement

int CurveElementType

struct LinearCurveStringElement

int CurveElementType

int length

double[] coords size = thislength PositionSize (this)

struct CircularArcCurveStringElement

int CurveElementType == CurveElmentTypeArc

double[] coords size = 2 PositionSize(this)

struct CurveString

int geomType

156 | Chapter 12 The Geometry API

CoordinateDimensionality type all types allowed

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct Ring

double[] startPoint size = PositionSize(this)

int numElements gt=0

CurveStringElement[] elements size = numElements

struct MultiCurveString

int geomType

int numCurveStrings gt= 0

CurveString[] curveStrings size = numCurveStrings

struct CurvePolygon

int geomType

CoordinateDimensionality type

int numRings gt=1 as there has to be at least one ring

Ring[] rings size = numRings

struct MultiCurvePolygon

int geomType

int numPolygons gt=0

CurvePolygon[] polygons size = numElements

In the following example a polygon is formatted within a byte arrayrepresenting the stream according to the FGF specification

FGF Binary Specification | 157

T = 3 stands for GeometryType == GeometryTypePolygon

CT = 0 stands for CoordinateDimensionality == CoordinateDimensionalityXY

NR = 2 stands for number of rings = 2

NP =3 stands for number of points = 3

FGF TextFGF Text is the textual analogue to the binary FGF format It is a superset ofthe OGC WKT format XY dimensionality is the default and is optional FGFText can be used to represent any geometry value in the Geometry API whetheror not it originates from the FGF geometry factory Conversions are done withthe following methods

FdoGeometryFactoryAbstract CreateGeometry(FdoString text)

FdoIGeometry GetText()rdquo

A BNF for the FGF textual specification is contained in the topic GeometryValue on page 147

Abstract and Concrete ClassesThe Geometry API is almost completely abstract It provides an object-orientedinterface to geometry values All objects in the Geometry API have factorymethods in the FdoGeometryFactorytAbstract class One defaultimplementation is provided based on FGF in-memory binary storage It isaccessible via the concrete class FdoFgfGeometryFactory

NOTE The FdoFgfGeometryFactory employes object pooling for many of the datatypes in the API While many methods appear to be executing ldquoCreaterdquo or ldquoGetrdquoactions they are in fact accessing object pools thus avoiding costly operationson the memory heap

All of the other classes in the Geometry API with the exception of two relateto the main abstract type FdoIGeometry They either derive from it or arecomponents of it

158 | Chapter 12 The Geometry API

The two exception concrete classes are

FdoDirectPositionImpl a small helper class implementingFdoIDirectPosition

FdoEnvelopeImpl a small helper class implementing FdoIEnvelope

Geometries in FGF format can be exchanged between software componentswithout depending on the Geometry API itself because they are not genuinegeometry ldquoobjectsrdquo FGF content is based on byte arrays It is handled througha simple FdoByteArray class that is not specific to geometry

Geometry TypesThe Geometry types comprise the Global Enum FdoGeometryType Thefollowing are Geometry types

0 FdoGeometryType_None Indicates no specific type used for ldquounknownrdquoldquodo not carerdquo or an incompletely constructed Geometry object

NOTE FdoGeometryType_ None does not represent an instantiable type An FDOclient should not expect an FDO provider to list support for it in its capabilities

1 FdoGeometryType_Point Point type (FdoIPoint)

2 FdoGeometryType_LineString LineString type (FdoILineString)

3 FdoGeometryType_Polygon Polygon type (FdoIPolygon)

4 FdoGeometryType_MultiPoint MultiPoint type (FdoIMultiPoint)

5 FdoGeometryType_MultiLineString MultiLineString type(FdoIMultiLineString)

6 FdoGeometryType_MultiPolygon MultiPolygon type (FdoIMultiPolygon)

7 FdoGeometryType_MultiGeometry MultiGeometry type(FdoIMultiGeometry)

10 FdoGeometryType_CurveString CurveString type (FdoICurveString)

11 FdoGeometryType_CurvePolygon CurvePolygon type(FdoICurvePolygon)

Geometry Types | 159

12 FdoGeometryType_MultiCurveString MultiCurveString type(FdoIMultiCurveString)

13 FdoGeometryType_MultiCurvePolygon MultiCurvePolygon type(FdoIMultiCurvePolygon

Mapping Between Geometry and GeometricTypes

The FDO API GeometricType enumeration of GeometricProperty gives theclient application some knowledge of which geometry types comprise thegeometric property so that it can present the user with an intelligent editorfor selecting styles for rendering the geometry In particular GeometricTyperelates to shape dimensionality of geometries allowed in FDO geometricproperties The nearest analogues in the Geometry API are

FdoDimensionality which pertains to ordinate (not shape) dimensionalityof geometry values

FdoGeometryType which has types whose abstract base types map toGeometric Type

The GeometricType enumeration is as follows

Point = 0x01 Point Type Geometry

Curve = 0x02 Line and Curve Type Geometry

Surface = 0x04 Surface (or Area) Type Geometry

Solid = 0x08 Solid Type Geometry

NOTE The enumeration defines a bit mask and the GetGeometricTypes andSetGeometricTypes methods take and return an integer This is to allow a geometryproperty to be of more than one type For example the callgeometricPropertySetGeometricTypes(Point | Surface)

would allow the geometric property to represent either point type geometry orsurface type geometry (polygons)

160 | Chapter 12 The Geometry API

Spatial ContextSpatial Context is a coordinate system with an identity Any geometries thatare to be spatially related must be in a common spatial context

Providing an identify for each coordinate system supports separate workspacessuch as schematic diagrams which are non-georeferenced However thereare also georeferenced cases In general two users may create drawings usingthe same default spatial parameters (for example rectangular and10000x10000) that have nothing to do with each other If their drawingsare to be put into a common database the spatial context capability of FDOpreserves the container aspect of the data along wih the spatial parameters

The FDO Spatial Context Commands are part of the FDO API They supportcontrol over Spatial Contexts in the following ways

Metadata control Creates and deletes Spatial Contexts

Active Spatial Context A session setting to specify which Spatial Contextto use by default while storingretrieving geometries and performing spatialqueries

There is a default Spatial Context for each database Its attributes (such ascoordinate system) are specified when the database is created This SpatialContext is the active one in any FDO session until a Spatial Context Commandis used to change this state The default Spatial Contextrsquos identifier numberis 0 (zero)

Spatial contexts have two tolerance attributes XYTolerance and ZToleranceThe tolerances are in distance units that depend on the coordinate system inuse Geodetic coordinate systems typically have ldquoon the groundrdquo linear distanceunits instead of the angular (that is degrees minutes or seconds) units usedfor positional ordinates The meter is the most common unit Mostnon-geodetic systems are rectilinear and use the same unit for positionalordinates and distances for example meters or feet

Specify Dimensionality When CreatingGeometries Using String Specifications

When creating a 3D geometry from string specifications you must specify theDimensionality argument XYZ explicitly because the default dimensionalityis XY and the geometry factory code will only process the first two ordinates

Spatial Context | 161

The following code successfully creates pointOne as a 3D point whereaspointTwo is created as a 2D point

FdoFgfGeometryFactory geometryFactory = FdoFgfGeometryFact

oryGetInstance()

FdoIPoint pointOne

pointOne = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT XYZ (1 2 3)rsquo)rdquo))

FdoPoint pointTwo

pointTwo = dynamic_cast(geometryFactory-gtCreateGeometry(LrdquoGeomFrom

Text(lsquoPOINT (1 2 3)rsquo)rdquo))

xmlFeatureFlags = FdoXmlFeatureFlagsCreate( None FdoXmlFlagsEr

rorLevel_Normal True FdoXmlFeatureFlagsConflictOption_Add )

Inserting Geometry ValuesFor information about geometry property values see Geometry Property Valueson page 121

See Example Inserting an Integer a String and a Geometry Value on page122 for a code example that shows how to insert a Geometry value

162 | Chapter 12 The Geometry API

FDO Cookbook

IntroductionThis chapter contains code samples of common operations

Some operations like connection must discuss differences among providersReferences are made to both Autodesk proprietary providers and open sourceproviders Providers whose name begins with ldquoAutodeskrdquo are available only incommercial releases of Autodesk products Providers whose name begins withldquoOSGeordquo are available in releases of open source software at httpfdoosgeoorgSome of the open source providers are also available in commercial releases ofAutodesk products

Recommendations

After iterating through readers such IFeatureReader IDataReaderISQLDataReader or DbUserReader call the Close() or Dispose() method Notdoing so may cause unhandled exceptions at some future time Be sure toenclose the statement that returns a reader in a try block so that you canclose the reader in the catch block

RegistryThe registry contains the list of providers that are available in a particular FDOinstallation FDO initializes the registry using the contents of the providersxmlfile that is co-located with the FDO binaries

13

163

The FeatureProviderRegistryFeatureProviderName elements in theprovidersxml file contain fully qualified provider names A fully qualifiedprovider name has four parts which are separated by dot (lsquorsquo) characters Theparts areltdomaingtltshortNamegtltmajorReleaseNumbergtltminorReleaseNumbergtThere are two domains Autodesk and OSGeo The former indicates proprietaryand the latter open source software

Use Cases

Get a fully qualified provider name in order to create a a connection Thefully qualified name contains version numbers so having a dictionary thatmaps generic provider names to the currently loaded fully qualified nameis useful

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager andProviderCollection

OSGeoFDO for IProviderRegistry

IProviderRegistry registry = FeatureAccessManagerGetProviderRe

gistry()

ProviderCollection providers = registryGetProviders()

Map provider short name to fully qualified name

Dictionaryltstring stringgt providerAbbrToFullName = new Diction

aryltstring stringgt()

string shortName = null

foreach (Provider provider in providers)

shortName = providerNameSplit()[1]

providerAbbrToFullName[shortName] = providerName

ConnectionThe connection object contains a connection string property that containsthe connection parameter names and values The connection string propertycan be set by using a connection property dictionary or by assigning a

164 | Chapter 13 FDO Cookbook

connection string directly to it The property dictionaryrsquos methods tell youthe names of the connection parameters their current values and theiroptionality

Some parameters must always be set for a connection to succeed for examplethe OSGeoSDF File parameter and the AutodeskOracle Username Passwordand Service parameters Some parameters need not be set if you accept thedefault value For example the SDF ReadOnly parameter has a default settingof false The Oracle DataStore parameter need not be set if your objective isto obtain the names of the available data stores within the data source In thiscase connecting with Username Password and Service parameters results ina pending connection You can then query the DataStore parameter to getthe list of available data stores set the DataStore parameter to the value ofone of the list members and open the connection again but this time to afully operational state If you already know the name of the data store thatyou want you can set its value at the outset and open the connection fullywithout the intervening step

The following table sets out the names of the connection parameters for eachprovider

Connection ParametersProvider

Username Password Service DataStoreAutodeskOracle

DefaultRasterFileLocationAutodeskRaster

Username Password Service DataStoreAutodeskSqlServer

Server Instance Username Password DatastoreOsGeoArcSDE

DefaultRasterFileLocationOSGeoGdal

Username Password Service OracleSchema KingFdoClassOSGeoKingOracle

Username Password Service DataStoreOSGeoMySQL

UserId Password DataSourceName ConnectionStringGenerateDefaultGeometryProperty

OSGeoODBC

DataSource ReadOnlyOSGeoOGR

Connection | 165

Connection ParametersProvider

Username Password Service DataStoreOSGeoPostGIS

File ReadOnlyOSGeoSDF

DefaultFileLocationOSGeoSHP

Username Password Service DataStoreOSGeoSQLServerSpatial

FeatureServer Username PasswordOSGeoWFS

FeatureServer Username Password DefaultImageHeightOSGeoWMS

Use Cases

Create a connection to get the provider capabilities See the Capabilitieson page 168 topic

Get a list of the connection parameters

Determine the optionality of a parameter

Set the value of a parameter

Open and close connections

C

The following namespaces are used

OSGeoFDOClientServices for FeatureAccessManager

OSGeoFDO for IConnectionManager

OSGeoFDOConnections for IConnectionImp IConnectionInfoIConnectionPropertyDictionary ConnectionState

Create a Connection

The connection is created in the closed state

166 | Chapter 13 FDO Cookbook

IConnectionManager connMgr = FeatureAccessManagerGetConnectionMan

ager()

string fullName = providerAbbrToFullName[ldquoOraclerdquo]

IConnectionImp conn = connMgrCreateConnection(fullName) as ICon

nectionImp

Determine the Names of the Parameters

Before a connection can be opened the connection parameters must beidentified and given values You can query a connection to identify theseparameters The code block shows the retrieval of the connection parameternames into a string array

IConnectionInfo connInfo = connectionConnectionInfo

IConnectionPropertyDictionary properties = connInfoConnectionProp

erties

string[] names = propertiesPropertyNames

Determine the Optionality of a Parameter

The code block shows determining the optionality of the first connectionparameter

Boolean isRequired = propertiesIsPropertyRequired(names[0])

Set a Parameter

The code block shows the setting of the Username parameter

propertiesSetProperty(ldquoUsernamerdquo ldquoEXISTINGUSERrdquo)

Get the Connection String

The code block shows getting the connection string value from the connection

string connectionString = connectionConnectionString

Open and Close a Connection

The code block shows opening and closing a connection Valid connectionstates are Busy Closed Open and Pending

ConnectionState connState = connectionOpen()

ConnectionState connState = connectionClose()

Connection | 167

CapabilitiesThe following code samples are a representative listing of the capabilitymethods in each category For a complete listing consult the API referencedocumentation

The capabilities for a provider are statically defined You create a connectionobject for the provider and use this object to query the capabilities Theconnection does not have to be open

Some capabilities are defined as booleans for example support for theDISTINCT operator in a SQL SELECT statement Sample code for this is shownin the Command section Some capabilities are defined by arrays of enumeratedtype values for example the feature commands The presence of the capabilityis determined by testing each value in the array for its equality with one ofthe values in the enumerated type range sample code that tests for thepresence of the create data store command is shown in the Command section

The schema capabilities include a string type that defines the characters thatmay not appear in a schema name and two integer types that define themaximum decimal precision and scale

Use Cases

Get the capabilities of a provider

Write code that executes if the provider currently in use supports it

C

The following namespaces and types are used

OSGeoFDOCommands for CommandType

OSGeoFDOCommandsLocking for LockType

OSGeoFDOCommandsSpatialContext for SpatialContextExtentType

OSGeoFDOCommon for GeometryComponentType GeometryType

OSGeoFDOConnectionsCapabilities for ICommandCapabiltiesIConnectionCapabilities IExpressionCapabilities IFilterCapabilitiesIGeometryCapabilities IRasterCapabilities ISchemaCapabilitiesFunctionDefinitionCollection FunctionDefinitionReadOnlySignatureDefinitionCollection SignatureDefinition

168 | Chapter 13 FDO Cookbook

ReadOnlyArgumentDefinitionCollection ArgumentDefinitionThreadCapability

OSGeoFDOExpression for ExpressionType

OSGeoFDOFilter for ConditionType DistanceOperationsSpatialOperations

OSGeoFDOSchema for ClassType DataType PropertyType

Command

ICommandCapabilities cmdCapabilities = connCommandCapabilities

int[] commands = cmdCapabilitiesCommands

Boolean supportsSelectDistinct = cmdCapabilitiesSupportsSelectDis

tinct()

CommandType cmdType = (CommandType)commands[0]

Boolean supportsCreateDataStore = false

for (int i = 0 i lt commandsGetLength(0) i++)

if (commands[i] == (int)CommandTypeCommandType_CreateDataStore)

supportsCreateDataStore = true

Connection

IConnectionCapabilities connCapabilities = connConnectionCapabil

ities

LockType[] lockTypes = connCapabilitiesLockTypes

SpatialContextExtentType[] spatialContextExtentTypes = connCapab

ilitiesSpatialContextTypes

ThreadCapability threadCapability = connCapabilitiesThreadCapab

ility

Boolean supportsConfiguration = connCapabilitiesSupportsConfigur

ation()

Capabilities | 169

Expression

IExpressionCapabilities exprCapabilities = connectionExpression

Capabilities

ExpressionType[] expressionTypes = exprCapabilitiesExpression

Types

FunctionDefinitionCollection functions = exprCapabilitiesFunc

tions

FunctionDefinition function = functions[0]

ReadOnlySignatureDefinitionCollection signatureDefs = functionSig

natures

SignatureDefinition signatureDef = signatureDefs[0]

PropertyType returnPropertyType = signatureDefReturnPropertyType

if (returnPropertyType == PropertyTypePropertyType_DataProperty)

DataType returnDataType = signatureDefReturnType

ReadOnlyArgumentDefinitionCollection arguments = signatureDefAr

guments

ArgumentDefinition argDef = arguments[0]

PropertyType argPropertyType = argDefPropertyType

if (argPropertyType == PropertyTypePropertyType_DataProperty)

DataType argDataType = argDefDataType

Filter

IFilterCapabilities filterCapabilities = connFilterCapabilities

Boolean supportsGeodesicDistance = filterCapabilitiesSupports

GeodesicDistance()

ConditionType[] conditionTypes = filterCapabilitiesConditionTypes

DistanceOperations[] distanceOperations = filterCapabilitiesDis

tanceOperations

SpatialOperations[] spatialOperations = filterCapabilitiesSpatia

lOperations

170 | Chapter 13 FDO Cookbook

Geometry

IGeometryCapabilities geometryCapabilities = connGeometryCapabil

ities

GeometryType[] geometryTypes = geometryCapabilitiesGeometryTypes

GeometryComponentType[] geometryComponentTypes = geometryCapabil

itiesGeometryComponentTypes

int dimensionalities = geometryCapabilitiesDimensionalities

Boolean HasZ = (dimensionalities amp 1) == 1

Boolean HasM = (dimensionalities amp 2) == 2

NOTE The dimensionalities integer contains bit-field definitions XY is 0 becauseall spatial data has at least an X and Y coordinate Z is 1 and M is 2 Use bitwiseAND (amp) to combine and bitwise OR (|) to separate

Raster

IRasterCapabilities rasterCapabilities = connRasterCapabilities

Boolean supportsRaster = rasterCapabilitiesSupportsRaster()

Schema

ISchemaCapabilities schemaCapabilities = connSchemaCapabilities

DataType[] dataTypes = schemaCapabilitiesDataTypes

ClassType[] classTypes = schemaCapabilitiesClassTypes

string reservedCharactersForName = schemaCapabilitiesReservedChar

actersForName

int maximumDecimalPrecision = schemaCapabilitiesMaximumDecimalPre

cision

DataType[] supportedAutoGeneratedTypes = schemaCapabilitiesSuppor

tedAutoGeneratedTypes

DataType[] supportedIdentityPropertyTypes = schemaCapabilitiesSup

portedIdentityPropertyTypes

Boolean supportsAutoIdGeneration = schemaCapabilitiesSupportsAut

oIdGeneration

Data StoreThe Sql Server SQL Server Spatial Oracle MySQL PostGIS and SDF providerssupport the following data store commands create destroy and with theexception of SDF list SDF is a file-based provider and the rest areRDBMS-based

Data Store | 171

By default the Sql Server Oracle MySQL and SDF providers create data storesthat contain FDO metadata By default the SQL Server Spatial provider createsa data store that does not contain the FDO metadata To make this providercreate a data store that does contain the FDO metadata you must set theIDataStorePropertyDictionary property IsFdoEnabled to true The PostGISprovider creates a data store without the FDO metadata

A provider uses the FDO metadata to

Assign a default spatial context to a Geometric Property Definition duringschema creation

When connected to the SDF Provider the CreateDataStore command createsan SDF file and the DestroyDataStore command deletes it There cannot bemultiple data stores in an SDF file and so there is no need for the list commandUnlike the RDBMS-based providers you do not have to open a pendingconnection in order to create and execute the CreateDataStore commandBefore executing the DestroyDataStore command close the connection

For the RDBMS-based providers creating a data store means creating a containerwithin a database There can be many data stores within a database and thelist command lists them

To create a data store in one of these RDBMS-based providers you open apending connection using an administrator account name and password andthen execute the CreateDataStore command Once you have created the datastore you close the administrator connection and open a normal userconnection This time you give a value to the DataStore connection parameterand open the connection to a fully operational state Before executing theDestroyDataStore command close the connection unset the DataStoreconnection parameter and reopen it using the administrator account nameand password in the pending state

C

The following namespaces are used

OSGeoFDOCommandsDataStore

OSGeoFDOCommands

172 | Chapter 13 FDO Cookbook

ICreateDataStore createDS = connCreateCommand(CommandTypeCom

mandType_CreateDataStore) as ICreateDataStore

IDataStorePropertyDictionary properties = createDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

createDSExecute()

IListDataStores listDS = connCreateCommand(CommandTypeCommand

Type_ListDataStores) as IListDataStores

IDataStoreReader reader = listDSExecute()

IDestroyDataStore destroyDS = connCreateCommand(CommandTypeCom

mandType_DestroyDataStore) as IDestroyDataStore

IDataStorePropertyDictionary properties = destroyDSDataStoreProp

erties

propertiesSetProperty(paramName paramValue)

destroyDSExecute()

User ManagementThe providers may be categorized into five groups with respect to usermanagement The grouping criteria is the method used to create the username

The first group consists of the AutodeskOracle provider which has access toan FDO API for user management

The second group consists of MySQL SqlServer and SQLServerSpatial Theseproviders support the SQLCommand which can be used to create users

The third group consists of ODBC A username and password may be quiredto connect depending on the back-end data store On XP you use the ODBCData Source Administrator tool to configure the username

The third group consists of the web server providers WFS and WMS Ausername and password may be required depending on the site

The fourth group consists of the file-based providers which do not require ausername and password

The FDO User Management API

The AutodeskOracle provider has access to an FDO API for user managementBefore you can add a user you must have added the f_user_role to the databaseas described in the Preparations topic at the beginning of this chapter Duringthe add user operation the f_user_role is assigned to the new user You must

User Management | 173

open a pending connection using an administrator account name and passwordto add or drop a user

C

The AutodeskFdoFdoUtilitiesUserMgr namespace is used

IUserManagerImp userMgr = new IUserManagerImp(connection)

userMgrAddUser(AUserName APassword)

DbUserReader reader = userMgrGetDbUsers()

userMgrDropUser(AUserName)

The SQLCommand Method for User Management

List usersDrop a userAdd a userProvider

SELECT user FROM mysqluserWHERE user = lsquoAUserNamersquo

DROP USER lsquoAUser-Namersquo

CREATE USER lsquoAUserNamersquoIDENTIFIED BY lsquoAPasswordrsquo

MySQL

GRANT ALL ON TO lsquoAUs-erNamersquo

SELECT name FROM sysserv-er_principals WHERE name =lsquoAUserNamersquo

EXEC sp_droploginloginame = lsquoAUser-Namersquo

CREATE LOGIN AUserNameWITH password = lsquoAPass-wordrsquo EXEC sp_addsrvrole-

SqlServer andSQLServerSpa-tial

member loginame = lsquoAUs-erNamersquo rolename =lsquosysadminrsquo

C

The code samples use the SQL syntax supported by MySQL in the stringspassed to the FDO API command calls

The following namespaces are used

OSGeoFDOCommandsSQL

OSGeoFDOCommands

174 | Chapter 13 FDO Cookbook

create a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = create user AUserName identified by

APassword

int returnVal = sqlCommandExecuteNonQuery()

sqlCommandSQLStatement = grant all on to AUserName

returnVal = sqlCommandExecuteNonQuery()

drop a user

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = drop user AUserName

int returnVal = sqlCommandExecuteNonQuery()

list users

ISQLCommand sqlCommand = connCreateCommand(CommandTypeCommand

Type_SQLCommand) as ISQLCommand

sqlCommandSQLStatement = select user from mysqluser where user

= AUserName

ISQLDataReader reader = sqlCommandExecuteReader()

readerClose()

Spatial ContextA spatial context specifies a coordinate system and an extent for a set ofgeometries The spatial context object has a Name property The value of theName property is assigned to the SpatialContextAssociation property of theGeometricPropertyDefinition object that defines a feature or non-featuregeometry belonging to a feature class In this way a coordinate system andextent is associated with geometry values inserted into the data store as partof instances of the class Example code showing this association is containedin the Basic Schema Operations on page 178 topic

NOTE It is worth emphasizing that each geometric property definiton in a featureclass definition can have a different spatial context This mechanism replaces thatof the active spatial context

The data stores created by the Oracle Sql Server MySQL and optionally theSQL Server Spatial providers contain metadata that supports the assignmentof a default spatial context to a Geometric Property Definition during schema

Spatial Context | 175

creation in the event that the user has not explicitly assigned one The attributevalues of the default spatial context are set out in the following table

ValueAttribute

DefaultName

ltno valuegtCoordinateSystem

ltno valuegtCoordinateSystemWkt

SpatialContextExtentType_StaticExtentType

POLYGON((-2000000 -2000000 2000000 -20000002000000 2000000 -2000000 2000000 -2000000 -2000000))

Extent

C

The code samples show how to create a spatial context and how to get thespatial contexts from a data store

The following namespaces are used

OSGeoFDOCommandsSpatialContext

OSGeoFDOGeometry

OSGeoFDOConnections

176 | Chapter 13 FDO Cookbook

get the spatial contexts from a data store

IGetSpatialContexts getSpatialContexts = connectionCreateCom

mand(CommandTypeCommandType_GetSpatialContexts) as IGetSpatialCon

texts

ISpatialContextReader reader = getSpatialContextsExecute()

string name = null

string coordSys = null

string wellKnownText = null

string desc = null

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IGeometry geom = null

string extent = null

SpatialContextExtentType extentType

double xyTolerance

double zTolerance

while (readerReadNext())

name = readerGetName()

coordSys = readerGetCoordinateSystem()

wellKnownText = readerGetCoordinateSystemWkt()

desc = readerGetDescription()

geom = geomFactoryCreateGeometryFromFgf(readerGetExtent())

extent = geomText

extentType = readerGetExtentType()

xyTolerance = readerGetXYTolerance()

zTolerance = readerGetZTolerance()

readerDispose()

Spatial Context | 177

create a spatial context whose coordinate system is WGS84 and

whose extent is the maximum

create the extent

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

ICreateSpatialContext createSpatialContext = connectionCreateCom

mand(CommandTypeCommandType_CreateSpatialContext) as ICreateSpa

tialContext

createSpatialContextCoordinateSystem =

createSpatialContextCoordinateSystemWkt = wgs84Wkt

createSpatialContextDescription = This Coordinate System is used

for GPS

a static extent is defined once and never changed

a dynamic extent grows to accommodate the geometries added to

the data store

createSpatialContextExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

createSpatialContextExtent = extent

the value of Name is assigned to the SpatialContextAssociation

attribute of a GeometricPropertyDefinition object during the

creation of the logical feature schema

in this way a coordinate system and extent is associated with

the geoemtries

createSpatialContextName = WGS84 Spatial Context

createSpatialContextExecute()

Basic Schema OperationsAll providers allow you to describe a schema but only SDF SHP MySQLPostGIS SqlServer SQLServerSpatial KingOracle and Oracle allow you toapply and destroy a schema

178 | Chapter 13 FDO Cookbook

C

The code samples show how to describe apply and destroy a schema

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommands

OSGeoFDOSchema

describe a schema

IDescribeSchema descSchema = connCreateCommand(CommandTypeCom

mandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

FeatureSchema schema = schemas[0]

ClassCollection classes = schemaClasses

Class featureClass = classes[0]

PropertyDefinitionCollection properties = featureClassProperties

PropertyDefinition property = properties[0]

PropertyType propertyType = propertyPropertyType

if (propertyType == PropertyTypePropertyType_DataProperty)

DataPropertyDefinition dataPropDef = property as DataPropertyDefin

ition

DataType dataType = dataPropDefDataType

Basic Schema Operations | 179

create and apply a schema

FeatureSchema schema = new FeatureSchema(AnApplicationSchema

This schema contains one feature class)

FeatureClass featClass = new FeatureClass(AFeatureClass This

feature class contains one identity property one data property and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(ID

This is the identity property)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = true

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition int32Prop = new DataPropertyDefini

tion(Int32Prop This is an Int32 property)

int32PropDataType = DataTypeDataType_Int32

propertiesAdd(int32Prop)

add the feature geometry

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(FeatGeomProp This is the feature geometry)

associate this geometric property with a spatial context

you must have already added the named context to the data store

if this property is not set it is assigned the default spatial

context

see the Spatial Context topic to read a description of the de

fault spatial context

featGeomPropSpatialContextAssociation = XY-M Spatial Context

by default this geometric property can contain geometries that

may be classified as point curve surface or solid

also by default this geometric property cannot contain geomet

ries that have a Z ordinate or a measure attribute

propertiesAdd(featGeomProp)

without the following line you would be adding a non-feature

geometry

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

apply the schema

180 | Chapter 13 FDO Cookbook

IApplySchema applySchema = connCreateCommand(CommandTypeCommand

Type_ApplySchema) as IApplySchema

applySchemaFeatureSchema = schema

applySchemaExecute()

destroy the schema

IDestroySchema destroySchema = connCreateCommand(CommandTypeCom

mandType_DestroySchema) as IDestroySchema

destroySchemaSchemaName = AnApplicationSchema

destroySchemaExecute()

Insert DataAll providers except Gdal Raster WFS and WMS allow you to insert data

C

The code sample shows how to insert a feature consisting of a data value anda geometry value

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOGeometry

Insert Data | 181

Identifier className = new Identifier(FeatureClass)

IInsert insert = connCreateCommand(CommandTypeCommandType_Insert)

as IInsert

insertFeatureClassName = className

PropertyValueCollection values = insertPropertyValues

add the Int32 value to the insert command

int32Value = new Int32Value(5)

int32PropVal = new PropertyValue(Int32Prop int32Value)

valuesAdd(int32PropVal)

add the feature geometry to the insert command

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

DirectPositionImpl position1 = new DirectPositionImpl(10 10)

IPoint point = geomFactoryCreatePoint(position1)

GeometryValue geomVal = new GeometryValue(geomFactoryGet

Fgf(point))

PropertyValue geomPropVal = new PropertyValue(FeatGeomProp

geomVal)

valuesAdd(geomPropVal)

insert the feature

IFeatureReader reader = insertExecute()

readerClose()

Select DataAll providers allow you to select data

C

In the following code sample the filter is set to retrieve values for each featurein the database Without adding a computed identifier to the select commandrsquosproperty collection the select command would return all of the propertyvalues for each feature in the database In this example the computed identifiercontains a function expression that converts the DateTime value in theDateTimeProp property to a string and returns the string So the select returnsa set of DateTime strings

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

182 | Chapter 13 FDO Cookbook

OSGeoFDOFilter

Identifier className = new Identifier(FeatureClass)

ISelect select = connCreateCommand(CommandTypeCommandType_Select)

as ISelect

selectFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectFilter = filter

ComputedIdentifier computedId = ExpressionParse((ToString(Date

TimeProp) as computedId)) as ComputedIdentifier

selectPropertyNamesAdd(computedId)

IFeatureReader reader = selectExecute()

readerClose()

Select Aggregate DataAll providers except the PostGIS provider allow you to select aggregate data

C

In the following code sample the filter is set to retrieve values for each featurein the database The computed identifier contains a function expression thattakes the average of all of the values in the property whose name is Int32Propand returns a double

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

Select Aggregate Data | 183

Identifier className = new Identifier(FeatureClass)

ISelectAggregates selectAggregates = connCreateCommand(Command

TypeCommandType_SelectAggregates) as ISelectAggregates

selectAggregatesFeatureClassName = className

Filter filter = FilterParse(ID gt= 0)

selectAggregatesFilter = filter

ComputedIdentifier computedId = ExpressionParse((Avg(Int32Prop)

as computedId)) as ComputedIdentifier

selectAggregatesPropertyNamesAdd(computedId)

IDataReader reader = selectAggregatesExecute()

readerClose()

Delete DataAll providers except Gdal Raster WFS and WMS allow you to delete data

C

The following namespaces are used

OSGeoFDOCommands

OSGeoFDOCommandsFeature

OSGeoFDOExpression

OSGeoFDOFilter

delete all of the data

ID is the name of the identity property

Filter filter = FilterParse(ID gt= 0)

Identifier className = new Identifier(FeatureClass)

IDelete delete = connCreateCommand(CommandTypeCommandType_Delete)

as IDelete

deleteFeatureClassName = className

deleteFilter = filter

int numDeleted = deleteExecute()

Schema OverridesWhen FDO connects to a datastore with an existing schema and describes theschema it maps the native data types to FDO data types to create a default

184 | Chapter 13 FDO Cookbook

physical to logical schema mapping You can create a schema mapping thatoverrides the default FDO mapping This schema override must be appliedevery time that you connect to the data store Use the providerrsquos SchemaOverride API to write a program that defines the overrides and writes themto an XML configuration file Thereafter before opening the connection tothe provider set the connection objectsrsquos configuration property to point tothe XML configuration file

The key elements to a schema override are an FDO feature schema and amapping of column names in the existing table to property names in the FDOfeature schema The ODBC provider supports the mapping of two columnnames in an existing table to a 2D FDO point geometry property and optionallysupports the mapping of three columns to a 3D point geometry property Inthe event that the mapping includes an FDO geometry property a spatialcontext definition should be provided

The description given here is based on sample code written to define a schemaoverride for a table in a Microsoft Access database The following table showsthe name of the column in the Access database which is the same as thedefault FDO property name the FDO property name assigned by the schemaoverride a description of the contents of the column the FDO data typeassigned by the default schema mapping and the FDO data type assigned bythe schema override

The default schema mapping of the CITY_ID and POPULATION columns areoverriden to assign them different data types than the default ones and togive them different names A change in case counts as a change in name Thedefault schema mapping of the LATITUDE and LONGITUDE columns areoverriden because they are combined into a single property that has a differentname and a different type than the defaults The default schema mapping ofthe NAME COUNTRY and CAPITAL columns are overriden to assign themdifferent names than the defaults The default schema mapping of the URLcolumn is not overriden and retains its default type and name

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

Int64Int16consecutive sequence of integersfrom 1 to lt 1000

IdCITY_ID

StringStringNamesNameNAME

StringStringNamesCountryCOUNTRY

Schema Overrides | 185

OverrideFDO DataType

Default FDOData Type

Column ContentsOverridePropertyName

Column Name(Default PropertyName)

StringStringlsquoNrsquo or lsquoYrsquoCaptialCAPITAL

Not over-riden

StringnullNot over-riden

URL

Int32Doublepositive integers lt 17000000PopulationPOPULATION

GeometryDoublepositive and negative decimalsGeometryLATITUDE

GeometryDoublepositive and negative decimalsGeometryLONGITUDE

First a conceptual view of how to create the XML configuration file for aschema override is presented and then a code view is presented The overrideincludes a geometry property and so a spatial context is defined as well

1 Open the XML file

2 Create a spatial context for the geometry and write it to the XML file

3 Create the FDO feature schema and write it to the XML file

4 Create a connection to the provider and get a reference to theconnectionrsquos physical schema mapping

5 Use the reference to the connectionrsquos physical schema mapping and theSchema Override API to create the schema override whereby the logicalfields in the feature schema are associated with columns in the databasetable

6 Write the schema override to the XML file

7 Close the XML file

C

The following namespaces are used

OSGeoFDOCommonIo

OSGeoFDOCommonXml

186 | Chapter 13 FDO Cookbook

OSGeoFDOGeometry

OSGeoFDOSchema

Create the XML Schema Override Configuration File

Open the XML File

IoFileStream writeFileStream = new IoFileStream(Citiesxml w)

XmlWriter writer = new XmlWriter(writeFileStream)

Create a Spatial Context and Write It to the XML File

XmlSpatialContextFlags flags = new XmlSpatialContextFlags()

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(writer flags)

DirectPositionImpl lowerLeft = new DirectPositionImpl()

lowerLeftX = -1800

lowerLeftY = -900

DirectPositionImpl upperRight = new DirectPositionImpl()

upperRightX = 1800

upperRightY = 900

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

IEnvelope envelope = geomFactoryCreateEnvelope(lowerLeft upper

Right)

IGeometry geom = geomFactoryCreateGeometry(envelope)

byte[] extent = geomFactoryGetFgf(geom)

spatialContextWriterCoordinateSystem = WGS 84

spatialContextWriterCoordinateSystemWkt = GEOGCS [ Longitude

Latitude (WGS 84) DATUM [WGS 84 SPHEROID [WGS 84

6378137 298257223563]] PRIMEM [ Greenwich 0000000 ] UNIT

Decimal Degree 001745329251994330]]

spatialContextWriterDescription = This Coordinate System is used

for GPS

spatialContextWriterExtentType = SpatialContextExtentTypeSpatial

ContextExtentType_Static

spatialContextWriterExtent = extent

spatialContextWriterName = WGS84

spatialContextWriterXYTolerance = 0001

the next line writes the XML declaration the opening tag for

the fdoDataStore element

and the gmlDerivedCRS element to the XML file

spatialContextWriterWriteSpatialContext()

Schema Overrides | 187

Create the Feature Schema and Write It to the XML File

188 | Chapter 13 FDO Cookbook

FeatureSchema schema = new FeatureSchema(World Logical feature

schema)

FeatureClass featClass = new FeatureClass(Cities This feature

class contains one identity property many data properties and

a feature geometry)

PropertyDefinitionCollection properties = featClassProperties

DataPropertyDefinitionCollection idProperties = featClassIdenti

tyProperties

DataPropertyDefinition idProp = new DataPropertyDefinition(Id

This is the unique id number for the city)

idPropDataType = DataTypeDataType_Int64

idPropIsAutoGenerated = false

idPropNullable = false

idPropReadOnly = true

propertiesAdd(idProp)

idPropertiesAdd(idProp)

DataPropertyDefinition nameProp = new DataPropertyDefini

tion(Name This is the name of the City)

namePropDataType = DataTypeDataType_String

namePropLength = 64

propertiesAdd(nameProp)

DataPropertyDefinition countryProp = new DataPropertyDefini

tion(Country This is country that contains the city)

countryPropDataType = DataTypeDataType_String

countryPropLength = 64

propertiesAdd(countryProp)

DataPropertyDefinition populationProp = new DataPropertyDefini

tion(Population This is the population of the city)

populationPropDataType = DataTypeDataType_Int32

propertiesAdd(populationProp)

DataPropertyDefinition capitalProp = new DataPropertyDefini

tion(Capital This is Y or N to say whether the city is the

capital of the country)

capitalPropDataType = DataTypeDataType_String

capitalPropLength = 1

propertiesAdd(capitalProp)

GeometricPropertyDefinition featGeomProp = new GeometricProperty

Definition(Geometry This is the feature geometry)

featGeomPropGeometryTypes = (int)GeometricTypeGeometric

Type_Point

featGeomPropHasElevation = false

featGeomPropHasMeasure = false

propertiesAdd(featGeomProp)

Schema Overrides | 189

featClassGeometryProperty = featGeomProp

ClassCollection classes = schemaClasses

classesAdd(featClass)

the next line writes the xsschema element to the XML file

schemaWriteXml(writer)

190 | Chapter 13 FDO Cookbook

Create the Physical Schema Mapping and Write It to the XML File

Schema Overrides | 191

set the connection to point

at the Microsoft Access database file

whose Data Source Name (DSN) has been

defined using the Data Sources (ODBC)

Windows XP administrative tool

connectionConnectionString = DataSourceName= + dataSourceName

get a reference to the PhysicalSchemaMapping object contained

in the connection

PhysicalSchemaMapping connectionSchemaMapping = connectionCreateS

chemaMapping()

use that reference to create an override physical schema mapping

the override definition associates columns in the columns of

the Access database with property names in the FDO feature schema

OvPhysicalSchemaMapping mapping = new OvPhysicalSchemaMapping(con

nectionSchemaMapping false)

mappingName = World

OvClassCollection overrideClasses = mappingClasses

OvClassDefinition overrrideClassDef = new OvClassDefinition(Cit

ies)

OvPropertyDefinitionCollection overrideProperties = overrride

ClassDefProperties

associate the table in the Access database with the override

class definition

OvTable table = new OvTable(Cities)

overrrideClassDefTable = table

associate the columns in the table in the Access database with

the properties in the FDO feature schema

OvColumn column = null

OvGeometricPropertyDefinition overridGeomProp = new OvGeometric

PropertyDefinition(Geometry)

overridGeomPropGeometricColumnType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricColumnTypeOvGeometricColumnType_Double

overridGeomPropGeometricContentType = OSGeoFDOProvidersRd

bmsOverrideOvGeometricContentTypeOvGeometricContentType_Ordin

ates

overridGeomPropXColumnName = LONGITUDE

overridGeomPropYColumnName = LATITUDE

overridePropertiesAdd(overridGeomProp)

OvDataPropertyDefinition overrideIdProp = new OvDataPropertyDefin

ition(Id)

column = new OvColumn(CITY_ID) overrideIdPropColumn = column

overridePropertiesAdd(overrideIdProp)

192 | Chapter 13 FDO Cookbook

OvDataPropertyDefinition overrideNameProp = new OvDataPropertyDefin

ition(Name)

column = new OvColumn(NAME)

overrideNamePropColumn = column

overridePropertiesAdd(overrideNameProp)

OvDataPropertyDefinition overrideCountryProp = new OvDataProperty

Definition(Country)

column = new OvColumn(COUNTRY)

overrideCountryPropColumn = column

overridePropertiesAdd(overrideCountryProp)

OvDataPropertyDefinition overridePopulationProp = new OvDataProp

ertyDefinition(Population)

column = new OvColumn(POPULATION)

overridePopulationPropColumn = column

overridePropertiesAdd(overridePopulationProp)

OvDataPropertyDefinition overrideCapitalProp = new OvDataProperty

Definition(Capital)

column = new OvColumn(CAPITAL)

overrideCapitalPropColumn = column

overridePropertiesAdd(overrideCapitalProp)

overrideClassesAdd(overrideClassDef)

write the override definition to the XML file

XmlFlags flags = new XmlFlags()

the next line writes the SchemaMapping element to the XML file

mappingWriteXml(writer flags)

mappingDispose()

Write the Closing Tag and Close the XML File

the next line writes the closing tag of the fdoDataStore ele

ment to the XML file

writerWriteEndElement()

writerClose()

writerDispose()

writeFileStreamClose()

writeFileStreamDispose()

Configure a Connection to Use the Schema Override

The connection object contains a property whose value points to the XMLconfiguration file

Schema Overrides | 193

IConnection connection = connMgrCreateConnection(providerName)

IoFileStream configurationFileStream = new IoFileStream(Cit

iesxml r)

connectionConfiguration = configurationFileStream

connectionConnectionString = DataSourceName= + dataSourceName

connectionOpen()

Xml SerializeDeserializeThis code sample serializes the spatial context and feature schema of a datastore to an xml file and then deserializes it in another data store

C

This is the C code

Namespaces

The following namespaces are used

OSGeoFDOCommandsSchema

OSGeoFDOCommonIo

OSGeoFDOCommonXml

OSGeoFDOSchema

OSGeoFDOXml

194 | Chapter 13 FDO Cookbook

Serialize

open the xml file

XmlWriter xmlWriter = new XmlWriter(xmlFilename)

serial the spatial contexts

XmlSpatialContextWriter spatialContextWriter = new XmlSpatialCon

textWriter(xmlWriter)

XmlSpatialContextSerializerXmlSerialize(connection spatialContex

tWriter)

serialize the feature schemas

IDescribeSchema descSchema = connectionCreateCommand(Command

TypeCommandType_DescribeSchema) as IDescribeSchema

FeatureSchemaCollection schemas = descSchemaExecute()

schemasWriteXml(xmlWriter)

clean up

spatialContextWriterDispose()

xmlWriterDispose()

C | 195

Deserialize

deserialize the spatial contexts

IoFileStream fileStream = new IoFileStream(xmlFilename r)

XmlReader xmlReader = new XmlReader(fileStream)

XmlSpatialContextReader xScReader = new XmlSpatialContextReader(xm

lReader)

XmlSpatialContextSerializerXmlDeserialize(connection xScReader)

fileStreamReset()

deserialize the schema

FeatureSchemaCollection schemas = new FeatureSchemaCollec

tion(null)

schemasReadXml(fileStream)

IApplySchema applySchema = connectionCreateCommand(CommandTypeCom

mandType_ApplySchema) as IApplySchema

FeatureSchema schema = null

for (int i = 0 i lt schemasCount i++)

schema = schemasget_Item(i)

applySchemaFeatureSchema = schema

applySchemaExecute()

fileStreamReset()

clean up

xmlReaderDispose()

fileStreamClose()

GeometryThe geometry code samples are divided into two parts The first is constructinggeometries The second is deconstructing them that is extracting informationfrom the geometry objects

Construction

Geometries can be constructed using a set of scaffolding classes which includesa geometry factory class or they can be constructed using the geometry factoryclass from text specifications The syntax for the text specifications is describedin the Geometry Value section in the Filter and Expression Languages chapter

196 | Chapter 13 FDO Cookbook

What follows here is a description of geometry construction using thescaffolding classes

Some geometries are constructed using a two step procedure First createcoordinates and then create the geometry Some geometries require anintermediate step Use the coordinates to create subcomponents and then usethe subcomponents to create the geometry The construction of somegeometries requires the use of helper collection classes Some of these classesare collections of geometries and some are collections of geometrysubcomponents

Simple geometries like point and line are constructed directly from coordinatesComplex geometries like curved lines and polygons are constructed fromgeometry subcomponents like arc and line segments and rings In generalsubcomponents are constructed from coordinates The exception is the ringwhich is constructed from arc and line segments The glue is the helpercollection classes for coordinates segments and rings

A geometry object may consist of homogeneous or heterogeneous aggregationsof points lines and polygons The glue is helper collection classes for pointslines and polygons

C Namespaces

The following namespaces are used

OSGeoFDOCommon

OSGeoFDOGeometry

C Geometry Scaffolding Classes

The scaffolding classes used to construct the simple complex and aggregategeometries are the following

the IDirectionPosition class used to construct positions (coordinates)

the FgfGeometryFactory class used to construct the geometrysubcomponents and geometries

the geometry subcomponent classes ILineStringSegmentICircularArcSegment ILinearRing and IRing

Construction | 197

the helper collection classes PointCollection LineStringCollectionCurveSegmentCollection LinearRingCollection RingCollectionPolygonCollection CurvePolygonCollection and GeometryCollection

IDirectPositionImpl

The IDirectPosition is the basic building block of geometries Use its constructorto define a coordinate Use instances of it to define the IPoint and ILineStringgeometries or to define the geometry subcompoonents ILinearRingICircularArcSegment and ILineStringSegment

DirectPositionImpl pos00 = new DirectPositionImpl(00 00)

FgfGeometryFactory

Use an instance of this class to do the following

create geometry subcomponents used to construct IGeometry-based objects

create IGeometry-based objects

convert IGeometry-based objects into binary-formatted geometries usedfor data store inserts

convert binary-formatted geometries retrieved during data store queriesinto IGeometry-based objects

FgfGeometryFactory geomFactory = new FgfGeometryFactory()

Geometry Subcomponents

The following subcomponents are used in the construction of geometries andgeometry subcomponents

The ICircularArcSegment and ILineStringSegment subcomponents are usedto construct the ICurveString geometry and the IRing geometrysubcomponent

The ILinearRing subcomponent is used to contruct the IPolygon geometry

The IRing subcomponent is used to construct the ICurvePolygon geometry

198 | Chapter 13 FDO Cookbook

ICircularArcSegment

The creation of an instances uses IDirectPositionImpl objects whichrespectively define a start position a mid point and an end position for thearc

ICircularArcSegment as012122 = geomFactoryCreateCircularArcSeg

ment(pos01 pos21 pos22)

ILineStringSegment

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos23)

positionsAdd(pos30)

positionsAdd(pos33)

ILineStringSegment ls233033 = geomFactoryCreateLineStringSeg

ment(positions)

positionsClear()

ILinearRing

The creation of an instance uses a DirectPositionCollection which containsIDirectionPositionImpl objects

positionsAdd(pos01)

positionsAdd(pos21)

positionsAdd(pos12)

positionsAdd(pos01)

ILinearRing lr01211201 = geomFactoryCreateLinearRing(positions)

positionsClear()

IRing

An IRing is constructed using a CurveSegmentCollection This collection cancontain ICircularArcSegment and ILineStringSegment objects

curveSegmentsAdd(as1340n20)

curveSegmentsAdd(lsn2013)

IRing rAs1340n20Lsn2013 = geomFactoryCreateRing(curveSegments)

curveSegmentsClear()

Construction | 199

Collection Classes

The following collection classes are used during the construction of the variousgeometries

Contains IDirectPositionImpl ojbects

DirectPositionCollection positions = new DirectPositionCollec

tion()

Contains IPoint objects

PointCollection points = new PointCollection()

Contains ILineString objects

LineStringCollection lines = new LineStringCollection()

Contains ICircularArcSegment and ILineStringSegment objects

CurveSegmentCollection curveSegments = new CurveSegmentCollec

tion()

Contains ICurveString objects

CurveStringCollection curves = new CurveStringCollection()

Contains ILinearRing objects

LinearRingCollection linearRings = new LinearRingCollection()

Contains IRing objects

RingCollection curveRings = new RingCollection()

Contains IPolygon objects

PolygonCollection linearPolygons = new PolygonCollection()

Contains ICurvePolygon objects

CurvePolygonCollection curvePolygons = new CurvePolygonCollec

tion()

GeometryCollection geometries = new GeometryCollection()

C Geometries Constructed usingIDirectPositionImpl

These geometries are IPoint and ILineString

IPoint

The creation of an instances uses an IDirectionPositionImpl object

IPoint pt00 = geomFactoryCreatePoint(pos00)

200 | Chapter 13 FDO Cookbook

ILineString

The creation of an instances uses a DirectPositionCollection object which iscomposed of IDirectionPositionImpl object

positionsAdd(pos01)

positionsAdd(pos21)

ILineString line0121 = geomFactoryCreateLineString(positions)

positionsClear()

C Geometries Constructed Using GeometrySubcomponents

These geometries are ICurveString IPolygon and ICurvePolygon

ICurveString

The creation of an instance uses a CurveSegmentCollection object whichcontains an ICircularArcSegment object and an ILineStringSegment object

ICurveString composed of a circular arc segment and a line

string segment

curveSegmentsAdd(as022223)

curveSegmentsAdd(ls233033)

ICurveString csAs022223Ls233033 = geomFactoryCreateCur

veString(curveSegments)

curveSegmentsClear()

IPolygon

The creation of an instance uses an ILinearRing object for the exterior ringand a LinearRingCollection object composed of ILinearRing objects for theinterior rings

IPolygon with one exterior ring and no interior rings

IPolygon polyEr01211201 = geomFactoryCreatePolygon(lr01211201

null)

IPolygon with one exterior ring and one interior ring

linearRingsAdd(lr01211201)

polyEr13n204013Ir01211201 = geomFactoryCreatePolygon(lr13n204013

linearRings)

linearRingsClear()

Construction | 201

ICurvePolygon

The creation of an instance uses an IRing object for the exterior ring and aRingCollection object composed of an IRing object for the interior rings

ICurvePolygon with one exterior ring rAs1340n20Lsn2013 which

is composed of an arc segment and a line segment

and one interior ring rLs0121Ls2112Ls1201 which is a triangle

made of three line segments

curveRingsAdd(rLs0121Ls2112Ls1201)

ICurve Polygon curvPolyErAs1340n20Lsn2013IrLs0121Ls2112Ls1201 =

geomFactoryCreateCurvePolygon(rAs1340n20Lsn2013 curveRings)

curveRingsClear()

C Aggregate Geometries

The aggregate geometries are IMultiPoint IMultiLineString IMultiCurveStringIMultiPolygon IMultiCurvePolygon and IMultiGeometry

IMultiPoint

The creation of an instance uses a PointCollection object

pointsAdd(pt00)

pointsAdd(pt11)

IMultiPoint pt00pt11 = geomFactoryCreateMultiPoint(points)

pointsClear()

IMultiLineString

The creation of an instance uses a LineStringCollection object

linesAdd(line0121)

linesAdd(line0222)

IMultiLineString line0121line0222 = geomFactoryCreateMultiLineS

tring(lines)

linesClear()

IMultiCurveString

The creation of an instance uses a CurveStringCollection object

202 | Chapter 13 FDO Cookbook

curvesAdd(csAs012122)

curvesAdd(csAs022223Ls233033)

IMultiCurveString aMultiCurvePolygon = geomFactoryCreateMultiCur

veString(curves)

curvesClear()

IMultiPolygon

The creation of an instance uses a PolygonCollection object

linearPolygonsAdd(polygonNum1)

linearPolygonsAdd(polygonNum2)

IMultiPolygon aMultiPolygon = geomFactoryCreateMultiPolygon(lin

earPolygons)

linearPolygonsClear()

IMultiCurvePolygon

The creation of an instance uses a CurvePolygonCollection object

curvePolygonsAdd(curvePolygonNum1)

curvePolygonsAdd(curvePolygonNum2)

IMultiCurvePolygon aMultiCurvePolygon = geomFactoryCreateMultiC

urvePolygon(curvePolygons)

curvePolygonsClear()

IMultiGeometry

The creation of an instance uses a GeometryCollection object

geometriesAdd(aPoint)

geometriesAdd(aMultiPoint)

geometriesAdd(aLineString)

geometriesAdd(aMultiLineString)

geometriesAdd(aCurveString)

geometriesAdd(aMultiCurveString)

geometriesAdd(aPolygon)

geometriesAdd(aMultiPolygon)

geometriesAdd(aCurvePolygon)

geometriesAdd(aMultiCurvePolygon)

IMultiGeometry aMultiGeometry = geomFactoryCreateMultiGeometry(geo

metries)

geometriesClear()

Construction | 203

C Geometries from Text Specifications

You can use the geometry factoryrsquos CreateGeometry method to creategeometries from text specifications Herersquos an IPoint example

IPoint pt11 = geomFactoryCreatePoint(pos11)

IPoint aSecondPt11 = geomFactoryCreateGeometry(pt11Text) as

IPoint

aThirdPt11 = geomFactoryCreateGeometry(POINT (1 1)) as IPoint

Deconstruction

Deconstruction means getting information such as dimensionality envelopetext specification geometry geometry subcomponents and positions(coordinates) The following table specifies the information available fromthe classes

Position means coordinate values Dimensionality values are XY XYZ XYMor XYZM Envelope means bounding rectangle The envelope for an aggregategeometry contains all of the included geometries Text means FGF well-knowntext specification IsClosed is a boolean specifying whether or not the startand end coordinates are identical

Information availableClass

position dimensionalityIDirectPosition

position dimensionality envelope textIPoint

dimensionality envelope text IPointIMultiPoint

position dimensionality envelope textILineString

dimensionality envelope text ILineStrinIMultiLineString

IsClosed position dimensionality envelopeILineStringSegment

IsClosed position dimensionality envelopeICircularArcSegment

204 | Chapter 13 FDO Cookbook

Information availableClass

position dimensionality envelope text ICircularArcSegment ILineStringSegmentICurveString

dimensionality envelope text ICurveStringIMultiCurveString

position dimensionality envelopeILinearRing

dimensionality envelope text ILinearRingIPolygon

dimensionality envelope text IPolygonIMultiPolygon

position dimensionality ICircularArcSegment ILineStringSegmentIRing

dimensionality envelope text IRingICurvePolygon

dimensionality envelope text ICurvePolygonIMultiCurvePolygon

dimensionality envelope text IPoint IMultiPoint ILineString IMultiLineStringICurveString IMultiCurveString IPolygon IMultiPolygon ICurvePolygon IMulti-CurvePolygon

IMultiGeometry

Coordinates

IDirectPosition aPosition

double X = aPositionX

double Y = aPositionY

double Z

double M

int dim = aPositionDimensionality

if ((dim amp 1) == 1)

Z = aPositionZ

if ((dim amp 2) == 2)

M = aPositionM

Deconstruction | 205

IDirectPosition (IPoint ILineString ICircularArcSegmentILineStringSegment ILinearRing)

IPoint aPoint

IDirectPosition position = aPointPosition

ILineString line

IDirectPosition aPosition = null

IDirectPosition startPosition = lineStartPosition

IDirectPosition endPosition = lineEndPosition

for (int i = 0 i lt lineCount i++)

aPosition = lineget_Item(i)

ICircularArcSegment arcSegment

IDirectPosition startPosition = arcSegmentStartPosition

IDirectPosition midPoint = arcSegmentMidPoint

IDirectPosition endPosition = arcSegmentEndPosition

ILineStringSegment lineSegment

IDirectPosition startPosition = lineSegmentStartPosition

IDirectPosition endPosition = lineSegmentEndPosition

DirectPositionCollection positions = lineSegmentPositions

foreach(IDirectPosition position in positions)

ICurveString curve

IDirectPosition startPosition = curveStartPosition

IDirectPosition endPosition = curveEndPosition

ILinearRing linearRing

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

ILinearRing ring

IDirectPosition position = null

for (int i = 0 i lt ringCount i++)

position = ringget_Item(i)

Dimensionality Envelope and Text

int dimensionality = aPointDimensionality

IEnvelope envelope = aPointEnvelope

string text = aPointText

206 | Chapter 13 FDO Cookbook

IsClosed (ICircularArcSegment and ILineStringSegment)

ICircularArcSegment arcSegment

bool isClosed = arcSegmentIsClosed

ILineStringSegment lineSegment

bool isClosed = lineSegmentIsClosed

IPoint and IMultiPoint

IMultiPoint aMultiPoint

IPoint aPoint = null

for (int i = 0 i lt aMultiPointCount i++)

aPoint = aMultiPointget_Item(i)

ILineString and IMultiLineString

IMultiLineString aMultiLineString

ILineString line = null

for (int i = 0 i lt aMultiLineStringCount i++)

line = aMultiLineStringget_Item(i)

ICurveString and IMultiCurveString

IMultiCurveString aMultiCurveString

ICurveString curve = null

for (int i = 0 i lt aMultiCurveStringCount i++)

curve = aMultiCurveStringget_Item(i)

Deconstruction | 207

ICircularArcSegment and ILineStringSegment (ICurveString andIRing)

ICurveString aCurveString

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt aCurveStringCount i++)

curveSegment = aCurveStringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

IRing ring

ICurveSegmentAbstract curveSegment = null

ICircularArcSegment arcSegment = null

ILineStringSegment lineSegment = null

for (int i = 0 i lt ringCount i++)

curveSegment = ringget_Item(i)

if (curveSegmentDerivedType == GeometryComponentTypeGeometry

ComponentType_CircularArcSegment)

arcSegment = curveSegment as ICircularArcSegment

else if (curveSegmentDerivedType == GeometryComponentTypeGeo

metryComponentType_LineStringSegment)

lineSegment = curveSegment as ILineStringSegment

ILinearRing (IPolygon)

IPolygon aPolygon

ILinearRing anExteriorRing = aPolygonExteriorRing

ILinearRing anInteriorRing = null

for (int i = 0 i lt aPolygonInteriorRingCount i++)

anInteriorRing = aPolygonGetInteriorRing(i)

208 | Chapter 13 FDO Cookbook

IPolygon and IMultiPolygon

IMultiPolygon aMultiPolygon

IPolygon aPolygon = null

for (int i = 0 i lt aMultiPolygonCount i++)

aPolygon = aMultiPolygonget_Item(i)

IRing (ICurvePolygon)

ICurvePolygon aCurvePolygon

IRing anExteriorRing = aCurvePolygonExteriorRing

IRing anInteriorRing = null

for (int i = 0 i lt count i++)

anInteriorRing = aCurvePolygonget_InteriorRing(i)

ICurvePolygon and IMultiCurvePolygon

IMultiCurvePolygon aMultiCurvePolygon

ICurvePolygon aCurvePolygon = null

for (int i = 0 i lt aMultiCurvePolygonCount i++)

aCurvePolygon = aMultiCurvePolygonget_Item(i)

Deconstruction | 209

IMultiGeometry

IMultiGeometry aMultiGeometry

IGeometry geom = null

GeometryType geomType

IPoint pt = null

IMultiPoint mpt = null

ILineString line = null

IMultiLineString mline = null

ICurveString curve = null

IMultiCurveString mcurve = null

IPolygon poly = null

IMultiPolygon mpoly = null

ICurvePolygon curvPoly = null

IMultiCurvePolygon mCurvPoly = null

for (int i = 0 i lt aMultiGeometryCount i++)

geom = aMultiGeometryget_Item(i)

geomType = geomDerivedType

switch (geomType)

case GeometryTypeGeometryType_Point pt = geom as IPoint break

case GeometryTypeGeometryType_MultiPoint mpt = geom as IMulti

Point break

case GeometryTypeGeometryType_LineString line = geom as ILin

eString break

case GeometryTypeGeometryType_MultiLineString mline = geom as

IMultiLineString break

case GeometryTypeGeometryType_CurveString curve = geom as

ICurveString break

case GeometryTypeGeometryType_MultiCurveString mcurve = geom

as IMultiCurveString break

case GeometryTypeGeometryType_Polygon poly = geom as IPolygon

break

case GeometryTypeGeometryType_MultiPolygon mpoly = geom as

IMultiPolygon break

case GeometryTypeGeometryType_CurvePolygon curvPoly = geom as

ICurvePolygon break

case GeometryTypeGeometryType_MultiCurvePolygon mCurvPoly =

geom as IMultiCurvePolygon break

default break

210 | Chapter 13 FDO Cookbook

OSGeo FDO Provider forArcSDE

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ArcSDE

What Is FDO Provider for ArcSDEThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store A provider is a specific implementation of theFDO API that provides access to data in a particular data store ESRIreg ArcSDEreg

(Spatial Database Engine) is part of the ArcGIS 9 system ArcSDE manages theexchange of information between an (ArcGIS 9 Desktop) application and arelational database management system FDO Provider for ArcSDE provides FDOwith access to an ArcSDE 9-based data store which in this case must be Oracle9i (9206)

FDO Provider for ArcSDE SoftwareRequirements

Installed Components

FDO Provider for ArcSDE dynamically linked libraries are installed with the FDOSDK They are located in ltFDO SDK Install LocationgtFDObin You do nothave to do anything to make these DLLs visible

A

211

External Dependencies

The operation of FDO Provider for ArcSDE is dependent on the presence ofArcSDE 9 and a supported data source such as Oracle 9i in the networkenvironment The host machine running FDO Provider for ArcSDE must alsohave the required DLLs present which are available by installing either anArcGIS 91 Desktop application or the ArcSDE SDK For example the requiredDLLs are present if either ArcViewreg ArcEditorreg or ArcInforeg are installed Formore information about ArcGIS 91 Desktop applications and the ArcSDE SDKrefer to the ESRI documentation

Specifically in order for FDO Provider for ArcSDE to run three dynamicallylinked libraries sde91dll sg91dll and pe91dll are required and you mustensure that the PATH environment variable references the local foldercontaining these DLLs For example in Microsoft Windows if ArcGIS 91Desktop is installed to CProgram FilesArcGIS then the required ArcSDEbinaries are located at CProgram FilesArcGISArcSDEbin Similarly if theArcSDE SDK is installed to the default location then the required ArcSDEbinaries are located at CArcGisArcSDEbin The absence of thisconfiguration may cause the following exception message The ArcSDE runtimewas not found

FDO Provider for ArcSDE LimitationsThe FDO Provider for ArcSDE is based on a subset of the ArcSDE API Thissubset does not include the following

Raster functionality

Native ArcSDE metadata

The annotation data with the exception of the ANNO_TEXT column

ArcSDE LimitationsFDO Provider for ArcSDE must abide by limitations of the ArcSDE technologyto which it connects This section discusses these limitations

212 | Appendix A OSGeo FDO Provider for ArcSDE

Relative to ArcObjects API and ArcGIS Server API

The ArcSDE API does not support the following advanced functionality foundin the ArcObjects API and the newer ArcGIS Server API

Advanced geometries such as Bezier curves and ellipses

Relationships

Topology

Networks

Analysis

Linear referencing

Curved Segments

If ArcSDE encounters curved segments it will automatically tessellate themThis means that if you create a geometry containing an arc segment in anArcSDE table using ArcObjects API and then you try to read that geometryback using the ArcSDE API you will get a series of line segments thatapproximate the original arc segment That is you get an approximation ofthe original geometry

Locking and Versioning

ArcSDE permits row locks or table versioning provided that the ID columnwhich uniquely identifies the row is maintained by ArcSDE If there is no IDcolumn or the ID column is maintained by the user ArcSDE does not permitrow locking or table versioning to be enabled

NOTE In ArcSDE you can either lock rows in a table or version a table but youcannot do both at the same time To do either you must alter the tablersquosregistration

The following sections illustrate these three steps

1 The creation of a table

Relative to ArcObjects API and ArcGIS Server API | 213

2 The alteration of the table registration to identify one of the columndefinitions as the row ID column and to enable row locking

3 The alteration of the table registration to disable row locking and toenable versioning

Table Creation

The command is

sdetable -o create -t hassdemaintainedrowid -d name string(20)

fid integer(9) -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The Row Lock has no value and the value of Dependent Objects is None

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column

Row ID Column Type

Row Lock

Minimum Row ID

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Identity Row ID Column and Enable Row Locking

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -c fid -C sde -L

on -u t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

214 | Appendix A OSGeo FDO Provider for ArcSDE

NOTE The Row ID Column value is FID the Row ID Column Type value is SDEMaintained and the Row Lock value is Enable

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Enable

Minimum Row ID 1

Dependent Objects None

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

Disable Row Locking and Enable Versioning

The command is

sdetable -o alter_reg -t hassdemaintainedrowid -L off -V MULTI -u

t_user -p test

The output of the describe registration command (sdetable -o describe_reg)for this table is as follows

NOTE The ldquoRow Lockrdquo is ldquoNot Enablerdquo and ldquoDependent Objectsrdquo is ldquoMultiversionTablerdquo

Locking and Versioning | 215

Table Owner T_USER

Table Name HASSDEMAINTAINEDROWID

Registration Id 18111

Row ID Column FID

Row ID Column Type SDE Maintained

Row ID Allocation Many

Row Lock Not Enable

Minimum Row ID 1

Dependent Objects Multiversion Table

Dependent Object Names A18111 D18111

Registration Date 022405 130802

Config Keyword DEFAULTS

User Privileges SELECT UPDATE INSERT DELETE

Visibility Visible

FDO Provider for ArcSDE ConnectionThis information supplements the Establishing a Connection chapter Youconnect to an ArcSDE data store indirectly through the ArcSDE server Theunderlying data source for the data store is a database such as Oracle TheArcSDE server is connected to the data source and mediates the requests thatyou send it

You can connect to FDO Provider for ArcSDE in one step if you already knowthe name of the data store that you want to use Otherwise you must connectin two steps

The minimum required connection properties for the initial call to Open()are server instance username and password Multiple users can access thedata store However access is password-protected The server property is thename of the machine hosting the ArcSDE server The instance property actsas an index into an entry in the services file An entry contains port andprotocol information used to connect to the ArcSDE server On a Windowsmachine the services file is located in CWINDOWSsystem32driversetcAssuming that the instance name is ldquoesri_sderdquo an entry would look somethinglike this ldquoesri_sde 5151tcp ArcSDE Server Listening Portrdquo

An ArcSDE data source may contain more than one data store For the firstcall to Open() a data store name is optional If successful the first call toOpen() results in the data store parameter becoming a required parameter anda list of the names of the data stores in the data source becoming availableYou must choose a data store and call Open() again

216 | Appendix A OSGeo FDO Provider for ArcSDE

If the data source supports multiple data stores the list returned by the firstcall to Open() will contain a list of all of the data stores resident in the datasource Otherwise the list will contain one entry ldquoDefault Data Storerdquo

If you know the name of the data store you can provide it for the first call toOpen() and make the connection in one step

Data Type MappingsThis section shows the mappings from FDO data types to ArcSDE data typesto Oracle data types

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDataType_Boolean

Not supportedNot supportedFdoDataType_Byte

DATEdateFdoDataType_DateTime

Not supportedNot supportedFdoDataType_Decimal

NUMBER(388)double(388)FdoDataType_Double

NUMBER(4)integer(4)FdoDataType_Int16

NUMBER(10)integer(10)FdoDataType_Int32

Not supportedNot supportedFdoDataType_Int64

NUMBER(62)float(62) typicalFdoDataType_SingleNUMBER(n8)float(0ltnlt=6 oltmltDBMSLimit)) possible

VARCHAR2(ltlengthgt)string(ltlengthgt)FdoDataType_String

LONG RAWblobFdoDataType_BLOB

Not supportedNot supportedFdoDataType_CLOB

Data Type Mappings | 217

Oracle Column Typesdetable Column DefinitionFDO DataType

Not supportedNot supportedFdoDatatype_UniqueID

Creating a Feature SchemaThis section describes the creation of the SampleFeatureSchema which is theexample feature schema described in the Schema Management chapter It alsodescribes the creation of the OGC980461FS schema which is the schemadefined in the OpenGIS project document 98-046r1

FDO Provider for ArcSDE does not support the creation or destruction offeature schema (that is does not support the FdoIApplySchema andFdoIDestroySchema commands) However it does support theFdoIDescribeSchema command The intended use of FDO Provider for ArcSDEis to operate on already existing feature schemas FDO Provider for ArcSDEsupports inserting selecting updating and deleting data in existing schemas

You can use FDO Provider for ArcSDE to operate on a new feature schemaHowever you must create the schema using ArcSDE tools In particular youuse the sdetable and sdelayer commands which can be used to create a schemain any of the data store technologies used by ArcSDE This part of thedescription is generic Other parts of the description are specific to Oracle andto Windows XP because Oracle is the data store technology and Windows XPis the operating system for this exercise

First you must create an Oracle username for the feature schema (that is thename of the Oracle user is the name of the feature schema) To do this youconnect as system administrator to the Oracle instance used by the ArcSDEserver The following command creates the user and grants to that user theprivileges necessary for the ArcSDE tool commands to succeed

grant connectresource to ltschemaNamegt identified by ltpasswordgt

Secondly you must log in to the host where the ArcSDE server is runningArcSDE tools are on the host machine where the ArcSDE server resides

TIP NetMeeting can be used to remotely login to where the ArcSDE Server isrunning and launch a command window (that is in the Run dialog box entercmd) The ArcSDE tool commands can be executed through the command windowDo not use CWINDOWSSYSTEM32COMMANDCOM because the line bufferis too short to contain the entire text of some of the SDE tool command strings

218 | Appendix A OSGeo FDO Provider for ArcSDE

Finally execute the sdetable and sdelayer commands in a command windowto create each of the classes Since you are executing these commands on thehost where the ArcSDE server is located you can omit the server name optionIf the ArcSDE server is connected to only one data store you can omit theservice option For more information about all of the ArcSDE commandsconsult the ArcSDE Developer Help Guide

SampleFeatureSchema

In this sample a feature schema called SampleFeatureSchema is created whichcontains one feature class called SampleFeatureClass This feature class hasthe following three properties

An Int32 called SampleIdentityDataProperty

A string called SampleNameDataProperty

A polygon geometry called SampleGeometricProperty

First use the sdetable -o create command to add the integer and stringproperties to SampleFeatureClass Then use the sdetable -o alter_reg commandto identify the SampleIdentityDataProperty as an identity property Finallyuse the sdelayer -o add command to add the geometric property toSampleFeatureClass This assumes that only one ArcSDE server service isrunning so that the -i option is optional The -i option takes a service nameas an argument

The sdetable -o create command can be invoked as follows

sdetable -o create -t SampleFeatureClass -d ldquoSampleIdentityData

Property INTEGER(10) SampleNameDataProperty STRING(64)rdquo -u

SampleFeatureSchema -p test

The -o option takes the command option name The -d option takes thecolumn definitions which is a quoted list of column namecolumn type pairsdelimited by commas The -u option takes an Oracle database user namewhich becomes the feature schema name The -p option takes a password

The sdetable -o alter_reg command is invoked as follows

sdetable -o alter_reg -t SampleFeatureClass -c SampleIdentityData

Property -C USER -u SampleFeatureSchema -p test

The -c option identifies the column name that will be the identity propertyThe -C option indicates whether SDE is supposed to generate the value orobtain it from the user You will be prompted to confirm that you want toalter the registration of the table

Creating a Feature Schema | 219

The sdelayer command is invoked as follows

sdelayer -o add -l SampleFeatureClassSampleGeometricProperty -E

0010050 -e a -u SampleFeatureSchema -p test

The -o option takes the command option name The -l option identifies thetable and column The -E option identifies the extents the arguments areltxminyminxmaxymaxgt The -e option identifies the geometry type withlsquoarsquo indicating an area shape

OGC980461FS

This schema contains the ten classes defined in the OpenGIS Project Document980946r1 The types of the properties belonging to the classes is similar tothat of SampleFeatureClass namely an integer a string and a geometry Onedifference is that the geometry in three of the classes is multipart Two ofthem have MULTIPOLYGON geometries and one of them has aMULTILINESTRING geometry A multipart geometry is indicated by addinga lsquo+rsquo to the entity argument to the -e option in the sdelayer command AMULTIPOLYGON geometry is indicated by ldquo-e a+rdquo and a MULTILINESTRINGgeometry is indicated by ldquo-e l+rdquo

An ArcSDE table cannot have two geometries This restriction impacts thedefinition of the buildings class which has a POLYGON and a POINTgeometry We have chosen to add the POINT geometry The OpenGIS 98-046r1document defines one query that references building objects and the POINTgeometry supports this query

NOTE The use of -E option in the sdelayer command defines the extents Thearguments are ltxminyminxmaxymaxgt The values provided below ensure thatyou will not receive any ldquoordinate out of boundsrdquo errors when inserting the98046r1 data

220 | Appendix A OSGeo FDO Provider for ArcSDE

ArcSDE Commands That Define the OGC980461FS Classes

Creating a Feature Schema | 221

sdetable -o create -t lakes -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t lakes -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l lakesshore -E 0010050 -e a -u OGC980461FS

-p test

sdetable -o create -t road_segments -d fid integer(10) name

string(64) aliases string(64) num_lanes integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t road_segments -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l road_segmentscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t divided_routes -d fid integer(10) name

string(64) num_lanes integer(10) -u OGC980461FS -p test

sdetable -o alter_reg -t divided_routes -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l divided_routescenterlines -E 0010050 -e l+

-u OGC980461FS -p test

sdetable -o create -t forests -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t forests -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l forestsboundary -E 0010050 -e a+ -u

OGC980461FS -p test

sdetable -o create -t bridges -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t bridges -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l bridgesposition -E 0010050 -e p -u

OGC980461FS -p test

sdetable -o create -t streams -d fid integer(10) name string(64)

-u OGC980461FS -p test

sdetable -o alter_reg -t streams -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l streamscenterline -E 0010050 -e l -u

OGC980461FS -p test

sdetable -o create -t buildings -d fid integer(10) address

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t buildings -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l buildingsposition -E 0010050 -e p -u

OGC980461FS -p test

222 | Appendix A OSGeo FDO Provider for ArcSDE

sdetable -o create -t ponds -d fid integer(10) name string(64)

type string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t ponds -c fid -C user -u OGC980461FS -p

test

sdelayer -o add -l pondsshores -E 0010050 -e a+ -u OGC980461FS

-p test

sdetable -o create -t named_places -d fid integer(10) name

string(64) -u OGC980461FS -p test

sdetable -o alter_reg -t named_places -c fid -C user -u OGC980461FS

-p test

sdelayer -o add -l named_placesboundary -E 0010050 -e a -u

OGC980461FS -p test

sdetable -o create -t map_neatlines -d fid integer(10) -u

OGC980461FS -p test

sdetable -o alter_reg -t map_neatlines -c fid -C user -u

OGC980461FS -p test

sdelayer -o add -l map_neatlinesneatline -E 0010050 -e a -u

OGC980461FS -p test

Logical to Physical Schema MappingThis mapping does not apply because the ArcSDE provider does not supportthe ApplySchema command

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data types TheArcSDE provider talks to the ArcSDE server The server uses either Oracle orSql Server as the back-end data store technology So two schema mappins aredescribed here

Oracle 10gR2 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter The class name is the name of the tablecreated using the sdetable command The property names are the columnnames

Logical to Physical Schema Mapping | 223

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoSrdquo means that the storage typeused for the geometry is Oracle Spatial The -G argument ldquo26910rdquo is the SRID ofa coordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N The sqlplus command select cs_name from mdsyscs_srs where srid =

26910 returns NAD83 UTM zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde -u existinguser -p test -G 26910 -P 32 -t S

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int16NUMBER(4)SE_INT16 4SMINT4COL

UnmappedCHAR(38)SE_UUID 38ID

Int16NUMBER(4)SE_INT16 4INT16COL

224 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeOracle TypeArcSDE Type Lengthdecimal places

Column

Int32NUMBER(38)SE_INT32 10INT32COL

SingleNUMBER(62)SE_FLOAT32 6 2FLOAT32COL

DoubleNUMBER(154)SE_FLOAT64 7 2FLOAT64COL

Int32NUMBER(10)SEINT32 10INT10

SingleNUMBER(44)SE_FLOAT32 4 4FLOAT4_4

DoubleNUMBER(72)SE_FLOAT64 7 2DOUBLE7_2

StringVARCHAR2(64)SE_STRING 64STRING64

BLOBBLOBSE_BLOB 0BLOBCOL

UnmappedCLOBSE_CLOB 0CLOBCOL

StringNVARCHAR2(255)SE_NSTRING 255NSTRINGCOL

UnmappedNCLOBSE_NCLOB 0NCLOBCOL

DateTimeDATESE_DATE 0DATECOL

GeometryMDSYSSDO_GEOMETRYSE_SHAPE 0FEATGEOM

Int32NUMBER(38)SE_INT32 10OBJECTID

NOTE The OBJECTID column was not specified in the -d arguments of the sdetablecommand

Sql Server 2005 Back-End

The schema name is the name of the user supplied as the value of theUsername connection parameter prefixed by ldquoSDE_rdquo The class name is the

Physical to Logical Schema Mapping | 225

name of the table created using the sdetable command The property namesare the column names

The following ArcSDE commands were used to create a table The sdetablecreates a business table The sdelayer command converts the business tableinto a feature class table

NOTE The sdetable -i option designates the ArcSDE server instance against whichto apply the command The value can be a symbolic name or a port number Ifthe value is a symbolic name the symbolic name must be mapped to a tcp portnumber in the CWINDOWSsystem32driversetcservices file

NOTE The sdelayer -e argument ldquonprdquo means that the geometry is either a 2Dpoint or NULL The -l argument ldquoexistingtablefeatgeom means a geometry columncalled featgeom in a table called existingtable The -E argument ldquoemptyrdquo meansthat the layer envelope is empty The -P argument ldquo32rdquo means that the geometryis stored with 32-bit precision The -t argument ldquoBrdquo means that the storage typeused for the geometry is Esri Binary The -G argument ldquo26910rdquo is the SRID of acoordinate system in the pedefh file as well as in the Oracle mdsyscs_srs tableYou can access this file by googling ldquopedefhrdquo It contains the following linedefine PE_PCS_NAD_1983_UTM_10N 26910 NAD 1983 UTM Zone 10N

sdetable -o create -t existingtable -d ldquosmInt4Col smallint(4)

int16Col int16 int32Col int32 float32Col float32 florat64Col

float64 int10 integer(10) float4_4 float(44) double7_2

double(72) string64 string(64) blobCol blob clobCol clob id

uuid nStringCol nstring nClobCol nclob dateCol daterdquo -u existin

guser -p test -i esri_sde_ss

sdelayer -o add -l existingtablefeatgeom -e np -E empty -i

esri_sde_ss -u existinguser -p test -G 26910 -P 32 -t B

The following table maps the output of the sdetable -o describe commandto the output of the sqlplus desc command to the output of the FDODescribeSchema command

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int16smallintSE_INT16 4SMINT4COL

UnmappeduniqueidentifierSE_UUID 38ID

Int16smallintSE_INT16 4INT16COL

226 | Appendix A OSGeo FDO Provider for ArcSDE

FDO TypeSql Server TypeArcSDE Type Lengthdecimal places

Column

Int32intSE_INT32 10INT32COL

SinglerealSE_FLOAT32 6 2FLOAT32COL

DoublefloatSE_FLOAT64 7 2FLOAT64COL

Int32intSEINT32 10INT10

Singlenumeric(44)SE_FLOAT32 4 4FLOAT4_4

Singlenumeric(72)SE_FLOAT64 7 2DOUBLE7_2

Stringvarchar(64)SE_STRING 64STRING64

BLOBimageSE_BLOB 0BLOBCOL

UnmappedtextSE_CLOB 0CLOBCOL

Stringnvarchar(255)SE_NSTRING 255NSTRINGCOL

UnmappedntextSE_NCLOB 0NCLOBCOL

DateTimedateSE_DATE 0DATECOL

GeometryintSE_SHAPE 0FEATGEOM

FDO Provider for ArcSDE CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

FDO Provider for ArcSDE Capabilities | 227

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

locking

exclusive locking type

transactions

long transactions

SQL

multiple spatial contexts

specifying coordinate systems by name or ID without specifying WKT

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

228 | Appendix A OSGeo FDO Provider for ArcSDE

The following capabilities are supported

class and feature class class types

DateTime data type with a maximum length of 12 bytes

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 4294967296

BLOB data type with a maximum length of 4294967296

Int32 auto-generated data type

Identity properties of type DateTime Double Int16 Int32 Single Stringand BLOB

Name size limitation of 123 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 65 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 160 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 32 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite unique value constraints

Multiple schemas

Null value constraints

Unique value constraints

FDO Provider for ArcSDE Capabilities | 229

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ActivateSpatialContext

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLComnmand

FdoCommandType_AcquireLock

FdoCommandType_GetLockInfo

FdoCommandType_GetLockedObjects

FdoCommandType_GetLockOwners

FdoCommandType_ReleaseLock

FdoCommandType_ActivateLongTransaction

FdoCommandType_DeactivateLongTransaction

FdoCommandType_CommitLongTransaction

FdoCommandType_CreateLongTransaction

FdoCommandType_GetLongTransactions

230 | Appendix A OSGeo FDO Provider for ArcSDE

FdoCommandType_RollbackLongTransaction

FdoCommandType_ListDataStores

The following capabilities are supported

command parameterization

simple functions in Select and SelectAggregate commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

the Beyond and Within distance operations

spatial operations of type Contains Crosses Disjoint Equals IntersectsOverlaps Touches Within CoveredBy Inside and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic expressions are supported

The following functions are supported

Double Sum(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Int64 Count(lttypegt value) where lttypegt is one of Boolean Double SingleDecimal Byte DateTime Int16 Int32 Int64 String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

FDO Provider for ArcSDE Capabilities | 231

Double Avg(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double Max(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Double StdDev(lttypegt value) where lttypegt is one of Double Single Int16or Int32

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

232 | Appendix A OSGeo FDO Provider for ArcSDE

OSGeo FDO Provider forMySQL

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor MySQL

What Is FDO Provider for MySQLThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for MySQL provides FDO withaccess to a MySQL-based data store

The FDO Provider for MySQL API provides custom commands that arespecifically designed to work with the FDO API For example using thesecommands you can do the following

Gather information about a provider

Transmit client services exceptions

Get lists of accessible data stores

Create connection objects

Create and execute spatial queries

The MySQL architecture supports different storage engines Choose an engineas needed depending on its characteristics and capabilities such as the following

MyISAM is a disk-based storage engine It does not support transactions

InnoDB is a disk-based storage engine It has full ACID transaction capability

B

233

Memory (Heap) is a storage engine utilizing only RAM It is very fast

NDB is the MySQL Cluster storage engine

MERGE is a variation of MyISAM A MERGE table is a collection of identicalMyISAM tables which means that all tables have the same columnscolumn types indexes and so on

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for MySQL API Reference Help(MySQL_Provider_APIchm)

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in thecommandrsquos class collection The mapping of logical FDO data types to nativetypes is described here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the numberof digits to the right of the decimal point The maximum number of digits in thenative type is 64

NOTE The definition of the FDO String data type requires that the length propertybe set

Native Data TypeFDO Data Type

tinyint(4)Boolean

tinyint(3) unsignedByte

datetimeDateTime

decimal(204)Decimal (precision = 20 scale = 4)

doubleDouble

smallint(6)Int16

234 | Appendix B OSGeo FDO Provider for MySQL

Native Data TypeFDO Data Type

int(11)Int32

bigint(20)Int64

doubleSingle

varchar(64)String (length is 64)

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The name of the schema is the concatenation of lsquoFdorsquo and the name of thedatabase This is the database created using the lsquoCREATE DATABASErsquo commandand containing the existing table(s) The table names are the class names andthe column names are the property names

NOTE The length of a bit field is in the range 1-64 A row in a column of typebit(64) can hold 64 bit values

NOTE The following native types are not mapped to FDO data types float floatunsigned real unsigned double unsigned binary varbinary tinyblob blobmediumblob longblob tinytext mediumtext and longtext

FDO Data TypeDefaultsNative Type

Booleanlength = 1bit(

Bytebit(2)

Int64bit(64)

Int16length = 4tinyint

Physical to Logical Schema Mapping | 235

FDO Data TypeDefaultsNative Type

Bytelength = 3tinyint unsigned

Int16length = 6smallint

Int32length = 5smallint unsigned

Int32length = 9mediumint

Int32length = 8mediumint unsigned

Int32length = 11int

Int64length = 10int unsigned

Int64length = 20bigint

Int64length = 20bigint unsigned

Doublereal

Doubledouble

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric

Decimal (precision = 10 scale =0)

precision = 10 scale = 0numeric unsigned

DateTimedate

DateTimedatetime

DateTimetimestamp

Int32year

236 | Appendix B OSGeo FDO Provider for MySQL

FDO Data TypeDefaultsNative Type

String (length = 192)char(64)

String (length = 192)varchar(64)

Stringenum

Stringset

FDO Provider for MySQL CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

transactions

FDO Provider for MySQL Capabilities | 237

SQL

multiple spatial contexts

Write

Multi-user write

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 95 digits (maximum decimalprecision of 65 and maximum decimal scale of 30)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of 2147483647

Int64 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 64 for a schema element name of typeFdoSchemaElementNameType_Datastore

238 | Appendix B OSGeo FDO Provider for MySQL

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 200 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Composite unique value constraints

Datastore scope unique ID generation

Default value

Exclusive value range constraints

Inclusive value range constraints

Inheritance

Multiple schemas

Null value constraints

Object properties

Unique value constraints

Schema modification

Schema overrides

Unique value constraints

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()

FDO Provider for MySQL Capabilities | 239

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_DestroySpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

FdoCommandType_ListDataStores

FdoCommandType_DescribeSchemaMapping

FdoCommandType_SQLComnmand

FdoRdbmsCommandType_CreateSpatialIndex

FdoRdbmsCommandType_DestroySpatialIndex

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

240 | Appendix B OSGeo FDO Provider for MySQL

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null spatial and distance

spatial operations of type Intersects and EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic function and parameter expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Decimal Double SingleInt16 Int32 or Int64

Decimal Ceil(lttypegt value) where lttypegt is one of Decimal or Double

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single or String

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

FDO Provider for MySQL Capabilities | 241

Byte Min(lttypegt value) where lttypegt is one of Byte DateTime DecimalDouble Single Int16 Int32 Int64 Single or String

Double Sum(lttypegt value) where lttypegt is one of Decimal Double Int16Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

242 | Appendix B OSGeo FDO Provider for MySQL

OSGeo FDO Provider forODBC

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor ODBC

What Is FDO Provider for ODBCThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for ODBC provides FDO withaccess to an ODBC-based data store

The FDO Provider for ODBC can access simple x y z feature objects that canrun in a multi-platform environment including Windows Linux and UNIX

The FDO Provider for ODBC has the following characteristics

The FDO Provider for ODBC supports the definition of one or more featureclasses in terms of any relational database table that contains an X Y andoptionally Z columns

Metadata which maps the table name and X Y and optionally Z columnsto a feature class is maintained outside the database in a configuration fileThis information in conjunction with the table structure in the databaseprovides the definition of the feature class

The x y and z locations of objects are stored in separate properties in theprimary object definition of a feature but are accessible through a singleclass property lsquoGeometryrsquo

C

243

Read-only access is provided to pre-existing data defined and populatedthrough 3rd party applications (that is FDO Provider for ODBC will notbe responsible for defining the physical schema of the data store nor forpopulating the object data)

The schema configuration of the data store is provided to the FDO Providerfor ODBC through an optional XML file containing the Geographic MarkupLanguage (GML) definition of the schema that maps lsquotablesrsquo and lsquocolumnsrsquoin the data store to feature classes and property mappings in the FDO datamodel

NOTE Microsoft Excel (must have at least one named range do not use DATABASEor other reserved words as a range name)

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for ODBC API Reference Help (ODBC_Provider_APIchm)

Physical to Logical Schema MappingsMappings of data in three data sources a Microsoft Access database (an accdbfile) an Excel spreadsheet (xlsx file) and a text file to FDO data types areshown

Microsoft Access

Use the ODBC provider to connect to a Microsoft Access database

The schema name is ldquoFdordquo There is only one database per file so there canbe only one schema The table names are used for class names Column namesare used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are AutoNumberReplication ID NumberReplication ID and OLE objectThe mapping of the rest of the native data types is in the following table

244 | Appendix C OSGeo FDO Provider for ODBC

NOTE The AutoNumber Number and DateTime native types are sub-typed Ifa column named X and a column named Y both typed NumberDouble arepresent they are mapped to an FDO geometric property whose type is Point andwhose spatial context association property is ldquoDefaultrdquo

FDO TypeNative TypeSubType

Int32AutoNumberLong Integer

Notmapped

AutoNumberReplication ID

StringText

StringMemo

ByteNumberByte

Int16NumberInteger

Int32NumberLong Integer

SingleNumberSingle

DoubleNumberDouble

DecimalNumberDecimal

Notmapped

NumberReplication ID

DateTimeDateTimeGeneral Date

DateTimeDateTimeLong Date

DateTimeDateTimeMedium Date

DateTimeDateTimeShort Date

Physical to Logical Schema Mappings | 245

FDO TypeNative TypeSubType

DateTimeDateTimeLong Time

DateTimeDateTimeMedium Time

DateTimeDateTimeShort Time

DecimalCurrency

BooleanYesNo

Notmapped

OLE object

StringHyperlink

StringAttachment

Microsoft Excel

Use the ODBC provider to connect to an Excel file

The schema name is ldquoFdordquo There is only one schema per file The range namesare used for class names Column names are used for property names A columnname is a text entry in a cell that is at the top of a column as defined by theboundaries of the named range

If a column named X and a column named Y are present they are mappedto an FDO geometric property whose type is Point and whose spatial contextassociation property is ldquoDefaultrdquo

Three approaches were used to explore the mapping The first approach lookedat the effect of cell content the second approach looked at the effect of cellformat the third approach looked at the effect of both

The first approach involved copying data from a Microsoft Access databaseinto an Excel spreadsheet The copy operation created a named range thatincluded all of the copied data The name for the range came from the Accessdatabase By default all of the Excel cells have a format type of ldquoGeneralrdquo The

246 | Appendix C OSGeo FDO Provider for ODBC

accompanying table shows the mapping of sample cell content to FDO datatype

FDO TypeCell Content

Double2

Double6452067

StringRussia

Stringltemptygt

StringN

NOTE All of the data in each column was consistent The column containing ldquo2rdquocontained only positive integers The column containing ldquo6452067rdquo containedonly similar numbers including negative values The column containing the lsquoNrsquocontained only single characters that were either lsquoNrsquo or lsquoYrsquo The column containingldquoRussiardquo contained only names The column containing an empty cell containedonly empty cells

The second approach involved setting up a named range consisting of 9columns by 2 rows The cells of the first row are formatted as ldquoGeneralrdquo andcontain column labels The cells of the second row are formatted respectivelyldquoGeneralrdquo ldquoNumberrdquo ldquoCurrencyrdquo ldquoAccountingrdquo ldquoDaterdquo ldquoTimerdquoldquoPercentagerdquo ldquoFractionrdquo ldquoScientificrdquo and ldquoTextrdquo No cell in the second rowhas content The accompanying table shows the mapping of cell format toFDO data type

FDO TypeExcel Cell Format

StringGeneral

DoubleNumber

DecimalCurrency

DecimalAccounting

Physical to Logical Schema Mappings | 247

FDO TypeExcel Cell Format

DateTimeDate

DateTimeTime

DoublePercentage

DoubleFraction

DoubleScientific

StringText

The intent of the third approach is to understand how the mapping wouldbe affected by content that violated the cellrsquos format or was inconsistent withthe data in the rest of the column

Inserting ldquohererdquo in the cells formatted as Number Currency AccountingDate Time Percentage Fraction and Scientific caused them to be mapped toString

Inserting -1225 in the cell formatted as Currency caused no change in themapping to Decimal

Inserting 1225 in the cell formatted as Date caused no change in the mappingto DateTime Excel converted 1225 to ldquo1121900 60000 AMrdquo

Inserting ldquohererdquo in one of the cells in the column of integers copied from theAccess database resulted in no change to the mapping to Double This maybe a bug

Text File

Use the ODBC provider to connect to a text file You must first create a DSNusing the XP Data Sources (ODBC) administrative tool The DSN maps to adirectory not a file Each file in the directory is mapped to an FDO class

248 | Appendix C OSGeo FDO Provider for ODBC

NOTE When selecting the directory for the DSN you will notice a listing of thefiles recognized as text files by the driver It will recognize Vim backup files forexample Citiestxt~ as text files The execution of a describe schema commandon a directory containing a Vim backup file caused an exception whose messageis ldquoRDBMS [Microsoft][ODBC Text Driver] Cannot update Database or object isread-onlyrdquo Removal of the Vim backup file prevented this exception

The schema name is ldquoFdordquo There is only one schema per directory The classname is the name of the file for example ldquoCities_txtrdquo The property namesare taken from the first line in the file Here are the first two lines from acomma-delimited text file The property names are ldquoCITY_IDrdquo ldquoNAMErdquo etcThe table shows the mapping of the sample text to FDO data type

CITY_IDNAMECOUNTRYPOPULATIONCAPITALLATITUDELON

GITUDEURLFOUNDED

1MurmanskRussia468000N689633087172008 00000

FDO Data TypeSample Text

Int32468000

StringRussia

Double6896

Stringltemptygt

NOTE Changing ldquoLATITUDErdquo to ldquoYrdquo and ldquoLONGITUDErdquo to ldquoXrdquo causes these twofields to be mapped to a geometric property called ldquoGeometryrdquo whose spatialcontext association is to a spatial context called ldquoDefaultrdquo

FDO Provider for ODBC CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

FDO Provider for ODBC Capabilities | 249

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

SQL

XML configuration

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 56 digits (maximum decimalprecision of 28 and maximum decimal scale of 28)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

250 | Appendix C OSGeo FDO Provider for ODBC

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Auto-generated data types Int16 and Int64

Identity properties of type Boolean Byte and DateTime

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Composite ID

Default value

Inheritance

Multiple schemas

Null value constraints

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaning

FDO Provider for ODBC Capabilities | 251

of the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_GetSpatialContexts

FdoCommandType_SQLCommand

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

availability of ordering in Select and SelectAggregates command

availability of grouping criteria in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Intersects Within Inside and EnvelopeIntersects

252 | Appendix C OSGeo FDO Provider for ODBC

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The full range of expression functions are supported as set out in theCapabilities chapter

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZ is supported The Point geometry types is supported

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for ODBC Capabilities | 253

254

OSGeo FDO Provider forSDF

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SDF

What Is FDO Provider for SDFThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SDF is a standalone fileformat that supports GIS data

The FDO Provider for SDF uses Autodesks spatial database format which is afile-based personal geodatabase that supports multiple featuresattributes spatialindexing interoperability file-locking and high performance for large datasets

The SDF file format has the following characteristics

SDF files can be read on different platforms

The SDF file has its own spatial indexing

SDF files can store geometric and non-geometric data with minimumoverhead

Although it does not support concurrency control (locking) the SDF fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SDF API Reference Help (SDF_Provider_APIchm)

D

255

FDO Provider for SDF CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per command threaded

dynamic spatial content extent type

Write

Flush

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

256 | Appendix D OSGeo FDO Provider for SDF

Boolean data type with a maximum length of 1 byte

Byte data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of 8 bytes

Int16 data type with a maximum length of 2 bytes

Int32 data type with a maximum length of 4 bytes

Int64 data type with a maximum length of 8bytes

Single data type with a maximum length of 4 bytes

String data type with a maximum length of unknown

Int32 auto-generated data type

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Association properties

Auto ID generation

Composite ID

Exclusive value range constraints

FDO Provider for SDF Capabilities | 257

Inclusive value range constraints

Inheritance

Null value constraints

Schema modification

Value constraints list

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_ApplySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

FdoCommandType_CreateDataStore

FdoCommandType_DestroyDataStore

SdfCommandType_ExtendedSelect

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

258 | Appendix D OSGeo FDO Provider for SDF

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Contains Disjoint Inside Intersects Withinand EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty geomValue)

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBGeometricProperty AssociationProperty

Double Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

FDO Provider for SDF Capabilities | 259

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeometry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

260 | Appendix D OSGeo FDO Provider for SDF

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SDF Capabilities | 261

262

OSGeo FDO Provider forSHP

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor SHP

What Is FDO Provider for SHPThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for SHP provides FDO withaccess to an SHP-based data store

The FDO Provider for SHP uses a standalone file format that supports GIS dataThe FDO Provider for SHP (Shape) has the following characteristics

Read-only access is provided to pre-existing spatial and attribute data froman Environmental Systems Research Institute (ESRI) Shape file (SHP)

The FDO Provider for SHP can run in a multi-platform environmentincluding Windows and Linux

A Shape file consists of three separate files SHP (shape geometry) SHX (shapeindex) and DBF (shape attributes in dBASE format)

The FDO Provider for SHP accesses the information in each of the threeseparate files and treats each SHP and its associated DBF file as a featureclass with a single geometry property and optionally with data attributeproperties

Schema configuration of the data store is provided to the FDO Provider forSHP through an XML file containing the Geographic Markup Language

E

263

(GML) definition of the schema that maps SHP and DBF data in the datastore to feature classes and property mappings in the FDO data model

Although it does not support concurrency control (locking) the SHP fileformat is a valid alternative to RDBMS

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for SHP API Reference Help (SHP_Provider_APIchm)

Creating SHP Files for the Logical to PhysicalSchema Mapping

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The shape files used for the purpose of mapping FDO logical types to shapenative types were created using the following method The path argument isthe path to a filename whose pattern is ltbasegtshp The type argument specifiesthe type of the shape filersquos geometry for example ShapLibShapeTypePointExecution of the method creates the named ltbasegtshp file as well as altbasegtshx file

using MapTools

public bool CreateShpFile(string path ShapeLibShapeType type)

IntPtr hShp = ShapeLibSHPCreate(path type)

if (hShpEquals(IntPtrZero)) return false

else

ShapeLibSHPClose(hShp)

return true

The FDO ApplySchema creates the ltbasegtdbf and ltbasegtcpg It will alsocreate the ltbasegtprj file if a spatial context has been created and the nameof the coordinate system referenced by the spatial context definition has beenassigned to the feature geometric property definitionrsquos spatial contextassociation property

264 | Appendix E OSGeo FDO Provider for SHP

Creating SHP Files for the Physical to LogicalSchema Mapping

To do the physical to logical schema mapping requires shp files containingall possible shp data types Two approaches for creating such shp files havebeen used The first approach is to use the ArcSDE sde2shp command toconvert an ArcSDE schema to a shapefile schema The second approach is touse the ShapeLib C library to create the shapefiles

sde2shp

This command converts the contents of an ArcSDE data store into a set ofshape files The conversion is guided by a text specification that maps anArcSDE column name to a tuple consisting of a shape table column name ashape column type identifier a column width and optionally the number ofdeciaml places

The source ArcSDE data store for this exercise is that specified in the ArcSDEappendix in the topic about physical to logical schema mapping The datastore contained a table called ldquoExistingTablerdquo This table containing a geometrycolumn called ldquofeatgeomrdquo The featgeom column allows only point geometriesto be stored A shape geometry can only be of one type So for the conversionto work the ArcSDE geometry column has to be restricted to contain onlyone geometry type The source ArcSDE data store contained no data TheArcSDE geometry was created with a coordinate system specified

The syntax of the command follows sde2shp -o init -l

ExistingTablefeatgeom -f points -a file=pointstxt -t point -i

esri_sde_ss -u sde -p fdotest The -f argument becomes the root name ofthe shape files that are created by the command (pointsshp pointsshxpointsdbf pointsidx and pointsprj) The -t argument is the shape geometrytype The -i argument is the name of the ArcSDE server instance the symbolicname is mapped to a TCP port in theCWINDOWSsystem32driversetcservices file The -u and -p argumentsidentify a username and password in the data store The -a argument identifiesthe file used to specify the conversion of the non-geometry columnconversions

The contents of the pointstxt conversion file are as follows

Creating SHP Files for the Physical to Logical Schema Mapping | 265

smInt4Col smInt4 N 4

int16Col int16Col N 4

int32Col int32Col N 10

float32Col float32C N 6 2

float64Col float64C N 15 4

int10 Int10 N 10

float4_4 float4_4 N 4 3

double7_4 doubl7_2 N 7 2

string64 str64 C 64

nStringCol nStrCol C 254

dateCol dateCol D 8

NOTE Initial values for column widths and number of decimal places were takenfrom the output of the sdetable -o describe command These values were changedover the course of several executions of the sde2shp in response to warning anderror messages issued by the sde2shp command

ShapeLib

See httpshapelibmaptoolsorg The shape files used in this exercise werecreated using a NET wrapper that you can obtain from the ShapeLib site TheNET wrapper package contains test code that was easily adapted to the purposeof creating shape files for the schema mapping exercise

The ltbasegtshp and ltbasegtshx files are created by the ShapeLibSHPCreatemethod

The ltbasegtprj file is created by using a text editor to create the file andinserting the WKT string specification for the coordinate system

The ltbasegtdbf file is created by the following code

IntPtr dbfFile = MapToolsShapeLibDBFCre

ate(Pointspointsdbf)

int logicalColNum = MapToolsShapeLibDBFAddField(dbfFile Logic

alCol ShapeLibDBFFieldTypeFTLogical 1 0)

int strColNum = MapToolsShapeLibDBFAddField(dbfFile StrCol

ShapeLibDBFFieldTypeFTString 64 0)

int dateColNum = MapToolsShapeLibDBFAddField(dbfFile DateCol

ShapeLibDBFFieldTypeFTDate 8 0)

int integer20_0Num = MapToolsShapeLibDBFAddField(dbfFile In

teger20 ShapeLibDBFFieldTypeFTInteger 20 0)

int double18_4Num = MapToolsShapeLibDBFAddField(dbfFile

Double18_4 ShapeLibDBFFieldTypeFTDouble 18 4)

MapToolsShapeLibDBFClose(dbfFile)

266 | Appendix E OSGeo FDO Provider for SHP

Logical to Physical Schema MappingThe SHP provider supports the DestroySchema and ApplySchema commandsSo it is possible to create shape files whose schema has been defined usingFDO and then map the logical FDO data types to the shape native types Thismapping is described here The creation of the shape file used for this purposeis described in this appendix

Native Type Column Width Decimal PlacesFDO Type

L 1Boolean

D 8DateTime

N gt0 gt0Decimal

N 11Int32

C gt0String

Physical to Logical Schema MappingWhen FDO describes the schema of an existing shapefile that was not createdby the ApplySchema command it maps native data types to FDO data typesTwo shapfiles have been mapped One shapfile has been created using theArcSDE command sde2shp The creation of the source ArcSDE schema isdescribed in the appendix for the ArcSDE provider The other shapfile hasbeen created using a NET wrapper for the ShapeLib C Library These twomethods for creating shapefiles are described in this appendix

The schema name is ldquoDefaultrdquo The class name is the root name of the fileFor example if the filename is ldquopointsshprdquo the class name is ldquopointsrdquo Theattribute property names are the dBASE column names The geometry propertyname is ldquoGeometryrdquo The value of the feature classrsquos SpatialContextAssociationproperty is the name of the coordinate system specified in the prj file Forexample if the coordinate system specification in the prj has the patternldquoPROJCS[]rdquo the value of the SpatialContextAssociation proerty is the valueof the ltnamegt parameter in the pattern ldquoPROJCS[ltnamegt]rdquo

Logical to Physical Schema Mapping | 267

sde2shp

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat came from the conversion of an ArcSDE schema is in the following table

FDO Data TypeNative Type Column Width DecimalPlaces

DecimalN 4

DecimalN 10

DecimalN 6 2

DecimalN 15 4

DecimalN 4 3

DecimalN 7 2

StringC

DateTimeD

ShapeLib

The mapping of SHP (dbf) native types to FDO data types for the SHP schemathat was created by a ShapeLib program is in the following table

FDO Data TypeNative Type Column Width Decimal Places

BooleanL 1

StringC 64

DateTimeD 8

DecimalN 20 0

268 | Appendix E OSGeo FDO Provider for SHP

FDO Data TypeNative Type Column Width Decimal Places

DecimalN 18 4

FDO Provider for SHP CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

multiple spatial contexts

Write

Multi-user write

Flush

FDO Provider for SHP Capabilities | 269

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of 1 byte

DateTime data type with a maximum length of 12 bytes

Decimal data type with a maximum length of 255 digits (maximum decimalprecision of 255 and maximum decimal scale of 255)

Int32 data type with a maximum length of 4 bytes

String data type with a maximum length of 255

Int32 auto-generated data type

Identity properties of type Int32

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of 7 for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of 255 for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of 11 for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of 0 for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name

Auto ID generation

Multiple schemas

Null value constraints

270 | Appendix E OSGeo FDO Provider for SHP

Schema modification

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_Insert

FdoCommandType_Delete

FdoCommandType_Update

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_ApplySchema

FdoCommandType_DestroySchema

FdoCommandType_CreateSpatialContext

FdoCommandType_GetSpatialContexts

SdfCommandType_CreateSDFFile

The following capabilities are supported

simple functions in Select and SelectAggregate commands

use of expressions for properties in Select and SelectAggregates commands

use of Distinct in SelectAggregates command

FDO Provider for SHP Capabilities | 271

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

The following capabilities are supported

Conditions of type comparison like in null and spatial

spatial operations of type Within Inside Intersects EnvelopeIntersects

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Basic and function expressions are supported

The following functions are supported

Double Avg(lttypegt value) where lttypegt is one of Byte Decimal DoubleSingle Int16 Int32 or Int64

Double Ceil(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Concat(String str1Val String str2Val)

Int64 Count(lttypegt value) where lttypegt is one of Boolean Byte DateTimeDecimal Double Int16 Int32 Int64 Single String BLOB CLOBObjectProperty GeometricProperty AssociationProperty or RasterProperty

Decimal Floor(lttypegt value) where lttypegt is one of Decimal Double orSingle

String Lower(String value)

Double Max(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

Byte Min(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

272 | Appendix E OSGeo FDO Provider for SHP

Double Sum(lttypegt value) where lttypegt is one of Byte Decimal DoubleInt16 Int32 Int64 or Single

String Upper(String value)

GeometricProperty SpatialContexts(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types LinearRingand LineStringSegment are supported The following geometry types aresupported

Point

LineString

Polygon

MultiPoint

MultiLineString

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

No Raster capabilities are supported

FDO Provider for SHP Capabilities | 273

274

OSGeo FDO Provider forSQL Server Spatial

Logical to Physical Schema MappingThe FDO ApplySchema command creates a table for each class in the commandrsquosclass collection The mapping of logical FDO data types to native types isdescribed here

NOTE The definition of the FDO Decimal data type requires that the precisionproperty be set as a minimum to 1 in this case the scale property is set to 0 bydefault Precision is the number of digits in the number and scale is the number ofdigits to the right of the decimal point The maximum number of digits in the nativetype is 38

NOTE The definition of the FDO String data type requires that the length propertybe set

Native TypeFDO Data Type

bitBoolean

tinyintByte

datetimeDateTime

decimal(204)Decimal (precision property is set to 20and scale property is set to 4)

F

275

Native TypeFDO Data Type

floatDouble

smallintInt16

intInt32

bigintInt64

realSingle

nvarchar(64)String (length property set to 64)

geographygeometry with a geodetic coordinate sys-tem

geometrygeometry with a Euclidean coordinate sys-tem

Physical to Logical Schema MappingWhen FDO describes the schema of an existing table that was not created bythe ApplySchema command it maps native data types to FDO data typesThis mapping is described here

The database name is used for the feature schema name The table names areused for class names Column names are used for property names

Some native types are not mapped to FDO data types and so do not appearin the output of the describe schema command even if they exist in the tableThey are date datetim2(7) datetimeoffset(7) hierarchyid sql_variatn time(7)and xml The mapping of the rest of the native data types is in the followingtable

276 | Appendix F OSGeo FDO Provider for SQL Server Spatial

NOTE The geography and geometric native types map to the geometric propertytype FDO properties are classified as data geometric object association or rasterOnly the data properties are further classified

FDO TypeNative Type

Int64bigint

BLOBbinary(50)

Booleanbit

Stringchar(10)

DateTimedatetime

Decimaldecimal(180)

Doublefloat

Geometricgeography

Geometricgeometry

BLOBimage

Int32int

Decimalmoney

Stringnchar(10)

Stringntext

Decimalnumeric(180)

Stringnvarchar(50)

Physical to Logical Schema Mapping | 277

FDO TypeNative Type

Stringnvarchar(MAX)

Singlereal

DateTimesmalldatetime

Int16smallint

Decimalsmallmoney

Stringtext

DateTimetimestamp

Bytetinyint

Stringuniqueidentifier

BLOBvarbinary(50)

Stringvarchar(50)

BLOBvarbinary(MAX)

278 | Appendix F OSGeo FDO Provider for SQL Server Spatial

OSGeo FDO Provider forWFS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WFS

What Is FDO Provider for WFSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WFS provides FDO withaccess to a WFS-based data store

An OGC Web Feature Service (WFS) provides access to geographic features thatare stored in an opaque data store in a clientserver environment A client usesWFS to retrieve geospatial data that is encoded in Geography Markup Language(GML) from a single or multiple Web Feature Service The communicationbetween client and server is encoded in XML If the WFS response includesfeature geometries it is encoded in Geography Markup Language (GML) whichis specified in the OpenGIS Geographic Markup Language ImplementationSpecification

Using FDO Provider for WFS data manipulation operations you can do thefollowing

Query features based on spatial and non-spatial constraints

Create new feature instances

Delete feature instances

Update feature instances

G

279

Lock feature instances

For more information see The Essential FDO (FET_TheEssentialFDOpdf)

NOTE There is no public API documentation for the FDO Provider for WFSfunctionality is available through the main FDO API

FDO Provider for WFS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threaded

static spatial content extent type

multiple spatial contexts

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()

280 | Appendix G OSGeo FDO Provider for WFS

method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

Boolean data type with a maximum length of unknown bytes

Byte data type with a maximum length of unknown bytes

DateTime data type with a maximum length of unknown bytes

Decimal data type with a maximum length of unknown digits (maximumdecimal precision of unknown and maximum decimal scale of unknown)

Double data type with a maximum length of unknown bytes

Int16 data type with a maximum length of unknown bytes

Int32 data type with a maximum length of unknown bytes

Int64 data type with a maximum length unknown 8 bytes

Single data type with a maximum length of unknown bytes

String data type with a maximum length of unknown

Identity properties of type Boolean Byte DateTime Decimal DoubleInt16 Int32 Int64 Single and String

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Characters that cannot be used for a schema element name (null)

Composite ID

FDO Provider for WFS Capabilities | 281

Multiple schemas

Object properties

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FdoCommandType_DescribeSchema

FdoCommandType_GetSpatialContexts

FdoRdbmsCommandType_GetSpatialIndexes

The following capabilities are supported

use of expressions for properties in Select and SelectAggregates commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

282 | Appendix G OSGeo FDO Provider for WFS

Basic expressions are supported

The following functions are supported

GeometricProperty SpatialExtents(GeometricProperty property)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XYZM is supported The geometry component types RingLinearRing CircularArcSegment and LineStringSegment are supported Thefollowing geometry types are supported

Point

LineString

Polygon

MultiPoint

MultiLineString

MultiPolygon

MultiGeoemtry

CurveString

CurvePolygon

MultiCurveString

MultiCurvePolygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

FDO Provider for WFS Capabilities | 283

No Raster capabilities are supported

284 | Appendix G OSGeo FDO Provider for WFS

OSGeo FDO Provider forWMS

This appendix discusses FDO API development issues that are related to OSGeo FDO Providerfor WMS

What Is FDO Provider for WMSThe Feature Data Objects (FDO) API provides access to data in a data store Aprovider is a specific implementation of the FDO API that provides access todata in a particular data store The FDO Provider for WMS provides FDO withaccess to a WMS-based data store

An Open Geospatial Consortium (OGC) Web Map Service (WMS) producesmaps of spatially referenced data dynamically from geographic informationThis international standard defines a map to be a portrayal of geographicinformation as a digital image file suitable for display on a computer screen Amap is not the data itself Maps by WMS are generally rendered in a pictorialformat such as PNG GIF or JPEG or occasionally as vector-based graphicalelements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile(WebCGM) formats

The FDO Provider for WMS has the following characteristics

The FDO Provider for WMS serves up map information originating from anOGC Basic Web Map Service that provides pictorially formatted images suchas PNG GIF or JPEG

WMS map data is exposed through an FDO feature schema whose classescontain an FDO Raster property definition The FDO schema exposed fromthe FDO Provider for WMS conforms to a pre-defined FDO schema that is

H

285

specific to WMS and that acts as the basis for all FDO interaction withWMS data regardless of the originating source of the WMS images

WMS data manipulation operations are limited to querying features basedon spatial and non-spatial constraints Schema manipulation operationsare not supported

The FDO Provider for WMS can run in a multi-platform environmentincluding Windows and Linux

For more information see The Essential FDO (FET_TheEssentialFDOpdf) andthe OSGeo FDO Provider for WMS API Reference Help (WMS_Provider_APIchm)

FDO Provider for WMS CapabilitiesThe capabilities of an FDO provider are grouped in the following categories

Connection

Schema

Commands

Expressions

Filters

Geometry

Raster

Connection Capabilities

Use the FdoIConnectionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetConnectionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIConnectionCapabilities class descriptionin the FDO API Reference documentation

The following capabilities are supported

Per connection threading

static spatial content extent type

XML configuration

286 | Appendix H OSGeo FDO Provider for WMS

Schema Capabilities

Use the FdoISchemaCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetSchemaCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoISchemaCapabilities class description inthe FDO API Reference documentation

The following capabilities are supported

class and feature class class types

String data type with a maximum length of unknown

BLOB data type with a maximum length of unknown bytes

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Datastore

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Schema

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Class

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Property

Name size limitation of unknown for a schema element name of typeFdoSchemaElementNameType_Description

Inheritance

Schema overrides

Command Capabilities

Use the FdoICommandCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetCommandCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoICommandCapabilities class description inthe FDO API Reference documentation

The following commands are supported

FdoCommandType_Select

FdoCommandType_SelectAggregates

FDO Provider for WMS Capabilities | 287

FdoCommandType_DescribeSchema

FdoCommandType_DescribeSchemaMapping

FdoCommandType_GetSpatialContexts

The following capabilities are supported

simple functions in Select and SelectAggregate commands

Filter Capabilities

Use the FdoIFilterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetFilterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIFilterCapabilities class description in the FDO API Referencedocumentation

No filter capabilities are supported

Expression Capabilities

Use the FdoIExpressionCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetExpressionCapabilities()method on the FdoIConnection object For an explanation of the meaningof the capabilities consult the FdoIExpressionCapabilities class description inthe FDO API Reference documentation

Function expressions are supported

The following functions are supported

BLOB RESAMPLE(BLOB raster Double minX Double minY Double maxXDouble maxY Int32 height Int32 width)

BLOB CLIP(BLOB raster Double minX Double minY Double maxX DoublemaxY)

GeometricProperty SpatialExtents(BLOB raster)

Geometry Capabilities

Use the FdoIGeometryCapabilities object methods to learn about thesecapabilities You can get this object by calling the GetGeometryCapabilities()method on the FdoIConnection object For an explanation of the meaning

288 | Appendix H OSGeo FDO Provider for WMS

of the capabilities consult the FdoIGeometryCapabilities class description inthe FDO API Reference documentation

Dimensionality XY is supported The geometry component type LinearRingis supported The following geometry types are supported

Polygon

Raster Capabilities

Use the FdoIRasterCapabilities object methods to learn about these capabilitiesYou can get this object by calling the GetRasterCapabilities() method on theFdoIConnection object For an explanation of the meaning of the capabilitiesconsult the FdoIRasterCapabilities class description in the FDO API Referencedocumentation

The Raster capability is supported The following raster data models aresupported

Bitonal1-bitpixelUnsigned Integer

Gray8-bitpixelUnsigned Integer

RGB24-bitpixelUnsigned Integer

RGBA32-bitpixelUnsigned Integer

Palette8-bitpixelUnsigned Integer

FDO Provider for WMS Capabilities | 289

290

Index

A

AGF 152API

defined 5FDO 5

application development 11architecture and packages 8ArcSDE

limitations 212ArcSDE Provider 211

Capabilities 227 237 249 256 269 280 286

Software Requirements 211association property 15Autodesk Geometry Format (AGF) 152

B

behaviors GisPtr 25BinaryOperations 146

C

calls chain 25capabilities

FDO Provider for ArcSDE 227 237 249 256 269 280 286

classcontained 91feature 14IdentityProperty and

ObjectProperty 91ndash92standalone 91

Class Diagram FDO Schema Element 93class type 14collection classes 23comparison operations 146connection

ArcSDE 216establishing 29

semantics 27constraints expression text 141constraints filter text 141constraints provider-specific 141Contained Class 91context spatial 18

D

data concepts 13data property

defined 15data sources and data stores 27data store 18

defined 18FDO Provider for ArcSDE 211FDO Provider for MySQL 233FDO Provider for ODBC 243FDO Provider for SDF 255FDO Provider for SHP 263FDO Provider for WMS 285filtering 19 139locking 19querying 129schemas and the 85transactions 20

data stores data sources and 27data type

DATETIME 145DOUBLE 145IDENTIFIER 144INTEGER 145PARAMETER 144STRING 144

data type mappings 217data types 144DataStore

FDO Provider for ArcSDE 211develop applications 11dimensionality defined 15

Index | 291

E

edit a GML schema file 101element states schema 94elements of a schema 14example

creating a schema 111creating a schema read in from an

XML file 114deleting property values 127describing a schema 114destroying a schema 114inserting an Integer a string and a

Geometry Value 122query 130schema management 111updating property values 125

expression grammar 143expression text 140Expression defined 19expressions 140

F

factory abstract geometry 159FDO

architecture and packages 8FDO API

defined 5FDO concepts

commands 18data store 18expression 19feature class 14filter 19geometry property 16locking 19object property 17property 15spatial context 18transactions 20

FDO In General 161FDO Provider for ArcSDE

capabilities 227 237 249 256 269 280 286

connection 216

defined 211software requirements 211

FDO Provider for MySQLdefined 233

FDO Provider for ODBCdefined 243

FDO Provider for SDF 255defined 255

FDO Provider for SDF defined 255FDO Provider for SHP

defined 263FDO Provider for WMS

defined 285FDO schema element class diagram 93FDO XML format 95FDOClass 90FDOFeatureClass 90FDOIActivateLongTransaction 136FDOICommitLongTransaction 137FDOICreateLongTransaction 137FDOIDeactivateLongTransaction 136FDOIGetLongTransactions 137FDOIRollbackLongTransaction 136feature class 14feature schema creating a 218filter

grammar 141Filter 139

defined 19filter text 140filters 19

G

geometric types mapping betweenGeometry and 160

geometry 16Geometry

basic or pure 152properties 16types 159value 147working with 151

geometry and geometric types mappingbetween 160

Geometry API 151

292 | Index

GIS_SAFE_RELEASE (ptr) 21ndash22GisPtr 22GML schema file creating and

editing 101

H

handler exception 23

K

keywords filter and expression 144

L

locking 19ArcSDE limitations 213defined 19

long transactiondefined 135leaf 135root 20 135ndash136

M

mappingsdata type 217physical 86

memory management 21models modifying 94

N

non-feature class issues 91non-smart ptr 26

O

object propertydefined 17

ObjectProperty types 90OGC WKT 151operations comparison 146operations data maintenance 119

operator precedence 146operators 146overrides

schema 88

P

packageconnections 27Schema 85

packages FDO 8parent in the schema classes 86properties

base 85Geometry 16

propertyassociation 15data 15defined 15object 17Raster 17

property definitions adding GMLfor 105

property values 120data 120geometry 121

Provider for ArcSDEconnection 216defined 211

Provider for MySQLdefined 233

Provider for ODBCdefined 243

Provider for SHPdefined 263

provider defined 9

Q

querycreating 129example 130

Index | 293

R

raster propertydefined 17

references cross-schema 86requirements

FDO Provider for ArcSDE 211rollback mechanism schema 95root long transaction defined 20

S

SampleFeatureSchemaxml 115schema

defined 13schema elements 14

schema management 111schema mapping defined 14schema overrides 14schema create 89 218schemas

describing 92element states 94modifying models 94rollback mechanism 95working with 88

SDFFDO Provider for 255

software requirements 211spatial context 161spatial context defined 18special characters 147

standalone class 91states schema element 94supported interfaces LT 136

T

text expression 140text filter 140transaction long 20types

Geometry 159ObjectProperty 90

U

UnaryOperations 146

V

valuesdeleting 126updating 125

W

WKT 151

X

XML Format FDO 95

294 | Index

  • Contents
  • About This Guide
    • Audience and Purpose
    • How This Guide Is Organized
    • Whatrsquos New
      • Introduction
        • What Is the FDO API
          • From the Perspective of the Client Application User
          • From the Perspective of the Client Application Engineer
            • Getting Started
            • FDO Architecture and Providers
            • What Is a Provider
            • Developing Applications
              • FDO Concepts
                • Data Concepts
                • Operational Concepts
                  • Development Practices
                    • Memory Management
                    • Collections
                    • Exception Handling
                    • Exception Messages
                    • Managing FdoPtr Behaviors
                      • Establishing a Connection
                        • Connection Semantics
                        • Establishing a Connection
                          • FDO Capabilities
                            • FDO Capabilities
                              • Introduction
                              • Provider Type
                              • Command
                              • Connection
                              • Expression
                              • Filter
                              • Geometry
                              • Raster
                              • Schema
                                • Expressible as Boolean
                                • Not Expressible as a Boolean
                                  • Schema Management
                                    • Schema Package
                                    • Schema Mappings
                                    • Schema Overrides
                                    • Working with Schemas
                                    • FDOFeatureClass
                                    • FDOClass
                                    • Non-Feature Class Issues
                                    • Modifying Models
                                    • Schema Element States
                                    • Rollback Mechanism
                                    • FDO XML Format
                                    • Creating and Editing a GML Schema File
                                    • Schema Management Examples
                                      • Data Maintenance
                                        • Data Maintenance Operations
                                          • Inserting Values
                                          • Updating Values
                                          • Deleting Values
                                            • Related Class Topics
                                              • Performing Queries
                                                • Creating a Query
                                                • Query Example
                                                  • Long Transaction Processing
                                                    • What Is Long Transaction Processing
                                                    • Supported Interfaces
                                                      • Filter and Expression Languages
                                                        • Filters
                                                        • Expressions
                                                        • Filter and Expression Text
                                                        • Language Issues
                                                          • Provider-Specific Constraints on Filter and Expression Text
                                                          • Filter Grammar
                                                          • Expression Grammar
                                                          • Filter and Expression Keywords
                                                          • Data Types
                                                            • Identifier
                                                            • Parameter
                                                            • String
                                                            • Integer
                                                            • Double
                                                            • DateTime
                                                              • Operators
                                                              • Special Character
                                                              • Geometry Value
                                                                  • The Geometry API
                                                                    • Introduction
                                                                    • FGF and WKB
                                                                    • FGF Binary Specification
                                                                    • FGF Text
                                                                    • Abstract and Concrete Classes
                                                                    • Geometry Types
                                                                    • Mapping Between Geometry and Geometric Types
                                                                    • Spatial Context
                                                                    • Specify Dimensionality When Creating Geometries Using String Specifications
                                                                    • Inserting Geometry Values
                                                                      • FDO Cookbook
                                                                        • Introduction
                                                                        • Recommendations
                                                                        • Registry
                                                                        • Connection
                                                                        • Capabilities
                                                                        • Data Store
                                                                        • User Management
                                                                        • Spatial Context
                                                                        • Basic Schema Operations
                                                                        • Insert Data
                                                                        • Select Data
                                                                        • Select Aggregate Data
                                                                        • Delete Data
                                                                        • Schema Overrides
                                                                        • Xml SerializeDeserialize
                                                                          • C
                                                                            • Geometry
                                                                              • Construction
                                                                                • C Namespaces
                                                                                • C Geometry Scaffolding Classes
                                                                                • C Geometries Constructed using IDirectPositionImpl
                                                                                • C Geometries Constructed Using Geometry Subcomponents
                                                                                • C Aggregate Geometries
                                                                                • C Geometries from Text Specifications
                                                                                  • Deconstruction
                                                                                      • OSGeo FDO Provider for ArcSDE
                                                                                        • What Is FDO Provider for ArcSDE
                                                                                        • FDO Provider for ArcSDE Software Requirements
                                                                                          • Installed Components
                                                                                          • External Dependencies
                                                                                            • FDO Provider for ArcSDE Limitations
                                                                                            • ArcSDE Limitations
                                                                                              • Relative to ArcObjects API and ArcGIS Server API
                                                                                                • Curved Segments
                                                                                                  • Locking and Versioning
                                                                                                    • Table Creation
                                                                                                    • Identity Row ID Column and Enable Row Locking
                                                                                                    • Disable Row Locking and Enable Versioning
                                                                                                        • FDO Provider for ArcSDE Connection
                                                                                                        • Data Type Mappings
                                                                                                        • Creating a Feature Schema
                                                                                                        • Logical to Physical Schema Mapping
                                                                                                        • Physical to Logical Schema Mapping
                                                                                                        • FDO Provider for ArcSDE Capabilities
                                                                                                          • OSGeo FDO Provider for MySQL
                                                                                                            • What Is FDO Provider for MySQL
                                                                                                            • Logical to Physical Schema Mapping
                                                                                                            • Physical to Logical Schema Mapping
                                                                                                            • FDO Provider for MySQL Capabilities
                                                                                                              • OSGeo FDO Provider for ODBC
                                                                                                                • What Is FDO Provider for ODBC
                                                                                                                • Physical to Logical Schema Mappings
                                                                                                                • FDO Provider for ODBC Capabilities
                                                                                                                  • OSGeo FDO Provider for SDF
                                                                                                                    • What Is FDO Provider for SDF
                                                                                                                    • FDO Provider for SDF Capabilities
                                                                                                                      • OSGeo FDO Provider for SHP
                                                                                                                        • What Is FDO Provider for SHP
                                                                                                                        • Creating SHP Files for the Logical to Physical Schema Mapping
                                                                                                                        • Creating SHP Files for the Physical to Logical Schema Mapping
                                                                                                                        • Logical to Physical Schema Mapping
                                                                                                                        • Physical to Logical Schema Mapping
                                                                                                                        • FDO Provider for SHP Capabilities
                                                                                                                          • OSGeo FDO Provider for SQL Server Spatial
                                                                                                                            • Logical to Physical Schema Mapping
                                                                                                                            • Physical to Logical Schema Mapping
                                                                                                                              • OSGeo FDO Provider for WFS
                                                                                                                                • What Is FDO Provider for WFS
                                                                                                                                • FDO Provider for WFS Capabilities
                                                                                                                                  • OSGeo FDO Provider for WMS
                                                                                                                                    • What Is FDO Provider for WMS
                                                                                                                                    • FDO Provider for WMS Capabilities
                                                                                                                                      • Index
Page 6: here - OSGeo Download Server
Page 7: here - OSGeo Download Server
Page 8: here - OSGeo Download Server
Page 9: here - OSGeo Download Server
Page 10: here - OSGeo Download Server
Page 11: here - OSGeo Download Server
Page 12: here - OSGeo Download Server
Page 13: here - OSGeo Download Server
Page 14: here - OSGeo Download Server
Page 15: here - OSGeo Download Server
Page 16: here - OSGeo Download Server
Page 17: here - OSGeo Download Server
Page 18: here - OSGeo Download Server
Page 19: here - OSGeo Download Server
Page 20: here - OSGeo Download Server
Page 21: here - OSGeo Download Server
Page 22: here - OSGeo Download Server
Page 23: here - OSGeo Download Server
Page 24: here - OSGeo Download Server
Page 25: here - OSGeo Download Server
Page 26: here - OSGeo Download Server
Page 27: here - OSGeo Download Server
Page 28: here - OSGeo Download Server
Page 29: here - OSGeo Download Server
Page 30: here - OSGeo Download Server
Page 31: here - OSGeo Download Server
Page 32: here - OSGeo Download Server
Page 33: here - OSGeo Download Server
Page 34: here - OSGeo Download Server
Page 35: here - OSGeo Download Server
Page 36: here - OSGeo Download Server
Page 37: here - OSGeo Download Server
Page 38: here - OSGeo Download Server
Page 39: here - OSGeo Download Server
Page 40: here - OSGeo Download Server
Page 41: here - OSGeo Download Server
Page 42: here - OSGeo Download Server
Page 43: here - OSGeo Download Server
Page 44: here - OSGeo Download Server
Page 45: here - OSGeo Download Server
Page 46: here - OSGeo Download Server
Page 47: here - OSGeo Download Server
Page 48: here - OSGeo Download Server
Page 49: here - OSGeo Download Server
Page 50: here - OSGeo Download Server
Page 51: here - OSGeo Download Server
Page 52: here - OSGeo Download Server
Page 53: here - OSGeo Download Server
Page 54: here - OSGeo Download Server
Page 55: here - OSGeo Download Server
Page 56: here - OSGeo Download Server
Page 57: here - OSGeo Download Server
Page 58: here - OSGeo Download Server
Page 59: here - OSGeo Download Server
Page 60: here - OSGeo Download Server
Page 61: here - OSGeo Download Server
Page 62: here - OSGeo Download Server
Page 63: here - OSGeo Download Server
Page 64: here - OSGeo Download Server
Page 65: here - OSGeo Download Server
Page 66: here - OSGeo Download Server
Page 67: here - OSGeo Download Server
Page 68: here - OSGeo Download Server
Page 69: here - OSGeo Download Server
Page 70: here - OSGeo Download Server
Page 71: here - OSGeo Download Server
Page 72: here - OSGeo Download Server
Page 73: here - OSGeo Download Server
Page 74: here - OSGeo Download Server
Page 75: here - OSGeo Download Server
Page 76: here - OSGeo Download Server
Page 77: here - OSGeo Download Server
Page 78: here - OSGeo Download Server
Page 79: here - OSGeo Download Server
Page 80: here - OSGeo Download Server
Page 81: here - OSGeo Download Server
Page 82: here - OSGeo Download Server
Page 83: here - OSGeo Download Server
Page 84: here - OSGeo Download Server
Page 85: here - OSGeo Download Server
Page 86: here - OSGeo Download Server
Page 87: here - OSGeo Download Server
Page 88: here - OSGeo Download Server
Page 89: here - OSGeo Download Server
Page 90: here - OSGeo Download Server
Page 91: here - OSGeo Download Server
Page 92: here - OSGeo Download Server
Page 93: here - OSGeo Download Server
Page 94: here - OSGeo Download Server
Page 95: here - OSGeo Download Server
Page 96: here - OSGeo Download Server
Page 97: here - OSGeo Download Server
Page 98: here - OSGeo Download Server
Page 99: here - OSGeo Download Server
Page 100: here - OSGeo Download Server
Page 101: here - OSGeo Download Server
Page 102: here - OSGeo Download Server
Page 103: here - OSGeo Download Server
Page 104: here - OSGeo Download Server
Page 105: here - OSGeo Download Server
Page 106: here - OSGeo Download Server
Page 107: here - OSGeo Download Server
Page 108: here - OSGeo Download Server
Page 109: here - OSGeo Download Server
Page 110: here - OSGeo Download Server
Page 111: here - OSGeo Download Server
Page 112: here - OSGeo Download Server
Page 113: here - OSGeo Download Server
Page 114: here - OSGeo Download Server
Page 115: here - OSGeo Download Server
Page 116: here - OSGeo Download Server
Page 117: here - OSGeo Download Server
Page 118: here - OSGeo Download Server
Page 119: here - OSGeo Download Server
Page 120: here - OSGeo Download Server
Page 121: here - OSGeo Download Server
Page 122: here - OSGeo Download Server
Page 123: here - OSGeo Download Server
Page 124: here - OSGeo Download Server
Page 125: here - OSGeo Download Server
Page 126: here - OSGeo Download Server
Page 127: here - OSGeo Download Server
Page 128: here - OSGeo Download Server
Page 129: here - OSGeo Download Server
Page 130: here - OSGeo Download Server
Page 131: here - OSGeo Download Server
Page 132: here - OSGeo Download Server
Page 133: here - OSGeo Download Server
Page 134: here - OSGeo Download Server
Page 135: here - OSGeo Download Server
Page 136: here - OSGeo Download Server
Page 137: here - OSGeo Download Server
Page 138: here - OSGeo Download Server
Page 139: here - OSGeo Download Server
Page 140: here - OSGeo Download Server
Page 141: here - OSGeo Download Server
Page 142: here - OSGeo Download Server
Page 143: here - OSGeo Download Server
Page 144: here - OSGeo Download Server
Page 145: here - OSGeo Download Server
Page 146: here - OSGeo Download Server
Page 147: here - OSGeo Download Server
Page 148: here - OSGeo Download Server
Page 149: here - OSGeo Download Server
Page 150: here - OSGeo Download Server
Page 151: here - OSGeo Download Server
Page 152: here - OSGeo Download Server
Page 153: here - OSGeo Download Server
Page 154: here - OSGeo Download Server
Page 155: here - OSGeo Download Server
Page 156: here - OSGeo Download Server
Page 157: here - OSGeo Download Server
Page 158: here - OSGeo Download Server
Page 159: here - OSGeo Download Server
Page 160: here - OSGeo Download Server
Page 161: here - OSGeo Download Server
Page 162: here - OSGeo Download Server
Page 163: here - OSGeo Download Server
Page 164: here - OSGeo Download Server
Page 165: here - OSGeo Download Server
Page 166: here - OSGeo Download Server
Page 167: here - OSGeo Download Server
Page 168: here - OSGeo Download Server
Page 169: here - OSGeo Download Server
Page 170: here - OSGeo Download Server
Page 171: here - OSGeo Download Server
Page 172: here - OSGeo Download Server
Page 173: here - OSGeo Download Server
Page 174: here - OSGeo Download Server
Page 175: here - OSGeo Download Server
Page 176: here - OSGeo Download Server
Page 177: here - OSGeo Download Server
Page 178: here - OSGeo Download Server
Page 179: here - OSGeo Download Server
Page 180: here - OSGeo Download Server
Page 181: here - OSGeo Download Server
Page 182: here - OSGeo Download Server
Page 183: here - OSGeo Download Server
Page 184: here - OSGeo Download Server
Page 185: here - OSGeo Download Server
Page 186: here - OSGeo Download Server
Page 187: here - OSGeo Download Server
Page 188: here - OSGeo Download Server
Page 189: here - OSGeo Download Server
Page 190: here - OSGeo Download Server
Page 191: here - OSGeo Download Server
Page 192: here - OSGeo Download Server
Page 193: here - OSGeo Download Server
Page 194: here - OSGeo Download Server
Page 195: here - OSGeo Download Server
Page 196: here - OSGeo Download Server
Page 197: here - OSGeo Download Server
Page 198: here - OSGeo Download Server
Page 199: here - OSGeo Download Server
Page 200: here - OSGeo Download Server
Page 201: here - OSGeo Download Server
Page 202: here - OSGeo Download Server
Page 203: here - OSGeo Download Server
Page 204: here - OSGeo Download Server
Page 205: here - OSGeo Download Server
Page 206: here - OSGeo Download Server
Page 207: here - OSGeo Download Server
Page 208: here - OSGeo Download Server
Page 209: here - OSGeo Download Server
Page 210: here - OSGeo Download Server
Page 211: here - OSGeo Download Server
Page 212: here - OSGeo Download Server
Page 213: here - OSGeo Download Server
Page 214: here - OSGeo Download Server
Page 215: here - OSGeo Download Server
Page 216: here - OSGeo Download Server
Page 217: here - OSGeo Download Server
Page 218: here - OSGeo Download Server
Page 219: here - OSGeo Download Server
Page 220: here - OSGeo Download Server
Page 221: here - OSGeo Download Server
Page 222: here - OSGeo Download Server
Page 223: here - OSGeo Download Server
Page 224: here - OSGeo Download Server
Page 225: here - OSGeo Download Server
Page 226: here - OSGeo Download Server
Page 227: here - OSGeo Download Server
Page 228: here - OSGeo Download Server
Page 229: here - OSGeo Download Server
Page 230: here - OSGeo Download Server
Page 231: here - OSGeo Download Server
Page 232: here - OSGeo Download Server
Page 233: here - OSGeo Download Server
Page 234: here - OSGeo Download Server
Page 235: here - OSGeo Download Server
Page 236: here - OSGeo Download Server
Page 237: here - OSGeo Download Server
Page 238: here - OSGeo Download Server
Page 239: here - OSGeo Download Server
Page 240: here - OSGeo Download Server
Page 241: here - OSGeo Download Server
Page 242: here - OSGeo Download Server
Page 243: here - OSGeo Download Server
Page 244: here - OSGeo Download Server
Page 245: here - OSGeo Download Server
Page 246: here - OSGeo Download Server
Page 247: here - OSGeo Download Server
Page 248: here - OSGeo Download Server
Page 249: here - OSGeo Download Server
Page 250: here - OSGeo Download Server
Page 251: here - OSGeo Download Server
Page 252: here - OSGeo Download Server
Page 253: here - OSGeo Download Server
Page 254: here - OSGeo Download Server
Page 255: here - OSGeo Download Server
Page 256: here - OSGeo Download Server
Page 257: here - OSGeo Download Server
Page 258: here - OSGeo Download Server
Page 259: here - OSGeo Download Server
Page 260: here - OSGeo Download Server
Page 261: here - OSGeo Download Server
Page 262: here - OSGeo Download Server
Page 263: here - OSGeo Download Server
Page 264: here - OSGeo Download Server
Page 265: here - OSGeo Download Server
Page 266: here - OSGeo Download Server
Page 267: here - OSGeo Download Server
Page 268: here - OSGeo Download Server
Page 269: here - OSGeo Download Server
Page 270: here - OSGeo Download Server
Page 271: here - OSGeo Download Server
Page 272: here - OSGeo Download Server
Page 273: here - OSGeo Download Server
Page 274: here - OSGeo Download Server
Page 275: here - OSGeo Download Server
Page 276: here - OSGeo Download Server
Page 277: here - OSGeo Download Server
Page 278: here - OSGeo Download Server
Page 279: here - OSGeo Download Server
Page 280: here - OSGeo Download Server
Page 281: here - OSGeo Download Server
Page 282: here - OSGeo Download Server
Page 283: here - OSGeo Download Server
Page 284: here - OSGeo Download Server
Page 285: here - OSGeo Download Server
Page 286: here - OSGeo Download Server
Page 287: here - OSGeo Download Server
Page 288: here - OSGeo Download Server
Page 289: here - OSGeo Download Server
Page 290: here - OSGeo Download Server
Page 291: here - OSGeo Download Server
Page 292: here - OSGeo Download Server
Page 293: here - OSGeo Download Server
Page 294: here - OSGeo Download Server
Page 295: here - OSGeo Download Server
Page 296: here - OSGeo Download Server
Page 297: here - OSGeo Download Server
Page 298: here - OSGeo Download Server
Page 299: here - OSGeo Download Server
Page 300: here - OSGeo Download Server
Page 301: here - OSGeo Download Server
Page 302: here - OSGeo Download Server