# Netatmo Station Météo - Anémomètre - Sens du vent - Points cardinaux

**URL:** <https://community.gladysassistant.com/t/netatmo-station-meteo-anemometre-sens-du-vent-points-cardinaux/5892>\
**Category:** Développement\
**Created:** [Décembre 10, 2020, 9:31 UTC](https://community.gladysassistant.com/t/netatmo-station-meteo-anemometre-sens-du-vent-points-cardinaux/5892 "2020-12-10T09:31:30Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [Décembre 11, 2020, 9:58 UTC](https://community.gladysassistant.com/t/netatmo-station-meteo-anemometre-sens-du-vent-points-cardinaux/5892/9 "2020-12-11T09:58:21Z")

</div>

J’utilise une fonction mise dans le fichier server/utils/cardinalpoint.js :

```auto
/** 
 * Given "0-360" returns the nearest cardinal direction "N/NE/E/SE/S/SW/W/NW"  
 */
function getCardinalDirection(angle) {
    if (typeof angle === 'string') {
        angle = parseInt(angle);
    }
    if (angle <= 0 || angle > 360 || typeof angle === 'undefined') {
        return '☈';
    }
    const arrows = { north: '↑ N', north_north_east: '↗ NNE', north_east: '↗ NE', east: '→ E', south_east: '↘ SE', south_south_east: '↘ SSE', south: '↓ S', south_south_west: '↙ SSW', south_west: '↙ SW', west: '← W', north_west: '↖ NW', north_north_west: '↖ NNW' };
    const directions = Object.keys(arrows);
    const degree = 360 / directions.length;
    angle = angle + degree / 2;
    for (let i = 0; i < directions.length; i++) {
      if (angle >= (i * degree) && angle < (i + 1) * degree) {
          return arrows[directions[i]];
        }
    }
    return arrows['north'];
  }
  module.exports = {
    getCardinalDirection,
  };

```

Car pour l’angle du vent il y a 16 direction possible. Je trouvais cela plus simple de récupérer la valeur en String dans la DB mais en effet je n’avais pas pensé à faire ça dans l’ui. Je vois pour le passer côté front du coup.

---

_[View the full topic](https://community.gladysassistant.com/t/netatmo-station-meteo-anemometre-sens-du-vent-points-cardinaux/5892)._
