Skip to content

Commit

Permalink
Release v1.15.4 (#1308)
Browse files Browse the repository at this point in the history
* Revert "chore(searchSource): deletion of cadastre search source (#1152)"

This reverts commit b55613f.

* 1.15.4
  • Loading branch information
alecarn authored Jul 5, 2023
1 parent e226274 commit 2393363
Show file tree
Hide file tree
Showing 15 changed files with 217 additions and 30 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## [1.15.3](https://github.com/infra-geo-ouverte/igo2-lib/compare/1.15.2...1.15.3) (2023-06-12)
## [1.15.4](https://github.com/infra-geo-ouverte/igo2-lib/compare/1.15.2...1.15.4) (2023-07-05)


### Bug Fixes
### Reverts

* **draw:** drawing circle crash whole drawing component. ([#1273](https://github.com/infra-geo-ouverte/igo2-lib/issues/1273)) ([e3ee3b5](https://github.com/infra-geo-ouverte/igo2-lib/commit/e3ee3b593e4afde201fc601373478aa8cf8556a3))
* Revert "chore(searchSource): deletion of cadastre search source (#1152)" ([2e073d7](https://github.com/infra-geo-ouverte/igo2-lib/commit/2e073d71890d3b8aea68f84129f4600b9652d158)), closes [#1152](https://github.com/infra-geo-ouverte/igo2-lib/issues/1152)



Expand Down
2 changes: 2 additions & 0 deletions demo/src/app/geo/search/search.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
provideNominatimSearchSource,
provideIChercheReverseSearchSource,
provideCoordinatesReverseSearchSource,
provideCadastreSearchSource,
provideStoredQueriesSearchSource,
provideStoredQueriesReverseSearchSource
} from '@igo2/geo';
Expand Down Expand Up @@ -54,6 +55,7 @@ import { AppSearchRoutingModule } from './search-routing.module';
exports: [AppSearchComponent],
providers: [
provideCoordinatesReverseSearchSource(),
provideCadastreSearchSource(),
provideIChercheSearchSource(),
provideWorkspaceSearchSource(),
provideILayerSearchSource(),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"workspaces": [
"./packages/*"
],
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/auth",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand All @@ -26,8 +26,8 @@
"@angular/forms": "^14.3.0",
"@angular/material": "^14.2.7",
"@angular/router": "^14.3.0",
"@igo2/core": "^1.15.3",
"@igo2/utils": "^1.15.3",
"@igo2/core": "^1.15.4",
"@igo2/utils": "^1.15.4",
"rxjs": "^7.5.6",
"@azure/msal-angular": "^2.4.1",
"@azure/msal-browser": "^2.28.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/common",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand All @@ -18,8 +18,8 @@
"@angular/core": "^14.3.0",
"@angular/material": "^14.2.7",
"@angular/platform-browser": "^14.3.0",
"@igo2/core": "^1.15.3",
"@igo2/utils": "^1.15.3",
"@igo2/core": "^1.15.4",
"@igo2/utils": "^1.15.4",
"scroll-into-view-if-needed": "^2.2.20",
"typy": "^3.3.0"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/context/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/context",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand All @@ -20,11 +20,11 @@
"@angular/forms": "^14.3.0",
"@angular/material": "^14.2.7",
"@angular/platform-browser": "^14.3.0",
"@igo2/auth": "^1.15.3",
"@igo2/common": "^1.15.3",
"@igo2/core": "^1.15.3",
"@igo2/utils": "^1.15.3",
"@igo2/geo": "^1.15.3",
"@igo2/auth": "^1.15.4",
"@igo2/common": "^1.15.4",
"@igo2/core": "^1.15.4",
"@igo2/utils": "^1.15.4",
"@igo2/geo": "^1.15.4",
"ol": "^7.3.0",
"rxjs": "^7.5.6"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/core",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand All @@ -23,7 +23,7 @@
"@angular/core": "^14.3.0",
"@angular/platform-browser": "^14.3.0",
"@angular/router": "^14.3.0",
"@igo2/utils": "^1.15.3",
"@igo2/utils": "^1.15.4",
"rxjs": "^7.5.6",
"ngx-indexed-db": "^11.0.2",
"ngx-toastr": "^15.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/config/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export interface Version {
}

export const version: Version = {
lib: '1.15.3',
releaseDate: 1686590809688
lib: '1.15.4',
releaseDate: 1688557109892
};
8 changes: 4 additions & 4 deletions packages/geo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/geo",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand Down Expand Up @@ -30,9 +30,9 @@
"@angular/forms": "^14.3.0",
"@angular/material": "^14.2.7",
"@angular/platform-browser": "^14.3.0",
"@igo2/common": "^1.15.3",
"@igo2/core": "^1.15.3",
"@igo2/utils": "^1.15.3",
"@igo2/common": "^1.15.4",
"@igo2/core": "^1.15.4",
"@igo2/utils": "^1.15.4",
"flexsearch": "0.7.21",
"ol": "^7.3.0",
"proj4": "^2.8.0",
Expand Down
36 changes: 36 additions & 0 deletions packages/geo/src/lib/search/shared/sources/cadastre.providers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { HttpClient } from '@angular/common/http';

import { ConfigService, LanguageService, StorageService } from '@igo2/core';

import { SearchSource } from './source';
import { CadastreSearchSource } from './cadastre';

/**
* Cadastre search source factory
* @ignore
*/
export function cadastreSearchSourceFactory(
http: HttpClient,
languageService: LanguageService,
storageService: StorageService,
config: ConfigService
) {
return new CadastreSearchSource(
http,
languageService,
storageService,
config.getConfig(`searchSources.${CadastreSearchSource.id}`),
);
}

/**
* Function that returns a provider for the Cadastre search source
*/
export function provideCadastreSearchSource() {
return {
provide: SearchSource,
useFactory: cadastreSearchSourceFactory,
multi: true,
deps: [HttpClient, LanguageService, StorageService, ConfigService]
};
}
147 changes: 147 additions & 0 deletions packages/geo/src/lib/search/shared/sources/cadastre.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';

import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';

import olWKT from 'ol/format/WKT';

import { FEATURE, Feature, FeatureGeometry } from '../../../feature';

import { SearchResult } from '../search.interfaces';
import { SearchSource, TextSearch } from './source';
import { SearchSourceOptions, TextSearchOptions } from './source.interfaces';

import { LanguageService, StorageService } from '@igo2/core';
import { computeTermSimilarity } from '../search.utils';
import { Cacheable } from 'ts-cacheable';
import { GeoJsonGeometryTypes } from 'geojson';

/**
* Cadastre search source
*/
@Injectable()
export class CadastreSearchSource extends SearchSource implements TextSearch {
static id = 'cadastre';
static type = FEATURE;

constructor(
private http: HttpClient,
private languageService: LanguageService,
storageService: StorageService,
@Inject('options') options: SearchSourceOptions
) {
super(options, storageService);
}

getId(): string {
return CadastreSearchSource.id;
}

getType(): string {
return CadastreSearchSource.type;
}

/*
* Source : https://wiki.openstreetmap.org/wiki/Key:amenity
*/
protected getDefaultOptions(): SearchSourceOptions {
return {
title: 'Cadastre (Québec)',
searchUrl: 'https://carto.cptaq.gouv.qc.ca/php/find_lot_v1.php?'
};
}

/**
* Search a place by name
* @param term Place name
* @returns Observable of <SearchResult<Feature>[]
*/
@Cacheable({
maxCacheCount: 20
})
search(
term: string | undefined,
options?: TextSearchOptions
): Observable<SearchResult<Feature>[]> {
term = term.endsWith(',') ? term.slice(0, -1) : term;
term = term.startsWith(',') ? term.substr(1) : term;
term = term.replace(/ /g, '');

const params = this.computeSearchRequestParams(term, options || {});
if (!params.get('numero') || !params.get('numero').match(/^[0-9,]+$/g)) {
return of([]);
}
return this.http
.get(this.searchUrl, { params, responseType: 'text' })
.pipe(map((response: string) => this.extractResults(response, term)));
}

private computeSearchRequestParams(
term: string,
options: TextSearchOptions
): HttpParams {
return new HttpParams({
fromObject: Object.assign(
{
numero: term,
epsg: '4326'
},
this.params,
options.params || {}
)
});
}

private extractResults(response: string, term: string): SearchResult<Feature>[] {
return response
.split('<br />')
.filter((lot: string) => lot.length > 0)
.map((lot: string) => this.dataToResult(lot, term));
}

private dataToResult(data: string, term: string): SearchResult<Feature> {
const lot = data.split(';');
const numero = lot[0];
const wkt = lot[7];
const geometry = this.computeGeometry(wkt);

const properties = {
NoLot: numero,
Route: '<span class="routing"> <u>' + this.languageService.translate.instant('igo.geo.seeRouting') + '</u> </span>'
};
const id = [this.getId(), 'cadastre', numero].join('.');

return {
source: this,
meta: {
dataType: FEATURE,
id,
title: numero,
score: computeTermSimilarity(term.trim(), numero),
icon: 'map-marker'
},
data: {
type: FEATURE,
projection: 'EPSG:4326',
geometry,
properties,
meta: {
id,
title: numero
}
}
};
}

private computeGeometry(wkt: string): FeatureGeometry {
const feature = new olWKT().readFeature(wkt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:4326'
});
return {
type: feature.getGeometry().getType() as GeoJsonGeometryTypes,
coordinates: (feature.getGeometry() as any).getCoordinates()
};
}
}
2 changes: 2 additions & 0 deletions packages/geo/src/lib/search/shared/sources/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './cadastre';
export * from './cadastre.providers';
export * from './source';
export * from './source.interfaces';
export * from './icherche';
Expand Down
6 changes: 3 additions & 3 deletions packages/integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/integration",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand All @@ -16,8 +16,8 @@
"peerDependencies": {
"@angular/common": "^14.3.0",
"@angular/core": "^14.3.0",
"@igo2/geo": "1.15.3",
"@igo2/context": "1.15.3",
"@igo2/geo": "1.15.4",
"@igo2/context": "1.15.4",
"rxjs": "^7.5.6"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/utils",
"version": "1.15.3",
"version": "1.15.4",
"description": "IGO Library",
"author": "IGO Community",
"keywords": ["igo"],
Expand Down

0 comments on commit 2393363

Please sign in to comment.