Skip to content

Commit e6e3560

Browse files
committed
add google_polyline_algorithm proj
1 parent a33f056 commit e6e3560

12 files changed

+495
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Files and directories created by pub
2+
.dart_tool/
3+
.packages
4+
# Remove the following pattern if you wish to check in your lock file
5+
pubspec.lock
6+
7+
# Conventional directory for build outputs
8+
build/
9+
10+
# Directory created by dartdoc
11+
doc/api/

AUTHORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the MarchDev Toolkit projects. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
MarchDev Toolkit <eo.march.dev@gmail.com>
7+
- Oleh Marchenko <oleh.marchenko.95@gmail.com>
8+
- Elena Marchenko <eo.marchenko96@gmail.com>

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 1.0.0
2+
3+
* Added `encodePoint`, `encodePolyline` and `decodePolyline` methods
4+
* Added Examples
5+
* Added Tests

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# google_polyline_algorithm
2+
3+
![Build](https://github.com/marchdev-tk/google_polyline_algorithm/workflows/build/badge.svg)
4+
[![codecov](https://codecov.io/gh/marchdev-tk/google_polyline_algorithm/branch/master/graph/badge.svg)](https://codecov.io/gh/marchdev-tk/google_polyline_algorithm)
5+
[![Pub](https://img.shields.io/pub/v/google_polyline_algorithm.svg)](https://pub.dartlang.org/packages/google_polyline_algorithm)
6+
![GitHub](https://img.shields.io/github/license/marchdev-tk/google_polyline_algorithm)
7+
![GitHub stars](https://img.shields.io/github/stars/marchdev-tk/google_polyline_algorithm?style=social)
8+
9+
Dart implementation of Googles Polyline Encoding lossy compression Algorithm.
10+
11+
## Getting Started
12+
13+
This package adds following methods to work with Googles Polyline Encoding Algorithm:
14+
15+
* `encodePoint(num current, {num previous = 0, int accuracyExponent = 5})` encodes a single coordinate
16+
17+
* `encodePolyline(List<List<num>> coordinates, {int accuracyExponent = 5})` encodes a list of coordinates into an encoded polyline stirng
18+
19+
* `decodePolyline(String polyline, {int accuracyExponent = 5})` decodes an encoded polyline string into a list of coordinates
20+
21+
## Examples
22+
23+
```dart
24+
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
25+
26+
final coord = encodePoint(-179.9832104);
27+
print(coord);
28+
// output is `~oia@'
29+
30+
final coords = encodePolyline([
31+
[38.5, -120.2],
32+
[40.7, -120.95],
33+
[43.252, -126.453],
34+
]);
35+
print(coords);
36+
// output is `_p~iF~ps|U_ulLnnqC_mqNvxq`@'
37+
38+
final polyline = decodePolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
39+
print(polyline);
40+
// output is [[38.5, -120.2],[40.7, -120.95],[43.252, -126.453],]
41+
```

analysis_options.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Defines a default set of lint rules enforced for
2+
# projects at Google. For details and rationale,
3+
# see https://github.com/dart-lang/pedantic#enabled-lints.
4+
include: package:pedantic/analysis_options.1.8.0.yaml
5+
6+
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
7+
# Uncomment to specify additional rules.
8+
# linter:
9+
# rules:
10+
# - camel_case_types
11+
12+
# analyzer:
13+
# exclude:
14+
# - path/to/excluded/files/**

example/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# google_polyline_algorithm_example
2+
3+
Demonstrates how to use the google_polyline_algorithm package.
4+
5+
## Usage
6+
7+
```dart
8+
void main() {
9+
final coord = encodePoint(-179.9832104);
10+
print(coord);
11+
// output is `~oia@'
12+
13+
final coords = encodePolyline([
14+
[38.5, -120.2],
15+
[40.7, -120.95],
16+
[43.252, -126.453],
17+
]);
18+
print(coords);
19+
// output is `_p~iF~ps|U_ulLnnqC_mqNvxq`@'
20+
21+
final polyline = decodePolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
22+
print(polyline);
23+
// output is [[38.5, -120.2],[40.7, -120.95],[43.252, -126.453],]
24+
}
25+
```
26+
27+
28+
## Getting Started
29+
30+
For help getting started with Dart, view
31+
[online documentation](https://dart.dev/docs), which offers tutorials,
32+
samples, guidance, and a full API reference.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
2+
3+
void main() {
4+
final coord = encodePoint(-179.9832104);
5+
print(coord);
6+
// output is `~oia@'
7+
8+
final coords = encodePolyline([
9+
[38.5, -120.2],
10+
[40.7, -120.95],
11+
[43.252, -126.453],
12+
]);
13+
print(coords);
14+
// output is `_p~iF~ps|U_ulLnnqC_mqNvxq`@'
15+
16+
final polyline = decodePolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
17+
print(polyline);
18+
// output is [[38.5, -120.2],[40.7, -120.95],[43.252, -126.453],]
19+
}

lib/google_polyline_algorithm.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) 2020, the MarchDev Toolkit project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library google_polyline_algorithm;
6+
7+
export 'src/google_polyline_algorithm.dart';

0 commit comments

Comments
 (0)