Skip to content
Snippets Groups Projects
Commit 0c4eeff2 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Fix bug for some non geographical data

parent d0235f52
Branches
Tags
No related merge requests found
Pipeline #
...@@ -4,7 +4,6 @@ import { ErrorHandler, Injectable } from '@angular/core'; ...@@ -4,7 +4,6 @@ import { ErrorHandler, Injectable } from '@angular/core';
export class ErrorsHandler implements ErrorHandler { export class ErrorsHandler implements ErrorHandler {
handleError(error: Error) { handleError(error: Error) {
console.log(error);
return; return;
} }
......
...@@ -58,13 +58,17 @@ ...@@ -58,13 +58,17 @@
{{ element.properties[key] }} {{ element.properties[key] }}
</div> </div>
<div class="column is-12 data-details"> <div class="column is-12 data-details">
<h4> <h4 *ngIf="element.geometry">
<i class="fas fa-map-signs title-icon"></i>Geometry</h4> <i class="fas fa-map-signs title-icon"></i>Geometry</h4>
<app-data-properties class="properties" [object]="element.geometry"></app-data-properties> <app-data-properties class="properties" [object]="element.geometry" *ngIf="element.geometry"></app-data-properties>
<h4> <h4 *ngIf="element.properties">
<i class="fas fa-info title-icon"></i>Properties</h4> <i class="fas fa-info title-icon"></i>Properties</h4>
<app-data-properties class="properties" [object]="element.properties"></app-data-properties> <app-data-properties class="properties" [object]="element.properties" *ngIf="element.properties"></app-data-properties>
<div class="has-text-centered">
<span i18n="@@dataset.data.unavailableInfo">Unavailable information for this data</span>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -14,9 +14,11 @@ export class Data implements IData { ...@@ -14,9 +14,11 @@ export class Data implements IData {
type: string; type: string;
properties: any; properties: any;
constructor(data: IData) { constructor(data?: IData) {
this.geometry = data.geometry; if (data) {
this.type = data.type; this.geometry = data.geometry;
this.properties = data.properties; this.type = data.type;
this.properties = data.properties;
}
} }
} }
...@@ -43,20 +43,24 @@ export class DatasetDetailService { ...@@ -43,20 +43,24 @@ export class DatasetDetailService {
if (e.hits.hits.length > 0) { if (e.hits.hits.length > 0) {
const metadata = new Metadata(e.hits.hits[0]._source['metadata-fr']); const metadata = new Metadata(e.hits.hits[0]._source['metadata-fr']);
const coordinates = e.hits.hits[0]._source['metadata-fr']['bbox']['coordinates'][0]; const bbox = e.hits.hits[0]._source['metadata-fr']['bbox'];
if (bbox !== undefined && bbox['coordinates'] !== undefined) {
const coordinates = e.hits.hits[0]._source['metadata-fr']['bbox']['coordinates'][0];
metadata.max_west = Math.max.apply(Math, coordinates.map((point) => {
return point[0];
}));
metadata.max_east = Math.min.apply(Math, coordinates.map((point) => {
return point[0];
}));
metadata.max_north = Math.max.apply(Math, coordinates.map((point) => {
return point[1];
}));
metadata.max_south = Math.min.apply(Math, coordinates.map((point) => {
return point[1];
}));
}
metadata.dataset_index = e.hits.hits[0]._index; metadata.dataset_index = e.hits.hits[0]._index;
metadata.max_west = Math.max.apply(Math, coordinates.map((point) => {
return point[0];
}));
metadata.max_east = Math.min.apply(Math, coordinates.map((point) => {
return point[0];
}));
metadata.max_north = Math.max.apply(Math, coordinates.map((point) => {
return point[1];
}));
metadata.max_south = Math.min.apply(Math, coordinates.map((point) => {
return point[1];
}));
this._dataset.totalData = e.hits.total; this._dataset.totalData = e.hits.total;
...@@ -102,7 +106,7 @@ export class DatasetDetailService { ...@@ -102,7 +106,7 @@ export class DatasetDetailService {
return this._children; return this._children;
}), }),
catchError((err) => { catchError((err) => {
throw this._errorService.handleError(err, { message: errors.geosource.getDatasetById }); throw this._errorService.handleError(err, { message: errors.geosource.getDatasetChildren });
}), }),
), ),
); );
...@@ -117,6 +121,9 @@ export class DatasetDetailService { ...@@ -117,6 +121,9 @@ export class DatasetDetailService {
map((res) => { map((res) => {
return this._dataset.data; return this._dataset.data;
}), }),
catchError((err) => {
throw this._errorService.handleError(err, { message: errors.geosource.getDatasetData });
}),
); );
} }
...@@ -126,11 +133,16 @@ export class DatasetDetailService { ...@@ -126,11 +133,16 @@ export class DatasetDetailService {
tap((res) => { tap((res) => {
this._dataset.data = []; this._dataset.data = [];
this._researchMaxResult = res.hits.total; this._researchMaxResult = res.hits.total;
console.log(res)
this.setDatasetData(res); this.setDatasetData(res);
}), }),
map((res) => { map((res) => {
return this._dataset.data; return this._dataset.data;
}), }),
catchError((err) => {
console.log(err)
throw this._errorService.handleError(err, { message: errors.geosource.getDatasetData });
}),
); );
} }
......
...@@ -17,6 +17,7 @@ export const errors = { ...@@ -17,6 +17,7 @@ export const errors = {
mapError: 'Une erreur c\'est produite avec la carte', mapError: 'Une erreur c\'est produite avec la carte',
getDatasetChildren: 'Impossible de récupérer les enfants du jeu de données', getDatasetChildren: 'Impossible de récupérer les enfants du jeu de données',
getDatasetTitle: 'Impossible de récupérer le titre du jeu de données', getDatasetTitle: 'Impossible de récupérer le titre du jeu de données',
getDatasetData: 'Impossible de récupérer la donnée du jeu de données',
}, },
matomo: { matomo: {
getViews: 'Impossible de récupérer le nombre de vues', getViews: 'Impossible de récupérer le nombre de vues',
......
...@@ -17,6 +17,7 @@ export const errors = { ...@@ -17,6 +17,7 @@ export const errors = {
mapError: 'Something went wrong with the map', mapError: 'Something went wrong with the map',
getDatasetChildren: 'Failed to get the dataset children', getDatasetChildren: 'Failed to get the dataset children',
getDatasetTitle: 'Failed to get the datatset title', getDatasetTitle: 'Failed to get the datatset title',
getDatasetData: 'Failed to get the dataset data',
}, },
matomo: { matomo: {
getViews: 'Cannot get the views count', getViews: 'Cannot get the views count',
......
...@@ -215,6 +215,10 @@ ...@@ -215,6 +215,10 @@
<source>Associated articles</source> <source>Associated articles</source>
<target>Associated articles</target> <target>Associated articles</target>
</trans-unit> </trans-unit>
<trans-unit id="dataset.data.unavailableInfo" datatype="html">
<source>Unavailable information for this data</source>
<target>Unavailable information for this data</target>
</trans-unit>
<trans-unit id="wordpresPageError.title" datatype="html"> <trans-unit id="wordpresPageError.title" datatype="html">
<source>Oups, something went wrong ...</source> <source>Oups, something went wrong ...</source>
<target>Oups, something went wrong ...</target> <target>Oups, something went wrong ...</target>
......
...@@ -223,6 +223,10 @@ ...@@ -223,6 +223,10 @@
<source>Associated articles</source> <source>Associated articles</source>
<target>Articles associés</target> <target>Articles associés</target>
</trans-unit> </trans-unit>
<trans-unit id="dataset.data.unavailableInfo" datatype="html">
<source>Unavailable information for this data</source>
<target>Information non disponible pour cette donnée</target>
</trans-unit>
<trans-unit id="wordpresPageError.title" datatype="html"> <trans-unit id="wordpresPageError.title" datatype="html">
<source>Oups, something went wrong ...</source> <source>Oups, something went wrong ...</source>
<target>Oups, il y a eu un problème ...</target> <target>Oups, il y a eu un problème ...</target>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment