@@ -1544,7 +1544,41 @@ def test_extract_unique_points(self):
15441544 self .check_sgpd_equals_gpd (df_result , expected )
15451545
15461546 def test_offset_curve (self ):
1547- pass
1547+ s = GeoSeries (
1548+ [
1549+ LineString ([(0 , 0 ), (0 , 1 ), (1 , 1 )]),
1550+ LineString ([(0 , 0 ), (10 , 0 )]),
1551+ ]
1552+ )
1553+
1554+ result = s .offset_curve (1.0 )
1555+ expected = gpd .GeoSeries (
1556+ [
1557+ LineString ([(0 , 0 ), (0 , 1 ), (1 , 1 )]),
1558+ LineString ([(0 , 0 ), (10 , 0 )]),
1559+ ]
1560+ ).offset_curve (1.0 )
1561+ self .check_sgpd_equals_gpd (result , expected )
1562+
1563+ # Negative distance (right side)
1564+ result = s .offset_curve (- 1.0 )
1565+ expected = gpd .GeoSeries (
1566+ [
1567+ LineString ([(0 , 0 ), (0 , 1 ), (1 , 1 )]),
1568+ LineString ([(0 , 0 ), (10 , 0 )]),
1569+ ]
1570+ ).offset_curve (- 1.0 )
1571+ self .check_sgpd_equals_gpd (result , expected )
1572+
1573+ # Check that GeoDataFrame works too
1574+ df_result = s .to_geoframe ().offset_curve (1.0 )
1575+ expected = gpd .GeoSeries (
1576+ [
1577+ LineString ([(0 , 0 ), (0 , 1 ), (1 , 1 )]),
1578+ LineString ([(0 , 0 ), (10 , 0 )]),
1579+ ]
1580+ ).offset_curve (1.0 )
1581+ self .check_sgpd_equals_gpd (df_result , expected )
15481582
15491583 def test_interiors (self ):
15501584 pass
@@ -2599,6 +2633,54 @@ def test_snap(self):
25992633 df_result = s .to_geoframe ().snap (s2 , tolerance = 1 , align = False )
26002634 self .check_sgpd_equals_gpd (df_result , expected )
26012635
2636+ def test_shortest_line (self ):
2637+ s1 = GeoSeries (
2638+ [
2639+ Point (0 , 0 ),
2640+ LineString ([(0 , 0 ), (1 , 0 )]),
2641+ Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 ), (0 , 1 )]),
2642+ ]
2643+ )
2644+ s2 = GeoSeries (
2645+ [
2646+ Point (1 , 1 ),
2647+ Point (0 , 1 ),
2648+ Point (2 , 2 ),
2649+ ]
2650+ )
2651+
2652+ result = s1 .shortest_line (s2 , align = False )
2653+ expected = gpd .GeoSeries (
2654+ [
2655+ LineString ([(0 , 0 ), (1 , 1 )]),
2656+ LineString ([(0 , 0 ), (0 , 1 )]),
2657+ LineString ([(1 , 1 ), (2 , 2 )]),
2658+ ]
2659+ )
2660+ self .check_sgpd_equals_gpd (result , expected )
2661+
2662+ # Test with single geometry
2663+ result = s1 .shortest_line (Point (1 , 1 ))
2664+ expected = gpd .GeoSeries (
2665+ [
2666+ LineString ([(0 , 0 ), (1 , 1 )]),
2667+ LineString ([(1 , 0 ), (1 , 1 )]),
2668+ LineString ([(1 , 1 ), (1 , 1 )]),
2669+ ]
2670+ )
2671+ self .check_sgpd_equals_gpd (result , expected )
2672+
2673+ # Test that GeoDataFrame works too
2674+ df_result = s1 .to_geoframe ().shortest_line (s2 , align = False )
2675+ expected = gpd .GeoSeries (
2676+ [
2677+ LineString ([(0 , 0 ), (1 , 1 )]),
2678+ LineString ([(0 , 0 ), (0 , 1 )]),
2679+ LineString ([(1 , 1 ), (2 , 2 )]),
2680+ ]
2681+ )
2682+ self .check_sgpd_equals_gpd (df_result , expected )
2683+
26022684 def test_intersection_all (self ):
26032685 s = GeoSeries ([box (0 , 0 , 2 , 2 ), box (1 , 1 , 3 , 3 )])
26042686 result = s .intersection_all ()
0 commit comments