You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+39-25Lines changed: 39 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -81,41 +81,47 @@ Below is a list of triggers that exist within `dropchop` that can be picked up a
81
81
82
82
### Adding a Turf function
83
83
84
-
**These instructions assume you are adding a Turf operation that returns NEW GEOMETRY** If you plan to add a Turf operation that returns something other than geometry, such as [`count`](http://turfjs.org/static/docs/module-turf_count.html), please look at [this issue thread](https://github.com/cugos/drop-n-chop/issues/80) first.
84
+
**These instructions assume you are adding a Turf operation that returns NEW GEOMETRY** If you plan to add a Turf operation that returns something other than geometry, such as [`distance`](http://turfjs.org/docs/#distance), please look at [this issue thread](https://github.com/cugos/dropchop/issues/80) first.
85
85
86
86
Turf functions are their own geoprocesses within this application. Since each spatial operation requires different data types, parameters, and options, each Turf option must be specified individually.
87
87
88
88
#### 1. Find the operation in Turf docs
89
-
Too add a new operation, find its relevant page in the Turf documentation. Here is [`buffer`](http://turfjs.org/static/docs/module-turf_buffer.html) for example.
89
+
To add a new operation, find its relevant page in the Turf documentation. Here is [`buffer`](http://turfjs.org/docs/#buffer), for example.
90
90
91
91
#### 2. Add operation info and parameters
92
-
We need to open [`/src/js/operations/Geo.js`](https://github.com/cugos/drop-n-chop/blob/master/src/js/ops.geo.dropchop.js) and add a new object that describes the particular operation you want. Below is an example of `buffer`:
92
+
Open [`src/js/ops.geo.dropchop.js`](src/js/ops.geo.dropchop.js) and add a new configuration object that describes the particular operation you want. Below is an example of such an object for`buffer`:
93
93
94
94
```javascript
95
95
buffer: {
96
96
maxFeatures:1,
97
+
minFeatures:1,
98
+
requirements: {
99
+
generalFeature:true,
100
+
types: ['Feature', 'FeatureCollection']
101
+
},
97
102
description:'Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.',
Notice that there are two parameters, `distance` and `unit`. Each of these is optional according to Turf's documentation. Distance can be any number, but Unit can only be a particular set of options. Make sure if you want the user to only choose certain options to use `type: 'select'` and list your `options` accordingly. `createsLayer` represents whether the operation returns a layer that should be placed on the map.
117
123
118
-
A greater list of possibly operation configurations can be seen below:
124
+
A template list of possible operation configurations can be seen below:
119
125
120
126
```javascript
121
127
operationName: {
@@ -134,13 +140,21 @@ operationName: {
134
140
}
135
141
```
136
142
137
-
#### 3. Add the new operation to appropriate menu
138
-
To add the task to the menu, open [`/src/js/controller/AppController.js`](https://github.com/cugos/drop-n-chop/blob/master/src/js/controller/AppController.js). On [this line](https://github.com/cugos/drop-n-chop/blob/master/src/js/controller/AppController.js#L24) you will see an array of different items. Add your new item here. **Be sure it is named exactly the same as the turf operation!**
143
+
#### 3. Add the module to the build process.
144
+
Insert the new function into [`package.json`](package.json#L33) and [`lib/turf_setup.js`](lib/turf_setup.js#L4).
145
+
146
+
#### 4. Save & build
147
+
You should now be able to rebuild the application and test out your new operation. Per [the installation process](INSTALLATION.md), build the app packages:
148
+
149
+
```
150
+
npm install
151
+
gulp build:prod
152
+
gulp
153
+
```
139
154
140
-
#### 4. Save & run `grunt`
141
-
You should now be able to rebuild the application and test out your new operation. Make sure you have some test data to work with. You can find some in the [`test` folder](https://github.com/cugos/drop-n-chop/tree/master/test). If these files aren't working, making quick features at [geojson.io](http://geojson.io/) typically works well.
155
+
Then try it out by visiting [http://localhost:8888/?gist=b1467dd8c405f6ef38e0857555670e00](http://localhost:8888/?gist=b1467dd8c405f6ef38e0857555670e00) in your browser. This automatically loads Libya's boundary polygon to test the new function; use [geojson.io](http://geojson.io) to create other test data as needed.
142
156
143
-
If things aren't working, make sure to check out your console for javascript errors. If you are unable to solve the issue feel free to [submit a ticket](https://github.com/cugos/drop-n-chop/issues) on the repository issues! Please include the error that you are receiving, the operation you are trying to add, and the data that you were testing with.
157
+
If things aren't working, make sure to check out your console for javascript errors. If you are unable to solve the issue feel free to [submit a ticket](https://github.com/cugos/dropchop/issues) on the repository issues! Please include the error that you are receiving, the operation you are trying to add, and the data that you were testing with.
144
158
145
159
#### 5. Test!
146
160
In order to make sure our operations are running as expected you should write some tests. MORE TO COME HERE!
0 commit comments