Skip to content

Commit 0e1d769

Browse files
author
Edward Wu
authored
Issue #1095: Spatial component should use floats for distance. (#1096)
1 parent 376ad9f commit 0e1d769

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to the Solarium library will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
### Changed
9+
- Spatial component distance type changed from int to float
10+
711
## [6.3.2]
812
### Added
913
- Solarium\Component\ReRankQuery::setOperator()

src/Component/Spatial.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public function setField(string $sfield): self
5252
}
5353

5454
/**
55-
* @param int $distance
55+
* @param float $distance
5656
*
5757
* @return self Provides fluent interface
5858
*/
59-
public function setDistance(int $distance): self
59+
public function setDistance(float $distance): self
6060
{
6161
$this->setOption('d', $distance);
6262

@@ -89,9 +89,9 @@ public function getField(): ?string
8989
/**
9090
* Get d option.
9191
*
92-
* @return int|null
92+
* @return float|null
9393
*/
94-
public function getDistance(): ?int
94+
public function getDistance(): ?float
9595
{
9696
return $this->getOption('d');
9797
}

tests/Component/RequestBuilder/SpatialTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function testBuildComponent()
1616

1717
$component = new Component();
1818
$component->setField('geo');
19-
$component->setDistance(50);
19+
$component->setDistance(50.1415);
2020
$component->setPoint('48.2233,16.3161');
2121

2222
$request = $builder->buildComponent($component, $request);
@@ -25,7 +25,7 @@ public function testBuildComponent()
2525
[
2626
'pt' => '48.2233,16.3161',
2727
'sfield' => 'geo',
28-
'd' => 50,
28+
'd' => 50.1415,
2929
],
3030
$request->getParams()
3131
);

tests/Component/SpatialTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testConfigMode()
2222
{
2323
$options = [
2424
'sfield' => 'geo',
25-
'd' => 50,
25+
'd' => 50.1415,
2626
'pt' => '48.2233,16.3161',
2727
];
2828

@@ -64,7 +64,7 @@ public function testSetAndGetField()
6464

6565
public function testSetAndGetDistance()
6666
{
67-
$value = 5;
67+
$value = 5.9438;
6868
$this->spatial->setDistance($value);
6969

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

0 commit comments

Comments
 (0)