Skip to content

Commit

Permalink
chore: bumped geo-pixel-stream to gdal-async branch
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Apr 11, 2024
1 parent 572c32a commit 1beef43
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 63 deletions.
10 changes: 5 additions & 5 deletions lib/hooks/hooks.geojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export function readSequentialGeoJson (options = {}) {

await new Promise((resolve, reject) => {
rl
.on('line', (line) => {
json.push(JSON.parse(line))
})
.on('close', resolve)
.on('error', reject)
.on('line', (line) => {
json.push(JSON.parse(line))
})
.on('close', resolve)
.on('error', reject)
})
// Allow transform after read
if (options.transform) json = transformJsonObject(json, options.transform)
Expand Down
18 changes: 8 additions & 10 deletions lib/hooks/hooks.mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ async function dropIndex (collection, collectionName, index) {
// If index does not exist we do not raise
if (error instanceof MongoError && error.code === 27) {
debug(collectionName + ' collection index does not exist, skipping drop')
return
} else {
// Rethrow
throw error
Expand All @@ -40,7 +39,6 @@ async function createIndex (collection, collectionName, index) {
// If index already exists with different options we do not raise
if (error instanceof MongoError && error.code === 85) {
debug(collectionName + ' collection index does already exist with different options, skipping create')
return
} else {
// Rethrow
throw error
Expand Down Expand Up @@ -145,12 +143,12 @@ export function createMongoCollection (options = {}) {
}
// Add index if required
if (options.index) {
await createIndex (collection, collectionName, options.index)
await createIndex(collection, collectionName, options.index)
} else if (options.indices) { // Or multiple indices
// As arguments or single object ?
for (let i = 0; i < options.indices.length; i++) {
const index = options.indices[i]
await createIndex (collection, collectionName, index)
await createIndex(collection, collectionName, index)
}
}
return hook
Expand All @@ -168,7 +166,7 @@ export function dropMongoIndex (options = {}) {

const collectionName = template(item, _.get(options, 'collection', _.snakeCase(item.id)))
// Check if already exist (strict mode requires a callback)
let collection = await new Promise((resolve, reject) => {
const collection = await new Promise((resolve, reject) => {
client.db.collection(collectionName, { strict: true }, (error, collection) => {
// If it does not exist we will create it
if (error) resolve(null)
Expand All @@ -181,11 +179,11 @@ export function dropMongoIndex (options = {}) {
}
// Drop index if required
if (options.index) {
await dropIndex (collection, collectionName, options.index)
await dropIndex(collection, collectionName, options.index)
} else if (options.indices) { // Or multiple indices
for (let i = 0; i < options.indices.length; i++) {
const index = options.indices[i]
await dropIndex (collection, collectionName, index)
await dropIndex(collection, collectionName, index)
}
}
return hook
Expand All @@ -203,7 +201,7 @@ export function createMongoIndex (options = {}) {

const collectionName = template(item, _.get(options, 'collection', _.snakeCase(item.id)))
// Check if already exist (strict mode requires a callback)
let collection = await new Promise((resolve, reject) => {
const collection = await new Promise((resolve, reject) => {
client.db.collection(collectionName, { strict: true }, (error, collection) => {
// If it does not exist we will create it
if (error) resolve(null)
Expand All @@ -217,11 +215,11 @@ export function createMongoIndex (options = {}) {
}
// Add index if required
if (options.index) {
await createIndex (collection, collectionName, options.index)
await createIndex(collection, collectionName, options.index)
} else if (options.indices) { // Or multiple indices
for (let i = 0; i < options.indices.length; i++) {
const index = options.indices[i]
await createIndex (collection, collectionName, index)
await createIndex(collection, collectionName, index)
}
}
return hook
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/hooks.raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path'
import _ from 'lodash'
import makeDebug from 'debug'
import gtif from '@kalisio/geo-pixel-stream'
import gdal from 'gdal-next'
import gdal from 'gdal-async'
import { getStoreFromHook } from '../utils.js'

const debug = makeDebug('krawler:hooks:raster')
Expand Down
4 changes: 2 additions & 2 deletions lib/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function activateHooks (serviceHooks, service) {
}

export function insertHookBefore (insertionHookName, hooksDefinition, insertedHookName, insertedHookOptions) {
let newHooksDefinition = {}
const newHooksDefinition = {}
// Need to create a new definition object as key insertion order matters
_.forOwn(hooksDefinition, (hookOptions, hookName) => {
if (hookName === insertionHookName) {
Expand All @@ -193,7 +193,7 @@ export function insertHookBefore (insertionHookName, hooksDefinition, insertedHo
}

export function insertHookAfter (insertionHookName, hooksDefinition, insertedHookName, insertedHookOptions) {
let newHooksDefinition = {}
const newHooksDefinition = {}
// Need to create a new definition object as key insertion order matters
_.forOwn(hooksDefinition, (hookOptions, hookName) => {
newHooksDefinition[hookName] = hookOptions
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@feathersjs/feathers": "^5.0.8",
"@feathersjs/socketio": "^5.0.8",
"@kalisio/feathers-distributed": "^2.4.0",
"@kalisio/geo-pixel-stream": "https://github.com/kalisio/geo-pixel-stream#next",
"@kalisio/geo-pixel-stream": "https://github.com/kalisio/geo-pixel-stream#gdal-async",
"@mapbox/sphericalmercator": "^1.0.5",
"@tmcw/togeojson": "^5.2.1",
"@turf/turf": "6.2.0-alpha.3",
Expand Down
4 changes: 2 additions & 2 deletions test/hooks.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('krawler:hooks:utils', () => {
}

it('insert hook before', () => {
let newHookDefinitions = pluginHooks.insertHookBefore('convertToGeoJson', hookDefinitions, 'transformJson', {})
const newHookDefinitions = pluginHooks.insertHookBefore('convertToGeoJson', hookDefinitions, 'transformJson', {})
let index = 0
_.forOwn(newHookDefinitions, (hookOptions, hookName) => {
if (index === 0) expect(hookName).to.equal('readJson')
Expand All @@ -170,7 +170,7 @@ describe('krawler:hooks:utils', () => {
})

it('insert hook after', () => {
let newHookDefinitions = pluginHooks.insertHookAfter('readJson', hookDefinitions, 'transformJson', {})
const newHookDefinitions = pluginHooks.insertHookAfter('readJson', hookDefinitions, 'transformJson', {})
let index = 0
_.forOwn(newHookDefinitions, (hookOptions, hookName) => {
if (index === 0) expect(hookName).to.equal('readJson')
Expand Down
Loading

0 comments on commit 1beef43

Please sign in to comment.