本文整理匯總了TypeScript中@turf/boolean-point-on-line.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: booleanContains
/**
* Boolean-contains returns True if the second geometry is completely contained by the first geometry.
* The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b)
* must not intersect the exterior of the primary (geometry a).
* Boolean-contains returns the exact opposite result of the `@turf/boolean-within`.
*
* @name booleanContains
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
* @returns {boolean} true/false
* @example
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
* var point = turf.point([1, 2]);
*
* turf.booleanContains(line, point);
* //=true
*/
export default function booleanContains(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry) {
const geom1 = getGeom(feature1);
const geom2 = getGeom(feature2);
const type1 = getType(feature1);
const type2 = getType(feature2);
const coords1 = getCoords(feature1);
const coords2 = getCoords(feature2);
switch (type1) {
case 'Point':
switch (type2) {
case 'Point':
return compareCoords(coords1, coords2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'MultiPoint':
switch (type2) {
case 'Point':
return isPointInMultiPoint(geom1, geom2);
case 'MultiPoint':
return isMultiPointInMultiPoint(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'LineString':
switch (type2) {
case 'Point':
return isPointOnLine(geom2, geom1, {ignoreEndVertices: true});
case 'LineString':
return isLineOnLine(geom1, geom2);
case 'MultiPoint':
return isMultiPointOnLine(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'Polygon':
switch (type2) {
case 'Point':
return booleanPointInPolygon(geom2, geom1, {ignoreBoundary: true});
case 'LineString':
return isLineInPoly(geom1, geom2);
case 'Polygon':
return isPolyInPoly(geom1, geom2);
case 'MultiPoint':
return isMultiPointInPoly(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
default:
throw new Error('feature1 ' + type1 + ' geometry not supported');
}
}
示例2: booleanWithin
/**
* Boolean-within returns true if the first geometry is completely within the second geometry.
* The interiors of both geometries must intersect and, the interior and boundary of the primary (geometry a)
* must not intersect the exterior of the secondary (geometry b).
* Boolean-within returns the exact opposite result of the `@turf/boolean-contains`.
*
* @name booleanWithin
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
* @returns {boolean} true/false
* @example
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
* var point = turf.point([1, 2]);
*
* turf.booleanWithin(point, line);
* //=true
*/
function booleanWithin(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry): boolean {
var type1 = getType(feature1);
var type2 = getType(feature2);
var geom1 = getGeom(feature1);
var geom2 = getGeom(feature2);
switch (type1) {
case 'Point':
switch (type2) {
case 'MultiPoint':
return isPointInMultiPoint(geom1, geom2);
case 'LineString':
return booleanPointOnLine(geom1, geom2, {ignoreEndVertices: true});
case 'Polygon':
case 'MultiPolygon':
return booleanPointInPolygon(geom1, geom2, {ignoreBoundary: true});
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'MultiPoint':
switch (type2) {
case 'MultiPoint':
return isMultiPointInMultiPoint(geom1, geom2);
case 'LineString':
return isMultiPointOnLine(geom1, geom2);
case 'Polygon':
case 'MultiPolygon':
return isMultiPointInPoly(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'LineString':
switch (type2) {
case 'LineString':
return isLineOnLine(geom1, geom2);
case 'Polygon':
case 'MultiPolygon':
return isLineInPoly(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'Polygon':
switch (type2) {
case 'Polygon':
case 'MultiPolygon':
return isPolyInPoly(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
default:
throw new Error('feature1 ' + type1 + ' geometry not supported');
}
}
示例3: featureEach
featureEach(tree.search(segment), function (match) {
if (doesOverlaps === false) {
var coordsSegment = getCoords(segment).sort();
var coordsMatch: any = getCoords(match).sort();
// Segment overlaps feature
if (equal(coordsSegment, coordsMatch)) {
doesOverlaps = true;
// Overlaps already exists - only append last coordinate of segment
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
// Match segments which don't share nodes (Issue #901)
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
nearestPointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
nearestPointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
nearestPointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
nearestPointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
// Do not define (doesOverlap = true) since more matches can occur within the same segment
// doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
else overlapSegment = match;
}
}
});
示例4: isLineOnLine
function isLineOnLine(lineString1, lineString2) {
var haveFoundInteriorPoint = false;
for (var i = 0; i < lineString2.coordinates.length; i++) {
if (isPointOnLine({type: 'Point', coordinates: lineString2.coordinates[i]}, lineString1, { ignoreEndVertices: true })) {
haveFoundInteriorPoint = true;
}
if (!isPointOnLine({type: 'Point', coordinates: lineString2.coordinates[i]}, lineString1, {ignoreEndVertices: false })) {
return false;
}
}
return haveFoundInteriorPoint;
}
示例5: isLineOnLine
export function isLineOnLine(lineString1: LineString, lineString2: LineString) {
let haveFoundInteriorPoint = false;
for (const coords of lineString2.coordinates) {
if (isPointOnLine({type: "Point", coordinates: coords}, lineString1, { ignoreEndVertices: true })) {
haveFoundInteriorPoint = true;
}
if (!isPointOnLine({type: "Point", coordinates: coords}, lineString1, {ignoreEndVertices: false })) {
return false;
}
}
return haveFoundInteriorPoint;
}
示例6: isMultiPointOnLine
function isMultiPointOnLine(multiPoint, lineString) {
var foundInsidePoint = false;
for (var i = 0; i < multiPoint.coordinates.length; i++) {
if (!booleanPointOnLine(multiPoint.coordinates[i], lineString)) {
return false;
}
if (!foundInsidePoint) {
foundInsidePoint = booleanPointOnLine(multiPoint.coordinates[i], lineString, {ignoreEndVertices: true});
}
}
return foundInsidePoint;
}
示例7: isMultiPointOnLine
export function isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) {
let haveFoundInteriorPoint = false;
for (const coord of multiPoint.coordinates) {
if (isPointOnLine(coord, lineString, {ignoreEndVertices: true})) {
haveFoundInteriorPoint = true;
}
if (!isPointOnLine(coord, lineString)) {
return false;
}
}
if (haveFoundInteriorPoint) {
return true;
}
return false;
}
示例8: checkRingsForSpikesPunctures
function checkRingsForSpikesPunctures(geom) {
for (var i = 0; i < geom.length - 1; i++) {
var point = geom[i]
for (var ii = i + 1; ii < geom.length - 2; ii++) {
var seg = [geom[ii], geom[ii + 1]]
if (isPointOnLine(point, lineString(seg))) return true
}
}
return false
}