Skip to content

Commit

Permalink
Add source code
Browse files Browse the repository at this point in the history
  • Loading branch information
lucka-me committed Apr 21, 2023
1 parent b5fae8d commit 7ad90e9
Show file tree
Hide file tree
Showing 18 changed files with 3,719 additions and 130 deletions.
135 changes: 5 additions & 130 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,130 +1,5 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.DS_Store
/node_modules
/bin
/build
/.pkg-cache
4 changes: 4 additions & 0 deletions .tokeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package.json
package-lock.json
tsconfig.json
*.md
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Ingress Drone Explorer - Node.js

[![Lines of code][nodejs-loc]][nodejs-repo]

An offline CLI tool to analyze reachable Portals for Ingress Drone Mark I.

Implementations in different languages are listed and compared in [Benchmark](#benchmark).

## Build from Source

### Requirements

- Node 18 (Backporting should be possible and easy)

### Build

```sh
$ npm init
$ npm run build
$ npm run package # Package an executable with pkg
```

Please notice the [`pkg`](https://github.com/vercel/pkg) will download necessary binary files to `~/.pkg-cache`, it may be overriden by environment variable `PKG_CACHE_PATH`:

```sh
$ export PKG_CACHE_PATH=./.pkg-cache
$ npm run package
```

## Exploration Guide

### Prepare Files

All the files should be JSON.

1. Portal list file(s), should be an array of:
```jsonc
{
"guid": "GUID of Portal",
"title": "Title of Portal",
"lngLat": {
"lng": 90.0, // Longitude
"lat": 45.0 // Latitude
}
}
```
2. Portal Key list file, should be an array of GUID (Not required but strongly recommended)

Maybe an IITC plugin like [this](https://github.com/lucka-me/toolkit/tree/master/Ingress/Portal-List-Exporter) helps.

### Usage

```
$ ingress-drone-explorer <portal-list-file> -s <longitude,latitude> [options...]
```

#### Options

Explore with key list:
```sh
$ ... -k <path-to-key-list-file>
```

Output cells JSON for IITC Draw tools:
```sh
$ ... --output-drawn-items <path-to-output>
```

Help information:
```sh
$ ingress-drone-explorer -h
```

## Benchmark

### Sample Data

- Area: Shenzhen downtown and Hong Kong
- Portals: 34,041 Portals in 13,451 cells
- Keys: 11 matched
- Start Point: Shenzhen Bay Sports Center
- Result: 30,462 Portals and 11,342 cells are reachable

### Result

Average exploration time consumed of 100 executions on MacBook Air (M2).

| Implementation | Lines of Code | Commit | Consumed
| ---------------------: | :-------------: | :---------------------------------: | :---
| [Node.js][nodejs-repo] | ![][nodejs-loc] | `Current` | 1.295 s
| [C++][cpp-repo] | ![][cpp-loc] | [`db5a976`][cpp-benchmark-commit] | 0.583 s
| [Swift][swift-repo] | ![][swift-loc] | [`68ae1b4`][swift-benchmark-commit] | 3.000 s

The results of other implementations may be outdated, please check their repositories for latest results.

[nodejs-repo]: https://github.com/lucka-me/ingress-drone-explorer-nodejs
[nodejs-loc]: https://img.shields.io/tokei/lines/github/lucka-me/ingress-drone-explorer-nodejs

[cpp-repo]: https://github.com/lucka-me/ingress-drone-explorer-cpp
[cpp-loc]: https://img.shields.io/tokei/lines/github/lucka-me/ingress-drone-explorer-cpp
[cpp-benchmark-commit]: https://github.com/lucka-me/ingress-drone-explorer-cpp/commit/db5a976

[swift-repo]: https://github.com/lucka-me/ingress-drone-explorer-swift
[swift-loc]: https://img.shields.io/tokei/lines/github/lucka-me/ingress-drone-explorer-swift
[swift-benchmark-commit]: https://github.com/lucka-me/ingress-drone-explorer-swift/commit/68ae1b4
Loading

0 comments on commit 7ad90e9

Please sign in to comment.