Skip to content

Commit c25c84c

Browse files
Expose GeoJson's web retrieval to its own function (#1458)
* move GeoJson.process_data()'s web data retrieval to its own fucntion so it can be overrriden or subclassed readily * remove whitespace Co-authored-by: Beau Uriona <buriona@usbr.gov>
1 parent 15f9cec commit c25c84c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

folium/features.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def process_data(self, data):
526526
if data.lower().startswith(('http:', 'ftp:', 'https:')):
527527
if not self.embed:
528528
self.embed_link = data
529-
return requests.get(data).json()
529+
return self.get_geojson_from_web(data)
530530
elif data.lstrip()[0] in '[{': # This is a GeoJSON inline string
531531
self.embed = True
532532
return json.loads(data)
@@ -544,6 +544,9 @@ def process_data(self, data):
544544
raise ValueError('Cannot render objects with any missing geometries'
545545
': {!r}'.format(data))
546546

547+
def get_geojson_from_web(self, url):
548+
return requests.get(url).json()
549+
547550
def convert_to_feature_collection(self):
548551
"""Convert data into a FeatureCollection if it is not already."""
549552
if self.data['type'] == 'FeatureCollection':

0 commit comments

Comments
 (0)