wiki:CodeSnippets/GetDynamicExtents

Version 1 (modified by jbirch, 16 years ago) ( diff )

--

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

Calculating Dynamic Extents

The easiest and most efficient way of determining extents from a provider that supports dynamic extents is to use the GetSpatialContext command.

C# Example

  using OSGeo.FDO.Connections;
  using OSGeo.FDO.Commands.SpatialContext;
  using OSGeo.FDO.Geometry;

  IGetSpatialContexts getSpatialContexts = connection.CreateCommand(CommandType.CommandType_GetSpatialContexts) as IGetSpatialContexts;
  ISpatialContextReader reader = getSpatialContexts.Execute(); 
  IGeometry geom = null; 
  byte[] extentAsByteArr = null; 
  string extentAsText = null; 
  FgfGeometryFactory geomFactory = new FgfGeometryFactory(); 

  while (reader.ReadNext()) {
    extentAsByteArr = reader.GetExtent();
    // if extent type is dynamic and no geometries have been added
    // the extent can be null
    if (extentAsByteArr != null)
    {
      geom = geomFactory.CreateGeometryFromFgf(extentAsByteArr);
      extentAsText = geom.Text;
    }
    else
    {
      extentAsText = "No extent found";
    }
  }

C++ Example

  Please add here!

Contributors

  • Donald Cameron
Note: See TracWiki for help on using the wiki.