Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subset operation fails when used on a filtered file #183

Open
AkshayPatil1994 opened this issue May 1, 2024 · 4 comments
Open

Subset operation fails when used on a filtered file #183

AkshayPatil1994 opened this issue May 1, 2024 · 4 comments

Comments

@AkshayPatil1994
Copy link

cjio <myfile> subset --radius <sx> <sy> <radius> save <outfile>

The above command returns an empty file when is obtained from

cjio <oldfile> lod_filter 2.2 save <myfile>

However, if I use the original file containing the entire dataset and then use the subset operation it returns the right result. A bit puzzeled as to why this is the case. I would have expected it to work eitherway, but perhaps I misunderstood something. Perhaps the right order of using cjio would be to

  1. Subset first (always)
  2. Then use the filter operation

What I used that returns empty data

  1. Filter for lod2.2
  2. Subset

cjio version
cjio version 2.0

To Reproduce
Steps detailed above

Expected behavior
I was expecting that that since the subset operation yanks the chunk that is of interest it should have worked irrespective of the contents of the file. However, it seems that subset operations can only work on the original file with all the contents and do not work when a filtered file is used as shown above.

Screenshots
NA

Desktop (please complete the following information):

  • OS: MacOSX
  • Version 14.4.1

Additional context
NA

@hugoledoux
Copy link
Member

It should work either way.

Can you provide the file, or a subset of it so that I can reproduce the bug? Is it the 3dbag?

@AkshayPatil1994
Copy link
Author

subset.city.json

This is the subset that breaks things when the order is not followed!

@hugoledoux
Copy link
Member

okay so I can reproduce this bug with any 3dbag.nl files.

Both functions are okay and work, this is the good news.

The reason nothing is returned is that if you lod_filter "2.2" then the geometry having lod=0 which is in the parent Building gets removed, and the Building has no geometry itself, the geometries are in the BuildingPart which contains the lod=2.2

We decided a while ago that the subset operator should not include the parents of selected city objects (https://github.com/cityjson/cjio/blob/develop/cjio/subset.py#L8), only the children of the selected ones. This was to avoid adding the parents if one ID of a BuildingPart is selected for instance: we cannot add only the child since we would create invalid files (a CityObject having a parent must have its parent in the file), and we thought that including the parents was somehow not the behaviour we wanted.

But clearly your example breaks this, so I am not sure what we should do.

@balazsdukai any thoughts?

@balazsdukai
Copy link
Member

In case of spatial subsets the whole hierarchy should be included for a CityObject.
As you say Hugo, the risk is that we include dangling children in the output, because the parent object does not overlap the area of interest.
I think we could resolve this by keeping an account of child-->parent in the output, and at the end remove all children that does not have a parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants