Giter Site home page Giter Site logo

polyline-encoder's Introduction

Polyline Encoder

Polyline Encoder is a simple PHP class that will help you work with polyline encoding / decoding. For more details about the polyline encoder algorithm, please refer to : https://developers.google.com/maps/documentation/utilities/polylinealgorithm

License

This project is under MIT and GPLv2 Licenses.

Usage

Just insert the following line at the top of your PHP file :

#require_once 'PolylineEncoder.php';

Encode a polyline

To encode a polyline just follow those steps :

$polylineEncoder = new PolylineEncoder();

$polylineEncoder->addPoint(30.5,-120.2);
$polylineEncoder->addPoint(40.7,-120.95);
$polylineEncoder->addPoint(43.252,-126.453);

$encodedString = $polylineEncoder->encodedString();

Decode a polyline

$decodedPoints = PolylineEncoder::decodeValue("_p~iF~ps|U_ulLnnqC_mqNvxq`@");

Note

Please note that the encoding levels are currently not supported.

polyline-encoder's People

Contributors

dyaaj avatar

Stargazers

Marc Wieland avatar Roberto Butti avatar Mohamed Saher avatar Miguel Stevens avatar Mike Grigoriev avatar Divyanshu Bhatnagar avatar Thomas Gratier avatar Michael Kubler avatar  avatar Israel Pérez avatar Pavel Dvořák avatar Sebastian Erb avatar Jairo Chapela-Martínez avatar Drew LeSueur avatar Sean Pangia avatar  avatar Adrian Gibbons avatar  avatar  avatar stefw avatar  avatar

Watchers

James Cloos avatar  avatar AgênciaTI avatar Sebastian Erb avatar

polyline-encoder's Issues

Typo fix

It should be PolylineEncoder::decodeValue instead of PolylineEncoder::decodeString in your "Decode a polyline" example

Kind regards.

Beware of double quoted strings in examples

Hi, in your examples you're using double quoted strings, but so, some chars in encoded string (that may be composed of any ASCII char) have different meaning and will lead to wrong decoding, for example the following string (attaching a txt file due to formatting issues in GitHub):
test.txt
is decoded with single quoted string syntax but is decoded differently with double quoted string syntax.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.