Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1095: Spatial component should use floats for distance. #1096

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading