Changes between Initial Version and Version 1 of CodeSnippets/GetStaticExtents


Ignore:
Timestamp:
Oct 15, 2008, 10:02:02 AM (16 years ago)
Author:
jbirch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodeSnippets/GetStaticExtents

    v1 v1  
     1[[PageOutline]]
     2
     3This page is an FDO Code Snippet.  Visit the CodeSnippets page to view more!
     4
     5= Calculating Static Extents =
     6
     7Some 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.
     8
     9== C++ Example ==
     10
     11{{{
     12#!cpp
     13
     14  FdoPtr<FdoISelectAggregates> agg = (FdoISelectAggregates*)con->CreateCommand(FdoCommandType_SelectAggregates);
     15  agg->SetFeatureClassName(L"MyFeatureClass");
     16  FdoPtr<FdoIdentifierCollection> props = agg->GetPropertyNames();
     17
     18  FdoPtr<FdoExpression> exp = FdoExpression::Parse(L"SpatialExtents(GEOMETRY)");
     19  FdoPtr<FdoComputedIdentifier> se = FdoComputedIdentifier::Create(L"Extents", exp);
     20  props->Add(se);
     21
     22  FdoPtr<FdoIDataReader> extrdr = agg->Execute();
     23  extrdr->ReadNext();
     24
     25  FdoPtr<FdoByteArray> ba = extrdr->GetGeometry(L"Extents");
     26  //ba contains the extents polygon, in FGF array form, use FdoIGeometry APIs to get the numbers out of it.
     27
     28}}}
     29
     30== C# Example ==
     31
     32{{{
     33#!cpp
     34
     35  public IPolygon GetExtents()
     36  {
     37    IPolygon retpolygon;
     38    ISelectAggregates pselagree = (ISelectAggregates)FDOConnection.CreateCommand(CommandType.CommandType_SelectAggregates);
     39 
     40    pselagree.SetFeatureClassName(System.IO.Path.GetFileNameWithoutExtension(OpenedFile));
     41    IFeatureReader FDOReader = pselagree.Execute();
     42    FgfGeometryFactory GeoFac = new FgfGeometryFactory();
     43
     44    Byte[] Tmppts = FDOReader.GetGeometry("Geometry");
     45
     46    IGeometry Geo = GeoFac.CreateGeometryFromFgf(Tmppts);
     47
     48    retpolygon = (IPolygon)Geo;
     49
     50    return retpolygon;
     51
     52  }
     53
     54}}}
     55
     56
     57== Contributors ==
     58
     59 * Traian Stanev
     60 * Shaik Esu
     61