diff --git a/demo/src/environments/environment.ts b/demo/src/environments/environment.ts
index 6fcae8266d..c2125809ab 100644
--- a/demo/src/environments/environment.ts
+++ b/demo/src/environments/environment.ts
@@ -68,7 +68,7 @@ export const environment: Environment = {
enabled: true
},
icherche: {
- searchUrl: '/apis/icherche/geocode',
+ searchUrl: '/apis/icherche',
order: 2,
enabled: true,
params: {
@@ -76,7 +76,7 @@ export const environment: Environment = {
}
},
icherchereverse: {
- searchUrl: '/apis/territoires/locate',
+ searchUrl: '/apis/territoires',
order: 3,
enabled: true
},
diff --git a/packages/geo/src/lib/print/shared/print.service.ts b/packages/geo/src/lib/print/shared/print.service.ts
index 410b84a037..e69c216d22 100644
--- a/packages/geo/src/lib/print/shared/print.service.ts
+++ b/packages/geo/src/lib/print/shared/print.service.ts
@@ -246,7 +246,7 @@ export class PrintService {
}
const scaleText = translate.instant('igo.geo.printForm.scale');
const mapScale = map.viewController.getScale(dpi);
- textProjScale += scaleText + ' ~ 1 ' + formatScale(mapScale);
+ textProjScale += scaleText + ': ~ 1 ' + formatScale(mapScale);
}
doc.setFont('courier');
doc.setFontSize(projScaleSize);
@@ -493,7 +493,7 @@ export class PrintService {
const mapScale = map.viewController.getScale(resolution);
newContext.textAlign = 'start';
newContext.fillText(
- scaleText + ' ~ 1 : ' + formatScale(mapScale),
+ scaleText + ': ~ 1 : ' + formatScale(mapScale),
positionWProjScale,
positionHProjScale
);
diff --git a/packages/geo/src/lib/search/search-settings/search-settings.component.html b/packages/geo/src/lib/search/search-settings/search-settings.component.html
index d785f13a00..8a0b3a3ca0 100644
--- a/packages/geo/src/lib/search/search-settings/search-settings.component.html
+++ b/packages/geo/src/lib/search/search-settings/search-settings.component.html
@@ -60,13 +60,13 @@
- {{settingValue.title}}
+ (change)="settingsValueCheckedCheckbox($event, source, setting, settingValue)">
+ {{settingValue.title}}
diff --git a/packages/geo/src/lib/search/search-settings/search-settings.component.scss b/packages/geo/src/lib/search/search-settings/search-settings.component.scss
index 8a27295e44..3eb09ef8b1 100644
--- a/packages/geo/src/lib/search/search-settings/search-settings.component.scss
+++ b/packages/geo/src/lib/search/search-settings/search-settings.component.scss
@@ -2,6 +2,7 @@
.checkAllButton{
text-align: center;
+ padding: 0 5px;
}
.igo-search-settings-button ::ng-deep div.mat-button-ripple-round {
diff --git a/packages/geo/src/lib/search/search-settings/search-settings.component.ts b/packages/geo/src/lib/search/search-settings/search-settings.component.ts
index 5d3bf5a998..1c7b53f72a 100644
--- a/packages/geo/src/lib/search/search-settings/search-settings.component.ts
+++ b/packages/geo/src/lib/search/search-settings/search-settings.component.ts
@@ -1,4 +1,4 @@
-import {MatCheckboxChange, MatRadioChange } from '@angular/material';
+import { MatCheckboxChange, MatRadioChange } from '@angular/material';
import {
Component,
@@ -9,7 +9,10 @@ import {
import { SearchSourceService } from '../shared/search-source.service';
import { SearchSource } from '../shared/sources/source';
-import { SearchSourceSettings, SettingOptions } from '../shared/sources/source.interfaces';
+import {
+ SearchSourceSettings,
+ SettingOptions
+} from '../shared/sources/source.interfaces';
/**
* This component allows a user to select a search type yo enable. In it's
@@ -25,9 +28,7 @@ import { SearchSourceSettings, SettingOptions } from '../shared/sources/source.i
styleUrls: ['./search-settings.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
-
export class SearchSettingsComponent {
-
/**
* Event emitted when the enabled search source changes
*/
@@ -40,7 +41,9 @@ export class SearchSettingsComponent {
* @internal
*/
getSearchSources(): SearchSource[] {
- return this.searchSourceService.getSources().filter(s => s.available && s.getId() !== 'map');
+ return this.searchSourceService
+ .getSources()
+ .filter(s => s.available && s.getId() !== 'map');
}
/**
@@ -80,11 +83,7 @@ export class SearchSettingsComponent {
* Triggered when the check all / uncheck all type is clicked,
* @internal
*/
- checkUncheckAll(
- event,
- source: SearchSource,
- setting: SearchSourceSettings
- ) {
+ checkUncheckAll(event, source: SearchSource, setting: SearchSourceSettings) {
event.stopPropagation();
this.computeCheckAllBehavior(setting);
setting.values.forEach(settingValue => {
@@ -104,7 +103,7 @@ export class SearchSettingsComponent {
setting: SearchSourceSettings,
settingValue: SettingOptions
) {
- setting.values.forEach( conf => {
+ setting.values.forEach(conf => {
if (conf.value !== settingValue.value) {
conf.enabled = !event.source.checked;
} else {
@@ -120,4 +119,7 @@ export class SearchSettingsComponent {
this.searchSourceChange.emit(source);
}
+ getAvailableValues(setting: SearchSourceSettings) {
+ return setting.values.filter(s => s.available !== false);
+ }
}
diff --git a/packages/geo/src/lib/search/shared/search.interfaces.ts b/packages/geo/src/lib/search/shared/search.interfaces.ts
index 12d29bae05..32f5518618 100644
--- a/packages/geo/src/lib/search/shared/search.interfaces.ts
+++ b/packages/geo/src/lib/search/shared/search.interfaces.ts
@@ -1,6 +1,5 @@
import { Observable } from 'rxjs';
-import { MetadataLayerOptions } from './../../metadata/shared/metadata.interface';
import { SearchSource } from './sources/source';
export interface Research {
diff --git a/packages/geo/src/lib/search/shared/sources/icherche.providers.ts b/packages/geo/src/lib/search/shared/sources/icherche.providers.ts
index 5a5b340104..0e0ae90d7d 100644
--- a/packages/geo/src/lib/search/shared/sources/icherche.providers.ts
+++ b/packages/geo/src/lib/search/shared/sources/icherche.providers.ts
@@ -1,3 +1,4 @@
+import { Injector } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ConfigService, LanguageService } from '@igo2/core';
@@ -37,12 +38,14 @@ export function provideDefaultIChercheSearchResultFormatter() {
export function ichercheSearchSourceFactory(
http: HttpClient,
config: ConfigService,
- formatter: IChercheSearchResultFormatter
+ formatter: IChercheSearchResultFormatter,
+ injector: Injector
) {
return new IChercheSearchSource(
http,
config.getConfig(`searchSources.${IChercheSearchSource.id}`),
- formatter
+ formatter,
+ injector
);
}
@@ -54,7 +57,7 @@ export function provideIChercheSearchSource() {
provide: SearchSource,
useFactory: ichercheSearchSourceFactory,
multi: true,
- deps: [HttpClient, ConfigService, IChercheSearchResultFormatter]
+ deps: [HttpClient, ConfigService, IChercheSearchResultFormatter, Injector]
};
}
@@ -64,11 +67,13 @@ export function provideIChercheSearchSource() {
*/
export function ichercheReverseSearchSourceFactory(
http: HttpClient,
- config: ConfigService
+ config: ConfigService,
+ injector: Injector
) {
return new IChercheReverseSearchSource(
http,
- config.getConfig(`searchSources.${IChercheReverseSearchSource.id}`)
+ config.getConfig(`searchSources.${IChercheReverseSearchSource.id}`),
+ injector
);
}
@@ -80,6 +85,6 @@ export function provideIChercheReverseSearchSource() {
provide: SearchSource,
useFactory: ichercheReverseSearchSourceFactory,
multi: true,
- deps: [HttpClient, ConfigService]
+ deps: [HttpClient, ConfigService, Injector]
};
}
diff --git a/packages/geo/src/lib/search/shared/sources/icherche.ts b/packages/geo/src/lib/search/shared/sources/icherche.ts
index 35f1d11256..1c60d7a6fd 100644
--- a/packages/geo/src/lib/search/shared/sources/icherche.ts
+++ b/packages/geo/src/lib/search/shared/sources/icherche.ts
@@ -1,11 +1,11 @@
-import { Injectable, Inject } from '@angular/core';
+import { Injectable, Inject, Injector } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
+import { AuthService } from '@igo2/auth';
import { LanguageService } from '@igo2/core';
-
import { ObjectUtils } from '@igo2/utils';
import { FEATURE, Feature } from '../../../feature';
@@ -47,9 +47,19 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
private http: HttpClient,
@Inject('options') options: SearchSourceOptions,
@Inject(IChercheSearchResultFormatter)
- private formatter: IChercheSearchResultFormatter
+ private formatter: IChercheSearchResultFormatter,
+ injector: Injector
) {
super(options);
+
+ const authService = injector.get(AuthService);
+ if (!authService) {
+ this.getAllowedTypes();
+ } else {
+ authService.authenticate$.subscribe(() => {
+ this.getAllowedTypes();
+ });
+ }
}
getId(): string {
@@ -58,8 +68,8 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
protected getDefaultOptions(): SearchSourceOptions {
return {
- title: 'ICherche Québec',
- searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/icherche/geocode',
+ title: 'iCherche',
+ searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/icherche',
settings: [
{
type: 'checkbox',
@@ -87,13 +97,14 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
title: 'Route',
value: 'routes',
enabled: false,
+ available: false,
hashtags: ['route']
},
{
title: 'Municipalité',
value: 'municipalites',
enabled: true,
- hashtags: ['municipalité']
+ hashtags: ['municipalité', 'mun']
},
// {
// title: 'Ancienne municipalité',
@@ -127,6 +138,7 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
title: 'Entreprise',
value: 'entreprises',
enabled: false,
+ available: false,
hashtags: ['entreprise']
}
]
@@ -212,7 +224,7 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
if (!params.get('type').length) {
return of([]);
}
- return this.http.get(this.searchUrl, { params }).pipe(
+ return this.http.get(`${this.searchUrl}/geocode`, { params }).pipe(
map((response: IChercheResponse) => this.extractResults(response)),
catchError(err => {
err.error.toDisplay = true;
@@ -222,6 +234,17 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
);
}
+ private getAllowedTypes() {
+ return this.http
+ .get(`${this.searchUrl}/types`)
+ .subscribe((types: string[]) => {
+ const typeSetting = this.settings.find(s => s.name === 'type');
+ typeSetting.values.forEach(v => {
+ v.available = types.indexOf(v.value as string) > -1;
+ });
+ });
+ }
+
private computeRequestParams(
term: string,
options: TextSearchOptions
@@ -348,13 +371,23 @@ export class IChercheReverseSearchSource extends SearchSource
implements ReverseSearch {
static id = 'icherchereverse';
static type = FEATURE;
- static propertiesBlacklist: string[] = ['doc_type'];
+ static propertiesBlacklist: string[] = [];
constructor(
private http: HttpClient,
- @Inject('options') options: SearchSourceOptions
+ @Inject('options') options: SearchSourceOptions,
+ injector: Injector
) {
super(options);
+
+ const authService = injector.get(AuthService);
+ if (!authService) {
+ this.getAllowedTypes();
+ } else {
+ authService.authenticate$.subscribe(() => {
+ this.getAllowedTypes();
+ });
+ }
}
getId(): string {
@@ -364,7 +397,7 @@ export class IChercheReverseSearchSource extends SearchSource
protected getDefaultOptions(): SearchSourceOptions {
return {
title: 'Territoire (Géocodage inversé)',
- searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/territoires/locate',
+ searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/territoires',
settings: [
{
type: 'checkbox',
@@ -379,7 +412,8 @@ export class IChercheReverseSearchSource extends SearchSource
{
title: 'Route',
value: 'routes',
- enabled: false
+ enabled: false,
+ available: false
},
{
title: 'Arrondissement',
@@ -418,13 +452,24 @@ export class IChercheReverseSearchSource extends SearchSource
options?: ReverseSearchOptions
): Observable[]> {
const params = this.computeRequestParams(lonLat, options || {});
- return this.http.get(this.searchUrl, { params }).pipe(
+ return this.http.get(`${this.searchUrl}/locate`, { params }).pipe(
map((response: IChercheReverseResponse) => {
return this.extractResults(response);
})
);
}
+ private getAllowedTypes() {
+ return this.http
+ .get(`${this.searchUrl}/types`)
+ .subscribe((types: string[]) => {
+ const typeSetting = this.settings.find(s => s.name === 'type');
+ typeSetting.values.forEach(v => {
+ v.available = types.indexOf(v.value as string) > -1;
+ });
+ });
+ }
+
private computeRequestParams(
lonLat: [number, number],
options?: ReverseSearchOptions
diff --git a/packages/geo/src/lib/search/shared/sources/ilayer.ts b/packages/geo/src/lib/search/shared/sources/ilayer.ts
index da5d7be056..082180c785 100644
--- a/packages/geo/src/lib/search/shared/sources/ilayer.ts
+++ b/packages/geo/src/lib/search/shared/sources/ilayer.ts
@@ -85,7 +85,41 @@ export class ILayerSearchSource extends SearchSource implements TextSearch {
protected getDefaultOptions(): ILayerSearchSourceOptions {
return {
title: 'igo.geo.search.ilayer.name',
- searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/layers/search'
+ searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/layers/search',
+ settings: [
+ {
+ type: 'radiobutton',
+ title: 'results limit',
+ name: 'limit',
+ values: [
+ {
+ title: '1',
+ value: 1,
+ enabled: false
+ },
+ {
+ title: '5',
+ value: 5,
+ enabled: true
+ },
+ {
+ title: '10',
+ value: 10,
+ enabled: false
+ },
+ {
+ title: '25',
+ value: 25,
+ enabled: false
+ },
+ {
+ title: '50',
+ value: 50,
+ enabled: false
+ }
+ ]
+ }
+ ]
};
}
diff --git a/packages/geo/src/lib/search/shared/sources/source.interfaces.ts b/packages/geo/src/lib/search/shared/sources/source.interfaces.ts
index 44a6cae92f..2a89d1c484 100644
--- a/packages/geo/src/lib/search/shared/sources/source.interfaces.ts
+++ b/packages/geo/src/lib/search/shared/sources/source.interfaces.ts
@@ -23,6 +23,7 @@ export interface SettingOptions {
enabled: boolean;
title: string;
hashtags?: string[];
+ available?: boolean;
}
export interface TextSearchOptions {
diff --git a/packages/geo/src/lib/search/shared/sources/source.ts b/packages/geo/src/lib/search/shared/sources/source.ts
index 29e8767e65..25e11c09b7 100644
--- a/packages/geo/src/lib/search/shared/sources/source.ts
+++ b/packages/geo/src/lib/search/shared/sources/source.ts
@@ -107,11 +107,13 @@ export class SearchSource {
break;
case 'checkbox':
let confValue = '';
- setting.values.forEach(conf => {
- if (conf.enabled) {
- confValue += conf.value + ',';
- }
- });
+ setting.values
+ .filter(s => s.available !== false)
+ .forEach(conf => {
+ if (conf.enabled) {
+ confValue += conf.value + ',';
+ }
+ });
confValue = confValue.slice(0, -1);
this.options.params = Object.assign(this.options.params || {}, {
[setting.name]: confValue
@@ -152,8 +154,17 @@ export class SearchSource {
searchSourceSetting.values.forEach(conf => {
const hashtagKey = hashtag.substring(1);
if (typeof conf.value === 'string') {
- const types = conf.value.toLowerCase().split(',');
- const index = types.indexOf(hashtagKey.toLowerCase());
+ const types = conf.value
+ .toLowerCase()
+ .normalize('NFD')
+ .replace(/[\u0300-\u036f]/g, '')
+ .split(',');
+ const index = types.indexOf(
+ hashtagKey
+ .toLowerCase()
+ .normalize('NFD')
+ .replace(/[\u0300-\u036f]/g, '')
+ );
if (index !== -1) {
hashtagsValid.push(types[index]);
}
diff --git a/proxy.conf.json b/proxy.conf.json
index 729687edc9..06087d314c 100644
--- a/proxy.conf.json
+++ b/proxy.conf.json
@@ -1,9 +1,4 @@
{
- "/icherche/": {
- "target": "https://geoegl.msp.gouv.qc.ca",
- "changeOrigin": true,
- "secure": false
- },
"/ws/": {
"target": "https://geoegl.msp.gouv.qc.ca",
"secure": false,