@@ -101,6 +101,12 @@ def coastline_crossing(lon1, lat1, lon2, lat2, step_degrees, land_side=True):
101101 y_degree_diff = np .abs (lat2 - lat1 )
102102 if x_degree_diff == 0 and y_degree_diff == 0 :
103103 continue
104+ if x_degree_diff > 180 : # Crossing dateline
105+ if lon1 < 0 :
106+ lon2 = lon2 - 360
107+ x_degree_diff = np .abs (lon2 - lon1 )
108+ pass
109+ # TODO: delta_lon * cos(latitude)
104110 x_samples = np .floor (x_degree_diff / step_degrees ).astype (np .int64 ) if x_degree_diff > step_degrees else 1
105111 x = np .linspace (lon1 , lon2 , x_samples )
106112 y_samples = np .floor (y_degree_diff / step_degrees ).astype (np .int64 ) if y_degree_diff > step_degrees else 1
@@ -693,8 +699,8 @@ def interact_with_coastline(self, final=False):
693699 return
694700
695701 self .elements .lon [on_land ], self .elements .lat [on_land ] = coastline_crossing (
696- self ._elements_previous .lon [on_land ],
697- self ._elements_previous .lat [on_land ],
702+ self ._elements_previous .lon [self . elements . ID ][ on_land ],
703+ self ._elements_previous .lat [self . elements . ID ][ on_land ],
698704 self .elements .lon [on_land ],
699705 self .elements .lat [on_land ],
700706 coastline_approximation_precision ,
@@ -716,14 +722,13 @@ def interact_with_coastline(self, final=False):
716722 logger .debug ('%s elements hit coastline, '
717723 'moving back to water' % len (on_land ))
718724 on_land_ID = self .elements .ID [on_land ]
719-
720725 if not coastline_approximation_precision :
721726 self .elements .lon [on_land ] = self ._elements_previous .lon [on_land_ID ]
722727 self .elements .lat [on_land ] = self ._elements_previous .lat [on_land_ID ]
723728 else :
724729 self .elements .lon [on_land ], self .elements .lat [on_land ] = coastline_crossing (
725- self ._elements_previous .lon [on_land ],
726- self ._elements_previous .lat [on_land ],
730+ self ._elements_previous .lon [self . elements . ID ][ on_land ],
731+ self ._elements_previous .lat [self . elements . ID ][ on_land ],
727732 self .elements .lon [on_land ],
728733 self .elements .lat [on_land ],
729734 coastline_approximation_precision ,
0 commit comments