• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

brick / geo / 13872073621

15 Mar 2025 10:37AM UTC coverage: 51.165% (-36.2%) from 87.322%
13872073621

push

github

BenMorel
Add support for GeosOp in requireEngine()

1866 of 3647 relevant lines covered (51.17%)

1154.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/src/Projector/RemoveZMProjector.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Geo\Projector;
6

7
use Brick\Geo\CoordinateSystem;
8
use Brick\Geo\Point;
9
use Override;
10

11
/**
12
 * Removes the Z and/or M coordinates of a geometry.
13
 */
14
final class RemoveZMProjector implements Projector
15
{
16
    public function __construct(
17
        private readonly bool $removeZ = false,
18
        private readonly bool $removeM = false,
19
    ) {
20
    }
8✔
21

22
    #[Override]
23
    public function project(Point $point): Point
24
    {
25
        $coordinateSystem = $this->getTargetCoordinateSystem($point->coordinateSystem());
8✔
26

27
        if ($point->isEmpty()) {
8✔
28
            return new Point($coordinateSystem);
×
29
        }
30

31
        $x = $point->x();
8✔
32
        $y = $point->y();
8✔
33
        $z = $point->z();
8✔
34
        $m = $point->m();
8✔
35

36
        assert($x !== null);
37
        assert($y !== null);
38

39
        $coords = [$x, $y];
8✔
40

41
        if (! $this->removeZ && $z !== null) {
8✔
42
            $coords[] = $z;
×
43
        }
44

45
        if (! $this->removeM && $m !== null) {
8✔
46
            $coords[] = $m;
×
47
        }
48

49
        return new Point($coordinateSystem, ...$coords);
8✔
50
    }
51

52
    #[Override]
53
    public function getTargetCoordinateSystem(CoordinateSystem $sourceCoordinateSystem): CoordinateSystem
54
    {
55
        return $sourceCoordinateSystem
8✔
56
            ->withZ($sourceCoordinateSystem->hasZ() && ! $this->removeZ)
8✔
57
            ->withM($sourceCoordinateSystem->hasM() && ! $this->removeM);
8✔
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc