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