refactored
This commit is contained in:
parent
471dbad6aa
commit
f039d394a5
12 changed files with 29 additions and 23 deletions
|
|
@ -1,3 +0,0 @@
|
||||||
## 1.0.0
|
|
||||||
|
|
||||||
- Initial version.
|
|
||||||
16
README.md
16
README.md
|
|
@ -1,8 +1,12 @@
|
||||||
# WhatFreeWords
|

|
||||||
|
|
||||||
|
# Map3Terms
|
||||||
|
|
||||||
[](http://www.wtfpl.net/)
|
[](http://www.wtfpl.net/)
|
||||||
|
|
||||||
This is the Dart port of the original [JavaScript implementation](https://github.com/pballett/whatfreewords) that was published as a small test to show how one might reversibly map each ~1m² element of the globe onto a 3-tuple of words.
|
This is the Dart port of the original [JavaScript implementation](https://github.com/pballett/map3terms) of a small but ingenious test to show how one might reversibly map roughly each square meter of the globe onto a 3-tuple of words using a simplified symmetric encryption method called [Feistel cipher](https://en.wikipedia.org/wiki/Feistel_cipher).
|
||||||
|
|
||||||
|
It seems inspired by the existing proprietary geocoding service [What3Words](https://wiki.openstreetmap.org/wiki/What3words) but uses a completely different method and list of words.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
@ -10,15 +14,15 @@ In your Flutter/Dart `pubspec.yaml` file include
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
whatfreewords:
|
map3terms:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/randogoth/whatfreewords.git
|
url: https://github.com/randogoth/map3terms.git
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
import 'package:whatfreewords/whatfreewords.dart';
|
import 'package:map3terms/map3terms.dart';
|
||||||
|
|
||||||
// coordinate to wfw
|
// coordinate to wfw
|
||||||
final List<double> coord = [51.50844113, -0.116708278];
|
final List<double> coord = [51.50844113, -0.116708278];
|
||||||
|
|
@ -30,7 +34,7 @@ final coords = wordsToCoord(words);
|
||||||
print(coords); // [51.5084, -0.1167]
|
print(coords); // [51.5084, -0.1167]
|
||||||
```
|
```
|
||||||
|
|
||||||
Check it out [here](https://pballett.github.io/whatfreewords/).
|
Check it out [here](https://pballett.github.io/map3terms/).
|
||||||
|
|
||||||
To do this we needed three things:
|
To do this we needed three things:
|
||||||
1. A function which maps metre-accurate (latitude, longitude) pairs into three 5-digit integers below 40k.
|
1. A function which maps metre-accurate (latitude, longitude) pairs into three 5-digit integers below 40k.
|
||||||
|
|
|
||||||
BIN
bunny.png
Normal file
BIN
bunny.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
11
example/map3terms_example.dart
Normal file
11
example/map3terms_example.dart
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import 'package:map3terms/map3terms.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
List<double> coordinate = [51.50844113, -0.116708278];
|
||||||
|
|
||||||
|
String words = await coordToWords(coordinate);
|
||||||
|
print("Words: $words");
|
||||||
|
|
||||||
|
List<double> backToCoord = await wordsToCoord(words);
|
||||||
|
print("Coordinates: ${backToCoord[0]}, ${backToCoord[1]}");
|
||||||
|
}
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import 'package:whatfreewords/whatfreewords.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
var awesome = Awesome();
|
|
||||||
print('awesome: ${awesome.isAwesome}');
|
|
||||||
}
|
|
||||||
3
lib/map3terms.dart
Normal file
3
lib/map3terms.dart
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
library map3terms;
|
||||||
|
|
||||||
|
export 'src/map3terms_scrambler.dart';
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'whatfreewords_cipher.dart';
|
import 'map3terms_map.dart';
|
||||||
|
|
||||||
final Map<String, String> ilist =
|
final Map<String, String> ilist =
|
||||||
wlist.map((key, value) => MapEntry(value, key));
|
wlist.map((key, value) => MapEntry(value, key));
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
library whatfreewords;
|
|
||||||
|
|
||||||
export 'src/whatfreewords_scrambler.dart';
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
name: whatfreewords
|
name: map3terms
|
||||||
description: A library for converting coordinates to words and back using a Feistel network.
|
description: A library for converting coordinates to words and back using a Feistel network.
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
homepage: https://github.com/randogoth/whatfreewords
|
homepage: https://github.com/randogoth/map3terms
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.0 <3.0.0'
|
sdk: '>=2.17.0 <3.0.0'
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:whatfreewords/whatfreewords.dart';
|
import 'package:map3terms/map3terms.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
|
|
||||||
group('WhatFreeWords Tests', () {
|
group('map3terms Tests', () {
|
||||||
test('Coordinate to Words and Back', () async {
|
test('Coordinate to Words and Back', () async {
|
||||||
final List<double> coord = [51.50844113, -0.116708278];
|
final List<double> coord = [51.50844113, -0.116708278];
|
||||||
final words = await coordToWords(coord);
|
final words = await coordToWords(coord);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue