soda-angular
Version:
Socrata SODA client for Angular
29 lines (28 loc) • 1 kB
JavaScript
import { WellKnownType } from '../../../../datatypes/well-known-type';
import { LocationUtils } from '../../../../utilities/location-utils';
export class WithinBox {
constructor(column, start, end) {
if (!column) {
throw new Error("Column must be provided");
}
if (!start) {
throw new Error("Start point must be provided");
}
if (!end) {
throw new Error("End point must be provided");
}
this.Column = column;
this.Start = start;
this.End = end;
}
toString() {
if (LocationUtils.isLocation(this.Start.Value)) {
return `within_box(${this.Column}, ${this.Start.Value}, ${this.End.Value})`;
}
else {
const wktStart = new WellKnownType(this.Start.Value);
const wktEnd = new WellKnownType(this.End.Value);
return `within_box(${this.Column}, '${wktStart}', '${wktEnd}')`;
}
}
}