FDO API Reference Feature Data Objects

SpatialContextReader.h

Go to the documentation of this file.
00001 #ifndef FDO_XML_SPATIALCONTEXTREADER_H_
00002 #define FDO_XML_SPATIALCONTEXTREADER_H_
00003 
00004 //
00005 // Copyright (C) 2004-2006  Autodesk, Inc.
00006 // 
00007 // This library is free software; you can redistribute it and/or
00008 // modify it under the terms of version 2.1 of the GNU Lesser
00009 // General Public License as published by the Free Software Foundation.
00010 // 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 
00021 #ifdef _WIN32
00022 #pragma once
00023 #endif
00024 
00025 #include <FdoStd.h>
00026 #include <Fdo/Commands/SpatialContext/SpatialContextExtentType.h>
00027 #include <Fdo/Commands/SpatialContext/ISpatialContextReader.h>
00028 #include <Fdo/Xml/SpatialContextFlags.h>
00029 
00030 class FdoXmlSCReadHandler;
00031 
00032 /// \brief
00033 /// FdoXmlSpatialContextReader reads Spatial Contexts from an XML 
00034 /// document. Unlike other XML Readers, the reading is done procedurally, 
00035 /// rather than through events. FdoXmlSpatialContextReader implements 
00036 /// FdoISpatialContextReader to provide the functions for retrieving the 
00037 /// spatial contexts that were read.
00038 class FdoXmlSpatialContextReader : 
00039     public FdoISpatialContextReader,
00040     public FdoXmlSaxHandler
00041 {
00042 public:
00043 
00044     /// \brief
00045     /// creates a Spatial Context Reader.
00046     /// 
00047     /// \param reader 
00048     /// Input XML document reader. Specifies the XML
00049     /// document that the Spatial Contexts will be read from.
00050     /// \param flags 
00051     /// Input options for controlling the 
00052     /// deserializing of the Spatial Contexts. If NULL then the 
00053     /// default flags are used.
00054     /// 
00055     /// \return
00056     /// Returns FdoXmlSpatialContextReader
00057     /// 
00058     FDO_API static FdoXmlSpatialContextReader * Create( 
00059         FdoXmlReader*               reader,
00060         FdoXmlSpatialContextFlags*  flags = NULL
00061     );
00062 
00063     /// \brief
00064     /// Gets the Xml document reader that was passed to this object.
00065     /// 
00066     /// \return
00067     /// Returns the XML document reader.
00068     /// 
00069     FDO_API FdoXmlReader* GetXmlReader();
00070 
00071 // FdoISpatialContextReader implementation
00072 
00073     /// \brief
00074     /// Gets the name of the spatial context currently being read.
00075     /// 
00076     /// \return
00077     /// Returns the name of the spatial context.
00078     /// 
00079     FDO_API virtual FdoString* GetName();
00080 
00081     /// \brief
00082     /// Gets the description of the spatial context currently being read.
00083     /// 
00084     /// \return
00085     /// Returns the description of the spatial context.
00086     /// 
00087     FDO_API virtual FdoString* GetDescription();
00088 
00089     /// \brief
00090     /// Gets the name of the coordinate system of the spatial context currently
00091     /// being read. If the result is a null or empty string, the coordinate system is
00092     /// unknown to the spatial context.
00093     /// 
00094     /// \return
00095     /// Returns the coordinate system name of the spatial context.
00096     /// 
00097     FDO_API virtual FdoString* GetCoordinateSystem();
00098 
00099     /// \brief
00100     /// Gets the coordinate system in OpenGIS SRS WKT format of the spatial context currently
00101     /// being read. If the result is an empty string, the coordinate system WKT description is
00102     /// not available.
00103     /// 
00104     /// \return
00105     /// Returns the coordinate system description in WKT of of the spatial context.
00106     /// 
00107     FDO_API virtual FdoString* GetCoordinateSystemWkt();
00108 
00109     /// \brief
00110     /// Gets the extent type of the spatial context currently being read.
00111     /// 
00112     /// \return
00113     /// Returns the extent type.
00114     /// 
00115     FDO_API virtual FdoSpatialContextExtentType GetExtentType();
00116 
00117     /// \brief
00118     /// Gets the extent of the spatial context currently being read as a byte
00119     /// array in FGF format.
00120     /// 
00121     /// \param length 
00122     /// Output the length of the returned byte array.
00123     /// 
00124     /// \return
00125     /// Returns the extent as a byte array in FGF format.
00126     /// 
00127     FDO_API virtual FdoByteArray* GetExtent();
00128 
00129     /// \brief
00130     /// Gets the tolerance value for XY ordinates of the spatial context
00131     /// currently being read. Tolerances are used in some geometric tests,
00132     /// mostly for equality between coordinates.  This occurs frequently in spatial
00133     /// queries, especially with "on boundary" or "just touching" conditions.
00134     /// It is also an objective amount that can be used when formulating step
00135     /// distances for parametric curve interpolation.
00136     /// 
00137     /// \return
00138     /// Returns the tolerance
00139     /// 
00140     FDO_API virtual const double GetXYTolerance();
00141 
00142     /// \brief
00143     /// Gets the tolerance value for Z ordinates of the spatial context
00144     /// currently being read. Tolerances are used in some geometric tests,
00145     /// mostly for equality between coordinates.  This occurs a frequently in spatial
00146     /// queries, especially with "on boundary" or "just touching" conditions.
00147     /// It is also an objective amount that can be used when formulating step
00148     /// distances for parametric curve interpolation.
00149     /// 
00150     /// \return
00151     /// Returns the tolerance
00152     /// 
00153     FDO_API virtual const double GetZTolerance();
00154 
00155     /// \brief
00156     /// Returns true if the spatial context currently being read is the active
00157     /// spatial context.
00158     /// 
00159     /// \return
00160     /// Returns true if the current spatial context is the active one.
00161     /// 
00162     FDO_API virtual const bool IsActive();
00163 
00164     /// \brief
00165     /// Advances the reader to the next item. The default position of the reader
00166     /// is prior to the first item. Thus, you must call ReadNext to begin
00167     /// accessing any data.
00168     /// 
00169     /// \return
00170     /// Returns true if there is a next item.
00171     /// 
00172     FDO_API virtual bool ReadNext();
00173 
00174     FDO_API virtual FdoXmlSaxHandler* XmlStartDocument(FdoXmlSaxContext*);
00175 
00176     /// The following callbacks catch the start element and end element
00177     /// SAX events.
00178     FDO_API virtual FdoXmlSaxHandler* XmlStartElement( 
00179         FdoXmlSaxContext* context, 
00180         FdoString* uri, 
00181         FdoString* name, 
00182         FdoString* qname, 
00183         FdoXmlAttributeCollection* atts
00184     );
00185 
00186     FDO_API virtual FdoBoolean XmlEndElement( 
00187         FdoXmlSaxContext* context, 
00188         FdoString* uri, 
00189         FdoString* name, 
00190         FdoString* qname
00191     );
00192 
00193 
00194 protected:
00195     /// default constructor to keep linux from complaining.
00196     FdoXmlSpatialContextReader() {}
00197 
00198     FDO_API FdoXmlSpatialContextReader( 
00199         FdoXmlReader* reader,
00200         FdoXmlSpatialContextFlags* flags
00201     );
00202     FDO_API virtual ~FdoXmlSpatialContextReader();
00203 
00204     /// Closes the FdoXmlSpatialContextReader object, freeing any resources it may
00205     /// be holding.
00206     FDO_API virtual void Dispose();
00207 
00208     /// Throws an exception if a getter is called but there is no currently read Spatial Context.
00209     void ThrowOnNotRead( FdoString* function );
00210 
00211 private:
00212 
00213     FdoXmlReaderP               mXmlReader;
00214     FdoXmlSpatialContextFlagsP  mXmlFlags;
00215 
00216     FdoBoolean              mIsActiveSC;
00217     FdoByteArray*           mExtent;
00218 
00219     FdoXmlSCReadHandler*     mSCHandler;
00220 };
00221 
00222 /// \brief
00223 /// FdoXmlSpatialContextReaderP is a FdoPtr on FdoXmlSpatialContextReader, provided for convenience.
00224 typedef FdoPtr<FdoXmlSpatialContextReader> FdoXmlSpatialContextReaderP;
00225 
00226 
00227 #endif
00228 
00229 

Comments or suggestions? Send us feedback.