コード例 #1
0
  public List<HashMap> searchQoneba(String searchText) throws SQLException, AppException {

    List<HashMap> result = new ArrayList<HashMap>();

    OracleResultSet rset = null;
    OracleCallableStatement stmt = null;
    try {

      stmt =
          (OracleCallableStatement)
              conn.prepareCall(
                  "begin ?:=" + TgisDBUtils.SCHEMA + "SEARCH_PKG.search_qoneba( ? ); end;");

      stmt.registerOutParameter(1, OracleTypes.CURSOR);

      stmt.setString(2, searchText);

      stmt.execute();

      rset = (OracleResultSet) stmt.getCursor(1);

      DBUtils.fetchOraSysRefCursor(rset, result, true, null);

      return result;

    } finally {
      DBUtils.clear(rset, stmt);
    }
  }
コード例 #2
0
  public List<HashMap> searchRoads(String searchText) throws SQLException, AppException {

    List<HashMap> result = new ArrayList<HashMap>();

    OracleResultSet rset = null;
    OracleCallableStatement stmt = null;
    try {

      stmt =
          (OracleCallableStatement)
              conn.prepareCall(
                  "begin ?:=" + TgisDBUtils.SCHEMA + "SEARCH_PKG.search_roads( ? ); end;");

      stmt.registerOutParameter(1, OracleTypes.CURSOR);

      stmt.setString(2, searchText);

      stmt.execute();

      rset = (OracleResultSet) stmt.getCursor(1);

      DBUtils.fetchOraSysRefCursor(rset, result, true, null);

      for (HashMap road : result) {
        List<HashMap> roadParts = (List<HashMap>) road.get("geometry");
        if (roadParts.size() == 1) {
          road.put("geometry", ((HashMap) roadParts.get(0)).get("geometry"));
        } else {
          if (roadParts.size() > 1) {
            StringBuilder joinedRoadWkt = new StringBuilder("MULTILINESTRING (");
            for (HashMap roadPart : roadParts) {

              String roadPartWkt = (String) roadPart.get("geometry");
              joinedRoadWkt.append(
                  roadPartWkt.replaceFirst("LINESTRING ", "").replaceFirst("MULTILINESTRING ", ""));
              joinedRoadWkt.append(",");
            }
            joinedRoadWkt.append(")");
            road.put("geometry", joinedRoadWkt.toString());
          } else {
            road.put("geometry", null);
          }
        }
      }

      return result;

    } finally {
      DBUtils.clear(rset, stmt);
    }
  }