Skip to content

Commit 8e85ec8

Browse files
committed
remove None type
1 parent c4d07a4 commit 8e85ec8

File tree

2 files changed

+36
-46
lines changed

2 files changed

+36
-46
lines changed

web-app/admin/src/app/observation/observation-edit/observation-edit-geometry/observation-edit-geometry-form.component.html

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
<div class="chip-type">
33
<span class="chip-type__label">GEOMETRY</span>
44
<mat-chip-list selectable="true">
5-
<mat-chip color="primary" [selected]="selectedShapeType === 'Point'" (click)="shapeTypeChanged('Point')">Point</mat-chip>
6-
<mat-chip color="primary" [selected]="selectedShapeType === 'LineString'" (click)="shapeTypeChanged('LineString')">Line</mat-chip>
7-
<mat-chip color="primary" [selected]="selectedShapeType === 'Polygon'" (click)="shapeTypeChanged('Polygon')">Polygon</mat-chip>
8-
<mat-chip color="primary" [selected]="selectedShapeType === undefined" (click)="shapeTypeChanged()">None</mat-chip>
5+
<mat-chip color="primary" [selected]="selectedShapeType === 'Point'"
6+
(click)="shapeTypeChanged('Point')">Point</mat-chip>
7+
<mat-chip color="primary" [selected]="selectedShapeType === 'LineString'"
8+
(click)="shapeTypeChanged('LineString')">Line</mat-chip>
9+
<mat-chip color="primary" [selected]="selectedShapeType === 'Polygon'"
10+
(click)="shapeTypeChanged('Polygon')">Polygon</mat-chip>
911
</mat-chip-list>
1012
</div>
1113

1214
<div class="chip-type">
1315
<span class="chip-type__label mat-subtitle-2">MANUAL EDIT</span>
1416
<mat-chip-list selectable="true">
15-
<mat-chip color="primary" [selected]="coordinateSystem === 'wgs84'" (click)="coordinateSystemChange('wgs84')">Lat/Lng</mat-chip>
16-
<mat-chip color="primary" [selected]="coordinateSystem === 'mgrs'" (click)="coordinateSystemChange('mgrs')">MGRS</mat-chip>
17-
<mat-chip color="primary" [selected]="coordinateSystem === 'dms'" (click)="coordinateSystemChange('dms')">DMS</mat-chip>
17+
<mat-chip color="primary" [selected]="coordinateSystem === 'wgs84'"
18+
(click)="coordinateSystemChange('wgs84')">Lat/Lng</mat-chip>
19+
<mat-chip color="primary" [selected]="coordinateSystem === 'mgrs'"
20+
(click)="coordinateSystemChange('mgrs')">MGRS</mat-chip>
21+
<mat-chip color="primary" [selected]="coordinateSystem === 'dms'"
22+
(click)="coordinateSystemChange('dms')">DMS</mat-chip>
1823
</mat-chip-list>
1924
</div>
2025

@@ -23,13 +28,15 @@
2328
<div class="coordinate">
2429
<mat-form-field appearance="standard">
2530
<mat-label>Latitude</mat-label>
26-
<input matInput type="number" step="any" min="-90" max="90" [(ngModel)]="latitude" (ngModelChange)="onLatLngChange()" [disabled]="!feature?.geometry?.coordinates">
31+
<input matInput type="number" step="any" min="-90" max="90" [(ngModel)]="latitude"
32+
(ngModelChange)="onLatLngChange()" [disabled]="!feature?.geometry?.coordinates">
2733
</mat-form-field>
2834
</div>
2935
<div class="coordinate">
3036
<mat-form-field appearance="standard">
3137
<mat-label>Longitude</mat-label>
32-
<input matInput type="number" step="any" min="-180" max="180" [(ngModel)]="longitude" (ngModelChange)="onLatLngChange()" [disabled]="!feature?.geometry?.coordinates">
38+
<input matInput type="number" step="any" min="-180" max="180" [(ngModel)]="longitude"
39+
(ngModelChange)="onLatLngChange()" [disabled]="!feature?.geometry?.coordinates">
3340
</mat-form-field>
3441
</div>
3542
</div>
@@ -40,7 +47,8 @@
4047
<div class="coordinate">
4148
<mat-form-field appearance="standard">
4249
<mat-label>MGRS</mat-label>
43-
<input matInput type="text" [(ngModel)]="mgrs" (ngModelChange)="onMgrsChange()" [disabled]="!feature?.geometry?.coordinates" #mgrsModel="ngModel" mgrs>
50+
<input matInput type="text" [(ngModel)]="mgrs" (ngModelChange)="onMgrsChange()"
51+
[disabled]="!feature?.geometry?.coordinates" #mgrsModel="ngModel" mgrs>
4452
<mat-error>Invalid MGRS</mat-error>
4553
</mat-form-field>
4654
</div>
@@ -52,26 +60,16 @@
5260
<div class="coordinate">
5361
<mat-form-field appearance="standard">
5462
<mat-label>Latitude DMS</mat-label>
55-
<input type="text" placeholder="00° 00' 00&quot; N"
56-
matInput
57-
formControlName="lat"
58-
[inputMask]="dmsLatMask"
59-
(paste)="onDmsPaste($event, DMSDimensionKey.Latitude)"
60-
dmsValidation="latitude"
61-
>
63+
<input type="text" placeholder="00° 00' 00&quot; N" matInput formControlName="lat" [inputMask]="dmsLatMask"
64+
(paste)="onDmsPaste($event, DMSDimensionKey.Latitude)" dmsValidation="latitude">
6265
<mat-error>Invalid DMS latitude</mat-error>
6366
</mat-form-field>
6467
</div>
6568
<div class="coordinate">
6669
<mat-form-field appearance="standard">
6770
<mat-label>Longitude DMS</mat-label>
68-
<input type="text" placeholder="000° 00' 00&quot; E"
69-
matInput
70-
formControlName="lon"
71-
[inputMask]="dmsLonMask"
72-
(paste)="onDmsPaste($event, DMSDimensionKey.Longitude)"
73-
dmsValidation="longitude"
74-
>
71+
<input type="text" placeholder="000° 00' 00&quot; E" matInput formControlName="lon" [inputMask]="dmsLonMask"
72+
(paste)="onDmsPaste($event, DMSDimensionKey.Longitude)" dmsValidation="longitude">
7573
<mat-error>Invalid DMS longitude</mat-error>
7674
</mat-form-field>
7775
</div>
@@ -80,6 +78,7 @@
8078

8179
<div class="edit-location__actions">
8280
<button mat-button type="button" color="primary" (click)="onCancel()">Cancel</button>
83-
<button mat-flat-button type="button" color="primary" (click)="onSave()" [disabled]="!feature?.geometry?.coordinates?.length">Save</button>
81+
<button mat-flat-button type="button" color="primary" (click)="onSave()"
82+
[disabled]="!feature?.geometry?.coordinates?.length">Save</button>
8483
</div>
8584
</div>

web-app/admin/src/app/observation/observation-edit/observation-edit-geometry/observation-edit-geometry-form.component.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)