From 6332e02f5eb7ec1d58e314ab16edcd724e7181ac Mon Sep 17 00:00:00 2001 From: Leonardo Barreiros Date: Wed, 3 Nov 2021 18:20:03 -0300 Subject: [PATCH] [#30] feat - add export points to kml --- src/comunidades/comunidades.service.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/comunidades/comunidades.service.ts b/src/comunidades/comunidades.service.ts index 48ddaef..ec62913 100644 --- a/src/comunidades/comunidades.service.ts +++ b/src/comunidades/comunidades.service.ts @@ -397,4 +397,30 @@ export class ComunidadesService { return communityData; } + + async exportCommunityPointsToKml(communityId: string) { + const communityData = await this.getPointByCommunityId(communityId); + const geoJsonData = []; + + communityData.forEach((point) => { + geoJsonData.push({ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: point.coordinates, + }, + properties: { + name: point.title, + }, + }); + }); + + const geoJson = { + type: 'FeatureCollection', + features: geoJsonData, + }; + const kmlCommunityData = tokml(geoJson); + + return kmlCommunityData; + } }