Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return result;
}
const modeConfig = this.getModeConfig() || {};
// Default turf value for circle is 64
const { steps = 64 } = modeConfig;
const options = { steps };
if (steps < 4) {
console.warn(`Minimum steps to draw a circle is 4 `); // eslint-disable-line no-console,no-undef
options.steps = 4;
}
const centerCoordinates = clickSequence[0];
const radius = Math.max(distance(centerCoordinates, event.groundCoords), 0.001);
this._setTentativeFeature(circle(centerCoordinates, radius, options));
return result;
}
}
_handlePointerMoveForDrawCircleByBoundingBox(groundCoords: Position) {
if (this._clickSequence.length === 0) {
// nothing to do yet
return;
}
const firstClickedPoint = this._clickSequence[0];
const centerCoordinates = getIntermediatePosition(firstClickedPoint, groundCoords);
const radius = Math.max(distance(firstClickedPoint, centerCoordinates), 0.001);
this._setTentativeFeature(circle(centerCoordinates, radius));
}
_handlePointerMoveForDrawCircleFromCenter(groundCoords: Position) {
if (this._clickSequence.length === 0) {
// nothing to do yet
return;
}
const centerCoordinates = this._clickSequence[0];
const radius = Math.max(distance(centerCoordinates, groundCoords), 0.001);
this._setTentativeFeature(circle(centerCoordinates, radius));
}
export function geoDistance(node: GeoDistance) {
const {
distance, unit, lat, lon
} = node;
const geoPoint = [lon, lat];
const config = { units: unit };
let polygon: createCircle;
if (lat != null && lon != null) {
polygon = createCircle(
geoPoint,
distance,
config
);
}
// Nothing matches so return false
if (polygon == null) return () => false;
return testGeoPolygon(polygon);
}
function sector(center, radius, bearing1, bearing2, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
// validation
if (!center) throw new Error('center is required');
if (bearing1 === undefined || bearing1 === null) throw new Error('bearing1 is required');
if (bearing2 === undefined || bearing2 === null) throw new Error('bearing2 is required');
if (!radius) throw new Error('radius is required');
if (typeof options !== 'object') throw new Error('options must be an object');
if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
return circle(center, radius, options);
}
var coords = getCoords(center);
var arc = lineArc(center, radius, bearing1, bearing2, options);
var sliceCoords = [[coords]];
coordEach(arc, function (currentCoords) {
sliceCoords[0].push(currentCoords);
});
sliceCoords[0].push(coords);
return polygon(sliceCoords);
}
pointTopLeft,
pointBottomRight,
]);
const box = bbox(line);
polygon = bboxPolygon(box);
}
}
if (geoPoint && geoDistance) {
const { distance, unit } = parseGeoDistance(geoDistance);
const config = { units: unit };
const parsedGeoPoint = parseGeoPoint(geoPoint);
if (parsedGeoPoint != null) {
polygon = createCircle(
parsedGeoPoint,
distance,
config
);
}
}
// Nothing matches so return false
if (polygon == null) return () => false;
return (fieldData: string): boolean => {
const point = parseGeoPoint(fieldData, false);
if (!point) return false;
return pointInPolygon(point, polygon);
};
}
_loadSample = (type: string) => {
if (type === 'mixed') {
this.setState({
testFeatures: sampleGeoJson,
selectedFeatureIndexes: []
});
} else if (type === 'complex') {
this.setState({
testFeatures: {
type: 'FeatureCollection',
features: [
circle([-122.45, 37.81], 4, { steps: 5000 }),
circle([-122.33, 37.81], 4, { steps: 5000 }),
circle([-122.45, 37.73], 4, { steps: 5000 }),
circle([-122.33, 37.73], 4, { steps: 5000 })
]
},
selectedFeatureIndexes: []
});
} else if (type === 'blank') {
this.setState({
testFeatures: EMPTY_FEATURE_COLLECTION,
selectedFeatureIndexes: []
});
} else if (type === 'file') {
const el = document.createElement('input');
el.type = 'file';
el.onchange = e => {
if (e.target.files && e.target.files[0]) {
const reader = new FileReader();
reader.onload = ({ target }) => {
export function makeCircle(point: GeoPoint, distance: number, config: any) {
return createCircle(makeCoordinatesFromGeoPoint(point), distance, config);
}
export function generateCircleFromFeet([point, radius]) {
return circle(point, toMiles([radius]), { units: 'miles' });
}