Skip to content

Commit

Permalink
feat(custom-pu-grid): add new shape type from_shapefile
Browse files Browse the repository at this point in the history
  • Loading branch information
kgajowy committed Sep 10, 2021
1 parent 5a77099 commit 7b06b6a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class ShapeTypeFromShapefile1631266860142 implements MigrationInterface {
async down(queryRunner: QueryRunner) {
await queryRunner.query(
`alter type shape_type add value 'from_shapefile';`,
);
await queryRunner.query(
`CREATE TABLE planning_units_geom_from_shapefile PARTITION OF planning_units_geom FOR VALUES IN ('from_shapefile');`,
);
}

async up(queryRunner: QueryRunner) {
// see AddDraftStatusToJobStatusEnum1618241224000
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export class PlanningUnitsGridProcessor
FROM (
SELECT json_array_elements($1::json -> 'features') AS features
) AS f
ON CONFLICT ON CONSTRAINT planning_units_geom_the_geom_type_key DO UPDATE SET type = 'irregular'
ON CONFLICT ON CONSTRAINT planning_units_geom_the_geom_type_key DO UPDATE SET type = 'from_shapefile'
RETURNING "id"
`,
[result.right, ShapeType.Irregular, projectId],
[result.right, ShapeType.FromShapefile, projectId],
);
const output = plainToClass<JobOutput, JobOutput>(JobOutput, {
geometryIds: puGeometriesIds.map((row) => row.id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const getFixtures = async () => {
from (
select the_geom
from planning_units_geom
where type = 'irregular'
where type = 'from_shapefile'
and project_id = $1
) as t(geom)
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum ShapeType {
Square = 'square',
Hexagon = 'hexagon',
Irregular = 'irregular',
FromShapefile = 'from_shapefile',
}

@Entity('planning_units_geom')
Expand Down

0 comments on commit 7b06b6a

Please sign in to comment.