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


C# IGeometryCollection.GetOrdinates方法代码示例

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


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

示例1: 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


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