moos-map 1.1.2__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {moos_map-1.1.2/src/moos_map.egg-info → moos_map-1.2.0}/PKG-INFO +11 -4
  2. {moos_map-1.1.2 → moos_map-1.2.0}/README.md +10 -3
  3. {moos_map-1.1.2 → moos_map-1.2.0}/pyproject.toml +1 -1
  4. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/__init__.py +1 -1
  5. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/geometry.py +0 -11
  6. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/moos_compat.py +55 -12
  7. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/service.py +1 -16
  8. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/verification.py +8 -22
  9. {moos_map-1.1.2 → moos_map-1.2.0/src/moos_map.egg-info}/PKG-INFO +11 -4
  10. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map.egg-info/SOURCES.txt +1 -0
  11. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_geometry.py +0 -6
  12. moos_map-1.2.0/tests/test_moos_compat.py +105 -0
  13. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_service.py +30 -7
  14. moos_map-1.2.0/tests/test_verification.py +76 -0
  15. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_web.py +7 -4
  16. moos_map-1.1.2/tests/test_moos_compat.py +0 -34
  17. {moos_map-1.1.2 → moos_map-1.2.0}/LICENSE +0 -0
  18. {moos_map-1.1.2 → moos_map-1.2.0}/setup.cfg +0 -0
  19. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/__main__.py +0 -0
  20. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/acquisition.py +0 -0
  21. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/cache.py +0 -0
  22. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/cli.py +0 -0
  23. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/errors.py +0 -0
  24. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/geocoding.py +0 -0
  25. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/models.py +0 -0
  26. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/moos_files.py +0 -0
  27. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/raster.py +0 -0
  28. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/sources.py +0 -0
  29. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/static/app.js +0 -0
  30. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/static/index.html +0 -0
  31. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/static/styles.css +0 -0
  32. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map/web.py +0 -0
  33. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map.egg-info/dependency_links.txt +0 -0
  34. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map.egg-info/entry_points.txt +0 -0
  35. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map.egg-info/requires.txt +0 -0
  36. {moos_map-1.1.2 → moos_map-1.2.0}/src/moos_map.egg-info/top_level.txt +0 -0
  37. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_acquisition.py +0 -0
  38. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_cli.py +0 -0
  39. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_geocoding.py +0 -0
  40. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_info.py +0 -0
  41. {moos_map-1.1.2 → moos_map-1.2.0}/tests/test_sources.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moos-map
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: Build exact-crop TIFF background maps for MOOS-IvP
5
5
  License-Expression: GPL-3.0-only
6
6
  Project-URL: Repository, https://github.com/cbenjamin23/moos-map
@@ -23,6 +23,12 @@ Build cropped TIFF background maps for MOOS-IvP through a local browser UI or
23
23
  the `moos-map` command. Both interfaces use the same map sources, crop logic,
24
24
  cache, and MOOS compatibility checks.
25
25
 
26
+ MOOS Map targets current upstream MOOS-IvP with the default PROJ-backed
27
+ `CMOOSGeodesy`. Its datum-fixed UTM zone and hemisphere support maps that cross
28
+ zone boundaries or the equator. Legacy MOOS-IvP builds and current builds
29
+ configured with `--with-proj=off` are not supported for maps that cross a UTM
30
+ zone boundary or the equator.
31
+
26
32
  [PyPI Project](https://pypi.org/project/moos-map/)
27
33
 
28
34
  ## Install
@@ -175,9 +181,10 @@ those foundations with:
175
181
  - **Complete Map Bundles:** Places matching `.tif`, `.info`, and optional
176
182
  copy-ready `.moos` files together in a named output directory.
177
183
 
178
- - **MOOS Geodesy Validation:** Detects UTM-zone crossings, incompatible
179
- map/origin zones, invalid geographic bounds, and placement conditions that
180
- current MOOS geodesy cannot represent reliably.
184
+ - **Current MOOS Geodesy Compatibility:** Supports datum-fixed PROJ maps that
185
+ cross UTM boundaries or the equator and calculates pMarineViewer placement
186
+ estimates even when the map center and mission origin select different
187
+ natural zones.
181
188
 
182
189
  - **Shared CLI and GUI Core:** Uses the same source registry, crop calculations,
183
190
  cache, output writers, and validation from both interfaces, rather than
@@ -4,6 +4,12 @@ Build cropped TIFF background maps for MOOS-IvP through a local browser UI or
4
4
  the `moos-map` command. Both interfaces use the same map sources, crop logic,
5
5
  cache, and MOOS compatibility checks.
6
6
 
7
+ MOOS Map targets current upstream MOOS-IvP with the default PROJ-backed
8
+ `CMOOSGeodesy`. Its datum-fixed UTM zone and hemisphere support maps that cross
9
+ zone boundaries or the equator. Legacy MOOS-IvP builds and current builds
10
+ configured with `--with-proj=off` are not supported for maps that cross a UTM
11
+ zone boundary or the equator.
12
+
7
13
  [PyPI Project](https://pypi.org/project/moos-map/)
8
14
 
9
15
  ## Install
@@ -156,9 +162,10 @@ those foundations with:
156
162
  - **Complete Map Bundles:** Places matching `.tif`, `.info`, and optional
157
163
  copy-ready `.moos` files together in a named output directory.
158
164
 
159
- - **MOOS Geodesy Validation:** Detects UTM-zone crossings, incompatible
160
- map/origin zones, invalid geographic bounds, and placement conditions that
161
- current MOOS geodesy cannot represent reliably.
165
+ - **Current MOOS Geodesy Compatibility:** Supports datum-fixed PROJ maps that
166
+ cross UTM boundaries or the equator and calculates pMarineViewer placement
167
+ estimates even when the map center and mission origin select different
168
+ natural zones.
162
169
 
163
170
  - **Shared CLI and GUI Core:** Uses the same source registry, crop calculations,
164
171
  cache, output writers, and validation from both interfaces, rather than
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "moos-map"
7
- version = "1.1.2"
7
+ version = "1.2.0"
8
8
  description = "Build exact-crop TIFF background maps for MOOS-IvP"
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-only"
@@ -1,3 +1,3 @@
1
1
  """MOOS-IvP background map builder."""
2
2
 
3
- __version__ = "1.1.2"
3
+ __version__ = "1.2.0"
@@ -191,14 +191,3 @@ def utm_zone_number(longitude: float, latitude: float | None = None) -> int:
191
191
  if 33 <= longitude < 42:
192
192
  return 37
193
193
  return zone
194
-
195
-
196
- def crosses_utm_zone(bounds: Bounds) -> bool:
197
- epsilon = 1e-12
198
- corners = {
199
- utm_zone_number(bounds.west, bounds.south),
200
- utm_zone_number(bounds.west, bounds.north),
201
- utm_zone_number(bounds.east - epsilon, bounds.south),
202
- utm_zone_number(bounds.east - epsilon, bounds.north),
203
- }
204
- return len(corners) != 1
@@ -23,18 +23,31 @@ class PMarineViewerEstimate:
23
23
  requested_area_max_position_error_m: float
24
24
 
25
25
 
26
- def moos_utm(latitude: float, longitude: float) -> tuple[float, float]:
27
- """Replicate the WGS-84 LLtoUTM calculation in CMOOSGeodesy.
28
-
29
- Returns (northing, easting). CMOOSGeodesy independently chooses a zone
30
- for every point, which is why moos-map rejects zone-crossing rasters.
26
+ def moos_utm(
27
+ latitude: float,
28
+ longitude: float,
29
+ *,
30
+ zone: int | None = None,
31
+ southern_hemisphere: bool | None = None,
32
+ ) -> tuple[float, float]:
33
+ """Replicate the WGS-84 UTM calculation used by CMOOSGeodesy.
34
+
35
+ Returns ``(northing, easting)``. Current PROJ-backed CMOOSGeodesy selects
36
+ a UTM zone and hemisphere when the datum is initialized and retains that
37
+ projection for subsequent points. Supplying ``zone`` and
38
+ ``southern_hemisphere`` models that fixed projection; omitting either
39
+ selects the point's natural value for that part of the projection.
31
40
  """
32
41
 
33
42
  long_temp = (longitude + 180.0) % 360.0 - 180.0
34
43
  latitude_radians = math.radians(latitude)
35
44
  longitude_radians = math.radians(long_temp)
36
- zone = utm_zone_number(long_temp, latitude)
37
- central_longitude = (zone - 1) * 6 - 180 + 3
45
+ projection_zone = (
46
+ utm_zone_number(long_temp, latitude) if zone is None else zone
47
+ )
48
+ if not 1 <= projection_zone <= 60:
49
+ raise ValueError("UTM zone must be between 1 and 60")
50
+ central_longitude = (projection_zone - 1) * 6 - 180 + 3
38
51
  central_longitude_radians = math.radians(central_longitude)
39
52
 
40
53
  eccentricity_squared = MOOS_WGS84_ECCENTRICITY_SQUARED
@@ -92,7 +105,10 @@ def moos_utm(latitude: float, longitude: float) -> tuple[float, float]:
92
105
  / 720
93
106
  )
94
107
  )
95
- if latitude < 0:
108
+ use_southern_hemisphere = (
109
+ latitude < 0 if southern_hemisphere is None else southern_hemisphere
110
+ )
111
+ if use_southern_hemisphere:
96
112
  northing += 10_000_000.0
97
113
  return northing, easting
98
114
 
@@ -109,8 +125,25 @@ def estimate_pmarineviewer_placement(
109
125
  if samples_per_axis < 1:
110
126
  raise ValueError("samples_per_axis must be at least one")
111
127
 
112
- northwest_northing, northwest_easting = moos_utm(bounds.north, bounds.west)
113
- southeast_northing, southeast_easting = moos_utm(bounds.south, bounds.east)
128
+ map_center_latitude = (bounds.north + bounds.south) / 2.0
129
+ map_center_longitude = (bounds.west + bounds.east) / 2.0
130
+ map_zone = utm_zone_number(map_center_longitude, map_center_latitude)
131
+ map_southern_hemisphere = map_center_latitude < 0
132
+ origin_zone = utm_zone_number(origin.longitude, origin.latitude)
133
+ origin_southern_hemisphere = origin.latitude < 0
134
+
135
+ northwest_northing, northwest_easting = moos_utm(
136
+ bounds.north,
137
+ bounds.west,
138
+ zone=map_zone,
139
+ southern_hemisphere=map_southern_hemisphere,
140
+ )
141
+ southeast_northing, southeast_easting = moos_utm(
142
+ bounds.south,
143
+ bounds.east,
144
+ zone=map_zone,
145
+ southern_hemisphere=map_southern_hemisphere,
146
+ )
114
147
  width = abs(northwest_easting - southeast_easting)
115
148
  height = abs(northwest_northing - southeast_northing)
116
149
 
@@ -119,7 +152,12 @@ def estimate_pmarineviewer_placement(
119
152
  center_x = (0.5 - origin_x_fraction) * width
120
153
  center_y = (0.5 - origin_y_fraction) * height
121
154
 
122
- origin_northing, origin_easting = moos_utm(origin.latitude, origin.longitude)
155
+ origin_northing, origin_easting = moos_utm(
156
+ origin.latitude,
157
+ origin.longitude,
158
+ zone=origin_zone,
159
+ southern_hemisphere=origin_southern_hemisphere,
160
+ )
123
161
  image_north_y = latitude_to_tile_y(bounds.north, 0)
124
162
  image_south_y = latitude_to_tile_y(bounds.south, 0)
125
163
 
@@ -140,7 +178,12 @@ def estimate_pmarineviewer_placement(
140
178
  )
141
179
  image_u = (longitude - bounds.west) / (bounds.east - bounds.west)
142
180
  displayed_x = (image_u - origin_x_fraction) * width
143
- northing, easting = moos_utm(latitude, longitude)
181
+ northing, easting = moos_utm(
182
+ latitude,
183
+ longitude,
184
+ zone=origin_zone,
185
+ southern_hemisphere=origin_southern_hemisphere,
186
+ )
144
187
  true_x = easting - origin_easting
145
188
  true_y = northing - origin_northing
146
189
  maximum = max(
@@ -17,12 +17,10 @@ from .errors import SourcePolicyError, ValidationError
17
17
  from .geometry import (
18
18
  approximate_ground_size,
19
19
  bounds_for_tile_range,
20
- crosses_utm_zone,
21
20
  estimate_vertical_mapping_error_for_bounds,
22
21
  meters_per_pixel,
23
22
  pixel_window_for_bounds,
24
23
  tile_range_for_bounds,
25
- utm_zone_number,
26
24
  )
27
25
  from .models import BuildResult, MapPlan, MapRequest
28
26
  from .moos_compat import estimate_pmarineviewer_placement
@@ -105,10 +103,6 @@ def plan_map(
105
103
  )
106
104
  if request.bounds.south < -80 or request.bounds.north > 84:
107
105
  raise ValidationError("MOOS UTM map placement is limited to 80°S through 84°N")
108
- if crosses_utm_zone(request.bounds):
109
- raise ValidationError(
110
- "Requested bounds cross a UTM zone boundary; choose a smaller region"
111
- )
112
106
  if not source.min_zoom <= request.zoom <= source.max_zoom:
113
107
  raise ValidationError(
114
108
  f"Source '{source.id}' supports zoom {source.min_zoom} through "
@@ -117,21 +111,12 @@ def plan_map(
117
111
  tiles = tile_range_for_bounds(request.bounds, request.zoom)
118
112
  download_bounds = bounds_for_tile_range(tiles)
119
113
  actual_bounds = request.bounds
120
- map_center_latitude = (actual_bounds.north + actual_bounds.south) / 2.0
121
- map_center_longitude = (actual_bounds.east + actual_bounds.west) / 2.0
122
- map_zone = utm_zone_number(map_center_longitude, map_center_latitude)
123
- origin_zone = utm_zone_number(request.origin.longitude, request.origin.latitude)
124
- if map_zone != origin_zone:
125
- raise ValidationError(
126
- f"Mission origin is in UTM zone {origin_zone}, but the TIFF is in zone "
127
- f"{map_zone}; current MOOS geodesy cannot place this reliably"
128
- )
129
114
  requested_width, requested_height = approximate_ground_size(request.bounds)
130
115
  actual_width, actual_height = requested_width, requested_height
131
116
  crop = pixel_window_for_bounds(request.bounds, tiles, source.tile_size)
132
117
  pixel_width = crop.output_width
133
118
  pixel_height = crop.output_height
134
- center_latitude = map_center_latitude
119
+ center_latitude = (actual_bounds.north + actual_bounds.south) / 2.0
135
120
 
136
121
  warnings: list[str] = []
137
122
  if not source.export_allowed:
@@ -7,7 +7,6 @@ from typing import Any
7
7
  from PIL import Image, UnidentifiedImageError
8
8
 
9
9
  from .errors import ValidationError
10
- from .geometry import crosses_utm_zone, utm_zone_number
11
10
  from .moos_compat import estimate_pmarineviewer_placement
12
11
  from .moos_files import parse_info_file
13
12
 
@@ -76,27 +75,14 @@ def verify_bundle(tiff_path: Path) -> VerificationReport:
76
75
  details["info_comments"] = list(info.comments)
77
76
  if info.bounds.south < -80 or info.bounds.north > 84:
78
77
  errors.append("The .info bounds exceed the normal MOOS UTM latitude range")
79
- if crosses_utm_zone(info.bounds):
80
- errors.append("The .info bounds cross a UTM zone boundary")
81
- else:
82
- center_latitude = (info.bounds.north + info.bounds.south) / 2.0
83
- center_longitude = (info.bounds.east + info.bounds.west) / 2.0
84
- map_zone = utm_zone_number(center_longitude, center_latitude)
85
- origin_zone = utm_zone_number(info.origin.longitude, info.origin.latitude)
86
- if map_zone != origin_zone:
87
- errors.append(
88
- f"The .info origin is in UTM zone {origin_zone}, while the image "
89
- f"is in zone {map_zone}"
90
- )
91
- else:
92
- placement = estimate_pmarineviewer_placement(info.bounds, info.origin)
93
- details["pmarineviewer_estimate"] = {
94
- "width_m": placement.width_m,
95
- "height_m": placement.height_m,
96
- "image_center_local_x_m": placement.image_center_x_m,
97
- "image_center_local_y_m": placement.image_center_y_m,
98
- "estimated_max_position_error_m": (placement.max_position_error_m),
99
- }
78
+ placement = estimate_pmarineviewer_placement(info.bounds, info.origin)
79
+ details["pmarineviewer_estimate"] = {
80
+ "width_m": placement.width_m,
81
+ "height_m": placement.height_m,
82
+ "image_center_local_x_m": placement.image_center_x_m,
83
+ "image_center_local_y_m": placement.image_center_y_m,
84
+ "estimated_max_position_error_m": placement.max_position_error_m,
85
+ }
100
86
  if not info.bounds.contains(info.origin.latitude, info.origin.longitude):
101
87
  warnings.append(
102
88
  "The .info datum/origin is outside the image bounds; this is valid if "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moos-map
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: Build exact-crop TIFF background maps for MOOS-IvP
5
5
  License-Expression: GPL-3.0-only
6
6
  Project-URL: Repository, https://github.com/cbenjamin23/moos-map
@@ -23,6 +23,12 @@ Build cropped TIFF background maps for MOOS-IvP through a local browser UI or
23
23
  the `moos-map` command. Both interfaces use the same map sources, crop logic,
24
24
  cache, and MOOS compatibility checks.
25
25
 
26
+ MOOS Map targets current upstream MOOS-IvP with the default PROJ-backed
27
+ `CMOOSGeodesy`. Its datum-fixed UTM zone and hemisphere support maps that cross
28
+ zone boundaries or the equator. Legacy MOOS-IvP builds and current builds
29
+ configured with `--with-proj=off` are not supported for maps that cross a UTM
30
+ zone boundary or the equator.
31
+
26
32
  [PyPI Project](https://pypi.org/project/moos-map/)
27
33
 
28
34
  ## Install
@@ -175,9 +181,10 @@ those foundations with:
175
181
  - **Complete Map Bundles:** Places matching `.tif`, `.info`, and optional
176
182
  copy-ready `.moos` files together in a named output directory.
177
183
 
178
- - **MOOS Geodesy Validation:** Detects UTM-zone crossings, incompatible
179
- map/origin zones, invalid geographic bounds, and placement conditions that
180
- current MOOS geodesy cannot represent reliably.
184
+ - **Current MOOS Geodesy Compatibility:** Supports datum-fixed PROJ maps that
185
+ cross UTM boundaries or the equator and calculates pMarineViewer placement
186
+ estimates even when the map center and mission origin select different
187
+ natural zones.
181
188
 
182
189
  - **Shared CLI and GUI Core:** Uses the same source registry, crop calculations,
183
190
  cache, output writers, and validation from both interfaces, rather than
@@ -34,4 +34,5 @@ tests/test_info.py
34
34
  tests/test_moos_compat.py
35
35
  tests/test_service.py
36
36
  tests/test_sources.py
37
+ tests/test_verification.py
37
38
  tests/test_web.py
@@ -4,7 +4,6 @@ import pytest
4
4
 
5
5
  from moos_map.geometry import (
6
6
  bounds_for_tile_range,
7
- crosses_utm_zone,
8
7
  estimate_vertical_mapping_error,
9
8
  pixel_window_for_bounds,
10
9
  tile_range_for_bounds,
@@ -45,11 +44,6 @@ def test_exact_crop_window_is_smaller_than_downloaded_tile_grid() -> None:
45
44
  assert crop.bottom < tiles.rows * 256
46
45
 
47
46
 
48
- def test_utm_zone_boundary_detection() -> None:
49
- assert crosses_utm_zone(Bounds(west=-72.1, south=42.0, east=-71.9, north=42.1))
50
- assert not crosses_utm_zone(Bounds(west=-71.2, south=42.0, east=-71.0, north=42.1))
51
-
52
-
53
47
  def test_vertical_mapping_error_is_small_but_nonzero_for_local_map() -> None:
54
48
  tiles = TileRange(zoom=16, x_min=19826, x_max=19827, y_min=24239, y_max=24240)
55
49
 
@@ -0,0 +1,105 @@
1
+ from __future__ import annotations
2
+
3
+ import pytest
4
+
5
+ from moos_map.models import Bounds, Origin
6
+ from moos_map.moos_compat import estimate_pmarineviewer_placement, moos_utm
7
+
8
+
9
+ def test_fixed_zone_projection_remains_continuous_across_boundary() -> None:
10
+ _, west_easting = moos_utm(0.0, -0.0001, zone=30)
11
+ _, east_easting = moos_utm(0.0, 0.0001, zone=30)
12
+
13
+ assert east_easting - west_easting == pytest.approx(22.28574, abs=0.001)
14
+
15
+
16
+ def test_fixed_hemisphere_projection_remains_continuous_across_equator() -> None:
17
+ north_northing, _ = moos_utm(
18
+ 0.0001,
19
+ -3.0,
20
+ zone=30,
21
+ southern_hemisphere=False,
22
+ )
23
+ south_northing, _ = moos_utm(
24
+ -0.0001,
25
+ -3.0,
26
+ zone=30,
27
+ southern_hemisphere=False,
28
+ )
29
+ southern_frame_northing, _ = moos_utm(
30
+ 0.0001,
31
+ -3.0,
32
+ zone=30,
33
+ southern_hemisphere=True,
34
+ )
35
+ natural_south_northing, _ = moos_utm(-0.0001, -3.0, zone=30)
36
+
37
+ assert north_northing > 0 > south_northing
38
+ assert north_northing - south_northing == pytest.approx(22.106, abs=0.001)
39
+ assert southern_frame_northing - north_northing == pytest.approx(10_000_000)
40
+ assert natural_south_northing - south_northing == pytest.approx(10_000_000)
41
+
42
+
43
+ def test_estimate_matches_current_backimg_probe() -> None:
44
+ bounds = Bounds(
45
+ west=-71.092529296875,
46
+ south=42.35448465106745,
47
+ east=-71.08154296875,
48
+ north=42.36260292171997,
49
+ )
50
+
51
+ estimate = estimate_pmarineviewer_placement(
52
+ bounds,
53
+ Origin(latitude=42.3585, longitude=-71.0875),
54
+ requested_bounds=Bounds(
55
+ west=-71.088,
56
+ south=42.358,
57
+ east=-71.087,
58
+ north=42.359,
59
+ ),
60
+ )
61
+
62
+ # Current BackImg probe reports integer-truncated 882x923 and center
63
+ # (37.2678, 4.98198) for this exact generated bundle.
64
+ assert estimate.width_m == pytest.approx(882.6581, abs=0.001)
65
+ assert estimate.height_m == pytest.approx(923.6906, abs=0.001)
66
+ assert estimate.image_center_x_m == pytest.approx(37.2678, abs=0.001)
67
+ assert estimate.image_center_y_m == pytest.approx(4.9820, abs=0.001)
68
+ assert estimate.requested_area_max_position_error_m < estimate.max_position_error_m
69
+
70
+
71
+ def test_estimate_uses_map_center_zone_across_utm_boundary() -> None:
72
+ estimate = estimate_pmarineviewer_placement(
73
+ Bounds(west=-72.1, south=42.0, east=-71.9, north=42.1),
74
+ Origin(latitude=42.05, longitude=-72.0),
75
+ )
76
+
77
+ assert estimate.width_m == pytest.approx(16_163.118, abs=0.01)
78
+ assert estimate.height_m == pytest.approx(11_685.607, abs=0.01)
79
+ assert estimate.max_position_error_m == pytest.approx(707.274, abs=0.1)
80
+
81
+
82
+ @pytest.mark.parametrize(
83
+ ("bounds", "origin", "expected_height_m"),
84
+ [
85
+ (
86
+ Bounds(west=-3.005, south=-0.005, east=-2.995, north=0.005),
87
+ Origin(latitude=0.0, longitude=-3.0),
88
+ 1_105.300465,
89
+ ),
90
+ (
91
+ Bounds(west=-3.005, south=-0.01, east=-2.995, north=0.005),
92
+ Origin(latitude=-0.0025, longitude=-3.0),
93
+ 1_657.950698,
94
+ ),
95
+ ],
96
+ )
97
+ def test_estimate_uses_datum_hemisphere_across_equator(
98
+ bounds: Bounds,
99
+ origin: Origin,
100
+ expected_height_m: float,
101
+ ) -> None:
102
+ estimate = estimate_pmarineviewer_placement(bounds, origin)
103
+
104
+ assert estimate.height_m == pytest.approx(expected_height_m, abs=0.001)
105
+ assert estimate.max_position_error_m < 0.001
@@ -203,22 +203,45 @@ def test_outside_origin_is_allowed_with_warning(tmp_path: Path) -> None:
203
203
  assert any("origin lies outside" in warning for warning in plan.warnings)
204
204
 
205
205
 
206
- def test_cross_zone_map_is_rejected(tmp_path: Path) -> None:
206
+ def test_cross_zone_map_is_planned_with_fixed_zone_geodesy(tmp_path: Path) -> None:
207
207
  request = local_request(
208
208
  tmp_path,
209
209
  bounds=Bounds(west=-72.1, south=42.0, east=-71.9, north=42.1),
210
210
  origin=Origin(latitude=42.05, longitude=-72.0),
211
211
  )
212
212
 
213
- with pytest.raises(ValidationError, match="UTM zone"):
214
- plan_map(request)
213
+ plan = plan_map(request)
214
+
215
+ assert plan.pmarineviewer_width_m == pytest.approx(16_163.118, abs=0.01)
216
+ assert plan.warnings == ()
215
217
 
216
218
 
217
- def test_origin_in_different_utm_zone_is_rejected(tmp_path: Path) -> None:
219
+ def test_origin_and_map_center_may_use_different_utm_zones(tmp_path: Path) -> None:
218
220
  request = local_request(
219
221
  tmp_path,
220
- origin=Origin(latitude=42.36, longitude=-72.1),
222
+ bounds=Bounds(west=-72.1, south=42.0, east=-71.9, north=42.1),
223
+ origin=Origin(latitude=42.05, longitude=-72.05),
224
+ )
225
+
226
+ plan = plan_map(request)
227
+
228
+ assert plan.estimated_max_pmarineviewer_position_error_m == pytest.approx(
229
+ 881.182, abs=0.01
221
230
  )
231
+ assert plan.warnings == ()
232
+
233
+
234
+ def test_equator_crossing_map_is_planned_in_datum_hemisphere(
235
+ tmp_path: Path,
236
+ ) -> None:
237
+ request = local_request(
238
+ tmp_path,
239
+ bounds=Bounds(west=-3.005, south=-0.005, east=-2.995, north=0.005),
240
+ origin=Origin(latitude=0.0, longitude=-3.0),
241
+ )
242
+
243
+ plan = plan_map(request)
222
244
 
223
- with pytest.raises(ValidationError, match="origin is in UTM zone"):
224
- plan_map(request)
245
+ assert plan.pmarineviewer_height_m == pytest.approx(1_105.300465, abs=0.001)
246
+ assert plan.estimated_max_pmarineviewer_position_error_m < 0.001
247
+ assert plan.warnings == ()
@@ -0,0 +1,76 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ import pytest
6
+ from PIL import Image
7
+
8
+ from moos_map.models import Bounds, Origin
9
+ from moos_map.moos_files import write_info_file
10
+ from moos_map.verification import verify_bundle
11
+
12
+
13
+ def write_bundle(tmp_path: Path, bounds: Bounds, origin: Origin) -> Path:
14
+ tiff_path = tmp_path / "cross_zone.tif"
15
+ Image.new("RGB", (16, 16)).save(tiff_path, format="TIFF")
16
+ write_info_file(
17
+ tiff_path.with_suffix(".info"),
18
+ actual_bounds=bounds,
19
+ origin=origin,
20
+ source_id="test",
21
+ source_attribution="Test Provider",
22
+ zoom=16,
23
+ requested_bounds=bounds,
24
+ generator_version="test",
25
+ )
26
+ return tiff_path
27
+
28
+
29
+ def test_cross_zone_bundle_is_valid_with_current_proj_geodesy(tmp_path: Path) -> None:
30
+ tiff_path = write_bundle(
31
+ tmp_path,
32
+ Bounds(west=-72.1, south=42.0, east=-71.9, north=42.1),
33
+ Origin(latitude=42.05, longitude=-72.0),
34
+ )
35
+
36
+ report = verify_bundle(tiff_path)
37
+
38
+ assert report.ok
39
+ assert report.warnings == ()
40
+ assert report.details["pmarineviewer_estimate"]["width_m"] > 16_000
41
+
42
+
43
+ def test_different_map_and_origin_zones_are_valid(tmp_path: Path) -> None:
44
+ tiff_path = write_bundle(
45
+ tmp_path,
46
+ Bounds(west=-72.1, south=42.0, east=-71.9, north=42.1),
47
+ Origin(latitude=42.05, longitude=-72.05),
48
+ )
49
+
50
+ report = verify_bundle(tiff_path)
51
+
52
+ assert report.ok
53
+ assert report.warnings == ()
54
+ assert report.details["pmarineviewer_estimate"][
55
+ "estimated_max_position_error_m"
56
+ ] > 800
57
+
58
+
59
+ def test_equator_crossing_bundle_uses_datum_hemisphere(tmp_path: Path) -> None:
60
+ tiff_path = write_bundle(
61
+ tmp_path,
62
+ Bounds(west=-3.005, south=-0.005, east=-2.995, north=0.005),
63
+ Origin(latitude=0.0, longitude=-3.0),
64
+ )
65
+
66
+ report = verify_bundle(tiff_path)
67
+
68
+ assert report.ok
69
+ assert report.warnings == ()
70
+ assert report.details["pmarineviewer_estimate"]["height_m"] == pytest.approx(
71
+ 1_105.300465,
72
+ abs=0.001,
73
+ )
74
+ assert report.details["pmarineviewer_estimate"][
75
+ "estimated_max_position_error_m"
76
+ ] < 0.001
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import pytest
3
4
  from fastapi.testclient import TestClient
4
5
 
5
6
  from moos_map.geocoding import GeocodingError, SearchBounds, SearchResult
@@ -180,15 +181,17 @@ def test_blank_output_directory_is_accepted_by_plan_and_rejected_by_build() -> N
180
181
  assert "Choose an output directory" in response.json()["error"]
181
182
 
182
183
 
183
- def test_api_returns_user_facing_domain_error() -> None:
184
+ def test_plan_api_accepts_different_map_and_origin_zones_without_warning() -> None:
184
185
  response = client.post(
185
186
  "/api/plan",
186
187
  json={
187
188
  "bounds": {"west": -72.1, "south": 42, "east": -71.9, "north": 42.1},
188
- "origin": {"latitude": 42.05, "longitude": -72},
189
+ "origin": {"latitude": 42.05, "longitude": -72.05},
189
190
  "zoom": 16,
190
191
  },
191
192
  )
192
193
 
193
- assert response.status_code == 400
194
- assert "UTM zone" in response.json()["error"]
194
+ assert response.status_code == 200
195
+ plan = response.json()
196
+ assert plan["pmarineviewer_width_m"] == pytest.approx(16_163.118, abs=0.01)
197
+ assert plan["warnings"] == []
@@ -1,34 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import pytest
4
-
5
- from moos_map.models import Bounds, Origin
6
- from moos_map.moos_compat import estimate_pmarineviewer_placement
7
-
8
-
9
- def test_estimate_matches_current_backimg_probe() -> None:
10
- bounds = Bounds(
11
- west=-71.092529296875,
12
- south=42.35448465106745,
13
- east=-71.08154296875,
14
- north=42.36260292171997,
15
- )
16
-
17
- estimate = estimate_pmarineviewer_placement(
18
- bounds,
19
- Origin(latitude=42.3585, longitude=-71.0875),
20
- requested_bounds=Bounds(
21
- west=-71.088,
22
- south=42.358,
23
- east=-71.087,
24
- north=42.359,
25
- ),
26
- )
27
-
28
- # Current BackImg probe reports integer-truncated 882x923 and center
29
- # (37.2678, 4.98198) for this exact generated bundle.
30
- assert estimate.width_m == pytest.approx(882.6581, abs=0.001)
31
- assert estimate.height_m == pytest.approx(923.6906, abs=0.001)
32
- assert estimate.image_center_x_m == pytest.approx(37.2678, abs=0.001)
33
- assert estimate.image_center_y_m == pytest.approx(4.9820, abs=0.001)
34
- assert estimate.requested_area_max_position_error_m < estimate.max_position_error_m
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes