Skip to content

Commit 5701635

Browse files
kappu72offtherailz
authored andcommitted
Close geosolutions-it#3695 Wrong west south coordinates (geosolutions-it#3742)
1 parent e3669ab commit 5701635

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

web/client/components/mapcontrols/mouseposition/MousePositionLabelDMS.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,22 @@ class MousePositionLabelDMS extends React.Component {
3636
};
3737

3838
render() {
39+
const {lng, lat} = this.props.position || {};
3940
let pos = this.getPositionValues(this.props.position);
41+
let lgnSign = lng < 0 ? "-" : "";
42+
let latSign = lat < 0 ? "-" : "";
4043
let integerFormat = {style: "decimal", minimumIntegerDigits: 2, maximumFractionDigits: 0};
4144
let decimalFormat = {style: "decimal", minimumIntegerDigits: 2, maximumFractionDigits: 2, minimumFractionDigits: 2};
4245
let lngDFormat = {style: "decimal", minimumIntegerDigits: 3, maximumFractionDigits: 0};
4346
return (
4447
<h5>
4548
<Label bsSize="lg" bsStyle="info">
46-
<span>Lat: </span><NumberFormat key="latD" numberParams={integerFormat} value={roundCoord({roundingBehaviour: "floor", value: pos.lat, maximumFractionDigits: integerFormat.maximumFractionDigits})} />
49+
<span>Lat: {latSign}</span><NumberFormat key="latD" numberParams={integerFormat} value={Math.abs(pos.lat)} />
4750
<span>° </span><NumberFormat key="latM" numberParams={integerFormat} value={roundCoord({roundingBehaviour: "floor", value: pos.latM, maximumFractionDigits: integerFormat.maximumFractionDigits})} />
4851
<span>&apos; </span><NumberFormat key="latS" numberParams={decimalFormat} value={pos.latS}/>
4952
<span>&apos;&apos;</span>
5053
<span className="mouseposition-separator"/>
51-
<span> Lng: </span><NumberFormat key="lngD" numberParams={lngDFormat} value={roundCoord({roundingBehaviour: "floor", value: pos.lng, maximumFractionDigits: lngDFormat.maximumFractionDigits})} />
54+
<span> Lng: {lgnSign}</span><NumberFormat key="lngD" numberParams={lngDFormat} value={Math.abs(pos.lng)} />
5255
<span>° </span><NumberFormat key="lngM" numberParams={integerFormat} value={roundCoord({roundingBehaviour: "floor", value: pos.lngM, maximumFractionDigits: integerFormat.maximumFractionDigits})} />
5356
<span>&apos; </span><NumberFormat key="lngS" numberParams={decimalFormat} value={pos.lngS}/><span>''</span>
5457
</Label>

web/client/components/mapcontrols/mouseposition/__tests__/MousePositionLabelDMS-test.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ describe('MousePositionLabelDMS', () => {
2525
});
2626

2727
it('checks default', () => {
28-
2928
const cmp = ReactDOM.render(
3029
<MousePositionLabelDMS/>
3130
, document.getElementById("container"));
@@ -70,7 +69,6 @@ describe('MousePositionLabelDMS', () => {
7069

7170
const cmpDom = ReactDOM.findDOMNode(cmp);
7271
expect(cmpDom).toExist();
73-
7472
expect(cmpDom.textContent).toBe("Lat: 13° 31' 60.00'' Lng: 028° 18' 00.00''");
7573
});
7674

@@ -104,8 +102,36 @@ describe('MousePositionLabelDMS', () => {
104102
expect(cmp).toExist();
105103
const cmpDom = ReactDOM.findDOMNode(cmp);
106104
expect(cmpDom).toExist();
105+
// it should be Lat: -00° 00' 21.60'' Lng: -000° 00' 21.60'' instead of Lat: -01° 00' 21.60'' Lng: -001° 00' 21.60''
106+
expect(cmpDom.textContent).toBe("Lat: -00° 00' 21.60'' Lng: -000° 00' 21.60''");
107+
});
108+
it('test sign changes when crossing greenwich meridian and equator parallel and latD lngD are 0', () => {
109+
const cmp = ReactDOM.render(
110+
<IntlProvider>
111+
<MousePositionLabelDMS
112+
position={{lng: -0.006, lat: -0.006}}
113+
/>
114+
</IntlProvider>
115+
, document.getElementById("container"));
116+
expect(cmp).toExist();
117+
const cmpDom = ReactDOM.findDOMNode(cmp);
118+
expect(cmpDom).toExist();
107119

108-
// it should be 010° 28' 30.05'' instead of 010° 29' 00''
120+
// it should be Lat: -00° 00' 21.60'' Lng: -000° 00' 21.60''
109121
expect(cmpDom.textContent).toBe("Lat: -00° 00' 21.60'' Lng: -000° 00' 21.60''");
122+
123+
const cmpPositive = ReactDOM.render(
124+
<IntlProvider>
125+
<MousePositionLabelDMS
126+
position={{lng: 0.006, lat: 0.006}}
127+
/>
128+
</IntlProvider>
129+
, document.getElementById("container"));
130+
expect(cmpPositive).toExist();
131+
const cmpDomPositive = ReactDOM.findDOMNode(cmpPositive);
132+
expect(cmpDomPositive).toExist();
133+
134+
// it should be Lat: 00° 00' 21.60'' Lng: 000° 00' 21.60'' instead of Lat: -00° 00' 21.60'' Lng: -000° 00' 21.60''
135+
expect(cmpDomPositive.textContent).toBe("Lat: 00° 00' 21.60'' Lng: 000° 00' 21.60''");
110136
});
111137
});

0 commit comments

Comments
 (0)