use of il.ac.technion.cs.yp.btw.classes.Road in project BTW by TechnionYearlyProject.
the class TestRoadsDataBase method testGetRoad.
/*
* @author Sharon Hadar
* @Date 21/01/2018*/
@Test
public void testGetRoad() {
String mapName = "first";
MainDataBase.openConnection();
Road ayalonn = RoadsDataBase.getRoad("Ayalonn", mapName);
assertNotNull(ayalonn);
// System.out.println(ayalonn.toString());
Road road1 = RoadsDataBase.getRoad("Road1", mapName);
assertNotNull(road1);
// System.out.println(road1.toString());
Road road4 = RoadsDataBase.getRoad("Road4", mapName);
assertNotNull(road4);
// System.out.println(road4.toString());
Road road6 = RoadsDataBase.getRoad("Road6", mapName);
assertNotNull(road6);
// System.out.println(road6.toString());
MainDataBase.closeConnection();
}
use of il.ac.technion.cs.yp.btw.classes.Road in project BTW by TechnionYearlyProject.
the class QueryTrafficLightExample method arrangeRecievedData.
/*
* @author Sharon Hadar
* @Date 21/01/2018*/
@Override
public Set<Road> arrangeRecievedData(ResultSet resultSet) {
Set<Road> roads = new HashSet();
try {
while (resultSet.next()) {
String nameID = resultSet.getString("nameID");
int cord1x = resultSet.getInt("cord1x");
int cord2x = resultSet.getInt("cord2x");
int cord1y = resultSet.getInt("cord1y");
int cord2y = resultSet.getInt("cord2y");
int length = resultSet.getInt("length");
int secStart = resultSet.getInt("secStart");
int secEnd = resultSet.getInt("secEnd");
String overload = resultSet.getString("overload");
System.out.println("nameID = " + nameID + " cord1x = " + cord1x + " cord2x = " + cord2x + " cord1y = " + cord1y + " cord2y = " + cord2y + " length = " + length + " secStart = " + secStart + " secEnd = " + secEnd + " overload = " + overload);
String myStreet = nameID.split("st")[0];
Point sourceCrossroadId = new PointImpl(cord1x, cord1y);
Point destinationCrossroadId = new PointImpl(cord2x, cord2y);
Road road = new DataRoad(nameID, length, myStreet, sourceCrossroadId, destinationCrossroadId, mapName);
System.out.println(road.toString());
roads.add(road);
}
} catch (SQLException e) {
System.out.println("query has failed");
}
return roads;
}
use of il.ac.technion.cs.yp.btw.classes.Road in project BTW by TechnionYearlyProject.
the class NaiveNavigationManager method staticAStar.
private List<Road> staticAStar(Road src, Road dst, double sourceRoadRatio) throws PathNotFoundException {
PriorityQueue<RoadWrapper> open = new PriorityQueue<>();
PriorityQueue<RoadWrapper> closed = new PriorityQueue<>();
open.add(RoadWrapper.buildSourceRoad(src, dst, sourceRoadRatio));
while (!open.isEmpty()) {
RoadWrapper next = open.poll();
closed.add(next);
if (next.getRoad().equals(dst)) {
LinkedList<RoadWrapper> path = new LinkedList<>();
RoadWrapper currWrapper = next;
while (currWrapper != null) {
path.addFirst(currWrapper);
currWrapper = currWrapper.getParent();
}
return path.stream().map(RoadWrapper::getRoad).collect(Collectors.toList());
}
for (Road r : next.getNeighbors()) {
double dist = next.dist + next.getDistFromNeighbor(r);
RoadWrapper newWrapper = RoadWrapper.buildRouteRoad(r, dst, dist, next);
if (open.contains(newWrapper)) {
RoadWrapper oldWrapper = null;
for (RoadWrapper w : open) {
if (w.equals(newWrapper)) {
oldWrapper = w;
break;
}
}
if (oldWrapper.dist > newWrapper.dist) {
open.remove(oldWrapper);
open.add(newWrapper);
}
} else if (closed.contains(newWrapper)) {
RoadWrapper oldWrapper = null;
for (RoadWrapper w : closed) {
if (w.equals(newWrapper)) {
oldWrapper = w;
break;
}
}
if (oldWrapper.dist > newWrapper.dist) {
closed.remove(oldWrapper);
open.add(newWrapper);
}
} else {
open.add(newWrapper);
}
}
}
throw new PathNotFoundException("No path from " + src.getRoadName() + " to " + dst.getRoadName());
}
use of il.ac.technion.cs.yp.btw.classes.Road in project BTW by TechnionYearlyProject.
the class DataStreet method toString.
/*
* @author Sharon Hadar
* @Date 21/01/2018
* get a string represents the street*/
@Override
public String toString() {
String street = "";
street += "street: ";
street += "name = " + name;
street += "\nthe roads are:\n";
for (Road road : roads) {
street += "\t" + road.toString() + "\n";
}
return street;
}
use of il.ac.technion.cs.yp.btw.classes.Road in project BTW by TechnionYearlyProject.
the class MapGraphics method calculateTrafficLightLocation.
/**
*@author: Anat & Sharon
* @date: 20/1/18
* returns the degree value in radians
* of the given line on, from the x-axis
* @param trafficLight - the line we check is its source road
* @return the degree value in radians
* of the given line on, from the x-axis
* The functions:
* y1 = ax+b1
* y2 = -(1/a)*x+b2
*/
private Point calculateTrafficLightLocation(TrafficLight trafficLight) {
Road sourceRoad = trafficLight.getSourceRoad();
double deviationAngle = 0.85;
double deviationDistance = 0.0003;
return getDeviationFromVectorEnd(sourceRoad.getSourceCrossroad(), sourceRoad.getDestinationCrossroad(), deviationAngle, deviationDistance);
}
Aggregations