Skip to content

Commit

Permalink
Simplify self-intersecting polygons when generating print params
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Mar 4, 2024
1 parent bca57df commit 37c45e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qwc2",
"version": "2024.02.29-master",
"version": "2024.03.04-master",
"description": "QGIS Web Client 2 core",
"author": "Sourcepole AG",
"license": "BSD-2-Clause",
Expand All @@ -24,7 +24,6 @@
"flat": "^6.0.1",
"formdata-json": "^1.0.0",
"geojson-bounding-box": "^0.2.0",
"geojson-polygon-self-intersections": "^1.2.1",
"html-react-parser": "^5.0.7",
"ismobilejs": "^1.1.1",
"jszip": "^3.10.1",
Expand Down Expand Up @@ -59,6 +58,7 @@
"react-swipeable": "^7.0.1",
"redux-logger": "^3.0.6",
"reselect": "^5.0.1",
"simplepolygon": "^1.2.3",
"sortablejs": "^1.15.1",
"stream-browserify": "^3.0.0",
"svgpath": "^2.6.0",
Expand Down
4 changes: 1 addition & 3 deletions plugins/map/RedliningSupport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import React from 'react';
import {connect} from 'react-redux';

import polySelfIntersections from 'geojson-polygon-self-intersections';
import isEmpty from 'lodash.isempty';
import ol from 'openlayers';
import PropTypes from 'prop-types';
import {createSelector} from 'reselect';
Expand Down Expand Up @@ -541,7 +539,7 @@ class RedliningSupport extends React.Component {
if (
(feature.shape === "Text" && !feature.properties.label) ||
(feature.shape === "Circle" && feature.circleParams.radius === 0) ||
(feature.geometry?.type === "Polygon" && (!isEmpty(polySelfIntersections(feature).geometry.coordinates) || this.currentFeature.getGeometry().getArea() === 0))
(feature.geometry?.type === "Polygon" && this.currentFeature.getGeometry().getArea() === 0)
) {
if (!newFeature) {
this.props.removeLayerFeatures(this.props.redlining.layer, [feature.id]);
Expand Down
6 changes: 5 additions & 1 deletion utils/VectorLayerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import geojsonBbox from 'geojson-bounding-box';
import isEmpty from 'lodash.isempty';
import {getDefaultImageStyle} from 'ol/format/KML';
import ol from 'openlayers';
import simplepolygon from 'simplepolygon';
import svgpath from 'svgpath';
import {v1 as uuidv1} from 'uuid';

Expand Down Expand Up @@ -42,7 +43,10 @@ const VectorLayerUtils = {
if (layer.type !== 'vector' || (layer.features || []).length === 0 || layer.visibility === false || layer.skipPrint === true) {
continue;
}
for (const feature of layer.features) {
const features = layer.features.map(feature =>
feature.geometry.type === "Polygon" ? simplepolygon(feature).features.map(f => ({...feature, geometry: f.geometry})) : feature
).flat();
for (const feature of features) {
if (!VectorLayerUtils.validateGeometry(feature.geometry)) {
continue;
}
Expand Down

0 comments on commit 37c45e7

Please sign in to comment.