@turf/boolean-contains
Advanced tools
Comparing version 4.7.3 to 5.0.4
@@ -1,10 +0,9 @@ | ||
/// <reference types="geojson" /> | ||
import { Feature, GeometryObject } from '@turf/helpers' | ||
type Feature = GeoJSON.Feature<any> | GeoJSON.GeometryObject; | ||
/** | ||
* http://turfjs.org/docs/#boolean-contains | ||
*/ | ||
declare function booleanContains(feature1: Feature, feature2: Feature): boolean; | ||
declare namespace booleanContains { } | ||
export = booleanContains; | ||
export default function ( | ||
feature1: Feature<any> | GeometryObject, | ||
feature2: Feature<any> | GeometryObject | ||
): boolean; |
45
index.js
@@ -1,8 +0,5 @@ | ||
var inside = require('@turf/inside'); | ||
var calcBbox = require('@turf/bbox'); | ||
var isPointOnLine = require('@turf/boolean-point-on-line'); | ||
var invariant = require('@turf/invariant'); | ||
var getGeom = invariant.getGeom; | ||
var getCoords = invariant.getCoords; | ||
var getGeomType = invariant.getGeomType; | ||
import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; | ||
import calcBbox from '@turf/bbox'; | ||
import isPointOnLine from '@turf/boolean-point-on-line'; | ||
import { getGeom, getCoords, getType } from '@turf/invariant'; | ||
@@ -20,4 +17,4 @@ /** | ||
* @example | ||
* const line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
* const point = turf.point([1, 2]); | ||
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
* var point = turf.point([1, 2]); | ||
* | ||
@@ -27,5 +24,5 @@ * turf.booleanContains(line, point); | ||
*/ | ||
module.exports = function (feature1, feature2) { | ||
var type1 = getGeomType(feature1); | ||
var type2 = getGeomType(feature2); | ||
function booleanContains(feature1, feature2) { | ||
var type1 = getType(feature1); | ||
var type2 = getType(feature2); | ||
var geom1 = getGeom(feature1); | ||
@@ -56,3 +53,3 @@ var geom2 = getGeom(feature2); | ||
case 'Point': | ||
return isPointOnLine(geom2, geom1, true); | ||
return isPointOnLine(geom2, geom1, {ignoreEndVertices: true}); | ||
case 'LineString': | ||
@@ -68,3 +65,3 @@ return isLineOnLine(geom1, geom2); | ||
case 'Point': | ||
return inside(geom2, geom1, true); | ||
return booleanPointInPolygon(geom2, geom1, {ignoreBoundary: true}); | ||
case 'LineString': | ||
@@ -82,3 +79,3 @@ return isLineInPoly(geom1, geom2); | ||
} | ||
}; | ||
} | ||
@@ -117,3 +114,3 @@ function isPointInMultiPoint(multiPoint, point) { | ||
for (var i = 0; i < multiPoint.coordinates.length; i++) { | ||
if (isPointOnLine(multiPoint.coordinates[i], lineString, true)) { | ||
if (isPointOnLine(multiPoint.coordinates[i], lineString, {ignoreEndVertices: true})) { | ||
haveFoundInteriorPoint = true; | ||
@@ -133,3 +130,3 @@ } | ||
for (var i = 0; i < multiPoint.coordinates.length; i++) { | ||
if (!inside(multiPoint.coordinates[i], polygon, true)) { | ||
if (!booleanPointInPolygon(multiPoint.coordinates[i], polygon, {ignoreBoundary: true})) { | ||
return false; | ||
@@ -144,6 +141,6 @@ } | ||
for (var i = 0; i < lineString2.coordinates.length; i++) { | ||
if (isPointOnLine({type: 'Point', coordinates: lineString2.coordinates[i]}, lineString1, true)) { | ||
if (isPointOnLine({type: 'Point', coordinates: lineString2.coordinates[i]}, lineString1, { ignoreEndVertices: true })) { | ||
haveFoundInteriorPoint = true; | ||
} | ||
if (!isPointOnLine({type: 'Point', coordinates: lineString2.coordinates[i]}, lineString1, false)) { | ||
if (!isPointOnLine({type: 'Point', coordinates: lineString2.coordinates[i]}, lineString1, {ignoreEndVertices: false })) { | ||
return false; | ||
@@ -166,3 +163,3 @@ } | ||
var midPoint = getMidpoint(linestring.coordinates[i], linestring.coordinates[i + 1]); | ||
if (inside({type: 'Point', coordinates: midPoint}, polygon, true)) { | ||
if (booleanPointInPolygon({type: 'Point', coordinates: midPoint}, polygon, { ignoreBoundary: true })) { | ||
output = true; | ||
@@ -191,3 +188,3 @@ break; | ||
for (var i = 0; i < feature2.coordinates[0].length; i++) { | ||
if (!inside(feature2.coordinates[0][i], feature1)) { | ||
if (!booleanPointInPolygon(feature2.coordinates[0][i], feature1)) { | ||
return false; | ||
@@ -211,4 +208,4 @@ } | ||
* @private | ||
* @param {[number, number]} pair1 point [x,y] | ||
* @param {[number, number]} pair2 point [x,y] | ||
* @param {Array<number>} pair1 point [x,y] | ||
* @param {Array<number>} pair2 point [x,y] | ||
* @returns {boolean} true/false if coord pairs match | ||
@@ -223,1 +220,3 @@ */ | ||
} | ||
export default booleanContains; |
{ | ||
"name": "@turf/boolean-contains", | ||
"version": "4.7.3", | ||
"version": "5.0.4", | ||
"description": "turf boolean-contains module", | ||
"main": "index.js", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"main.js" | ||
], | ||
"scripts": { | ||
"test": "node test.js", | ||
"bench": "node bench.js" | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"bench": "node -r @std/esm bench.js" | ||
}, | ||
@@ -36,16 +40,22 @@ "repository": { | ||
"devDependencies": { | ||
"@turf/helpers": "^4.7.3", | ||
"benchmark": "2.1.4", | ||
"boolean-jsts": "0.0.1", | ||
"boolean-shapely": "0.1.2", | ||
"glob": "7.1.2", | ||
"load-json-file": "2.0.0", | ||
"tape": "4.7.0" | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"boolean-jsts": "*", | ||
"boolean-shapely": "*", | ||
"glob": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"tape": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/bbox": "^4.7.3", | ||
"@turf/boolean-point-on-line": "^4.7.3", | ||
"@turf/inside": "^4.7.3", | ||
"@turf/invariant": "^4.7.3" | ||
"@turf/bbox": "^5.0.4", | ||
"@turf/boolean-point-in-polygon": "^5.0.4", | ||
"@turf/boolean-point-on-line": "^5.0.4", | ||
"@turf/helpers": "^5.0.4", | ||
"@turf/invariant": "^5.0.4" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
# @turf/boolean-contains | ||
# booleanContains | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
## booleanContains | ||
Boolean-contains returns True if the second geometry is completely contained by the first geometry. | ||
@@ -18,4 +20,4 @@ The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) | ||
```javascript | ||
const line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
const point = turf.point([1, 2]); | ||
var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
var point = turf.point([1, 2]); | ||
@@ -22,0 +24,0 @@ turf.booleanContains(line, point); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18211
6
401
53
5
8
+ Added@turf/helpers@^5.0.4
+ Added@turf/bbox@5.1.5(transitive)
+ Added@turf/boolean-point-in-polygon@5.1.5(transitive)
+ Added@turf/boolean-point-on-line@5.1.5(transitive)
+ Added@turf/helpers@5.1.5(transitive)
+ Added@turf/invariant@5.2.0(transitive)
+ Added@turf/meta@5.2.0(transitive)
- Removed@turf/inside@^4.7.3
- Removed@turf/bbox@4.7.3(transitive)
- Removed@turf/boolean-point-on-line@4.7.3(transitive)
- Removed@turf/inside@4.7.3(transitive)
- Removed@turf/invariant@4.7.3(transitive)
- Removed@turf/meta@4.7.4(transitive)
Updated@turf/bbox@^5.0.4
Updated@turf/invariant@^5.0.4