/// <summary> /// Initializes the grid by loading or creating cardinal direction points. /// </summary> private void Init() { var directionPoints = new Dictionary <DirectionEnum, IGeoLocation>(); // load existing cardinal direction points from DB foreach (var directionPoint in Home.CardinalDirectionPoints.Where(x => x.UnitDistance == unitDistance)) { directionPoints[directionPoint.Direction] = directionPoint; } // add any missing direction points foreach (DirectionEnum direction in Enum.GetValues(typeof(DirectionEnum))) { if (directionPoints.ContainsKey(direction)) { continue; } directionPoints[direction] = ComputeOffset(direction); var newPoint = new CardinalDirectionPoint() { OriginId = Home.Id, UnitDistance = unitDistance, Direction = direction, Latitude = directionPoints[direction].Latitude, Longitude = directionPoints[direction].Longitude }; dbContext.CardinalDirectionPoints.InsertOnSubmit(newPoint); } // save any possible new points dbContext.SubmitChanges(); // set deltas deltaLat = (directionPoints[DirectionEnum.North].Latitude - directionPoints[DirectionEnum.South].Latitude) / 2.0; deltaLon = (directionPoints[DirectionEnum.East].Longitude - directionPoints[DirectionEnum.West].Longitude) / 2.0; }
private void detach_CardinalDirectionPoints(CardinalDirectionPoint entity) { this.SendPropertyChanging(); entity.Origin = null; }
partial void UpdateCardinalDirectionPoint(CardinalDirectionPoint instance);
partial void DeleteCardinalDirectionPoint(CardinalDirectionPoint instance);
partial void InsertCardinalDirectionPoint(CardinalDirectionPoint instance);