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


C# Geometry.getPrecisionModel方法代码示例

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


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

示例1: Write

        /// <summary>
        /// Writes a <b>Geometry</b> to the given binary wirter.
        /// </summary>
        /// <param name="geometry">The geometry to write.</param>
        /// <param name="writer">The file stream to write to.</param>
        /// <param name="factory">The geometry factory to use.</param>
        public override void Write(Geometry geometry, BinaryWriter writer, GeometryFactory factory)
        {
            /* This makes exporting really slow for complex polygons
             * if (geometry.isValid() == false)
            {
                Trace.WriteLine("Invalid polygon being written.");
            }*/

            GeometryCollection multi;
            if(geometry is GeometryCollection)
            {
                multi = (GeometryCollection) geometry;
            }
            else
            {
                GeometryFactory gf = new GeometryFactory(geometry.getPrecisionModel());
                //multi = new MultiPolygon(new Polygon[]{(Polygon) geometry}, geometry.PrecisionModel, geometry.GetSRID());
                multi = gf.createMultiPolygon( new Polygon[]{(Polygon) geometry} );
            }
            //file.setLittleEndianMode(true);
            writer.Write(int.Parse(Enum.Format(typeof(ShapeType),this.ShapeType,"d")));

            Envelope box = multi.getEnvelopeInternal();
            Envelope bounds = ShapeHandler.GetEnvelopeExternal(factory.getPrecisionModel(), box);
            writer.Write(bounds.getMinX());
            writer.Write(bounds.getMinY());
            writer.Write(bounds.getMaxX());
            writer.Write(bounds.getMaxY());

            int numParts = GetNumParts(multi);
            int numPoints = multi.getNumPoints();
            writer.Write(numParts);
            writer.Write(numPoints);

            // write the offsets to the points
            int offset=0;
            for (int part = 0; part < multi.getNumGeometries(); part++)
            {
                // offset to the shell points
                Polygon polygon = (Polygon)multi.getGeometryN(part);
                writer.Write(offset);
                offset = offset + polygon.getExteriorRing().getNumPoints();
                // offstes to the holes

                for (int i = 0; i < polygon.getNumInteriorRing(); i++)
                {
                    writer.Write(offset);
                    offset = offset + polygon.getInteriorRingN(i).getNumPoints();
                }
            }

            // write the points
            for (int part = 0; part < multi.getNumGeometries(); part++)
            {
                Polygon poly = (Polygon)multi.getGeometryN(part);
                Coordinate[] coords = poly.getExteriorRing().getCoordinates();
                if (com.vividsolutions.jts.algorithm.RobustCGAlgorithms.isCCW(coords)==true)
                {
                    Array.Reverse(coords);
                    //coords = coords.ReverseCoordinateOrder();
                }
                WriteCoords(coords, writer, factory);

                for (int i = 0; i < poly.getNumInteriorRing(); i++)
                {
                    Coordinate[] coords2 = poly.getInteriorRingN(i).getCoordinates();
                    if (com.vividsolutions.jts.algorithm.RobustCGAlgorithms.isCCW(coords2)==false)
                    {
                        Array.Reverse(coords2);
                        //coords = coords.ReverseCoordinateOrder();
                    }
                    WriteCoords(coords2, writer, factory);
                }
            }
        }
开发者ID:vmoll,项目名称:geotools,代码行数:81,代码来源:PolygonHandler.cs


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