ruvents/data-space

This package is abandoned and no longer maintained. No replacement package was suggested.

RUVENTS Data Space

2.0.0-alpha15 2016-10-20 00:12 UTC

README

Example

<?php

use Ruvents\DataSpace\Space;

$space = new Space(['x', 'y', 'z']);

$space->setPoint([1,1,1], 'Point 1, 1, 1');
$space->setPoint([3,2,4], 'Point 3, 2, 4');
$space->setPoint([5,2,1], 'Point 5, 2, 1');

$space->getAxis('x')->setCoordinate(1, 'Coordinate x1');
$space->getAxis('y')->setCoordinate(2, 'Coordinate y2');
$space->getAxis('z')->setCoordinate(4, 'Coordinate z4');

# for a grid (only existing points are displayed)
$xIterator = $space->getIterator();
foreach ($xIterator as $x => $yIterator) {
    $xData = $xIterator->getCurrentCoordinate();

    foreach ($yIterator as $y => $zIterator) {
        $yData = $yIterator->getAxis()->getCoordinate($y);

        foreach ($zIterator as $z => $point) {
            $zData = $space->getAxis('z')->getCoordinate($z);

            echo "Point at ($x, $y, $z). Point data: $point, xData: $xData, yData: $yData, zData: $zData<br>";
        }
    }
}

echo '<br>';

# for a table (all coordinates are displayed)
foreach ($space->getAxis('x') as $x => $xData) {
    foreach ($space->getAxis('y') as $y => $yData) {
        foreach ($space->getAxis('z') as $z => $zData) {
            $point = $space->getPoint([$x, $y, $z], 'default');

            echo "Point at ($x, $y, $z). Point data: $point, xData: $xData, yData: $yData, zData: $zData<br>";
        }
    }
}