| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
include(dirname(__FILE__).'/../bootstrap/unit.php'); |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
$t = new lime_test(286, new lime_output_color()); |
|---|
| 13 |
|
|---|
| 14 |
$t->diag('GMapCoords Tests'); |
|---|
| 15 |
|
|---|
| 16 |
for ($zoom=0; $zoom<15;$zoom += 3) |
|---|
| 17 |
{ |
|---|
| 18 |
for($lat=90; $lat>=-90; $lat-=10) |
|---|
| 19 |
{ |
|---|
| 20 |
$t->is(GMapCoord::fromPixToLat(GMapCoord::fromLatToPix($lat, $zoom),$zoom),(float)$lat,'les projections mercator sur les latitudes marchent'); |
|---|
| 21 |
} |
|---|
| 22 |
for($lng=-180; $lng<=180; $lng+=10) |
|---|
| 23 |
{ |
|---|
| 24 |
$t->is(GMapCoord::fromPixToLng(GMapCoord::fromLngToPix($lng, $zoom),$zoom),(float)$lng,'les projections mercator sur les longitudes marchent'); |
|---|
| 25 |
} |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
$lat = 0; |
|---|
| 29 |
$lng = 0; |
|---|
| 30 |
$zoom = 0; |
|---|
| 31 |
|
|---|
| 32 |
$pix = GMapCoord::fromLatToPix($lat, $zoom); |
|---|
| 33 |
$t->is($pix,128,'Latitude 0 is at the middle of the map for zoom 0'); |
|---|
| 34 |
$pix = GMapCoord::fromLngToPix($lng, $zoom); |
|---|
| 35 |
$t->is($pix,128,'Longitude 0 is at the middle of the map for zoom 0'); |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
$lat = 0; |
|---|
| 39 |
$lng = -180; |
|---|
| 40 |
$zoom = 12; |
|---|
| 41 |
$pix = GMapCoord::fromLatToPix($lat, $zoom); |
|---|
| 42 |
$t->is($pix,256*pow(2,$zoom-1),'Latitude 0 is at the middle of the map whatever the zoom'); |
|---|
| 43 |
$pix = GMapCoord::fromLngToPix($lng, $zoom); |
|---|
| 44 |
$t->is($pix,0,'Longitude -180 is at the left of the map whathever the zoom'); |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
$coord_paris = new GMapCoord(48.857939,2.346611); |
|---|
| 48 |
$coord_le_mans = new GMapCoord(48.007381,0.202131); |
|---|
| 49 |
$t->is(round(GMapCoord::distance($coord_le_mans, $coord_paris)),257,'Approximate distance between Le Mans and Paris is 257'); |
|---|
| 50 |
|
|---|
| 51 |
$coord_luxembourg = new GMapCoord(48.846559,2.340689); |
|---|
| 52 |
$coord_saint_michel = new GMapCoord(48.853717,2.344015); |
|---|
| 53 |
$t->is(round(GMapCoord::distance($coord_luxembourg, $coord_saint_michel)*1000),879,'Approximate distance between RER Luxembourg and Saint-Michel is 879 meters'); |
|---|