getSpatialindexBBoxWherePiece method

String? getSpatialindexBBoxWherePiece(
  1. TableName tableName,
  2. String? alias,
  3. double x1,
  4. double y1,
  5. double x2,
  6. double y2,
)

Implementation

String? getSpatialindexBBoxWherePiece(TableName tableName, String? alias,
    double x1, double y1, double x2, double y2) {
  if (!_supportsRtree) return null;
  FeatureEntry? featureItem = feature(tableName);
  if (featureItem == null) {
    return null;
  }
  String spatial_index = getSpatialIndexName(featureItem);

  String? pk = _sqliteDb.getPrimaryKey(tableName);
  if (pk == null) {
// can't use spatial index
    return null;
  }

  String check =
      "($x1 <= maxx and $x2 >= minx and $y1 <= maxy and $y2 >= miny)";
// Make Sure the table name is escaped
  String sql = pk +
      " IN ( SELECT id FROM \"" +
      spatial_index +
      "\"  WHERE " +
      check +
      ")";
  return sql;
}