public FieldMapAnnotation(Field field)
 {
     coordinate = new CLLocationCoordinate2D(GeoHelper.CalculateCenter(field.BoundingCoordinates).Latitude, GeoHelper.CalculateCenter(field.BoundingCoordinates).Longitude);
     Field = field;
     title = field.Name;
     subtitle = string.Format("Number of blocks: {0}", field.Blocks.Count);
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TreeWatch.MapViewModel"/> class.
        /// </summary>
        public MapViewModel()
        {
            this.fieldHelper = FieldHelper.Instance;
            this.fieldHelper.MapTapped += this.MapTapped;
            this.fieldHelper.FieldSelected += this.FieldSelected;
            this.fieldHelper.BlockSelected += this.BlockSelected;
            this.Fields = new ObservableCollection<Field>(new DBQuery<Field>(App.Database).GetAll());
            this.selectedField = new Field("Dummy", new List<Position>(), new List<Block>());

            foreach (Field f in this.Fields)
            {
                var whc = GeoHelper.CalculateBoundingBox(f.BoundingCoordinates);
                double rad = (whc.WidthInMeters > whc.HeightInMeters) ? whc.WidthInMeters : whc.HeightInMeters;
                rad *= 0.5;
                CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion(f.Name, whc.Center.Latitude, whc.Center.Longitude, rad)
                    {
                        NotifyOnStay = false,
                        StayedInThresholdDuration = TimeSpan.FromMinutes(10)
                    });
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Field selected event.
 /// </summary>
 /// <param name="field">Field that raises the selected event.</param>
 public void FieldSelectedEvent(Field field)
 {
     if (this.FieldSelected != null)
     {
         FieldHelper.SelectedField = field;
         this.FieldSelected(this, new FieldSelectedEventArgs(field));
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TreeWatch.FieldSelectedEventArgs"/> class.
 /// </summary>
 /// <param name="field">Field that through the event.</param>
 public FieldSelectedEventArgs(Field field)
 {
     this.Field = field;
 }
Esempio n. 5
0
        /// <summary>
        /// Navigates to field.
        /// </summary>
        /// <param name="field">The field which information should be shown.</param>
        public static void NavigateToField(Field field)
        {
            var navigationPage = (NavigationPage)Application.Current.MainPage;

            var informationViewModel = new InformationViewModel(field);
            navigationPage.PushAsync(new FieldInformationContentPage(informationViewModel));
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the field from a KML file.
        /// </summary>
        /// <returns>The field.</returns>
        /// <param name="kml">Kml file.</param>
        public static Field GetField(string kml)
        {
            var resultField = new Field();
            resultField.BoundingCoordinates = new List<Position>();
            var xml = XDocument.Parse(kml);

            var ns = xml.Root.Name.Namespace;

            var cords = xml.Descendants(ns + "coordinates");

            resultField.BoundingCoordinates = GetCoordinates(cords);

            return resultField;
        }