|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Query\AST\Node; |
|
8
|
|
|
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseVariadicFunction; |
|
9
|
|
|
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Traits\BooleanValidationTrait; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Implementation of PostGIS ST_ConcaveHull() function. |
|
13
|
|
|
* |
|
14
|
|
|
* Computes a possibly concave geometry that contains all input geometry vertices. |
|
15
|
|
|
* The result approaches the convex hull as the target percent increases. |
|
16
|
|
|
* |
|
17
|
|
|
* @see https://postgis.net/docs/ST_ConcaveHull.html |
|
18
|
|
|
* @since 4.0 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Martin Georgiev <[email protected]> |
|
21
|
|
|
* |
|
22
|
|
|
* @example Using it in DQL: "SELECT ST_CONCAVEHULL(g.geometry, 0.9) FROM Entity g" |
|
23
|
|
|
* @example Using it in DQL: "SELECT ST_CONCAVEHULL(g.geometry, 0.9, 'true') FROM Entity g" |
|
24
|
|
|
* Returns a concave hull polygon. |
|
25
|
|
|
*/ |
|
26
|
|
|
class ST_ConcaveHull extends BaseVariadicFunction |
|
27
|
|
|
{ |
|
28
|
|
|
use BooleanValidationTrait; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
2 |
|
protected function getNodeMappingPattern(): array |
|
31
|
|
|
{ |
|
32
|
2 |
|
return [ |
|
33
|
2 |
|
'StringPrimary,ArithmeticPrimary,StringPrimary', |
|
34
|
2 |
|
'StringPrimary,ArithmeticPrimary', |
|
35
|
2 |
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
2 |
|
protected function getFunctionName(): string |
|
39
|
|
|
{ |
|
40
|
2 |
|
return 'ST_ConcaveHull'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
2 |
|
protected function getMinArgumentCount(): int |
|
44
|
|
|
{ |
|
45
|
2 |
|
return 2; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
2 |
|
protected function getMaxArgumentCount(): int |
|
49
|
|
|
{ |
|
50
|
2 |
|
return 3; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
2 |
|
protected function validateArguments(Node ...$arguments): void |
|
54
|
|
|
{ |
|
55
|
2 |
|
parent::validateArguments(...$arguments); |
|
56
|
|
|
|
|
57
|
2 |
|
if (\count($arguments) === 3) { |
|
58
|
2 |
|
$this->validateBoolean($arguments[2], $this->getFunctionName()); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|