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

Ajoute la surface des parcelles dans l'API sortante #151

Merged
merged 1 commit into from
Feb 20, 2024
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
2 changes: 1 addition & 1 deletion docs/rfc/002-api-lecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Le parcellaire est représenté en utilisant le [format standardisé **GeoJSON**
| `dateEngagement` | `string` | Date d'engagement en Agriculture Biologique de la parcelle (si applicable) (au format [ISO 8601]) |
| `commentaire` | `string` | Notes d'audit spécifiques à la parcelle |
| `annotations` | `json` | Liste d'étiquettes ([cf. Annotations](#valeurs-possibles--annotations)) |

| `surface` | `float` | Surface totale de la parcelle (en hectare) calculée à partir de ses contours géographiques |

##### Propriétés facultatives

Expand Down
2 changes: 2 additions & 0 deletions lib/outputs/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

const { featureCollection } = require('@turf/helpers')
const area = require('@turf/area').default

/**
* @param {CartoBioCulture} culture
Expand All @@ -33,6 +34,7 @@ function parcelleToApi (parcelle) {
...parcelle,
properties: {
id: String(parcelle.id),
surface: area(parcelle.geometry) / 10000,
commune: parcelle.properties.COMMUNE,
cultures: parcelle.properties.cultures.map(cultureToApi),
niveauConversion: parcelle.properties.conversion_niveau,
Expand Down
1 change: 1 addition & 0 deletions lib/outputs/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type OutputApiFeatureProperties = {
id: string;
commune: string;
cultures: OutputApiCulture[];
surface: number;
niveauConversion: EtatProduction;
dateEngagement: string;
commentaire: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agencebio/cartobio-types",
"version": "1.1.3",
"version": "1.2.0",
"main": "types.d.ts",
"repository": {
"type": "git",
Expand Down
14 changes: 13 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@fastify/swagger-ui": "^1.3.0",
"@sentry/integrations": "^7.36.0",
"@sentry/node": "^7.28.1",
"@turf/area": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/intersect": "^6.5.0",
"@turf/union": "^6.5.0",
Expand Down
Loading