NREL / developer.nrel.gov

An issue tracker for NREL's APIs available at https://developer.nrel.gov
43 stars 39 forks source link

Radius query param not working #303

Open albertRCell opened 1 year ago

albertRCell commented 1 year ago

Hello,

I'm trying the nearest api with different values for radius param, however looks like I always get the same result regardless of the value passed, here's an example of the request.

https://developer.nrel.gov/api/alt-fuel-stations/v1/nearest.json?api_key=MY_KEY&fuel_type=ELEC&latitude=38.623038&longitude=-121.448351&radius=25

Thanks in advance.

ScottHutchinson commented 1 year ago

Too bad nobody is responding to these issues more promptly.

I don't see a radius request parameter listed at the documentation. Either that parameter is undocumented, or the API should respond with an 'unknown parameter' error.

In fact, I don't see latitude or longitude in the documentation either. But what you are attempting seems very useful, so it would be a good enhancement if it's not yet supported.

GUI commented 1 year ago

@albertRCell: Sorry this slipped past us. The radius parameter defines the maximum radius of results returned. However, you must also pay attention to the limit parameter, since by default we only return the 20 closest results (results are ordered by how close they are to the input lat/lon). So in the case of this latitude/longitude, there are currently 717 separate station locations within 25 miles. So with the default limit of 20 applied, the first 20 results are all within 2 miles, so that's why you're likely not seeing a difference in the response if you're trying to increase the radius. Try passing in the limit=all parameter, or use the offset parameter (with a smaller limit) to paginate through all of the available results. Hope that helps clarify things, but let us know if think you're still seeing any issues.

@ScottHutchinson: The radius, latitude, and longitude parameters are all valid for the Nearest Stations API (you were linking to the "All Stations API" which is focused on bulk downloads and not geospatial capabilities, so that's why it's not an option on that endpoint).

albertRCell commented 1 year ago

@GUI Thank you very much for the explanation, limit parameter is doing the trick.