def __call__( self, latlng: np.ndarray, calculate_clipping=False ) -> Union[np.ndarray, Tuple[np.ndarray, np.ndarray]]: assertMultipleVec2d(latlng) projected = self.preprojection(latlng) dist_c1 = euclideanDistSquared(projected, self.center1) dist_c2 = euclideanDistSquared(projected, self.center2) selection_c1 = dist_c1 < dist_c2 selection_c2 = dist_c1 >= dist_c2 del dist_c1, dist_c2 data_c1 = projected[:, selection_c1] data_c2 = projected[:, selection_c2] projected_c1 = self._single_forward(data_c1, self.center1, self.theta1, 1) projected_c2 = self._single_forward(data_c2, self.center2, self.theta2, -1) projected[:, selection_c1] = projected_c1 projected[:, selection_c2] = projected_c2 if not calculate_clipping: return projected clipping_c1 = projected_c1[0, :] > 0 clipping_c2 = projected_c2[0, :] < 0 clipping = np.full((latlng.shape[1]), False) clipping[selection_c1] = clipping_c1 clipping[selection_c2] = clipping_c2 return projected, clipping
def invert(self, xy: np.ndarray): assertMultipleVec2d(xy) selection_c1 = xy[0, :] < 0 selection_c2 = xy[0, :] >= 0 data_c1 = xy[:, selection_c1] data_c2 = xy[:, selection_c2] exp_c1 = self._single_backward(data_c1, self.center1, self.theta1, 1) exp_c2 = self._single_backward(data_c2, self.center2, self.theta2, -1) unprojected = np.zeros_like(xy) unprojected[:, selection_c1] = exp_c1 unprojected[:, selection_c2] = exp_c2 return self.preprojection.invert(unprojected)
def getZoomLevel(self, pixel_data: np.ndarray, pixel_per_unit: float) -> np.ndarray: assertMultipleVec2d(pixel_data) pixel_data = pixel_data.copy() # pixel_data = self.smoothing_function.invert(pixel_data) size_per_pixel_azimuth_units = np.exp( -np.abs(pixel_data[0, :]) ) / pixel_per_unit # exp in here is the problem. Should be 1/exp or similar size_per_pixel_latlng = 180.0 * size_per_pixel_azimuth_units * self.center_point_distance k = -np.log2(size_per_pixel_latlng) zoom = k + 2 return zoom
def invert(self, data: np.ndarray): assertMultipleVec2d(data) current_angle = data[1, :] scaled = np.log(np.abs(self.scale(current_angle))) data[0, :] -= scaled return data
def invert(self, xy: np.ndarray) -> np.ndarray: mathutils.assertMultipleVec2d(xy) return mathutils.assertMultipleVec2d( np.rad2deg(self._backward(xy) - self.offset))
def __call__(self, latlng: np.ndarray) -> np.ndarray: mathutils.assertMultipleVec2d(latlng) return mathutils.assertMultipleVec2d( self._forward(np.deg2rad(latlng) + self.offset))