Esempio n. 1
0
        public void DBGeography_SO24405645_SO24402424()
        {
            Dapper.EntityFramework.Handlers.Register();

            connection.Execute("create table #Geo (id int, geo geography, geometry geometry)");

            var obj = new HazGeo
            {
                Id       = 1,
                Geo      = DbGeography.LineFromText("LINESTRING(-122.360 47.656, -122.343 47.656 )", 4326),
                Geometry = DbGeometry.LineFromText("LINESTRING (100 100, 20 180, 180 180)", 0)
            };

            connection.Execute("insert #Geo(id, geo, geometry) values (@Id, @Geo, @Geometry)", obj);
            var row = connection.Query <HazGeo>("select * from #Geo where id=1").SingleOrDefault();

            row.IsNotNull();
            row.Id.IsEqualTo(1);
            row.Geo.IsNotNull();
            row.Geometry.IsNotNull();
        }
Esempio n. 2
0
                private static IEnumerable <MethodInfo> GetSupportedMethods()
                {
                    yield return(GetStaticMethod(() => DbGeography.FromText(default(string))));

                    yield return(GetStaticMethod(() => DbGeography.FromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.PointFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.LineFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.PolygonFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.MultiPointFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.MultiLineFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.MultiPolygonFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.GeographyCollectionFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.FromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.FromBinary(default(byte[]))));

                    yield return(GetStaticMethod(() => DbGeography.PointFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.LineFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.PolygonFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.MultiPointFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.MultiLineFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.MultiPolygonFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.GeographyCollectionFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeography.FromGml(default(string))));

                    yield return(GetStaticMethod(() => DbGeography.FromGml(default(string), default(int))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.AsBinary()));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.AsGml()));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.AsText()));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.SpatialEquals(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Disjoint(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Intersects(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Buffer(default(double))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Distance(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Intersection(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Union(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.Difference(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.SymmetricDifference(default(DbGeography))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.ElementAt(default(int))));

                    yield return(GetInstanceMethod((DbGeography geo) => geo.PointAt(default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.FromText(default(string))));

                    yield return(GetStaticMethod(() => DbGeometry.FromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.PointFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.LineFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.PolygonFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.MultiPointFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.MultiLineFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.MultiPolygonFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.GeometryCollectionFromText(default(string), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.FromBinary(default(byte[]))));

                    yield return(GetStaticMethod(() => DbGeometry.FromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.PointFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.LineFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.PolygonFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.MultiPointFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.MultiLineFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.MultiPolygonFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.GeometryCollectionFromBinary(default(byte[]), default(int))));

                    yield return(GetStaticMethod(() => DbGeometry.FromGml(default(string))));

                    yield return(GetStaticMethod(() => DbGeometry.FromGml(default(string), default(int))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.AsBinary()));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.AsGml()));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.AsText()));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.SpatialEquals(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Disjoint(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Intersects(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Touches(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Crosses(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Within(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Contains(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Overlaps(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Relate(default(DbGeometry), default(string))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Buffer(default(double))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Distance(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Intersection(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Union(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.Difference(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.SymmetricDifference(default(DbGeometry))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.ElementAt(default(int))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.PointAt(default(int))));

                    yield return(GetInstanceMethod((DbGeometry geo) => geo.InteriorRingAt(default(int))));
                }
Esempio n. 3
0
                private static Dictionary <MethodInfo, string> GetRenamedMethodFunctions()
                {
                    var result = new Dictionary <MethodInfo, string>();

                    result.Add(GetStaticMethod(() => DbGeography.FromText(default(string))), "GeographyFromText");
                    result.Add(GetStaticMethod(() => DbGeography.FromText(default(string), default(int))), "GeographyFromText");
                    result.Add(GetStaticMethod(() => DbGeography.PointFromText(default(string), default(int))), "GeographyPointFromText");
                    result.Add(GetStaticMethod(() => DbGeography.LineFromText(default(string), default(int))), "GeographyLineFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeography.PolygonFromText(default(string), default(int))), "GeographyPolygonFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeography.MultiPointFromText(default(string), default(int))), "GeographyMultiPointFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeography.MultiLineFromText(default(string), default(int))), "GeographyMultiLineFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeography.MultiPolygonFromText(default(string), default(int))),
                        "GeographyMultiPolygonFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeography.GeographyCollectionFromText(default(string), default(int))),
                        "GeographyCollectionFromText");
                    result.Add(GetStaticMethod(() => DbGeography.FromBinary(default(byte[]), default(int))), "GeographyFromBinary");
                    result.Add(GetStaticMethod(() => DbGeography.FromBinary(default(byte[]))), "GeographyFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeography.PointFromBinary(default(byte[]), default(int))), "GeographyPointFromBinary");
                    result.Add(GetStaticMethod(() => DbGeography.LineFromBinary(default(byte[]), default(int))), "GeographyLineFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeography.PolygonFromBinary(default(byte[]), default(int))), "GeographyPolygonFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeography.MultiPointFromBinary(default(byte[]), default(int))),
                        "GeographyMultiPointFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeography.MultiLineFromBinary(default(byte[]), default(int))),
                        "GeographyMultiLineFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeography.MultiPolygonFromBinary(default(byte[]), default(int))),
                        "GeographyMultiPolygonFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeography.GeographyCollectionFromBinary(default(byte[]), default(int))),
                        "GeographyCollectionFromBinary");
                    result.Add(GetStaticMethod(() => DbGeography.FromGml(default(string))), "GeographyFromGml");
                    result.Add(GetStaticMethod(() => DbGeography.FromGml(default(string), default(int))), "GeographyFromGml");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.AsBinary()), "AsBinary");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.AsGml()), "AsGml");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.AsText()), "AsText");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.SpatialEquals(default(DbGeography))), "SpatialEquals");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Disjoint(default(DbGeography))), "SpatialDisjoint");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Intersects(default(DbGeography))), "SpatialIntersects");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Buffer(default(double))), "SpatialBuffer");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Distance(default(DbGeography))), "Distance");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Intersection(default(DbGeography))), "SpatialIntersection");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Union(default(DbGeography))), "SpatialUnion");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.Difference(default(DbGeography))), "SpatialDifference");
                    result.Add(
                        GetInstanceMethod((DbGeography geo) => geo.SymmetricDifference(default(DbGeography))), "SpatialSymmetricDifference");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.ElementAt(default(int))), "SpatialElementAt");
                    result.Add(GetInstanceMethod((DbGeography geo) => geo.PointAt(default(int))), "PointAt");
                    result.Add(GetStaticMethod(() => DbGeometry.FromText(default(string))), "GeometryFromText");
                    result.Add(GetStaticMethod(() => DbGeometry.FromText(default(string), default(int))), "GeometryFromText");
                    result.Add(GetStaticMethod(() => DbGeometry.PointFromText(default(string), default(int))), "GeometryPointFromText");
                    result.Add(GetStaticMethod(() => DbGeometry.LineFromText(default(string), default(int))), "GeometryLineFromText");
                    result.Add(GetStaticMethod(() => DbGeometry.PolygonFromText(default(string), default(int))), "GeometryPolygonFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.MultiPointFromText(default(string), default(int))), "GeometryMultiPointFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.MultiLineFromText(default(string), default(int))), "GeometryMultiLineFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.MultiPolygonFromText(default(string), default(int))),
                        "GeometryMultiPolygonFromText");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.GeometryCollectionFromText(default(string), default(int))),
                        "GeometryCollectionFromText");
                    result.Add(GetStaticMethod(() => DbGeometry.FromBinary(default(byte[]))), "GeometryFromBinary");
                    result.Add(GetStaticMethod(() => DbGeometry.FromBinary(default(byte[]), default(int))), "GeometryFromBinary");
                    result.Add(GetStaticMethod(() => DbGeometry.PointFromBinary(default(byte[]), default(int))), "GeometryPointFromBinary");
                    result.Add(GetStaticMethod(() => DbGeometry.LineFromBinary(default(byte[]), default(int))), "GeometryLineFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.PolygonFromBinary(default(byte[]), default(int))), "GeometryPolygonFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.MultiPointFromBinary(default(byte[]), default(int))),
                        "GeometryMultiPointFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.MultiLineFromBinary(default(byte[]), default(int))), "GeometryMultiLineFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.MultiPolygonFromBinary(default(byte[]), default(int))),
                        "GeometryMultiPolygonFromBinary");
                    result.Add(
                        GetStaticMethod(() => DbGeometry.GeometryCollectionFromBinary(default(byte[]), default(int))),
                        "GeometryCollectionFromBinary");
                    result.Add(GetStaticMethod(() => DbGeometry.FromGml(default(string))), "GeometryFromGml");
                    result.Add(GetStaticMethod(() => DbGeometry.FromGml(default(string), default(int))), "GeometryFromGml");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.AsBinary()), "AsBinary");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.AsGml()), "AsGml");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.AsText()), "AsText");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.SpatialEquals(default(DbGeometry))), "SpatialEquals");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Disjoint(default(DbGeometry))), "SpatialDisjoint");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Intersects(default(DbGeometry))), "SpatialIntersects");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Touches(default(DbGeometry))), "SpatialTouches");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Crosses(default(DbGeometry))), "SpatialCrosses");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Within(default(DbGeometry))), "SpatialWithin");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Contains(default(DbGeometry))), "SpatialContains");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Overlaps(default(DbGeometry))), "SpatialOverlaps");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Relate(default(DbGeometry), default(string))), "SpatialRelate");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Buffer(default(double))), "SpatialBuffer");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Distance(default(DbGeometry))), "Distance");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Intersection(default(DbGeometry))), "SpatialIntersection");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Union(default(DbGeometry))), "SpatialUnion");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.Difference(default(DbGeometry))), "SpatialDifference");
                    result.Add(
                        GetInstanceMethod((DbGeometry geo) => geo.SymmetricDifference(default(DbGeometry))), "SpatialSymmetricDifference");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.ElementAt(default(int))), "SpatialElementAt");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.PointAt(default(int))), "PointAt");
                    result.Add(GetInstanceMethod((DbGeometry geo) => geo.InteriorRingAt(default(int))), "InteriorRingAt");
                    return(result);
                }
Esempio n. 4
0
        public static void ResetDataSource()
        {
            instance = new SpatialModel();

            // Discard all local changes, and reload data from DB, them remove all
            foreach (var x in instance.People)
            {
                // Discard local changes for the person..
                instance.Entry(x).State = EntityState.Detached;
            }

            instance.People.RemoveRange(instance.People);

            // This is to set the People Id from 0
            instance.Database.ExecuteSqlCommand("DBCC CHECKIDENT ('People', RESEED, 0)");

            instance.SaveChanges();

            #region People

            #region Friends russellwhyte & scottketchum & ronaldmundy
            var person1 = new Person
            {
                PersonId     = 1,
                FirstName    = "Russell",
                LastName     = "Whyte",
                UserName     = "******",
                DbLocation   = DbGeography.FromText("POINT(52.808019 -1.345367)", 4326),
                DbLineString = DbGeography.LineFromText("LINESTRING (30 10, 10 30, 40 40)", 4326)
            };

            var person2 = new Person
            {
                PersonId     = 2,
                FirstName    = "Scott",
                LastName     = "Ketchum",
                UserName     = "******",
                DbLocation   = DbGeography.FromText("POINT(52.808019 -1.345367)", 4326),
                DbLineString = DbGeography.LineFromText("LINESTRING (40 10, 10 30, 40 40)", 4326)
            };

            var person3 = new Person
            {
                PersonId   = 3,
                FirstName  = "Ronald",
                LastName   = "Mundy",
                UserName   = "******",
                DbLocation = DbGeography.FromText("POINT(52.808019 -1.345367)", 4326)
            };

            var person4 = new Person
            {
                PersonId   = 4,
                FirstName  = "Javier",
                UserName   = "******",
                DbLocation = DbGeography.FromText("POINT(52.808019 -1.345367)", 4326)
            };

            #endregion

            instance.People.AddRange(new List <Person>
            {
                person1,
                person2,
                person3,
                person4,
            });

            #endregion

            instance.SaveChanges();
        }
Esempio n. 5
0
 public DbGeography ToDbGeography(int epsg)
 {
     return(DbGeography.LineFromText(ToWKT(), epsg));
 }