@@ -815,7 +815,7 @@ def box_indexes(x, y, step):
815
815
816
816
817
817
@njit (cache = True )
818
- def poly_indexs (x_p , y_p , x_c , y_c ):
818
+ def poly_indexs_ (x_p , y_p , x_c , y_c ):
819
819
"""
820
820
Index of contour for each postion inside a contour, -1 in case of no contour
821
821
@@ -873,6 +873,34 @@ def poly_indexs(x_p, y_p, x_c, y_c):
873
873
return indexs
874
874
875
875
876
+ @njit (cache = True )
877
+ def poly_indexs (x_p , y_p , x_c , y_c ):
878
+ """
879
+ index of contour for each postion inside a contour, -1 in case of no contour
880
+
881
+ :param array x_p: longitude to test
882
+ :param array y_p: latitude to test
883
+ :param array x_c: longitude of contours
884
+ :param array y_c: latitude of contours
885
+ """
886
+ nb_p = x_p .shape [0 ]
887
+ nb_c = x_c .shape [0 ]
888
+ indexs = - ones (nb_p , dtype = numba_types .int32 )
889
+ for i in range (nb_c ):
890
+ x_ , y_ = reduce_size (x_c [i ], y_c [i ])
891
+ x_c_min , y_c_min = x_ .min (), y_ .min ()
892
+ x_c_max , y_c_max = x_ .max (), y_ .max ()
893
+ v = create_vertice (x_ , y_ )
894
+ for j in range (nb_p ):
895
+ if indexs [j ] != - 1 :
896
+ continue
897
+ x , y = x_p [j ], y_p [j ]
898
+ if x > x_c_min and x < x_c_max and y > y_c_min and y < y_c_max :
899
+ if winding_number_poly (x , y , v ) != 0 :
900
+ indexs [j ] = i
901
+ return indexs
902
+
903
+
876
904
@njit (cache = True )
877
905
def insidepoly (x_p , y_p , x_c , y_c ):
878
906
"""
0 commit comments