|
5 | 5 | <TimeCreated>63812,81607.191685</TimeCreated> |
6 | 6 |
|
7 | 7 | <Parameter name="NODESIZE"> |
8 | | -<Default>4</Default> |
| 8 | +<Default>100</Default> |
9 | 9 | </Parameter> |
10 | 10 |
|
11 | 11 | <Parameter name="ROOTNODE"> |
|
51 | 51 | </Method> |
52 | 52 |
|
53 | 53 | <Method name="Insert"> |
54 | | -<FormalSpec>x:%Float,y:%Float,id:%String,data:%String="",block:%String=..#ROOTNODE</FormalSpec> |
| 54 | +<FormalSpec>x:%Float,y:%Float,id:%String,data:%String="",block:%String=..#ROOTNODE,node:IndexNode=""</FormalSpec> |
55 | 55 | <Implementation><![CDATA[ |
56 | | -#dim node As IndexNode |
57 | | -set node = ##class(IndexNode).Get(..indexGlobal, block) |
58 | | -if ('..IsInside(x, y, block)) return |
| 56 | +set:node="" node = ##class(IndexNode).Get(..indexGlobal, block) |
| 57 | +if ('..IsInside(x, y, node)) return |
59 | 58 | if (node.isLeaf){ |
60 | | -if ('..Contains(x, y, block)) { |
| 59 | +if ('..LeafContains(x, y, block)) { |
61 | 60 | set node.size = node.size + 1 |
62 | 61 | do ##class(IndexNode).Put(..indexGlobal, block, node) |
63 | 62 | } |
64 | 63 | set @..indexGlobal@(block, "data", x, y, id) = data |
65 | | -if (node.size > ..#NODESIZE) do ..Split(block) |
| 64 | +if (node.size > ..#NODESIZE) do ..Split(block, node) |
66 | 65 | } |
67 | 66 | else{ |
68 | 67 | for i=0:1:3 { |
|
77 | 76 | <Implementation><![CDATA[ |
78 | 77 | #dim node As IndexNode |
79 | 78 | set node = ##class(IndexNode).Get(..indexGlobal, block) |
80 | | -if ('..IsInside(x, y, block)) return |
| 79 | +if ('..IsInside(x, y, node)) return |
81 | 80 | if (node.isLeaf){ |
82 | | -if ('..Contains(x, y, block)) { |
| 81 | +if ('..LeafContains(x, y, block)) { |
83 | 82 | //TODO: throw error |
84 | 83 | return |
85 | 84 | } |
86 | 85 | kill @..indexGlobal@(block, "data", x, y, id) |
87 | | -if ('..Contains(x, y, block)){ |
| 86 | +if ('..LeafContains(x, y, block)){ |
88 | 87 | set node.size=node.size-1 |
89 | 88 | do ##class(IndexNode).Put(..indexGlobal, block, node) |
90 | 89 | } |
|
99 | 98 | </Method> |
100 | 99 |
|
101 | 100 | <Method name="IsInside"> |
102 | | -<FormalSpec>x:%Float,y:%Float,block:%String</FormalSpec> |
| 101 | +<FormalSpec>x:%Float,y:%Float,node:IndexNode</FormalSpec> |
103 | 102 | <ReturnType>%Boolean</ReturnType> |
104 | | -<Implementation><![CDATA[ |
105 | | -#dim node As IndexNode |
106 | | -set node = ##class(IndexNode).Get(..indexGlobal, block) |
107 | | -return (x>=node.minX) && (x<node.maxX) && (y>=node.minY) && (y<node.maxY) |
| 103 | +<Implementation><![CDATA[return (x>=node.minX) && (x<node.maxX) && (y>=node.minY) && (y<node.maxY) |
108 | 104 | ]]></Implementation> |
109 | 105 | </Method> |
110 | 106 |
|
111 | | -<Method name="Contains"> |
112 | | -<FormalSpec>x:%Float,y:%Float,block:%String=..#ROOTNODE</FormalSpec> |
| 107 | +<Method name="LeafContains"> |
| 108 | +<FormalSpec>x:%Float,y:%Float,block:%String</FormalSpec> |
113 | 109 | <ReturnType>%Boolean</ReturnType> |
114 | | -<Implementation><![CDATA[ |
115 | | -#dim node As IndexNode |
116 | | -set node = ##class(IndexNode).Get(..indexGlobal, block) |
117 | | -if ('..IsInside(x, y, block)) return $$$NO |
118 | | -if (node.isLeaf){ |
119 | | -return $DATA(@..indexGlobal@(block, "data", x, y))>0 |
120 | | -} |
121 | | -for i=0:1:3 { |
122 | | -if (..Contains(x, y, block_i)) return $$$YES |
123 | | -} |
124 | | -return $$$NO |
| 110 | +<Implementation><![CDATA[return $DATA(@..indexGlobal@(block, "data", x, y))>0 |
125 | 111 | ]]></Implementation> |
126 | 112 | </Method> |
127 | 113 |
|
128 | 114 | <Method name="Split"> |
129 | | -<FormalSpec>block:%String</FormalSpec> |
| 115 | +<FormalSpec>block:%String,node:IndexNode</FormalSpec> |
130 | 116 | <Implementation><![CDATA[ |
131 | | -#dim node As IndexNode |
132 | | -set node = ##class(IndexNode).Get(..indexGlobal, block) |
133 | 117 | set midX = (node.minX+node.maxX)/2 |
134 | 118 | set midY = (node.minY+node.maxY)/2 |
135 | 119 |
|
|
154 | 138 | while (y'=""){ |
155 | 139 | set id = $o(@..indexGlobal@(block, "data", x, y, "")) |
156 | 140 | while (id'=""){ |
157 | | -do ..Insert(x, y, id, @..indexGlobal@(block, "data", x, y, id), block) |
| 141 | +do ..Insert(x, y, id, @..indexGlobal@(block, "data", x, y, id), block, node) |
158 | 142 | set id = $o(@..indexGlobal@(block, "data", x, y, id)) |
159 | 143 | } |
160 | 144 | set y = $o(@..indexGlobal@(block, "data", x, y)) |
|
0 commit comments