Giter Club home page Giter Club logo

arc.php's Introduction

arc.php

port of https://github.com/springmeyer/arc.js to php

Calculate great circles routes as lines in GeoJSON or WKT format.

Algorithms from http://williams.best.vwh.net/avform.htm#Intermediate

Includes basic support for splitting lines that cross the dateline, based on a partial port of code from OGR.

License

BSD

Usage

Just point the machine to Arc.php and it'll load everything:

require_once '../Arc.php';

API

1) Create start and end coordinates

First we need to declare where the arc should start and end

$start = (object) [ 'x' => -122, 'y' => 48 ];
$end = (object) [ 'x' => -77, 'y' => 39 ];

Note that x here is longitude in degrees and y is latitude in degrees.

2) Create GreatCircle object

Next we pass the start/end to the GreatCircle constructor, along with an optional object representing the properties for this future line.

$generator = new Arc\GreatCircle($start, $end, (object) ['name' => 'Seattle to DC']);

3) Generate a line arc

Then call the Arc function on the GreatCircle object to generate a line:

$line = $generator->Arc(100,(object)['offset'=>10]);

The line will be a raw sequence of the start and end coordinates plus an arc of intermediate coordinate pairs.

CAVEATS AND FURTHER READING

Check https://github.com/springmeyer/arc.js for more information about how it works. The interface should be more-or-less the same as javascript. Some small deviations where I felt they were neccessary. I've also ported the examples and tests. Your mileage may vary, I offer no warranty. In fact, while I understand the signatures and whatnot, I didn't really bother untangling everything... ...So I know less about this than what springmeyer. Nonetheless, if you have issues, report them here as they're quite probably bugs in my port effort :-) It wasn't done with great care or diligence but it seems to work OK. I wasn't aiming for any particular platform so there's a good chance it'll choke on PHP versions less than seven.

Anyway, enjoy :)

arc.php's People

Contributors

sneakywhoami avatar

Watchers

 avatar  avatar

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.