The challenge is to create an app that can be deployed on the Drone Deploy App Market that allows a user to submit a .shp, .kml, or .zip file of an area of interest and generate a drone flight plan for that area.
Creating the app required taking the following steps:
- Finding external libraries that would successfully convert the different file formats into usable geoJSON
- Converting the files and verifying the geoJSON data within them was acceptable and did in fact reflect a geographic feature
- Standardizing the data returned from the different conversion libraries to pass on to the DroneDeploy API
- Calling the DroneDeploy API to create the Flight Plan, pan to the vicinity of the plan, and track success of the app
The following conversion libraries were used:
-
Tom MacWright has produced a library to convert KML files to geoJSON. jQuery's ajax method was used in the case of the KML to geoJSON converter since the the function required an xml object to process to return the geoJSON data.
-
Mike Bostock has produced a library called Shapefile to convert SHP files to geoJSON.
-
Calvin Metcalf has produced a library called shapefile-js to convert ZIP files to geoJSON.
Each library produced geoJSON data in slightly different formats.
For example, in the KML to geoJSON converter, the geojson object looked like this:
{type: "FeatureCollection", features: [ {type:"Feature", geometry: {..}, properties: {..} } ] };
The SHP to geoJSON converter yielded a data object that looked like this:
[{coordinates:[[...]], type: "Polygon"}];
The ZIP to geoJSON converter yielded this data object:
{type:"Feature", features: [ {type:"Feature", geometry: {..}, properties: {..} } ], fileName:"Limits of flight"}
Due to the varying nature of the geoJSON object returned from each file converter, steps were taken to create a standard geoData object that captured relevant data from the GeoJSON object for processing later.
GeoJSON.js was used to convert data retrieved from the GeoJSON objects back into standard geojson formats that could begin to be used by functions regardless of the filetype submitted.
Turf.js was used to process and analyze the geoJSON objects. Methods used from the Turf.js library included turf.centroid, turf.booleanContains, and turf.bbox. In previous iterations of the app, more Turf.js methods were used, but it eventually became evident that they were extraneous.
The DroneDeploy API provides methods to turn a shape geometry into a flight path and to zoom into the flight plan view.
The Flight Plan app can be found here.
User submits a .kml, .shp, or a .zip file of a geographic area of interest:
Once flight plan is created, map view pans to vicinity of plan:
User can click on Flight Plan icon to view detailed drone flight path: