Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
path.push(endCoord);
// ---------------------------------------
// astar-andrea ------------------------
// var result = aStar(matrix, [closestToStart.x, closestToStart.y], [closestToEnd.x, closestToEnd.y], 'DiagonalFree');
// var path = [start.geometry.coordinates];
// result.forEach(function (coord) {
// var coords = pointMatrix[coord[1]][coord[0]].split('|');
// path.push([+coords[0], +coords[1]]); // make sure coords are numbers
// });
// path.push(end.geometry.coordinates);
// ---------------------------------------
return cleanCoords(lineString(path));
}
function simplifyGeom(geometry, tolerance, highQuality) {
var type = geometry.type;
// "unsimplyfiable" geometry types
if (type === 'Point' || type === 'MultiPoint') return geometry;
// Remove any extra coordinates
cleanCoords(geometry, true);
var coordinates = geometry.coordinates;
switch (type) {
case 'LineString':
geometry['coordinates'] = simplifyLine(coordinates, tolerance, highQuality);
break;
case 'MultiLineString':
geometry['coordinates'] = coordinates.map(function (lines) {
return simplifyLine(lines, tolerance, highQuality);
});
break;
case 'Polygon':
geometry['coordinates'] = simplifyPolygon(coordinates, tolerance, highQuality);
break;
case 'MultiPolygon':
geometry['coordinates'] = coordinates.map(function (rings) {
function booleanParallel(line1: Feature | LineString, line2: Feature | LineString): boolean {
// validation
if (!line1) throw new Error('line1 is required');
if (!line2) throw new Error('line2 is required');
var type1 = getType(line1, 'line1');
if (type1 !== 'LineString') throw new Error('line1 must be a LineString');
var type2 = getType(line2, 'line2');
if (type2 !== 'LineString') throw new Error('line2 must be a LineString');
var segments1 = lineSegment(cleanCoords(line1)).features;
var segments2 = lineSegment(cleanCoords(line2)).features;
for (var i = 0; i < segments1.length; i++) {
var segment1 = segments1[i].geometry.coordinates;
if (!segments2[i]) break;
var segment2 = segments2[i].geometry.coordinates;
if (!isParallel(segment1, segment2)) return false;
}
return true;
}
function booleanParallel(line1: Feature | LineString, line2: Feature | LineString): boolean {
// validation
if (!line1) throw new Error('line1 is required');
if (!line2) throw new Error('line2 is required');
var type1 = getType(line1, 'line1');
if (type1 !== 'LineString') throw new Error('line1 must be a LineString');
var type2 = getType(line2, 'line2');
if (type2 !== 'LineString') throw new Error('line2 must be a LineString');
var segments1 = lineSegment(cleanCoords(line1)).features;
var segments2 = lineSegment(cleanCoords(line2)).features;
for (var i = 0; i < segments1.length; i++) {
var segment1 = segments1[i].geometry.coordinates;
if (!segments2[i]) break;
var segment2 = segments2[i].geometry.coordinates;
if (!isParallel(segment1, segment2)) return false;
}
return true;
}
function booleanEqual(feature1: Feature | Geometry, feature2: Feature | Geometry): boolean {
const type1 = getGeom(feature1).type;
const type2 = getGeom(feature2).type;
if (type1 !== type2) return false;
const equality = new GeojsonEquality({precision: 6});
return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
}