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

Fix regression with PolygonValidator and modules #703

Merged
merged 1 commit into from
Nov 21, 2023
Merged
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
12 changes: 9 additions & 3 deletions resources/assets/js/annotations/ol/PolygonValidator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'jsts/org/locationtech/jts/monkey'; // This monkey patches jsts prototypes.
import GeometryCollection from '@biigle/ol/geom/GeometryCollection';
import JstsLinearRing from 'jsts/org/locationtech/jts/geom/LinearRing';
import LinearRing from '@biigle/ol/geom/LinearRing';
import LineString from '@biigle/ol/geom/LineString';
Expand Down Expand Up @@ -42,11 +43,16 @@ export function simplifyPolygon(feature) {
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon
MultiPolygon,
GeometryCollection
);

// Translate ol geometry into jsts geometry
let jstsPolygon = parser.read(feature.getGeometry());
// Use convertFromPolygon() instead of write() because:
// 1. Only Polygons are possible here
// 2. Some BIIGLE modules (e.g. magic-sam) import OpenLayers again and create
// geometry from there, so the "module Polygon" does not equal the "core Polygon"
// in the instanceof check of write().
let jstsPolygon = parser.convertFromPolygon(feature.getGeometry());

if (jstsPolygon.isSimple()) {
return feature;
Expand Down