Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pravj/bangalore-taxis
Code used to analyse patterns in my post 'Bangalore-taxis'
https://github.com/pravj/bangalore-taxis
Last synced: 30 days ago
JSON representation
Code used to analyse patterns in my post 'Bangalore-taxis'
- Host: GitHub
- URL: https://github.com/pravj/bangalore-taxis
- Owner: pravj
- Created: 2015-09-01T07:20:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-01T07:30:54.000Z (about 9 years ago)
- Last Synced: 2024-04-14T19:59:22.607Z (7 months ago)
- Language: R
- Size: 225 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Bangalore-taxis
===============> Code sample used in my post, [Jump in to ride all the Bangalore taxis, at once.](http://pravj.github.io/blog/bangalore-taxis/)
## Group by vehicle type
```
r.db('test').table('warehouse')
.filter({available: true})
.pluck('cab_id', 'type')
.distinct()
.group('type')
.count()
```## Insertion of 'index' field
```
r.db('test').table('warehouse').update({index: r.row('major').coerceTo("NUMBER").mul(4)})
r.db('test').table('warehouse').update({index: r.row('index').add(r.row('minor').coerceTo("NUMBER"))})
r.db('test').table('warehouse').update({index: r.row('index').add(-4)})
```## Cab count distribution by type (per quarter-hour)
```
r.db('test').table('warehouse')
.filter({available: true})
.without('id', 'distance', 'duration', 'cab_lat', 'cab_lng', 'place_lat', 'place_lng')
.distinct()
.orderBy('index','cab_id')
.group('index')
.count()
```## Rise of the Guardians(Vehicles)
```
r.db('test').table('warehouse')
.filter({available: true})
.pluck('cab_id', 'cab_time')
.distinct()
.orderBy('cab_time')
```## The cab who stayed there
> Co-ordinates of the cab, and the time when it moved last
```
r.db('test').table('warehouse')
.filter({available: true})
.group('cab_lat', 'cab_lng', 'cab_time')
.count()
.ungroup()
.orderBy(r.desc('reduction'))
```>
## Apperance Defragmentation Graph (per cab)
> Not using this because it would result in a 44 x 897 matrix, which is too large to properly analyse in small screens (mobile devices).
```
r.db('test').table('warehouse')
.filter({available: true})
.group('cab_id')
.orderBy('index')
.pluck('index')
.distinct()
```## Cab which was spotted most
```
r.db('test').table('warehouse')
.filter({available: true})
.group('cab_id')
.orderBy('index')
.pluck('index')
.distinct()
.count()
.ungroup()
.orderBy(r.desc('reduction'))
```## Cab which travelled most
```
r.db('test').table('warehouse')
.filter({available: true})
.without('id', 'place_lat', 'place_lng', 'duration', 'distance')
.group('cab_id')
.pluck('cab_lat', 'cab_lng', 'index', 'timestamp')
.orderBy('index')
```## Cab distribution by location (per quarter-hour)
```
r.db('test').table('warehouse')
.filter({available: true})
.group('cab_id', 'index')
.nth(0)
.pluck('cab_id', 'index', 'timestamp', 'cab_lat', 'cab_lng',' type')
.ungroup()
.orderBy(r.row('reduction')('index'))
```## Cab density index
```
r.db('taxis').table('datacenter')
.filter({available: true})
.pluck('cab_lat', 'cab_lng')
.distinct()
.map(function(instance) {
return r.circle(centerPoint, 2, {unit: 'mi'})
.includes(r.point(instance('cab_lat'), instance('cab_lat')))
})
.count(true)
```## LICENSE
MIT © [Pravendra Singh](http://pravj.github.io)