Skip to content

Commit

Permalink
feat(dsl): define nwu_to_utm
Browse files Browse the repository at this point in the history
  • Loading branch information
doudou committed Jan 12, 2024
1 parent 60ffc03 commit 38a625d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/syskit/log/dsl/maps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,35 @@ def define_local_origin(nwu_x, nwu_y, utm_zone)
# (e.g. GSL::Vector) or scalars
# @return [[(Float,#each)]] the latitude and longitude coordinates, either as
# vectors (one for each) or scalars, depending on the type of arguments
def nwu_to_latlon(x, y, reference_latitude:, local_origin: @local_origin)
def nwu_to_utm(x, y, local_origin: @local_origin)
if x.kind_of?(::Daru::Vector)
x = x.to_gsl
y = y.to_gsl
end

northing = x + local_origin.nwu_x
easting = 1_000_000 - y - local_origin.nwu_y
[easting, northing]
end

# Convert Rock's NWU coordinates into latitude and longitude
#
# @param [Float,#each] easting the easting coordinates, either as vectors
# (e.g. GSL::Vector) or scalars
# @param [Float,#each] northing the northing coordinates, either as vectors
# (e.g. GSL::Vector) or scalars
# @return [[(Float,#each)]] the latitude and longitude coordinates, either as
# vectors (one for each) or scalars, depending on the type of arguments
def nwu_to_latlon(x, y, reference_latitude: nil, local_origin: @local_origin)
easting, northing = nwu_to_utm(x, y, local_origin: local_origin)

zone = local_origin.utm_zone.to_s
if reference_latitude
zone_letter =
GeoUtm::UTMZones.calc_utm_default_letter(reference_latitude)
zone += zone_letter
end

zone_letter = GeoUtm::UTMZones.calc_utm_default_letter(reference_latitude)
zone = "#{local_origin.utm_zone}#{zone_letter}"
utm_to_latlon(easting, northing, zone)
end

Expand Down

0 comments on commit 38a625d

Please sign in to comment.