示例#1
0
        public void TestSTReverse()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryConstructors.STMakeLine(
                           GeometryConstructors.STMakePoint(1, 2),
                           GeometryConstructors.STMakePoint(1, 10)))
                .Insert();

                var result = db.TestGeometries
                             .Where(g => g.Id == 1)
                             .Select(g => g.Geometry.STReverse().AsText())
                             .Single();

                Assert.AreEqual("LINESTRING (1 10, 1 2)", result);

                Assert.IsNull(db.Select(() => GeometryEditors.STReverse((NTSG)null)));

                Assert.AreEqual(
                    "LINESTRING(1 10,1 2)",
                    db.Select(() => GeometryEditors.STReverse("LINESTRING(1 2,1 10)").STAsText()));
            }
        }
示例#2
0
        public void TestSTMakeLine()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(p => p.Geometry, () => GeometryConstructors.STMakeLine(
                           GeometryInput.STGeomFromText("POINT(1 2)"),
                           GeometryInput.STGeomFromText("POINT(3 4)")))
                .Insert();

                db.TestGeometries
                .Value(g => g.Id, 2)
                .Value(p => p.Geometry, () => GeometryConstructors.STMakeLine(
                           GeometryInput.STGeomFromText("LINESTRING(0 0, 1 1)"),
                           GeometryInput.STGeomFromText("LINESTRING(2 2, 3 3)")))
                .Insert();

                var line1 = db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STAsText()).Single();
                Assert.AreEqual("LINESTRING(1 2,3 4)", line1);

                var line2 = db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STAsText()).Single();
                Assert.AreEqual("LINESTRING(0 0,1 1,2 2,3 3)", line2);
            }
        }
        public void TestSTIsValidTrajectory()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () =>
                       GeometryConstructors.STMakeLine(
                           GeometryConstructors.STMakePointM(0, 0, 1),
                           GeometryConstructors.STMakePointM(0, 1, 2)))
                .Insert();

                db.TestGeometries
                .Value(g => g.Id, 2)
                .Value(g => g.Geometry, () =>
                       GeometryConstructors.STMakeLine(
                           GeometryConstructors.STMakePointM(0, 0, 1),
                           GeometryConstructors.STMakePointM(0, 1, 0)))
                .Insert();

                db.TestGeometries.Value(g => g.Id, 3)
                .Value(g => g.Geometry, () => null)
                .Insert();

                Assert.IsTrue(db.TestGeometries
                              .Where(g => g.Id == 1)
                              .Select(g => g.Geometry.STIsValidTrajectory()).Single());

                Assert.IsFalse(db.TestGeometries
                               .Where(g => g.Id == 2)
                               .Select(g => g.Geometry.STIsValidTrajectory())
                               .Single());

                Assert.IsNull(db.TestGeometries
                              .Where(g => g.Id == 3)
                              .Select(g => g.Geometry.STIsValidTrajectory())
                              .Single());

                Assert.IsTrue(db.Select(() => TrajectoryFunctions.STIsValidTrajectory("LINESTRING(0 0 0 1,0 1 0 2)")));
                Assert.IsFalse(db.Select(() => TrajectoryFunctions.STIsValidTrajectory("POINT(0 0)")));
            }
        }
示例#4
0
        public void TestSTSplit()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryConstructors.STMakeLine(GeometryConstructors.STMakePoint(10, 10), GeometryConstructors.STMakePoint(190, 190)))
                .Insert();
                db.TestGeometries
                .Value(g => g.Id, 2)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText("POINT(100 90)").STBuffer(50))
                .Insert();

                var result = db.TestGeometries
                             .Where(g => g.Id == 1)
                             .Select(g => g.Geometry.STSplit(db.TestGeometries.Where(g2 => g2.Id == 2).Single().Geometry))
                             .Single() as NTSGS.GeometryCollection;

                Assert.IsNotNull(result);
            }
        }