Skip to content

Commit

Permalink
Halve the number of calls to cosd, sind in spherical cellarea (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 authored Oct 11, 2024
1 parent 3489062 commit f5ec851
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ext/RastersProjExt/cellarea.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ end

_lonlat_to_sphericalpoint(args) = _lonlat_to_sphericalpoint(args...)
function _lonlat_to_sphericalpoint(lon, lat)
x = cosd(lat) * cosd(lon)
y = cosd(lat) * sind(lon)
z = sind(lat)
lonsin, loncos = sincosd(lon)
latsin, latcos = sincosd(lat)
x = latcos * loncos
y = latcos * lonsin
z = latsin
return SphericalPoint(x,y,z)
end

Expand Down Expand Up @@ -182,4 +184,4 @@ function axis_is_degrees(crs::Proj.CRS, axis_index::Int; context::Ptr{Proj.PJ_CO
# in which case we should technically return true.
# We'd also have to return the conversion factor in this case, and maybe the category (radians or degrees)...
return isequal(unit_str, "degree")
end
end

0 comments on commit f5ec851

Please sign in to comment.