Ejemplo n.º 1
0
 public function testSelectSTSummaryGeography()
 {
     if ($this->getPlatform()->getName() == 'mysql') {
         $this->markTestSkipped('Function not supported on mssql.');
     }
     $entity1 = new GeographyEntity();
     $point1 = new GeographyPoint(5, 5);
     $entity1->setGeography($point1);
     $this->_em->persist($entity1);
     $entity2 = new GeographyEntity();
     $lineString2 = new GeographyLineString(array(array(1, 1), array(2, 2), array(3, 3)));
     $entity2->setGeography($lineString2);
     $this->_em->persist($entity2);
     $entity3 = new GeographyEntity();
     $polygon3 = new GeographyPolygon(array(array(array(0, 0), array(10, 0), array(10, 10), array(0, 10), array(0, 0))));
     $entity3->setGeography($polygon3);
     $this->_em->persist($entity3);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery('SELECT g, ST_Summary(g.geography) FROM CrEOF\\Spatial\\Tests\\Fixtures\\GeographyEntity g');
     $result = $query->getResult();
     $this->assertCount(3, $result);
     $this->assertEquals($entity1, $result[0][0]);
     $this->assertRegExp('/^Point\\[.*G.*\\]/', $result[0][1]);
     $this->assertEquals($entity2, $result[1][0]);
     $this->assertRegExp('/^LineString\\[.*G.*\\]/', $result[1][1]);
     $this->assertEquals($entity3, $result[2][0]);
     $this->assertRegExp('/^Polygon\\[.*G.*\\]/', $result[2][1]);
 }
Ejemplo n.º 2
0
 /**
  * @group geography
  */
 public function testSelectSTDistanceGeographyCartesian()
 {
     $newYork = new GeographyPoint(-73.93861099999999, 40.664167);
     $losAngles = new GeographyPoint(-118.243, 34.0522);
     $dallas = new GeographyPoint(-96.803889, 32.782778);
     $madison = new GeographyPoint(-89.40000000000001, 43.066667);
     $entity1 = new GeographyEntity();
     $entity1->setGeography($newYork);
     $this->_em->persist($entity1);
     $entity2 = new GeographyEntity();
     $entity2->setGeography($losAngles);
     $this->_em->persist($entity2);
     $entity3 = new GeographyEntity();
     $entity3->setGeography($dallas);
     $this->_em->persist($entity3);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery('SELECT g, ST_Distance(g.geography, ST_GeomFromText(:p1), false) FROM CrEOF\\Spatial\\Tests\\Fixtures\\GeographyEntity g');
     $query->setParameter('p1', $madison, 'geopoint');
     $result = $query->getResult();
     $this->assertCount(3, $result);
     $this->assertEquals($entity1, $result[0][0]);
     $this->assertEquals(1305895.94823465, $result[0][1]);
     $this->assertEquals($entity2, $result[1][0]);
     $this->assertEquals(2684082.08249337, $result[1][1]);
     $this->assertEquals($entity3, $result[2][0]);
     $this->assertEquals(1313754.60684762, $result[2][1]);
 }
 /**
  * @expectedException \PHPUnit_Framework_Error
  */
 public function testBadGeographyValue()
 {
     $entity = new GeographyEntity();
     $entity->setGeography('POINT(0 0)');
 }
Ejemplo n.º 4
0
 /**
  * @expectedException \PHPUnit_Framework_Error
  */
 public function testBadGeographyValue()
 {
     $entity = new GeographyEntity();
     try {
         $entity->setGeography('POINT(0 0)');
     } catch (\TypeError $exception) {
         throw new \PHPUnit_Framework_Error($exception->getMessage(), $exception->getCode());
     }
 }