Search in sources :

Example 1 with Crossroad

use of il.ac.technion.cs.yp.btw.classes.Crossroad in project BTW by TechnionYearlyProject.

the class FreeFormMapSimulatorTest method testParameterMapRadius.

@Test
public void testParameterMapRadius() {
    int testCityRadius = 10000;
    FreeFormMapSimulator f = new FreeFormMapSimulator().setCityRadius(testCityRadius);
    f.build();
    for (Crossroad crossroad : f.getCrossRoads()) {
        assertTrue(FreeFormMapSimulator.calculateLengthBetween2Points(f.getCityCenter(), crossroad) <= (f.getCityRadius() + DEFAULT_RADIUS_MARGIN_OF_ERROR));
    }
}
Also used : Crossroad(il.ac.technion.cs.yp.btw.classes.Crossroad) Test(org.junit.Test)

Example 2 with Crossroad

use of il.ac.technion.cs.yp.btw.classes.Crossroad in project BTW by TechnionYearlyProject.

the class FreeFormMapSimulatorTest method testManyBlocksParameterMapRadius.

@Test
public void testManyBlocksParameterMapRadius() {
    int testCityRadius = 10000;
    int testNumOfBlocks = 300;
    FreeFormMapSimulator f = new FreeFormMapSimulator().setCityRadius(testCityRadius).setNumOfCityBlocks(testNumOfBlocks);
    f.build();
    for (Crossroad crossroad : f.getCrossRoads()) {
        assertTrue(FreeFormMapSimulator.calculateLengthBetween2Points(f.getCityCenter(), crossroad) <= (f.getCityRadius() + DEFAULT_RADIUS_MARGIN_OF_ERROR));
    }
}
Also used : Crossroad(il.ac.technion.cs.yp.btw.classes.Crossroad) Test(org.junit.Test)

Example 3 with Crossroad

use of il.ac.technion.cs.yp.btw.classes.Crossroad 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) {
        System.out.println("query 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)

Example 4 with Crossroad

use of il.ac.technion.cs.yp.btw.classes.Crossroad in project BTW by TechnionYearlyProject.

the class FreeFormMapSimulatorTest method testDefaultMapRadius.

@Test
public void testDefaultMapRadius() {
    FreeFormMapSimulator f = new FreeFormMapSimulator();
    f.build();
    for (Crossroad crossroad : f.getCrossRoads()) {
        assertTrue(FreeFormMapSimulator.calculateLengthBetween2Points(f.getCityCenter(), crossroad) <= (f.getCityRadius() + DEFAULT_RADIUS_MARGIN_OF_ERROR));
    }
}
Also used : Crossroad(il.ac.technion.cs.yp.btw.classes.Crossroad) Test(org.junit.Test)

Aggregations

Crossroad (il.ac.technion.cs.yp.btw.classes.Crossroad)4 Test (org.junit.Test)3 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 DataCrossRoad (il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad)1 DataTrafficLight (il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1