Example #1
0
 /**
  * Test Bounding Box to geometry
  *
  * @return void
  */
 public function test_toGeometry()
 {
     $bb = new Util_BoundingBox(-180, -90, 180, 90);
     $geom = $bb->toGeometry();
     $this->assertEquals('POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90))', $geom->toWKT());
     $bb = new Util_BoundingBox(-1, -1, 1, 1);
     $geom = $bb->toGeometry();
     $this->assertEquals('POLYGON((-1 -1,1 -1,1 1,-1 1,-1 -1))', $geom->toWKT());
 }
Example #2
0
 /**
  * Get a subquery to return post_point entries within a bounding box
  * @param  string $bbox Bounding box
  * @return Database_Query
  */
 private function getBoundingBoxSubquery(Util_BoundingBox $bounding_box)
 {
     return DB::select('post_id')->from('post_point')->where(DB::expr('CONTAINS(GeomFromText(:bounds), value)', [':bounds' => $bounding_box->toWKT()]), '=', 1);
 }