public override DbGeography Buffer(DbGeography geographyValue, double distance) { throw new NotImplementedException(); }
public override DbGeography PointAt(DbGeography geographyValue, int index) { throw new System.NotImplementedException(); }
public static DbGeography CreatePoint(double lat, double lon, int srid = 4326) { string wkt = String.Format("POINT({0} {1})", lon, lat); return(DbGeography.PointFromText(wkt, srid)); }
protected GeographyWrapper(DbGeography dbGeo) { this._dbGeo = dbGeo; }
public override bool GetIsEmpty(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override string GetSpatialTypeName(DbGeography geographyValue) { throw new System.NotImplementedException(); }
/// <summary> /// Feature转换成GGGX数据 /// </summary> /// <param name="list"></param> /// <returns></returns> public static XmlDocument FeatureToGGGX(List <GeoFeature> list) { List <GeoFeature> ftList = list; //初始化一个xml实例 XmlDocument myXmlDoc = new XmlDocument(); XmlDeclaration declaration = myXmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null); myXmlDoc.AppendChild(declaration); XmlNamespaceManager xnm = new XmlNamespaceManager(myXmlDoc.NameTable); xnm.AddNamespace("gml", "http://www.opengis.net/gml"); xnm.AddNamespace(string.Empty, "http://www.jurassic.com.cn/3gx"); //创建xml的根节点 XmlElement rootElement = myXmlDoc.CreateElement("", "FeatureCollection", "http://www.jurassic.com.cn/3gx"); rootElement.SetAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); rootElement.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); rootElement.SetAttribute("name", "GGGX数据 ");//设置该节点genre属性 rootElement.SetAttribute("xsi:schemaLocation", "http://www.jurassic.com.cn/3gx 3GX.Data.Feature.GeoMap.xsd"); myXmlDoc.AppendChild(rootElement); XmlElement crsElement = myXmlDoc.CreateElement("CRS", "http://www.jurassic.com.cn/3gx"); crsElement.SetAttribute("codeSpace", "china"); crsElement.InnerText = "地理坐标(经纬度)"; rootElement.AppendChild(crsElement); foreach (GeoFeature ft in ftList) { XmlElement gfElement = myXmlDoc.CreateElement("GF", "http://www.jurassic.com.cn/3gx"); gfElement.SetAttribute("class", ft.CLASS); gfElement.SetAttribute("id", ft.BOID); gfElement.SetAttribute("bot", ft.BOT); gfElement.SetAttribute("type", ft.FT); XmlElement titleElement = myXmlDoc.CreateElement("Title", "http://www.jurassic.com.cn/3gx"); titleElement.InnerText = ft.NAME; gfElement.AppendChild(titleElement); if (ft.AliasNameList != null) { foreach (AliasName aliasName in ft.AliasNameList) { XmlElement nameElement = myXmlDoc.CreateElement("Name"); nameElement.SetAttribute("codeSpace", aliasName.APPDOMAIN); nameElement.InnerText = aliasName.NAME; gfElement.AppendChild(nameElement); } } XmlElement PropertySetsElement = myXmlDoc.CreateElement("PropertySets", "http://www.jurassic.com.cn/3gx"); if (ft.PropertyList != null) { foreach (Property property in ft.PropertyList) { XmlDocumentFragment propertyElement = myXmlDoc.CreateDocumentFragment(); propertyElement.InnerXml = property.MD; PropertySetsElement.AppendChild(propertyElement); } } gfElement.AppendChild(PropertySetsElement); XmlElement shapesElement = myXmlDoc.CreateElement("Shapes", "http://www.jurassic.com.cn/3gx"); if (ft.GeometryList != null) { foreach (Geometry geometry in ft.GeometryList) { XmlElement shapeElement = myXmlDoc.CreateElement("Shape", "http://www.jurassic.com.cn/3gx"); shapeElement.SetAttribute("name", geometry.NAME); XmlReader reader = XmlReader.Create(new StringReader(DbGeography.FromText(geometry.GEOMETRY).AsGml())); AbstractGeometryType gml = GmlHelper.Deserialize(reader); StringWriter sw = new StringWriter(); XmlWriter xw = XmlWriter.Create(sw); GmlHelper.Serialize(xw, gml); XmlDocument shapeDoc = new XmlDocument(); shapeDoc.LoadXml(sw.ToString()); XmlDocumentFragment shape = myXmlDoc.CreateDocumentFragment(); shape.InnerXml = shapeDoc.DocumentElement.OuterXml; shapeElement.AppendChild(shape); shapesElement.AppendChild(shapeElement); } } gfElement.AppendChild(shapesElement); rootElement.AppendChild(gfElement); } return(myXmlDoc); }
/// <summary> /// 将XmlNode转换成Feature集合 /// </summary> /// <param name="nodeGF"></param> /// <returns></returns> private static List <GeoFeature> ConvertToFeatureByNode(XmlNode nodeGF) { List <GeoFeature> ftList = new List <GeoFeature>(); //对象 GeoFeature ft = new GeoFeature(); ft.BOID = null; ft.BOT = null; ft.NAME = xmlHelp.GetXmlNodeByXpath(nodeGF, "x:Title").InnerText; ft.FT = nodeGF.Attributes["type"].Value; //对象别名 List <AliasName> aliasNameList = new List <AliasName>(); foreach (XmlNode nodeAlisaName in xmlHelp.GetXmlNodeListByXpath(nodeGF, "x:Name")) { if (nodeAlisaName.Attributes["codeSpace"] == null) { continue; } AliasName aliasNameM = new AliasName(); aliasNameM.BOID = ft.BOID; aliasNameM.NAME = nodeAlisaName.InnerText; aliasNameM.APPDOMAIN = nodeAlisaName.Attributes["codeSpace"].Value; aliasNameList.Add(aliasNameM); } ft.AliasNameList = aliasNameList; //对象参数 List <Property> propertyList = new List <Property>(); foreach (XmlNode nodePropertySet in xmlHelp.GetXmlNodeListByXpath(nodeGF, "x:PropertySets/x:PropertySet")) { if (nodePropertySet.ChildNodes.Count > 0) { if (nodePropertySet.Attributes["name"] == null) { continue; } Property propertyM = new Property(); propertyM.BOID = ft.BOID; propertyM.NS = nodePropertySet.Attributes["name"].Value; propertyM.MD = nodePropertySet.OuterXml; propertyList.Add(propertyM); } else if (!string.IsNullOrEmpty(nodeGF.Attributes["class"].Value) && ft.FT == "井位") { Property propertyM = new Property(); propertyM.BOID = ft.BOID; propertyM.NS = "基础参数"; propertyM.MD = " <PropertySet name=\"基础数据\" codeSpace=\"http://www.Petrochina.com/IS/PCEDM\" xmlns=\"http://www.jurassic.com.cn/3gx\"><P n=\"井别\" t=\"String\" r=\"eq\">" + nodeGF.Attributes["class"].Value + "</P></PropertySet>"; propertyM.MdSource = "3GX数据"; if (!propertyList.Exists(p => p.MD == propertyM.MD)) { propertyList.Add(propertyM); } } } ft.PropertyList = propertyList; //对象坐标 List <Geometry> geometryList = new List <Geometry>(); foreach (XmlNode nodeShape in xmlHelp.GetXmlNodeListByXpath(nodeGF, "x:Shapes/x:Shape")) { Geometry geometryM = new Geometry(); geometryM.BOID = ft.BOID; geometryM.NAME = nodeShape.Attributes["name"] != null ? nodeShape.Attributes["name"].Value : null; geometryM.GEOMETRY = DbGeography.FromGml(nodeShape.InnerXml).AsText(); geometryList.Add(geometryM); } ft.GeometryList = geometryList; ftList.Add(ft); //子对象 foreach (XmlNode node in xmlHelp.GetXmlNodeListByXpath(nodeGF, "x:SubFeatures/x:GF")) { ConvertToFeatureByNode(node).ForEach(e => ftList.Add(e)); } return(ftList); }
public static T ToGeoJSONObject <T>(this DbGeography dbGeography) where T : GeoJSONObject { return(dbGeography.ToGeoJSONGeometry() as T); }
public void Seed(GearsOfWarContext context) { var lancer = new StandardWeapon { Name = "Lancer", Specs = new WeaponSpecification { AmmoPerClip = 60, ClipsCount = 8, } }; var gnasher = new StandardWeapon { Name = "Gnasher", Specs = new WeaponSpecification { AmmoPerClip = 8, ClipsCount = 6, }, SynergyWith = lancer, }; var hammerburst = new StandardWeapon { Name = "Hammerburst", Specs = new WeaponSpecification { AmmoPerClip = 20, ClipsCount = 7, } }; var markza = new StandardWeapon { Name = "Markza", Specs = new WeaponSpecification { AmmoPerClip = 10, ClipsCount = 12, }, SynergyWith = gnasher, }; var mulcher = new HeavyWeapon { Name = "Mulcher", Overheats = true, }; context.Weapons.AddRange(new List <Weapon> { lancer, gnasher, hammerburst, markza, mulcher, }); var deltaSquad = new Squad { Id = 1, Name = "Delta", }; var kiloSquad = new Squad { Id = 2, Name = "Kilo", }; context.Squads.AddRange(new[] { deltaSquad, kiloSquad }); var jacinto = new City { Name = "Jacinto", }; var ephyra = new City { Name = "Ephyra", }; var hanover = new City { Name = "Hanover", }; #if NET452 jacinto.Location = DbGeography.FromText("POINT(1 1)", DbGeography.DefaultCoordinateSystemId); ephyra.Location = DbGeography.FromText("POINT(2 2)", DbGeography.DefaultCoordinateSystemId); hanover.Location = DbGeography.FromText("POINT(3 3)", DbGeography.DefaultCoordinateSystemId); #endif context.Cities.AddRange(new[] { jacinto, ephyra, hanover }); var marcusTag = new CogTag { Id = Guid.NewGuid(), Note = "Marcus's Tag", }; var domsTag = new CogTag { Id = Guid.NewGuid(), Note = "Dom's Tag", }; var colesTag = new CogTag { Id = Guid.NewGuid(), Note = "Cole's Tag", }; var bairdsTag = new CogTag { Id = Guid.NewGuid(), Note = "Bairds's Tag", }; var paduksTag = new CogTag { Id = Guid.NewGuid(), Note = "Paduk's Tag", }; var kiaTag = new CogTag { Id = Guid.NewGuid(), Note = "K.I.A.", }; context.Tags.AddRange( new[] { marcusTag, domsTag, colesTag, bairdsTag, paduksTag, kiaTag }); var marcus = new Gear { Nickname = "Marcus", FullName = "Marcus Fenix", Squad = deltaSquad, Rank = MilitaryRank.Sergeant, Tag = marcusTag, CityOfBirth = jacinto, Weapons = new List <Weapon> { lancer, gnasher }, }; var dom = new Gear { Nickname = "Dom", FullName = "Dominic Santiago", Squad = deltaSquad, Rank = MilitaryRank.Corporal, Tag = domsTag, CityOfBirth = ephyra, Weapons = new List <Weapon> { hammerburst, gnasher } }; var cole = new Gear { Nickname = "Cole Train", FullName = "Augustus Cole", Squad = deltaSquad, Rank = MilitaryRank.Private, Tag = colesTag, CityOfBirth = hanover, Weapons = new List <Weapon> { gnasher, mulcher } }; var baird = new Gear { Nickname = "Baird", FullName = "Damon Baird", Squad = deltaSquad, Rank = MilitaryRank.Corporal, Tag = bairdsTag, Weapons = new List <Weapon> { lancer, gnasher } }; var paduk = new Gear { Nickname = "Paduk", FullName = "Garron Paduk", Squad = kiloSquad, Rank = MilitaryRank.Private, Tag = paduksTag, Weapons = new List <Weapon> { markza }, }; marcus.Reports = new List <Gear> { dom, cole, baird }; baird.Reports = new List <Gear> { paduk }; context.Gears.AddRange(new[] { marcus, dom, cole, baird, paduk }); context.SaveChanges(); }
/// <summary> /// Performs Address Verification on the provided <see cref="Rock.Model.Location" />. /// </summary> /// <param name="location">A <see cref="Rock.Model.Location" /> to verify.</param> /// <param name="reVerify">if set to <c>true</c> [re verify].</param> public bool Verify(Location location, bool reVerify) { bool success = false; // Do not reverify any locked locations if (location == null || (location.IsGeoPointLocked.HasValue && location.IsGeoPointLocked.Value)) { return(false); } string inputLocation = location.ToString(); // Create new context to save service log without affecting calling method's context var rockContext = new RockContext(); Model.ServiceLogService logService = new Model.ServiceLogService(rockContext); bool standardized = location.StandardizeAttemptedDateTime.HasValue && !reVerify; bool geocoded = location.GeocodeAttemptedDateTime.HasValue && !reVerify; bool anyActiveStandardizationService = false; bool anyActiveGeocodingService = false; // Save current values for situation when first service may successfully standardize or geocode, but not both // In this scenario the first service's values should be preserved string street1 = location.Street1; string street2 = location.Street2; string city = location.City; string county = location.County; string state = location.State; string country = location.Country; string postalCode = location.PostalCode; string barcode = location.Barcode; DbGeography geoPoint = location.GeoPoint; // Try each of the verification services that were found through MEF foreach (var service in Rock.Address.VerificationContainer.Instance.Components) { var component = service.Value.Value; if (component != null && component.IsActive && ( (!standardized && component.SupportsStandardization) || (!geocoded && component.SupportsGeocoding))) { string resultMsg = string.Empty; var result = component.Verify(location, out resultMsg); if (!standardized && component.SupportsStandardization) { anyActiveStandardizationService = true; // Log the service and result location.StandardizeAttemptedServiceType = service.Value.Metadata.ComponentName; location.StandardizeAttemptedResult = resultMsg; // As long as there wasn't a connection error, update the attempted datetime if ((result & Address.VerificationResult.ConnectionError) != Address.VerificationResult.ConnectionError) { location.StandardizeAttemptedDateTime = RockDateTime.Now; } // If location was successfully geocoded, update the timestamp if ((result & Address.VerificationResult.Standardized) == Address.VerificationResult.Standardized) { location.StandardizedDateTime = RockDateTime.Now; standardized = true; // Save standardized address in case another service is called for geocoding street1 = location.Street1; street2 = location.Street2; city = location.City; county = location.County; state = location.State; country = location.Country; postalCode = location.PostalCode; barcode = location.Barcode; } } else { // Reset the address back to what it was originally or after previous service successfully standardized it location.Street1 = street1; location.Street2 = street2; location.City = city; location.County = county; location.State = state; location.Country = country; location.PostalCode = postalCode; location.Barcode = barcode; } if (!geocoded && component.SupportsGeocoding) { anyActiveGeocodingService = true; // Log the service and result location.GeocodeAttemptedServiceType = service.Value.Metadata.ComponentName; location.GeocodeAttemptedResult = resultMsg; // As long as there wasn't a connection error, update the attempted datetime if ((result & Address.VerificationResult.ConnectionError) != Address.VerificationResult.ConnectionError) { location.GeocodeAttemptedDateTime = RockDateTime.Now; } // If location was successfully geocoded, update the timestamp if ((result & Address.VerificationResult.Geocoded) == Address.VerificationResult.Geocoded) { location.GeocodedDateTime = RockDateTime.Now; geocoded = true; // Save the lat/long in case another service is called for standardization geoPoint = location.GeoPoint; } } else { // Reset the lat/long back to what it was originally or after previous service successfully geocoded it location.GeoPoint = geoPoint; } // Log the results of the service if (!string.IsNullOrWhiteSpace(resultMsg)) { Model.ServiceLog log = new Model.ServiceLog(); log.LogDateTime = RockDateTime.Now; log.Type = "Location Verify"; log.Name = service.Value.Metadata.ComponentName; log.Input = inputLocation; log.Result = resultMsg.Left(200); log.Success = success; logService.Add(log); } // If location has been succesfully standardized and geocoded, break to get out, otherwise next service will be attempted if (standardized && geocoded) { break; } } } // If there is only one type of active service (standardization/geocoding) the other type's attempted datetime // needs to be updated so that the verification job will continue to process additional locations vs just getting // stuck on the first batch and doing them over and over again because the other service type's attempted date is // never updated. if (anyActiveStandardizationService && !anyActiveGeocodingService) { location.GeocodeAttemptedDateTime = RockDateTime.Now; } if (anyActiveGeocodingService && !anyActiveStandardizationService) { location.StandardizeAttemptedDateTime = RockDateTime.Now; } rockContext.SaveChanges(); return(standardized || geocoded); }
private static void SeedDb() { using var context = new AnimalContext(); context.Database.Delete(); context.Database.Create(); #region Seed TPT (Animal) var beaver1 = new Beaver { Name = "SomeBeavers1", Age = 27, Fluffiness = FluffinessEnum.VeryFluffy, Size = 15, IpAddress = "127.0.0.1" }; var beaver2 = new Beaver { Name = "SomeBeavers2", Age = 26, Fluffiness = FluffinessEnum.Fluffy, Size = 14, IpAddress = "127.0.0.1" }; var beaver3 = new Beaver { Name = "SomeBeavers3", Age = 25, Fluffiness = FluffinessEnum.NotFluffy, Size = 13, IpAddress = "127.0.0.1" }; var beaver4 = new Beaver { Name = "SomeBeavers4", Age = 24, Fluffiness = FluffinessEnum.Fluffy, Size = 12, IpAddress = "127.0.0.1" }; var beaver5 = new Beaver { Name = "SomeBeavers5", Age = 23, Fluffiness = FluffinessEnum.VeryFluffy, Size = 11, IpAddress = "127.0.0.1" }; var crow1 = new Crow { Name = "Crowly", Age = 5, Color = "black", Size = 1, IpAddress = "127.0.0.1" }; var crow2 = new Crow { Name = "Crowly1", Age = 5, Color = "black", Size = 1, IpAddress = "127.0.0.1" }; var crow3 = new Crow { Name = "Crowly2", Age = 22, Color = "black", Size = 4, IpAddress = "127.0.0.1" }; var crow4 = new Crow { Name = "Crowly3", Age = 50, Color = "white", Size = 10, IpAddress = "127.0.0.1" }; var crow5 = new Crow { Name = "Crowly4", Age = 5, Color = "pink", Size = 1, IpAddress = "127.0.0.1" }; var deer1 = new Deer { Name = "Dasher", Age = 1, Horns = true, IpAddress = "127.0.0.1" }; var deer2 = new Deer { Name = "Dancer", Age = 2, Horns = true, IpAddress = "127.0.0.1" }; var deer3 = new Deer { Name = "Prancer", Age = 1, Horns = false, IpAddress = "127.0.0.1" }; var deer4 = new Deer { Name = "Vixen", Age = 1, Horns = true, IpAddress = "127.0.0.1" }; var deer5 = new Deer { Name = "Comet", Age = 1, Horns = true, IpAddress = "127.0.0.1" }; var deer6 = new Deer { Name = "Cupid", Age = 1, Horns = false, IpAddress = "127.0.0.1" }; var deer7 = new Deer { Name = "Donder ", Age = 1, Horns = true, IpAddress = "127.0.0.1" }; var deer8 = new Deer { Name = "Blitzen", Age = 1, Horns = true, IpAddress = "127.0.0.1" }; context.Beavers.Add(beaver1); context.Beavers.Add(beaver2); context.Beavers.Add(beaver3); context.Beavers.Add(beaver4); context.Beavers.Add(beaver5); context.Crows.Add(crow1); context.Crows.Add(crow2); context.Crows.Add(crow3); context.Crows.Add(crow4); context.Crows.Add(crow5); context.Deers.Add(deer1); context.Deers.Add(deer2); context.Deers.Add(deer3); context.Deers.Add(deer4); context.Deers.Add(deer5); context.Deers.Add(deer6); context.Deers.Add(deer7); context.Deers.Add(deer8); #endregion #region Seed Many-to-many (Club) var club1 = new Club { Title = "TreesWorshipers", Animals = new List <Animal> { beaver1, beaver2, beaver3, beaver4, beaver5, crow4 }, Locations = new List <Location> { new() { Address = "North America", GeographicLocation = DbGeography.FromText("POINT(-122 47)") }, new() { Address = "Canada", GeographicLocation = DbGeography.FromText("POINT(122 40)") }, new() { Address = "Russia", GeographicLocation = DbGeography.FromText("POINT(1 1)") } } }; var club2 = new Club { Title = "CornLovers", Animals = new List <Animal> { crow1, crow2, crow3, crow4, crow5 }, Locations = new List <Location> { new() { Address = "Westeros", GeographicLocation = DbGeography.FromText("POINT(00 00)") } } }; var club3 = new Club { Title = "ChristmasTeam", Animals = new List <Animal> { beaver1, beaver2, beaver3, beaver4, beaver5, crow1, crow2, crow3, crow4, crow5, deer1, deer2, deer3, deer4, deer5, deer6, deer7, deer8 }, Locations = new List <Location> { new() { Address = "North Pole", GeographicLocation = DbGeography.FromText("POINT(9 9)") } } }; context.Clubs.Add(club1); context.Clubs.Add(club2); context.Clubs.Add(club3); #endregion #region Seed Grades var grade1 = new Grade { TheGrade = 5, Club = club1, Animal = beaver1 }; var grade2 = new Grade { TheGrade = 4, Club = club1, Animal = beaver2 }; var grade3 = new Grade { TheGrade = 3, Club = club1, Animal = beaver3 }; var grade4 = new Grade { TheGrade = 3, Club = club1, Animal = beaver4 }; var grade5 = new Grade { TheGrade = 2, Club = club1, Animal = beaver5 }; var grade6 = new Grade { TheGrade = 1, Club = club1, Animal = crow4 }; var grade7 = new Grade { TheGrade = 5, Club = club2, Animal = crow1 }; var grade8 = new Grade { TheGrade = 4.5, Club = club2, Animal = crow2 }; var grade9 = new Grade { TheGrade = 2.1, Club = club2, Animal = crow3 }; var grade10 = new Grade { TheGrade = 4.3, Club = club2, Animal = crow4 }; var grade27 = new Grade { TheGrade = 4.5, Club = club3, Animal = beaver1 }; var grade26 = new Grade { TheGrade = 4.5, Club = club3, Animal = beaver2 }; var grade25 = new Grade { TheGrade = 4.5, Club = club3, Animal = beaver3 }; var grade24 = new Grade { TheGrade = 4.5, Club = club3, Animal = beaver4 }; var grade23 = new Grade { TheGrade = 4.5, Club = club3, Animal = beaver5 }; var grade22 = new Grade { TheGrade = 4.5, Club = club3, Animal = crow1 }; var grade21 = new Grade { TheGrade = 3.5, Club = club3, Animal = crow2 }; var grade20 = new Grade { TheGrade = 2.5, Club = club3, Animal = crow3 }; var grade19 = new Grade { TheGrade = 1.5, Club = club3, Animal = crow4 }; var grade28 = new Grade { TheGrade = 4.9, Club = club3, Animal = crow5 }; var grade11 = new Grade { TheGrade = 4.8, Club = club3, Animal = deer1 }; var grade12 = new Grade { TheGrade = 4.7, Club = club3, Animal = deer2 }; var grade13 = new Grade { TheGrade = 4.6, Club = club3, Animal = deer3 }; var grade14 = new Grade { TheGrade = 4.5, Club = club3, Animal = deer4 }; var grade15 = new Grade { TheGrade = 4.4, Club = club3, Animal = deer5 }; var grade16 = new Grade { TheGrade = 4.3, Club = club3, Animal = deer6 }; var grade17 = new Grade { TheGrade = 4.2, Club = club3, Animal = deer7 }; var grade18 = new Grade { TheGrade = 4.1, Club = club3, Animal = deer8 }; context.Grades.Add(grade1); context.Grades.Add(grade2); context.Grades.Add(grade3); context.Grades.Add(grade4); context.Grades.Add(grade5); context.Grades.Add(grade6); context.Grades.Add(grade7); context.Grades.Add(grade8); context.Grades.Add(grade9); context.Grades.Add(grade10); context.Grades.Add(grade11); context.Grades.Add(grade12); context.Grades.Add(grade13); context.Grades.Add(grade14); context.Grades.Add(grade15); context.Grades.Add(grade16); context.Grades.Add(grade17); context.Grades.Add(grade18); context.Grades.Add(grade19); context.Grades.Add(grade20); context.Grades.Add(grade21); context.Grades.Add(grade22); context.Grades.Add(grade23); context.Grades.Add(grade24); context.Grades.Add(grade25); context.Grades.Add(grade26); context.Grades.Add(grade27); context.Grades.Add(grade28); #endregion #region Seed Jobs var job1 = new Job { Title = "Builder", Salary = 1, Animals = new List <Animal> { beaver1, beaver2, beaver3, beaver4, beaver5 } }; var job2 = new Job { Title = "Messenger", Salary = 10, Animals = new List <Animal> { crow1, crow2, crow3, crow4 } }; var job3 = new Job { Title = "Delivery", Salary = 100, Animals = new List <Animal> { deer1, deer2, deer3, deer4, deer5, deer6, deer7, deer8 } }; context.Jobs.Add(job1); context.Jobs.Add(job2); context.Jobs.Add(job3); #endregion #region Seed TPH (Food) var food1 = new NormalFood { Title = "Elm", Animal = beaver1, Taste = Taste.Normal }; var food2 = new VeganFood { Title = "Daphne laureola", Animal = beaver2, Calories = 100 }; var food3 = new VeganFood { Title = "Carpinus betulus", Animal = beaver3, Calories = 1001 }; var food4 = new VeganFood { Title = "Hornbeam", Animal = beaver4, Calories = 101 }; var food5 = new NormalFood { Title = "Pizza", Animal = beaver5, Taste = Taste.Excellent }; var food6 = new NormalFood { Title = "Steak", Animal = crow1, Taste = Taste.Excellent }; var food7 = new NormalFood { Title = "Meat", Animal = crow2, Taste = Taste.Good }; var food8 = new NormalFood { Title = "Pizza", Animal = crow3, Taste = Taste.VeryGood }; var food9 = new VeganFood { Title = "Corn", Animal = crow4, Calories = 1 }; var food10 = new NormalFood { Title = "Pizza", Animal = crow5, Taste = Taste.Normal }; var food11 = new VeganFood { Title = "Pizza", Animal = deer1, Calories = 10 }; var food12 = new VeganFood { Title = "Pizza", Animal = deer2, Calories = 10 }; var food13 = new VeganFood { Title = "Pizza", Animal = deer3, Calories = 10 }; var food14 = new VeganFood { Title = "Pizza", Animal = deer4, Calories = 10 }; var food15 = new VeganFood { Title = "Pizza", Animal = deer5, Calories = 10 }; var food16 = new VeganFood { Title = "Pizza", Animal = deer6, Calories = 10 }; var food17 = new NormalFood { Title = "Elves", Animal = deer7, Taste = Taste.Excellent }; var food18 = new VeganFood { Title = "Pizza", Animal = deer8, Calories = 10 }; context.Food.Add(food1); context.Food.Add(food2); context.Food.Add(food3); context.Food.Add(food4); context.Food.Add(food5); context.Food.Add(food6); context.Food.Add(food7); context.Food.Add(food8); context.Food.Add(food9); context.Food.Add(food10); context.Food.Add(food11); context.Food.Add(food12); context.Food.Add(food13); context.Food.Add(food14); context.Food.Add(food15); context.Food.Add(food16); context.Food.Add(food17); context.Food.Add(food18); #endregion #region Seed Many-to-many old style (Drawback) var drawback1 = new Drawback { Title = "Crowdy", Foods = new List <Food> { food1, food2, food3, food4, /*food5,*/ food6, food7, food8, food9, food10, food11, food12, food13, food14, food15, food16, food17, food18 }, Clubs = new List <Club> { club1, club2, club3 }, Consequence = new Consequence { Name = "Nervousness" }, DrawbackDetail = new DrawbackDetails { DateCreated = DateTime.Now, Description = "the quality or state of being nervous" } }; var drawback2 = new Drawback { Title = "Windy", Foods = new List <Food> { food1, food2, food3, food4, food5, food6, food7, food8, food9, food10, food11, food12, food13, food14, food15, food16, food17, food18 }, Clubs = new List <Club> { club1, club2, club3 }, Consequence = new Consequence { Name = "Teleportation to Land of Oz" }, DrawbackDetail = new DrawbackDetails { DateCreated = DateTime.Now, Description = "hallucination" } }; var drawback3 = new Drawback { Title = "Soggy", Foods = new List <Food> { food1, food2, food3, food4, food5, food6, food7, food8, food9, food10, food11, food12, food13, food14, food15, food16, food17, food18 }, Clubs = new List <Club> { club1, club2, club3 }, Consequence = new Consequence { Name = "Wet clothes" }, DrawbackDetail = new DrawbackDetails { DateCreated = DateTime.Now, Description = "cold" } }; var drawback4 = new Drawback { Title = "Hardy", Foods = new List <Food> { food1, food2, food3, food4, food5, food6, food7, food8, food9, food10, food11, food12, food13, food14, food15, food16, food17, food18 }, Clubs = new List <Club> { club1, club2, club3 }, Consequence = new Consequence { Name = "Sadness" }, DrawbackDetail = new DrawbackDetails { DateCreated = DateTime.Now, Description = "the condition or quality of being sad" } }; context.Drawbacks.Add(drawback1); context.Drawbacks.Add(drawback2); context.Drawbacks.Add(drawback3); context.Drawbacks.Add(drawback4); var jobDrawback1 = new JobDrawback { Job = job1, Drawback = drawback1 }; var jobDrawback2 = new JobDrawback { Job = job1, Drawback = drawback2 }; var jobDrawback3 = new JobDrawback { Job = job1, Drawback = drawback3 }; var jobDrawback4 = new JobDrawback { Job = job1, Drawback = drawback4 }; var jobDrawback5 = new JobDrawback { Job = job2, Drawback = drawback1 }; var jobDrawback6 = new JobDrawback { Job = job2, Drawback = drawback2 }; var jobDrawback7 = new JobDrawback { Job = job3, Drawback = drawback1 }; var jobDrawback8 = new JobDrawback { Job = job3, Drawback = drawback2 }; context.JobDrawbacks.Add(jobDrawback1); context.JobDrawbacks.Add(jobDrawback2); context.JobDrawbacks.Add(jobDrawback3); context.JobDrawbacks.Add(jobDrawback4); context.JobDrawbacks.Add(jobDrawback5); context.JobDrawbacks.Add(jobDrawback6); context.JobDrawbacks.Add(jobDrawback7); context.JobDrawbacks.Add(jobDrawback8); #endregion #region Seed Persons var person1 = new Person { Name = "BeaverPerson", AnimalsLoved = new List <Animal> { beaver1, beaver2, beaver3, beaver4, beaver5 }, AnimalsHated = new List <Animal> { deer1, deer2, deer3, deer4, deer5, deer6, deer7, deer8 } }; context.Persons.Add(person1); #endregion context.SaveChanges(); }
private void Seed() { using (var context = new IceAndFireModel.IceAndFireContext(_entityConnectionString)) { if (context.Creatures.Count() > 0) { return; } var aryaStark = new IceAndFireModel.Human { Name = "Arya", PlaceOfBirth = DbGeography.FromText("POINT (1 1)", GeographySrid), Size = IceAndFireModel.CreatureSize.Small, }; var sansaStark = new IceAndFireModel.Human { Name = "Sansa", PlaceOfBirth = DbGeography.FromText("POINT (1 1)", GeographySrid), Size = IceAndFireModel.CreatureSize.Small, }; var branStark = new IceAndFireModel.Human { Name = "Brandon", PlaceOfBirth = DbGeography.FromText("POINT (1 1)", GeographySrid), Size = IceAndFireModel.CreatureSize.Small, }; var ricksonStark = new IceAndFireModel.Human { Name = "Rickson", PlaceOfBirth = DbGeography.FromText("POINT (1 1)", GeographySrid), Size = IceAndFireModel.CreatureSize.Small, }; var stannisBaratheon = new IceAndFireModel.Human { Name = "Stannis", PlaceOfBirth = DbGeography.FromText("POINT (2 2)", GeographySrid), Size = IceAndFireModel.CreatureSize.Medium, }; var tyrionLannister = new IceAndFireModel.Human { Name = "Tyrion", PlaceOfBirth = DbGeography.FromText("POINT (3 3)", GeographySrid), Size = IceAndFireModel.CreatureSize.Small, }; var jamieLannister = new IceAndFireModel.Human { Name = "Jamie", PlaceOfBirth = DbGeography.FromText("POINT (3 3)", GeographySrid), Size = IceAndFireModel.CreatureSize.Medium, }; var cerseiLannister = new IceAndFireModel.Human { Name = "Cersei", PlaceOfBirth = DbGeography.FromText("POINT (3 3)", GeographySrid), Size = IceAndFireModel.CreatureSize.Medium, }; var jonSnow = new IceAndFireModel.Human { Name = "Jon", PlaceOfBirth = DbGeography.FromText("POINT (4 4)", GeographySrid), Size = IceAndFireModel.CreatureSize.Small, }; var daenerysTargaryen = new IceAndFireModel.Human { Name = "Daenerys", PlaceOfBirth = DbGeography.FromText("POINT (5 5)", GeographySrid), Size = IceAndFireModel.CreatureSize.Medium, }; var aegonTargaryen = new IceAndFireModel.Human { Name = "Aegon", PlaceOfBirth = DbGeography.FromText("POINT (5 5)", GeographySrid), Size = IceAndFireModel.CreatureSize.Medium, }; var aurochs = new IceAndFireModel.Animal { IsCarnivore = false, IsDangerous = false, Name = "Aurochs", Size = IceAndFireModel.CreatureSize.Large, }; var direwolf = new IceAndFireModel.Animal { IsCarnivore = true, IsDangerous = true, Name = "Direwolf", Size = IceAndFireModel.CreatureSize.Large, }; var kraken = new IceAndFireModel.Animal { IsCarnivore = true, IsDangerous = true, Name = "Kraken", Size = IceAndFireModel.CreatureSize.VeryLarge, }; var houseStark = new IceAndFireModel.House { Name = "Stark", Sigil = DbGeometry.FromText("POINT (1 1)", GeometrySrid), Words = "Winter is coming", ProminentMembers = new List <IceAndFireModel.Human> { aryaStark, sansaStark, branStark, ricksonStark }, }; var houseBaratheon = new IceAndFireModel.House { Name = "Baratheon", Sigil = DbGeometry.FromText("POINT (2 2)", GeometrySrid), Words = "Ours is the fury", ProminentMembers = new List <IceAndFireModel.Human> { stannisBaratheon, }, }; var houseLannister = new IceAndFireModel.House { Name = "Lannister", Sigil = DbGeometry.FromText("POINT (3 3)", GeometrySrid), Words = "Hear me roar!", ProminentMembers = new List <IceAndFireModel.Human> { tyrionLannister, jamieLannister, cerseiLannister, }, }; var houseTargaryen = new IceAndFireModel.House { Name = "Targaryen", Sigil = DbGeometry.FromText("POINT (4 4)", GeometrySrid), Words = "Fire and blood", ProminentMembers = new List <IceAndFireModel.Human> { jonSnow, daenerysTargaryen, aegonTargaryen, }, }; var north = new IceAndFireModel.Land { LocationOnMap = DbGeography.FromText("POINT (1 1)", GeographySrid), Name = "North", RulingHouse = houseStark, }; var stormlands = new IceAndFireModel.Land { LocationOnMap = DbGeography.FromText("POINT (2 2)", GeographySrid), Name = "Stormlands", RulingHouse = houseBaratheon, }; var westerlands = new IceAndFireModel.Land { LocationOnMap = DbGeography.FromText("POINT (3 3)", GeographySrid), Name = "Westerlands", RulingHouse = houseLannister, }; var dragonstone = new IceAndFireModel.Land { LocationOnMap = DbGeography.FromText("POINT (4 4)", GeographySrid), Name = "Dragonstone", RulingHouse = houseTargaryen, }; context.Lands.Add(north); context.Lands.Add(stormlands); context.Lands.Add(westerlands); context.Lands.Add(dragonstone); context.Creatures.Add(aurochs); context.Creatures.Add(direwolf); context.Creatures.Add(kraken); context.SaveChanges(); } }
public override double Distance(DbGeography geographyValue, DbGeography otherGeography) { throw new NotImplementedException(); }
public bool UpdateOfficerLocation(string officerCode, double lat, double lon) { var pointString = string.Format("POINT({0} {1})", lon.ToString(), lat.ToString()); DbGeography dbGeography = DbGeography.FromText(pointString); var officer = operationalDataContext.Patrols.Where(x => x.PatrolCode == officerCode).FirstOrDefault(); long maxIndex = 0; if (operationalDataContext.PatrolLastLocations != null) { maxIndex = operationalDataContext.PatrolLastLocations.Select(y => y.PatrolLatLocationId).Max(); } if (officer == null) { officer = new Patrol { PatrolCode = officerCode, PatrolPlateNo = "officer", DateCreated = DateTime.Now, PatrolOriginalId = Guid.NewGuid(), StatusId = 1, StatusName = "Available", IsDeleted = false, IsPatrol = false }; operationalDataContext.Patrols.Add(officer); if (!(operationalDataContext.SaveChanges() > 0)) { return(false); } } var officerLocation = operationalDataContext.PatrolLastLocations.Where(p => p.PatrolCode == officerCode).FirstOrDefault(); if (officerLocation == null) { officerLocation = new PatrolLastLocation { PatrolLatLocationId = ++maxIndex, PatrolId = officer.PatrolId, PatrolCode = officer.PatrolCode, Altitude = 1, Latitude = lat, Longitude = lon, IsNoticed = false, GeoLocation = dbGeography, LocationDate = DateTime.Now, Speed = 0, StatusId = 1, StatusName = "Available", IsPatrol = false }; operationalDataContext.PatrolLastLocations.Add(officerLocation); } else { officerLocation.Latitude = lat; officerLocation.Longitude = lon; officerLocation.GeoLocation = dbGeography; officerLocation.LocationDate = DateTime.Now; officerLocation.IsNoticed = false; } if (!(operationalDataContext.SaveChanges() > 0)) { return(false); } return(true); }
public override int GetDimension(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override bool SpatialEquals(DbGeography geographyValue, DbGeography otherGeography) { throw new NotImplementedException(); }
public override double? GetMeasure(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override bool Intersects(DbGeography geographyValue, DbGeography otherGeography) { throw new System.NotImplementedException(); }
public override DbGeographyWellKnownValue CreateWellKnownValue(DbGeography geographyValue) { throw new NotImplementedException(); }
public override DbGeography SymmetricDifference(DbGeography geographyValue, DbGeography otherGeography) { throw new System.NotImplementedException(); }
public override DbGeography Difference(DbGeography geographyValue, DbGeography otherGeography) { throw new System.NotImplementedException(); }
/// <summary> /// Sets the location's GeoPoint from a latitude and longitude. /// </summary> /// <param name="latitude">A <see cref="System.Double"/> representing the latitude for this location.</param> /// <param name="longitude">A <see cref="System.Double"/>representing the longitude for this location.</param> public void SetLocationPointFromLatLong(double latitude, double longitude) { this.GeoPoint = DbGeography.FromText(string.Format("POINT({0} {1})", longitude, latitude)); }
public override byte[] AsBinary(DbGeography geographyValue) { throw new NotImplementedException(); }
public static DbGeography CreatePoint(double latitude, double longitude, int srid = 4326) { return(DbGeography.PointFromText($"POINT({longitude} {latitude})", srid)); }
public override int GetCoordinateSystemId(DbGeography geographyValue) { throw new NotImplementedException(); }
public override double?GetLongitude(DbGeography geographyValue) { throw new NotImplementedException(); }
public override double? GetLongitude(DbGeography geographyValue) { throw new NotImplementedException(); }
public override double?GetMeasure(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override int? GetPointCount(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override int?GetPointCount(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override DbGeography GetStartPoint(DbGeography geographyValue) { throw new System.NotImplementedException(); }
public override string AsGml(DbGeography geographyValue) { throw new NotImplementedException(); }
public override string AsText(DbGeography geographyValue) { throw new NotImplementedException(); }
public override DbGeography Union(DbGeography geographyValue, DbGeography otherGeography) { throw new System.NotImplementedException(); }
public static string GetCaravanDirections(DbGeography current, DbGeography destination) { return(OrdersParser.ParseDirections(GetDirections(destination.Latitude.Value, destination.Longitude.Value, current.Latitude.Value, current.Longitude.Value).Result)); }