Skip to content

Instantly share code, notes, and snippets.

@nilclass
Created September 1, 2013 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilclass/6404631 to your computer and use it in GitHub Desktop.
Save nilclass/6404631 to your computer and use it in GitHub Desktop.
CouchDB design document to convert some JSON points (custom format (I think?)) into a MultiPoint GeoJSON thingy.
{
"_id": "_design/timeline",
"_rev": "25-ccec1e8c0085a9b130b5f5289ae99d4b",
"views": {
"bySavedTime": {
"map": "function (doc) {\n if(doc.data && doc.data.position && typeof(doc.data.position.timestamp) == 'number') {\n emit([doc.channel, doc.data.position.timestamp], doc);\n }\n}"
}
},
"lists": {
"multipoint": "function(head, req) { var feature = { type: 'Feature', geometry: { type: 'MultiPoint', coordinates: [] }, properties: { time: [] } }; var row; while(row = getRow()) { if(row.value.data && row.value.data.position && row.value.data.position.coords && typeof(row.value.data.position.timestamp) == 'number') { var pos = row.value.data.position; feature.geometry.coordinates.push([pos.coords.longitude, pos.coords.latitude]); feature.properties.time.push(pos.timestamp); } } start({ headers: { 'Content-Type': 'application/json' } }); send(JSON.stringify(feature)); }"
},
"language": "javascript"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment