/** * Encoded WKB from blob * * This method will copy the given blob to memory descriptor. There's better * ways to do this. * * @param string $blob - Binary safe string * * @return string */ public function encodeFromBlob($blob) { $this->fd = fopen('php://memory', 'wb'); fwrite($this->fd, $blob); fseek($this->fd, 0); $points = $this->parseWkb(); fclose($this->fd); return parent::encode($points); }
/** * Test rounding issues report by issue #10 * * @return NULL */ public function testRounding() { $originalPoints = array(48.000006, 2.000004, 48.00001, 2.0); $encoded = Polyline::encode($originalPoints); $this->assertEquals('a_~cH_seK??', $encoded); $decodedPoints = Polyline::decode($encoded); $this->assertTrue($decodedPoints[0] === $decodedPoints[2]); $this->assertTrue($decodedPoints[1] === $decodedPoints[3]); }
/** * Test encode points to string * * @covers Polyline::encode * @covers Polyline::flatten * * @return NULL */ public function testEncode() { // Remove the following lines when you implement this test. $this->assertEquals($this->encoded, Polyline::encode($this->points)); }