当前位置: 首页>>代码示例>>C#>>正文


C# IGeometry.GetBoundingRectangle方法代码示例

本文整理汇总了C#中IGeometry.GetBoundingRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.GetBoundingRectangle方法的具体用法?C# IGeometry.GetBoundingRectangle怎么用?C# IGeometry.GetBoundingRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGeometry的用法示例。


在下文中一共展示了IGeometry.GetBoundingRectangle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

        /// <summary>
        /// Записать данные геометрического  объекта в указанный поток 
        /// </summary>
        /// <param name="geometry">Геометрический объект для записи</param>
        /// <param name="file">Поток записи</param>
        public override void Write(IGeometry geometry, BinaryWriter file)
        {
            if (!(geometry is MultiPoint))
                throw new ArgumentException("Geometry Type error: MultiPoint expected, but the type retrieved is " + geometry.GetType().Name);

            MultiPoint mpoint = geometry as MultiPoint;
            
            file.Write(int.Parse(Enum.Format(typeof(ShapeType), ShapeType, "d")));

            BoundingRectangle bounds = geometry.GetBoundingRectangle();//GetEnvelopeExternal(/*geometryFactory.PrecisionModel,*/ box);
            file.Write(bounds.MinX);
            file.Write(bounds.MinY);
            file.Write(bounds.MaxX);
            file.Write(bounds.MaxY);

            int numPoints = mpoint.ExtractCoordinates().Length;//.NumPoints;
            file.Write(numPoints);						

            // write the points 
            for (int i = 0; i < numPoints; i++)
            {
                PointD point = new PointD(mpoint.Points[i]);// Geometries[i];
                file.Write(point.X);
                file.Write(point.Y);	
            }            
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:31,代码来源:MultiPointHandler.cs

示例2: calculateOverlay

        private GeometryCollection calculateOverlay(IGeometry geometry1, IGeometry geometry2, OverlayType operation, bool performSnapping)
        {
            GeometryCollection result = new GeometryCollection();

            if (geometry1 == null && geometry2 == null)
                return result;

            if (geometry2 == null)
            {
                if (operation != OverlayType.Intersection)
                    result.Add((IGeometry)geometry1.Clone());

                return result;
            }

            if (geometry1 == null)
            {
                if (operation == OverlayType.Intersection || operation == OverlayType.Difference)
                    return result;
                result.Add((IGeometry)geometry2.Clone());

                return result;
            }

            // If the bounding rectangles do not intersect, the result of all operations can be obtained easily
            BoundingRectangle br1 = geometry1.GetBoundingRectangle();
            BoundingRectangle br2 = geometry2.GetBoundingRectangle();
            if(!br1.IsEmpty())
                br1.Grow(PlanimetryAlgorithms.Tolerance);
            if (!br2.IsEmpty())
                br2.Grow(PlanimetryAlgorithms.Tolerance);

            if (!br1.Intersects(br2))
                return calculateNonIntersectedObjectsOverlay(geometry1, geometry2, operation, performSnapping);

            // easier to convert the point-to-multipoint to preserve generality
            if (geometry1 is PointD)
            {
                PointD p = (PointD)geometry1.Clone();
                geometry1 = new MultiPoint(new ICoordinate[] { p.Coordinate });
            }

            if (geometry2 is PointD)
            {
                PointD p = (PointD)geometry2.Clone();
                geometry2 = new MultiPoint(new ICoordinate[] { p.Coordinate });
            }

            int minDim = Math.Min((int)geometry1.Dimension, (int)geometry2.Dimension);
            int maxDim = Math.Max((int)geometry1.Dimension, (int)geometry2.Dimension);

            // overlay calculation points
            if (minDim == 0 && maxDim == 0)
                getPointPointOverlay((MultiPoint)geometry1, (MultiPoint)geometry2, operation, result);

            // calculation overlay polylines
            if (minDim == 1 && maxDim == 1)
                getPolylinePolylineOverlay((Polyline)geometry1, (Polyline)geometry2, operation, result, false);

            // calculation of polygon overlay
            if (minDim == 2 && maxDim == 2)
                getPolygonPolygonOverlay((Polygon)geometry1, (Polygon)geometry2, operation, result, false);

            // calculation overlay points and polylines
            if (minDim == 0 && maxDim == 1)
            {
                if (geometry1 is MultiPoint)
                    getPointPolylineOverlay((MultiPoint)geometry1, (Polyline)geometry2, operation, result, false, false);
                else
                    getPointPolylineOverlay((MultiPoint)geometry2, (Polyline)geometry1, operation, result, false, true);
            }

            // calculation point and polygon overlay
            if (minDim == 0 && maxDim == 2)
            {
                if (geometry1 is MultiPoint)
                    getPointPolygonOverlay((MultiPoint)geometry1, (Polygon)geometry2, operation, result, false, false);
                else
                    getPointPolygonOverlay((MultiPoint)geometry2, (Polygon)geometry1, operation, result, false, true);
            }

            // calculation overlay polylines and polygons
            if (minDim == 1 && maxDim == 2)
            {
                if (geometry1 is Polyline)
                    getPolylinePolygonOverlay((Polyline)geometry1, (Polygon)geometry2, operation, result, false, false);
                else
                    getPolylinePolygonOverlay((Polyline)geometry2, (Polygon)geometry1, operation, result, false, true);
            }

            return result;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:92,代码来源:Overlays.cs

示例3: Write

        /// <summary>
        /// Записывает данные геометрического  объекта в указанный поток.
        /// </summary>
        /// <param name="geometry">Геометрический объект для записи</param>
        /// <param name="file">Поток записи</param>
        public override void Write(IGeometry geometry, BinaryWriter file)
        {            
            file.Write(int.Parse(Enum.Format(typeof(ShapeType), ShapeType, "d")));

            BoundingRectangle bounds = geometry.GetBoundingRectangle(); // GetEnvelopeExternal(/*geometryFactory.PrecisionModel,*/  box);
            file.Write(bounds.MinX);
            file.Write(bounds.MinY);
            file.Write(bounds.MaxX);
            file.Write(bounds.MaxY);

            int numParts = GetNumParts(geometry);
            int numPoints = geometry.CoordinateCount + numParts;
            file.Write(numParts);
            file.Write(numPoints);

            //parts
            int offset = 0;
            foreach (Contour contour in ((Polygon)geometry).Contours)
            {
                file.Write(offset);
                offset += contour.Vertices.Count + 1;
            }            
            
            foreach (Contour contour in ((Polygon)geometry).Contours)
            {
                System.Collections.Generic.List<ICoordinate> points = contour.Vertices.ToList();
                points.Add(PlanimetryEnvironment.NewCoordinate(contour.Vertices[0].X, contour.Vertices[0].Y));
                WriteCoords(points, file);
            }
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:35,代码来源:PolygonHandler.cs

示例4: init

        private void init(bool performSnapping)
        {
            _geometry1 = (IGeometry)_geometry1.Clone();
            if (_geometry2 != null)
                _geometry2 = (IGeometry)_geometry2.Clone();

            BoundingRectangle br = _geometry1.GetBoundingRectangle();
            if (_geometry2 != null)
                br.Join(_geometry2.GetBoundingRectangle());

            // Translating the pieces so that the origin was located in the center of the coverage.
            // This increases the accuracy of intermediate calculations.
            if (!br.IsEmpty())
            {
                _translationCenter = br.Center();

                _geometry1 = translateGeometry(_geometry1, -_translationCenter.X, -_translationCenter.Y);
                if (_geometry2 != null)
                    _geometry2 = translateGeometry(_geometry2, -_translationCenter.X, -_translationCenter.Y);

                if (performSnapping)
                {
                    _geometry1 = snapGeometryPoints(_geometry1);
                    reduceGeometrySegments(_geometry1, PlanimetryAlgorithms.Tolerance * 1.42);

                    if (_geometry2 != null)
                    {
                        _geometry2 = snapGeometryPoints(_geometry2);
                        reduceGeometrySegments(_geometry2, PlanimetryAlgorithms.Tolerance * 1.42);
                    }
                }
                else
                {
                    reduceGeometrySegments(_geometry1, PlanimetryAlgorithms.Tolerance);
                    if (_geometry2 != null)
                        reduceGeometrySegments(_geometry2, PlanimetryAlgorithms.Tolerance);
                }
            }
            else
                _translationCenter = PlanimetryEnvironment.NewCoordinate(0, 0);
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:41,代码来源:Overlays.cs

示例5: EuclideanDistance

        /// <summary>
        /// Calculates the Euclidean distance between two geometries.
        /// </summary>
        /// <param name="geometry1">First geometry</param>
        /// <param name="geometry2">Second geometry</param>
        /// /// <param name="threshold">The threshold value of the distance 
        /// at which a search is terminated</param>
        /// <returns>A distance between geometries (less than or equal to the threshold value)</returns>
        public static double EuclideanDistance(IGeometry geometry1, IGeometry geometry2, double threshold)
        {
            if (threshold < 0)
                throw new ArgumentOutOfRangeException("threshold");

            double result = 0;
            checkGeometry(geometry1);
            checkGeometry(geometry2);

            List<ICoordinate> points1 = new List<ICoordinate>(geometry1.ExtractCoordinates());
            List<ICoordinate> points2 = new List<ICoordinate>(geometry2.ExtractCoordinates());

            if (geometry1 is Polygon || geometry2 is Polygon)
            {
                if (geometry1.GetBoundingRectangle().Intersects(geometry2.GetBoundingRectangle()))
                    if (geometry1 is Polygon)
                    {
                        if (hasPointInside((Polygon)geometry1, points2))
                            return 0;
                    }
                    else
                    {
                        if (hasPointInside((Polygon)geometry2, points1))
                            return 0;
                    }
            }

            result = calculateDistanceBrutForce(geometry1, geometry2, points1, points2, threshold);

            return result;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:39,代码来源:DataStructures.cs


注:本文中的IGeometry.GetBoundingRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。