@@ -5,8 +5,6 @@ import { getOwner } from '@ember/application';
5
5
import { format as formatDate , isValid as isValidDate , formatDistanceToNow } from 'date-fns' ;
6
6
import isRelationMissing from '@fleetbase/ember-core/utils/is-relation-missing' ;
7
7
import isValidCoordinates from '@fleetbase/ember-core/utils/is-valid-coordinates' ;
8
- import isLatitude from '@fleetbase/ember-core/utils/is-latitude' ;
9
- import isLongitude from '@fleetbase/ember-core/utils/is-longitude' ;
10
8
import config from 'ember-get-config' ;
11
9
12
10
export default class DriverModel extends Model {
@@ -123,33 +121,24 @@ export default class DriverModel extends Model {
123
121
return formatDate ( this . created_at , 'dd, MMM' ) ;
124
122
}
125
123
126
- @computed ( 'location' ) get latitude ( ) {
127
- if ( this . location ) {
128
- let x = get ( this . location , 'coordinates.0' ) ;
129
- let y = get ( this . location , 'coordinates.1' ) ;
130
-
131
- return isLatitude ( x ) ? x : y ;
132
- }
133
-
134
- return 0 ;
135
- }
136
-
137
124
@computed ( 'location' ) get longitude ( ) {
138
- if ( this . location ) {
139
- let x = get ( this . location , 'coordinates.0' ) ;
140
- let y = get ( this . location , 'coordinates.1' ) ;
141
-
142
- return isLongitude ( y ) ? y : x ;
143
- }
125
+ return get ( this . location , 'coordinates.0' ) ;
126
+ }
144
127
145
- return 0 ;
128
+ @computed ( 'location' ) get latitude ( ) {
129
+ return get ( this . location , 'coordinates.1' ) ;
146
130
}
147
131
148
132
@computed ( 'latitude' , 'longitude' ) get coordinates ( ) {
149
133
// eslint-disable-next-line ember/no-get
150
134
return [ get ( this , 'latitude' ) , get ( this , 'longitude' ) ] ;
151
135
}
152
136
137
+ @computed ( 'latitude' , 'longitude' ) get positionString ( ) {
138
+ // eslint-disable-next-line ember/no-get
139
+ return `${ get ( this , 'latitude' ) } ${ get ( this , 'longitude' ) } ` ;
140
+ }
141
+
153
142
@computed ( 'latitude' , 'longitude' ) get latlng ( ) {
154
143
return {
155
144
// eslint-disable-next-line ember/no-get
@@ -168,7 +157,11 @@ export default class DriverModel extends Model {
168
157
} ;
169
158
}
170
159
171
- @computed ( 'coordinates' ) get hasValidCoordinates ( ) {
160
+ @computed ( 'coordinates' , 'latitude' , 'longitude' ) get hasValidCoordinates ( ) {
161
+ if ( this . longitude === 0 || this . latitude === 0 ) {
162
+ return false ;
163
+ }
164
+
172
165
return isValidCoordinates ( this . coordinates ) ;
173
166
}
174
167
0 commit comments