Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushpatnaikgit committed Jun 14, 2021
1 parent 191438a commit 2bb54a3
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/coordinate_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@ struct CoordinateSystem
width::Int64
end

function lat_to_row(coordinate_system::CoordinateSystem, x)
top_left = coordinate_system.top_left.latitude
bottom_right = coordinate_system.bottom_right.latitude
height = coordinate_system.height
function lat_to_row(geometry::CoordinateSystem, x)
top_left = geometry.top_left.latitude
bottom_right = geometry.bottom_right.latitude
height = geometry.height
return ((x - top_left) * height / (bottom_right - top_left))
end

function long_to_column(coordinate_system::CoordinateSystem, x)
top_left = coordinate_system.top_left.longitude
bottom_right = coordinate_system.bottom_right.longitude
width = coordinate_system.width
function long_to_column(geometry::CoordinateSystem, x)
top_left = geometry.top_left.longitude
bottom_right = geometry.bottom_right.longitude
width = geometry.width
return ((x - top_left) * width/(bottom_right - top_left))
end

function row_to_lat(coordinate_system::CoordinateSystem, x)
top_left = coordinate_system.top_left.latitude
bottom_right = coordinate_system.bottom_right.latitude
height = coordinate_system.height
function row_to_lat(geometry::CoordinateSystem, x)
top_left = geometry.top_left.latitude
bottom_right = geometry.bottom_right.latitude
height = geometry.height
return ((bottom_right - top_left)/height * x + top_left)
end

function column_to_long(coordinate_system::CoordinateSystem, x)
top_left = coordinate_system.top_left.longitude
bottom_right = coordinate_system.bottom_right.longitude
width = coordinate_system.width
function column_to_long(geometry::CoordinateSystem, x)
top_left = geometry.top_left.longitude
bottom_right = geometry.bottom_right.longitude
width = geometry.width
return((bottom_right - top_left)/width * x + top_left)
end

function translate_coordinate_system(coordinate_system::CoordinateSystem,top_left::Coordinate,bottom_right::Coordinate)
top_left_row = lat_to_row(coordinate_system, top_left.latitude)
bottom_right_row = lat_to_row(coordinate_system, bottom_right.latitude)
bottom_right_col = long_to_column(coordinate_system,bottom_right.longitude)
top_left_col = long_to_column(coordinate_system, top_left.longitude)
function translate_geometry(geometry::CoordinateSystem,top_left::Coordinate,bottom_right::Coordinate)
top_left_row = lat_to_row(geometry, top_left.latitude)
bottom_right_row = lat_to_row(geometry, bottom_right.latitude)
bottom_right_col = long_to_column(geometry,bottom_right.longitude)
top_left_col = long_to_column(geometry, top_left.longitude)
height = round(top_left_col - bottom_right_col)
width = round(top_left_row - bottom_right_row)
return CoordinateSystem(top_left, bottom_right, height, width)
Expand Down

0 comments on commit 2bb54a3

Please sign in to comment.