Repository: geopy/geopy
Pull request #454 (2020-11-12 18:04:18)

improve Nominatim.search docstring
- `view_box` -> `viewbox` plus proper markup
- Specify what `viewbox` actually does

kannes: Failed tests are unrelated to my changes from what I am seeing, only Photon failed, which I did not touch in any way.

Patch:
diff --git a/geopy/geocoders/nominatim.py b/geopy/geocoders/nominatim.py
index 415d236..e87a7f7 100644
--- a/geopy/geocoders/nominatim.py
+++ b/geopy/geocoders/nominatim.py
@@ -204,11 +204,13 @@ class Nominatim(Geocoder):
         :type viewbox: list or tuple of 2 items of :class:`geopy.point.Point` or
             ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``.
 
-        :param viewbox: Coordinates to restrict search within.
+        :param viewbox: Prefer this area to find search results. By default this is
+            treated as a hint, if you want to restrict results to this area,
+            specify ``bounded=True`` as well.
             Example: ``[Point(22, 180), Point(-22, -180)]``.
 
         :param bool bounded: Restrict the results to only items contained
-            within the bounding view_box.
+            within the bounding ``viewbox``.
 
         :param str featuretype: If present, restrict results to certain type of features.
             Allowed values: `country`, `state`, `city`, `settlement`.
diff --git a/geopy/point.py b/geopy/point.py
index d6a5ee8..7c061e0 100644
--- a/geopy/point.py
+++ b/geopy/point.py
@@ -15,20 +15,20 @@ POINT_PATTERN = re.compile(r"""
     .*?
     (?P<latitude>
       (?P<latitude_direction_front>[NS])?[ ]*
-        (?P<latitude_degrees>-?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
+        (?P<latitude_degrees>[+-]?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
         (?:(?P<latitude_arcminutes>%(FLOAT)s)[%(PRIME)s'm][ ]*)?
         (?:(?P<latitude_arcseconds>%(FLOAT)s)[%(DOUBLE_PRIME)s"s][ ]*)?
         )?(?P<latitude_direction_back>[NS])?)
     %(SEP)s
     (?P<longitude>
       (?P<longitude_direction_front>[EW])?[ ]*
-      (?P<longitude_degrees>-?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
+      (?P<longitude_degrees>[+-]?%(FLOAT)s)(?:[%(DEGREE)sD\*\u00B0\s][ ]*
       (?:(?P<longitude_arcminutes>%(FLOAT)s)[%(PRIME)s'm][ ]*)?
       (?:(?P<longitude_arcseconds>%(FLOAT)s)[%(DOUBLE_PRIME)s"s][ ]*)?
       )?(?P<longitude_direction_back>[EW])?)(?:
     %(SEP)s
       (?P<altitude>
-        (?P<altitude_distance>-?%(FLOAT)s)[ ]*
+        (?P<altitude_distance>[+-]?%(FLOAT)s)[ ]*
         (?P<altitude_units>km|m|mi|ft|nm|nmi)))?
     \s*$
 """ % {


Test patch:
diff --git a/test/geocoders/banfrance.py b/test/geocoders/banfrance.py
index 1cb34ff..c8c4af7 100644
--- a/test/geocoders/banfrance.py
+++ b/test/geocoders/banfrance.py
@@ -26,7 +26,7 @@ class TestBANFrance(BaseTestGeocoder):
             {"query": "48.154587,3.221237"},
             {"latitude": 48.154587, "longitude": 3.221237},
         )
-        assert "Rue des Fontaines" in location.address
+        assert "Collemiers" in location.address
 
     async def test_geocode_limit(self):
         result = await self.geocode_run(
diff --git a/test/geocoders/geocodefarm.py b/test/geocoders/geocodefarm.py
index 42a31ab..ccb9366 100644
--- a/test/geocoders/geocodefarm.py
+++ b/test/geocoders/geocodefarm.py
@@ -39,11 +39,11 @@ class TestGeocodeFarm(BaseTestGeocoder):
         assert "chicago" in location.address.lower()
 
     async def test_location_address(self):
-        await self.geocode_run(
+        location = await self.geocode_run(
             {"query": "moscow"},
-            {"address": "Moscow, Russia",
-             "latitude": 55.7558913503453, "longitude": 37.6172961632184}
+            {"latitude": 55.755891, "longitude": 37.61729}
         )
+        assert "Moscow, Russia" in location.address  # 'Moscow, Russia, Russia'
 
     async def test_reverse(self):
         location = await self.reverse_run(
diff --git a/test/geocoders/nominatim.py b/test/geocoders/nominatim.py
index 7c4d6e2..1fd5727 100644
--- a/test/geocoders/nominatim.py
+++ b/test/geocoders/nominatim.py
@@ -25,7 +25,7 @@ class BaseTestNominatim(BaseTestGeocoder):
     async def test_unicode_name(self):
         await self.geocode_run(
             {"query": "\u6545\u5bab \u5317\u4eac"},
-            {"latitude": 39.916, "longitude": 116.390},
+            {"latitude": 39.916, "longitude": 116.390, "delta": 1.0},
         )
 
     async def test_geocode_empty_result(self):
diff --git a/test/geocoders/photon.py b/test/geocoders/photon.py
index f61d9f3..2588395 100644
--- a/test/geocoders/photon.py
+++ b/test/geocoders/photon.py
@@ -26,13 +26,13 @@ class TestPhoton(BaseTestGeocoder):
 
     async def test_osm_tag(self):
         await self.geocode_run(
-            {"query": "Freedom", "osm_tag": "place"},
-            {"latitude": 44.3862491, "longitude": -88.290994},
+            {"query": "Freedom", "osm_tag": "tourism:artwork"},
+            {"latitude": 38.8898061, "longitude": -77.009088, "delta": 2.0},
         )
 
         await self.geocode_run(
-            {"query": "Freedom", "osm_tag": ["!place", "tourism"]},
-            {"latitude": 38.8898061, "longitude": -77.009088},
+            {"query": "Freedom", "osm_tag": ["!office", "place:hamlet"]},
+            {"latitude": 44.3862491, "longitude": -88.290994, "delta": 2.0},
         )
 
     async def test_unicode_name(self):
diff --git a/test/test_point.py b/test/test_point.py
index d672bcc..37d2586 100644
--- a/test/test_point.py
+++ b/test/test_point.py
@@ -60,6 +60,8 @@ class PointTestCase(unittest.TestCase):
         self.assertEqual(Point("41.5;-81.0"), (41.5, -81.0, 0.0))
         self.assertEqual(Point("41.5,-81.0"), (41.5, -81.0, 0.0))
         self.assertEqual(Point("41.5 -81.0"), (41.5, -81.0, 0.0))
+        self.assertEqual(Point("+41.5 -81.0"), (41.5, -81.0, 0.0))
+        self.assertEqual(Point("+41.5 +81.0"), (41.5, 81.0, 0.0))
         self.assertEqual(Point("41.5 N -81.0 W"), (41.5, 81.0, 0.0))
         self.assertEqual(Point("-41.5 S;81.0 E"), (41.5, 81.0, 0.0))
         self.assertEqual(Point("23 26m 22s N 23 27m 30s E"),