-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Projection classes to encapsulate arguments #379
base: main
Are you sure you want to change the base?
Changes from 1 commit
0c969bb
16819cc
979d057
c1161a3
29e263d
129ae99
adef7ad
97c836b
a414f7e
c7ee1a2
db7aca6
825cd66
acaca7d
919102d
f5897a8
7abe416
45abd59
b9997c1
f92c7d1
4161f9e
968b2cd
a77fd13
d030593
cd38f61
4793155
0f24da2
a43d4c8
f39053a
f386b09
8995715
20693e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…r than use the Enum which will be removed once all projections are defined.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,6 +16,9 @@ | |||||
import attr | ||||||
|
||||||
|
||||||
UNDEFINED = "" | ||||||
|
||||||
|
||||||
class Supported(Enum): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in #356, what is the intended use case for this class? Sorry if I'm being thick 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not really needed anymore. I was mostly using it as a place holder for the GMT projection codes, and to keep track (for myself) what had and had not been implemented. |
||||||
|
||||||
""" | ||||||
|
@@ -65,7 +68,7 @@ class _Projection: | |||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_fmt: str = attr.ib(init=False, repr=False, default="{_code}") | ||||||
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value) | ||||||
_code: str = attr.ib(init=False, repr=False, default=UNDEFINED) | ||||||
|
||||||
def __str__(self): | ||||||
maxrjones marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
exclude = attr.fields(self.__class__)._fmt | ||||||
|
@@ -106,7 +109,7 @@ class _Azimuthal(_Projection): | |||||
repr=False, | ||||||
default="{_code}{central_longitude}/{central_latitude}/{horizon}/{width}{unit}", | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value) | ||||||
_code: str = attr.ib(init=False, repr=False, default=UNDEFINED) | ||||||
|
||||||
@horizon.validator | ||||||
def check_horizon(self, attribute, value): | ||||||
|
@@ -147,7 +150,7 @@ class _Cylindrical(_Projection): | |||||
repr=False, | ||||||
default="{_code}{central_longitude}/{central_latitude}/{wdith}{unit}", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good pickup 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix it. |
||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value) | ||||||
_code: str = attr.ib(init=False, repr=False, default=UNDEFINED) | ||||||
|
||||||
|
||||||
@attr.s(kw_only=True) | ||||||
|
@@ -210,9 +213,7 @@ class LambertAzimuthalEqualArea(_Azimuthal): | |||||
""" | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.LAMBERT_AZIMUTH_EQUAL_AREA.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="A") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -239,9 +240,7 @@ class AzimuthalEquidistant(_Azimuthal): | |||||
horizon: float = attr.ib(default=180, kw_only=True) | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.AZIMUTHAL_EQUIDISTANT.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="E") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -268,9 +267,7 @@ class AzimuthalGnomic(_Azimuthal): | |||||
horizon: float = attr.ib(default=60, kw_only=True) | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.AZIMUTHAL_GNOMIC.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="F") | ||||||
|
||||||
@horizon.validator | ||||||
def check_horizon(self, attribute, value): | ||||||
|
@@ -305,9 +302,7 @@ class AzimuthalOrthographic(_Azimuthal): | |||||
horizon: float = attr.ib(default=90) | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.AZIMUTHAL_ORTHOGRAPHIC.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="G") | ||||||
|
||||||
@horizon.validator | ||||||
def check_horizon(self, attribute, value): | ||||||
|
@@ -366,9 +361,7 @@ class GeneralPerspective(_Projection): | |||||
repr=False, | ||||||
default="{_code}{central_longitude}/{central_latitude}/{altitude}/{azimuth}/{tilt}/{twist}/{viewport_width}/{viewport_height}/{width}{unit}", | ||||||
) | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.GENERAL_PERSPECTIVE.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="G") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -395,9 +388,7 @@ class GeneralSterographic(_Azimuthal): | |||||
horizon: float = attr.ib(default=90, kw_only=True) | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.GENERAL_STEREOGRAPHIC.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="S") | ||||||
|
||||||
@horizon.validator | ||||||
def check_horizon(self, attribute, value): | ||||||
|
@@ -432,9 +423,7 @@ class AlbersConicEqualArea(_Conic): | |||||
""" | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.ALBERS_CONIC_EQUAL_AREA.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="B") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True, kw_only=True) | ||||||
|
@@ -461,7 +450,7 @@ class EquidistantConic(_Conic): | |||||
""" | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib(init=False, repr=False, default=Supported.EQUIDISTANT_CONIC) | ||||||
_code: str = attr.ib(init=False, repr=False, default="JD") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -484,9 +473,7 @@ class CassiniCylindrical(_Cylindrical): | |||||
""" | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.CASSINI_CYLINDRICAL.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="C") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -512,9 +499,7 @@ class MercatorCylindrical(_Cylindrical): | |||||
central_latitude: float = attr.ib(default=0, kw_only=True) | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.MERCATOR_CYLINDRICAL.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="M") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -540,9 +525,7 @@ class CylindricalStereographic(_Cylindrical): | |||||
central_latitude: float = attr.ib(default=0, kw_only=True) | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.CYLINDRICAL_STEROGRAPHIC.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="JCyl_stere/") | ||||||
|
||||||
|
||||||
@attr.s(frozen=True) | ||||||
|
@@ -565,6 +548,4 @@ class CylindricalEqualArea(_Cylindrical): | |||||
""" | ||||||
|
||||||
# private; we don't want the user to care or know about | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
No need to repeat the same comment everywhere. In fact, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair comment. I'll remove them. |
||||||
_code: str = attr.ib( | ||||||
init=False, repr=False, default=Supported.CYLINDRICAL_EQUAL_AREA.value | ||||||
) | ||||||
_code: str = attr.ib(init=False, repr=False, default="Y") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attr
is a good choice for this 👍