Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatial filter1.5.2 #769

Merged
merged 7 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</mat-slide-toggle>
</div>

<div class="buffer-unit" *ngIf="isPolygon()">
<!-- <div class="buffer-unit" *ngIf="isPolygon()">
<form class="buffer-form">
<mat-form-field class="buffer">
<input type="number" matInput placeholder="{{'igo.geo.spatialFilter.buffer' | translate}}" [formControl]="bufferFormControl"
Expand All @@ -43,7 +43,7 @@
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div> -->

<div class="radius-unit" *ngIf="isPoint()">
<form class="radius-form">
Expand Down Expand Up @@ -132,13 +132,13 @@

<div class="buttons">

<button *ngIf="isPredefined()" mat-raised-button class="clear-search-button" [disabled]="!queryType && !zone"
(click)="clearSearch()">
{{'igo.geo.spatialFilter.clearSearch' | translate}}
</button>
<button *ngIf="isPredefined()" mat-raised-button class="clear-search-button" [disabled]="disabledClearSearch()"
(click)="clearSearch()">
{{'igo.geo.spatialFilter.clearSearch' | translate}}
</button>

<button *ngIf="isPolygon() || isPoint()" mat-raised-button class="clear-form-button" [disabled]="this.formControl.value === null"
(click)="this.formControl.reset()">
(click)="clearDrawZone()">
{{'igo.geo.spatialFilter.clearForm' | translate}}
</button>

Expand All @@ -147,7 +147,7 @@
{{'igo.geo.spatialFilter.goSearch' | translate}}
</button>

<button mat-raised-button class="remove-button" [disabled]="!store.entities$.getValue().length && !zone && !drawZone" (click)="clearButton()">
<button mat-raised-button class="remove-button" [disabled]="layers.length === 0" (click)="clearButton()">
{{'igo.geo.spatialFilter.removeLayer' | translate}}
</button>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit {
return [MeasureLengthUnit.Meters, MeasureLengthUnit.Kilometers];
}

@Input() layers: Layer[];
@Input() layers: Layer[] = [];

@Input()
get thematicLength(): number {
Expand Down Expand Up @@ -268,6 +268,10 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit {
if (value) {
this.value$.next(value);
this.drawZone = this.formControl.value as Feature;
if (this.buffer !== 0) {
this.drawZoneEvent.emit(this.drawZone);
this.bufferFormControl.setValue(this.buffer);
}
} else {
this.value$.next(undefined);
this.drawZone = undefined;
Expand All @@ -286,29 +290,29 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit {

this.bufferChanges$$ = this.bufferFormControl.valueChanges
.pipe(
debounceTime(500),
distinctUntilChanged()
debounceTime(500)
)
.subscribe((value) => {
if (this.measureUnit === MeasureLengthUnit.Meters && value > 0 && value < 100000) {
if (this.measureUnit === MeasureLengthUnit.Meters && value > 0 && value <= 100000) {
this.buffer = value;
this.bufferEvent.emit(value);
this.zoneWithBuffer = buffer(turf.polygon(this.drawZone.coordinates), this.bufferFormControl.value / 1000, {units: 'kilometers'});
this.zoneWithBufferChange.emit(this.zoneWithBuffer);
} else if (this.measureUnit === MeasureLengthUnit.Kilometers && value > 0 && value < 100) {
} else if (this.measureUnit === MeasureLengthUnit.Kilometers && value > 0 && value <= 100) {
this.buffer = value;
this.bufferEvent.emit(value);
this.zoneWithBuffer = buffer(turf.polygon(this.drawZone.coordinates), this.bufferFormControl.value, {units: 'kilometers'});
this.zoneWithBufferChange.emit(this.zoneWithBuffer);
} else if (value === 0 && value === this.bufferFormControl.value) {
} else if (value === 0) {
this.buffer = value;
this.bufferEvent.emit(value);
this.drawZoneEvent.emit(this.drawZone);
} else if (
value < 0 ||
(this.measureUnit === MeasureLengthUnit.Meters && value >= 100000) ||
(this.measureUnit === MeasureLengthUnit.Kilometers && value >= 100)) {
(this.measureUnit === MeasureLengthUnit.Meters && value > 100000) ||
(this.measureUnit === MeasureLengthUnit.Kilometers && value > 100)) {
this.bufferFormControl.setValue(0);
this.buffer = 0;
this.messageService.alert(this.languageService.translate.instant('igo.geo.spatialFilter.bufferAlert'),
this.languageService.translate.instant('igo.geo.spatialFilter.warning'));
}
Expand Down Expand Up @@ -559,16 +563,24 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit {
*/
clearButton() {
this.loading = true;
this.loading = false;
if (this.store) {
this.store.clear();
}
if (this.isPoint() || this.isPolygon()) {
this.drawZone = undefined;
this.bufferFormControl.setValue(0);
this.formControl.reset();
}
this.bufferFormControl.setValue(0);
this.buffer = 0;
this.bufferEvent.emit(0);
this.clearButtonEvent.emit();
this.loading = false;
}

clearDrawZone() {
this.formControl.reset();
this.bufferFormControl.setValue(0);
this.buffer = 0;
}

/**
Expand All @@ -577,6 +589,8 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit {
clearSearch() {
this.selectedThematics.clear();
this.bufferFormControl.setValue(0);
this.buffer = 0;
this.bufferEvent.emit(0);
this.thematicChange.emit([]);
this.clearSearchEvent.emit();
}
Expand Down Expand Up @@ -610,6 +624,15 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit {
return true;
}

disabledClearSearch() {
let disable = true;
this.selectedItemType === SpatialFilterItemType.Address ?
disable = this.queryType === undefined :
disable = this.queryType === undefined && this.selectedThematics.selected.length === 0;

return disable;
}

/**
* Manage radius value at user change
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
</mat-form-field>
<form>

<div class="buffer-div">
<!-- <div class="buffer-div">
<form class="buffer-form">
<mat-form-field class="buffer">
<input type="number" matInput placeholder="{{'igo.geo.spatialFilter.buffer' | translate}}" [formControl]="bufferFormControl"
[value]="0" [readonly]="!selectedZone">
[value]="0" [readonly]="!zone">
</mat-form-field>
</form>

Expand All @@ -28,4 +28,4 @@
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div> -->
Loading