Skip to content

Commit

Permalink
5401. fix rectangular roundvalue and step (#5402) (#5412)
Browse files Browse the repository at this point in the history
* 5401. fix rectangular roundvalue and step

* 5401. add unit test for length of input value

* 5401. fix rectangular spatial filter test
  • Loading branch information
gitcontributor committed Jun 5, 2020
1 parent fa461fd commit 9220893
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions web/client/components/data/query/GeometryDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class GeometryDetails extends React.Component {
style={{minWidth: '105px', margin: 'auto'}}
type="number"
id={"queryform_bbox_" + name}
step={!this.isWGS84() ? 1 : this.getStep(this.props.zoom)}
defaultValue={this.roundValue(value, !this.isWGS84() ? 100 : 1000000)}
step={this.getStep(this.props.zoom)}
defaultValue={this.roundValue(value, 1000000)}
onChange={(evt) => this.onUpdateBBOX(evt.target.value, name)}/>
</div>
);
Expand Down Expand Up @@ -323,7 +323,7 @@ class GeometryDetails extends React.Component {
for (let prop in this.extent) {
if (prop) {
let coordinateInput = document.getElementById("queryform_bbox_" + prop);
coordinateInput.value = this.roundValue(this.extent[prop], !this.isWGS84() ? 100 : 1000000);
coordinateInput.value = this.roundValue(this.extent[prop], 1000000);
this.onUpdateBBOX(this.extent[prop], prop);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ describe('GeometryDetails', () => {
it('creates the GeometryDetails component with BBOX selection', () => {
let geometry = {
extent: [
-1335833.8895192828,
5212046.6457833825,
-543239.115071175,
5785158.045300978
-12080719.446415536,
3035467.26726092,
-11112109.423985783,
6146760.066580733
],
projection: "EPSG:900913",
type: "Polygon"
Expand Down Expand Up @@ -172,5 +172,16 @@ describe('GeometryDetails', () => {
let panelBodyRows = pb.getElementsByClassName('row');
expect(panelBodyRows).toExist();
expect(panelBodyRows.length).toBe(3);

const panelBodyInputs = pb.querySelectorAll('input');
expect(panelBodyInputs.length).toBe(4);

[...panelBodyInputs].forEach(input => {
const [mainValue, decimals] = input.value.split('.');

expect(mainValue.length + decimals.length <= 10 && mainValue.length + decimals.length >= 7).toBeTruthy();
expect(mainValue.length <= 4).toBeTruthy(); // can be ranged from 180 to -180
expect(decimals.length === 6).toBeTruthy(); // always must be 6 digits
});
});
});

0 comments on commit 9220893

Please sign in to comment.