How to use the @turf/destination.default function in @turf/destination

To help you get started, we’ve selected a few @turf/destination examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github noncomputable / AgentMaps / tool / browserlessbuildings.js View on Github external
street_buffer = unit_options.front_buffer / 1000, //Distance between center of street and start of unit.
			house_depth = unit_options.depth / 1000,
			angle = bearing(anchor_a, anchor_b),
			new_angle = angle + i * 90, //Angle of line perpendicular to the anchor segment.
			unit_feature = { 
				type: "Feature",
				properties: {
					street: "none"
				},
				geometry: {
					type: "Polygon",
					coordinates: [[]]
				}
			};
			unit_feature.geometry.coordinates[0][0] = destination(anchor_a, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][1] = destination(anchor_b, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][2] = destination(anchor_b, street_buffer + house_depth, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][3] = destination(anchor_a, street_buffer + house_depth, new_angle).geometry.coordinates;
			unit_feature.geometry.coordinates[0][4] = unit_feature.geometry.coordinates[0][0];

			//Exclude the unit if it overlaps with any of the other proposed units.
			let all_proposed_unit_features = unit_features[0].concat(unit_features[1]).concat(proposed_unit_features);
			if (noOverlaps(unit_feature, all_proposed_unit_features)) { 
				//Recode index so that it's useful here.
				i = i === 1 ? 0 : 1;

				unit_feature.properties.street_id = street_leaflet_id,
				unit_feature.properties.OSM_street_id = street_OSM_id,
				unit_feature.properties.street_anchors = anchor_latLng_pair,	
				unit_feature.properties.neighbors = [null, null, null],
				unit_feature.properties.id = starting_id + increment,
				increment += 1;
github hotosm / MapCampaigner / lambda_functions / process / make_pdf_grid / index.js View on Github external
async function main(event) {
    const response = await getS3File(event.campaign_uuid);
    const f = JSON.parse(response).features
    const options = {units:"meters"}
    const features = []
    for (let i = 0; i < f.length; i++) {
        const box = bbox(f[i]);
        const w = distance([box[0], box[1]],[box[2],box[1]],{units:"meters"})
        const h = distance([box[0], box[1]],[box[0],box[3]],{units:"meters"})
        const wDiff = 1000 - (w % 1000);
        const hDiff = 706 - (h % 706);
        const poly = bboxPolygon(box);
        const c = centerOfMass(poly);
        const maxY = destination(c,(50 + h + hDiff)/2, 0, options).geometry.coordinates[1];
        const minY = destination(c,(50 +h + hDiff)/2, 180,options).geometry.coordinates[1];
        const maxX = destination(c,(50 + w + wDiff)/2, 90,options).geometry.coordinates[0];
        const minX = destination(c,(50 + w + wDiff)/2, -90,options).geometry.coordinates[0];
        const grid = rectangleGrid([minX, minY, maxX, maxY], 1000, 706, {units:"meters"});
        for (let j=0; j
github noncomputable / AgentMaps / src / buildings.js View on Github external
street_buffer = unit_options.front_buffer / 1000, //Distance between center of street and start of unit.
			house_depth = unit_options.depth / 1000,
			angle = bearing(anchor_a, anchor_b),
			new_angle = angle + i * 90, //Angle of line perpendicular to the anchor segment.
			unit_feature = { 
				type: "Feature",
				properties: {
					street: "none"
				},
				geometry: {
					type: "Polygon",
					coordinates: [[]]
				}
			};
			unit_feature.geometry.coordinates[0][0] = destination(anchor_a, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][1] = destination(anchor_b, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][2] = destination(anchor_b, street_buffer + house_depth, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][3] = destination(anchor_a, street_buffer + house_depth, new_angle).geometry.coordinates;
			unit_feature.geometry.coordinates[0][4] = unit_feature.geometry.coordinates[0][0];

			//Exclude the unit if it overlaps with any of the other proposed units.
			let all_proposed_unit_features = unit_features[0].concat(unit_features[1]).concat(proposed_unit_features);
			if (noOverlaps(unit_feature, all_proposed_unit_features)) { 
				//Recode index so that it's useful here.
				i = i === 1 ? 0 : 1;

				unit_feature.properties.street_id = street_leaflet_id,
				unit_feature.properties.OSM_street_id = street_OSM_id,
				unit_feature.properties.street_anchors = anchor_latLng_pair,	
				unit_feature.properties.neighbors = [null, null, null],
				unit_feature.properties.id = starting_id + increment,
				increment += 1;
github hotosm / MapCampaigner / lambda_functions / process / make_pdf_grid / index.js View on Github external
async function main(event) {
    const response = await getS3File(event.campaign_uuid);
    const f = JSON.parse(response).features
    const options = {units:"meters"}
    const features = []
    for (let i = 0; i < f.length; i++) {
        const box = bbox(f[i]);
        const w = distance([box[0], box[1]],[box[2],box[1]],{units:"meters"})
        const h = distance([box[0], box[1]],[box[0],box[3]],{units:"meters"})
        const wDiff = 1000 - (w % 1000);
        const hDiff = 706 - (h % 706);
        const poly = bboxPolygon(box);
        const c = centerOfMass(poly);
        const maxY = destination(c,(50 + h + hDiff)/2, 0, options).geometry.coordinates[1];
        const minY = destination(c,(50 +h + hDiff)/2, 180,options).geometry.coordinates[1];
        const maxX = destination(c,(50 + w + wDiff)/2, 90,options).geometry.coordinates[0];
        const minX = destination(c,(50 + w + wDiff)/2, -90,options).geometry.coordinates[0];
        const grid = rectangleGrid([minX, minY, maxX, maxY], 1000, 706, {units:"meters"});
        for (let j=0; j
github mapstertech / mapbox-gl-draw-rotate-mode / index.js View on Github external
polygon.forEach(function(coords,index) {
                  var distanceFromCenter = distance(state.originalCenter, coords);
                  var bearingFromCenter = bearing(state.originalCenter, coords);
                  var newPoint = destination(state.originalCenter, distanceFromCenter, bearingFromCenter+draggedBearing);
                  polyCoords.push(newPoint.geometry.coordinates);
                })
                multipolys.push(polyCoords);
github hotosm / MapCampaigner / lambda_functions / process / make_pdf_grid / index.js View on Github external
const response = await getS3File(event.campaign_uuid);
    const f = JSON.parse(response).features
    const options = {units:"meters"}
    const features = []
    for (let i = 0; i < f.length; i++) {
        const box = bbox(f[i]);
        const w = distance([box[0], box[1]],[box[2],box[1]],{units:"meters"})
        const h = distance([box[0], box[1]],[box[0],box[3]],{units:"meters"})
        const wDiff = 1000 - (w % 1000);
        const hDiff = 706 - (h % 706);
        const poly = bboxPolygon(box);
        const c = centerOfMass(poly);
        const maxY = destination(c,(50 + h + hDiff)/2, 0, options).geometry.coordinates[1];
        const minY = destination(c,(50 +h + hDiff)/2, 180,options).geometry.coordinates[1];
        const maxX = destination(c,(50 + w + wDiff)/2, 90,options).geometry.coordinates[0];
        const minX = destination(c,(50 + w + wDiff)/2, -90,options).geometry.coordinates[0];
        const grid = rectangleGrid([minX, minY, maxX, maxY], 1000, 706, {units:"meters"});
        for (let j=0; j
github hotosm / MapCampaigner / lambda_functions / process / make_pdf_grid / index.js View on Github external
async function main(event) {
    const response = await getS3File(event.campaign_uuid);
    const f = JSON.parse(response).features
    const options = {units:"meters"}
    const features = []
    for (let i = 0; i < f.length; i++) {
        const box = bbox(f[i]);
        const w = distance([box[0], box[1]],[box[2],box[1]],{units:"meters"})
        const h = distance([box[0], box[1]],[box[0],box[3]],{units:"meters"})
        const wDiff = 1000 - (w % 1000);
        const hDiff = 706 - (h % 706);
        const poly = bboxPolygon(box);
        const c = centerOfMass(poly);
        const maxY = destination(c,(50 + h + hDiff)/2, 0, options).geometry.coordinates[1];
        const minY = destination(c,(50 +h + hDiff)/2, 180,options).geometry.coordinates[1];
        const maxX = destination(c,(50 + w + wDiff)/2, 90,options).geometry.coordinates[0];
        const minX = destination(c,(50 + w + wDiff)/2, -90,options).geometry.coordinates[0];
        const grid = rectangleGrid([minX, minY, maxX, maxY], 1000, 706, {units:"meters"});
        for (let j=0; j
github noncomputable / AgentMaps / tool / browserlessbuildings.js View on Github external
house_depth = unit_options.depth / 1000,
			angle = bearing(anchor_a, anchor_b),
			new_angle = angle + i * 90, //Angle of line perpendicular to the anchor segment.
			unit_feature = { 
				type: "Feature",
				properties: {
					street: "none"
				},
				geometry: {
					type: "Polygon",
					coordinates: [[]]
				}
			};
			unit_feature.geometry.coordinates[0][0] = destination(anchor_a, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][1] = destination(anchor_b, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][2] = destination(anchor_b, street_buffer + house_depth, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][3] = destination(anchor_a, street_buffer + house_depth, new_angle).geometry.coordinates;
			unit_feature.geometry.coordinates[0][4] = unit_feature.geometry.coordinates[0][0];

			//Exclude the unit if it overlaps with any of the other proposed units.
			let all_proposed_unit_features = unit_features[0].concat(unit_features[1]).concat(proposed_unit_features);
			if (noOverlaps(unit_feature, all_proposed_unit_features)) { 
				//Recode index so that it's useful here.
				i = i === 1 ? 0 : 1;

				unit_feature.properties.street_id = street_leaflet_id,
				unit_feature.properties.OSM_street_id = street_OSM_id,
				unit_feature.properties.street_anchors = anchor_latLng_pair,	
				unit_feature.properties.neighbors = [null, null, null],
				unit_feature.properties.id = starting_id + increment,
				increment += 1;
github noncomputable / AgentMaps / src / buildings.js View on Github external
anchor_latLng_pair = [anchor_a, anchor_b],
			street_buffer = unit_options.front_buffer / 1000, //Distance between center of street and start of unit.
			house_depth = unit_options.depth / 1000,
			angle = bearing(anchor_a, anchor_b),
			new_angle = angle + i * 90, //Angle of line perpendicular to the anchor segment.
			unit_feature = { 
				type: "Feature",
				properties: {
					street: "none"
				},
				geometry: {
					type: "Polygon",
					coordinates: [[]]
				}
			};
			unit_feature.geometry.coordinates[0][0] = destination(anchor_a, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][1] = destination(anchor_b, street_buffer, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][2] = destination(anchor_b, street_buffer + house_depth, new_angle).geometry.coordinates,
			unit_feature.geometry.coordinates[0][3] = destination(anchor_a, street_buffer + house_depth, new_angle).geometry.coordinates;
			unit_feature.geometry.coordinates[0][4] = unit_feature.geometry.coordinates[0][0];

			//Exclude the unit if it overlaps with any of the other proposed units.
			let all_proposed_unit_features = unit_features[0].concat(unit_features[1]).concat(proposed_unit_features);
			if (noOverlaps(unit_feature, all_proposed_unit_features)) { 
				//Recode index so that it's useful here.
				i = i === 1 ? 0 : 1;

				unit_feature.properties.street_id = street_leaflet_id,
				unit_feature.properties.OSM_street_id = street_OSM_id,
				unit_feature.properties.street_anchors = anchor_latLng_pair,	
				unit_feature.properties.neighbors = [null, null, null],
				unit_feature.properties.id = starting_id + increment,

@turf/destination

turf destination module

MIT
Latest version published 2 months ago

Package Health Score

96 / 100
Full package analysis

Popular @turf/destination functions