Skip to content

Commit

Permalink
Merge 922c2b7 into dacab6f
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlkoch committed Aug 14, 2018
2 parents dacab6f + 922c2b7 commit 7ec976b
Show file tree
Hide file tree
Showing 22 changed files with 173 additions and 326 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"extends": [
"eslint:recommended"
],
"plugins": [],
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"globals": {
"Promise": false
},
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"semi": ["error", "always"],
"one-var": ["error", "never"],
"no-confusing-arrow": "error",
"no-unused-vars": ["error", {
"ignoreRestSiblings": true
}],
"key-spacing": ["error", {
"beforeColon": false,
"afterColon": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true
}
}],
"space-infix-ops": ["error", {"int32Hint": false}]
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "A set of helper classes for working with openLayers",
"main": "src/index.js",
"scripts": {
"lint": "eslint --ext js src/",
"pretest": "npm run lint",
"test": "jest --maxWorkers=4",
"test:watch": "jest --watchAll",
"coveralls": "cat coverage/lcov.info | coveralls",
Expand Down Expand Up @@ -48,10 +50,11 @@
"babel-preset-stage-0": "6.24.1",
"canvas-prebuilt": "1.6.5-prerelease.1",
"coveralls": "3.0.2",
"eslint": "5.0.1",
"jest": "23.5.0",
"node-pre-gyp": "0.11.0",
"np": "3.0.4",
"ol": "4.6.5",
"ol": "5.1.3",
"whatwg-fetch": "2.0.4"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/AnimateUtil/AnimateUtil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OlObservable from 'ol/observable';
import OlGeomPoint from 'ol/geom/point';
import OlGeomLineString from 'ol/geom/linestring';
import OlObservable from 'ol/Observable';
import OlGeomPoint from 'ol/geom/Point';
import OlGeomLineString from 'ol/geom/LineString';

/**
* This class provides some static methods which might be helpful when working
Expand Down
6 changes: 3 additions & 3 deletions src/AnimateUtil/AnimateUtil.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*eslint-env jest*/
import OlGeomPoint from 'ol/geom/point';
import OlFeature from 'ol/feature';
import OlStyleStyle from 'ol/style/style';
import OlGeomPoint from 'ol/geom/Point';
import OlFeature from 'ol/Feature';
import OlStyleStyle from 'ol/style/Style';

import AnimateUtil from '../AnimateUtil/AnimateUtil';
import TestUtil from '../TestUtil';
Expand Down
6 changes: 3 additions & 3 deletions src/CapabilitiesUtil/CapabilitiesUtil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OlWMSCapabilities from 'ol/format/wmscapabilities';
import OlSourceImageWMS from 'ol/source/imagewms';
import OlLayerImage from 'ol/layer/image';
import OlWMSCapabilities from 'ol/format/WMSCapabilities';
import OlSourceImageWMS from 'ol/source/ImageWMS';
import OlLayerImage from 'ol/layer/Image';

import get from 'lodash/get.js';

Expand Down
2 changes: 1 addition & 1 deletion src/CapabilitiesUtil/CapabilitiesUtil.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*eslint-env jest*/
import OlLayerImage from 'ol/layer/image';
import OlLayerImage from 'ol/layer/Image';
import { CapabilitiesUtil } from '../index';

const layerTitle = 'OpenStreetMap WMS - by terrestris';
Expand Down
4 changes: 2 additions & 2 deletions src/FeatureUtil/FeatureUtil.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*eslint-env jest*/

import OlFeature from 'ol/feature';
import OlGeomPoint from 'ol/geom/point';
import OlFeature from 'ol/Feature';
import OlGeomPoint from 'ol/geom/Point';

import {
FeatureUtil,
Expand Down
6 changes: 3 additions & 3 deletions src/FileUtil/FileUtil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OlFormatGeoJSON from 'ol/format/geojson';
import OlLayerVector from 'ol/layer/vector';
import OlSourceVector from 'ol/source/vector';
import OlFormatGeoJSON from 'ol/format/GeoJSON';
import OlLayerVector from 'ol/layer/Vector';
import OlSourceVector from 'ol/source/Vector';
import shp from 'shpjs';

/**
Expand Down
190 changes: 0 additions & 190 deletions src/GeometryUtil/GeometryUtil.example.jsx

This file was deleted.

8 changes: 0 additions & 8 deletions src/GeometryUtil/GeometryUtil.example.md

This file was deleted.

24 changes: 12 additions & 12 deletions src/GeometryUtil/GeometryUtil.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import OlFeature from 'ol/feature';
import OlGeomMultiPolygon from 'ol/geom/multipolygon';
import OlGeomMultiPoint from 'ol/geom/multipoint';
import OlGeomMultiLineString from 'ol/geom/multilinestring';
import OlFormatGeoJSON from 'ol/format/geojson';
import OlFeature from 'ol/Feature';
import OlGeomMultiPolygon from 'ol/geom/MultiPolygon';
import OlGeomMultiPoint from 'ol/geom/MultiPoint';
import OlGeomMultiLineString from 'ol/geom/MultiLineString';
import OlFormatGeoJSON from 'ol/format/GeoJSON';

import buffer from '@turf/buffer';
import difference from '@turf/difference';
Expand Down Expand Up @@ -61,7 +61,7 @@ class GeometryUtil {
const turfLine = geoJsonFormat.writeFeatureObject(lineFeat);
// This lists all the polygons in the feature and splits the Multi polygons into an array of polygons.
const geometries = GeometryUtil.separateGeometries(polygonFeat.getGeometry());
// the array containing all the split features
// the array containing all the split features
let allSplitedPolygons = [];
// iterates over each polygon and splits it
geometries.forEach(geometry => {
Expand All @@ -78,18 +78,18 @@ class GeometryUtil {
turfPolygonCoordinates.slice(1, turfPolygonCoordinates.length).forEach(function (coord) {
inners.push(lineString(coord));
});
// Polygonize the holes in the polygon
// Polygonize the holes in the polygon
const innerPolygon = polygonize(featureCollection(inners));
// make a lineString from the spliting line and the outer of the polygon
let unionGeom = union(outer, turfLine);
// Polygonize the combined lines.
const polygonizedUnionGeom = polygonize(unionGeom);
// Array of the split polygons within the geometry
const splitedPolygons = [];
// Iterate over each feature in the combined feature and remove sections that are outside the initial polygon and
// Iterate over each feature in the combined feature and remove sections that are outside the initial polygon and
// remove the parts from the cutted polygons that are in polygon holes.
featureEach(polygonizedUnionGeom, cuttedSection => {
// checks to see if segment is in polygon
// checks to see if segment is in polygon
const segmentInPolygon = intersect(cuttedSection, outerPolygon);
if (segmentInPolygon && segmentInPolygon.geometry.type === 'Polygon') {
let polygonWithoutHoles = [];
Expand Down Expand Up @@ -194,15 +194,15 @@ class GeometryUtil {
let append;
switch (geomType) {
case 'Polygon':
multiGeom = new OlGeomMultiPolygon();
multiGeom = new OlGeomMultiPolygon([]);
append = multiGeom.appendPolygon.bind(multiGeom);
break;
case 'Point':
multiGeom = new OlGeomMultiPoint();
multiGeom = new OlGeomMultiPoint([]);
append = multiGeom.appendPoint.bind(multiGeom);
break;
case 'LineString':
multiGeom = new OlGeomMultiLineString();
multiGeom = new OlGeomMultiLineString([]);
append = multiGeom.appendLineString.bind(multiGeom);
break;
default:
Expand Down
Loading

0 comments on commit 7ec976b

Please sign in to comment.