cfpb / grasshopper

CFPB's streaming batch geocoder
Creative Commons Zero v1.0 Universal
37 stars 13 forks source link

Batch API response (QM focus) #99

Open awolfe76 opened 9 years ago

awolfe76 commented 9 years ago

This is a question to get the conversation started on the batch API response for M3.

A possible example:

[
  {
    "type": "FeatureCollection",
    "query": "638 Louise Terrace, Loomis, California, 81985",
    "features": [
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [
            -74.518537,
            179.083152,
            0
          ]
        },
        "properties": {
          "address": "637 Louise Terrace, Loomis, California, 81985",
          "alt_addresses": "",
          "load_date": 1284882682262,
          "relevancy": 0.99
          // QM fields
          "county": "",
          "census_block": 2.03,
          "rural_underserved": false          
        }
      },
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [
            -74.518537,
            179.083152,
            0
          ]
        },
        "properties": {
          "address": "636 Louise Terrace, Loomis, California, 81985",
          "alt_addresses": "",
          "load_date": 1284882682262,
          "relevancy": 0.99
          // QM fields
          "county": "",
          "census_block": 2.03,
          "rural_underserved": false
        }
      }
    ],
    "status": "OK"
  }
]
jmarin commented 9 years ago
awolfe76 commented 9 years ago

Thanks @jmarin .

I'm ok with only one result, certainly simplifies things on the front-end. In QM-land we were showing multiples (and giving the option to choose), but having only one possible response removes that need ... which seems good to me, for a version 1.

Same for no results.

So, for the additional fields (QM example), are you saying we'll a call to a QM API which in turn will handle the geocoder call as well? And piece it all together? Again, sounds good just want to make sure I understand. Seems like the response in the QM case could be very similar to the geocoder response, with a few additional fields.

For the FeatureCollection, the array was to show that there could be more than one, but yeah, I only included one. Though it might not be necessary if we have only 0 or 1 response per address. Features would be fine, as long as we have the actual query in there too. Maybe as a property value, really only necessary for batch.

[
    {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [
            -74.518537,
            179.083152,
            0
          ]
        },
        "properties": {
          // the query
          "query": "636 Louise Terrace, Loomis, California, 81985",
          "address": "636 Louise Terrace, Loomis, California, 81985",
          "alt_addresses": "",
          "load_date": 1284882682262,
          "relevancy": 0.99
        }
    },
    // as many others as required
]
jmarin commented 9 years ago

@awolfe76 Thanks, this gives me something to start chewing on. Will update this with comments as I dive deeper into the implementation