How to use the timezonefinder.global_settings.MAX_HAVERSINE_DISTANCE function in timezonefinder

To help you get started, we’ve selected a few timezonefinder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MrMinimal64 / timezonefinder / timezonefinder / helpers_numba.py View on Github external
def distance_to_polygon(lng_rad, lat_rad, nr_points, points):
    min_distance = MAX_HAVERSINE_DISTANCE

    for i in range(nr_points):
        min_distance = min(min_distance, haversine(lng_rad, lat_rad, radians(int2coord(points[0][i])),
                                                   radians(int2coord(points[1][i]))))
    return min_distance
github MrMinimal64 / timezonefinder / timezonefinder / helpers.py View on Github external
def distance_to_polygon(lng_rad, lat_rad, nr_points, points):
    min_distance = MAX_HAVERSINE_DISTANCE

    for i in range(nr_points):
        min_distance = min(min_distance, haversine(lng_rad, lat_rad, radians(int2coord(points[0][i])),
                                                   radians(int2coord(points[1][i]))))

    return min_distance
github MrMinimal64 / timezonefinder / timezonefinder / timezonefinder.py View on Github external
# initialize the list of ids
        # this list is sorted (see documentation of compile_id_list() )
        possible_polygons, ids, zones_are_equal = self.compile_id_list(possible_polygons, polygons_in_list)

        # if all the polygons in this shortcut belong to the same zone return it
        if zones_are_equal:
            if not (return_distances or force_evaluation):
                return timezone_names[ids[0]]

        if exact_computation:
            routine = exact_routine
        else:
            routine = normal_routine

        min_distance = MAX_HAVERSINE_DISTANCE
        distances = empty(polygons_in_list, dtype=DTYPE_FORMAT_F_NUMPY)
        # [None for i in range(polygons_in_list)]

        if force_evaluation:
            for pointer, polygon_nr in enumerate(possible_polygons):
                distance = routine(polygon_nr)
                distances[pointer] = distance
                if distance < min_distance:
                    min_distance = distance
                    current_closest_id = ids[pointer]

        else:
            pointer = 0
            # stores which polygons have been checked yet
            already_checked = [False] * polygons_in_list  # initialize array with False
            while pointer < polygons_in_list:
github MrMinimal64 / timezonefinder / timezonefinder / helpers_numba.py View on Github external
def distance_to_polygon(lng_rad, lat_rad, nr_points, points):
    min_distance = MAX_HAVERSINE_DISTANCE

    for i in range(nr_points):
        min_distance = min(min_distance, haversine(lng_rad, lat_rad, radians(int2coord(points[0][i])),
                                                   radians(int2coord(points[1][i]))))
    return min_distance