/// <summary> /// Gets the color of the tree type. /// </summary> /// <returns>The tree type color.</returns> /// <param name="id">TreeType ID</param> public static Color GetTreeTypeColor(int id) { var connection = new TreeWatchDatabase(); TreeType type = new DBQuery <TreeType>(connection).GetByID(id); return(type.ColorProp); }
/// <summary> /// Gets the color of the tree type. /// </summary> /// <returns>The tree type color.</returns> /// <param name="id">TreeType ID</param> public static Color GetTreeTypeColor(int id) { var connection = new TreeWatchDatabase(); TreeType type = new DBQuery<TreeType>(connection).GetByID(id); return type.ColorProp; }
/// <summary> /// Sets up mock data. /// </summary> public static void SetUpMockData() { var connection = new TreeWatchDatabase(); connection.ClearDataBase(); var fieldQuery = new DBQuery <Field>(connection); var treetypeQuery = new DBQuery <TreeType>(connection); var blockQuery = new DBQuery <Block>(connection); var heatmapQuery = new DBQuery <HeatMap>(connection); var treetypes = treetypeQuery.GetAllWithChildren(); var field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanKarwei.kml")); field.Name = "Karwei"; fieldQuery.InsertWithChildren(field); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanPraxis.kml")); field.Name = "Praxis"; fieldQuery.InsertWithChildren(field); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanSligro.kml")); field.Name = "Sligro"; fieldQuery.InsertWithChildren(field); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanGrutto.kml")); field.Name = "Grutto"; field.Blocks = KMLParser.GetBlocks(KMLParser.LoadFile("KML.Blocks.rassenmapGrutto.kml"), treetypes); blockQuery.InsertAllWithChildren(field.Blocks); fieldQuery.InsertWithChildren(field, false); treetypes = treetypeQuery.GetAllWithChildren(); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanHema.kml")); field.Name = "Hema"; field.Blocks = KMLParser.GetBlocks(KMLParser.LoadFile("KML.Blocks.rassenmapHema.kml"), treetypes); blockQuery.InsertAllWithChildren(field.Blocks); fieldQuery.InsertWithChildren(field, false); /* SQLite on android can not handle this many entitys at once. * Therefore we can not add this field, also heatmaps dont work at all in android. */ if (TargetPlatform.iOS == Device.OS) { var heatmap = KMLParser.GetHeatmap(KMLParser.LoadFile("KML.Heatmaps.Biomassa.kml")); heatmap.Name = "Biomassa"; heatmapQuery.InsertWithChildren(heatmap); treetypes = treetypeQuery.GetAllWithChildren(); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanIkea.kml")); field.Name = "Ikea"; field.Blocks = KMLParser.GetBlocks(KMLParser.LoadFile("KML.Blocks.rassenmapIkea.kml"), treetypes); blockQuery.InsertAllWithChildren(field.Blocks); fieldQuery.InsertWithChildren(field, false); } }
/// <summary> /// Sets up mock data. /// </summary> public static void SetUpMockData() { var connection = new TreeWatchDatabase(); connection.ClearDataBase(); var fieldQuery = new DBQuery<Field>(connection); var treetypeQuery = new DBQuery<TreeType>(connection); var blockQuery = new DBQuery<Block>(connection); var heatmapQuery = new DBQuery<HeatMap>(connection); var treetypes = treetypeQuery.GetAllWithChildren(); var field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanKarwei.kml")); field.Name = "Karwei"; fieldQuery.InsertWithChildren(field); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanPraxis.kml")); field.Name = "Praxis"; fieldQuery.InsertWithChildren(field); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanSligro.kml")); field.Name = "Sligro"; fieldQuery.InsertWithChildren(field); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanGrutto.kml")); field.Name = "Grutto"; field.Blocks = KMLParser.GetBlocks(KMLParser.LoadFile("KML.Blocks.rassenmapGrutto.kml"), treetypes); blockQuery.InsertAllWithChildren(field.Blocks); fieldQuery.InsertWithChildren(field, false); treetypes = treetypeQuery.GetAllWithChildren(); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanHema.kml")); field.Name = "Hema"; field.Blocks = KMLParser.GetBlocks(KMLParser.LoadFile("KML.Blocks.rassenmapHema.kml"), treetypes); blockQuery.InsertAllWithChildren(field.Blocks); fieldQuery.InsertWithChildren(field, false); /* SQLite on android can not handle this many entitys at once. * Therefore we can not add this field, also heatmaps dont work at all in android. */ if (TargetPlatform.iOS == Device.OS) { var heatmap = KMLParser.GetHeatmap(KMLParser.LoadFile("KML.Heatmaps.Biomassa.kml")); heatmap.Name = "Biomassa"; heatmapQuery.InsertWithChildren(heatmap); treetypes = treetypeQuery.GetAllWithChildren(); field = KMLParser.GetField(KMLParser.LoadFile("KML.Fields.perceelscanIkea.kml")); field.Name = "Ikea"; field.Blocks = KMLParser.GetBlocks(KMLParser.LoadFile("KML.Blocks.rassenmapIkea.kml"), treetypes); blockQuery.InsertAllWithChildren(field.Blocks); fieldQuery.InsertWithChildren(field, false); } }
/// <summary> /// Initializes a new instance of the <see cref="TreeWatch.DBQuery{T}"/> class. /// </summary> /// <param name="db">Database connection.</param> public DBQuery(TreeWatchDatabase db) { this.connection = db.Connection; }
/// <summary> /// Adds the fields. /// </summary> private void AddFields() { foreach (var field in this.myMap.Fields) { var connection = new TreeWatchDatabase(); var query = new DBQuery<Field>(connection); query.GetChildren(field); if (field.Blocks.Count != 0) { foreach (var block in field.Blocks) { if (block.BoundingCoordinates.Count != 0 && block.BoundingCoordinates.Count >= 3) { this.Map.AddPolygon(GetPolygon( FieldMapRenderer.ConvertCoordinates(block.BoundingCoordinates), block.TreeType.ColorProp.ToAndroid())); } } } if (field.BoundingCoordinates.Count != 0 && field.BoundingCoordinates.Count >= 3) { this.Map.AddPolygon(GetPolygon( FieldMapRenderer.ConvertCoordinates(field.BoundingCoordinates), this.myMap.OverLayColor.ToAndroid(), this.myMap.BoundaryColor.ToAndroid())); } } }
/// <summary> /// Adds the fields to the map. /// </summary> private void AddFields() { var connection = new TreeWatchDatabase(); foreach (var field in this.myMap.Fields) { var query = new DBQuery<Field>(connection); var blockPolygons = new List<ColorPolygon>(); query.GetChildren(field); if (field.Blocks.Count != 0) { foreach (var block in field.Blocks) { if (block.BoundingCoordinates.Count != 0 && block.BoundingCoordinates.Count >= 3) { var blockPoints = ConvertCoordinates(block.BoundingCoordinates); var blockPolygon = (ColorPolygon)MKPolygon.FromCoordinates(blockPoints); blockPolygon.FillColor = block.TreeType.ColorProp.ToCGColor(); blockPolygons.Add(blockPolygon); } } var blockMultiPolygon = new MultiPolygon(blockPolygons); this.mapView.AddOverlay(blockMultiPolygon); } if (field.BoundingCoordinates.Count != 0 && field.BoundingCoordinates.Count >= 3) { var points = ConvertCoordinates(field.BoundingCoordinates); var polygon = MKPolygon.FromCoordinates(points); polygon.Title = "Field"; this.mapView.AddOverlay(polygon); } } var query2 = new DBQuery<HeatMap>(connection); var heatmaps = query2.GetAllWithChildren(); var heatmap = heatmaps[0]; this.AddHeatMap(heatmap.Points); }