Skip to content

Commit

Permalink
Bugfix/127 intersect geometrycollection (#129)
Browse files Browse the repository at this point in the history
* buffer all the things

* buffer all the things

* bump version

* tweak version name
  • Loading branch information
cedrikv authored Jun 9, 2021
1 parent 58c05f4 commit 3095fba
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/commonjs/gis-utils/map-util.d.ts.map

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

8 changes: 5 additions & 3 deletions dist/commonjs/gis-utils/map-util.js

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

2 changes: 1 addition & 1 deletion dist/commonjs/gis-utils/map-util.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/native-modules/gis-utils/map-util.d.ts.map

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

8 changes: 5 additions & 3 deletions dist/native-modules/gis-utils/map-util.js

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

2 changes: 1 addition & 1 deletion dist/native-modules/gis-utils/map-util.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oerelia",
"description": "An Aurelia plugin project.",
"version": "0.9.6",
"version": "0.9.7-alpha.0",
"repository": {
"type": "git",
"url": "https://github.com/OnroerendErfgoed/oerelia.git"
Expand Down
9 changes: 6 additions & 3 deletions src/gis-utils/map-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ export class MapUtil {

public static intersectPolygons(polygon1: ol.Feature, polygon2: ol.Feature): ol.Feature {
const parser = new jsts.io.OL3Parser();
const writer = new jsts.io.GeoJSONWriter();

parser.inject(ol.geom.Point, ol.geom.LineString, ol.geom.LinearRing, ol.geom.Polygon,
ol.geom.MultiPoint, ol.geom.MultiLineString, ol.geom.MultiPolygon);
ol.geom.MultiPoint, ol.geom.MultiLineString, ol.geom.MultiPolygon, ol.geom.GeometryCollection);
const jstsGeom1 = parser.read(polygon1.getGeometry());
const jstsGeom2 = parser.read(polygon2.getGeometry());
const intersects = jstsGeom1.intersects(jstsGeom2);
Expand All @@ -255,8 +257,9 @@ export class MapUtil {
}

const jstsGeom = polygon2 ? jstsGeom1.intersection(jstsGeom2) : jstsGeom1;
const polygon = parser.write(jstsGeom);
const coords = polygon.getType() === 'Polygon' ? [polygon.getCoordinates()] : polygon.getCoordinates();
const buffered = jstsGeom.buffer(0);
const polygon = writer.write(buffered);
const coords = polygon.type === 'Polygon' ? [polygon.coordinates] : polygon.coordinates;
if (coords[0].length > 0) {
return new ol.Feature({
geometry: new ol.geom.MultiPolygon(coords)
Expand Down

0 comments on commit 3095fba

Please sign in to comment.