How to use the timezonefinder.global_settings.DTYPE_FORMAT_F_NUMPY 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 / test / test_helpers.py View on Github external
[coord2int(x) for x in y_coords],
        ]
        trans_points = [
            [None for x in x_coords],
            [None for x in y_coords],
        ]

        x_rad = radians(1.0)
        y_rad = radians(0.0)

        # print(km2deg(haversine(x_rad, y_rad, p1_lng_rad, p1_lat_rad)))
        assert km2deg(haversine(x_rad, y_rad, p1_lng_rad, p1_lat_rad)) == 1

        distance_exact = distance_to_polygon_exact(x_rad, y_rad, len(x_coords),
                                                   np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY),
                                                   np.array(trans_points, dtype=DTYPE_FORMAT_F_NUMPY))
        # print(km2deg(distance_exact))
        assert km2deg(distance_exact) == 0.5
        # print('=====')
        distance = distance_to_polygon(x_rad, y_rad, len(x_coords), np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY))
        # print(km2deg(distance))
        assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
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:
                # only check a polygon when its id is not the closest a the moment and it has not been checked already!
github MrMinimal64 / timezonefinder / timezonefinder / timezonefinder.py View on Github external
def exact_routine(polygon_nr):
            coords = self.coords_of(polygon_nr)
            nr_points = len(coords[0])
            empty_array = empty([2, nr_points], dtype=DTYPE_FORMAT_F_NUMPY)
            return distance_to_polygon_exact(lng, lat, nr_points, coords, empty_array)