added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
@@ -0,0 +1,2 @@
Jonas Hermsmeier <jhermsmeier@gmail.com>
Gonzalo Infante <chalo.infante01@gmail.com>
@@ -0,0 +1,20 @@
# The MIT License (MIT)
Copyright (c) 2016 Jonas Hermsmeier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
# google-polyline
[![npm](https://img.shields.io/npm/v/google-polyline.svg?style=flat-square)](https://npmjs.com/package/google-polyline)
[![npm license](https://img.shields.io/npm/l/google-polyline.svg?style=flat-square)](https://npmjs.com/package/google-polyline)
[![npm downloads](https://img.shields.io/npm/dm/google-polyline.svg?style=flat-square)](https://npmjs.com/package/google-polyline)
[![build status](https://img.shields.io/travis/jhermsmeier/node-google-polyline.svg?style=flat-square)](https://travis-ci.org/jhermsmeier/node-google-polyline)
Encodes and decodes [Google's polyline format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
## Install via [npm](https://npmjs.com)
```sh
$ npm install --save google-polyline
```
## Usage
```js
var polyline = require( 'google-polyline' )
```
```js
polyline.encode([
[ 38.5, -120.2 ],
[ 40.7, -120.95 ],
[ 43.252, -126.453 ]
])
> '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
```
```js
polyline.decode( '_p~iF~ps|U_ulLnnqC_mqNvxq`@' )
> [
[ 38.5, -120.2 ],
[ 40.7, -120.95 ],
[ 43.252, -126.453 ]
]
```
## Benchmarks
```sh
$ npm run benchmark
```
```
# decode: 3 points ⨉ 1000
ok ~9.03 ms (0 s + 9026482 ns)
# decode: ~350 points ⨉ 1000
ok ~34 ms (0 s + 33985497 ns)
# encode: 3 points ⨉ 1000
ok ~16 ms (0 s + 15696046 ns)
# encode: ~350 points ⨉ 1000
ok ~80 ms (0 s + 80340403 ns)
```
@@ -0,0 +1,56 @@
var PRECISION = 1e5
function decode( value ) {
var points = []
var lat = 0
var lon = 0
var values = decode.integers( value, function( x, y ) {
lat += x
lon += y
points.push([ lat / PRECISION, lon / PRECISION ])
})
return points
}
decode.sign = function( value ) {
return value & 1 ? ~( value >>> 1 ) : ( value >>> 1 )
}
decode.integers = function( value, callback ) {
var values = 0
var x = 0
var y = 0
var byte = 0
var current = 0
var bits = 0
for( var i = 0; i < value.length; i++ ) {
byte = value.charCodeAt( i ) - 63
current = current | (( byte & 0x1F ) << bits )
bits = bits + 5
if( byte < 0x20 ) {
if( ++values & 1 ) {
x = decode.sign( current )
} else {
y = decode.sign( current )
callback( x, y )
}
current = 0
bits = 0
}
}
return values
}
module.exports = decode
@@ -0,0 +1,75 @@
var PRECISION = 1e5
var CHARCODE_OFFSET = 63
var CHARMAP = {}
for( var i = 0x20; i < 0x7F; i++ ) {
CHARMAP[ i ] = String.fromCharCode( i )
}
function encode( points ) {
// px, py, x and y store rounded exponentiated versions of the values
// they represent to compute the actual desired differences. This helps
// with finer than 5 decimals floating point numbers.
var px = 0, py = 0
return reduce( points, function( str, lat, lon ) {
var x = Math.round( lat * 1e5 )
var y = Math.round( lon * 1e5 )
str += chars( sign( ( x - px ) ) ) +
chars( sign( ( y - py ) ) )
px = x
py = y
return str
})
}
function reduce( points, callback ) {
var point = null
var lat = 0
var lon = 0
var str = ''
for( var i = 0; i < points.length; i++ ) {
point = points[i]
lat = point.lat || point.x || point[0]
lon = point.lng || point.y || point[1]
str = callback( str, lat, lon )
}
return str
}
function sign( value ) {
return ( value < 0 ) ? ~( value << 1 ) : ( value << 1 )
}
function charCode( value ) {
return (( value & 0x1F ) | 0x20 ) + 63
}
function chars( value ) {
var str = ''
while( value >= 0x20 ) {
str += CHARMAP[ charCode( value ) ]
value = value >> 5
}
str += CHARMAP[ value + 63 ]
return str
}
module.exports = encode
@@ -0,0 +1,4 @@
module.exports = {
encode: require( './encode' ),
decode: require( './decode' ),
}
@@ -0,0 +1,69 @@
{
"_from": "google-polyline@^1.0.3",
"_id": "google-polyline@1.0.3",
"_inBundle": false,
"_integrity": "sha512-36BnqVxmVcR8lTvzO6aeXdICNChAwQLlfMkR1P9IBpTWE8hA6bAbQHCVArwMHB5WIMq9owywtAkjioe3crNq4Q==",
"_location": "/google-polyline",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "google-polyline@^1.0.3",
"name": "google-polyline",
"escapedName": "google-polyline",
"rawSpec": "^1.0.3",
"saveSpec": null,
"fetchSpec": "^1.0.3"
},
"_requiredBy": [
"/hafas-client"
],
"_resolved": "https://registry.npmjs.org/google-polyline/-/google-polyline-1.0.3.tgz",
"_shasum": "b1fafd8841059f7049d4ba6767c386be979510dc",
"_spec": "google-polyline@^1.0.3",
"_where": "/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/node_modules/hafas-client",
"author": {
"name": "Jonas Hermsmeier",
"email": "jhermsmeier@gmail.com",
"url": "https://jhermsmeier.de"
},
"bugs": {
"url": "https://github.com/jhermsmeier/node-google-polyline/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Gonzalo Infante",
"email": "chalo.infante01@gmail.com"
}
],
"deprecated": false,
"description": "Encode / decode Google's polyline format",
"devDependencies": {
"mocha": "^5.2.0",
"nanobench": "^2.1.1"
},
"directories": {
"test": "test"
},
"homepage": "https://github.com/jhermsmeier/node-google-polyline",
"keywords": [
"google",
"polyline",
"encoding",
"encode",
"decode"
],
"license": "MIT",
"main": "lib/polyline.js",
"name": "google-polyline",
"repository": {
"type": "git",
"url": "git+https://github.com/jhermsmeier/node-google-polyline.git"
},
"scripts": {
"benchmark": "nanobench benchmark/*.js",
"test": "mocha --ui tdd"
},
"version": "1.0.3"
}