/// <summary>Creates a new instance of the <see cref="FdoGeometry" /> class that encapsulates /// a copy of the specified FDO envelope, in the specified coordinate system.</summary> /// <param name="envelope">The FDO envelope for which a copy will be encapsulated.</param> /// <param name="coordinateSystem">The coordinate system of the encapsulated FDO geometry.</param> /// <remarks> /// <para>This instance encapsulates a copy of the specified <paramref name="envelope" />. It is thus /// the responsibility of the caller to <see cref="IDisposable.Dispose()" /> the specified <paramref name="envelope" />.</para> /// </remarks> public FdoEnvelope(FGeometry.IEnvelope envelope, ICoordinateSystem coordinateSystem) { Debug.Assert(envelope!=null); if (envelope==null) throw new ArgumentNullException("envelope"); Debug.Assert(coordinateSystem!=null); if (coordinateSystem==null) throw new ArgumentNullException("coordinateSystem"); _Envelope=FdoGeometryBuilder.Factory.CreateEnvelope(envelope); _CoordinateSystem=coordinateSystem; }
/// <summary>Creates a new instance of the <see cref="FdoGeometry" /> class that encapsulates /// a copy of the specified FDO geometry, in the specified coordinate system.</summary> /// <param name="geometry">The FDO geometry for which a copy will be encapsulated.</param> /// <param name="coordinateSystem">The coordinate system of the encapsulated FDO geometry.</param> /// <remarks> /// <para>This instance encapsulates a copy of the specified <paramref name="geometry" />. It is thus /// the responsibility of the caller to <see cref="IDisposable.Dispose()" /> the specified <paramref name="geometry" />.</para> /// </remarks> public FdoGeometry(FGeometry.IGeometry geometry, ICoordinateSystem coordinateSystem) { Debug.Assert(geometry!=null); if (geometry==null) throw new ArgumentNullException("geometry"); Debug.Assert(coordinateSystem!=null); if (coordinateSystem==null) throw new ArgumentNullException("coordinateSystem"); _Geometry=FdoGeometryBuilder.Factory.CreateGeometry(geometry); _CoordinateSystem=coordinateSystem; }
/// <summary> /// Creates the polygon from an envelope. /// </summary> /// <param name="env">The envelope.</param> /// <returns></returns> public static Fdo.IPolygon CreatePolygonFromEnvelope(Fdo.IEnvelope env) { FdoGeometryFactory fact = FdoGeometryFactory.Instance; Fdo.IGeometry geom = fact.CreateGeometry(env); return (Fdo.IPolygon)geom; }
/// <summary> /// Creates an R-Tree query rectangle from an FDO envelope /// </summary> /// <param name="env">The env.</param> /// <returns></returns> public static Rectangle RectFromEnvelope(Fdo.IEnvelope env) { return new Rectangle((float)env.MinX, (float)env.MinY, (float)env.MaxX, (float)env.MaxY, (float)env.MinZ, (float)env.MaxZ); }
private static void CreateFigure(IGeometrySink sink, FGeometry.DirectPositionCollection positions) { if ((positions==null) || (positions.Count==0)) return; using (FGeometry.IDirectPosition p0=positions[0]) { if (p0.Dimensionality>2) sink.BeginFigure(p0.X, p0.Y, p0.Z); else sink.BeginFigure(p0.X, p0.Y, null); } for (int i=1; i<positions.Count; ++i) using (FGeometry.IDirectPosition pi=positions[i]) { if (pi.Dimensionality>2) sink.AddLine(pi.X, pi.Y, pi.Z); else sink.AddLine(pi.X, pi.Y, null); } sink.EndFigure(); }
private static void _PopulateSimpleType(IGeometrySink sink, FGeometry.IGeometry geometry) { sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.DerivedType)); switch (geometry.DerivedType) { case FCommon.GeometryType.GeometryType_LineString: using (FGeometry.DirectPositionCollection positions=((FGeometry.ILineString)geometry).Positions) CreateFigure(sink, positions); break; case FCommon.GeometryType.GeometryType_Point: using (FGeometry.DirectPositionCollection positions=new FGeometry.DirectPositionCollection()) using (FGeometry.IDirectPosition dp=((FGeometry.IPoint)geometry).Position) { positions.Add(dp); CreateFigure(sink, positions); } break; case FCommon.GeometryType.GeometryType_Polygon: { var polygon=(FGeometry.IPolygon)geometry; using (FGeometry.ILinearRing exterior=polygon.ExteriorRing) using (FGeometry.DirectPositionCollection positions=exterior.Positions) CreateFigure(sink, positions); for (int i=0; i<polygon.InteriorRingCount; ++i) using (FGeometry.ILinearRing interior=polygon.GetInteriorRing(i)) using (FGeometry.DirectPositionCollection positions=interior.Positions) CreateFigure(sink, positions); } break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, geometry.DerivedType ) ); } sink.EndGeometry(); }