public void TestSTAngle() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var p1 = db.Select(() => GeometryConstructors.STPoint(0, 0)); var p2 = db.Select(() => GeometryConstructors.STPoint(100, 100)); var p3 = db.Select(() => GeometryConstructors.STPoint(0, 0)); var p4 = db.Select(() => GeometryConstructors.STPoint(100, 0)); var a1 = db.Select(() => MathematicalFunctions.Degrees(MeasurementFunctions.STAngle(p1, p2, p3, p4))); Assert.AreEqual(45, a1.Value, 1.0E-8); var a2 = db.Select(() => MathematicalFunctions.Degrees(MeasurementFunctions.STAngle(p2, p1, p4))); Assert.AreEqual(45, a2.Value, 1.0E-8); Assert.IsNull(db.Select(() => MeasurementFunctions.STAngle(p1, p1, p1, p1))); } }
public void TestSTAzimuth() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var p1 = db.Select(() => GeometryConstructors.STPoint(25, 45)); var p2 = db.Select(() => GeometryConstructors.STPoint(75, 100)); var a1 = db.Select(() => MathematicalFunctions.Degrees(MeasurementFunctions.STAzimuth(p1, p2))); var a2 = db.Select(() => MathematicalFunctions.Degrees(MeasurementFunctions.STAzimuth(p2, p1))); Assert.AreEqual(42.2736890060937, a1, 1.0E-8); Assert.AreEqual(222.273689006094, a2, 1.0E-8); Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth(p1, p1))); Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth(p1, null))); Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth(null, p1))); } }
public void TestSTAzimuth() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var p1 = db.Select(() => GeometryConstructors.STPoint(25, 45)); var p2 = db.Select(() => GeometryConstructors.STPoint(75, 100)); var a1 = db.Select(() => MathematicalFunctions.Degrees(MeasurementFunctions.STAzimuth(p1, p2))); var a2 = db.Select(() => MathematicalFunctions.Degrees(MeasurementFunctions.STAzimuth(p2, p1))); Assert.AreEqual(42.2736890060937, a1.Value, 1.0E-8); Assert.AreEqual(222.273689006094, a2.Value, 1.0E-8); Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth(p1, p1))); Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth(p1, null))); Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth(null, p1))); ////Assert.IsNull(db.Select(() => MeasurementFunctions.STAzimuth((NTSG)null, (NTSG)null))); var pointA = new NTSGS.Point(0, 0) { SRID = SRID4326 }; db.Insert(new TestGeographyEntity(1, pointA)); var pointB = new NTSGS.Point(15, 5) { SRID = SRID4326 }; db.Insert(new TestGeographyEntity(2, pointB)); var azimuth = db.TestGeographies .Where(g => g.Id == 1) .Select(g => g.Geography.STAzimuth(db.TestGeographies.Where(g0 => g0.Id == 2).Single().Geography)) .Single(); Assert.AreEqual(1.24683, azimuth.Value, 1.0E-5); } }