Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. import random
  2. import json
  3.  
  4. locations = {
  5. 'Chengdu': (30.5728, 104.0668),
  6. 'Beijing': (39.9042, 116.4074),
  7. 'Shanghai': (31.2304, 121.4737),
  8. 'Taipei': (25.0330, 121.5654),
  9. 'Dazhou': (31.2096, 107.4680),
  10. 'Hong Kong': (22.3193, 114.1694),
  11. 'Shenzhen': (22.5431, 114.0579),
  12. 'Tokyo': (35.6762, 139.6502),
  13. 'Seoul': (37.5665, 126.9780),
  14. 'Tibet': (30.1534, 88.7879),
  15. 'Hokkaido': (43.2203, 142.8635),
  16. 'Sapporo': (43.0618, 141.3545),
  17. 'Kyoto': (35.0116, 135.7681),
  18. 'Saigon': (10.8231, 106.6297),
  19. 'Hanoi': (21.0278, 105.8342),
  20. 'Bangkok': (13.7563, 100.5018),
  21. 'Vientiane': (17.9757, 102.6331),
  22. 'Macau': (22.1987, 113.5439),
  23. 'Hainan': (19.5664, 109.9497),
  24. 'Urumqi': (43.8256, 87.6168),
  25. 'Mumbai': (19.0760, 72.8777),
  26. 'Osaka': (34.6937, 135.5023),
  27. 'Chongqing': (29.4316, 106.9123),
  28. 'Jiuquan': (39.7329, 98.4945),
  29. 'Xian': (34.3416, 108.9398),
  30. 'Hangzhou': (30.2741, 120.1551),
  31. 'Guangzhou': (23.1291, 113.2664),
  32. 'Hohhot': (40.8424, 111.7500),
  33. 'Jinan:': (36.6512, 117.1201),
  34. 'Wuhan': (30.5928, 114.3055),
  35. 'Nanjing': (32.0603, 118.7969),
  36. 'Wenzhou': (27.9938, 120.6994),
  37. 'Fuzhou': (26.0745, 119.2965),
  38. 'Qingdao': (36.0671, 120.3826),
  39. 'Harbin': (45.8038, 126.5350),
  40. 'Mohe': (52.9723, 122.5386)
  41. }
  42.  
  43. names = [
  44. 'aaa ff',
  45. 'bbb',
  46. 'ccc gg',
  47. 'xxx v',
  48. 'tyt iiii eeee',
  49. 'sss lkop wgw',
  50. 'poppppppppp',
  51. 'kjkjkjkjkjkjkjkjkjkjk',
  52. 'zz xx cc vv',
  53. '一些中文',
  54. '长一些的句子哈哈',
  55. '再来一句更长很多很大的句子']
  56.  
  57. startTimes = [
  58. '1993-11-22',
  59. '1998-06-06',
  60. '1913-05-13',
  61. '1966-12-05',
  62. '1923-11-10',
  63. '1856-04-12',
  64. '1889-03-23',
  65. '1934-07-15'
  66. ]
  67.  
  68. types = [
  69. 'HISTORY_EVENT',
  70. 'PERSON',
  71. 'CHARACTER'
  72. ]
  73.  
  74. descriptions = [
  75. 'this is a description about something',
  76. 'lalala lalala lalala hahahahahahahaha',
  77. 'ooooooooops, that is messed up',
  78. 'the random data needs a really long description in order to take up as much space as it can',
  79. 'this time it will try to continue creating an even larger text to occupy even more space to check whether there will be any layout odds shownup on the page'
  80. ]
  81.  
  82. def toMapItem(indexAndLocation):
  83. index, location = indexAndLocation
  84. city, coordinate = location
  85. latitude = coordinate[0]
  86. longitude = coordinate[1]
  87. name = random.choice(names)
  88. startTime = random.choice(startTimes)
  89. itemType = random.choice(types)
  90. desc = random.choice(descriptions)
  91. return {
  92. 'id': str(index),
  93. 'name': name,
  94. 'type': itemType,
  95. 'location': {
  96. 'latitude': latitude,
  97. 'longitude': longitude,
  98. 'city': city
  99. },
  100. 'period': {
  101. 'startTime': startTime
  102. },
  103. 'options': {
  104. 'description': desc
  105. }
  106. }
  107.  
  108. mapItems = list(map(toMapItem, enumerate(list(locations.items()))))
  109. data = {
  110. 'mapItems': mapItems
  111. }
  112.  
  113. with open('randomDb.json', 'w', encoding='utf-8') as f:
  114. json.dump(data, f, ensure_ascii=False, indent=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement