Search in sources :

Example 16 with Point

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

the class QueryCentralLocation method arrangeRecievedData.

/*
     * @author Sharon Hadar
     * @Date 21/01/2018
     * construct a centeral location from the data base results*/
@Override
public CentralLocation arrangeRecievedData(ResultSet resultSet) {
    CentralLocation centralLocation = null;
    try {
        // check if it is necessary.
        resultSet.next();
        String nameID = resultSet.getString("nameID");
        String street = resultSet.getString("street");
        double cord1x = resultSet.getDouble("cord1x");
        double cord2x = resultSet.getDouble("cord2x");
        double cord3x = resultSet.getDouble("cord3x");
        double cord4x = resultSet.getDouble("cord4x");
        double cord1y = resultSet.getDouble("cord1y");
        double cord2y = resultSet.getDouble("cord2y");
        double cord3y = resultSet.getDouble("cord3y");
        double cord4y = resultSet.getDouble("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 = new DataCentralLocation(points, nameID, street, mapName);
    } catch (SQLException e) {
        logger.error("query central location has failed");
    }
    return centralLocation;
}
Also used : DataCentralLocation(il.ac.technion.cs.yp.btw.db.DataObjects.DataCentralLocation) SQLException(java.sql.SQLException) CentralLocation(il.ac.technion.cs.yp.btw.classes.CentralLocation) DataCentralLocation(il.ac.technion.cs.yp.btw.db.DataObjects.DataCentralLocation) Point(il.ac.technion.cs.yp.btw.classes.Point) PointImpl(il.ac.technion.cs.yp.btw.classes.PointImpl) HashSet(java.util.HashSet)

Example 17 with Point

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

the class QueryStreet method arrangeRecievedData.

/*
     * @author Sharon Hadar
     * @Date 21/01/2018
     * construct a street from the result of the data base*/
@Override
public Street arrangeRecievedData(ResultSet resultSet) {
    Set<Road> roads = new HashSet();
    try {
        while (resultSet.next()) {
            String nameID = resultSet.getString("nameID");
            int cord1x = resultSet.getInt("cord1x");
            int cord2x = resultSet.getInt("cord2x");
            int cord1y = resultSet.getInt("cord1y");
            int cord2y = resultSet.getInt("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) {
        logger.error("query has failed");
    }
    return new DataStreet(streetName, roads, mapName);
}
Also used : DataStreet(il.ac.technion.cs.yp.btw.db.DataObjects.DataStreet) 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

Point (il.ac.technion.cs.yp.btw.classes.Point)17 PointImpl (il.ac.technion.cs.yp.btw.classes.PointImpl)12 SQLException (java.sql.SQLException)10 HashSet (java.util.HashSet)10 TrafficLight (il.ac.technion.cs.yp.btw.classes.TrafficLight)5 DataRoad (il.ac.technion.cs.yp.btw.db.DataObjects.DataRoad)5 DataTrafficLight (il.ac.technion.cs.yp.btw.db.DataObjects.DataTrafficLight)5 Road (il.ac.technion.cs.yp.btw.classes.Road)4 CentralLocation (il.ac.technion.cs.yp.btw.classes.CentralLocation)3 DataCentralLocation (il.ac.technion.cs.yp.btw.db.DataObjects.DataCentralLocation)3 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 Crossroad (il.ac.technion.cs.yp.btw.classes.Crossroad)2 DataCrossRoad (il.ac.technion.cs.yp.btw.db.DataObjects.DataCrossRoad)2 Pair (javafx.util.Pair)2 Test (org.junit.Test)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 CityRoad (il.ac.technion.cs.yp.btw.citysimulation.CityRoad)1 CityTrafficLight (il.ac.technion.cs.yp.btw.citysimulation.CityTrafficLight)1