Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _determine_time_ranges_pointbased(traj, polygon):
df = traj.df
df['t'] = df.index
df['intersects'] = df.intersects(polygon)
df['segment'] = (df['intersects'].shift(1) != df['intersects']).astype(int).cumsum()
df = df.groupby('segment', as_index=False).agg({'t': ['min', 'max'], 'intersects': ['min']})
df.columns = df.columns.map('_'.join)
ranges = []
for index, row in df.iterrows():
if row['intersects_min']:
ranges.append(TemporalRange(row['t_min'], row['t_max']))
return ranges