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(*): add a widget to workspace to select features by geometry #1627

Open
wants to merge 13 commits into
base: next
Choose a base branch
from
Open
75 changes: 75 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions packages/geo/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"ts-cacheable",
"ts-md5",
"@turf/helpers",
"@turf/boolean-intersects",
"@turf/buffer",
"@turf/intersect",
"@turf/line-intersect",
"@turf/point-on-feature"
],
Expand Down
3 changes: 3 additions & 0 deletions packages/geo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
},
"dependencies": {
"@turf/helpers": "^6.5.0",
"@turf/boolean-intersects": "^6.5.0",
"@turf/buffer": "^6.5.0",
"@turf/intersect": "^6.5.0",
"@turf/line-intersect": "^6.5.0",
"@turf/point-on-feature": "^6.5.0",
"nosleep.js": "^0.12.0",
Expand Down
32 changes: 31 additions & 1 deletion packages/geo/src/lib/geometry/shared/geometry.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import OlPoint from 'ol/geom/Point';
import OlPolygon from 'ol/geom/Polygon';
import * as olstyle from 'ol/style';

import { lineString } from '@turf/helpers';
import booleanIntersects from '@turf/boolean-intersects';
import buffer from '@turf/buffer';
import { Units, lineString } from '@turf/helpers';
import lineIntersect from '@turf/line-intersect';

import { FeatureGeometry } from '../../feature';
import {
GeometrySliceLineStringError,
GeometrySliceMultiPolygonError,
Expand Down Expand Up @@ -158,3 +161,30 @@ export function getMousePositionFromOlGeometryEvent(olEvent: BasicEvent) {
const olGeometryCast = olGeometry as OlPoint | OlLineString | OlCircle;
return olGeometryCast.getFlatCoordinates().slice(-2) as [number, number];
}

export function doesOlGeometryIntersects(
olGeometry1: OlGeometry,
olGeometry2: OlGeometry
): boolean {
const olGeoJSON = new OlGeoJSON();
const firstGeom = olGeoJSON.writeGeometryObject(olGeometry1);
const secondGeom = olGeoJSON.writeGeometryObject(olGeometry2);
return booleanIntersects(
firstGeom as FeatureGeometry,
secondGeom as FeatureGeometry
);
}

export function bufferOlGeometry(
olGeometry: OlGeometry,
dist: number,
units: Units = 'meters'
): FeatureGeometry {
const olGeoJSON = new OlGeoJSON();
const bufferedGeom = olGeoJSON.writeGeometryObject(
olGeometry
) as FeatureGeometry;

var buffered = buffer(bufferedGeom, dist, { units });
return buffered.geometry;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<button class="close" mat-icon-button color="warn" (click)="onClose()">
<mat-icon svgIcon="close"></mat-icon>
</button>

<igo-form
*ngIf="form$ | async as form"
[form]="form"
[formData]="data$ | async"
(submitForm)="onSubmit($event)"
>
<div *ngIf="form.fields.length" class="form-container">
<igo-form-field
*ngFor="let field of form.fields"
[field]="field"
></igo-form-field>
</div>

<div formButtons class="actions-container">
<button
mat-stroked-button
type="button"
color="primary"
(click)="clearForm()"
>
{{
'igo.geo.workspace.widget.interactiveSelection.reset.button' | translate
}}
</button>
<button
mat-flat-button
type="submit"
color="primary"
[disabled]="submitDisabled"
>
{{ submitButtonText$ | async | translate }}
</button>
</div>
</igo-form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:host {
.close {
margin-top: 1px;
margin-right: 2px;
position: absolute;
top: 0;
right: 0;
}
.actions-container {
button:not(:last-child) {
margin-right: 8px;
}
}
.form-container {
width: 100%;
padding: 10px;

igo-form-field {
display: block;
height: auto;
}
}
}
Loading
Loading