-
Notifications
You must be signed in to change notification settings - Fork 4
/
tgj3.m
69 lines (44 loc) · 1.6 KB
/
tgj3.m
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
50
51
52
53
54
55
56
57
58
tgj3 ; Fix up references to non-existant nodes from ways
;
; Iterate through all ways
; Check each node
s count=0
s w=^tgjCheckpoint
f d i w="" q
. s w=$o(^way(w)) i w="" q
. s s=""
. f d i s="" q
. . s s=$o(^way(w,s)) i s="" q
. . s count=count+1
. . i count#10000=0 w "." s ^tgjCheckpoint=w
. . s n=^way(w,s)
. . s version=$o(^nodeVersion(n,"v",""),-1)
. . i version="" s ^tgjBad(w,s)="No versions of node exist" q
. . s changeset=^nodeVersion(n,"v",version)
. . s visible=$p(^c(changeset,"n",n,"v",version,"a"),$c(1),5)
. . i visible="false" s ^tgjBad(w,s)="Node exists but has been deleted" q
. . i '$d(^wayByNode(n,w)) s ^tgjBadx(w,s)="No entry for node in ^wayByNode"
q
fix ; Find all the nodes
; If the node has been deleted (latest version has visible=false) then reinstate it
; If the node does not exist at all then report No Versions
s count=0
s w=""
f d i w="" q
. s w=$o(^tgjBad(w)) i w="" q
. s seq=""
. f d i seq="" q
. . s seq=$o(^tgjBad(w,seq)) i seq="" q
. . ;i $e(^tgjBad(w,seq),1,7)="Deleted" q
. . ;i $e(^tgjBad(w,seq),1,11)="no versions" q
. . i $g(^way(w,seq))'=^tgjBad(w,seq) s ^tgjCheck(w,seq)=1 q
. . s n=^way(w,seq)
. . s version=$o(^nodeVersion(n,"v",""),-1) i version="" w !,w," ",seq,"=",n," no versions" q
. . s changeset=^nodeVersion(n,"v",version)
. . s visible=$p(^c(changeset,"n",n,"v",version,"a"),$c(1),5)
. . i visible="" w !,w," ",seq,"=",n," not deleted" q ; Node not deleted
. . w !,w," ",seq,"=",n," deleted, needs to be undeleted"
. . s $p(^c(changeset,"n",n,"v",version,"a"),$c(1),5)=""
. . s count=count+1
w !,count
q