public void TestSTBuffer() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var point1 = db.Select(() => GeometryInput.STGeomFromText("POINT(100 90)")); var buffer1 = db.Select(() => GeometryProcessing.STBuffer(point1, 50, "quad_segs=8").STGeometryType()); Assert.AreEqual("ST_Polygon", buffer1); var buffer2 = db.Select(() => GeometryProcessing.STBuffer(point1, 50).STNPoints()); Assert.AreEqual(33, buffer2); var buffer3 = db.Select(() => GeometryProcessing.STBuffer(point1, 50, 2).STNPoints()); Assert.AreEqual(9, buffer3); Assert.IsNull(db.Select(() => GeometryProcessing.STBuffer(null, 0))); Assert.IsNull(db.Select(() => GeometryProcessing.STBuffer(null, 0, null))); db.TestGeographies .Value(g => g.Id, 1) .Value(g => g.Geography, () => GeometryInput.STGeogFromText("POINT(0 0)")) .Insert(); var geographyPointBufferArea = db.TestGeographies .Where(g => g.Id == 1) .Select(g => g.Geography.STBuffer(50.0).STArea()) .Single(); Assert.AreEqual(7788.324, geographyPointBufferArea.Value, 1.0E-3); } }
public void TestSTBuffer() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var pt1 = db.Select(() => GeometryInput.STGeomFromText("POINT(100 90)")); var buffer1 = db.Select(() => GeometryProcessing.STBuffer(pt1, 50, "quad_segs=8").STGeometryType()); Assert.AreEqual("ST_Polygon", buffer1); var buffer2 = db.Select(() => GeometryProcessing.STBuffer(pt1, 50).STNPoints()); Assert.AreEqual(33, buffer2); var buffer3 = db.Select(() => GeometryProcessing.STBuffer(pt1, 50, 2).STNPoints()); Assert.AreEqual(9, buffer3); Assert.IsNull(db.Select(() => GeometryProcessing.STBuffer(null, 0))); Assert.IsNull(db.Select(() => GeometryProcessing.STBuffer(null, 0, null))); } }
public void TestSTRelateBool() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { const string Wkt1 = "POINT(1 2)"; const string Wkt2 = "POINT(1 2)"; Assert.IsTrue(db.Select(() => GeometryInput.STGeomFromText(Wkt1) .STRelate( GeometryProcessing.STBuffer(GeometryInput.STGeomFromText(Wkt2), 2), "0FFFFF212"))); Assert.IsNull(db.TestGeometries .Where(g => g.Id == 1) .Select(g => g.Geometry) .Select(g => g.STRelate( GeometryProcessing.STBuffer(GeometryInput.STGeomFromText(Wkt2), 2), "0FFFFF212" )).FirstOrDefault()); } }
public void TestSTContainsProperly() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { const string Point1 = "POINT(1 1)"; var query1 = from g1 in db.SelectQuery(() => GeometryProcessing.STBuffer(GeometryInput.STGeomFromText(Point1), 3)) from g2 in db.SelectQuery(() => GeometryProcessing.STBuffer(GeometryInput.STGeomFromText(Point1), 10)) select g2.STContainsProperly(g1); var result1 = query1.FirstOrDefault(); Assert.IsNotNull(result1); Assert.IsTrue(result1); var query2 = from g1 in db.TestGeometries.Where(g => g.Id == 1) from g2 in db.TestGeometries.Where(g => g.Id == 1) select g2.Geometry.STContainsProperly(g1.Geometry); var result2 = query2.FirstOrDefault(); Assert.IsNull(result2); // TODO: need explicit cast text to geometry if (this.CurrentVersion >= new Version("3.0.0")) { Assert.IsTrue( db.Select(() => SpatialRelationships.STContainsProperly( "POLYGON((0 0,1 0,1 1,0 1, 0 0))", "LINESTRING(0.2 0.2, 0.8 0.8)"))); Assert.IsFalse( db.Select(() => SpatialRelationships.STContainsProperly( "POLYGON((0 0,1 0,1 1,0 1, 0 0))", "LINESTRING(0.2 0.2, 1.2 1.2)"))); } } }