Skip to content

rate limiting w/ enterprise #19

@iskandari

Description

@iskandari

I have been trying to use the isochrone API to generate 10-minute walking isochrones using a list of coordinate pairs but my attempt fails even while iterating over a small number (such as 5) points. I have an enterprise account so should there should be a very high rate limit.

The script will execute the first time on 5 points, but on the second try and subsequent tries, it will throw the following error from isochrone.js :

            'data': resp.durations[0],
                        ^
      TypeError: Cannot read property 'durations' of undefined

If I include a geojson with many points (such as 100), it will fail every time.

Any ideas on how to solve this?
I have included both the geojson that I am iterating over and the modified index.js file below:

index.js

isochrone = require('./isochrone.js');
var turf = require('@turf/turf');
var fs = require('fs'),
obj

token = 'mytoken'

fs.readFile('poi.geojson', handleFile);
fts = []

function handleFile(err, data) {
    if (err) throw err
    obj = JSON.parse(data)
    features = obj.features
    console.log(features.length)

    for (var j = 0; j <features.length; j++) {

    	console.log(j)
	
		coords = features[j].geometry.coordinates

		isochrone(coords, {"token":token, "threshold":[600], "mode":"walking", batchSize:25}, function(err, output){
			
			if (err) console.log("not throwing error");
				
			output = output.features
			console.log(output)
			fts.push(output[0]);
			

			 if (j >= features.length){console.log('made it to the end')
			 	
		 	var collection = JSON.stringify({
			features: fts,
     	    type: 'FeatureCollection'
			});

		 	fs.writeFileSync('isochrones.geojson', collection);

			 }
		});	

   }

}

poi.geojson

{
"type": "FeatureCollection",
"name": "poi",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "stop_id": 6, "stop_name": "Jackson & Lotus", "stop_lat": 41.876513, "stop_lon": -87.761446 }, "geometry": { "type": "Point", "coordinates": [ -87.761446, 41.876513 ] } },
{ "type": "Feature", "properties": { "stop_id": 2, "stop_name": "5900 W Jackson", "stop_lat": 41.87706679, "stop_lon": -87.77131794 }, "geometry": { "type": "Point", "coordinates": [ -87.77131794, 41.87706679 ] } },
{ "type": "Feature", "properties": { "stop_id": 1, "stop_name": "Jackson & Austin Terminal", "stop_lat": 41.87632184, "stop_lon": -87.77410482000001 }, "geometry": { "type": "Point", "coordinates": [ -87.77410482, 41.87632184 ] } },
{ "type": "Feature", "properties": { "stop_id": 4, "stop_name": "5700 W Jackson", "stop_lat": 41.87702418, "stop_lon": -87.76745055000001 }, "geometry": { "type": "Point", "coordinates": [ -87.76745055, 41.87702418 ] } },
{ "type": "Feature", "properties": { "stop_id": 3, "stop_name": "Jackson & Menard", "stop_lat": 41.87695725, "stop_lon": -87.76975039 }, "geometry": { "type": "Point", "coordinates": [ -87.76975039, 41.87695725 ] } }
]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions