Navigator Documentation

Similar documents
sptrans Documentation

pyserial-asyncio Documentation

Flask-Sitemap Documentation

Flask Gravatar. Release 0.5.0

calio / form-input-nginx-module

Open Source Used In TSP

PyWin32ctypes Documentation

RPly Documentation. Release Alex Gaynor

Explaining & Accessing the SPDX License List

HALCoGen TMS570LS31x Help: example_sci_uart_9600.c

Mercantile Documentation

django-generic-filters Documentation

openresty / encrypted-session-nginx-module

Open Source Used In Cisco Configuration Professional for Catalyst 1.0

Distinction Import Module User Guide. DISTINCTION.CO.UK

HYDRODESKTOP VERSION 1.4 QUICK START GUIDE

Grouper UI csrf xsrf prevention

IETF TRUST. Legal Provisions Relating to IETF Documents. February 12, Effective Date: February 15, 2009

System Log NextAge Consulting Pete Halsted

DHIS 2 Android User Manual 2.22


Package fst. December 18, 2017

ColdFusion Builder 3.2 Third Party Software Notices and/or Additional Terms and Conditions

TWAIN driver User s Guide

Spout to NDI. Convert between Spout and Newtek NDI sources. Using the Newtek NDI SDK. Version 2.

monolith Documentation

Ecma International Policy on Submission, Inclusion and Licensing of Software

Intel Stress Bitstreams and Encoder (Intel SBE) 2017 AVS2 Release Notes (Version 2.3)

ProgressBar Abstract

Static analysis for quality mobile applications

Documentation Roadmap for Cisco Prime LAN Management Solution 4.2

openresty / array-var-nginx-module

LabVIEW Driver. User guide Version

Ecma International Policy on Submission, Inclusion and Licensing of Software

IETF TRUST. Legal Provisions Relating to IETF Documents. Approved November 6, Effective Date: November 10, 2008

Preface. Audience. Cisco IOS Software Documentation. Organization

Table of Contents Overview...2 Selecting Post-Processing: ColorMap...3 Overview of Options Copyright, license, warranty/disclaimer...

Migration Tool. Migration Tool (Beta) Technical Note

ANZ TRANSACTIVE MOBILE for ipad

iwrite technical manual iwrite authors and contributors Revision: 0.00 (Draft/WIP)

US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

User Manual. Date Aug 30, Enertrax DAS Download Client

Package fst. June 7, 2018

Watch 4 Size v1.0 User Guide By LeeLu Soft 2013

LGR Toolset (beta) User Guide. IDN Program October 2016

Open Source and Standards: A Proposal for Collaboration

Business Rules NextAge Consulting Pete Halsted

MagicInfo Express Content Creator

notify2 Documentation

Moodle. Moodle. Deployment Guide

HYDRODESKTOP VERSION 1.1 BETA QUICK START GUIDE

HIS document 2 Loading Observations Data with the ODDataLoader (version 1.0)

Denkh XML Reporter. Web Based Report Generation Software. Written By Scott Auge Amduus Information Works, Inc.

User Manual for Video Codec

About This Guide. and with the Cisco Nexus 1010 Virtual Services Appliance: N1K-C1010

Data Deduplication Metadata Extension

DHIS2 Android user guide 2.26

Packet Trace Guide. Packet Trace Guide. Technical Note

Dr. K. Y. Srinivasan. Jason Goldschmidt. Technical Lead NetApp Principal Architect Microsoft Corp.

Definiens. Tissue Studio Release Notes

MUMPS IO Documentation

Pulse Check User Guide and Technical Guide. Quick Start Framework. Version Name: Winter 16 Version Number: 1.5 Date:

An Easy Way to Split a SAS Data Set into Unique and Non-Unique Row Subsets Thomas E. Billings, MUFG Union Bank, N.A., San Francisco, California

PTZ Control Center Operations Manual

The Cron service allows you to register STAF commands that will be executed at a specified time interval(s).

Definiens. Image Miner bit and 64-bit Editions. Release Notes

DHIS 2 Android User Manual 2.23

Cassette Documentation

PageScope Box Operator Ver. 3.2 User s Guide

User Guide. Calibrated Software, Inc.

Open Source Used In c1101 and c1109 Cisco IOS XE Fuji

TheGreenBow VPN Client ios User Guide

NemHandel Referenceklient 2.3.1

User s Manual Earth-Centered Earth-Fixed in WGS84 by Hydrometronics LLC

LGR Toolset (beta) User Guide. IDN Program 24 October 2017

NemHandel Referenceklient 2.3.0

HYDROOBJECTS VERSION 1.1

Trimble. ecognition. Release Notes

Scott Auge

Copyright PFU LIMITED 2016

Definiens. Image Miner bit and 64-bit Edition. Release Notes

Copyright PFU LIMITED

RSA Two Factor Authentication

This file includes important notes on this product and also the additional information not included in the manuals.

cs50.c /**************************************************************************** * CS50 Library 6 *

Taking the LPC800 into the delta quadrant :)

FLAMEBOSS 300 MANUAL

@list = bsd_glob('*.[ch]'); $homedir = bsd_glob('~gnat', GLOB_TILDE GLOB_ERR);

GoldSim License Server Activation Utility Installation and Basic Use

Introduction. The Win32 OpenSSL Installation Group hopes that you enjoy this software and get many years of use out of it!

NTLM NTLM. Feature Description

This file includes important notes on this product and also the additional information not included in the manuals.

iphone/ipad Connection Manual

GoldSim License Portal A User s Guide for Managing Your GoldSim Licenses

License, Rules, and Application Form

Copyright 2010 by Microtek International, Inc. Trademarks. Important. All rights reserved.

DAP Controller FCO

Fujitsu ScandAll PRO V2.1.5 README

Adobe Connect. Adobe Connect. Deployment Guide

Hyperscaler Storage. September 12, 2016

Transcription:

Navigator Documentation Release 1.0.0 Simon Holywell February 18, 2016

Contents 1 Installation 3 1.1 Packagist with Composer........................................ 3 1.2 git Clone or Zip Package......................................... 3 2 Quickstart Tutorial 5 2.1 Super Simple Example.......................................... 5 2.2 A Slightly More Advanced Example................................... 5 3 Coordinates 7 3.1 Custom Parser.............................................. 7 4 LatLong 9 5 Distance 11 5.1 Calculators................................................ 11 5.2 Converters................................................ 12 6 Tests 13 6.1 Travis-CI................................................. 13 6.2 Code Coverage.............................................. 13 7 Contribution 15 8 Licence 17 8.1 BSD 2-Clause License.......................................... 17 9 Indices and tables 19 i

ii

Navigator Documentation, Release 1.0.0 A PHP library for geographic calculations: Calculate the distance between two coordinate points on the earth s surface (using Vincenty, Haversine, Great Circle or The Cosine Law) Conversion between units (metres to kilometres, nautical miles and miles). Convert coordinate notation (decimals to degrees, minutes & seconds and back again). This is an improved (PHP5.3.2+) and tested version of Geographic Calculations in PHP. Contents: Contents 1

Navigator Documentation, Release 1.0.0 2 Contents

CHAPTER 1 Installation There are a few ways of installing this library, the easiest of which is via Packagist with Composer. 1.1 Packagist with Composer Composer is a great way to manage dependencies for PHP projects and there is a ready made package for Navigator available on Packagist. In your projects composer.json file you should enter the following information: { } "require": { "treffynnon/navigator": "1.*" } Next you need to install composer on your system with curl -s http://getcomposer.org/installer php Install the Composer managed dependencies with: php composer.phar install You will now have a vendors directory in your project that contains Navigator. Composer also automatically generates an autoload file that you can use to autoload the classes of the Navigator library (and any other dependencies you have managed with Composer). To do this add the following to your projects bootstrap file: <?php require 'vendor/autoload.php'; Navigator is now installed in your project with Composer meaning that it is easy to keep up to date! 1.2 git Clone or Zip Package Navigator can also be installed from source by either using git to clone or export the repository or by downloading a zipped release from GitHub. To obtain the library with git it is as simple as: 3

Navigator Documentation, Release 1.0.0 git clone git://github.com/treffynnon/navigator.git Otherwise you can download a zip or tar file of the latest release from GitHub and extract it. Then to initialise the autoloader for the Navigator library add the following to your projects bootstrap: <?php require_once DIR. 'Navigator/lib/Treffynnon/Navigator.php'; use Treffynnon\Navigator as N; N::autoloader(); The Navigator library is now available to your project. 4 Chapter 1. Installation

CHAPTER 2 Quickstart Tutorial Please ensure you have completed the installation instructions for the Navigator library before continuing with these quickstart tutorials. 2.1 Super Simple Example This is the easiest way to get a quick distance between two points of the Earth in metres. <?php use Treffynnon\Navigator as N; $distance = N::getDistance(10, 81.098, 15.6, '5 10\' 11.009"W'); The function takes a sequence of latitude and longitude values: N::getDistance(lat1, long1, lat2, long2) Returns the distance in metres between the supplied points on Earth Parameters lat1 (string or float) The latitude of point 1 long1 (string or float) The longitude of point 1 lat2 (string or float) The latitude of point 2 long2 (string or float) The longitude of point 2 Return type float 2.2 A Slightly More Advanced Example To get more control over the setup of the distance calculation you can make use of the distance factory. The following snippet will give the $distance using the Haversine formula and converted to parsecs. <?php use Treffynnon\Navigator as N; use Treffynnon\Navigator\Distance\Calculator\Haversine as H; use Treffynnon\Navigator\Distance\Converter\MetreToParsec as P; $Distance = N::distanceFactory(10, 81.098, 15.6, '5 10\' 11.009"W'); $distance = $Distance->get(new H, new P); 5

Navigator Documentation, Release 1.0.0 N::distanceFactory(lat1, long1, lat2, long2) Get a distance instance pre-populated with the supplied sequence of latitude and longitude values Parameters lat1 (string or float) The latitude of point 1 long1 (string or float) The longitude of point 1 lat2 (string or float) The latitude of point 2 long2 (string or float) The longitude of point 2 Return type TreffynnonNavigatorDistance 6 Chapter 2. Quickstart Tutorial

CHAPTER 3 Coordinates The coordinate class must be combined with LatLong to create a point on the celestial bodies surfaces (most commonly this is the Earth). It handles the storage of a supplied coordinate value and its conversion to radians for internal use by Calculators. This scheme makes it easy to supply a custom coordinate parser or specify whether to use Decimal or Degrees Minutes Seconds notation from the standard set of parsers. <?php use Treffynnon\Navigator\Coordinate as C; $coord = new C('5 10\' 11.009"W', new C\DmsParser); 3.1 Custom Parser Creating a custom parser is as simple as extending Treffynnon\Navigator\Coordinate\ParserAbstract like in this Radian parsing example <?php namespace YourProject\Navigator\Coordinate; use Treffynnon\Navigator\Coordinate as C; class RadianParser extends C\ParserAbstract { public function parse($coord) { return $coord; } public function get($coord) { return $coord; } } Then you can put it into action by injecting it into a coordinate instance <?php use YourProject\Navigator\Coordinate as YPC; use Treffynnon\Navigator\Coordinate as C; $coord = new C(1.2175876579, new YPC\RadianParser); Please note the namespace YourProject\Navigator\Coordinate should be changed to reflect the real names in your project. 7

Navigator Documentation, Release 1.0.0 8 Chapter 3. Coordinates

CHAPTER 4 LatLong It is just a simple construct to combine coordinate instances into a latitude and longitude point. It will also prime the coordinate with its direction (either latitude or longitude). This can later be used by a parser to add in any meta information about a coordinate. This can be most easily seen the in the get() method of the DmsParser class. 9

Navigator Documentation, Release 1.0.0 10 Chapter 4. LatLong

CHAPTER 5 Distance When Distance is supplied with two instances of LatLng it can be used to calculate the distance between the points. It does this by using a Calculator such as Great Circle and optionally a unit converter such as MetreToNauticalMile: <?php use Treffynnon\Navigator as N; $coord1 = new N\LatLong( new N\Coordinate(10.9978), new N\Coordinate(35.6234) ); $coord2 = new N\LatLong( new N\Coordinate(25), new N\Coordinate(-13.456) ); $Distance = new N\Distance($coord1, $coord2); Specify the calculator and conversion on the get() method of Distance: <?php use Treffynnon\Navigator\Distance as D; $distance = $Distance->get(new D\Calculator\GreatCircle, new D\Converter\MetreToNauticalMile); $distance now has the distance value calculated by Great Circle in Nautical Miles. 5.1 Calculators The Navigator library comes with four distance calculators by default: The Cosine Law Great Circle Haversine Vincenty Of the selection Vincenty is the most accurate and also the default. It is the most computationally intensive, but not prohibitively so by any stretch. 11

Navigator Documentation, Release 1.0.0 5.1.1 Celestial Bodies Most commonly and by default Navigator will be using Earth, but it can be altered by passing in a different Celestial Body such as Mars or the Moon: <?php use Treffynnon\Navigator\CelestialBody\Mars as M; use Treffynnon\Navigator\Distance as D; $distance = $Distance->get(new D\Calculator\GreatCircle(new M), new D\Converter\MetreToNauticalMile); Custom Celestial Bodies Custom celestial bodies are very simple to setup with a set of statistics - see Treffynnon\Navigator\CelestialBody\CelestialBodyAbstract for more information. 5.1.2 Custom Calculators As with coordinate parsers it is a trivial matter to create custom calculators. Simply extend the abstract class - Treffynnon\Navigator\Distance\Calculator\CalculatorAbstract. 5.2 Converters Converters can be used independently of the Navigator library or injected into the Distance->get() method. By default Navigator returns distances in metres, but this can be converted to the following units: Furlong Kilometre League Mile Nautical Mile Parsec An example follows: <?php use Treffynnon\Navigator\Distance\Converter\MetreToFurlong as F; $distance = $Distance->get(null, new F); 5.2.1 Custom Converters As with custom calculators, but even simpler! See Treffynnon\Navigator\Distance\Converter\ConverterAbstract. 12 Chapter 5. Distance

CHAPTER 6 Tests Tests are written for PHPUnit 3.5+ with 100% code coverage and can be run with: phpunit --bootstrap tests/bootstrap.php tests 6.1 Travis-CI Continuous integration is handled by Travis-CI: 6.2 Code Coverage Code coverage can be obtained from PHPUnit with the following command: phpunit --bootstrap tests/bootstrap.php --coverage-html../coverage tests 13

Navigator Documentation, Release 1.0.0 14 Chapter 6. Tests

CHAPTER 7 Contribution Contributions are welcome through pull requests, but they must not break any tests and all new features should come with 100% code coverage. 15

Navigator Documentation, Release 1.0.0 16 Chapter 7. Contribution

CHAPTER 8 Licence 8.1 BSD 2-Clause License Copyright (c) 2012, Simon Holywell All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, IN- CIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSI- NESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CON- TRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAM- AGE. 17

Navigator Documentation, Release 1.0.0 18 Chapter 8. Licence

CHAPTER 9 Indices and tables genindex search 19