Created
September 1, 2013 13:57
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_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