Skip to content

Commit

Permalink
Merge pull request #703 from biigle/patch-1
Browse files Browse the repository at this point in the history
Fix regression with PolygonValidator and modules
  • Loading branch information
mzur authored Nov 21, 2023
2 parents cd0a8c5 + 81522a0 commit 933c6f7
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit 933c6f7

Please sign in to comment.