예제 #1
0
 public function testPoint()
 {
     $p1 = GeoPointValue::createFromCommaSeparated('55.75747,37.61795');
     $p2 = GeoPointValue::createFromCommaSeparated('55.75147,37.61195');
     // ожидаем порядка 766 метров
     $this->assertEquals(0.766, round($p1->getDistanceTo($p2), 3));
     $this->assertEquals(0.766, round($p2->getDistanceTo($p1), 3));
     $this->assertEquals(0, round($p1->getDistanceTo($p1), 3));
 }
예제 #2
0
 public function convertOnSetter($value)
 {
     if ($value instanceof GeoPointValue) {
         return $value;
     }
     if (!is_string($value)) {
         throw new ConversionImpossibleException('Value of type ' . gettype($value) . ' should be presented as a EWKT string like "SRID=4326;POINT(0 0)" or a comma-separated string like "0,0"');
     }
     try {
         return GeoPointValue::createFromEWKT($value);
     } catch (ConversionImpossibleException $e) {
         return GeoPointValue::createFromCommaSeparated($value);
     }
 }