Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.trip.path.push(goal);
return;
}
let goal_layer = this.agentmap.units.getLayer(goal_place.id) || this.agentmap.streets.getLayer(goal_place.id);
//If the goal isn't unanchored, see if it's a street or a unit and schedule the agent appropriately.
if (goal_layer) {
let goal_coords = L.A.pointToCoordinateArray(goal_lat_lng);
//Buffering so that points on the perimeter, like the door, are captured.
//Also expands street lines into thin polygons (booleanPointInPolygon requires polys).
//Might be more efficient to generate the door so that it's slightly inside the area.
let goal_polygon = buffer(goal_layer.toGeoJSON(), .001);
if (booleanPointInPolygon(goal_coords, goal_polygon)) {
if (start_place.type === "unit" && goal_place.type === "unit" && start_place.id === goal_place.id) {
this.setTravelInUnit(goal_lat_lng, goal_place, speed);
return;
}
//Move to the street if it's starting at a unit and its goal is elsewhere.
else if (start_place.type === "unit") {
let start_unit_door = this.agentmap.getUnitDoor(start_place.id);
start_unit_door.new_place = start_place,
start_unit_door.speed = speed;
this.trip.path.push(start_unit_door);
let start_unit_street_id = this.agentmap.units.getLayer(start_place.id).street_id,
start_unit_street_point = this.agentmap.getStreetNearDoor(start_place.id);
start_unit_street_point.new_place = { type: "street", id: start_unit_street_id },
function turf_buffer(geojson, radius, opts) {
return tb.default(geojson, radius, opts);
}