This page is an FDO Code Snippet. Visit the CodeSnippets page to view more!

Calculating Static Extents

Some providers require that you perform a SelectAggregates on a dataset to determine its extents, specifiying the SpatialExtents function as one of the properties to calculate.

C++ Example

  FdoPtr<FdoISelectAggregates> agg = (FdoISelectAggregates*)con->CreateCommand(FdoCommandType_SelectAggregates);
  FdoPtr<FdoIdentifierCollection> props = agg->GetPropertyNames();

  FdoPtr<FdoExpression> exp = FdoExpression::Parse(L"SpatialExtents(GEOMETRY)");
  FdoPtr<FdoComputedIdentifier> se = FdoComputedIdentifier::Create(L"Extents", exp);

  FdoPtr<FdoIDataReader> extrdr = agg->Execute();

  FdoPtr<FdoByteArray> ba = extrdr->GetGeometry(L"Extents");
  //ba contains the extents polygon, in FGF array form, use FdoIGeometry APIs to get the numbers out of it.

C# Example

    public IPolygon GetExtents()
            IPolygon retpolygon;
            ISelectAggregates pselagree = (ISelectAggregates)FDOConnection.CreateCommand(CommandType.CommandType_SelectAggregates);
            pselagree.SetFeatureClassName(System.IO.Path.GetFileNameWithoutExtension(OpenedFile)); // Path and name of the shape file....
            IdentifierCollection props = pselagree.PropertyNames;
            Expression exp = Expression.Parse("SpatialExtents(Geometry)");
            ComputedIdentifier se = new ComputedIdentifier("Extents", exp);


            IDataReader FDOReader = pselagree.Execute();
            FgfGeometryFactory GeoFac = new FgfGeometryFactory();

            Byte[] Tmppts = FDOReader.GetGeometry("Extents");

            IGeometry Geo = GeoFac.CreateGeometryFromFgf(Tmppts);

            retpolygon = (IPolygon)Geo;

            return retpolygon;



  • Traian Stanev
  • Shaik Esu
Last modified 9 years ago Last modified on Oct 15, 2008 8:41:00 PM