s2geometry icon indicating copy to clipboard operation
s2geometry copied to clipboard

python binding: S2RegionCoverer GetCovering/GetInteriorCovering returns list instead of S2CellUnion

Open calestyo opened this issue 5 years ago • 3 comments

Hey.

According to http://s2geometry.io/devguide/s2cell_hierarchy GetCovering/GetInteriorCovering should return S2CellUnions... in Python however they return a tuple (of S2CelIIds).

Is this intended?

Cheers, Chris.

calestyo avatar Jun 22 '20 02:06 calestyo

Can you show your code? Are you sure it's a tuple? I think it probably can just be assigned to a tuple because it's iterable, like (x, y) = [1, 2].

jmr avatar Jul 28 '20 09:07 jmr

I printed the type in the unit test and it's a list. We're wrapping the version that returns a vector<S2CellId>, not a S2CellUnion

https://github.com/google/s2geometry/blob/master/src/s2/s2region_coverer.h#L189 https://github.com/google/s2geometry/blob/master/src/python/s2_common.i#L501

jmr avatar Jul 28 '20 10:07 jmr

Ah, I see... well in principle that's okay for me... my code already works using that version ^^

So from my side you can also just close that issue.... unless you say you rather want to keep the function signature more similar, i.e. return the S2CellUnion... and for the other version, use a signature more similar to the C version like GetCovering(list, returnlist)

calestyo avatar Jul 28 '20 13:07 calestyo