getSpatialindexBBoxWherePiece method

Future<String?> getSpatialindexBBoxWherePiece(
  1. TableName tableName,
  2. double x1,
  3. double y1,
  4. double x2,
  5. double y2,
)

Implementation

Future<String?> getSpatialindexBBoxWherePiece(
    TableName tableName, double x1, double y1, double x2, double y2) async {
  Polygon bounds = PostgisUtils.createPolygonFromBounds(x1, y1, x2, y2);
  GeometryColumn? gCol = await getGeometryColumnsForTable(tableName);
  if (gCol == null) {
    return null;
  }
  int srid = gCol.srid;

  String sql = gCol.geometryColumnName +
      " && ST_GeomFromText('" +
      bounds.toText() +
      "', $srid) AND ST_Intersects(" +
      gCol.geometryColumnName +
      ",ST_GeomFromText('" +
      bounds.toText() +
      "',$srid))";
  return sql;
}