Skip to content

Commit 641d9f3

Browse files
committed
Merge branch 'master' of github.com:intersystems-ru/spatialindex
2 parents dc58c8e + 939795a commit 641d9f3

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

SpatialIndex_Index.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919
This method is invoked when an existing instance of va class is deleted.</Description>
2020
<ClassMethod>1</ClassMethod>
2121
<CodeMode>generator</CodeMode>
22-
<FormalSpec>rect:%Binary</FormalSpec>
22+
<FormalSpec>queryType:%Binary,queryParams:%String</FormalSpec>
2323
<ReturnType>%Library.Binary</ReturnType>
2424
<SqlProc>1</SqlProc>
2525
<ServerOnly>1</ServerOnly>
2626
<Implementation><![CDATA[
27-
$$$GENERATE($C(9)_"set result = ##class(SpatialIndex.SQLResult).%New()")
28-
$$$GENERATE($C(9)_"do result.PrepareFind(rect)")
29-
$$$GENERATE($C(9)_"quit result")
27+
if %mode'="method" {
28+
set IndexGlobal = ..IndexLocation(%class,%property)
29+
set IndexGlobalQ = $$$QUOTE(IndexGlobal)
30+
$$$GENERATE($C(9)_"set result = ##class(SpatialIndex.SQLResult).%New()")
31+
$$$GENERATE($C(9)_"do result.PrepareFind($Name("_IndexGlobal_"), queryType, queryParams)")
32+
$$$GENERATE($C(9)_"quit result")
33+
}
3034
]]></Implementation>
3135
</Method>
3236

SpatialIndex_QueryExecutor.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<ReturnType>%Status</ReturnType>
2828
<Implementation><![CDATA[
2929
set index = $i(qHandle("index"))
30-
set AtEnd = index>=qHandle("data")
30+
set AtEnd = index>=$G(qHandle("data"))
3131
set Row = $lb(qHandle("data", index))
3232
return $$$OK
3333
]]></Implementation>

SpatialIndex_SQLResult.xml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,31 @@
2020
</Method>
2121

2222
<Method name="PrepareFind">
23-
<FormalSpec>rect:%Binary</FormalSpec>
23+
<FormalSpec>indexGlobal:%String,queryType:%String,queryParams:%Binary</FormalSpec>
2424
<ReturnType>%Status</ReturnType>
2525
<Implementation><![CDATA[
26-
set str = ""
27-
set $BIT(str,10 + 1) = 1
28-
set $BIT(str,15 + 1) = 1
29-
set $BIT(str,17 + 1) = 1
30-
set i%ResultBits = 1
31-
set i%ResultBits(1) = str
26+
//for now we only have queryType = window
27+
for i = 1:1:4 {
28+
set item = $Piece(queryParams, ",", i)
29+
set param = $Piece(item, "=", 1)
30+
set value = $Piece(item, "=" ,2)
31+
if param = "minx" {
32+
set minx = value
33+
} elseif param = "maxx" {
34+
set maxx = value
35+
} elseif param = "maxy"{
36+
set maxy = value
37+
} elseif param = "miny" {
38+
set miny = value
39+
}
40+
}
41+
set rset = ##class(%ResultSet).%New("SpatialIndex.QueryExecutor:FindWindow")
42+
do rset.Execute(indexGlobal,minx,miny,maxx,maxy)
43+
while (rset.Next()){
44+
set id = rset.Get("Id")
45+
set tChunk = (id\64000)+1, tPos=(id#64000)+1
46+
set $BIT(i%ResultBits(tChunk),tPos) = 1
47+
}
3248
quit $$$OK
3349
]]></Implementation>
3450
</Method>
@@ -38,14 +54,14 @@
3854
<ReturnType>%Boolean</ReturnType>
3955
<Implementation><![CDATA[
4056
set tChunk = (pItem\64000)+1, tPos=(pItem#64000)+1
41-
quit $bit($g(i%ResultBits(tChunk)),tPos)
57+
quit $bit($get(i%ResultBits(tChunk)),tPos)
4258
]]></Implementation>
4359
</Method>
4460

4561
<Method name="GetChunk">
4662
<FormalSpec>pChunk:%Integer</FormalSpec>
4763
<ReturnType>%Binary</ReturnType>
48-
<Implementation><![CDATA[quit $g(i%ResultBits(pChunk))
64+
<Implementation><![CDATA[quit $get(i%ResultBits(pChunk))
4965
]]></Implementation>
5066
</Method>
5167

SpatialIndex_Test.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,18 @@
5454
<IndexLocation>^SpatialIndex.TestI</IndexLocation>
5555
<StreamLocation>^SpatialIndex.TestS</StreamLocation>
5656
<Data name="TestDefaultData">
57+
<Structure>listnode</Structure>
58+
<Subscript/>
5759
<Value name="1">
5860
<Value>%%CLASSNAME</Value>
5961
</Value>
6062
<Value name="2">
6163
<Value>Name</Value>
6264
</Value>
6365
<Value name="3">
64-
<Value>X</Value>
65-
</Value>
66-
<Value name="4">
67-
<Value>Y</Value>
68-
</Value>
69-
<Value name="5">
7066
<Value>Latitude</Value>
7167
</Value>
72-
<Value name="6">
68+
<Value name="4">
7369
<Value>Longitude</Value>
7470
</Value>
7571
</Data>

0 commit comments

Comments
 (0)