Package org.worldbank.transport.tamt.shared

Examples of org.worldbank.transport.tamt.shared.StudyRegion


      tagDetails.setId(currentTagDetails.getId());
    }
    GWT.log("TAG DETAILS just id for saving flow:" + tagDetails);
   
    // get the study region id too (but just the id)
    StudyRegion region = new StudyRegion();
    region.setId(currentStudyRegion.getId());
    tagDetails.setRegion(region);
    defaultFlow.setTagDetails(tagDetails);
   
    defaultFlow.setW2Weekday(weekdayW2.getValue());
    defaultFlow.setW2Saturday(saturdayW2.getValue());
View Full Code Here


        gpsTrace.setId(id);
        gpsTrace.setName(name);
        gpsTrace.setDescription(description);

        StudyRegion region = new StudyRegion();
        region.setId(regionId);

        gpsTrace.setRegion(region);
        gpsTrace.setFileId(fileId);
        gpsTrace.setUploadDate(uploadDate);
        gpsTrace.setProcessDate(processDate);
View Full Code Here

              + e.getMessage());
    }
   
   
    // fill out the study region a bit more, including providing the offset
    StudyRegion query = gpsTrace.getRegion();
    StudyRegion studyRegion = regionDao.getStudyRegion(query);
   
    /*
     * Some imported points may be outside the study region boundary.
     * Delete them.
     */
    if( studyRegion != null )
    {
      logger.debug("Delete points outside of study region boundary");
      try {
        Connection connection = getConnection();
        Statement s = connection.createStatement();
        String sql = "DELETE FROM gpspoints WHERE id NOT IN " +
            "(SELECT p.id FROM gpspoints p, studyregion r " +
            "WHERE r.id = '"+studyRegion.getId()+"' " +
            "AND (ST_Contains(r.geometry, p.geometry)))";
        logger.debug(sql);
     
        /*
         * TODO: we aren't executing this SQL yet, because
         * when we do, the assign algorithm doesn't process
         * any points -- even if the study area includes the
         * intersection of Winneba and Dansoman where we
         * know there are points contained in the small.zip
         * test GPS archive.
         */
        //s.executeUpdate(sql);
     
      } catch (SQLException e) {
        logger.error("Delete points outside of region error:" + e.getMessage());
          throw new Exception(
              "There was an error deleting points outside the study region boundary: "
                  + e.getMessage())
      }
    }
   
    /*
     * We want to account for the UTC offset in the 'created' timestamp for each
     * GPS point. To do this, we lookup the UTC offset the user supplied
     * for the study region, and use PostGIS intervals to calculate the correct date
     */
    String regionOffset = studyRegion.getUtcOffset();
    String intervalOperator = "+";
    if( regionOffset == null || regionOffset.isEmpty() )
    {
      // default to 0, as in 'no offset'
      // If the user has not supplied one, their GPS trip data may be WAY off
View Full Code Here

      throw e;
    }
  }

  public StudyRegion getStudyRegion(StudyRegion studyRegion) throws Exception {
    StudyRegion fetched = null;
    try {
      Connection connection = getConnection();
      Statement s = connection.createStatement();
      String sql = "select id, name, description, AsText(geometry) geom, " +
      "mapzoomlevel, AsText(mapcenter) center, iscurrentregion, " +
      "default_zone_type, utcoffset, minsoakinterval, commercial_block_length, industrial_block_length, residential_block_length, gps_tagging_tolerance " +
      "FROM studyregion WHERE id = '"+studyRegion.getId()+"' ORDER BY name";
      logger.debug("getStudyRegions sql=" + sql);
      ResultSet r = s.executeQuery(sql);
      while( r.next() ) {
       
        /*
            * Retrieve the geometry as an object then cast it to the geometry type.
            * Print things out.
            */
          String id = r.getString(1);
            String name = r.getString(2);
            String description = r.getString(3);
            String lineString = r.getString(4);
            int mapZoomLevel = r.getInt(5);
            String mapCenterWKT = r.getString(6);
            boolean currentRegion = r.getBoolean(7);
            String defaultZoneType = r.getString(8);
            String utcOffset = r.getString(9);
            String minimumSoakInterval = r.getString(10);
            String commercialZoneBlockLength = r.getString(11);
            String industrialZoneBlockLength = r.getString(12);
            String residentialZoneBlockLength = r.getString(13);
            String gpsTaggingTolerance = r.getString(14);
           
            // convert a linestring to a JTS geometry
            WKTReader reader = new WKTReader();
            Geometry geometry = reader.read(lineString);
            Point centroidJTS = geometry.getCentroid();
           
            fetched = new StudyRegion();
            fetched.setId(id);
            fetched.setName(name);
            fetched.setDescription(description);
            fetched.setCurrentRegion(currentRegion);
            fetched.setMapZoomLevel(mapZoomLevel);
            fetched.setDefaultZoneType(defaultZoneType);
            fetched.setUtcOffset(utcOffset);
            fetched.setMinimumSoakInterval(minimumSoakInterval);
            fetched.setCommercialZoneBlockLength(commercialZoneBlockLength);
            fetched.setIndustrialZoneBlockLength(industrialZoneBlockLength);
            fetched.setResidentialZoneBlockLength(residentialZoneBlockLength);
            fetched.setGpsTaggingTolerance(gpsTaggingTolerance);
           
            // now convert the geometry to an ArrayList<Vertex> and
            // set in the roadDetails
            ArrayList<Vertex> vertices = Utils.geometryToVertexArrayList(geometry);
            fetched.setVertices(vertices);
           
            // convert the centroid point into a Vertex
            Vertex centroid = new Vertex();
            centroid.setLat(centroidJTS.getY());
            centroid.setLng(centroidJTS.getX());
            fetched.setCentroid(centroid);
           
            // and get the map meta data too
            Geometry mapCenterGeom = reader.read(mapCenterWKT);
            Point mapCenterJTS = mapCenterGeom.getCentroid();
            Vertex mapCenterVertex = new Vertex();
            mapCenterVertex.setLat(mapCenterJTS.getY());
            mapCenterVertex.setLng(mapCenterJTS.getX());
            fetched.setMapCenter(mapCenterVertex);
      }
    } catch (SQLException e) {
      logger.error(e.getMessage());
      throw e;
     
View Full Code Here

            // convert a linestring to a JTS geometry
            WKTReader reader = new WKTReader();
            Geometry geometry = reader.read(lineString);
            Point centroidJTS = geometry.getCentroid();
           
            StudyRegion studyRegion = new StudyRegion();
            studyRegion.setId(id);
            studyRegion.setName(name);
            studyRegion.setDescription(description);
            studyRegion.setCurrentRegion(currentRegion);
            studyRegion.setMapZoomLevel(mapZoomLevel);
            studyRegion.setDefaultZoneType(defaultZoneType);
            studyRegion.setUtcOffset(utcOffset);
            studyRegion.setMinimumSoakInterval(minimumSoakInterval);
            studyRegion.setCommercialZoneBlockLength(commercialZoneBlockLength);
            studyRegion.setIndustrialZoneBlockLength(industrialZoneBlockLength);
            studyRegion.setResidentialZoneBlockLength(residentialZoneBlockLength);
            studyRegion.setGpsTaggingTolerance(gpsTaggingTolerance);
           
            // now convert the geometry to an ArrayList<Vertex> and
            // set in the roadDetails
            ArrayList<Vertex> vertices = Utils.geometryToVertexArrayList(geometry);
            studyRegion.setVertices(vertices);
           
            // convert the centroid point into a Vertex
            Vertex centroid = new Vertex();
            centroid.setLat(centroidJTS.getY());
            centroid.setLng(centroidJTS.getX());
            studyRegion.setCentroid(centroid);
           
            // and get the map meta data too
            Geometry mapCenterGeom = reader.read(mapCenterWKT);
            Point mapCenterJTS = mapCenterGeom.getCentroid();
            Vertex mapCenterVertex = new Vertex();
            mapCenterVertex.setLat(mapCenterJTS.getY());
            mapCenterVertex.setLng(mapCenterJTS.getX());
            studyRegion.setMapCenter(mapCenterVertex);
           
           
            studyRegionList.add(studyRegion);
      }
      connection.close(); // returns connection to the pool
View Full Code Here

  }
 
  public TagDetails getStudyRegion(TagDetails tagDetails) throws Exception
  {
   
    StudyRegion studyRegion = null;
    try {
      Connection connection = getConnection();
      Statement s = connection.createStatement();
      String sql = "SELECT t.id, t.name, s.id, s.name " +
          "FROM tagdetails t, studyregion s " +
          "WHERE t.region = s.id " +
          "AND t.id = '"+tagDetails.getId()+"'";
      logger.debug("sql=" + sql);
      ResultSet r = s.executeQuery(sql);
      while( r.next() ) {
       
        // we will use the tag name
        tagDetails.setName(r.getString(2));
       
        // and we really want the study name
        studyRegion = new StudyRegion();
        studyRegion.setId(r.getString(3));
        studyRegion.setName(r.getString(4));
       
        tagDetails.setRegion(studyRegion);
       
      }
    } catch (SQLException e) {
View Full Code Here

    // truncate the speed distribution tables
    truncateSpeedDistributionTables();
   
    // get default study region
    ArrayList<StudyRegion> regions = regionDao.getStudyRegions();
    StudyRegion currentStudyRegion = null;
    for (Iterator iterator = regions.iterator(); iterator.hasNext();) {
      StudyRegion studyRegion = (StudyRegion) iterator.next();
      if( studyRegion.isCurrentRegion())
      {
        currentStudyRegion = studyRegion;
        break;
      }
    }
View Full Code Here

   
    logger.debug("populateSpeedDistObserved");
   
    // get default study region
    ArrayList<StudyRegion> regions = regionDao.getStudyRegions();
    StudyRegion currentStudyRegion = null;
    for (Iterator iterator = regions.iterator(); iterator.hasNext();) {
      StudyRegion studyRegion = (StudyRegion) iterator.next();
      if( studyRegion.isCurrentRegion())
      {
        currentStudyRegion = studyRegion;
        break;
      }
    }
View Full Code Here

    // truncate subsequent speed distribution tables
    truncateSpeedDistributionTablesPreSpeedDistTrafficFlow();
   
    // get default study region
    ArrayList<StudyRegion> regions = regionDao.getStudyRegions();
    StudyRegion currentStudyRegion = null;
    for (Iterator iterator = regions.iterator(); iterator.hasNext();) {
      StudyRegion studyRegion = (StudyRegion) iterator.next();
      if( studyRegion.isCurrentRegion())
      {
        currentStudyRegion = studyRegion;
        break;
      }
    }
View Full Code Here

    // truncate subsequent speed distribution tables
    //truncateSpeedDistributionTablesPreSpeedDistTrafficFlowTagVehicleSpeed();
   
    // get default study region
    ArrayList<StudyRegion> regions = regionDao.getStudyRegions();
    StudyRegion currentStudyRegion = null;
    for (Iterator iterator = regions.iterator(); iterator.hasNext();) {
      StudyRegion studyRegion = (StudyRegion) iterator.next();
      if( studyRegion.isCurrentRegion())
      {
        currentStudyRegion = studyRegion;
        break;
      }
    }
View Full Code Here

TOP

Related Classes of org.worldbank.transport.tamt.shared.StudyRegion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.