developmentseed / skynet-scrub-server

Backing store for developmentseed/skynet-scrub
13 stars 3 forks source link

Endpoints #2

Closed kamicut closed 7 years ago

kamicut commented 7 years ago

Endpoints we need to cover:

@drewbo @dereklieu do we need an endpoint to batch import features and assign ids (logic covered in bin/import.js)? Anything I missed?

drewbo commented 7 years ago

@kamicut what does /commit do? I think we're fine without batch import and assign since we'll do that manually for a while. Could put it on a hypothetical future roadmap

kamicut commented 7 years ago

@drewbo I was thinking on save in the frontend, instead of an api call per feature, it would be a batch commit. The format I was thinking of:

{
  "added": [{ "Feature": { "geometry": [] } }, { "Feature": { "geometry": [] } }],
  "modified": [{ "Feature": { "geometry": [], "properties": {"id": "id5"} } }],
  "deleted": ["id1", "id2", "id3"]
}
drewbo commented 7 years ago

@kamicut gotcha, I think the front-end won't necessarily distinguish between added and modified; should we think about mimicking the logic from draw (if no id match: add, if match: update)?

kamicut commented 7 years ago

@drewbo sure, I don't see a problem with that. I think we should have the same id construction in draw and in the database 1dd78efb bin/import.js#L16

dereklieu commented 7 years ago

Agree with what's been said. Apologies if this is now repetitive, but as for the commit endpoint, I'm also leaning towards a simpler format than the one outlined. Can't really see what having separate added and modified actions gets us when we aren't confined by a rigid order of database actions a la OSM.

{
  "id1": { "Feature": { "geometry": [] } },
  "id2": { "Feature": { "geometry": [] } },
  "id3": null
}

If an id doesn't match, create one, otherwise replace the existing one, and either use null or another value to signify deletion (maybe the geometry array is just []).

kamicut commented 7 years ago

I think null is fine, but having an empty geometry I feel is semantically different from delete.

kamicut commented 7 years ago

@drewbo I don't think we should have a POST /features.json. If we're creating ids on the client, then we can have a PUT features/:id that creates a feature at that id. What do you think?

drewbo commented 7 years ago

That's fine since we'll create ids for all features (using the same method) on the client side. The only discrepancy would be created if people add features outside of the provided front end