Skip to content

Commit

Permalink
Merge pull request #1078 from CartoDB/fix/isolines_range
Browse files Browse the repository at this point in the history
Rename isolines range parameter, fix doc
  • Loading branch information
jgoizueta authored Oct 9, 2019
2 parents 55c9f63 + 7b3f654 commit 4902289
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cartoframes/data/services/isolines.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Isolines(Service):
def __init__(self, credentials=None):
super(Isolines, self).__init__(credentials, quota_service=QUOTA_SERVICE)

def isochrones(self, source, range, **args):
def isochrones(self, source, ranges, **args):
"""isochrone areas
This method computes areas delimited by isochrone lines (lines of constant travel time) based upon public roads.
Expand Down Expand Up @@ -59,9 +59,9 @@ def isochrones(self, source, range, **args):
that identifies the source point corresponding to each area if the source has a
``cartodb_id`` column.
"""
return self._iso_areas(source, range, function='isochrone', **args)
return self._iso_areas(source, ranges, function='isochrone', **args)

def isodistances(self, source, range, **args):
def isodistances(self, source, ranges, **args):
"""isodistance areas
This method computes areas delimited by isodistance lines (lines of constant travel distance) based upon public
Expand All @@ -71,8 +71,6 @@ def isodistances(self, source, range, **args):
source (Dataset, Dataframe): containing the source points for the isochrones:
travel routes from the source points are computed to determine areas within
specified travel distances.
range (list): travel distance values in meters; for each value and source point
a distinct area are will be computed.
ranges (list): travel distance values in meters; for each range value and source point a result polygon
will be produced enclosing the area within range of the source.
exclusive (bool, optional): when False (the default), inclusive range areas are generated, each one
Expand Down Expand Up @@ -107,11 +105,11 @@ def isodistances(self, source, range, **args):
that identifies the source point corresponding to each area if the source has a
``cartodb_id`` column.
"""
return self._iso_areas(source, range, function='isodistance', **args)
return self._iso_areas(source, ranges, function='isodistance', **args)

def _iso_areas(self,
source,
range,
ranges,
dry_run=False,
table_name=None,
if_exists=None,
Expand All @@ -132,7 +130,7 @@ def _iso_areas(self,
source = Dataset(input_dataframe)

num_rows = source.get_num_rows()
metadata['required_quota'] = num_rows * len(range)
metadata['required_quota'] = num_rows * len(ranges)

if dry_run:
return self.result(data=None, metadata=metadata)
Expand Down Expand Up @@ -164,7 +162,7 @@ def _iso_areas(self,
}
iso_options = ["'{}={}'".format(k, v) for k, v in options.items() if v is not None]
iso_options = "ARRAY[{opts}]".format(opts=','.join(iso_options))
iso_ranges = 'ARRAY[{ranges}]'.format(ranges=','.join([str(r) for r in range]))
iso_ranges = 'ARRAY[{ranges}]'.format(ranges=','.join([str(r) for r in ranges]))

sql = _areas_query(
source_query, source_columns, iso_function, mode, iso_ranges, iso_options, source_has_id or exclusive)
Expand Down

0 comments on commit 4902289

Please sign in to comment.