Sorry guys. I hate reporting issues.
This one worked in previous versions of AM. But now does not work in AM4.1.5 or beta AM4.2x I will need to investigate when it started to hung and revert.
I know the code is good and both json's are good.
This code works with a shortened json DB but hangs with a 111589kb json. It never used to. It used to take about 2 to 3 minutes before the persistence file was written and available in the folder.
Of course the data is available when in code. No problem there. Just the write to the persistence file and hanging of AM.
Code: Select all
obstical=static_data_load("usa_obstacle_wip_bu2.json")
new_obstacle = persist_add("obstacle", {})
obs_table={}
if obstical~= nil then
print("Static Data loaded")
for i=1,#obstical["feature"] do
-- This is pattern, which describes what we expect the string to look like
local pattern = "^(%d+) (%d+) (%d+).(%d+)([NSEW])$"
lat_str = obstical["feature"][i]["lat_dmsh"]
lon_str = obstical["feature"][i]["lon_dmsh"]
-- Try to match the string with the pattern
local lat_deg, lat_min, lat_sec, lat_secd,lat_dir = string.match(lat_str, pattern)
local lon_deg, lon_min, lon_sec, lon_secd,lon_dir = string.match(lon_str, pattern)
-- Convert the string with the pattern to Decimal
local lat = lat_deg + (lat_min / 60) + (tonumber(lat_sec.."."..lat_secd) / 3600)
local lon = lon_deg + (lon_min / 60) + (tonumber(lon_sec.."."..lon_secd) / 3600)
lat = fif(lat_dir == "S" or lat_dir == "W", lat * -1, lat)
lon = fif(lon_dir == "S" or lon_dir == "W", lon * -1, lon)
-- Apply the Decimal conversion to the table
obstical["feature"][i]["laty"]=lat
obstical["feature"][i]["lonx"]=lon
table.insert(obs_table,obstical["feature"][i])
end
print("latY & lonx done")
-- Create the Persistence table
persist_put(new_obstacle,obs_table)
end
print("All Done")
it produces a .json like this...Extracting obstacle data and other data from a static obstacle data set. And I can change any element I need and store to this persistence file.
Code: Select all
[{
"key": "obstacle",
"value": [{
"lonx": -88.077500,
"lon_dmsh": "088 04 39.00W",
"obs_qty": 1,
"marking": "M",
"obstacle": "RIG",
"lighting": "R",
"amsl_height": 236,
"lat_dmsh": "30 10 45.00N",
"agl_height": 236,
"laty": 30.179167
}, {
"lonx": -88.120833,
"lon_dmsh": "088 07 15.00W",
"obs_qty": 1,
"marking": "M",
"obstacle": "RIG",
"lighting": "R",
"amsl_height": 241,
"lat_dmsh": "30 11 20.00N",
"agl_height": 240,
"laty": 30.188889
}, {
"lonx": -87.952778,
"lon_dmsh": "087 57 10.00W",
"obs_qty": 1,
"marking": "M",
"obstacle": "STACK",
"lighting": "R",
"amsl_height": 193,
"lat_dmsh": "30 11 20.00N",
"agl_height": 193,
"laty": 30.188889
}, {
"lonx": -87.873611,
"lon_dmsh": "087 52 25.00W",
"obs_qty": 1,
"marking": "N",
"obstacle": "BLDG",
"lighting": "R",
"amsl_height": 242,
"lat_dmsh": "30 13 49.00N",
"agl_height": 223,
"laty": 30.230278
}, {
"lonx": -87.875000,
"lon_dmsh": "087 52 30.00W",
"obs_qty": 1,
"marking": "N",
"obstacle": "BLDG",
"lighting": "R",
"amsl_height": 242,
"lat_dmsh": "30 13 49.00N",
"agl_height": 223,
"laty": 30.230278
}, {
"lonx": -87.866986,
"lon_dmsh": "087 52 01.15W",
"obs_qty": 1,
"marking": "N",
"obstacle": "TOWER",
"lighting": "D",
"amsl_height": 288,
"lat_dmsh": "30 14 14.57N",
"agl_height": 277,
"laty": 30.237381
}, {
"lonx": -87.747500,
"lon_dmsh": "087 44 51.00W",
"obs_qty": 1,
"marking": "N",
"obstacle": "BLDG",
"lighting": "D",
"amsl_height": 214,
"lat_dmsh": "30 14 27.00N",
"agl_height": 208,
"laty": 30.240833
}, {
"lonx": -87.703389,
"lon_dmsh": "087 42 12.20W",
"obs_qty": 1,
"marking": "N",
"obstacle": "BLDG",
"lighting": "N",
"amsl_height": 67,
"lat_dmsh": "30 14 43.32N",
"agl_height": 59,
"laty": 30.245367
}, {
"lonx": -87.701947,
"lon_dmsh": "087 42 07.01W",
"obs_qty": 1,
"marking": "N",
"obstacle": "BLDG",
"lighting": "R",
"amsl_height": 282,
"lat_dmsh": "30 14 44.06N",
"agl_height": 271,
"laty": 30.245572
}]
}]