UW-Macrostrat / macrostrat-api

The API for SCIENCE
3 stars 1 forks source link

Get children of a place on /places #189

Closed jczaplew closed 7 years ago

jczaplew commented 7 years ago

Migrated from https://github.com/UW-Macrostrat/wof/issues/3

@aazaff - "We need to adjust the API route so that you can get all immediate children of a parent - e.g., all countries of Europe, all regions of France, all counties of Wisconsin."

jczaplew commented 7 years ago

What do you think would be a sensible API for this functionality? I was thinking something like children_of=<wof_id of parent>

Also, I plan to set this up so that only the first level of children is provided. If the user wants additional levels they can recursively query.

aazaff commented 7 years ago

I agree. Only first level is necessary if we do it that way.

Alternatively, name=UnitedStaes&placetype=country&children=counties to get all US counties?

On May 1, 2017 8:50 AM, "John J Czaplewski" notifications@github.com wrote:

What do you think would be a sensible API for this functionality? I was thinking something like children_of=

Also, I plan to set this up so that only the first level of children is provided. If the user wants additional levels they can recursively query.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/UW-Macrostrat/macrostrat-api/issues/189#issuecomment-298336526, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ8JQ3JYLMBfjWI55Bw7Wu6MnGb5jWiCks5r1eMtgaJpZM4NNDWE .

jczaplew commented 7 years ago

That's a good point, I like that better.

There is only one thing in that form that complicates things a bit. We would need to check for and throw errors in the following situations:

We could either just deal with these or force the user to provide a wof_id when asking for children

Thoughts?

aazaff commented 7 years ago

Just return nothing. That's how we already handle errors for this route.

jczaplew commented 7 years ago

To get children the parameter will be called child_type or (child_placetype?), and accepts any valid placetype.

aazaff commented 7 years ago

Should be childtype to be consistent with placetype which is not snake_case

or change placetype to snake_case.

jczaplew commented 7 years ago

https://dev.macrostrat.org/api/v2/places?name=Wisconsin&placetype=region&childtype=county

or

https://dev.macrostrat.org/api/v2/places?wof_id=85688517&childtype=county

aazaff commented 7 years ago

I feel like we obviously want to support both?

jczaplew commented 7 years ago

Yes, I am just demonstrating the two ways of querying. Both will be supported.

jczaplew commented 7 years ago

Are you including this route in Velociraptr?

aazaff commented 7 years ago

Yes, there will be a wrapper for this, but the true path will be hidden in the package. I'll be hiding it in kind of a jenky way by putting a wrapper around the wrapper, but this will avoid people writing their own larger queries that overwhelm our server.

jczaplew commented 7 years ago

Alright, because currently there are no safeguards against people asking for all localities in a continent as a GeoJSON

aazaff commented 7 years ago

Oh... hmmm... that IS a problem even with my wrapper. Maybe I will only use the MapZen API and assume they've built in protections? Security through obscurity is not good.

jczaplew commented 7 years ago

I could build in a rudimentary safeguard that does something like throw an error if more than x features will be returned.

aazaff commented 7 years ago

Perhaps add a parameter that we can toggle for limits. &response=long or &response=short. short will throw an error for geojson's over a certain character length, long will give you everything. This way we can make larger calls internally.

I will fix the response option to short in the velociraptr version?

Or limit=TRUE limit=FALSE

jczaplew commented 7 years ago

Added an upper limit of 5000 results in d3cd68fb8fd658127bba92abd7ca852b7fd840b7.

Can we consider this resolved?

aazaff commented 7 years ago

Can we update the documentation to included childtype?

aazaff commented 7 years ago

I am reopening this issue. The current childtype parameter only works if a single parent is given. It should work for multiple parents.

e.g., - https://macrostrat.org/api/places?name=Arizona,California&placetype=region&childtype=county&format=geojson_bare

jczaplew commented 7 years ago

While fixing this I'm going to modify the route so that you can only query down one level. I.E. you will not be able to say name=North%20America&placetype=continent&childtype=locality

aazaff commented 7 years ago

Makes sense, is that to prevent overburdening the system?

On Tue, Jun 20, 2017 at 7:55 AM, John J Czaplewski <notifications@github.com

wrote:

While fixing this I'm going to modify the route so that you can only query down one level. I.E. you will not be able to say name=North%20America& placetype=continent&childtype=locality

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/UW-Macrostrat/macrostrat-api/issues/189#issuecomment-309784368, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ8JQ0As61v1XCr5UOokuQWM6E4E1iEPks5sF91WgaJpZM4NNDWE .

jczaplew commented 7 years ago

Yes. Don't want someone asking for gigabytes of data all at once....