Guest User

Untitled

a guest
Nov 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. //
  2. // Cheapest fuel station near here with hhcode and use haversine to limit distance
  3. //
  4.  
  5. // Le Val Martin
  6. //43.6214252,7.022854
  7. // Les Cabots
  8. //43.6260146,7.1063278
  9. // Le Fournel
  10. //43.5749417,7.1028818
  11. // Le Cannet
  12. //43.5745511,6.983477
  13.  
  14. // Sophia-Antipolis - Hôtel Ibis
  15. //43.620, 7.057
  16.  
  17. 'POLYGON ((7.023 43.621, 7.106 43.626, 7.103 43.575, 6.983 43.574, 7.023 43.621))' 0.01 false GEO.WKT
  18. GEO.REGEXP '~(' SWAP + ')' +
  19. 'regexp' STORE
  20.  
  21. [ 'READ' 'data.fuel' { 'type' 'gazole' 'loc' $regexp } NOW -1 ] FETCH 'data' STORE
  22. $data
  23.  
  24. NOW ISO8601
  25. '2017-11-01T00:00:00.000000Z'
  26. TIMECLIP
  27. NONEMPTY
  28.  
  29. [ SWAP
  30. <%
  31. // Extract lat + lon
  32. [ 3 7 ] SUBLIST FLATTEN DUP
  33. [ 1 2 ] SUBLIST LIST-> DROP
  34. 43.620 7.057
  35. HAVERSINE 'dist' STORE
  36. <% $dist 5000.0 > %>
  37. <% NULL 4 SET %>
  38. IFT
  39. %> MACROMAPPER 0 0 0
  40. ] MAP NONEMPTY
  41.  
  42. [ SWAP
  43. bucketizer.min
  44. NOW
  45. 0 //31536000000000
  46. 1
  47. ] BUCKETIZE
  48.  
  49. [ SWAP
  50. []
  51. reducer.min
  52. ] REDUCE
  53. [ SWAP mapper.tostring 0 0 0 ] MAP
  54.  
  55. // Get station value and its metadata (Name of the station)
  56. //IST-> DROP [ SWAP LOCATIONS ] FLATTEN LIST-> DROP ->HHCODE 'hfilter' STORE
  57. //[ $data [ ] { 'loc' $hfilter } filter.byattr ] FILTER
Add Comment
Please, Sign In to add comment