X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c8359181237a3b145ac48b5e58098b36674cd89f..b63633857ed4c9af7af6f35054569dc79c6cc5a0:/test/php/Nominatim/SearchContextTest.php diff --git a/test/php/Nominatim/SearchContextTest.php b/test/php/Nominatim/SearchContextTest.php index 2a74dc41..b5ef1a7a 100644 --- a/test/php/Nominatim/SearchContextTest.php +++ b/test/php/Nominatim/SearchContextTest.php @@ -1,17 +1,23 @@ oCtx = new SearchContext(); } @@ -50,4 +56,34 @@ class SearchContextTest extends \PHPUnit_Framework_TestCase $this->oCtx->distanceSQL('foo') ); } + + public function testSetViewboxFromBox() + { + $viewbox = array(30, 20, 40, 50); + $this->oCtx->setViewboxFromBox($viewbox, true); + $this->assertEquals( + 'ST_SetSRID(ST_MakeBox2D(ST_Point(30.000000,20.000000),ST_Point(40.000000,50.000000)),4326)', + $this->oCtx->sqlViewboxSmall + ); + // height: 10 + // width: 30 + $this->assertEquals( + 'ST_SetSRID(ST_MakeBox2D(ST_Point(50.000000,80.000000),ST_Point(20.000000,-10.000000)),4326)', + $this->oCtx->sqlViewboxLarge + ); + + + $viewbox = array(-1.5, -2, 1.5, 2); + $this->oCtx->setViewboxFromBox($viewbox, true); + $this->assertEquals( + 'ST_SetSRID(ST_MakeBox2D(ST_Point(-1.500000,-2.000000),ST_Point(1.500000,2.000000)),4326)', + $this->oCtx->sqlViewboxSmall + ); + // height: 3 + // width: 4 + $this->assertEquals( + 'ST_SetSRID(ST_MakeBox2D(ST_Point(4.500000,6.000000),ST_Point(-4.500000,-6.000000)),4326)', + $this->oCtx->sqlViewboxLarge + ); + } }