]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #1138 from mtmail/php-test-for-sqlViewboxLarge
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 14 Aug 2018 19:59:24 +0000 (21:59 +0200)
committerGitHub <noreply@github.com>
Tue, 14 Aug 2018 19:59:24 +0000 (21:59 +0200)
test for SearchContext::setViewboxFromBox

test/php/Nominatim/SearchContextTest.php

index 2a74dc41c5b6a21cb14bab50257b95e5e19c309f..db0b2dee1de20c4338f6cbd9d3ba1f6c42ec254a 100644 (file)
@@ -50,4 +50,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
+        );
+    }
 }