forked from TBTerra/spawnScan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
30 lines (27 loc) · 1.13 KB
/
Copy pathcheck.py
File metadata and controls
30 lines (27 loc) · 1.13 KB
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
import json
import math
with open('config.json') as file:
config = json.load(file)
def calcwork():
totalwork = 0
area = 0
for rect in config['work']:
distN = math.radians(max(rect[0], rect[2])-min(rect[0], rect[2]))*6371
distE = math.radians(max(rect[3], rect[1])-min(rect[3], rect[1]))*6371*math.cos(math.radians((rect[0]+rect[2])*0.5))
dlat = 0.00089
dlng = dlat / math.cos(math.radians((rect[0]+rect[2])*0.5))
latSteps = int((((max(rect[0], rect[2])-min(rect[0], rect[2])))/dlat)+0.75199999)
if latSteps<1:
latSteps=1
lngSteps = int((((max(rect[1], rect[3])-min(rect[1], rect[3])))/dlng)+0.75199999)
if lngSteps<1:
lngSteps=1
totalwork += latSteps * lngSteps
area += distN * distE
return totalwork, area
tscans,tarea = calcwork()
print 'total of {} steps covering {} km^2'.format(tscans,tarea)
numWorkers = ((tscans-1)//config['stepsPerPassPerWorker'])+1
if numWorkers > len(config['users']):
numWorkers = len(config['users'])
print 'with {} worker(s), doing {} scans each, would take {} hour(s)'.format(numWorkers,config['stepsPerPassPerWorker'],int(math.ceil(float(tscans)/(config['stepsPerPassPerWorker']*numWorkers))))