Abeeujah commented on code in PR #241:
URL: https://github.com/apache/sedona-db/pull/241#discussion_r2473696486


##########
c/sedona-geos/src/st_buffer.rs:
##########
@@ -592,4 +606,93 @@ mod tests {
 
         assert!(result_buffer.equals_exact(&expected_buffer, 0.1).unwrap());
     }
+
+    #[test]
+    fn test_side_right_geos_3_13() {
+        let wkt = "LINESTRING(50 50, 150 150, 150 50)";
+        let line = geos::Geometry::new_from_wkt(wkt).unwrap();
+        let distance = 100.0;
+
+        // Test single-sided buffer (GEOS 3.13+ removes artifacts, giving 
12713.61)
+        // PostGIS with GEOS 3.9 returns 16285.08 due to including geometric 
artifacts
+        // GEOS 3.12+ improvements: 
https://github.com/libgeos/geos/commit/091f6d99
+        let params_single = 
BufferParams::builder().single_sided(true).build().unwrap();
+
+        let buffer_right = line.buffer_with_params(-distance, 
&params_single).unwrap();
+        let area_right = buffer_right.area().unwrap();
+
+        // Expected area with GEOS 3.13 (improved algorithm without artifacts)
+        assert!(
+            (area_right - 12713.605978550266).abs() < 0.1,
+            "Expected GEOS 3.13+ area ~12713.61, got {}",
+            area_right
+        );
+    }
+
+    #[test]
+    fn test_empty_and_invalid_input() {
+        assert_eq!(
+            parse_buffer_side_style(None),
+            (false, false),
+            "Should return (false, false) for None."
+        );
+        assert_eq!(
+            parse_buffer_side_style(Some("")),
+            (false, false),
+            "Should return (false, false) for an empty string."
+        );
+        assert_eq!(
+            parse_buffer_side_style(Some("mitre_limit=5.0")),
+            (false, false),
+            "Should return (false, false) for an invalid key."
+        );
+    }
+
+    #[test]
+    fn test_single_side_and_case_insensitivity() {
+        assert_eq!(
+            parse_buffer_side_style(Some("side=left")),
+            (true, false),
+            "Should detect 'left'."
+        );
+        assert_eq!(
+            parse_buffer_side_style(Some("side=RIGHT")),
+            (false, true),
+            "Should detect 'RIGHT' case-insensitively."
+        );
+        assert_eq!(
+            parse_buffer_side_style(Some("SiDe=LeFt")),
+            (true, false),
+            "Should handle mixed case key and value."
+        );
+        assert_eq!(
+            parse_buffer_side_style(Some("join=mitre SIDE=RIGHT 
mitre_limit=5.0")),
+            (false, true),
+            "Should ignore other params and detect 'RIGHT'."
+        );
+        assert_eq!(
+            parse_buffer_side_style(Some("side=center")),
+            (false, false),
+            "Should ignore invalid side values."
+        );
+    }
+
+    #[test]
+    fn test_both_sides_present() {
+        assert_eq!(
+            parse_buffer_side_style(Some("side=left side=right")),

Review Comment:
   Thank you!!



-- 
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