Search in sources :

Example 6 with DataRoad

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

the class QueryAllRoads method arrangeRecievedData.

/*
     * @author Sharon Hadar
     * @Date 21/01/2018
     * construct a road by the information recieved from the data base
     * */
@Override
public Set<Road> arrangeRecievedData(ResultSet resultSet) {
    Set<Road> roads = new HashSet();
    try {
        while (resultSet.next()) {
            String nameID = resultSet.getString("nameID");
            double cord1x = resultSet.getDouble("cord1x");
            double cord2x = resultSet.getDouble("cord2x");
            double cord1y = resultSet.getDouble("cord1y");
            double cord2y = resultSet.getDouble("cord2y");
            int length = resultSet.getInt("length");
            int secStart = resultSet.getInt("secStart");
            int secEnd = resultSet.getInt("secEnd");
            long overload = resultSet.getLong("overload");
            String myStreet = nameID.split("st")[0];
            Point sourceCrossroadId = new PointImpl(cord1x, cord1y);
            Point destinationCrossroadId = new PointImpl(cord2x, cord2y);
            Road road = new DataRoad(nameID, length, myStreet, sourceCrossroadId, destinationCrossroadId, secStart, secEnd, overload, mapName);
            roads.add(road);
        }
    } catch (SQLException e) {
        System.out.println("query has failed");
    }
    return roads;
}
Also used : SQLException(java.sql.SQLException) Road(il.ac.technion.cs.yp.btw.classes.Road) DataRoad(il.ac.technion.cs.yp.btw.db.DataObjects.DataRoad) DataRoad(il.ac.technion.cs.yp.btw.db.DataObjects.DataRoad) Point(il.ac.technion.cs.yp.btw.classes.Point) Point(il.ac.technion.cs.yp.btw.classes.Point) PointImpl(il.ac.technion.cs.yp.btw.classes.PointImpl) HashSet(java.util.HashSet)

Aggregations

DataRoad (il.ac.technion.cs.yp.btw.db.DataObjects.DataRoad)6 PointImpl (il.ac.technion.cs.yp.btw.classes.PointImpl)5 Road (il.ac.technion.cs.yp.btw.classes.Road)5 Point (il.ac.technion.cs.yp.btw.classes.Point)4 SQLException (java.sql.SQLException)4 HashSet (java.util.HashSet)3 DataCrossRoad (il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad)1 DataStreet (il.ac.technion.cs.yp.btw.db.DataObjects.DataStreet)1 Test (org.junit.Test)1