Fix mysql wkt conversion (#9621)

This commit is contained in:
Oreille
2021-11-09 17:07:19 +01:00
committed by GitHub
parent ce97a40271
commit b82b68eacc

View File

@@ -87,6 +87,7 @@ class KnexSpatial_SQLite extends KnexSpatial {
return this.knex.raw('asgeojson(??.??) as ??', [table, column, column]);
}
}
class KnexSpatial_PG extends KnexSpatial {
async supported() {
const res = await this.knex.select('oid').from('pg_proc').where({ proname: 'postgis_version' });
@@ -94,7 +95,7 @@ class KnexSpatial_PG extends KnexSpatial {
}
createColumn(table: Knex.CreateTableBuilder, field: RawField | Field) {
const type = field.type.split('.')[1] ?? 'geometry';
return table.specificType(field.field, `geometry(${type})`);
return table.specificType(field.field, `geometry(${type}, 4326)`);
}
_intersects_bbox(key: string, geojson: GeoJSONGeometry): Knex.Raw {
const geometry = this.fromGeoJSON(geojson);
@@ -109,6 +110,9 @@ class KnexSpatial_MySQL extends KnexSpatial {
this.asText(table, column)
);
}
fromText(text: string): Knex.Raw {
return this.knex.raw('st_geomfromtext(?)', text);
}
}
class KnexSpatial_Redshift extends KnexSpatial {