ravendb
Version:
RavenDB client for Node.js
40 lines • 1.32 kB
JavaScript
import { throwError } from "../../../Exceptions/index.js";
import { WhereToken, WhereOptions } from "../../Session/Tokens/WhereToken.js";
export class SpatialCriteria {
_relation;
_distanceErrorPct;
constructor(relation, distanceErrorPct) {
this._relation = relation;
this._distanceErrorPct = distanceErrorPct;
}
toQueryToken(fieldName, addQueryParameter) {
const shapeToken = this._getShapeToken(addQueryParameter);
let whereOperator;
switch (this._relation) {
case "Within": {
whereOperator = "SpatialWithin";
break;
}
case "Contains": {
whereOperator = "SpatialContains";
break;
}
case "Disjoint": {
whereOperator = "SpatialDisjoint";
break;
}
case "Intersects": {
whereOperator = "SpatialIntersects";
break;
}
default: {
throwError("InvalidArgumentException");
}
}
return WhereToken.create(whereOperator, fieldName, null, new WhereOptions({
shape: shapeToken,
distance: this._distanceErrorPct
}));
}
}
//# sourceMappingURL=SpatialCriteria.js.map