Exemple #1
0
 public function test_createPointsAroundCenter()
 {
     $aPoints = createPointsAroundCenter(0, 0, 2);
     $this->assertEquals(101, count($aPoints));
     $this->assertEquals(array(['', 0, 2], ['', 0.12558103905863, 1.9960534568565], ['', 0.25066646712861, 1.984229402629]), array_splice($aPoints, 0, 3));
 }
Exemple #2
0
function geometryText2Points($geometry_as_text, $fRadius)
{
    $aPolyPoints = NULL;
    if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
        preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
    } elseif (preg_match('#LINESTRING\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
        preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
        preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
    } elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) {
        $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);
    }
    if (isset($aPolyPoints)) {
        $aResultPoints = array();
        foreach ($aPolyPoints as $aPoint) {
            $aResultPoints[] = array($aPoint[1], $aPoint[2]);
        }
        return $aResultPoints;
    }
    return;
}