Give satellite imagery, terrain data, buildings, streetview photos to your LLM
Fix inverted pitch
Belluxxda6b3197d005
diff --git a/aleph.py b/aleph.pyindex a398c89..d7a4fd3 100644--- a/aleph.py+++ b/aleph.py@@ -77,7 +77,7 @@ def parser():angle = street.add_mutually_exclusive_group()angle.add_argument("--heading", type=float, help="single-view heading clockwise from north, any finite float32 degrees (default: 0)")angle.add_argument("--look-at", nargs=2, type=float, metavar=("LAT", "LON"), help="turn a single view toward this point")- street.add_argument("--pitch", type=float, default=0, help="vertical angle, any finite float32 degrees (default: 0)")+ street.add_argument("--pitch", type=float, default=0, help="vertical angle, positive up and negative down; any finite float32 degrees (default: 0)")street.add_argument("--fov", type=int, default=75, help="horizontal field of view, 5–175 whole degrees (default: 75)")street.add_argument("--radius", type=float, help="maximum panorama search distance in meters (default: 50)")street.add_argument("--image-format", choices=("jpg", "png"), default="jpg")diff --git a/src/streetview.py b/src/streetview.pyindex 0b1ec84..aa96f7d 100644--- a/src/streetview.py+++ b/src/streetview.py@@ -114,7 +114,8 @@ def image_url(pano_id, heading, fov, pitch=0):w=1024,h=576,yaw=validate_angle(heading, "heading"),- pitch=validate_angle(pitch, "pitch"),+ # The thumbnail service uses positive-down; Aleph uses positive-up.+ pitch=-validate_angle(pitch, "pitch"),thumbfov=validate_fov(fov),)diff --git a/tests/test_queries.py b/tests/test_queries.pyindex 29b1a0a..34c0ae6 100644--- a/tests/test_queries.py+++ b/tests/test_queries.py@@ -109,7 +109,7 @@ class QueryTests(unittest.TestCase):if "/thumbnail" in address:values = parse_qs(urlsplit(address).query)self.assertAlmostEqual(float(values["yaw"][0]), 90, places=3)- self.assertEqual(values["pitch"], ["10.0"])+ self.assertEqual(values["pitch"], ["-10.0"])self.assertEqual(values["thumbfov"], ["175"])return image_bytes((1024, 576), "blue")self.fail(f"Unexpected request: {address}")@@ -219,7 +219,7 @@ class QueryTests(unittest.TestCase):return metadata()values = parse_qs(urlsplit(address).query)self.assertEqual(values["yaw"], ["-720.5"])- self.assertEqual(values["pitch"], ["100.25"])+ self.assertEqual(values["pitch"], ["-100.25"])return image_bytes((1024, 576), "blue")self.get.side_effect = responsediff --git a/tests/test_streetview.py b/tests/test_streetview.pyindex ab6e705..3942699 100644--- a/tests/test_streetview.py+++ b/tests/test_streetview.py@@ -8,6 +8,12 @@ from tests.fixtures import metadataclass StreetViewTests(unittest.TestCase):+ def test_pitch_converts_positive_up_to_provider_positive_down(self):+ for pitch in (-20, 0, 20):+ with self.subTest(pitch=pitch):+ query = parse_qs(urlsplit(streetview.image_url("panorama_0001", 0, 75, pitch)).query)+ self.assertEqual(float(query["pitch"][0]), -pitch)+def test_fov_bounds_and_integer_serialization(self):for value in (5, 75.0, 175):with self.subTest(value=value):