Skip to content

Commit

Permalink
Api spec tweaks (#12)
Browse files Browse the repository at this point in the history
* Make range a [float,float] for dbh and height

* Fix typo in callculation method

* Be more explicit about tree mean when a representative tree

* Add note about tree dbh and height being in meters

* Add todo about 3-letter codes for species

* Tweak docblock for StandardTree

* Second tweak to StandardTree docblock

* phpstan fixes

* Tweaks trees to volume in docblock comment for volumePerHa property
  • Loading branch information
sfreytag authored Jul 30, 2024
1 parent 39d7949 commit 12a9df4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
1 change: 1 addition & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ parameters:
- src
typeAliases:
JsonType: 'string|int|bool|float|null|array<string, mixed>|array<mixed>'
treatPhpDocTypesAsCertain: false
2 changes: 1 addition & 1 deletion src/Schema/StandardRepresentativeTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StandardRepresentativeTree


/**
* trees per hectare
* Volume per hectare
* @var float
*/
public $volumePerHa;
Expand Down
19 changes: 12 additions & 7 deletions src/Schema/StandardTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ class StandardTree
{
/**
* species ID
* todo create common list
* @todo create common list
* @todo How about the 3-letter codes? Then we do not need to rely on IDs
* into a common list.
* @var int
*/
public $speciesId;

/**
* height of this tree
* if this is a representative tree, thisshould correspond to the mean height
* Height of this tree in metres.
*
* If this is a representative tree, this is the mean height of the representative tree.
* @var float
*/
public $height;

/**
* dbh of this tree
* if this is a representative tree, thisshould correspond to the mean dbh
* dbh of this tree in metres.
*
* If this is a representative tree, this is the mean dbh of the representative tree.
* @var float
*/
public $dbh;
Expand All @@ -36,10 +41,10 @@ class StandardTree
* volume calculation method: eg blue book look up
* @var string
*/
public $volumeCalculationethod;
public $volumeCalculationMethod;

/**
* @see Create the Tree Species.
* Create the Standard Tree.
* @param int $speciesId The species ID.
* @return void
*/
Expand Down
34 changes: 25 additions & 9 deletions src/Schema/StandardTreeDistributionStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,53 @@
class StandardTreeDistributionStats
{
/**
* height range
* @var float
* The height range of the StandardTree expressed as a 2-tuple of floats
* in the order [min,max]
*
* @var array{float,float}
*/
public $heightRange;

/**
* dbh range
* @var float
* The dbh range of the StandardTree expressed as a 2-tuple of floats
* in the order [min,max]
*
* @var array{float,float}
*/
public $dbhRange;

/**
* height variance
* The height variance. This is the variance of the mean defined in
* the linked StandardTree.
* @var float
*/
public $heightVariance;

/**
* dbh variance
* The dbh variance. This is the variance of the mean defined in
* the linked StandardTree.
* @var float
*/
public $dbhVariance;

/**
* @see Create the Tree distribution statistics.
* @param float $heightRange The Tree distribution height range.
* Create the Tree distribution statistics.
*
* @param array{float,float} $heightRange The Tree distribution height range.
* @param array{float,float} $dbhRange The Tree distribution dbh range.
* @return void
*/
public function __construct(float $heightRange)
public function __construct(array $heightRange, array $dbhRange)
{
if (count($heightRange) != 2) {
throw new \Exception("heightRange must be an array of two floats");
}
$this->heightRange = $heightRange;

if (count($dbhRange) != 2) {
throw new \Exception("heightRange must be an array of two floats");
}
$this->dbhRange = $dbhRange;
}

}

0 comments on commit 12a9df4

Please sign in to comment.