Skip to content
Compare
Choose a tag to compare
@cole-brokamp cole-brokamp released this 10 Sep 17:31
fix json parsing error preventing container from working all together

using the `geocode()` function inside the script would fail because
ruby would also return a warning; for example:

```r
> geocode("224 Woolper Ave Cincinnati OH 45220")
Error: lexical error: invalid char in json text.
                                      /var/lib/gems/2.5.0/gems/Geocode
                     (right here) ------^

> addr_string <- "224 Woolper Ave Cincinnati OH 45220"
> system2('ruby',
+                    args = c('/root/geocoder/geocode.rb', shQuote(addr_string)),
+                    stderr=TRUE,stdout=TRUE)
[1] "/var/lib/gems/2.5.0/gems/Geocoder-US-2.0.4/lib/geocoder/us/database.rb:633: warning: constant ::Fixnum is deprecated"
[2] "[{\"street\":\"Woolper Ave\",\"zip\":\"45220\",\"city\":\"Cincinnati\",\"state\":\"OH\",\"lat\":39.150131,\"lon\":-84.515313,\"fips_county\":\"39061\",\"score\":0.947,\"prenum\":\"\",\"number\":\"224\",\"precision\":\"range\"}]"
```

this fix now only takes the second system/ruby output if its length is 2