//Write vertex's absLoc like so: (lat; lon; floor)
 private String getCoordinatesTitle(Vertex v)
 {
     AbsoluteLocation absLoc = v.AbsoluteLocations[0];
     StringBuilder sb = new StringBuilder();
     sb.Append("(");
     sb.Append(Math.Round((double)absLoc.latitude, 5));
     sb.Append("; ");
     sb.Append(Math.Round((double)absLoc.longitude, 5));
     sb.Append("; ");
     sb.Append((int)(absLoc.altitude));
     sb.Append(")");
     return sb.ToString();
 }
 private bool isEndpoint(Vertex v)
 {
     foreach (Vertex cur in mEndPoints)
     {
         if (cur.ID == v.ID)
             return true;
     }
     return false;
 }
        private void removeEndpoint(Vertex v)
        {
            int removeIdx = -1;
            //find vertex
            for (int i = 0; i < mEndPoints.Count; i++)
            {
                if (v.ID == mEndPoints[i].ID)
                {
                    removeIdx = i;
                    break;
                }
            }
            //remove vertex
            if (removeIdx != -1)
            {
                mEndPoints.RemoveAt(removeIdx);

                //Revert to original bitmap image
                Image img = mPrevEndpointImages[removeIdx];
                img.Source = MarkerConfig.getCorrectMarker(v); //could also use CreateImage(v) but that creates a new image

                mPrevEndpointImages.RemoveAt(removeIdx);
            }
        }   
 private void Tapped_UpdatePins(Vertex v, Image img)
 {
     if (isEndpoint(v))
     {
         //removeEndpoint(poiIndex, v);
         removeEndpoint(v);
     }
     else
     {
         //A link has to be between two endpoints
         if (hasTwoEndpoints())
         {
             MessageBox.Show("Too many endpoints.\n Pleasure remove another endpoint first");
         }
         else
         {
             //addEndpoint(v, img);
             addEndpoint(v, img);
         }
     }
 }
 private void addEndpoint(Vertex v, Image img)
 {
     mEndPoints.Add(v);
     mPrevEndpointImages.Add(img); //Save ref to org image
     img.Source = MarkerConfig.getDestinationMarker();
 }
Пример #6
0
		private static String createFoliaJsonLocation(Vertex v)
		{
			if (v == null)
				return "null";

			AbsoluteLocation absLoc = v.AbsoluteLocations[0];
			SymbolicLocation symLoc = null; 
			foreach (SymbolicLocation s in v.SymbolicLocations)
			{
				symLoc = s;
				break;
			}
			
			//[
			// {id: , latitude: , longitude: , altitude: , title: , description: , url: , location_type: }
			// ]

			StringBuilder sb = new StringBuilder();
			sb.Append("{");
			sb.Append("id: ").Append(v.ID);
			sb.Append(", latitude: ").Append(absLoc.latitude);
			sb.Append(", longitude: ").Append(absLoc.longitude);
			sb.Append(", altitude: ").Append(absLoc.altitude);
			String title = symLoc != null ? symLoc.title : "null";
			sb.Append(", title: ").Append("'").Append(title).Append("'");
			String description = symLoc != null ? symLoc.description : "null";
			sb.Append(", description: ").Append("'").Append(description).Append("'");
			String url = symLoc != null ? symLoc.url : "null";
			sb.Append(", url: ").Append("'").Append(url).Append("'");
			sb.Append(", location_type: ").Append(symLoc != null ? symLoc.info_type : -1);
			//ToString capitalizes boolean, so necessary to call toLower
			string isStair = v.isStairEndpoint().ToString().ToLower();
			sb.Append(", isStairEndpoint: ").Append(isStair);
			string isElevator = v.isElevatorEndpoint().ToString().ToLower();
			sb.Append(", isElevatorEndpoint: ").Append(isElevator);
			string isEntrance = (symLoc != null && (symLoc.is_entrance ?? false)).ToString().ToLower();
			sb.Append(", isEntrance: ").Append(isEntrance);
			sb.Append("}");

			return sb.ToString();
		}
        private void AddVertexPin(Vertex v)
        {            
            Image img = MarkerConfig.CreateImage(v);
            img.Tap += (object sender, GestureEventArgs e) =>
            {
                e.Handled = true;
                
                Tapped_UpdatePins(v, img);      
                Tapped_UpdateMenu();
                Tapped_UpdateTitle();                
            };

            //pushpin.MouseLeftButtonUp += new MouseButtonEventHandler(pushpin_MouseLeftButtonUp);
            AbsoluteLocation pos = v.AbsoluteLocations.First();
            
            mapLayerVertices.AddChild(img, new GeoCoordinate((double)pos.latitude, (double)pos.longitude), PositionOrigin.BottomCenter);
        }
        private void AddVertexPin(Vertex v)
        {
            //Pushpin pushpin = new Pushpin();
            //pushpin.Style = (Style)(Application.Current.Resources["PushpinStyle"]);

            Image pushpin = MarkerConfig.CreateImage(v);
            pushpin.Tap +=
                (object sender, GestureEventArgs e) =>
                {
                    e.Handled = true;
                    
                    mWebMapCommon.onTap(v); //updates the title

                    //Navigates to the possibilities
                    StringBuilder sb = new StringBuilder();
                    sb.Append(Globals.XamlUri_OfflineOnTapAction);
                    sb.Append("?title=");
                    sb.Append(this.ApplicationTitle.Text);
                    this.NavigationService.Navigate(new Uri(sb.ToString(), UriKind.Relative));
                };
            //pushpin.MouseLeftButtonUp += new MouseButtonEventHandler(pushpin_MouseLeftButtonUp);
            AbsoluteLocation pos = v.AbsoluteLocations.First();
            mapLayerVertices.AddChild(pushpin, new GeoCoordinate((double)pos.latitude, (double)pos.longitude), PositionOrigin.BottomCenter);
        }
Пример #9
0
		private static String createFoliaJsonLocationJava(Vertex v)
		{
			if (v == null)
				return "null";

			AbsoluteLocation absLoc = v.AbsoluteLocations[0];
			SymbolicLocation symLoc = null;
			foreach (SymbolicLocation s in v.SymbolicLocations)
			{
				symLoc = s;
				break;
			}

			StringBuilder sb = new StringBuilder();
			sb.Append("{");
			sb.Append("id: ").Append(v.ID);
			sb.Append(", latitude: ").Append(absLoc.latitude);
			sb.Append(", longitude: ").Append(absLoc.longitude);
			sb.Append(", altitude: ").Append(absLoc.altitude);
			String title = symLoc != null ? symLoc.title : "null";
			sb.Append(", title: ").Append("\"").Append(title).Append("\"");
			String description = symLoc != null ? symLoc.description : "null";
			sb.Append(", description: ").Append("\"").Append(description).Append("\"");
			String url = symLoc != null ? symLoc.url : "null";
			sb.Append(", url: ").Append("\"").Append(url).Append("\"");
			//sb.append(", location_type: ").append(symLoc != null ? symLoc.getType().toString() : "N/A");
			sb.Append(", location_type: ").Append(symLoc != null ? symLoc.info_type ?? -1 : -1);
			string isStairEndpoint = v.isStairEndpoint().ToString().ToLower();
			sb.Append(", isStairEndpoint: ").Append(isStairEndpoint);
			string isElevatorEndpoint = v.isElevatorEndpoint().ToString().ToLower();
			sb.Append(", isElevatorEndpoint: ").Append(isElevatorEndpoint);
			string isEntrance = (symLoc != null ? symLoc.is_entrance : false).ToString().ToLower();
			sb.Append(", isEntrance: ").Append(isEntrance);
			sb.Append("}");

			return sb.ToString();
		}
Пример #10
0
        public static BitmapImage getCorrectMarker(Vertex vertex)
        {
            //First check for 'walking' properties
            if (vertex.isStairEndpoint())
                return getStaircaseMarker();
            if (vertex.isElevatorEndpoint())
                return getElevatorMarker();

            SymbolicLocation symLoc = vertex.SymbolicLocations.FirstOrDefault();
            if (symLoc == null)
                return getNoSymbolicLocationMarker();

            //v has a symbolic location. Now, check for special properties
            //SymbolicLocation symLoc = v.getLocation().getSymbolicLocation();
            if (symLoc.is_entrance.HasValue && symLoc.is_entrance.Value == true)
                return getEntranceMarker();

            //HACK: The enum is found in the 'wrong' class
            switch ((EditSymbolicLocation.InfoType)symLoc.info_type)
            {
                case EditSymbolicLocation.InfoType.NONE:
                    return getSymbolicLocationMarker();  //NONE
                case EditSymbolicLocation.InfoType.OFFICE:
                    return getOfficeMarker();              //OFFICE
                case EditSymbolicLocation.InfoType.DEFIBRELLATOR:
                    return getDefibrellatorMarker();      //DEFIBRELLATOR
                case EditSymbolicLocation.InfoType.FIRST_AID_KIT:
                    return getFirstAidMarker();            //FIRST_AID_KIT
                case EditSymbolicLocation.InfoType.FIRE_EXTINGUISHER:
                    return getFireExtinguisherMarker();    //FIRE_EXTINGUISHER
                case EditSymbolicLocation.InfoType.TOILET:
                    return getToiletMarker();              //TOILET
                case EditSymbolicLocation.InfoType.FOOD:
                    return getFoodMarker();		       //FOOD
                case EditSymbolicLocation.InfoType.LECTURE_ROOM:
                    return getLectureRoomMarker();	       //LECTURE_ROOM
                case EditSymbolicLocation.InfoType.STJERNE_DAG:
                    return getStarMarker();
                default:
                    return getSymbolicLocationMarker(); //NONE  
            }
        }
Пример #11
0
 public static Image CreateImage(Vertex v)
 {
     Image img = new Image();
     img.Source = MarkerConfig.getCorrectMarker(v);
     const int actualImgHeight = 37;
     const int actualImgWidth = 32;
     img.MinHeight = actualImgHeight;
     img.MaxHeight = actualImgHeight * 1.5;
     img.MinWidth = actualImgWidth;
     img.MaxWidth = actualImgWidth * 1.5;
     return img;
 }
Пример #12
0
		/// <summary>
		/// Updates the currently selected vertex
		/// If it is an unbound location, then the selected vertex will have ID = -1
		/// else the selected vertex corresponds to a chosen vertex in the graph
		/// Do null pass null. 
		/// <param name="selectedVertex"></param>
		/// <param name="title"></param>
		/// <param name="isBound"></param>
		public void updateSelectedVertex(Vertex selectedVertex, string title, bool isBound)
		{
			if (selectedVertex == null)
				throw new ArgumentException("Selected Vertex must not be null. ");

			Map2DOffline.SelectedOfflineVertex = selectedVertex;
			this.isBoundLocation = isBound;
            
            //Tell UI to update title
			OnTitleChanged(new TitleArgs(title));
		}
Пример #13
0
		/**
		 * This method is called (from javascript) whenever the user taps on the map - not a marker. 
		 * This captures the lat, lon coordinates of the selected location  
		 * This also means that an unbound location has been selected, i.curEdge., selectedVertex will have id = -1.
		 * @param isOnline Indicates whether we are in the online phase (false)
		 * @param floor the current floor
		 * @param lat the latitude of the tapped location
		 * @param lon the longitude of the tapped location
		 */
		public void setSelectedLocation(bool isOnline, int floor, double lat, double lon)
		{
			Vertex curVertex = new Vertex();
			curVertex.ID = -1;
            curVertex.Building_ID = LocationService.CurrentBuilding.ID;
			AbsoluteLocation absLoc = new AbsoluteLocation();
			absLoc.latitude = Convert.ToDecimal(lat);
			absLoc.longitude = Convert.ToDecimal(lon);
			absLoc.altitude = floor;
			curVertex.AbsoluteLocations.Add(absLoc);

			StringBuilder title = new StringBuilder();
			title.Append("Unbound: ").Append(floor).Append(";").Append(Math.Round(lat, 5)).Append("; ").Append(Math.Round(lon, 5)).Append("; floor ").Append(floor);

			updateSelectedVertex(curVertex, title.ToString(), false);
            UI_ShowSelectedLocation(lat, lon);
		}
Пример #14
0
        public void onTap(Vertex v)
        {
            if (v == null)
                return;

            //NOTE: ID and (lat, lon) is for debugging (tracking down faulty rounded coordinates
            AbsoluteLocation absLoc = v.AbsoluteLocations[0];
            StringBuilder sb = new StringBuilder();
            sb.Append("ID: ").Append(v.ID);
            sb.Append(" (").Append(Math.Round((double)absLoc.latitude, 5)).Append(", ");
            sb.Append(Math.Round((double)absLoc.longitude, 5)).Append(", ");
            sb.Append((int)absLoc.altitude).Append(")");
            String title = sb.ToString();

            this.updateSelectedVertex(v, title, true);

            //navigate
        }
 public PoiEventArgs(Vertex v)
 {
     this.SelectedPoi = v;
 }
        private void AddVertexPin(Vertex v)
        {
            //Pushpin pushpin = new Pushpin();
            //pushpin.Style = (Style)(Application.Current.Resources["PushpinStyle"]);
            Image pushpin = MarkerConfig.CreateImage(v);
            //pushpin.Tap += new EventHandler<GestureEventArgs>(pushpin_Tap);
            pushpin.Tap += (object sender, GestureEventArgs args) =>
                {
                    SymbolicLocation symLoc = v.SymbolicLocations.FirstOrDefault();
                    if (symLoc != null)
                    {
                        string title = symLoc.title ?? "";
                        string description = symLoc.description ?? "";
                        string url = symLoc.url ?? "";
                        MessageBox.Show(string.Format("{0}\n{1}\n{2}", title, description, url));
                    }
                };

            AbsoluteLocation pos = v.AbsoluteLocations.First();
            mapLayerVertices.AddChild(pushpin, new GeoCoordinate((double)pos.latitude, (double)pos.longitude), PositionOrigin.BottomCenter);
        }