Skip to content

Commit

Permalink
Issue #1095: Spatial component should use floats for distance. (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Wu authored Sep 28, 2023
1 parent 376ad9f commit 0e1d769
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the Solarium library will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Spatial component distance type changed from int to float

## [6.3.2]
### Added
- Solarium\Component\ReRankQuery::setOperator()
Expand Down
8 changes: 4 additions & 4 deletions src/Component/Spatial.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public function setField(string $sfield): self
}

/**
* @param int $distance
* @param float $distance
*
* @return self Provides fluent interface
*/
public function setDistance(int $distance): self
public function setDistance(float $distance): self
{
$this->setOption('d', $distance);

Expand Down Expand Up @@ -89,9 +89,9 @@ public function getField(): ?string
/**
* Get d option.
*
* @return int|null
* @return float|null
*/
public function getDistance(): ?int
public function getDistance(): ?float
{
return $this->getOption('d');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Component/RequestBuilder/SpatialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testBuildComponent()

$component = new Component();
$component->setField('geo');
$component->setDistance(50);
$component->setDistance(50.1415);
$component->setPoint('48.2233,16.3161');

$request = $builder->buildComponent($component, $request);
Expand All @@ -25,7 +25,7 @@ public function testBuildComponent()
[
'pt' => '48.2233,16.3161',
'sfield' => 'geo',
'd' => 50,
'd' => 50.1415,
],
$request->getParams()
);
Expand Down
4 changes: 2 additions & 2 deletions tests/Component/SpatialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testConfigMode()
{
$options = [
'sfield' => 'geo',
'd' => 50,
'd' => 50.1415,
'pt' => '48.2233,16.3161',
];

Expand Down Expand Up @@ -64,7 +64,7 @@ public function testSetAndGetField()

public function testSetAndGetDistance()
{
$value = 5;
$value = 5.9438;
$this->spatial->setDistance($value);

$this->assertEquals($value, $this->spatial->getDistance());
Expand Down

0 comments on commit 0e1d769

Please sign in to comment.