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

brick / geo / 13753277563

09 Mar 2025 10:43PM UTC coverage: 49.787% (+2.5%) from 47.295%
13753277563

push

github

BenMorel
Prepare for release

1749 of 3513 relevant lines covered (49.79%)

975.53 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
    }
7✔
21

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

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

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

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

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

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

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

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

52
    #[Override]
53
    public function getTargetCoordinateSystem(CoordinateSystem $sourceCoordinateSystem): CoordinateSystem
54
    {
55
        return $sourceCoordinateSystem
7✔
56
            ->withZ($sourceCoordinateSystem->hasZ() && ! $this->removeZ)
7✔
57
            ->withM($sourceCoordinateSystem->hasM() && ! $this->removeM);
7✔
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