msewage-importer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +38 -10
- data/class-diagram.jpg +0 -0
- data/lib/msewage-importer/api.rb +9 -9
- data/lib/msewage-importer/geolocator.rb +2 -0
- data/lib/msewage-importer/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -12,14 +12,16 @@ kind of source at a time.
|
|
12
12
|
$ msewage-importer --type [source_type] --source [source.json]
|
13
13
|
|
14
14
|
Currently, the following source types are supported:
|
15
|
+
* animal_manure
|
16
|
+
* combined_sewer_outflow
|
17
|
+
* industrial_waste_outflow
|
18
|
+
* latrine
|
15
19
|
* open_defecation_site
|
20
|
+
* open_sewage_canal_or_puddle
|
21
|
+
* raw_sewage_outflow
|
22
|
+
* septic_tank_cesspool
|
16
23
|
* toilet
|
17
|
-
*
|
18
|
-
* septic_tank
|
19
|
-
* sewage_outflow
|
20
|
-
* manure
|
21
|
-
* industrial_waste
|
22
|
-
* open_sewage
|
24
|
+
* treatment_plant_outflow
|
23
25
|
|
24
26
|
## Help
|
25
27
|
|
@@ -27,24 +29,50 @@ Currently, the following source types are supported:
|
|
27
29
|
|
28
30
|
## Type of data supported
|
29
31
|
|
30
|
-
At this moment, only JSON data sources are supported. These sources should conform to the
|
32
|
+
At this moment, only JSON and CSV data sources are supported. These sources should conform to the
|
31
33
|
following format [mSewage API](http://data.mwater.co/msewage/apiv2#2)
|
32
34
|
|
35
|
+
The entries might already be geocoded. If they aren't, we will attempt to do so.
|
36
|
+
|
37
|
+
The data might come from a script like [this one](https://github.com/tlevine/pri-toilet-hackers).
|
38
|
+
|
39
|
+
### JSON
|
33
40
|
```json
|
34
41
|
{
|
35
42
|
"sources": [
|
36
43
|
{
|
44
|
+
// Type with a location string that will be geocoded
|
37
45
|
"name": "optional",
|
38
|
-
"
|
39
|
-
"location": "location string.
|
46
|
+
"desc": "optional",
|
47
|
+
"location": "location string. "
|
40
48
|
},
|
49
|
+
{
|
50
|
+
// Type that will not be geocoded
|
51
|
+
"name": "optional",
|
52
|
+
"desc": "optional",
|
53
|
+
"latitude": 0.00000,
|
54
|
+
"longitude": 0.00000
|
55
|
+
}
|
41
56
|
...
|
42
57
|
]
|
43
58
|
}
|
59
|
+
```
|
60
|
+
|
61
|
+
### CSV
|
44
62
|
|
63
|
+
```csv
|
64
|
+
name,desc,location
|
65
|
+
Optional name,Optional description,"Some place, some town, some country"
|
45
66
|
```
|
46
67
|
|
47
|
-
|
68
|
+
or
|
69
|
+
|
70
|
+
```csv
|
71
|
+
name,desc,latitude,longitude
|
72
|
+
Optional name,Optional description,0.0000,0.0000
|
73
|
+
```
|
74
|
+
|
75
|
+
The heading row is *required*.
|
48
76
|
|
49
77
|
## Contributing
|
50
78
|
|
data/class-diagram.jpg
ADDED
Binary file
|
data/lib/msewage-importer/api.rb
CHANGED
@@ -8,7 +8,7 @@ module Msewage::Importer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def insert(record)
|
11
|
-
res = HTTParty.put(new_source_url, body
|
11
|
+
res = HTTParty.put(new_source_url, :body => new_source_body(record))
|
12
12
|
!res["code"].nil?
|
13
13
|
print "."
|
14
14
|
end
|
@@ -21,12 +21,12 @@ module Msewage::Importer
|
|
21
21
|
|
22
22
|
def new_source_body(record)
|
23
23
|
{
|
24
|
-
created_by
|
25
|
-
desc
|
26
|
-
latitude
|
27
|
-
longitude
|
28
|
-
name
|
29
|
-
source_type
|
24
|
+
:created_by => user_name,
|
25
|
+
:desc => record["desc"] || record["description"],
|
26
|
+
:latitude => record["latitude"] || record["lat"],
|
27
|
+
:longitude => record["longitude"] || record["lon"],
|
28
|
+
:name => record["name"],
|
29
|
+
:source_type => record["source_type"]
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
@@ -35,9 +35,9 @@ module Msewage::Importer
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def retrieve_client_uid
|
38
|
-
body = { password
|
38
|
+
body = { :password => password }
|
39
39
|
path = "#{api_endpoint}/users/#{user_name}"
|
40
|
-
res = HTTParty.post(path, body
|
40
|
+
res = HTTParty.post(path, :body => body)
|
41
41
|
res["clientuid"]
|
42
42
|
end
|
43
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msewage-importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: geocoder
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- Rakefile
|
205
205
|
- WestBengal_2005.aspx.json
|
206
206
|
- bin/msewage-importer
|
207
|
+
- class-diagram.jpg
|
207
208
|
- config/config-example.yml
|
208
209
|
- lib/msewage-importer.rb
|
209
210
|
- lib/msewage-importer/api.rb
|