Skip to content

Commit

Permalink
boundingPolygons() is now part of the GeometryEngine interface
Browse files Browse the repository at this point in the history
Note that this method is not currently implemented by any of the available geometry engines.
  • Loading branch information
BenMorel committed May 3, 2015
1 parent 41977a5 commit 2f51ee8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
8 changes: 8 additions & 0 deletions src/Engine/DatabaseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,12 @@ public function maxDistance(Geometry $a, Geometry $b)
{
return $this->queryFloat('ST_MaxDistance', [$a, $b]);
}

/**
* {@inheritdoc}
*/
public function boundingPolygons(Geometry $g)
{
throw GeometryEngineException::unimplementedMethod(__METHOD__);
}
}
8 changes: 8 additions & 0 deletions src/Engine/GEOSEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,12 @@ public function maxDistance(Geometry $a, Geometry $b)
{
throw GeometryEngineException::unimplementedMethod(__METHOD__);
}

/**
* {@inheritdoc}
*/
public function boundingPolygons(Geometry $g)
{
throw GeometryEngineException::unimplementedMethod(__METHOD__);
}
}
11 changes: 11 additions & 0 deletions src/Engine/GeometryEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,15 @@ public function simplify(Geometry $g, $tolerance);
* @throws GeometryEngineException If the operation is not supported by the engine.
*/
public function maxDistance(Geometry $a, Geometry $b);

/**
* Returns the collection of polygons that bounds the given polygon 'p' for any polygon 'p' in the surface.
*
* @param Geometry $g
*
* @return Geometry
*
* @throws GeometryEngineException If the operation is not supported by the engine.
*/
public function boundingPolygons(Geometry $g);
}
12 changes: 12 additions & 0 deletions src/Exception/GeometryEngineException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public static function noEngineSet()
return new self('A GeometryEngine must be set to support this feature.');
}

/**
* @param string $methodName
*
* @return GeometryEngineException
*/
public static function unimplementedMethod($methodName)
{
$message = sprintf('%s() is currently not implemented.', $methodName);

return new self($message);
}

/**
* @param \Exception $e
*
Expand Down
12 changes: 0 additions & 12 deletions src/Exception/GeometryException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ public static function unsupportedPlatform()
return new self('This platform has an unsupported endianness.');
}

/**
* @param string $methodName
*
* @return GeometryException
*/
public static function unimplementedMethod($methodName)
{
$message = sprintf('%s() is currently not implemented.', $methodName);

return new static($message);
}

/**
* @param string $geometryType
*
Expand Down
6 changes: 2 additions & 4 deletions src/PolyhedralSurface.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,17 @@ public function patches()
/**
* Returns the collection of polygons in this surface that bounds the given polygon 'p' for any polygon 'p' in the surface.
*
* @todo needs implementation
*
* @noproxy
*
* @param Polygon $p
*
* @return MultiPolygon
*
* @throws GeometryException
* @throws GeometryEngineException If the operation is not supported by the geometry engine.
*/
public function boundingPolygons(Polygon $p)
{
throw GeometryException::unimplementedMethod(__METHOD__);
return GeometryEngineRegistry::get()->boundingPolygons($p);
}

/**
Expand Down

0 comments on commit 2f51ee8

Please sign in to comment.