Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[geomesa-users] Convert JSON epoch milliseconds time to dtg

I am reading in JSON data and trying to create records in HBASE for every JSON record I read in.  


The data I read in has a Lat, Long  fields defined as Float and a time field (PosTime) in epoch milliseconds.  I have had issues trying to read the time value field PosTime in order to create a dtg field.  


An example JSON record I read in is:


{"Id":11030911,"Rcvr":1001132,"HasSig":true,"Sig":14,"Icao":"A8517F","Bad":false,"Reg":"N635ND","FSeen":"\/Date(1523142698672)\/","TSecs":3595,"CMsgs":21097,"Alt":1500,"GAlt":1346,"InHg":29.7663422,"AltT":0,"TAlt":2592,"Call":"NDU635","Lat":33.312687,"Long":-111.670793,"PosTime":1523146232271,"Mlat":false,"Tisb":false,"Spd":3.5,"Trak":225.0,"TrkH":false,"Type":"C172","Mdl":"2013 CESSNA 172S","Man":"Cessna","CNum":"172S11294","Op":"UND AEROSPACE FOUNDATION     - GRAND FORKS, ND","Sqk":"1466","Help":false,"Vsi":0,"VsiT":1,"WTC":1,"Species":1,"Engines":"1","EngType":1,"EngMount":0,"Mil":false,"Cou":"United States","HasPic":false,"Interested":false,"FlightsCount":0,"Gnd":false,"SpdTyp":0,"CallSus":false,"ResetTrail":true,"TT":"a","Trt":5,"Year":"2013","Cos":[33.312927,-111.67012,1523146201927.0,1500.0,33.312996,-111.670299,1523146207177.0,1500.0,33.312968,-111.670448,1523146211677.0,1500.0,33.312939,-111.670477,1523146212787.0,1500.0,33.31287,-111.67056,1523146216537.0,1500.0,33.312801,-111.670642,1523146219662.0,1500.0,33.312712,-111.670756,1523146226130.0,1500.0,33.312687,-111.670779,1523146231412.0,1500.0,33.312687,-111.670793,1523146232271.0,1500.0]}

My converter setup is as follows:


geomesa {
  sfts {
  ads-b = {
  type-name = "adsb"
  fields = [
  { name = Rcvr,          type = Integer }
  { name = HasSig,          type = Boolean }
  { name = Icao,          type = String, index = true  }
  { name = PosTime,          type = String }
  { name = Mlat,          type = Boolean }
  { name = Tisb,          type = Boolean }
  { name = Spd,          type = Double }
  { name = Trak,          type = Double }
  { name = TrkH,          type = Boolean }
  { name = Type,          type = String }
  { name = CNum,          type = String }
  { name = From,          type = String }
  { name = To,          type = String }
  { name = TT,          type = String }
  { name = Trt,          type = Integer }
  { name = Year,          type = String }
  { name = Lat,          type = Double }
  { name = Long,         type = Double }
  { name = geom,         type = Point, srid = 4326}
  { name = dtg, type = Date }
]
user-data = "">
  geomesa.table.sharing = "false"
}
}

}

converters = {
ads-b = {
type = json
feature-path = "$.acList[*]"
id-field ="$Icao"
options = {
line-mode = "multi"
error-mode = "raise-errors"
validators = ["has-geo"]
}
fields = [
{ name = Rcvr,          json-type = "integer" , path = "$.Rcvr"}
{ name = HasSig,          json-type = "boolean",  path = "$.HasSig" }
{ name = Icao,          json-type = "string",  path = "$.Icao"}
{ name = PosTime,   json-type = "integer", path = "$.PosTime" }
{ name = Mlat,          json-type = "boolean",  path = "$.Mlat"  }
{ name = Tisb,          json-type = "boolean",  path = "$.Tisb"  }
{ name = Spd,          json-type = "double",  path = "$.Spd"  }
{ name = Trak,          json-type = "double",  path = "$.Trak"  }
{ name = TrkH,          json-type = "boolean",  path = "$.TrkH"  }
{ name = CNum,          json-type = "string",  path = "$.CNum"  }
{ name = From,          json-type = "string",  path = "$.From"  }
{ name = To,          json-type = "string",  path = "$.To"  }
{ name = TT,          json-type = "string",  path = "$.TT"  }
{ name = Trt,          json-type = "integer",  path = "$.Trt"  }
{ name = Year,          json-type = "string",  path = "$.Year"  }
{ name = Lat,          json-type = "double",  path = "$.Lat" }
{ name = Long,          json-type = "double",  path = "$.Long" }
{ name = geom, transform = "point($Long, $Lat)" }
{ name = millis, json-type = "string", path = "$.PosTime"  }
{ name = dtg, json-type = "string", transform = "millisToDate(stringToLong($millis, 0L))" }
]
}
}
}

When I add the dtg value to the converter the time is always showing as 1970-01-01T00:00:00.000Z.  The Geometry ends up being zero'ed out and the PosTime field which supplies the epoch time and the Lat Long fields are empty.

Example:
424940,63081,false,424940,,,false,452.0,57.5,false,,4058,"LEBL Barcelona, Spain","UUEE Sheremetyevo, Moscow, Russia",a,2,2009,,,POINT (0 0),1970-01-01T00:00:00.000Z

If I remove dtg all together the records are all populated.

Thanks in advance.

Chris 





Back to the top