Esempio n. 1
0
		public void addPoly(EIMAPolygon mypoly){
			this._polygons.Add (mypoly);
		}
Esempio n. 2
0
		public async void proceduralPolygonCall(Position pos){
			TKCustomMapPin addedPin = new TKCustomMapPin ();
			addedPin.IsDraggable = false;
			addedPin.IsVisible = true;
			addedPin.Image = "dot.png";
			addedPin.Position = pos;
			addedPin.ShowCallout = false;

			_pins.Add (addedPin);
			customAreaPolyPins.Add (addedPin);
			customAreaPolyPoints.Add (pos);

			if (customAreaPolyPoints.Count < 3) {
				return;
			} else {
				var action = await Application.Current.MainPage.DisplayActionSheet(							
					"Point Added",
					null,
					null,
					"Create Custom Area",
					"Add Another Point",
					"Delete Area");
				if (action == "Create Custom Area") {
					EIMAPolygon result = new EIMAPolygon ();
					result.Color = CONSTANTS.colorOptions[Array.IndexOf(CONSTANTS.dzTypeOptions, polyType)];

					result.Coordinates = customAreaPolyPoints;
					result.uid = CONSTANTS.generateUID();

					result.type = polyType;
					result.note = polyNote;
					_polygons.Add (result);

					creatingPolygon = false;
					customAreaPolyPoints = null;
					foreach (TKCustomMapPin element in customAreaPolyPins) {
						_pins.Remove (element);
					}
					customAreaPolyPins = null;
					saveData ();

				} else if (action == "Add Another Point") {
					return;
				} else if (action == "Delete Area") {
					creatingPolygon = false;
					customAreaPolyPoints = null;
					foreach (TKCustomMapPin element in customAreaPolyPins) {
						_pins.Remove (element);
					}
					customAreaPolyPins = null;
				}
			}
		}
Esempio n. 3
0
		public AddEditEIMAPolygonPage (MapModel myModel, bool editMode, EIMAPolygon toEdit) 
		{
			var header = new Label
			{
				Text = "Specify DangerZone",
				FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
				FontAttributes = FontAttributes.Bold,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.Start
			};
			var info = new Entry { 
				Placeholder = "Info",
				VerticalOptions = LayoutOptions.Center
			};

			var typePicker = new Picker
			{
				Title = "Danger Zone Type",
				VerticalOptions = LayoutOptions.Center
			};


			foreach (string s in CONSTANTS.dzTypeOptions) {
				typePicker.Items.Add (s);
			}

			var EnterButton = new Button { 
				Text = "Enter",
				VerticalOptions = LayoutOptions.Center
			};

			var CancelButton = new Button { 
				Text = "Cancel",
				VerticalOptions = LayoutOptions.Center
			};
			var stackLayout = new StackLayout (){
				VerticalOptions = LayoutOptions.Center
			};

			if (editMode) {				
				header.Text = "Edit DangerZone";
				EnterButton.Text = "Confirm Edit";
				info.Text = toEdit.note;
				typePicker.SelectedIndex = Array.IndexOf (CONSTANTS.dzTypeOptions, toEdit.type);
			}


			stackLayout.Children.Add (header);
			stackLayout.Children.Add (typePicker);
			stackLayout.Children.Add (info);
			var stackLayout2 = new StackLayout ();
			stackLayout2.HorizontalOptions = LayoutOptions.Center;
			stackLayout2.Orientation = StackOrientation.Horizontal;
			stackLayout2.Children.Add (EnterButton);
			stackLayout2.Children.Add (CancelButton);
			stackLayout.Children.Add (stackLayout2);
			Content = stackLayout;

			EnterButton.Clicked += (sender, e) => {
				if(typePicker.SelectedIndex < 0){
					DisplayAlert("Must Select a Danger Zone Type","","Cancel");
					return;
				}
				if(!editMode){
					//start process of selecting points. would need to set vars
					myModel.creatingPolygon = true;
					myModel.polyNote = info.Text;
					myModel.polyType = CONSTANTS.dzTypeOptions[typePicker.SelectedIndex];
					myModel.startProcedural();
					goBack ();
				} else{
					toEdit.type = CONSTANTS.dzTypeOptions[typePicker.SelectedIndex];
					toEdit.note = info.Text;
					toEdit.Color = CONSTANTS.colorOptions[typePicker.SelectedIndex];
					myModel.saveData ();
					goBack ();
				}
			};

			CancelButton.Clicked += (sender, e) => goBack ();
		}
Esempio n. 4
0
		static void updateMapData (JObject mapData)
		{
			var data = DataManager.getInstance ();
			var assetJArr = (JArray)mapData ["mapAssets"];
			var circJArr = (JArray)mapData ["mapCircles"];
			var polyJArr = (JArray)mapData ["mapPolygons"];

			var polyList = new List<EIMAPolygon> ();
			var circleList = new List<EIMACircle> ();
			var assetList = new List<EIMAPin> ();


			foreach (JObject item in polyJArr.Children()) {
				var poly = new EIMAPolygon();
				poly.note = (string)item ["note"];
				poly.uid = (string)item ["uid"];
				poly.type = (string)item ["type"];

				var cordList = new List<Position> ();

				JArray coords = (JArray)item ["points"];
				foreach (JObject pos in coords.Children()) {
					cordList.Add(new Position((double)pos["Latitude"],(double)pos["Longitude"]));
				}
				List<Position> copied = new List<Position>(cordList);
				poly.Coordinates = copied;
				polyList.Add (poly);
			}

			foreach(JObject item in assetJArr.Children()){
				EIMAPin toAdd = new EIMAPin ();

				toAdd.name = (string)item["name"];
				toAdd.uid = (string)item["uid"];
				toAdd.status = (string)item["status"];
				toAdd.organization = (string)item["organization"];
				toAdd.unit = (string)item ["unit"];

				toAdd.Subtitle = "Status:" + toAdd.status;

				JObject pos = (JObject)item ["position"];
				toAdd.Position = new Position ((double)pos["latitude"],(double)pos["longitude"]);
				toAdd.unitType = (string)item ["type"];

				assetList.Add (toAdd);
			}

			foreach (JObject item in circJArr.Children()) {
				var circle = new EIMACircle();
				circle.note = (string)item ["note"];
				circle.uid = (string)item ["uid"];
				circle.Radius = (double)item ["radius"];
				circle.type = (string)item ["type"];
				circle.Center = new Position ((double)item["center"]["lat"],(double)item["center"]["long"]);

				circleList.Add (circle);
			}

			data.setDangerZoneCircle (circleList);
			data.setAssets (assetList);
			data.setDangerZonePoly (polyList);

		}
Esempio n. 5
0
		//Get polygons
		public List<EIMAPolygon> getPolyDangerZone(){
			var toRet = new List<EIMAPolygon> ();

			JArray assets = (JArray)dataStore ["incident"] ["mapPolygonDangerZones"];


			foreach (JObject item in assets.Children()) {
				var poly = new EIMAPolygon();
				poly.Color = CONSTANTS.colorOptions [Array.IndexOf (CONSTANTS.dzTypeOptions,(string) item ["type"])];
				poly.note = (string)item ["note"];
				poly.uid = (string)item ["uid"];
				poly.type = (string)item ["type"];

				var cordList = new List<Position> ();

				JArray coords = (JArray)item ["coords"];
				foreach (JObject pos in coords.Children()) {
					cordList.Add(new Position((double)pos["lat"],(double)pos["long"]));
				}
				List<Position> copied = new List<Position>(cordList);
				poly.Coordinates = copied;
				toRet.Add (poly);
			}

			return toRet;
		}