UNPKG

@directus/api

Version:

Directus is a real-time API and App dashboard for managing SQL database content

26 lines (24 loc) 767 B
import { GeometryHelper } from "../types.js"; //#region src/database/helpers/geometry/dialects/postgres.ts var GeometryHelperPostgres = class extends GeometryHelper { async supported() { return (await this.knex.select("oid").from("pg_proc").where({ proname: "postgis_version" })).length > 0; } createColumn(table, field) { const type = this.geometrySubtype(field) ?? "geometry"; return table.specificType(field.field, `geometry(${type}, 4326)`); } _intersects_bbox(key, geojson) { const geometry = this.fromGeoJSON(geojson); return this.knex.raw("?? && ?", [key, geometry]); } asGeoJSON(table, column) { return this.knex.raw("st_asgeojson(??.??) as ??", [ table, column, column ]); } }; //#endregion export { GeometryHelperPostgres };