paleolimbot commented on code in PR #1225:
URL: https://github.com/apache/sedona-db/pull/1225#discussion_r3937720950


##########
rust/sedona-geometry/src/types.rs:
##########
@@ -429,6 +441,37 @@ impl GeometryTypeAndDimensionsSet {
             current_bit: 0,
         }
     }
+
+    /// The distinct geometry types in this set, in ascending WKB-id order.
+    pub fn geometry_types(&self) -> Vec<GeometryTypeId> {
+        // Collapse the four dimension bytes onto one: bit i is set iff a
+        // geometry with WKB id i is present under any dimension.
+        let merged =
+            (self.types | (self.types >> 8) | (self.types >> 16) | (self.types 
>> 24)) & 0xFF;
+        (0..8)
+            .filter(|i| merged & (1 << i) != 0)
+            .map(|i| {
+                GeometryTypeId::try_from_wkb_id(i)
+                    .expect("Invalid geometry type wkb_id in 
GeometryTypeAndDimensionsSet")
+            })
+            .collect()
+    }
+
+    /// The distinct dimensions in this set, in XY, XYZ, XYM, XYZM order.
+    pub fn dimensions(&self) -> Vec<Dimensions> {
+        // Each dimension occupies one byte; the dimension is present iff its
+        // byte has any type bit set.
+        [
+            (0x0000_00FF, Dimensions::Xy),
+            (0x0000_FF00, Dimensions::Xyz),
+            (0x00FF_0000, Dimensions::Xym),
+            (0xFF00_0000_u32, Dimensions::Xyzm),
+        ]
+        .into_iter()
+        .filter(|(mask, _)| self.types & mask != 0)
+        .map(|(_, dim)| dim)
+        .collect()
+    }

Review Comment:
   If you are going to add these two functions you should check the matrix of 
geometry type by dimensions that each pair correctly returns the correct 
list-of-one GeometryType and Dimensions (I don't think there's anything making 
sure the bits are correct at the moment)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to