Hello
Is there any way to split this array into lat/lon?
Thanks!
gross but works. will try a better way sometime in future
import "strings"
owners = from(bucket: "mister")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "unit")
|> filter(fn: (r) => r["_field"] == "friendly_name")
|> keep(columns: ["_time", "_value", "_field"])
locations = from(bucket: "mister")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "unit")
|> filter(fn: (r) => r["_field"] == "Location_str")
|> keep(columns: ["_time", "_value", "_field"])
geo = locations
|> map(fn: (r) => ({ r with geoloc:(string(v: r._value)) }))
x = geo
|> map(fn: (r) => {
clean = strings.replace(v: r.geoloc, t: "[", u: "", i: 2)
final = strings.replace(v: clean, t: "]", u: "", i: 2)
parts = strings.split(v: final, t: ",")
return { time: r["_time"], lat: parts[0], lon: parts[1]}
})
union(tables: [owners, x])