Skip to content
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

BUG: Mercator A defined only for lat_0 = 0 #1095

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Latest
- ENH: Added authority, accuracy, and allow_ballpark kwargs to :class:`pyproj.transformer.TransformerGroup` (pull #1076)
- CLN: Remove deprecated `skip_equivalent` kwarg from transformers and `errcheck` kwarg from :meth:`pyproj.crs.CRS.from_cf` (pull #1077)
- REF: use regex to process PROJ strings in :meth:`pyproj.crs.CRS.to_dict()`(pull #1086)
- BUG: :class:`pyproj.crs.coordinate_operation.MercatorAConversion` defined only for lat_0 = 0 (issue #1089)

3.3.1
-------
Expand Down
10 changes: 8 additions & 2 deletions pyproj/crs/coordinate_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,10 @@ def __new__(
"""
Parameters
----------
longitude_natural_origin: float, default=0.0
Latitude of natural origin (lat_0).
latitude_natural_origin: float, default=0.0
Latitude of natural origin (lat_0). Must be 0 by `this conversion's
definition
<https://epsg.org/coord-operation-method_9804/Mercator-variant-A.html>`_.
longitude_natural_origin: float, default=0.0
Longitude of natural origin (lon_0).
false_easting: float, default=0.0
Expand All @@ -699,6 +701,10 @@ def __new__(
Scale factor at natural origin (k or k_0).

"""
if latitude_natural_origin != 0:
raise CRSError(
"This conversion is defined for only latitude_natural_origin = 0."
)
merc_json = {
"$schema": "https://proj.org/schemas/v0.2/projjson.schema.json",
"type": "Conversion",
Expand Down
4 changes: 2 additions & 2 deletions test/crs/test_crs_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ def test_lambert_cylindrical_equal_area():


def test_mercator_a():
crs = ProjectedCRS(conversion=MercatorAConversion(1, 2, 3, 4))
crs = ProjectedCRS(conversion=MercatorAConversion(0, 2, 3, 4))
expected_cf = {
"semi_major_axis": 6378137.0,
"semi_minor_axis": crs.ellipsoid.semi_minor_metre,
Expand All @@ -1275,7 +1275,7 @@ def test_mercator_a():
"prime_meridian_name": "Greenwich",
"horizontal_datum_name": "World Geodetic System 1984",
"grid_mapping_name": "mercator",
"standard_parallel": 1.0,
"standard_parallel": 0.0,
"longitude_of_projection_origin": 2.0,
"false_easting": 3.0,
"false_northing": 4.0,
Expand Down
9 changes: 7 additions & 2 deletions test/crs/test_crs_coordinate_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def test_mercator_a_operation__defaults():

def test_mercator_a_operation():
aeaop = MercatorAConversion(
latitude_natural_origin=1,
latitude_natural_origin=0,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
Expand All @@ -323,14 +323,19 @@ def test_mercator_a_operation():
assert aeaop.name == "unknown"
assert aeaop.method_name == "Mercator (variant A)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 1.0,
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Scale factor at natural origin": 0.5,
}


def test_mercator_a_operation__invalid_lat0():
with pytest.raises(CRSError):
MercatorAConversion(latitude_natural_origin=1)


def test_mercator_b_operation__defaults():
lceaop = MercatorBConversion()
assert lceaop.name == "unknown"
Expand Down