Permalink
Browse files

implemented inside_circle geo method

  • Loading branch information...
1 parent a07dab2 commit b3e981e1d0cabc1b63bee739b34e3949775ee3fd @phifty committed Mar 28, 2010
@@ -68,6 +68,17 @@ def inside_box(type, predicate, x_min, y_min, x_max, y_max)
@server.request :get, self.path + "/box", :parameters => parameters, :expected_status_code => 200
end
+ def inside_circle(type, predicate, x, y, radius)
+ parameters = {
+ :type => type,
+ :predicate => predicate,
+ :x => x.to_s,
+ :y => y.to_s,
+ :radius => radius.to_s
+ }
+ @server.request :get, self.path + "/circle", :parameters => parameters, :expected_status_code => 200
+ end
+
end
end
View
@@ -189,3 +189,16 @@
:code: "200"
:body:
- [ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>" ]
+-
+ :http_method: "get"
+ :url: "http://localhost:10035/catalogs/test_catalog/repositories/test_repository/geo/circle"
+ :parameters:
+ :type: "<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"
+ :predicate: "\"at\""
+ :x: "9.0"
+ :y: "9.0"
+ :radius: "2.0"
+ :response:
+ :code: "200"
+ :body:
+ - [ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>" ]
@@ -208,9 +208,12 @@
it "should find objects inside a box" do
result = @geo.inside_box @type, "\"at\"", 8.0, 8.0, 11.0, 11.0
- result.should == [
- [ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"]
- ]
+ result.should include([ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"])
+ end
+
+ it "should find objects inside a circle" do
+ result = @geo.inside_circle @type, "\"at\"", 9.0, 9.0, 2.0
+ result.should include([ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"])
end
end
@@ -52,15 +52,18 @@
describe "inside_box" do
- before :each do
- @repository.statements.create "\"test_subject\"", "\"at\"", "\"+10+10\"^^#{@type}"
- end
-
it "should find objects inside a box" do
result = @geo.inside_box @type, "\"at\"", 8.0, 8.0, 11.0, 11.0
- result.should == [
- [ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"]
- ]
+ result.should include([ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"])
+ end
+
+ end
+
+ describe "inside_circle" do
+
+ it "should find objects inside a circle" do
+ result = @geo.inside_circle @type, "\"at\"", 9.0, 9.0, 2.0
+ result.should include([ "\"test_subject\"", "\"at\"", "\"+10.000000000931323+10.000000000931323\"^^<http://franz.com/ns/allegrograph/3.0/geospatial/cartesian/2.0/20.0/2.0/20.0/1.0>"])
end
end

0 comments on commit b3e981e

Please sign in to comment.