SHARE
TWEET

Untitled

a guest Jun 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var jsonData = "./data/tracking.json";
  2.      
  3. var outGeoJson = {}
  4. outGeoJson['properties'] = jsonData
  5. outGeoJson['type']= "Feature"
  6. outGeoJson['geometry']= {"type": "Point", "coordinates":
  7.     [jsonData['lat'], jsonData['lon']]}
  8.  
  9. console.log(outGeoJson)
  10.      
  11. var geojson = {
  12.   type: "FeatureCollection",
  13.   features: [],
  14. };
  15.  
  16. for (i = 0; i < jsonData.positions.length; i++) {
  17.   if (window.CP.shouldStopExecution(1)) {
  18.     break;
  19.   }
  20.   geojson.features.push({
  21.     "type": "Feature",
  22.     "geometry": {
  23.       "type": "Point",
  24.       "coordinates": [jsonData.positions[i].longitude, jsonData.positions[i].latitude]
  25.     },
  26.     "properties": {
  27.       "report_at": jsonData.positions[i].report_at,
  28.       "lat": jsonData.positions[i].lat,
  29.       "lon": jsonData.positions[i].lon,
  30.       "dir": jsonData.positions[i].dir,
  31.       "first": jsonData.positions[i].first,
  32.       "last": jsonData.positions[i].last
  33.     }
  34.   });
  35. }
  36.  
  37. window.CP.exitedLoop(1);
  38.  
  39. console.log(geojson)
  40.      
  41. {
  42.   "positions": [
  43.     {
  44.       "report_at": "2015-01-21 21:00:08",
  45.       "lat": "38.9080658",
  46.       "lon": "-77.0030365",
  47.       "elev": "0",
  48.       "dir": "0",
  49.       "gps": "0",
  50.       "callsign": "WX2DX",
  51.       "email": "",
  52.       "phone": "",
  53.       "ham": "WX2DX",
  54.       "ham_show": "0",
  55.       "freq": "",
  56.       "note": "",
  57.       "im": "",
  58.       "twitter": null,
  59.       "web": "",
  60.       "unix": "1421874008",
  61.       "first": "William",
  62.       "last": "Smith",
  63.       "marker": "36181"
  64.     }
  65.   ]
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top