-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.js
49 lines (45 loc) · 1.12 KB
/
grid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var clone = require('clone');
var jsonfile = require('jsonfile');
var path = require('path');
jsonfile.spaces = 4 //format json output
//Generate grid for schematic
grid = {
"type": "FeatureCollection",
"features": []
}
feature = {
"type": "Feature",
"properties": {
"fil": 0,
"col": 0
},
"geometry": {
"type": "LineString",
"coordinates": [
[ 0, 0 ],
[ 0, 0 ]
]
}
};
grid_size = 1200;
for (i = -grid_size; i<=grid_size; i++) {
//cols
f = clone(feature);
f.properties.col = i;
f.geometry.coordinates[0][1] = -grid_size;
f.geometry.coordinates[1][1] = grid_size;
f.geometry.coordinates[0][0] = i;
f.geometry.coordinates[1][0] = i;
grid.features.push(f);
//fils
f = clone(feature);
f.properties.fil = i;
f.geometry.coordinates[0][0] = -grid_size;
f.geometry.coordinates[1][0] = grid_size;
f.geometry.coordinates[0][1] = i;
f.geometry.coordinates[1][1] = i;
grid.features.push(f);
}
jsonfile.writeFile(path.join(process.cwd(),'data', 'grid.geojson'), grid, function (err) {
if (err) console.error(err);
});