|
| 1 | +import { IDocumentStore, PointField } from "../../src"; |
| 2 | +import { disposeTestDocumentStore, testContext } from "../Utils/TestUtil"; |
| 3 | +import { User } from "../Assets/Entities"; |
| 4 | +import { assertThat } from "../Utils/AssertExtensions"; |
| 5 | + |
| 6 | + |
| 7 | +describe("RDBC_594", function () { |
| 8 | + let store: IDocumentStore; |
| 9 | + |
| 10 | + beforeEach(async function () { |
| 11 | + store = await testContext.getDocumentStore(); |
| 12 | + }); |
| 13 | + |
| 14 | + afterEach(async () => |
| 15 | + await disposeTestDocumentStore(store)); |
| 16 | + |
| 17 | + describe("can use zero as distError", function () { |
| 18 | + it("relatedToShape", () => { |
| 19 | + const session = store.openSession(); |
| 20 | + |
| 21 | + const q1 = session.query(User) |
| 22 | + .spatial("WKT", |
| 23 | + f => f.relatesToShape("LINESTRING (1 0, 1 1, 1 2)", "Intersects", "Kilometers", 0)) |
| 24 | + .toString(); |
| 25 | + |
| 26 | + assertThat(q1) |
| 27 | + .contains("spatial.intersects(WKT, spatial.wkt($p0, 'Kilometers'), 0)"); |
| 28 | + }); |
| 29 | + |
| 30 | + it("intersects", () => { |
| 31 | + const session = store.openSession(); |
| 32 | + |
| 33 | + const q1 = session.query(User) |
| 34 | + .spatial("WKT", |
| 35 | + f => f.intersects("LINESTRING (1 0, 1 1, 1 2)", 0)) |
| 36 | + .toString(); |
| 37 | + |
| 38 | + assertThat(q1) |
| 39 | + .contains("spatial.intersects(WKT, spatial.wkt($p0), 0)"); |
| 40 | + }); |
| 41 | + |
| 42 | + it("contains", () => { |
| 43 | + const session = store.openSession(); |
| 44 | + |
| 45 | + const q1 = session.query(User) |
| 46 | + .spatial("WKT", |
| 47 | + f => f.contains("LINESTRING (1 0, 1 1, 1 2)", 0)) |
| 48 | + .toString(); |
| 49 | + |
| 50 | + assertThat(q1) |
| 51 | + .contains("spatial.contains(WKT, spatial.wkt($p0), 0)"); |
| 52 | + }); |
| 53 | + |
| 54 | + it("withinRadius", () => { |
| 55 | + const session = store.openSession(); |
| 56 | + |
| 57 | + const q1 = session.query(User) |
| 58 | + .spatial(new PointField("latitude2", "longitude2"), f => f.withinRadius(10, 10, 20, "Kilometers", 0)) |
| 59 | + .toString(); |
| 60 | + |
| 61 | + assertThat(q1) |
| 62 | + .contains("spatial.within(spatial.point(latitude2, longitude2), spatial.circle($p0, $p1, $p2, 'Kilometers'), 0)"); |
| 63 | + }) |
| 64 | + }) |
| 65 | +}); |
0 commit comments