@@ -17,7 +17,7 @@ export class MGRSValidatorDirective implements Validator {
1717 let error : ValidationErrors | null
1818 try {
1919 mgrs . toPoint ( control . value )
20- } catch ( e ) {
20+ } catch ( e ) {
2121 error = {
2222 mgrs : {
2323 value : control . value
@@ -60,7 +60,7 @@ type DMSFormValue = Partial<{ [DimensionKey.Latitude]: string, [DimensionKey.Lon
6060 templateUrl : './observation-edit-geometry-form.component.html' ,
6161 styleUrls : [ './observation-edit-geometry-form.component.scss' ] ,
6262 providers : [
63- { provide : NG_VALIDATORS , useExisting : MGRSValidatorDirective , multi : true } ,
63+ { provide : NG_VALIDATORS , useExisting : MGRSValidatorDirective , multi : true } ,
6464 { provide : NG_VALIDATORS , useExisting : DMSValidatorDirective , multi : true }
6565 ]
6666} )
@@ -97,8 +97,7 @@ export class ObservationEditGeometryFormComponent implements OnChanges, OnInit {
9797 @Inject ( MapService ) private mapService : any ,
9898 @Inject ( GeometryService ) private geometryService : any ,
9999 @Inject ( LocalStorageService ) private localStorageService : any ,
100- private snackBar : MatSnackBar )
101- {
100+ private snackBar : MatSnackBar ) {
102101 this . coordinateSystem = this . localStorageService . getCoordinateSystemEdit ( )
103102 }
104103
@@ -213,7 +212,7 @@ export class ObservationEditGeometryFormComponent implements OnChanges, OnInit {
213212 this . dmsForm . setValue ( formValue , { emitEvent : true } )
214213 return
215214 }
216- const [ first , second ] = coords . sort ( ( a , b ) => a instanceof DMSCoordinate ? - 1 : ( typeof b === 'number' ? 0 : 1 ) )
215+ const [ first , second ] = coords . sort ( ( a , b ) => a instanceof DMSCoordinate ? - 1 : ( typeof b === 'number' ? 0 : 1 ) )
217216 if ( typeof first === 'number' ) {
218217 // must both be numbers - assume latitude first
219218 const latDMS = DMSCoordinate . fromDecimalDegrees ( first , DimensionKey . Latitude )
@@ -249,7 +248,7 @@ export class ObservationEditGeometryFormComponent implements OnChanges, OnInit {
249248 if ( this . mgrsModel . control . invalid ) {
250249 return
251250 }
252- const [ lon , lat ] = mgrs . toPoint ( this . mgrs )
251+ const [ lon , lat ] = mgrs . toPoint ( this . mgrs )
253252 this . editCurrentCoordinates ( 'mgrs' , lat , lon )
254253 }
255254
@@ -275,14 +274,6 @@ export class ObservationEditGeometryFormComponent implements OnChanges, OnInit {
275274 this . feature . geometry . coordinates = [ ]
276275 this . feature . geometry . type = 'Polygon'
277276 break ;
278- default :
279- this . latitude = null
280- this . longitude = null
281- this . mgrs = null
282- this . dmsForm . setValue ( { [ DimensionKey . Latitude ] : '' , [ DimensionKey . Longitude ] : '' } , { emitEvent : false } )
283- delete this . feature . geometry . type
284- this . featureEdit . cancel ( )
285- break ;
286277 }
287278 if ( shapeType ) {
288279 this . onEditShape ( )
@@ -295,16 +286,16 @@ export class ObservationEditGeometryFormComponent implements OnChanges, OnInit {
295286
296287 editCurrentCoordinates ( from : CoordinateSystemKey , lat : number , lon : number ) : void {
297288 this . coordinateEditSource = from
298- let coordinates = [ ...this . feature . geometry . coordinates ]
289+ let coordinates = [ ...this . feature . geometry . coordinates ]
299290 if ( this . feature . geometry . type === 'Point' ) {
300- coordinates = [ lon , lat ]
291+ coordinates = [ lon , lat ]
301292 }
302293 else if ( this . feature . geometry . type === 'LineString' ) {
303- coordinates [ this . selectedVertexIndex ] = [ lon , lat ]
294+ coordinates [ this . selectedVertexIndex ] = [ lon , lat ]
304295 }
305296 else if ( this . feature . geometry . type === 'Polygon' ) {
306297 if ( coordinates [ 0 ] ) {
307- coordinates [ 0 ] [ this . selectedVertexIndex ] = [ lon , lat ]
298+ coordinates [ 0 ] [ this . selectedVertexIndex ] = [ lon , lat ]
308299 }
309300 }
310301 ensurePolygonClosed ( this . feature , coordinates )
@@ -332,7 +323,7 @@ export class ObservationEditGeometryFormComponent implements OnChanges, OnInit {
332323 this . coordinateEditSource = null
333324 if ( from !== 'mgrs' ) {
334325 this . mgrs = this . toMgrs ( this . feature )
335- this . mgrsModel . control . setValue ( this . mgrs , { emitEvent :false , emitViewToModelChange :false , emitModelToViewChange :true } )
326+ this . mgrsModel . control . setValue ( this . mgrs , { emitEvent : false , emitViewToModelChange : false , emitModelToViewChange : true } )
336327 }
337328 if ( from !== 'dms' ) {
338329 this . dmsForm . setValue ( {
@@ -347,10 +338,10 @@ function ensurePolygonClosed(feature, coordinates) {
347338 // Ensure first and last points are the same for polygon
348339 if ( feature . geometry . type === 'Polygon' ) {
349340 if ( feature . editedVertex === 0 ) {
350- coordinates [ 0 ] [ coordinates [ 0 ] . length - 1 ] = [ ...coordinates [ 0 ] [ 0 ] ]
341+ coordinates [ 0 ] [ coordinates [ 0 ] . length - 1 ] = [ ...coordinates [ 0 ] [ 0 ] ]
351342 }
352343 else if ( feature . editedVertex === coordinates [ 0 ] . length - 1 ) {
353- coordinates [ 0 ] [ 0 ] = [ ...coordinates [ 0 ] [ coordinates [ 0 ] . length - 1 ] ]
344+ coordinates [ 0 ] [ 0 ] = [ ...coordinates [ 0 ] [ coordinates [ 0 ] . length - 1 ] ]
354345 }
355346 }
356347}
0 commit comments