private void TestFormatting(Coordinate c) { var gs = new NtsGeometryServices(PrecisionModel.Floating.Value, 0); var rdr = new WKTReader(gs); Geometry point = gs.CreateGeometryFactory().CreatePoint(c); string result = writer.Write(point); Debug.WriteLine(result); var geom = rdr.Read(result); string tos = geom.ToString(); Assert.IsTrue(string.Equals(tos, result)); point = gs.CreateGeometryFactory(PrecisionModel.FloatingSingle.Value).CreatePoint(c); result = writer.Write(point); Debug.WriteLine(result); geom = rdr.Read(result); tos = geom.ToString(); Assert.IsTrue(string.Equals(tos, result)); point = gs.CreateGeometryFactory(PrecisionModel.Fixed.Value).CreatePoint(c); result = writer.Write(point); Debug.WriteLine(result); geom = rdr.Read(result); tos = geom.ToString(); Assert.IsTrue(string.Equals(tos, result)); }
/// <summary> /// Reads a <see cref="LinearRing"/> geometry. /// </summary> /// <param name="reader">The reader</param> /// <param name="cs">The coordinate system</param> /// <param name="srid">The spatial reference id for the geometry.</param> /// <returns>A <see cref="LinearRing"/> geometry</returns> protected LinearRing ReadLinearRing(BinaryReader reader, CoordinateSystem cs, int srid) { var factory = _geometryServices.CreateGeometryFactory(_precisionModel, srid, _sequenceFactory); int numPoints = reader.ReadInt32(); var sequence = ReadCoordinateSequenceRing(reader, numPoints, cs); return(factory.CreateLinearRing(sequence)); }
public MinimumBoundingCircleTest() { var gs = new NtsGeometryServices(PrecisionModel.Fixed.Value, 0); _geometryFactory = gs.CreateGeometryFactory(); _reader = new WKTReader(gs); }
public ConvexHullTest() { var gs = new NtsGeometryServices(new PrecisionModel(1000), 0); _geometryFactory = gs.CreateGeometryFactory(); _reader = new WKTReader(gs); }
public void Test() { var i = new NtsGeometryServices(CsFactory, PrecisionModel.Floating.Value, 0, GeometryOverlay.Legacy, new PerOrdinateEqualityComparer()); var f = i.CreateGeometryFactory(); var pt1 = f.CreatePoint(new Coordinate(1, 2)); var pt2 = f.CreatePoint(new CoordinateZ(1, 2, 3)); var pt3 = f.CreatePoint(new CoordinateM(1, 2, 4)); var pt4 = f.CreatePoint(new CoordinateZM(1, 2, 3, 4)); var pt5 = f.CreatePoint(new CoordinateZM(1, 2, double.NaN, 4)); var pt6 = f.CreatePoint(new Coordinate(1, 2)); Assert.IsFalse(pt1 == pt2); Assert.IsFalse(pt1 == pt3); Assert.IsFalse(pt1 == pt4); Assert.IsFalse(pt1 == pt5); Assert.IsTrue(pt1 == pt6); Assert.AreNotEqual(pt1, pt2); Assert.AreNotEqual(pt1, pt3); Assert.AreNotEqual(pt1, pt4); Assert.AreNotEqual(pt2, pt3); Assert.AreNotEqual(pt2, pt4); Assert.AreNotEqual(pt3, pt4); Assert.AreNotEqual(pt4, pt5); Assert.AreEqual(pt1, pt6); Assert.IsTrue(pt1 == f.CreatePoint(new CoordinateZ(1, 2))); Assert.IsTrue(pt1 == f.CreatePoint(new CoordinateM(1, 2))); Assert.IsTrue(pt1 == f.CreatePoint(new CoordinateZM(1, 2))); }
public void TestWithTolerance() { var i = new NtsGeometryServices(CsFactory, PrecisionModel.Floating.Value, 0, GeometryOverlay.Legacy, new PerOrdinateEqualityComparer()); var f = i.CreateGeometryFactory(); const double tolerance = 0.001; const double allowed = tolerance; var pt = f.CreatePoint(new CoordinateZM(1, 2, 3, 4)); Assert.That(pt == f.CreatePoint(new CoordinateZM(1 + allowed, 2, 3, 4)), Is.False); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1 + allowed, 2, 3, 4)), tolerance), Is.True); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(Math.BitIncrement(1 + allowed), 2, 3, 4)), tolerance), Is.False); Assert.That(pt == f.CreatePoint(new CoordinateZM(1 + allowed, 2, 3, 4)), Is.False); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1, 2 + allowed, 3, 4)), tolerance), Is.True); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1, Math.BitIncrement(2 + allowed), 3, 4)), tolerance), Is.False); Assert.That(pt == f.CreatePoint(new CoordinateZM(1 + allowed, 2, 3, 4)), Is.False); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1, 2, 3 - allowed, 4)), tolerance), Is.True); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1, 2, Math.BitDecrement(3 - allowed), 4)), tolerance), Is.False); Assert.That(pt == f.CreatePoint(new CoordinateZM(1 + allowed, 2, 3, 4)), Is.False); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1, 2, 3, 4 - allowed)), tolerance), Is.True); Assert.That(pt.EqualsExact(f.CreatePoint(new CoordinateZM(1, 2, 3, Math.BitDecrement(4 - allowed))), tolerance), Is.False); }
public IsValidTest() { var gs = new NtsGeometryServices(PrecisionModel.Floating.Value, 0); _geometryFactory = gs.CreateGeometryFactory(); _reader = new WKTReader(gs); }
public MiscellaneousTest() { var gs = new NtsGeometryServices(PrecisionModel.Fixed.Value, 0); _geometryFactory = gs.CreateGeometryFactory(); _reader = new WKTReader(gs); }
public LineStringImplTest() { var gs = new NtsGeometryServices(new PrecisionModel(1000)); geometryFactory = gs.CreateGeometryFactory(0); reader = new WKTReader(gs); }
public static Geometry ProjectTo(this Geometry geometry, int srid) { var geometryFactory = _geometryServices.CreateGeometryFactory(srid); var transformation = _coordinateSystemServices.CreateTransformation(geometry.SRID, srid); return(Transform(geometry, transformation.MathTransform)); }
public GeometryImplTest() { var gs = new NtsGeometryServices(CoordinateArraySequenceFactory.Instance, PrecisionModel.Fixed.Value, 0); _geometryFactory = gs.CreateGeometryFactory(); _reader = new WKTReader(gs); _readerFloat = new WKTReader(new NtsGeometryServices(CoordinateArraySequenceFactory.Instance, PrecisionModel.Floating.Value, 0)); }
public void TestReadLargeNumbers() { var precisionModel = new PrecisionModel(1E9); var gs = new NtsGeometryServices(precisionModel, 0); var geometryFactory = gs.CreateGeometryFactory(); var reader = new WKTReader(gs); var point1 = ((Point)reader.Read("POINT (123456789.01234567890 10)")).CoordinateSequence; var point2 = geometryFactory.CreatePoint(new Coordinate(123456789.01234567890, 10)).CoordinateSequence; Assert.That(point1.GetOrdinate(0, Ordinate.X), Is.EqualTo(point2.GetOrdinate(0, Ordinate.X)).Within(1E-7)); Assert.That(point1.GetOrdinate(0, Ordinate.Y), Is.EqualTo(point2.GetOrdinate(0, Ordinate.Y)).Within(1E-7)); }
public void TestInitialized() { var nts = new NtsGeometryServices( NetTopologySuite.Geometries.Implementation.DotSpatialAffineCoordinateSequenceFactory.Instance, new PrecisionModel(10d), 4326); var factory = nts.CreateGeometryFactory(); Assert.IsNotNull(factory); Assert.AreEqual(nts.DefaultSRID, factory.SRID); Assert.AreEqual(nts.DefaultPrecisionModel, factory.PrecisionModel); Assert.AreEqual(nts.DefaultCoordinateSequenceFactory, factory.CoordinateSequenceFactory); }
public static Geometry ReadGeometriesFromWkbHexString(string wkb, NtsGeometryServices services) { var reader = new WKBReader(services); var fileReader = new WKBHexFileReader(reader); var geomList = new List <Geometry>(); using (var ms = new MemoryStream()) { new StreamWriter(ms).Write(wkb); geomList.AddRange(fileReader.Read(ms)); } if (geomList.Count == 1) { return(geomList[1]); } return(services.CreateGeometryFactory().CreateGeometryCollection(GeometryFactory.ToGeometryArray(geomList))); }
public void OverlayUsingFixedPrecision() { var gs = new NtsGeometryServices(PrecisionModel.Fixed.Value, 0); var factory = gs.CreateGeometryFactory(); var reader = new WKTReader(gs); var pol = reader.Read(wktpol); Assert.IsNotNull(pol); Assert.IsTrue(pol.IsValid); Assert.IsTrue(pol.Factory.PrecisionModel == factory.PrecisionModel); var line = reader.Read(wktline); Assert.IsNotNull(line); Assert.IsTrue(line.IsValid); Assert.IsTrue(line.Factory.PrecisionModel == factory.PrecisionModel); Assert.IsTrue(pol.Intersects(line)); }
public void TestInitialized() { var nts = new NtsGeometryServices( NetTopologySuite.Geometries.Implementation.DotSpatialAffineCoordinateSequenceFactory.Instance, new PrecisionModel(10d), 4326); Assert.Throws<ArgumentNullException>(() => GeometryServiceProvider.Instance = null); GeometryServiceProvider.Instance = nts; var factory = nts.CreateGeometryFactory(); Assert.IsNotNull(factory); Assert.AreEqual(nts.DefaultSRID, factory.SRID); Assert.AreEqual(nts.DefaultPrecisionModel, factory.PrecisionModel); Assert.AreEqual(nts.DefaultCoordinateSequenceFactory, factory.CoordinateSequenceFactory); // restore default! GeometryServiceProvider.Instance = new NtsGeometryServices(); }
protected GeometryTestCase(CoordinateSequenceFactory coordinateSequenceFactory) { _geomServices = new NtsGeometryServices(coordinateSequenceFactory, PrecisionModel.Floating.Value, 0); _geomFactory = _geomServices.CreateGeometryFactory(); }
protected BaseSamples(NtsGeometryServices ntsGeometryServices) { Factory = ntsGeometryServices.CreateGeometryFactory(); Reader = new WKTReader(ntsGeometryServices); }
public GeometryFactoryTest(NtsGeometryServices ntsGeometryServices) { Factory = ntsGeometryServices.CreateGeometryFactory(); _reader = new WKTReader(ntsGeometryServices); }