/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); if (!GeometryEngineRegistry::has()) { $this->markTestSkipped('This test requires a connection to a database.'); } $engine = GeometryEngineRegistry::get(); if (!$engine instanceof PDOEngine) { $this->markTestSkipped('This test currently only works with a PDO connection.'); } $this->platform = $this->_conn->getDatabasePlatform(); $this->platform->registerDoctrineTypeMapping('geometry', 'binary'); $this->platform->registerDoctrineTypeMapping('linestring', 'binary'); $this->platform->registerDoctrineTypeMapping('multilinestring', 'binary'); $this->platform->registerDoctrineTypeMapping('multipoint', 'binary'); $this->platform->registerDoctrineTypeMapping('multipolygon', 'binary'); $this->platform->registerDoctrineTypeMapping('point', 'binary'); $this->platform->registerDoctrineTypeMapping('polygon', 'binary'); switch ($this->platform->getName()) { case 'postgresql': $this->_conn->executeQuery('CREATE EXTENSION IF NOT EXISTS postgis;'); break; } $this->fixtureLoader = new Loader(); $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/Fixtures'], false); $config->addCustomNumericFunction('EarthDistance', EarthDistanceFunction::class); $this->em = EntityManager::create($this->_conn, $config, $this->platform->getEventManager()); $this->schemaTool = new SchemaTool($this->em); $this->schemaTool->updateSchema([$this->em->getClassMetadata(Fixtures\GeometryEntity::class), $this->em->getClassMetadata(Fixtures\LineStringEntity::class), $this->em->getClassMetadata(Fixtures\MultiLineStringEntity::class), $this->em->getClassMetadata(Fixtures\MultiPointEntity::class), $this->em->getClassMetadata(Fixtures\MultiPolygonEntity::class), $this->em->getClassMetadata(Fixtures\PointEntity::class), $this->em->getClassMetadata(Fixtures\PolygonEntity::class)]); $purger = new ORMPurger(); $this->ormExecutor = new ORMExecutor($this->em, $purger); }
/** * Returns the 2-dimensional largest distance between two geometries in projected units. * * @noproxy * * @param Geometry $geometry * * @return float * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ public function maxDistance(Geometry $geometry) { return GeometryEngineRegistry::get()->maxDistance($this, $geometry); }
/** * @noproxy * * @return boolean * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ public function isClosed() { return GeometryEngineRegistry::get()->isClosed($this); }
/** * Returns a Point guaranteed to be on this MultiSurface. * * @noproxy * * @return Point * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ public function pointOnSurface() { return GeometryEngineRegistry::get()->pointOnSurface($this); }
/** * @param boolean $testMariaDB False to check for MYSQL, true to check for MariaDB. * @param string|null $operatorAndVersion An optional comparison operator and version number to test against. * * @return boolean */ private function isMySQLorMariaDB($testMariaDB, $operatorAndVersion = null) { $engine = GeometryEngineRegistry::get(); if ($engine instanceof PDOEngine) { $pdo = $engine->getPDO(); if ($pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql') { $statement = $pdo->query("SHOW VARIABLES LIKE 'version'"); $version = $statement->fetchColumn(1); $isMariaDB = substr($version, -8) === '-MariaDB'; if ($isMariaDB) { $version = substr($version, 0, -8); } if ($operatorAndVersion === null) { return $testMariaDB === $isMariaDB; } return $this->isVersion($version, $operatorAndVersion); } } return false; }
/** * Returns the length of this MultiCurve. * * The length is equal to the sum of the lengths of the element Curves. * * @noproxy * * @return float * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ public function length() { return GeometryEngineRegistry::get()->length($this); }