-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
2,627 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
indent = 2 | ||
margin = 120 | ||
always_for_in = true | ||
always_use_return = false | ||
whitespace_typedefs = false | ||
whitespace_in_kwargs = false | ||
whitespace_ops_in_indices = true | ||
remove_extra_newlines = true | ||
trailing_comma = false | ||
normalize_line_endings = "unix" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: FormatPR | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install JuliaFormatter and format | ||
run: | | ||
julia -e 'import Pkg; Pkg.add("JuliaFormatter")' | ||
julia -e 'using JuliaFormatter; format(".")' | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: ":robot: Format .jl files" | ||
title: '[AUTO] JuliaFormatter.jl run' | ||
branch: auto-juliaformatter-pr | ||
delete-branch: true | ||
labels: formatting, automated pr, no changelog | ||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
*.jl.*.cov | ||
*.jl.cov | ||
*.jl.mem | ||
/Manifest.toml | ||
.DS_Store | ||
Manifest.toml | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,9 @@ uuid = "b46f11dc-f210-4604-bfba-323c1ec968cb" | |
authors = ["Elias Carvalho <[email protected]> and contributors"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" | ||
|
||
[compat] | ||
Unitful = "1.19" | ||
julia = "1.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Cartography | ||
# Cartography.jl | ||
|
||
[![Build Status](https://github.com/JuliaEarth/Cartography.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaEarth/Cartography.jl/actions/workflows/CI.yml?query=branch%3Amain) | ||
[![Coverage](https://codecov.io/gh/JuliaEarth/Cartography.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaEarth/Cartography.jl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
# ------------------------------------------------------------------ | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ------------------------------------------------------------------ | ||
|
||
module Cartography | ||
|
||
# Write your package code here. | ||
using Unitful | ||
using Unitful: numtype | ||
|
||
include("utils.jl") | ||
include("ioutils.jl") | ||
include("ellipsoids.jl") | ||
include("datums.jl") | ||
include("crs.jl") | ||
include("codes.jl") | ||
|
||
export | ||
# revolution ellipsoids | ||
RevolutionEllipsoid, | ||
majoraxis, | ||
minoraxis, | ||
eccentricity, | ||
eccentricity², | ||
flattening, | ||
flattening⁻¹, | ||
|
||
# datums | ||
Datum, | ||
NoDatum, | ||
WGS84, | ||
WIII, | ||
ellipsoid, | ||
latitudeₒ, | ||
longitudeₒ, | ||
altitudeₒ, | ||
|
||
# coordinates | ||
CRS, | ||
Cartesian, | ||
Polar, | ||
Cylindrical, | ||
Spherical, | ||
GeodeticLatLon, | ||
GeocentricLatLon, | ||
AuthalicLatLon, | ||
LatLon, | ||
Mercator, | ||
WebMercator, | ||
PlateCarree, | ||
Lambert, | ||
Behrmann, | ||
GallPeters, | ||
WinkelTripel, | ||
Robinson, | ||
OrthoNorth, | ||
OrthoSouth, | ||
datum, | ||
|
||
# codes | ||
EPSG, | ||
ESRI | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# ------------------------------------------------------------------ | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ------------------------------------------------------------------ | ||
|
||
""" | ||
EPSG{code} | ||
EPSG dataset `code` between 1024 and 32767. | ||
Codes can be searched at [epsg.io](https://epsg.io). | ||
See [EPSG Geodetic Parameter Dataset](https://en.wikipedia.org/wiki/EPSG_Geodetic_Parameter_Dataset) | ||
""" | ||
abstract type EPSG{Code} end | ||
|
||
""" | ||
ESRI{code} | ||
ESRI dataset `code`. Codes can be searched at [epsg.io](https://epsg.io). | ||
""" | ||
abstract type ESRI{Code} end | ||
|
||
""" | ||
crs(::Type{EPSG{code}}) | ||
crs(::Type{ESRI{code}}) | ||
Returns a CRS type that has the EPSG/ESRI `code`. | ||
""" | ||
function crs end | ||
|
||
# ---------------- | ||
# IMPLEMENTATIONS | ||
# ---------------- | ||
|
||
crs(::Type{EPSG{3395}}) = Mercator{WGS84} | ||
crs(::Type{EPSG{3857}}) = WebMercator{WGS84} | ||
crs(::Type{EPSG{4326}}) = LatLon{WGS84} | ||
crs(::Type{EPSG{32662}}) = PlateCarree{WGS84} | ||
crs(::Type{ESRI{54017}}) = Behrmann{WGS84} | ||
crs(::Type{ESRI{54030}}) = Robinson{WGS84} | ||
crs(::Type{ESRI{54034}}) = Lambert{WGS84} | ||
crs(::Type{ESRI{54042}}) = WinkelTripel{WGS84} | ||
crs(::Type{ESRI{102035}}) = Orthographic{90.0u"°",0.0u"°",true,WGS84} | ||
crs(::Type{ESRI{102037}}) = Orthographic{-90.0u"°",0.0u"°",true,WGS84} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# ------------------------------------------------------------------ | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ------------------------------------------------------------------ | ||
|
||
""" | ||
CRS{Datum} | ||
Coordinate Reference System (CRS) with a given `Datum` | ||
""" | ||
abstract type CRS{Datum} end | ||
|
||
Base.isapprox(coords₁::C, coords₂::C; kwargs...) where {C<:CRS} = | ||
all(ntuple(i -> isapprox(getfield(coords₁, i), getfield(coords₂, i); kwargs...), nfields(coords₁))) | ||
|
||
# ------ | ||
# DATUM | ||
# ------ | ||
|
||
""" | ||
datum(coords) | ||
Returns the datum of the coordinates `coords`. | ||
""" | ||
datum(coords::CRS) = datum(typeof(coords)) | ||
datum(::Type{<:CRS{Datum}}) where {Datum} = Datum | ||
|
||
""" | ||
ellipsoid(coords) | ||
Returns the ellipsoid of the coordinates `coords`. | ||
""" | ||
ellipsoid(coords::CRS) = ellipsoid(typeof(coords)) | ||
ellipsoid(T::Type{<:CRS}) = ellipsoid(datum(T)) | ||
|
||
""" | ||
latitudeₒ(coords) | ||
Returns the latitude origin of the coordinates `coords`. | ||
""" | ||
latitudeₒ(coords::CRS) = latitudeₒ(typeof(coords)) | ||
latitudeₒ(T::Type{<:CRS}) = latitudeₒ(datum(T)) | ||
|
||
""" | ||
longitudeₒ(coords) | ||
Returns the longitude origin of the coordinates `coords`. | ||
""" | ||
longitudeₒ(coords::CRS) = longitudeₒ(typeof(coords)) | ||
longitudeₒ(T::Type{<:CRS}) = longitudeₒ(datum(T)) | ||
|
||
""" | ||
altitudeₒ(coords) | ||
Returns the altitude origin of the coordinates `coords`. | ||
""" | ||
altitudeₒ(coords::CRS) = altitudeₒ(typeof(coords)) | ||
altitudeₒ(T::Type{<:CRS}) = altitudeₒ(datum(T)) | ||
|
||
# ----------- | ||
# IO METHODS | ||
# ----------- | ||
|
||
function Base.summary(io::IO, coords::CRS) | ||
name = prettyname(coords) | ||
Datum = datum(coords) | ||
print(io, "$name{$Datum} coordinates") | ||
end | ||
|
||
function Base.show(io::IO, coords::CRS) | ||
name = prettyname(coords) | ||
Datum = datum(coords) | ||
print(io, "$name{$Datum}(") | ||
printfields(io, coords, compact=true) | ||
print(io, ")") | ||
end | ||
|
||
function Base.show(io::IO, ::MIME"text/plain", coords::CRS) | ||
summary(io, coords) | ||
printfields(io, coords) | ||
end | ||
|
||
# ---------------- | ||
# IMPLEMENTATIONS | ||
# ---------------- | ||
|
||
const Len{T} = Quantity{T,u"𝐋"} | ||
const Met{T} = Quantity{T,u"𝐋",typeof(u"m")} | ||
const Rad{T} = Quantity{T,NoDims,typeof(u"rad")} | ||
const Deg{T} = Quantity{T,NoDims,typeof(u"°")} | ||
|
||
include("crs/basic.jl") | ||
include("crs/latlon.jl") | ||
include("crs/mercator.jl") | ||
include("crs/webmercator.jl") | ||
include("crs/eqdistcylindrical.jl") | ||
include("crs/eqareacylindrical.jl") | ||
include("crs/winkeltripel.jl") | ||
include("crs/robinson.jl") | ||
include("crs/orthographic.jl") |
Oops, something went wrong.