Search in sources :

Example 1 with DataCrossRoad

use of il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad in project BTW by TechnionYearlyProject.

the class TestGeoJasonToJavaParser method testCrossRoadsCorrect.

@Test
public void testCrossRoadsCorrect() {
    GeoJasonToJavaParser parser = new GeoJasonToJavaParser(mapName, geoJson);
    assertNotNull(parser.getTrafficLights());
    Iterator<Crossroad> crossRoadsIterator = parser.getCrossRoads().iterator();
    DataCrossRoad dataCrossroad = (DataCrossRoad) (crossRoadsIterator.next());
    assertNotNull(dataCrossroad);
    assertEquals(0.0014190683853251293, dataCrossroad.getCoordinateX(), 0.0000000000000000000001);
    assertEquals(0.014645366930914668, dataCrossroad.getCoordinateY(), 0.0000000000000000000001);
    assertEquals(1, parser.getCrossRoads().size());
}
Also used : Crossroad(il.ac.technion.cs.yp.btw.classes.Crossroad) DataCrossRoad(il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad) Test(org.junit.Test)

Example 2 with DataCrossRoad

use of il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad in project BTW by TechnionYearlyProject.

the class QueryCrossRoad method arrangeRecievedData.

/*
    * @author Sharon Hadar
    * @Date 21/01/2018
    * construct a cross road from the data base results
    * */
@Override
public Crossroad arrangeRecievedData(ResultSet resultSet) {
    Set<TrafficLight> 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);
            TrafficLight trafficLight = new DataTrafficLight(nameID, position, sourceRoadId, destinationRoadIf, overload, mapName);
            trafficLights.add(trafficLight);
        }
    } catch (SQLException e) {
        logger.error("queryCrossRoad has failed");
    }
    Crossroad crossRoad = new DataCrossRoad(this.position, trafficLights, mapName);
    return crossRoad;
}
Also used : DataTrafficLight(il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight) SQLException(java.sql.SQLException) DataTrafficLight(il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight) TrafficLight(il.ac.technion.cs.yp.btw.classes.TrafficLight) Crossroad(il.ac.technion.cs.yp.btw.classes.Crossroad) Point(il.ac.technion.cs.yp.btw.classes.Point) DataCrossRoad(il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad) PointImpl(il.ac.technion.cs.yp.btw.classes.PointImpl) HashSet(java.util.HashSet)

Aggregations

Crossroad (il.ac.technion.cs.yp.btw.classes.Crossroad)2 DataCrossRoad (il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad)2 Point (il.ac.technion.cs.yp.btw.classes.Point)1 PointImpl (il.ac.technion.cs.yp.btw.classes.PointImpl)1 TrafficLight (il.ac.technion.cs.yp.btw.classes.TrafficLight)1 DataTrafficLight (il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1