mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 21:34:06 +00:00
add tests for nearpoint sql functions
This commit is contained in:
@@ -34,13 +34,7 @@ class NearPoint
|
|||||||
|
|
||||||
public function withinSQL($sObj)
|
public function withinSQL($sObj)
|
||||||
{
|
{
|
||||||
return sprintf(
|
return sprintf('ST_DWithin(%s, %s, %F)', $sObj, $this->sSQL, $this->fRadius);
|
||||||
'ST_DWithin(%S, ST_SetSRID(ST_Point(%F,%F),4326), %F)',
|
|
||||||
$sObj,
|
|
||||||
$this->fLon,
|
|
||||||
$this->fLat,
|
|
||||||
$this->fRadius
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,4 +65,24 @@ class NearPointTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(-79.982, $aRes['pt']->lon(), 'degrees decimal ' . $sQuery, 0.01);
|
$this->assertEquals(-79.982, $aRes['pt']->lon(), 'degrees decimal ' . $sQuery, 0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWithinSQL()
|
||||||
|
{
|
||||||
|
$np = new NearPoint(0.1, 23, 1);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'ST_DWithin(foo, ST_SetSRID(ST_Point(23,0.1),4326), 1.000000)',
|
||||||
|
$np->withinSQL('foo')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDistanceSQL()
|
||||||
|
{
|
||||||
|
$np = new NearPoint(0.1, 23, 1);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'ST_Distance(ST_SetSRID(ST_Point(23,0.1),4326), foo)',
|
||||||
|
$np->distanceSQL('foo')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user