FDO .NET API Reference Feature Data Objects

mgSpatialUtility.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) 2004-2006  Autodesk, Inc.
00003 * 
00004 * This library is free software; you can redistribute it and/or
00005 * modify it under the terms of version 2.1 of the GNU Lesser
00006 * General Public License as published by the Free Software Foundation.
00007 * 
00008 * This library is distributed in the hope that it will be useful,
00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 * Lesser General Public License for more details.
00012 * 
00013 * You should have received a copy of the GNU Lesser General Public
00014 * License along with this library; if not, write to the Free Software
00015 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00016 *
00017 */
00018 
00019 #pragma once
00020 
00021 #include "mgSpatialGeometryValidity.h"
00022 
00023 BEGIN_NAMESPACE_OSGEO_GEOMETRY
00024 public __gc __interface IGeometry;
00025 public __gc __interface ILinearRing;
00026 public __gc __interface ICircularArcSegment;
00027 public __gc class ObjectFactory;
00028 public __gc class GeometryFactoryAbstract;
00029 public __gc __interface IPolygon;
00030 END_NAMESPACE_OSGEO_GEOMETRY
00031 
00032 class FdoSpatialUtility;
00033 
00034 BEGIN_NAMESPACE_OSGEO_SPATIAL
00035 
00036 /// \ingroup (OSGeoFDOSpatial)
00037 /// \brief
00038 /// A Spatial utility class.
00039 public __gc __sealed class SpatialUtility
00040 {
00041 public:
00042     /// \brief
00043     /// Approximates a geometry, which may contain parametric curve components,
00044     /// with a geometry that only contains straight, linear components.
00045     /// 
00046     /// \remarks
00047     /// If the given geometry does not require approximation, this method returns
00048     /// the input geometry, and thus avoids unnecessary object creation.
00049     /// Tolerances are in same units as the geometry's ordinates.
00050     /// If the given tolerances are both zero, a tesselated geometry is produced, 
00051     /// wherein arcs are represented using only their three defining positions.
00052     /// Math performed is all in implicit Cartesian (rectilinear) coordinate system.
00053     /// Measurement ("M") ordinates of interpolated positions undergo linear 
00054     /// interpolation from an arc's start position to end position (possibly disregarding
00055     /// an "M" ordinate in the arc's mid position).
00056     /// Unless the arc is too short for any interpolation, the "mid" point parameter
00057     /// used to define arcs is not guaranteed to appear among interpolated points.
00058     /// 
00059     /// \param geometry 
00060     /// Input Geometry to approximate
00061     /// \param maxSpacing 
00062     /// Input Maximum length of each line segment used to approximate parametric curves. Ignored if zero.
00063     /// \param maxOffset 
00064     /// Input Maximum distance that a line segment may be from the curve that it approximates (error tolerance). Ignored if zero.
00065     /// \param geometryFactory 
00066     /// Input Geometry factory for the creation of the approximated geometry.
00067     /// 
00068     /// \return
00069     /// Returns An approximation of the given geometry.
00070     /// 
00071     static NAMESPACE_OSGEO_GEOMETRY::IGeometry * ApproximateGeometryWithLineStrings(NAMESPACE_OSGEO_GEOMETRY::IGeometry * geometry, System::Double maxSpacing, System::Double maxOffset, NAMESPACE_OSGEO_GEOMETRY::GeometryFactoryAbstract * geometryFactory);
00072 
00073     /// \brief
00074     /// Tests whether a geometry can be supported using the given types and dimensionality.
00075     /// 
00076     /// \param geometry 
00077     /// Input Geometry to validate
00078     /// \param geometryTypes 
00079     /// Input Array of allowed geometry types. NULL is valid if geometryTypesCount is zero.
00080     /// \param geometryComponentTypes 
00081     /// Input Array of allowed geometry component types. NULL is valid if geometryComponentTypesCount is zero.
00082     /// \param dimensionality 
00083     /// Input Bit-mask of allowed dimensionalities (see Dimensionality).
00084     /// 
00085     /// \return
00086     /// Returns An enumeration indicating support for the given geometry.
00087     /// 
00088     static NAMESPACE_OSGEO_SPATIAL::SpatialGeometryValidity ValidateGeometryByType(NAMESPACE_OSGEO_GEOMETRY::IGeometry * geometry, NAMESPACE_OSGEO_COMMON::GeometryType geometryTypes [], NAMESPACE_OSGEO_COMMON::GeometryComponentType geometryComponentTypes [], System::Int32 dimensionality);
00089 
00090     /// \brief
00091     /// Evaluates if two FDO geometric objects spatially interact with each other based on a user supplied spatial operator.
00092     /// For example: Contains, Crosses, Disjoint, Equals, Intersects, Overlaps, Touches, Within, CoveredBy, Inside, EnvelopeIntersects.
00093     /// 
00094     /// \param g1 
00095     /// Input Left hand Geometry to Evaluate
00096     /// \param op 
00097     /// Input The spatial operation to apply to the left and right hand geometries 
00098     /// \param g2 
00099     /// Input Right hand Geometry to Evaluate
00100     /// 
00101     /// \return
00102     /// Returns The tesselated Geometry.
00103     /// 
00104     static System::Boolean Evaluate(NAMESPACE_OSGEO_GEOMETRY::IGeometry * g1, NAMESPACE_OSGEO_FDO_FILTER::SpatialOperations op, NAMESPACE_OSGEO_GEOMETRY::IGeometry * g2);
00105 
00106     /// \brief
00107     /// Tesselates a curve geometry into a set of line strings that approximate the curve geometry.
00108     /// 
00109     /// \param curve 
00110     /// Input Geometry to tesselate 
00111     /// 
00112     /// \return
00113     /// Returns The tesselated Geometry.
00114     /// 
00115     static NAMESPACE_OSGEO_GEOMETRY::IGeometry* TesselateCurve( NAMESPACE_OSGEO_GEOMETRY::IGeometry* curve);
00116 
00117     /// \brief
00118     /// Gets the extents of a geometry contained in a byte array.
00119     /// 
00120     /// \param bytes 
00121     /// Input Geometry whose extents will be returned
00122     /// \param minX 
00123     /// Output The minimim x position of the geometry
00124     /// \param minY 
00125     /// Output The minimim y position of the geometry
00126     /// \param maxX 
00127     /// Output The maximum x position of the geometry
00128     /// \param maxY 
00129     /// Output The maximum y position of the geometry
00130     /// 
00131     static System::Void GetExtents(System::Byte bytes [],  System::Double* minX, System::Double* minY, System::Double* maxX,  System::Double* maxY);
00132 
00133     /// \brief
00134     /// Gets the extents of a geometry contained in a byte array.
00135     /// 
00136     /// \param bytes 
00137     /// Input Geometry whose extents will be returned
00138     /// \param minX 
00139     /// Output The minimim x position of the geometry
00140     /// \param minY 
00141     /// Output The minimim y position of the geometry
00142     /// \param minZ 
00143     /// Output The minimim z position of the geometry
00144     /// \param maxX 
00145     /// Output The maximum x position of the geometry
00146     /// \param maxY 
00147     /// Output The maximum y position of the geometry
00148     /// \param maxZ 
00149     /// Output The maximum z position of the geometry
00150     /// 
00151     static System::Void GetExtents(System::Byte bytes [],  System::Double* minX, System::Double* minY, System::Double* minZ, System::Double* maxX,  System::Double* maxY, System::Double* maxZ);
00152 
00153     /// \brief
00154     /// Tests whether a point is within a ring or not.
00155     /// 
00156     /// \param ring 
00157     /// Input Ring to test
00158     /// \param coordinateX 
00159     /// Input X ordinate.
00160     /// \param coordinateY 
00161     /// Input Y ordinate.
00162     /// \param isOnBoundary 
00163     /// Output Specifies if the specified point is on the boundary of the ring.
00164     /// 
00165     /// \return
00166     /// Returns TRUE if the point is within ring or on its boundary, FALSE otherwise.
00167     /// 
00168     static System::Boolean PointInRing( NAMESPACE_OSGEO_GEOMETRY::ILinearRing* ring, System::Double coordinateX, System::Double coordinateY, System::Boolean* isOnBoundary);
00169 
00170     /// \brief
00171     /// Tests whether a point is within a ring or not.
00172     /// 
00173     /// \param ring 
00174     /// Input Ring to test
00175     /// \param coordinateX 
00176     /// Input X ordinate.
00177     /// \param coordinateY 
00178     /// Input Y ordinate.
00179     /// 
00180     /// \return
00181     /// Returns TRUE if the point is within ring or on its boundary, FALSE otherwise.
00182     /// 
00183     static System::Boolean PointInRing( NAMESPACE_OSGEO_GEOMETRY::ILinearRing* ring, System::Double coordinateX, System::Double coordinateY);
00184 
00185     /// \brief
00186     /// Tests whether a point is within a polygon (including its islands) or not.
00187     /// 
00188     /// \param polygon 
00189     /// Input Polygon to test
00190     /// \param coordinateX 
00191     /// Input X ordinate.
00192     /// \param coordinateY 
00193     /// Input Y ordinate.
00194     /// \param isOnExtBoundary 
00195     /// Output Specifies if the specified point is on the exterior boundary of the polygon.
00196     /// \param isOnInBoundary 
00197     /// Output Specifies if the specified point is on the interior boundary of the polygon.
00198     /// 
00199     /// \return
00200     /// Returns TRUE if the point is within polygon or on its boundary, FALSE otherwise.
00201     /// 
00202     static System::Boolean PointInPolygon(NAMESPACE_OSGEO_GEOMETRY::IPolygon* polygon, System::Double coordinateX, System::Double coordinateY, System::Boolean * isOnExtBoundary, System::Boolean * isOnInBoundary);
00203 
00204     /// \brief
00205     /// Tests whether a point is within a polygon (including its islands) or not.
00206     /// 
00207     /// \param polygon 
00208     /// Input Polygon to test
00209     /// \param coordinateX 
00210     /// Input X ordinate.
00211     /// \param coordinateY 
00212     /// Input Y ordinate.
00213     /// \param isOnExtBoundary 
00214     /// Output Specifies if the specified point is on the exterior boundary of the polygon.
00215     /// 
00216     /// \return
00217     /// Returns TRUE if the point is within polygon or on its boundary, FALSE otherwise.
00218     /// 
00219     static System::Boolean PointInPolygon(NAMESPACE_OSGEO_GEOMETRY::IPolygon* polygon, System::Double coordinateX, System::Double coordinateY, System::Boolean * isOnExtBoundary);
00220 
00221     /// \brief
00222     /// Tests whether a point is within a polygon (including its islands) or not.
00223     /// 
00224     /// \param polygon 
00225     /// Input Polygon to test
00226     /// \param coordinateX 
00227     /// Input X ordinate.
00228     /// \param coordinateY 
00229     /// Input Y ordinate.
00230     /// 
00231     /// \return
00232     /// Returns TRUE if the point is within polygon or on its boundary, FALSE otherwise.
00233     /// 
00234     static System::Boolean PointInPolygon(NAMESPACE_OSGEO_GEOMETRY::IPolygon* polygon, System::Double coordinateX, System::Double coordinateY);
00235 
00236     /// \brief
00237     /// Computes the area of a ring.
00238     /// 
00239     /// \param ring 
00240     /// Input Ring to test
00241     /// 
00242     /// \return
00243     /// Returns The area. The value may be positive (counterclockwise orientation) or
00244     /// negative (clockwise orientation) 
00245     /// 
00246     static System::Double ComputeLinearRingArea( NAMESPACE_OSGEO_GEOMETRY::ILinearRing* ring );
00247 
00248     /// \brief
00249     /// Computes the length (perimeter) of a ring.
00250     /// 
00251     /// \param ring 
00252     /// Input Ring to test
00253     /// 
00254     /// \return
00255     /// Returns The length.
00256     /// 
00257     static System::Double ComputeLinearRingLength( NAMESPACE_OSGEO_GEOMETRY::ILinearRing* ring );
00258 
00259     /// \brief
00260     /// Creates a Polygon or a MultiPolygon from a collection of rings.
00261     /// 
00262     /// \remarks
00263     /// /// 
00264     /// 
00265     /// \param rings 
00266     /// Input Collection of rings
00267     /// \param relateRings 
00268     /// Input Flag indicating if polygon formation is desired.
00269     /// If not desired (FALSE) a MultiPolygon containing only external polygons will be returned.
00270     /// When TRUE, the rings will be associated with each other, resulting in a polygon(s) with
00271     /// exterior/interior rings.
00272     /// 
00273     /// \return
00274     /// Returns The geometry containing the input rings.
00275     /// 
00276     /// Given a collection of rings the method may return, depending on flag relateRings:
00277     static NAMESPACE_OSGEO_GEOMETRY::IGeometry* CreateGeometryFromRings( NAMESPACE_OSGEO_GEOMETRY::LinearRingCollection* rings, System ::Boolean relateRings );
00278 
00279     /// \brief
00280     /// Checks the geometric validity of a circular arc.
00281     /// E.g. Checks whether the points describing the arc are collinear within a tolerance.
00282     /// 
00283     /// \param arc 
00284     /// Input Circular arc to test
00285     /// \param tolerance 
00286     /// Input Allowed tolerance
00287     /// 
00288     /// \return
00289     /// Returns Flag indicating whether the arc has collinear points.
00290     /// 
00291     static System::Boolean IsCircularArcValid( NAMESPACE_OSGEO_GEOMETRY::ICircularArcSegment *arc, System::Double tolerance );
00292 
00293 private:
00294     SpatialUtility(){}
00295 };
00296 
00297 END_NAMESPACE_OSGEO_SPATIAL
00298 
00299 

Comments or suggestions? Send us feedback.