Skip to content

Commit 54fc313

Browse files
committed
Fix the code
1 parent f335947 commit 54fc313

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

docs/src/experiments/regridding/regridding.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ grid2 = rand(FullGaussianGrid, 4 + 100)
9393
faces1 = SpeedyWeatherGeoMakieExt.get_faces(grid1)
9494
faces2 = SpeedyWeatherGeoMakieExt.get_faces(grid2)
9595

96-
polys1 = GI.Polygon.(GI.LinearRing.(eachcol(faces1))) .|> GO.fix
97-
polys2 = GI.Polygon.(GI.LinearRing.(eachcol(faces2))) .|> GO.fix
96+
polys1 = GI.Polygon.(GI.LinearRing.(eachcol(faces1))) .|> GO.CutAtAntimeridianAndPoles() .|> GO.fix
97+
polys2 = GI.Polygon.(GI.LinearRing.(eachcol(faces2))) .|> GO.CutAtAntimeridianAndPoles() .|> GO.fix
9898

9999
A = @time area_of_intersection_operator(polys1, polys2)
100100

src/transformations/correction/cut_at_antimeridian.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module _AntimeridianHelpers
5454

5555
import GeoInterface as GI
5656
import ..GeometryOps as GO
57+
using ..GeometryOps: CutAtAntimeridianAndPoles
5758

5859
# Custom cross product for 3D tuples
5960
function _cross(a::Tuple{Float64,Float64,Float64}, b::Tuple{Float64,Float64,Float64})
@@ -65,7 +66,8 @@ function _cross(a::Tuple{Float64,Float64,Float64}, b::Tuple{Float64,Float64,Floa
6566
end
6667

6768
# Convert spherical degrees to cartesian coordinates
68-
function spherical_degrees_to_cartesian(point::Tuple{Float64,Float64})::Tuple{Float64,Float64,Float64}
69+
function spherical_degrees_to_cartesian(c::CutAtAntimeridianAndPoles, point::Tuple{Float64,Float64})::Tuple{Float64,Float64,Float64}
70+
# TODO: handle non-degree domains somehow
6971
lon, lat = point
7072
slon, clon = sincosd(lon)
7173
slat, clat = sincosd(lat)
@@ -79,14 +81,14 @@ end
7981
# Calculate crossing latitude using great circle method
8082
function crossing_latitude_great_circle(c::CutAtAntimeridianAndPoles, start::Tuple{Float64,Float64}, endpoint::Tuple{Float64,Float64})::Float64
8183
# Convert points to 3D vectors
82-
p1 = spherical_degrees_to_cartesian(start)
83-
p2 = spherical_degrees_to_cartesian(endpoint)
84+
p1 = spherical_degrees_to_cartesian(c, start)
85+
p2 = spherical_degrees_to_cartesian(c, endpoint)
8486

8587
# Cross product defines plane through both points
8688
n1 = _cross(p1, p2)
8789

8890
# Unit vector that defines the meridian plane
89-
n2 = spherical_degrees_to_cartesian(c.left, 0.0)
91+
n2 = spherical_degrees_to_cartesian(c, (c.left, 0.0))
9092

9193
# Intersection of planes defined by cross product
9294
intersection = _cross(n1, n2)
@@ -294,7 +296,7 @@ function cut_at_antimeridian(
294296
end
295297

296298
# Build final polygons
297-
result_polygons = build_polygons(segments)
299+
result_polygons = build_polygons(c, segments)
298300

299301
# Add holes to appropriate polygons
300302
for hole in holes

0 commit comments

Comments
 (0)