use of il.ac.technion.cs.yp.btw.classes.Point in project BTW by TechnionYearlyProject.
the class TestTrafficLightDataBase method testGetAllTrafficLightsInPosition.
/*
* @author Sharon Hadar
* @Date 21/01/2018*/
@Test
public void testGetAllTrafficLightsInPosition() {
MainDataBase.openConnection();
Point position = new PointImpl(1, 1);
Set<TrafficLight> allTrafficLights = TrafficLightsDataBase.getAllTrafficLights(position, "mapName");
Iterator<TrafficLight> iterator = allTrafficLights.iterator();
// System.out.println("\n\n\nthe result set is:");
while (iterator.hasNext()) {
assertNotNull(iterator.next());
// System.out.println(iterator.next().toString());
}
MainDataBase.closeConnection();
}
use of il.ac.technion.cs.yp.btw.classes.Point in project BTW by TechnionYearlyProject.
the class MapGraphics method createLines.
/**
* @author Shay and Anat and Adam Elgressy
* @Date 20-1-2018
* creating the array of lines to represent roads
* @param roads - roads in the map
*/
private void createLines(Set<CityRoad> roads) {
HashSet<CityRoad> l_roads = new HashSet<>();
for (CityRoad currRoad : roads) {
double deviationAngle = 0.0;
double deviationDistance = -0.00003;
Point newSource = getDeviationFromVectorEnd(currRoad.getDestinationCrossroad(), currRoad.getSourceCrossroad(), deviationAngle, deviationDistance);
Point newDestination = getDeviationFromVectorEnd(currRoad.getSourceCrossroad(), currRoad.getDestinationCrossroad(), deviationAngle, deviationDistance);
deviationAngle = 0.5;
deviationDistance = 0.000125;
newSource = getDeviationFromVectorEnd(newDestination, newSource, -deviationAngle, deviationDistance);
newDestination = getDeviationFromVectorEnd(newSource, newDestination, deviationAngle, deviationDistance);
double xroad1 = newSource.getCoordinateX();
double yroad1 = newSource.getCoordinateY();
double xroad2 = newDestination.getCoordinateX();
double yroad2 = newDestination.getCoordinateY();
Line roadLine = new Line(xroad1, yroad1, xroad2, yroad2);
// roadLine.setStroke(Color.BLACK);
double avgSpeed = currRoad.getStatisticalData().getAverageSpeed();
chooseRoadColor(roadLine, avgSpeed);
roadLine.setStrokeWidth(0.00025);
roadLine.toBack();
deviationAngle = 0.0;
deviationDistance = -0.0003;
newSource = getDeviationFromVectorEnd(currRoad.getDestinationCrossroad(), currRoad.getSourceCrossroad(), deviationAngle, deviationDistance);
newDestination = getDeviationFromVectorEnd(currRoad.getSourceCrossroad(), currRoad.getDestinationCrossroad(), deviationAngle, deviationDistance);
double xSeperateLine1 = newSource.getCoordinateX();
double ySeperateLine1 = newSource.getCoordinateY();
double xSeperateLine2 = newDestination.getCoordinateX();
double ySeperateLine2 = newDestination.getCoordinateY();
Line separateline = new Line(xSeperateLine1, ySeperateLine1, xSeperateLine2, ySeperateLine2);
separateline.setStroke(Color.WHITE);
separateline.setStrokeWidth(0.00005);
lines.add(new Pair(roadLine, currRoad.getName()));
lines.add(new Pair(separateline, currRoad.getName()));
roadLine.setOnMouseClicked(event -> {
RoadData roadData = currRoad.getStatisticalData();
int length = roadData.getRoadLength();
double averageSpeed = roadData.getAverageSpeed();
int numOfVehicles = roadData.getNumOfVehicles();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/road_real_time_statistics.fxml"));
try {
Parent root = fxmlLoader.load();
RoadRealTimeStatisticsController roadRealTimeStatisticsController = fxmlLoader.getController();
roadRealTimeStatisticsController.generateView(length, averageSpeed, numOfVehicles, root);
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
use of il.ac.technion.cs.yp.btw.classes.Point in project BTW by TechnionYearlyProject.
the class GeoJasonToJavaParser method parseRoad.
/*@Author: Sharon Hadar
*@Date: 30/3/2018
*get the geometry of feature from type LineString, and parse it to java class Road
* the geometry's pattern is: {"type":"LineString","coordinates":[[0.01635651734518988,0.008806996592190556],[0.014402113034462271,0.006739623239087599]]}
* the properties pattern is: {"name":"31 StreetR","length":"316","overload":0}}]}
* */
private Road parseRoad(JsonObject geometry, JsonObject properties) {
String name = properties.get("name").getAsString();
int roadLength = properties.get("length").getAsInt();
String myStreet = name.split(" Street| StreetR")[0];
Point[] points = parsePointFromLineStringGeometry(geometry);
Point sourceCrossroadId = points[sourceCoordIndex];
Point destinationCrossroadId = points[destinationCoordIndex];
int secStart = 0;
if (name.contains("section")) {
secStart = Integer.parseInt(name.split("section ")[1].split("R")[0]);
}
int secEnd = secStart;
long overload = properties.get("overload").getAsLong();
return new DataRoad(name, roadLength, myStreet, sourceCrossroadId, destinationCrossroadId, secStart, secEnd, overload, mapName);
}
use of il.ac.technion.cs.yp.btw.classes.Point in project BTW by TechnionYearlyProject.
the class QueryTrafficLight method arrangeRecievedData.
/*
* @author Sharon Hadar
* @Date 21/01/2018
* construct a traffic light by the result of the data base*/
@Override
public TrafficLight arrangeRecievedData(ResultSet resultSet) {
TrafficLight trafficLight = null;
try {
resultSet.next();
String nameID = resultSet.getString("nameID");
double cordx = resultSet.getDouble("cordx");
double cordy = resultSet.getDouble("cordy");
String sourceRoadId = nameID.split("from:|to:")[1];
String destinationRoadIf = nameID.split("to:")[1];
long overload = resultSet.getLong("overload");
Point position = new PointImpl(cordx, cordy);
trafficLight = new DataTrafficLight(nameID, position, sourceRoadId, destinationRoadIf, overload, mapName);
} catch (SQLException e) {
logger.error("query trafficlight has failed");
}
return trafficLight;
}
use of il.ac.technion.cs.yp.btw.classes.Point in project BTW by TechnionYearlyProject.
the class TestDataCentralLocation method testCentralLocation.
/*
* @author Sharon Hadar
* @Date 21/01/2018*/
@Test
public void testCentralLocation() {
Point a = new PointImpl(3, 4);
Point b = new PointImpl(1, 2);
Set<Point> points = new HashSet<Point>();
points.add(a);
points.add(b);
CentralLocation cl = new DataCentralLocation(points, "Bank", "Namir", "try");
String s = cl.toString();
String sn = cl.getName();
Assert.assertTrue(s.contains(sn));
}
Aggregations