Commit 4f9c1a0c authored by Michael Auer's avatar Michael Auer
Browse files

set bigint to be parsed as int

parent fed9758c
This diff is collapsed.
......@@ -162,6 +162,7 @@ class Ohsome2X extends EventEmitter {
this.emit('progress', {type:'progress', processed: this.currentFeatureCount, total: this.totalFeatureCount, cursor: cursor, fetchSize: fetchSize, timestamp: new Date().toISOString()});
const sourceFeatureCollection: any = await this.sourceFeatureType.getFeaturesByCursorAndLimit(cursor, fetchSize);
console.log(JSON.stringify(sourceFeatureCollection,null,2));
let targetFeatureCollection: any;
featureCount = sourceFeatureCollection.features.length;
......@@ -697,4 +698,4 @@ class Ohsome2X extends EventEmitter {
}
export = Ohsome2X;
// export * from './config_types_interfaces';
\ No newline at end of file
// export * from './config_types_interfaces';
......@@ -10,7 +10,7 @@
import {PostgisStore, SourcePostgisFeatureTypeConfig, TargetPostgisFeatureTypeConfig} from './config_types_interfaces';
import {FeatureType} from './FeatureType';
import pgPromise, {IDatabase} from 'pg-promise'
import {types as pgTypes} from 'pg';
// import {types as pgTypes} from 'pg';
import * as turfHelpers from '@turf/helpers';
import {Feature, FeatureCollection} from '@turf/helpers';
// import * as moment from 'moment';
......@@ -46,13 +46,15 @@ export class PgFeatureType extends FeatureType {
if ('fetchSize' in config) {
this.fetchSize = config.fetchSize;
}
// this.db = new PgAsync(this.store);
this.pgp = pgPromise({});
//per default pg parses int8 values as strings
pgTypes.setTypeParser(20, function (val) {
this.pgp.pg.types.setTypeParser(20, function (val) {
return parseInt(val)
});
// this.db = new PgAsync(this.store);
this.pgp = pgPromise({});
this.db = this.pgp(this.store);
this.checkTableExists();
......@@ -162,7 +164,7 @@ export class PgFeatureType extends FeatureType {
ORDER BY "${this.geometryId}" ASC
LIMIT ${fetchSize};`;
console.log('Get cells from ' + this.tableName + ' with id > ' + cursor + ' with fetchSize: ' + fetchSize);
console.log(sql);
const result = await this.db.any(sql, cursor);
let features = result.map((row: any) => turfHelpers.feature(row.geom, {id: row.id}));
let featureCollection = turfHelpers.featureCollection(features);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment