Add ability to use local ArcGIS server
@@ -26,7 +26,6 @@ class ArcGIS(Geocoder):
_TOKEN_EXPIRED = 498
_MAX_RETRIES = 3
- auth_api = 'https://www.arcgis.com/sharing/generateToken'
def __init__(
self,
@@ -40,6 +39,8 @@ class ArcGIS(Geocoder):
user_agent=None,
format_string=None,
ssl_context=DEFAULT_SENTINEL,
+ auth_domain='www.arcgis.com',
+ domain='geocode.arcgis.com',
):
"""
@@ -83,6 +84,16 @@ class ArcGIS(Geocoder):
See :attr:`geopy.geocoders.options.default_ssl_context`.
.. versionadded:: 1.14.0
+
+ :param str auth_domain: Domain where the target ArcGIS auth service
+ is hosted. Required if authenticated mode is desired.
+
+ .. versionadded:: 1.17.0
+
+ :param str domain: Domain where the target ArcGIS service
+ is hosted.
+
+ .. versionadded:: 1.17.0
"""
super(ArcGIS, self).__init__(
format_string=format_string,
@@ -108,19 +119,28 @@ class ArcGIS(Geocoder):
self.username = username
self.password = password
self.referer = referer
+ self.auth_domain = auth_domain.strip('/')
+ self.auth_api = '%s://%s/sharing/generateToken' % (
+ self.scheme,
+ self.auth_domain
+ )
self.token = None
self.token_lifetime = token_lifetime * 60 # store in seconds
self.token_expiry = None
self.retry = 1
+ self.domain = domain.strip('/')
self.api = (
- '%s://geocode.arcgis.com/arcgis/rest/services/'
- 'World/GeocodeServer/findAddressCandidates' % self.scheme
+ '%s://%s/arcgis/rest/services/'
+ 'World/GeocodeServer/findAddressCandidates' % (
+ self.scheme,
+ self.domain
+ )
)
self.reverse_api = (
- '%s://geocode.arcgis.com/arcgis/rest/services/'
- 'World/GeocodeServer/reverseGeocode' % self.scheme
+ '%s://%s/arcgis/rest/services/'
+ 'World/GeocodeServer/reverseGeocode' % (self.scheme, self.domain)
)
def _authenticated_call_geocoder(self, url, timeout=DEFAULT_SENTINEL):
