use of il.ac.technion.cs.yp.btw.classes.PointImpl in project BTW by TechnionYearlyProject.
the class QueryTrafficLightExample method arrangeRecievedData.
/*
* @author Sharon Hadar
* @Date 21/01/2018*/
@Override
public Set<TrafficLight> arrangeRecievedData(ResultSet resultSet) {
Set<TrafficLight> trafficLights = new HashSet();
try {
while (resultSet.next()) {
String nameID = resultSet.getString("nameID");
int cordx = resultSet.getInt("cordx");
int cordy = resultSet.getInt("cordy");
String sourceRoadId = nameID.split("-")[1];
// resultSet.getString("from");
String destinationRoadIf = nameID.split("-")[2];
// resultSet.getString("to");
long overload = resultSet.getLong("overload");
Point position = new PointImpl(cordx, cordy);
TrafficLight trafficLight = new DataTrafficLight(nameID, position, sourceRoadId, destinationRoadIf, overload, mapName);
System.out.println(trafficLight.toString());
trafficLights.add(trafficLight);
}
} catch (SQLException e) {
System.out.println("query has failed");
}
return trafficLights;
}
use of il.ac.technion.cs.yp.btw.classes.PointImpl in project BTW by TechnionYearlyProject.
the class QueryAllCentralLocations method arrangeRecievedData.
/*
* @author Sharon Hadar
* @Date 21/01/2018
* get the results fro the data base and construct the match centeral locations
* */
@Override
public Set<CentralLocation> arrangeRecievedData(ResultSet resultSet) {
Set<CentralLocation> centralLocations = new HashSet();
try {
while (resultSet.next()) {
String nameID = resultSet.getString("nameID");
String street = resultSet.getString("street");
int cord1x = resultSet.getInt("cord1x");
int cord2x = resultSet.getInt("cord2x");
int cord3x = resultSet.getInt("cord3x");
int cord4x = resultSet.getInt("cord4x");
int cord1y = resultSet.getInt("cord1y");
int cord2y = resultSet.getInt("cord2y");
int cord3y = resultSet.getInt("cord3y");
int cord4y = resultSet.getInt("cord4y");
Set<Point> points = new HashSet<Point>();
points.add(new PointImpl(cord1x, cord1y));
points.add(new PointImpl(cord2x, cord2y));
points.add(new PointImpl(cord3x, cord3y));
points.add(new PointImpl(cord4x, cord4y));
CentralLocation centralLocation = new DataCentralLocation(points, nameID, street, mapName);
centralLocations.add(centralLocation);
}
} catch (SQLException e) {
logger.error("query has failed");
}
return centralLocations;
}
use of il.ac.technion.cs.yp.btw.classes.PointImpl 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.PointImpl 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));
}
use of il.ac.technion.cs.yp.btw.classes.PointImpl in project BTW by TechnionYearlyProject.
the class TestDataRoad method testConstructing.
@Test
public void testConstructing() {
// first constructor
Road a = new DataRoad("Road6", 3, "STR1", new PointImpl(0, 0), new PointImpl(6.6, 6.6), "try");
// second constructor
Road b = new DataRoad("Road4", 43346, "STR2", new PointImpl(11.32, 77.234), new PointImpl(6.6, 6.6), 0, 342, 235, "try");
Assert.assertTrue(b.isStreetNumberInRange(100));
Assert.assertFalse(b.isStreetNumberInRange(1000));
Assert.assertTrue(a.getName().equals("Road6"));
Assert.assertTrue(b.getName().equals("Road4"));
Assert.assertTrue(a.getRoadLength() == 3);
String s = a.toString();
String s2 = b.toString();
Assert.assertTrue(s.contains("Road6"));
Assert.assertTrue(s2.contains("STR2"));
Assert.assertNull(((DataRoad) a).getWeights());
Assert.assertNotNull(((DataRoad) a).getDistances());
// Assert.assertTrue(a.getSpeed()>-1 && a.getSpeed() <1);
// Assert.assertTrue(a.getOverload()>-1 && a.getOverload() <1);
Assert.assertTrue(s2.contains("STR2"));
System.out.println(a.getWeightByTime(BTWTime.of(0)).seconds());
}
Aggregations