Skip to main content

Posts

Showing posts with the label elevation

Things I Learned: Datasette-Enrichments: The Template Can Be The Optional Arguments

 This is a small thing, but it's going to give me a lot of utility with the enrichments I'm writing. More than once, I've run into the need for an input argument to the enrichments I'm creating. Take the elevation enrichment for example. I'd like the user to be able to specify how long their elevation profile path should be in meters. My slop and drop method for adding an argument to rows of table data would be to simply specify a constant in my SQL query ala  select tx_lat, tx_lng, rx_lat, rx_lng, 200 as optional_meters from qso_table That would result in an extra column containing the number 200 on every row. That also won't work with enrichments for the moment because the operate on filtered tables, not generic SQL queries. That was irksome. The answer though, is simple, elegant even. For each enrichment , the user specifies their input using a template. For the elevation enrichment, the template looks like this: but I could have just as easily typed and now...

Things I Learned: The Google Maps Elevation API and jq

This is moving kind of fast! Regarding the goal of automating elevations using Datasette and the Google Maps Elevation API. I pulled a QSO out of a hat last night and tried the coordinates between stations in a call to the Google Maps Elevation API.  The URL to use the API looked like this: https://maps.googleapis.com/maps/api/elevation/json?path=37.7248952%2C-122.4229361%7C37.7247294%2C-122.4207246&samples=200&key= where the path parameter contains two coordinates separated by %7C (html encoding for the pipe symbol: '|') and commas (aka %2C) define the coordinates of the tx station and the coordinate of a point 200 meters along the path to the rx station, and the samples parameter tells the API how many points to split the path into and return elevations for. It's all documented by Google here . I was quickly rewarded with data that looked like the following: { "results" : [ { "elevation" : 123.6165237426758, ...