internal static IEnumerable<BirdGroupFeature> AllWithObservation(Observation observation) { var results = new List<BirdGroupFeature>(); //First get all the matching bird groups that have already been loaded results.AddRange(BirdGroups.Values.Where(bird => bird.Observation == observation)); //Next search the database for matching birdgroups, but only load/add them if they are not already loaded. #if BROKEN_WHERE_GUID int columnIndex = FeatureSource.Columns.IndexOf("ObservationID"); var rows = MobileUtilities.GetFeatureRows(FeatureSource, observation.Guid, columnIndex); #else string whereClause = string.Format("ObservationID = '{{{0}}}'", observation.Guid); var rows = MobileUtilities.GetFeatureRows(FeatureSource, whereClause); #endif results.AddRange(from birdFeature in rows where !BirdGroups.ContainsKey(new Guid(birdFeature.GlobalId.ToByteArray())) select FromFeature(new Feature(birdFeature))); return results; }
public bool Save(Observation observation) { if (BirdGroupFeature == null) BirdGroupFeature = BirdGroupFeature.FromObservation(observation); BirdGroupFeature.Size = GroupSize; BirdGroupFeature.Behavior = Behavior.ToString()[0]; BirdGroupFeature.Species = Species.ToString()[0]; BirdGroupFeature.Comments = Comment; return BirdGroupFeature.Save(); }
internal static BirdGroupFeature FromObservation(Observation observation) { if (observation == null) throw new ArgumentNullException("observation"); var birdGroup = FromFeature(MobileUtilities.CreateNewFeature(FeatureSource)); if (birdGroup == null) throw new ApplicationException("Database returned null when asked to create a new feature"); birdGroup.Observation = observation; return birdGroup; }
public SelectionDialog(Observation observation) { Observation = observation; InitializeComponent(); }
public void RemoveObservation(Observation observation) { OpenObservations.Remove(observation); //If we are deleting the active record, make the first record active //If observation == ActiveObservation, then XAML bindings will set ActiveObservation to null if (ActiveObservation == null || observation == ActiveObservation) ActiveObservation = (OpenObservations.Count == 0) ? null : OpenObservations[0]; }
public void AddObservationAsActive(Observation observation) { OpenObservations.Add(observation); ActiveObservation = observation; }
private static bool IsWithin(Observation obs, Envelope extents) { if (obs.Feature == null) { Trace.TraceError("Observation:{1} has no Feature", obs); return false; } if (obs.Feature.FeatureDataRow == null) { Trace.TraceError("Observation:{1} has no FeatureDataRow", obs); return false; } if (obs.Feature.FeatureDataRow.Geometry == null) { Trace.TraceError("Observation:{1} has no Geometry", obs); return false; } return obs.Feature.FeatureDataRow.Geometry.Within(extents); }
private static Observation FromFeature(Feature feature) { if (feature == null) return null; if (!feature.IsEditing) feature.StartEditing(); var observation = new Observation { Feature = feature }; bool existing = observation.LoadAttributes(); Observations[observation.Guid] = observation; //load birdgroups. must becalled after updating Observations[], to avoid an infinite loop: obs->bird->obs->bird->... if (existing) observation.LoadBirdGroups(); return observation; }