Login   Register  
PHP Classes
elePHPant
Icontem

an example ?

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Geo Tools  >  All threads  >  an example ?  >  (Un) Subscribe thread alerts  
Subject:an example ?
Summary:Can you give an example to use it?
Messages:2
Author:Mick89
Date:2011-09-28 06:16:10
Update:2011-09-28 12:12:56
 

  1. an example ?   Reply   Report abuse  
Picture of Mick89
Mick89
2011-09-28 06:16:10
Hello,

Your class is interesting. But, can you give an example to use it?

Thanks!

Mick

  2. Re: an example ?   Reply   Report abuse  
Picture of Mark Schrer
Mark Schrer
2011-09-28 12:12:56 - In reply to message 1 from Mick89
i just wrote a test case for the class (suits as example as well)
to ensure it works correctly

in case anyone is interested:


App::import('Lib', 'Tools.GeoLib');

/**
* GeoLib based on GeoToolsClass
* 2011-09-28 ms
*/
class GeoLibCase extends CakeTestCase {

function startTest() {
$this->Geo = new GeoLib();

}



function testDistanceBetweenCoords() {
$munich = array('lat'=>48.1, 'lng'=>11.6);
$berlin = array('lat'=>52.5, 'lng'=>13.4);

$is = $this->Geo->distanceBetweenCoords($munich['lat'], $munich['lng'], $berlin['lat'], $berlin['lng']);
pr($is);

$this->assertTrue($is > 500000 && $is < 510000);
}

function testBearingBetweenCoords() {
$munich = array('lat'=>48.1, 'lng'=>11.6);
$berlin = array('lat'=>52.5, 'lng'=>13.4);

$is = $this->Geo->bearingBetweenCoords($munich['lat'], $munich['lng'], $berlin['lat'], $berlin['lng']);
pr($is);

$this->assertIdentical($is, 14);
}

function testMirrerBearing() {
$is = $this->Geo->mirrorBearing(14);
pr($is);
$this->assertIdentical($is, 346);

$is = $this->Geo->mirrorBearing(14, 'x');
pr($is);
$this->assertIdentical($is, 166);
}

function testCalcLatLong() {
$munich = array('lat'=>48.1, 'lng'=>11.6);
$berlin = array('lat'=>52.5, 'lng'=>13.4);

$is = $this->Geo->calcLatLong($munich['lat'], $munich['lng'], $this->Geo->distanceBetweenCoords($munich['lat'], $munich['lng'], $berlin['lat'], $berlin['lng']), $this->Geo->bearingBetweenCoords($munich['lat'], $munich['lng'], $berlin['lat'], $berlin['lng']));
pr($is);

$this->assertEqual((int)$is['lat'], (int)$berlin['lat']);
$this->assertEqual((int)$is['lng'], (int)$berlin['lng']);
}