├── upc.rb └── README.md /upc.rb: -------------------------------------------------------------------------------- 1 | #encode utf-8 2 | 3 | def upc_count() 4 | 5 | ori_data = read_file("game_log.tsv") 6 | data = ori_data 7 | data = data.split(/\n/) 8 | data.shift 9 | 10 | captured = [] 11 | upc = [] 12 | all_upv = [] 13 | upv = [] 14 | 15 | data.map do |x| 16 | i = x.split(/\t/) 17 | if i[3] == "captured portal" 18 | captured.push([i[0],i[1],i[2]]) 19 | end 20 | if ['hacked friendly portal','created link','mod deployed','resonator deployed','hacked enemy portal','resonator upgraded'].index(i[3]) 21 | all_upv.push([i[0],i[1],i[2]]) 22 | end 23 | end 24 | 25 | upc = captured.uniq { |x| [x[1], x[2]] } 26 | upv = all_upv.uniq { |x| [x[1], x[2]] } 27 | 28 | printf "Unique Portals Captured: #{upc.length}" 29 | printf "Unique Portals Visited: #{upv.length}" 30 | 31 | 32 | # draw_upc = '[' 33 | draw = '[' 34 | 35 | google_upc_map = [] 36 | upc_map = upc.each_slice(2000) 37 | upc_map.each_with_index do |data,i| 38 | google_upc_map[i] = "timestamp,latitude,longitude\r" 39 | data.each do |x| 40 | draw << "{\"type\":\"marker\",\"latLng\":{\"lat\":#{x[1]},\"lng\":#{x[2]}},\"color\":\"#246bce\"}," 41 | google_upc_map[i] << "#{x[0]}\,#{x[1]}\,#{x[2]}\r" 42 | end 43 | write_file("upc_map_#{i}.csv",google_upc_map[i]) 44 | end 45 | 46 | upv_map = upv.each_slice(50000) 47 | #upv_map = upv # put all upv in one file 48 | google_upv_map = [] 49 | upv_map.each_with_index do |data, i| 50 | google_upv_map[i] = "timestamp,latitude,longitude\r" 51 | data.each do |x| 52 | draw << "{\"type\":\"marker\",\"latLng\":{\"lat\":#{x[1]},\"lng\":#{x[2]}},\"color\":\"#1aff00\"}," 53 | google_upv_map[i] << "#{x[0]}\,#{x[1]}\,#{x[2]}\r" 54 | end 55 | write_file("upv_map_#{i}.csv",google_upv_map[i]) 56 | end 57 | 58 | draw.chop! 59 | draw << ']' 60 | write_file("draw_out.txt",draw) 61 | 62 | end 63 | 64 | def read_file(file_name) 65 | file = File.open(file_name, "r") 66 | data = file.read 67 | file.close 68 | return data 69 | end 70 | 71 | def write_file(file_name, text) 72 | File.open(file_name, 'w') { |file| file.write(text) } 73 | end 74 | 75 | upc_count() 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ingress UPC&UPV map 2 | 3 | A simple Ruby tool that parses Ingress **game_log.tsv** and generates UPC / UPV datasets for mapping and visualization. 4 | 5 | 数据来自于你向privacy@nianticspatial.com写信要求获取你的personal data, 度过不知道多少天之后他们会回信一个Google Drive文件,下载解压. 6 | 7 | 下面是写信模板,记得替换ID和邮箱 8 | 9 | ```text 10 | 11 | Dear Niantic Privacy Team, 12 | 13 | Please provide me with a copy of all personal data that Niantic Spatial holds about me. 14 | 15 | Here are my details for verification: 16 | 17 | Agent ID: {YOUR_AGENT_ID} 18 | 19 | Email Address associated with the account:{YOUR_EMAIL_ADDRESS} 20 | 21 | Please let me know if you require any additional information to verify my identity or process this request. 22 | 23 | Thank you for your time and assistance. 24 | 25 | Kind regards, 26 | 27 | (Your name here if needed) 28 | 29 | ``` 30 | 31 | --- 32 | 33 | ## How to use 34 | 35 | 1. 将 `upc.rb` 与 **game_log.tsv** 放在同一个目录下 36 | (⚠️ 注意:**portal_history.tsv 不支持**,其中包含奇怪或不完整记录,会导致分类错误。) 37 | 2. 运行: 38 | 39 | ```bash 40 | ruby upc.rb 41 | ``` 42 | 3. 执行完成后,会生成以下文件: 43 | 文件名 用途 44 | 45 | | 文件名|用途| 46 | | ---------------------------- | ---------------------------------------------------------------------- | 47 | | **draw\_out.txt** | 可导入 IITC Draw Tools。⚠️ 大量数据会导致浏览器卡死,慎用。 | 48 | | **upc\_map\_\*.csv** | 所有 Unique Portal Capture(UPC)坐标,自动切片(每片 ≤ 2000 行)。 | 49 | | **upv\_map\_0.csv** | 所有 Unique Portal Visit(UPV)坐标。 | 50 | 51 | 52 | 53 | --- 54 | 55 | ## Mapping Options 56 | 57 | ✔ 推荐:使用 Mapbox Studio(非常方便) 58 | 59 | 导入 Google My Maps 十分麻烦:每次最多上传 2000 行,还需要手动分图层。 60 | 相比之下,Mapbox Studio 可以一次性导入所有 CSV,体验更好。 61 | 62 | 这是我实际使用的 Mapbox 地图示例: 63 | 64 | 👉 https://api.mapbox.com/styles/v1/tolves/cmi0au74o002701sb2yfo9tgm.html?title=view&access_token=pk.eyJ1IjoidG9sdmVzIiwiYSI6ImNtaTBhZnBpaTBjYmQyaXNmbm90eTlvenYifQ.0IaPI_1QiHNGEhz0kim42A&zoomwheel=true&fresh=true#2/38/-34 65 | 66 | 在 Mapbox Studio 中: 67 | 68 | 1. 新建 Dataset 69 | 2. 直接拖入 upv_map_0.csv 或多个 upc_map_*.csv 70 | 3. 应用样式并发布即可 71 | 72 | 对比Google MyMap优点: 73 | 74 | 1. 支持一次导入大量数据 75 | 2. 标记渲染性能比 IITC / MyMaps 都强 76 | 3. 可以自定义颜色、样式、过滤器 77 | 4. 可在线分享地图(不需要登录 Google) 78 | 79 | --- 80 | 81 | ## What the script does 82 | 83 | - 读取 game_log.tsv 84 | - 根据动作类型识别: 85 | - UPC = captured portal 86 | - UPV = hack / deploy / upgrade / link / mod 等非 capture 互动 87 | - 自动根据坐标去重(每个 portal 只保留一次) 88 | - 输出 CSV(便于 GIS 和地图工具) 89 | - 生成 IITC Draw Tools JSON 90 | 91 | --- 92 | 93 | ## Notes 94 | 95 | * ​**不要使用 portal\_history.tsv**​,其中包含无效或损坏记录,会导致分类错误。 96 | * `draw_out.txt` 导入 IITC 时,大量数据(>20k)会导致页面卡死或崩溃。 97 | 98 | --------------------------------------------------------------------------------