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


C# IGeometryCollection.GetGeometryN方法代码示例

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


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

示例1: ClipGeometryCollection

        private static IGeometryCollection ClipGeometryCollection(IGeometryCollection geom, Envelope clipEnv)
        {
            var clipPoly = geom.Factory.ToGeometry(clipEnv);
            var clipped = new List<IGeometry>();
            for (var i = 0; i < geom.NumGeometries; i++)
            {
                var g = geom.GetGeometryN(i);
                IGeometry result = null;
                // don't clip unless necessary
                if (clipEnv.Contains(g.EnvelopeInternal))
                    result = g;
                else if (clipEnv.Intersects(g.EnvelopeInternal))
                {
                    result = clipPoly.Intersection(g);
                    // keep vertex key info
                    result.UserData = g.UserData;
                }

                if (result != null && !result.IsEmpty)
                {
                    clipped.Add(result);
                }
            }
            return geom.Factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(clipped));
        }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:25,代码来源:PolygonMap.cs

示例2: LoadSourceGeometries

 public void LoadSourceGeometries(IGeometryCollection geomColl)
 {
     for (int i = 0; i < geomColl.NumGeometries; i++)
     {
         IGeometry geom = geomColl.GetGeometryN(i);
         LoadVertices(geom.Coordinates, geom.UserData);
     }
 }
开发者ID:barentswatch,项目名称:NetTopologySuite,代码行数:8,代码来源:VertexTaggedGeometryDataMapper.cs

示例3: Map

 /// <summary>
 ///
 /// </summary>
 /// <param name="gc"></param>
 /// <returns></returns>
 public IGeometryCollection Map(IGeometryCollection gc)
 {
     IList<IGeometry> mapped = new List<IGeometry>();
     for (var i = 0; i < gc.NumGeometries; i++)
     {
         var g = _mapOp(gc.GetGeometryN(i));
         if (!g.IsEmpty)
             mapped.Add(g);
     }
     return gc.Factory.CreateGeometryCollection(
         GeometryFactory.ToGeometryArray(mapped));
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:17,代码来源:GeometryCollectionMapper.cs

示例4: TransformGeometryCollection

        /// <summary>
        /// Transforms a <see cref="GeoAPI.Geometries.IGeometryCollection"/>.
        /// </summary>
        /// <param name="geoms">GeometryCollection to transform</param>
        /// <param name="from">Source Projection</param>
        /// <param name="to">Target Projection</param>
        /// <param name="toFactory">The factory to create geometries for <paramref name="to"/></param>
        /// <returns>Transformed GeometryCollection</returns>
        public static IGeometryCollection TransformGeometryCollection(IGeometryCollection geoms, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
        {
            var gOut = new IGeometry[geoms.Count];
            for (var i = 0; i < geoms.Count; i++)
                gOut[i] = TransformGeometry(geoms.GetGeometryN(i), from, to, toFactory);

            return toFactory.CreateGeometryCollection(gOut);
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:16,代码来源:GeometryTransformDotSpatial.cs

示例5: WriteGeometryCollection

        /// <summary>
        /// Writes a geometrycollection.
        /// </summary>
        /// <param name="gc">The geometrycollection to be written.</param>
        /// <param name="bWriter">Stream to write to.</param>
        /// <param name="byteorder">Byte order</param>
        private static void WriteGeometryCollection(IGeometryCollection gc, BinaryWriter bWriter, WkbByteOrder byteorder)
        {
            //Get the number of geometries in this geometrycollection.
            var num = gc.NumGeometries;

            //Write the number of geometries.
            WriteUInt32((uint) num, bWriter, byteorder);

            //Loop on the number of geometries.
            //NOTE: by contract, the first item returned 
            //      from GetEnumerator (i.e. using foreach) is the IGeometryCollection itself!
            for (var i = 0; i < num; i++)
            {
                IGeometry geom = gc.GetGeometryN(i);
                //Write the byte-order format of the following geometry.
                bWriter.Write((byte) byteorder);
                //Write the type of each geometry.                
                WriteType(geom, bWriter, byteorder);
                //Write each geometry.
                WriteGeometry(geom, bWriter, byteorder);
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:28,代码来源:GeometryToWKB.cs

示例6: WriteGeometryCollection

 private void WriteGeometryCollection(IGeometryCollection gc, int level,
     StringBuilder sb)
 {
     StartLine("<MultiGeometry>\n", level, sb);
     for (int t = 0; t < gc.NumGeometries; t++)
         WriteGeometry(gc.GetGeometryN(t), level + 1, sb);
     StartLine("</MultiGeometry>\n", level, sb);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:8,代码来源:KMLWriter.cs

示例7: AppendGeometryCollectionText

 /// <summary>
 /// Converts a <c>GeometryCollection</c> to GeometryCollectionText
 /// format, then appends it to the writer.
 /// </summary>
 /// <param name="geometryCollection">The <c>GeometryCollection</c> to process.</param>
 /// <param name="level"></param>
 /// <param name="writer">The output writer to append to.</param>
 private void AppendGeometryCollectionText(IGeometryCollection geometryCollection, int level, TextWriter writer)            
 {
     if (geometryCollection.IsEmpty)
         writer.Write(" EMPTY");            
     else 
     {
         int level2 = level;
         writer.Write("(");
         for (int i = 0; i < geometryCollection.NumGeometries; i++) 
         {
             if (i > 0) 
             {
                 writer.Write(",");
                 level2 = level + 1;
             }
             AppendGeometryTaggedText(geometryCollection.GetGeometryN(i), level2, writer);
         }
         writer.Write(")");
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:27,代码来源:WKTWriter.cs

示例8: TransformGeometryCollection

 /// <summary>
 /// 
 /// </summary>
 /// <param name="geom"></param>
 /// <param name="parent"></param>
 /// <returns></returns>
 protected virtual IGeometry TransformGeometryCollection(IGeometryCollection geom, IGeometry parent) 
 {
     ArrayList transGeomList = new ArrayList();
     for (int i = 0; i < geom.NumGeometries; i++) 
     {
         IGeometry transformGeom = Transform(geom.GetGeometryN(i));
         if (transformGeom == null) continue;
         if (pruneEmptyGeometry && transformGeom.IsEmpty) continue;
         transGeomList.Add(transformGeom);
     }
     if (preserveGeometryCollectionType)
         return factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(transGeomList));
     return factory.BuildGeometry(transGeomList);
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:20,代码来源:GeometryTransformer.cs

示例9: WidestGeometry

        /// <summary>
        ///
        /// </summary>
        /// <param name="gc"></param>
        /// <returns></returns>
        private static IGeometry WidestGeometry(IGeometryCollection gc)
        {
            if (gc.IsEmpty)
                return gc;

            IGeometry widestGeometry = gc.GetGeometryN(0);
            for (int i = 1; i < gc.NumGeometries; i++) //Start at 1
                if (gc.GetGeometryN(i).EnvelopeInternal.Width > widestGeometry.EnvelopeInternal.Width)
                    widestGeometry = gc.GetGeometryN(i);
            return widestGeometry;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:16,代码来源:InteriorPointArea.cs

示例10: TransformGeometryCollection

 /// <summary>
 ///
 /// </summary>
 /// <param name="geom"></param>
 /// <param name="parent"></param>
 /// <returns></returns>
 protected virtual IGeometry TransformGeometryCollection(IGeometryCollection geom, IGeometry parent)
 {
     ArrayList transGeomList = new ArrayList();
     for (int i = 0; i < geom.NumGeometries; i++)
     {
         IGeometry transformGeom = Transform(geom.GetGeometryN(i));
         if (transformGeom == null) continue;
         if (PRUNE_EMPTY_GEOMETRY && transformGeom.IsEmpty) continue;
         transGeomList.Add(transformGeom);
     }
     return _factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(transGeomList));
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:18,代码来源:GeometryTransformer.cs

示例11: BuildSequence

        /// <summary>
        /// 
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        private static ICoordinateSequence BuildSequence(IGeometryCollection collection)
        {
            var seq = collection.Factory.CoordinateSequenceFactory.Create(collection.NumPoints,
                                                                          DetectOrdinates(collection));
            var count = 0;
            for (var i = 0; i < collection.Count; i++)
            {
                var tmp = collection.GetGeometryN(i);
                ICoordinateSequence tmpSeq = null;
                switch (tmp.OgcGeometryType)
                {
                    
                    case OgcGeometryType.Point:
                        tmpSeq = ((IPoint) tmp).CoordinateSequence;
                        break;
                    case OgcGeometryType.LineString:
                        tmpSeq = ((ILineString)tmp).CoordinateSequence;
                        break;

                    case OgcGeometryType.Polygon:
                        var poly = (IPolygon) tmp;
                        tmpSeq = poly.ExteriorRing.CoordinateSequence;
                        if (poly.NumInteriorRings > 0)
                        {
                            CoordinateSequences.Copy(tmpSeq, 0, seq, count, tmpSeq.Count);
                            int j;
                            for (j = 0; j < poly.NumInteriorRings - 1; j++)
                            {
                                tmpSeq = poly.GetInteriorRingN(j).CoordinateSequence;
                                CoordinateSequences.Copy(tmpSeq, 0, seq, count, tmpSeq.Count);
                                count += tmpSeq.Count;
                            }
                            tmpSeq = poly.GetInteriorRingN(j).CoordinateSequence;
                        }
                        break;

                    default:
                        throw new ArgumentException("Invalid geometry type");
                }

                if (tmpSeq != null)
                {
                    CoordinateSequences.Copy(tmpSeq, 0, seq, count, tmpSeq.Count);
                    count += tmpSeq.Count;
                }
            }
            return seq;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:53,代码来源:ShapeWriter.cs

示例12: DoTest

        private static void DoTest(IGeometryCollection geomsWrite, Ordinates ordinates, bool testGetOrdinate = true)
        {
            string fileName = string.Empty;

            try
            {

                fileName = Path.GetTempFileName();
                fileName = Path.ChangeExtension(fileName, "shp");
                ShapefileWriter.WriteGeometryCollection(fileName, geomsWrite);
                var reader = new ShapefileReader(fileName, ShapeFileShapeFactory.FactoryRead);
                var geomsRead = reader.ReadAll();

                // This tests x- and y- values
                if (!geomsWrite.EqualsExact(geomsRead))
                {
                    Assert.AreEqual(geomsWrite.NumGeometries, geomsRead.NumGeometries);
                    //
                    // This akward test is necessary since EqualsTopologically throws currently exceptions
                    var equal = true;
                    for (var i = 0; i < geomsRead.NumGeometries; i++)
                    {
                        var gw = geomsWrite.GetGeometryN(i);
                        var gr = geomsRead.GetGeometryN(i);
                        if (gw.IsEmpty && gr.IsEmpty)
                        {
                            if ((gw is ILineal && gr is ILineal) ||
                                (gw is IPolygonal && gr is IPolygonal))
                            {
                                // suppose these are equal
                            }
                            else
                            {
                                Console.WriteLine(string.Format("Geometries don't match at index {0}", i));
                                Console.WriteLine(string.Format("  written: {0}", gw.AsText()));
                                Console.WriteLine(string.Format("  read   : {0}", gr.AsText()));
                                equal = false;
                                Assert.IsTrue(equal, "Differenced found in geometries written and read!");
                            }
                        }
                        else if (!gw.EqualsExact(gr))
                        {
                            var hsm = new HausdorffSimilarityMeasure().Measure(gw, gr);
                            var asm = new AreaSimilarityMeasure().Measure(gw, gr);
                            var smc = SimilarityMeasureCombiner.Combine(hsm, asm);
                            if (!gw.EqualsNormalized(gr) || (1d - smc) > 1e-7)
                            {
                                Console.WriteLine(string.Format("Geometries don't match at index {0}", i));
                                Console.WriteLine(string.Format("  written: {0}", gw.AsText()));
                                Console.WriteLine(string.Format("  read   : {0}", gr.AsText()));
                                equal = false;
                                Assert.IsTrue(equal, "Differenced found in geometries written and read!");
                            }
                        }
                    }

                    //For polygons this has a tendency to fail, since the polygonhandler might rearrange the whole thing
                    if (testGetOrdinate)
                    {
                        if ((ordinates & Ordinates.Z) == Ordinates.Z)
                        {
                            var writeZ = geomsWrite.GetOrdinates(Ordinate.Z);
                            var readZ = geomsRead.GetOrdinates(Ordinate.Z);
                            Assert.IsTrue(ArraysEqual(writeZ, readZ));
                        }

                        if ((ordinates & Ordinates.M) == Ordinates.M)
                        {
                            var writeM = geomsWrite.GetOrdinates(Ordinate.M);
                            var readM = geomsRead.GetOrdinates(Ordinate.M);
                            Assert.IsTrue(ArraysEqual(writeM, readM));
                        }
                    }

                }

                // delete sample files
                File.Delete(fileName);
                File.Delete(Path.ChangeExtension(fileName, "shx"));
                File.Delete(Path.ChangeExtension(fileName, "dbf"));
            }
            catch (AssertionException ex)
            {
                Console.WriteLine("Failed test with {0}", ordinates);
                Console.WriteLine(ex.Message);
                Console.WriteLine("  Testfile '{0}' not deleted!", fileName);
                throw;
            }


        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:91,代码来源:ShapefileWriteTest.cs

示例13: FromGeometryCollection

        private static GeoAPIGeometryCollection FromGeometryCollection(IGeometryCollection geometry, GeoAPIGeometryFactory factory, bool copyUserData)
        {
            var dsGeometries = new GeoAPI.Geometries.IGeometry[geometry.NumGeometries];

            for (var i = 0; i < dsGeometries.Length; i++)
                dsGeometries[i] = FromGeometry(geometry.GetGeometryN(i), factory, copyUserData);

            var result = factory.CreateGeometryCollection(dsGeometries);
            if (copyUserData)
                result.UserData = geometry.UserData;
            return result;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:12,代码来源:GeometryConverterToGeoAPI.cs

示例14: HasRepeatedPoint

 /// <summary>
 /// 
 /// </summary>
 /// <param name="gc"></param>
 /// <returns></returns>
 private bool HasRepeatedPoint(IGeometryCollection gc)
 {
     for (int i = 0; i < gc.NumGeometries; i++)
     {
         IGeometry g = gc.GetGeometryN(i);
         if (HasRepeatedPoint(g)) 
             return true;
     }
     return false;
 }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:15,代码来源:RepeatedPointTester.cs

示例15: OLDtoShape

        /*
         // Obsolete (slower code)
        private Shape OLDtoShape(Polygon p)
        {
            ArrayList holeVertexCollection = new ArrayList();

            for (int j = 0; j < p.getNumInteriorRing(); j++) {
                holeVertexCollection.add(
                    toViewCoordinates(p.getInteriorRingN(j).getCoordinates()));
            }

            return new PolygonShape(
                toViewCoordinates(p.getExteriorRing().getCoordinates()),
                holeVertexCollection);
        }

        private Coordinate[] toViewCoordinates(Coordinate[] modelCoordinates)
        {
            Coordinate[] viewCoordinates = new Coordinate[modelCoordinates.length];

            for (int i = 0; i < modelCoordinates.length; i++) {
                Point2D point2D = toPoint(modelCoordinates[i]);
                viewCoordinates[i] = new Coordinate(point2D.getX(), point2D.getY());
            }

            return viewCoordinates;
        }
    */

        private GraphicsPath ToShape(IGeometryCollection gc)
        {
            var shape = new GeometryCollectionGraphicsPath();
            // add components to GC shape
            for (int i = 0; i < gc.NumGeometries; i++)
            {
                var g = gc.GetGeometryN(i);
                shape.Add(ToShape(g));
            }
            return shape.Path;
        }
开发者ID:abrobston,项目名称:NHibernate.Spatial,代码行数:40,代码来源:GraphicsPathWriter.cs


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