Package org.postgis

Examples of org.postgis.PGgeometry


        return obj != null ? PGgeometryConverter.convert(((PGgeometry) obj).getGeometry()) : null;
    }

    @Override
    public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException {
        PGgeometry geometry = new PGgeometry(PGgeometryConverter.convert(value));
        st.setObject(startIndex, geometry);
    }
View Full Code Here


    public Gps(/*int trip_id, */long timestampInMilliseconds, String point) throws SQLException {
        super();
//        this.trip_id = trip_id;
        this.timestampInMilliseconds = timestampInMilliseconds;
        this.point =  new LiveGovPoint(new PGgeometry(point));
    }
View Full Code Here

        this.tripId = tripId;
        this.activity_started_ts = activity_started_ts;
        this.activity_ended_ts = activity_ended_ts;
        this.activity = activity;
        this.activity_time_elapsed = activity_time_elapsed;
        this.point =  new LiveGovPoint(new PGgeometry(point));
    }
View Full Code Here

    // Select all nodes inside the box into the node temp table.
    LOG.finer("Selecting all nodes inside bounding box.");
    rowCount = jdbcTemplate.update(
        "CREATE TEMPORARY TABLE bbox_nodes ON COMMIT DROP AS"
        + " SELECT * FROM nodes WHERE (geom && ?)",
        new PGgeometry(bboxPolygon));
   
    LOG.finer("Adding a primary key to the temporary nodes table.");
    jdbcTemplate.update("ALTER TABLE ONLY bbox_nodes ADD CONSTRAINT pk_bbox_nodes PRIMARY KEY (id)");
   
    LOG.finer("Updating query analyzer statistics on the temporary nodes table.");
    jdbcTemplate.update("ANALYZE bbox_nodes");
   
    // Select all ways inside the bounding box into the way temp table.
    if (capabilityChecker.isWayLinestringSupported()) {
      LOG.finer("Selecting all ways inside bounding box using way linestring geometry.");
      // We have full way geometry available so select ways
      // overlapping the requested bounding box.
      rowCount = jdbcTemplate.update(
          "CREATE TEMPORARY TABLE bbox_ways ON COMMIT DROP AS"
          + " SELECT * FROM ways WHERE (linestring && ?)",
          new PGgeometry(bboxPolygon));
     
    } else if (capabilityChecker.isWayBboxSupported()) {
      LOG.finer("Selecting all ways inside bounding box using dynamically built"
          + " way linestring with way bbox indexing.");
      // The inner query selects the way id and node coordinates for
      // all ways constrained by the way bounding box which is
      // indexed.
      // The middle query converts the way node coordinates into
      // linestrings.
      // The outer query constrains the query to the linestrings
      // inside the bounding box. These aren't indexed but the inner
      // query way bbox constraint will minimise the unnecessary data.
      rowCount = jdbcTemplate.update(
        "CREATE TEMPORARY TABLE bbox_ways ON COMMIT DROP AS"
          + " SELECT w.* FROM ("
          + "SELECT c.id AS id, First(c.version) AS version, First(c.user_id) AS user_id,"
          + " First(c.tstamp) AS tstamp, First(c.changeset_id) AS changeset_id, First(c.tags) AS tags,"
          + " First(c.nodes) AS nodes, ST_MakeLine(c.geom) AS way_line FROM ("
          + "SELECT w.*, n.geom AS geom FROM nodes n"
          + " INNER JOIN way_nodes wn ON n.id = wn.node_id"
          + " INNER JOIN ways w ON wn.way_id = w.id"
          + " WHERE (w.bbox && ?) ORDER BY wn.way_id, wn.sequence_id"
          + ") c "
          + "GROUP BY c.id"
          + ") w "
          + "WHERE (w.way_line && ?)",
          new PGgeometry(bboxPolygon),
          new PGgeometry(bboxPolygon)
      );
     
    } else {
      LOG.finer("Selecting all way ids inside bounding box using already selected nodes.");
      // No way bbox support is available so select ways containing
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public Node mapRow(ResultSet rs, int rowNumber) throws SQLException {
    PGgeometry geom;
    Point point;
   
    geom = (PGgeometry) rs.getObject("geom");
    point = (Point) geom.getGeometry();
   
    return new Node(mapCommonEntityData(rs), point.y, point.x);
  }
View Full Code Here

      // Select all nodes inside the box into the node temp table.
      LOG.finer("Selecting all node ids inside bounding box.");
      preparedStatement = dbCtx.prepareStatement(
          "INSERT INTO box_node_list SELECT id FROM nodes WHERE (geom && ?)");
      prmIndex = 1;
      preparedStatement.setObject(prmIndex++, new PGgeometry(bboxPolygon));
      rowCount = preparedStatement.executeUpdate();
      preparedStatement.close();
      preparedStatement = null;
      LOG.finer(rowCount + " rows affected.");
     
      // Select all ways inside the bounding box into the way temp table.
      if (capabilityChecker.isWayLinestringSupported()) {
        LOG.finer("Selecting all way ids inside bounding box using way linestring geometry.");
        // We have full way geometry available so select ways
        // overlapping the requested bounding box.
        preparedStatement = dbCtx.prepareStatement(
          "INSERT INTO box_way_list "
            + "SELECT id FROM ways w where w.linestring && ?"
        );
        prmIndex = 1;
        preparedStatement.setObject(prmIndex++, new PGgeometry(bboxPolygon));
       
      } else if (capabilityChecker.isWayBboxSupported()) {
        LOG.finer("Selecting all way ids inside bounding box using dynamically built"
            + " way linestring with way bbox indexing.");
        // The inner query selects the way id and node coordinates for
        // all ways constrained by the way bounding box which is
        // indexed.
        // The middle query converts the way node coordinates into
        // linestrings.
        // The outer query constrains the query to the linestrings
        // inside the bounding box. These aren't indexed but the inner
        // query way bbox constraint will minimise the unnecessary data.
        preparedStatement = dbCtx.prepareStatement(
          "INSERT INTO box_way_list "
            + "SELECT way_id FROM ("
            + "SELECT c.way_id AS way_id, ST_MakeLine(c.geom) AS way_line FROM ("
            + "SELECT w.id AS way_id, n.geom AS geom FROM nodes n"
            + " INNER JOIN way_nodes wn ON n.id = wn.node_id"
            + " INNER JOIN ways w ON wn.way_id = w.id"
            + " WHERE (w.bbox && ?) ORDER BY wn.way_id, wn.sequence_id"
            + ") c "
            + "GROUP BY c.way_id"
            + ") w "
            + "WHERE (w.way_line && ?)"
        );
        prmIndex = 1;
        preparedStatement.setObject(prmIndex++, new PGgeometry(bboxPolygon));
        preparedStatement.setObject(prmIndex++, new PGgeometry(bboxPolygon));
       
      } else {
        LOG.finer("Selecting all way ids inside bounding box using already selected nodes.");
        // No way bbox support is available so select ways containing
        // the selected nodes.
View Full Code Here

     * Pass a geometry representation through the SQL server via prepared
     * statement
     */
    private static Geometry viaPrepSQL(Geometry geom, Connection conn) throws SQLException {
        PreparedStatement prep = conn.prepareStatement("SELECT ?::geometry");
        PGgeometry wrapper = new PGgeometry(geom);
        prep.setObject(1, wrapper, Types.OTHER);
        ResultSet rs = prep.executeQuery();
        rs.next();
        PGgeometry resultwrapper = ((PGgeometry) rs.getObject(1));
        return resultwrapper.getGeometry();
    }
View Full Code Here

    private static Geometry binaryViaSQL(byte[] rep, Connection conn) throws SQLException {
        PreparedStatement prep = conn.prepareStatement("SELECT ?::bytea::geometry");
        prep.setBytes(1, rep);
        ResultSet rs = prep.executeQuery();
        rs.next();
        PGgeometry resultwrapper = ((PGgeometry) rs.getObject(1));
        return resultwrapper.getGeometry();
    }
View Full Code Here

        System.out.println();

        System.out.println("PG Test:");
        System.out.println("\t" + mlng_str);
        PGgeometry pgf = new PGgeometry(mlng_str);
        System.out.println("\t" + pgf.toString());

        System.out.println();

        System.out.println("finished");
        // If we reached here without any exception, we passed all tests.
View Full Code Here

   
    prmIndex = populateEntityParameters(statement, initialIndex, way);
   
    try {
      for (int i = 0; i < geometries.size(); i++) {
        statement.setObject(prmIndex++, new PGgeometry(geometries.get(i)));
      }
     
    } catch (SQLException e) {
      throw new OsmosisRuntimeException(
        "Unable to set the bbox for way " + way.getId() + ".",
View Full Code Here

TOP

Related Classes of org.postgis.PGgeometry

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.