Skip to content

When I used set_spatial_filter_rect to filter features, no results were returned. #708

Open

Description

@allenlu2008

gdal 3.10
crates 0.18.0
Data Source : open file gdb

layer.set_spatial_filter_rect(minx, miny, maxx, maxy);
println!("1. feature count : {}", layer.feature_count());
println!("2. feature count : {}", layer.features().count());

output :

  1. feature count : 26
  2. feature count : 0

but all formats are functioning properly except for the File GDB format.

Not only are the values incorrect, but no features are being retrieved either

However, it succeeds if I use unsafe and gdal_sys.

unsafe {
        let c_l = layer.c_layer();
        OGR_L_SetSpatialFilterRect(c_l, minx, miny, maxx, maxy);
        while let Some(x) = {
            let feat_ptr = gdal_sys::OGR_L_GetNextFeature(c_l);
            if feat_ptr.is_null() {
                None
            } else {
                Some(feat_ptr)
            }
        } {
            let fid = gdal_sys::OGR_F_GetFID(x);
            let f = layer.feature(fid as u64).unwrap();
            println!("fid = {:?} name = {:?}", f.fid(), f.field(0));

            gdal_sys::OGR_F_Destroy(x);
        }
    }

output :
fid = Some(47) name = Ok(Some(StringValue("feat 1")))
fid = Some(48) name = Ok(Some(StringValue("feat 2")))
fid = Some(49) name = Ok(Some(StringValue("feat 3")))
……

This is doing my head in……

thx

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions