Changes between Initial Version and Version 1 of CodeSnippets/GetDynamicExtents


Ignore:
Timestamp:
10/15/08 10:01:17 (16 years ago)
Author:
jbirch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodeSnippets/GetDynamicExtents

    v1 v1  
     1[[PageOutline]]
     2
     3This page is an FDO Code Snippet.  Visit the CodeSnippets page to view more!
     4
     5= Calculating Dynamic Extents =
     6
     7The easiest and most efficient way of determining extents from a provider that supports dynamic extents is to use the !GetSpatialContext command.
     8
     9== C# Example ==
     10
     11{{{
     12#!cpp
     13
     14  using OSGeo.FDO.Connections;
     15  using OSGeo.FDO.Commands.SpatialContext;
     16  using OSGeo.FDO.Geometry;
     17
     18  IGetSpatialContexts getSpatialContexts = connection.CreateCommand(CommandType.CommandType_GetSpatialContexts) as IGetSpatialContexts;
     19  ISpatialContextReader reader = getSpatialContexts.Execute();
     20  IGeometry geom = null;
     21  byte[] extentAsByteArr = null;
     22  string extentAsText = null;
     23  FgfGeometryFactory geomFactory = new FgfGeometryFactory();
     24
     25  while (reader.ReadNext()) {
     26    extentAsByteArr = reader.GetExtent();
     27    // if extent type is dynamic and no geometries have been added
     28    // the extent can be null
     29    if (extentAsByteArr != null)
     30    {
     31      geom = geomFactory.CreateGeometryFromFgf(extentAsByteArr);
     32      extentAsText = geom.Text;
     33    }
     34    else
     35    {
     36      extentAsText = "No extent found";
     37    }
     38  }
     39
     40}}}
     41
     42== C++ Example ==
     43
     44{{{
     45#!cpp
     46
     47  Please add here!
     48
     49}}}
     50
     51== Contributors ==
     52
     53 * Donald Cameron
     54