/** * @covers ResultSet::getPoint */ public function testGetPoint() { $pointKey = 'point'; $geoPoint = 'POINT(-122.3340921148 38.421022632969)'; $this->result->setString($pointKey, $geoPoint); $actual = $this->result->getPoint($pointKey)->toWKT(); $excepted = \GeomPoint::fromWKT($geoPoint)->toWKT(); $this->assertSame($actual, $excepted); }
/** * @covers GeomPoint::getHemisphere */ public function testGetHemisphere() { $point = \GeomPoint::fromXY(21, 3.32); $this->assertEquals(\GeomPoint::NORTHERN_HEMISPHERE, $point->getHemisphere()); $point = \GeomPoint::fromXY(21, -3.32); $this->assertEquals(\GeomPoint::SOUTHERN_HEMISPHERE, $point->getHemisphere()); }
/** * @covers InputConverter::setPoint * @covers InputConverter::getPoint */ public function testSetPoint() { $point = \GeomPoint::fromXY(12, 21); $map = array(); $this->converter->setPoint($map, "key", $point); $expected = array("key_X" => 12, "key_Y" => 21, "key" => $point); $this->assertEquals($expected, $map); $actual = $this->converter->getPoint($map, "key"); $this->assertEquals($point, $actual); }
/** * Return a GeomPoint representing the value associated with the given key. * The value associated with the key is assumed to be a string in WKT format. * * @param $key * @return GeomPoint or null if the value associated with the given key is null. */ public function getPoint($key) { $val = $this->map[$key]; return $val === null ? null : GeomPoint::fromWKT($val); }
/** * Create a string (with WKT format) from longitude and latitude * WKT format for point type: POINT(X Y) * * @return GeomPoint|null if values are not set properly in the map. */ public function getPoint($map, $key) { $x = $this->getValue($map, $key . '_X'); $y = $this->getValue($map, $key . '_Y'); if (!is_numeric($x) && !is_numeric($y)) { return null; } return GeomPoint::fromXY($x, $y); }