use of il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight in project BTW by TechnionYearlyProject.
the class BTWDataBaseImpl method insertRoadsToTrafficLights.
/**
* @author Sharon Hadar
* @Date 21/01/2018
*/
private void insertRoadsToTrafficLights() {
Map<String, Road> roadsLightsOfName = new HashMap<>();
this.roads.forEach(road -> roadsLightsOfName.put(road.getName(), road));
for (TrafficLight trafficLight : this.trafficLights) {
String sourceRoadName = ((DataTrafficLight) trafficLight).getSourceRoadName();
((DataTrafficLight) trafficLight).setSourceRoad(roadsLightsOfName.get(sourceRoadName));
String destinationRoadName = ((DataTrafficLight) trafficLight).getDestinationRoadName();
((DataTrafficLight) trafficLight).setDestinationRoad(roadsLightsOfName.get(destinationRoadName));
}
}
use of il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight in project BTW by TechnionYearlyProject.
the class QueryAllTrafficLights method arrangeRecievedData.
/*
* @author Sharon Hadar
* @Date 21/01/2018
* build the recieved data from the data base results
* */
@Override
public Set<DataTrafficLight> arrangeRecievedData(ResultSet resultSet) {
Set<DataTrafficLight> trafficLights = new HashSet();
try {
while (resultSet.next()) {
String nameID = resultSet.getString("nameID");
double cordx = resultSet.getDouble("cordx");
double cordy = resultSet.getDouble("cordy");
String sourceRoadId = nameID.split("from:| to:")[1];
// resultSet.getString("from");
String destinationRoadIf = nameID.split(" to:")[1];
// resultSet.getString("to");
long overload = resultSet.getLong("overload");
Point position = new PointImpl(cordx, cordy);
DataTrafficLight trafficLight = new DataTrafficLight(nameID, position, sourceRoadId, destinationRoadIf, overload, mapName);
trafficLights.add(trafficLight);
}
} catch (SQLException e) {
logger.error("query all trafficlights failed");
}
return trafficLights;
}
use of il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight in project BTW by TechnionYearlyProject.
the class TestGeoJasonToJavaParser method testTrafficLightsCorrect.
@Test
public void testTrafficLightsCorrect() {
GeoJasonToJavaParser parser = new GeoJasonToJavaParser(mapName, geoJson);
assertNotNull(parser.getTrafficLights());
Iterator<TrafficLight> trafficLightsIterator = parser.getTrafficLights().iterator();
DataTrafficLight dataTrafficLight = (DataTrafficLight) (trafficLightsIterator.next());
assertNotNull(dataTrafficLight);
assertEquals("from:3 StreetR to:3 Street", dataTrafficLight.getName());
assertEquals("3 StreetR", dataTrafficLight.getSourceRoadName());
assertEquals("3 Street", dataTrafficLight.getDestinationRoadName());
assertEquals(0.0014190683853251293, dataTrafficLight.getCoordinateX(), 0.0000000000000000000001);
assertEquals(0.014645366930914668, dataTrafficLight.getCoordinateY(), 0.0000000000000000000001);
assertEquals(1, parser.getTrafficLights().size());
}
Aggregations