Skip to content

Commit

Permalink
fix: pr review tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
angelhigueraacid committed Mar 15, 2022
1 parent b7df73d commit e0f3221
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { Readable } from 'stream';
import { isLeft } from 'fp-ts/lib/Either';
import { ClonePieceUrisResolver } from '@marxan/cloning/infrastructure/clone-piece-data';
import { ProjectCustomProtectedAreasContent } from '@marxan/cloning/infrastructure/clone-piece-data/project-custom-protected-areas';
import { ProtectedArea } from '@marxan/protected-areas';

interface ProjectCustomProtectedAreasSelectResult {
fullname: string;
fullName: string;
ewkb: Buffer;
}

Expand All @@ -40,27 +41,22 @@ export class ProjectCustomProtectedAreasPieceExporter
}

async run(input: ExportJobInput): Promise<ExportJobOutput> {
console.log('hola');
const customProtectedAreas: ProjectCustomProtectedAreasSelectResult[] = await this.geoprocessingEntityManager.query(
`
SELECT ST_AsEWKB(the_geom) as ewkb, full_name as fullname
FROM wdpa
WHERE project_id = $1
`,
[input.resourceId],
);

console.log(customProtectedAreas);
const customProtectedAreas: ProjectCustomProtectedAreasSelectResult[] = await this.geoprocessingEntityManager
.createQueryBuilder()
.select('ST_AsEWKB(wdpa.the_geom)', 'ewkb')
.addSelect('full_name', 'fullName')
.from(ProtectedArea, 'wdpa')
.where('project_id = :projectId', { projectId: input.resourceId })
.execute();

const content = customProtectedAreas.map<ProjectCustomProtectedAreasContent>(
(protectedArea) => {
return {
fullName: protectedArea.fullname,
fullName: protectedArea.fullName,
ewkb: protectedArea.ewkb.toJSON().data,
};
},
);
console.log(content);

const outputFile = await this.fileRepository.save(
Readable.from(JSON.stringify(content)),
Expand Down

0 comments on commit e0f3221

Please sign in to comment.