source: tmcsimulator/trunk/webapps/GTEC/data_layers/vds_intersect.py @ 556

Revision 556, 832 bytes checked in by jdalbey, 6 years ago (diff)

Ver 0.1 of Graphic Traffic Events Creator.

Line 
1import json, sys
2# Read 2 filenames from command line
3# Output to stdout features in file2 not in file1
4
5if len(sys.argv) == 1:
6    print "Must provide 2 command line arguments"
7    print 'Number of arguments:', len(sys.argv)-1
8    exit
9   
10with open(sys.argv[1], "r") as read_file:
11    j = json.load(read_file)
12
13features1 = j["features"]
14
15# Create a set of ID's from first file of features
16alpha = set()
17for f in features1:
18    alpha.add(f["id"]);
19
20with open(sys.argv[2], "r") as read_file:
21    j = json.load(read_file)
22
23features2 = j["features"]
24
25# Lookup each feature ID from file2 in set     
26bravo = []
27for f in features2:
28    target = f["id"]
29    if target not in alpha:
30        bravo.append(target);
31
32# bravo contains items in dat2 not in dat1
33for b in bravo:
34    print b
35   
36# Note features dicts are saved for future use
Note: See TracBrowser for help on using the repository browser.