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

feat(geoprocessing): pu-inclusion: process geojson #258

Merged
merged 5 commits into from
Jun 17, 2021
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { GeoJSON } from 'geojson';
import { FeatureCollection, MultiPolygon, Polygon } from 'geojson';

export interface AdjustPlanningUnitsInput {
include?: {
pu?: string[];
geo?: GeoJSON[];
shape?: GeoJSON[];
geo?: FeatureCollection<Polygon | MultiPolygon>[];
};
exclude?: {
pu?: string[];
geo?: GeoJSON[];
shape?: GeoJSON[];
geo?: FeatureCollection<Polygon | MultiPolygon>[];
};
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { GeoJSON, MultiPolygon } from 'geojson';
import { FeatureCollection, MultiPolygon } from 'geojson';

const MultipolygonGeometry: MultiPolygon = Object.freeze({
type: 'MultiPolygon',
coordinates: [[[[0, 0]]]],
});

export const validGeoJson = (): GeoJSON => ({
export const validGeoJson = (): FeatureCollection<MultiPolygon> => ({
type: 'FeatureCollection',
features: [
{
Expand Down
6 changes: 3 additions & 3 deletions api/apps/api/src/modules/scenarios/dto/__mocks__/geometry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FeatureCollection } from 'geojson';
import { FeatureCollection, MultiPolygon } from 'geojson';

export const invalidMultiPolygon = (): FeatureCollection => ({
export const invalidMultiPolygon = (): FeatureCollection<MultiPolygon> => ({
type: 'FeatureCollection',
features: [
{
Expand All @@ -22,7 +22,7 @@ export const invalidMultiPolygon = (): FeatureCollection => ({
],
});

export const sampleMultiPolygonJson = (): FeatureCollection => ({
export const sampleMultiPolygonJson = (): FeatureCollection<MultiPolygon> => ({
type: 'FeatureCollection',
features: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IsOptional, IsUUID, ValidateNested } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { FeatureCollection } from 'geojson';
import { FeatureCollection, MultiPolygon, Polygon } from 'geojson';
import { Type } from 'class-transformer';
import { IsFeatureCollectionOfPolygons } from './is-feature-collection-of-polygons';

Expand All @@ -20,12 +20,12 @@ export class PlanningUnitsByGeoJsonUpdateDto {
@ApiPropertyOptional()
@IsOptional()
@IsFeatureCollectionOfPolygons({ each: true })
include?: FeatureCollection[];
include?: FeatureCollection<MultiPolygon | Polygon>[];

@ApiPropertyOptional()
@IsOptional()
@IsFeatureCollectionOfPolygons({ each: true })
exclude?: FeatureCollection[];
exclude?: FeatureCollection<MultiPolygon | Polygon>[];
}

export class UpdateScenarioPlanningUnitLockStatusDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,47 @@
* @todo move the planningUnitsGeom entity to the api
*/
import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { Geometry } from 'geojson';
import { defaultSrid } from '@marxan/utils/geo';

export enum ShapeType {
Square = 'square',
Hexagon = 'hexagon',
Irregular = 'irregular',
}
hotzevzl marked this conversation as resolved.
Show resolved Hide resolved

@Entity('planning_units_geom')
export class PlanningUnitsGeom {
/**
* id
*/
@ApiProperty()
@PrimaryColumn('uuid', { name: 'id' })
@PrimaryGeneratedColumn('uuid', { name: 'id' })
id!: string;

/**
* geometry column.
*/
@ApiProperty()
@Column('geometry', { name: 'the_geom', select: false })
theGeom!: any;
@Column('geometry', {
name: 'the_geom',
select: false,
spatialFeatureType: 'MultiPolygon',
srid: defaultSrid,
})
theGeom!: Geometry;

@Column({
enum: ShapeType,
type: 'enum',
name: 'type',
})
type!: ShapeType;

@Column({
nullable: true,
type: 'int',
})
size?: number | undefined | null;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading