public Edge(Vertex origin, Vertex destination) : this(origin, destination, (int)com.smartcampus.baselogic.DistanceMeasurements.CalculateMoveddistanceInMeters( origin.getLocation().getAbsoluteLocation().getLatitude(), origin.getLocation().getAbsoluteLocation().getLongitude(), destination.getLocation().getAbsoluteLocation().getLatitude(), destination.getLocation().getAbsoluteLocation().getLongitude())) { }
// Copy constructor public Vertex(Vertex aVertex) { double latitude = aVertex.getLocation().getAbsoluteLocation().getLatitude(); double longitude = aVertex.getLocation().getAbsoluteLocation().getLongitude(); double altitude = aVertex.getLocation().getAbsoluteLocation().getAltitude(); AggregateLocation aggLoc = new AggregateLocation(new AbsoluteLocation(latitude, longitude, altitude)); this.location = aggLoc; this.inEdges = aVertex.getInEdges(); this.outEdges = aVertex.getOutEdges(); this.id = aVertex.getId(); this.fingerprints = aVertex.getFingerPrints(); this.radiusVertices = aVertex.getRadiusVertices(); }
public bool addVertex(Vertex v) { if (vertices.ContainsKey(v.getId())) { return(false); } //Add vertex to <vertexId, vertex> structure vertices.Add(v.getId(), v); //Add vertex to <floorNum, List<Vertex> structure if (v.getLocation() != null && v.getLocation().getAbsoluteLocation() != null) { int floor = (int)v.getLocation().getAbsoluteLocation().getAltitude(); if (!verticesByFloor.ContainsKey(floor)) { verticesByFloor.Add(floor, new List <Vertex>()); } verticesByFloor[floor].Add(v); } return(true); }
public bool removeVertex(Vertex v) { foreach (Edge e in v.incidentEdges()) { edges.Remove(e); } //remove from <vertexId, vertex> structure vertices.Remove(v.getId()); //remove from <floorNum, List<Vertex> structure bool hasLocation = v.getLocation() != null && v.getLocation().getAbsoluteLocation() != null; if (hasLocation) { int floor = (int)v.getLocation().getAbsoluteLocation().getAltitude(); if (verticesByFloor.ContainsKey(floor)) { verticesByFloor[floor].Remove(v); } } return(true); }
// Methods dealing with directed edges // //Methods dealing with positioning //We don't bother to create a subclass for this behavior as our graph is only used for one purpose in this application public void InsertRadiusVertices(Vertex v, int radius) { AbsoluteLocation sourceLocation = v.getLocation().getAbsoluteLocation(); AbsoluteLocation targetLocation; double dist; foreach (Vertex w in vertices.Values) { if (v.Equals(w)) { continue; } targetLocation = w.getLocation().getAbsoluteLocation(); dist = com.smartcampus.baselogic.DistanceMeasurements.CalculateMoveddistanceInMeters( sourceLocation.getLatitude(), sourceLocation.getLongitude(), targetLocation.getLatitude(), targetLocation.getLongitude()); if (dist <= radius) { v.addRadiusVertex((Vertex)w); } } }
public bool removeVertex(Vertex v) { foreach (Edge e in v.incidentEdges()) edges.Remove(e); //remove from <vertexId, vertex> structure vertices.Remove(v.getId()); //remove from <floorNum, List<Vertex> structure bool hasLocation = v.getLocation() != null && v.getLocation().getAbsoluteLocation() != null; if (hasLocation) { int floor = (int)v.getLocation().getAbsoluteLocation().getAltitude(); if (verticesByFloor.ContainsKey(floor)) { verticesByFloor[floor].Remove(v); } } return true; }
// Methods dealing with directed edges // //Methods dealing with positioning //We don't bother to create a subclass for this behavior as our graph is only used for one purpose in this application public void InsertRadiusVertices(Vertex v, int radius) { AbsoluteLocation sourceLocation = v.getLocation().getAbsoluteLocation(); AbsoluteLocation targetLocation; double dist; foreach (Vertex w in vertices.Values) { if (v.Equals(w)) continue; targetLocation = w.getLocation().getAbsoluteLocation(); dist = com.smartcampus.baselogic.DistanceMeasurements.CalculateMoveddistanceInMeters( sourceLocation.getLatitude(), sourceLocation.getLongitude(), targetLocation.getLatitude(), targetLocation.getLongitude()); if (dist <= radius) v.addRadiusVertex((Vertex)w); } }
public bool addVertex(Vertex v) { if (vertices.ContainsKey(v.getId())) return false; //Add vertex to <vertexId, vertex> structure vertices.Add(v.getId(), v); //Add vertex to <floorNum, List<Vertex> structure if (v.getLocation() != null && v.getLocation().getAbsoluteLocation() != null) { int floor = (int)v.getLocation().getAbsoluteLocation().getAltitude(); if (!verticesByFloor.ContainsKey(floor)) { verticesByFloor.Add(floor, new List<Vertex>()); } verticesByFloor[floor].Add(v); } return true; }