Skip to content

Commit

Permalink
util updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kriscarle committed Mar 10, 2020
1 parent d98cb97 commit 31b42ac
Show file tree
Hide file tree
Showing 17 changed files with 8,103 additions and 235 deletions.
119 changes: 75 additions & 44 deletions .bitmap
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
/* THIS IS A BIT-AUTO-GENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. */

{
"kriscarle.maphubs-utils/maphubs-utils/url-util@1.0.0": {
"kriscarle.maphubs-utils/maphubs-utils/debug@1.0.0": {
"files": [
{
"relativePath": "url-util/index.js",
"relativePath": "debug/README.md",
"test": false,
"name": "index.js"
}
],
"mainFile": "url-util/index.js",
"trackDir": "url-util",
"origin": "AUTHORED"
},
"kriscarle.maphubs-utils/maphubs-utils/[email protected]": {
"files": [
"name": "README.md"
},
{
"relativePath": "log/index.js",
"relativePath": "debug/index.js",
"test": false,
"name": "index.js"
}
],
"mainFile": "log/index.js",
"trackDir": "log",
"origin": "AUTHORED"
},
"kriscarle.maphubs-utils/maphubs-utils/[email protected]": {
"files": [
{
"relativePath": "file-encoding-utils/README.md",
"test": false,
"name": "README.md"
},
{
"relativePath": "file-encoding-utils/index.js",
"relativePath": "debug/package.json",
"test": false,
"name": "index.js"
"name": "package.json"
}
],
"mainFile": "file-encoding-utils/index.js",
"trackDir": "file-encoding-utils",
"origin": "AUTHORED"
"mainFile": "debug/index.js",
"trackDir": "debug",
"origin": "AUTHORED",
"exported": true
},
"kriscarle.maphubs-utils/maphubs-utils/email-util@1.0.0": {
"kriscarle.maphubs-utils/maphubs-utils/email-util@1.1.1": {
"files": [
{
"relativePath": "email-util/README.md",
Expand All @@ -53,30 +35,42 @@
"relativePath": "email-util/index.js",
"test": false,
"name": "index.js"
},
{
"relativePath": "email-util/package.json",
"test": false,
"name": "package.json"
}
],
"mainFile": "email-util/index.js",
"trackDir": "email-util",
"origin": "AUTHORED"
"origin": "AUTHORED",
"exported": true
},
"kriscarle.maphubs-utils/maphubs-utils/debug@1.0.0": {
"kriscarle.maphubs-utils/maphubs-utils/file-encoding-utils@1.0.0": {
"files": [
{
"relativePath": "debug/README.md",
"relativePath": "file-encoding-utils/README.md",
"test": false,
"name": "README.md"
},
{
"relativePath": "debug/index.js",
"relativePath": "file-encoding-utils/index.js",
"test": false,
"name": "index.js"
},
{
"relativePath": "file-encoding-utils/package.json",
"test": false,
"name": "package.json"
}
],
"mainFile": "debug/index.js",
"trackDir": "debug",
"origin": "AUTHORED"
"mainFile": "file-encoding-utils/index.js",
"trackDir": "file-encoding-utils",
"origin": "AUTHORED",
"exported": true
},
"kriscarle.maphubs-utils/maphubs-utils/importers@1.0.2": {
"kriscarle.maphubs-utils/maphubs-utils/importers@1.1.8": {
"files": [
{
"relativePath": "importers/README.md",
Expand Down Expand Up @@ -114,19 +108,56 @@
"name": "index.js"
},
{
"relativePath": "importers/shapefile/index.js",
"relativePath": "importers/package.json",
"test": false,
"name": "index.js"
"name": "package.json"
},
{
"relativePath": "importers/shapefile/shapefile-fairy.js",
"relativePath": "importers/shapefile/index.js",
"test": false,
"name": "shapefile-fairy.js"
"name": "index.js"
}
],
"mainFile": "importers/index.js",
"trackDir": "importers",
"origin": "AUTHORED"
"origin": "AUTHORED",
"exported": true
},
"kriscarle.maphubs-utils/maphubs-utils/[email protected]": {
"files": [
{
"relativePath": "log/index.js",
"test": false,
"name": "index.js"
},
{
"relativePath": "log/package.json",
"test": false,
"name": "package.json"
}
],
"mainFile": "log/index.js",
"trackDir": "log",
"origin": "AUTHORED",
"exported": true
},
"kriscarle.maphubs-utils/maphubs-utils/[email protected]": {
"files": [
{
"relativePath": "url-util/index.js",
"test": false,
"name": "index.js"
},
{
"relativePath": "url-util/package.json",
"test": false,
"name": "package.json"
}
],
"mainFile": "url-util/index.js",
"trackDir": "url-util",
"origin": "AUTHORED",
"exported": true
},
"version": "13.0.4"
"version": "14.7.6"
}
3 changes: 1 addition & 2 deletions bit.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"env": {
"compiler": "bit.envs/compilers/flow@0.0.10"
"compiler": "bit.envs/compilers/flow@7.0.3"
},
"dependencies": {},
"componentsDefaultDirectory": "{name}",
"packageManager": "npm"
}
32 changes: 16 additions & 16 deletions email-util/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions email-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"homepage": "https://bitsrc.io/kriscarle/maphubs-utils/email-util",
"main": "index.js",
"dependencies": {
"aws-sdk": "^2.374.0",
"bluebird": "^3.5.3",
"nodemailer": "^4.7.0"
"aws-sdk": "^2.630.0",
"bluebird": "^3.7.2",
"nodemailer": "^6.4.3"
},
"devDependencies": {},
"peerDependencies": {},
Expand Down
7 changes: 4 additions & 3 deletions importers/csv/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// @flow
const csv2geojson = require('csv2geojson')
const { csv2geojson } = require('csv2geojson')
const fileEncodingUtils = require('../../file-encoding-utils')
const Promise = require('bluebird')
const util = require('util')
const csv2geo = util.promisify(csv2geojson)

module.exports = async function (filePath: string, layer_id: number, config?: Object) {
const data = fileEncodingUtils.getDecodedFileWithBestGuess(filePath)
const geoJSON = await Promise.promisify(csv2geojson.csv2geojson, {context: csv2geojson})(data)
const geoJSON = await csv2geo(data)
if (geoJSON) {
return geoJSON
} else {
Expand Down
5 changes: 3 additions & 2 deletions importers/geobuf/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// @flow
const geobuf = require('geobuf')
const Pbf = require('pbf')
const Promise = require('bluebird')
const fs = require('fs')
const debug = require('../../debug')('importers/geobuf')
const util = require('util')
const readFile = util.promisify(fs.readFile)

module.exports = async function (filePath: string, layer_id: number, config?: Object) {
debug.log(`importing Geobuf for layer: ${layer_id}`)
/* eslint-disable security/detect-non-literal-fs-filename */
// file path is a folder from a env var + a GUID, not orginal filename
const file = await Promise.promisify(fs.readFile, {context: fs})(filePath)
const file = await readFile(filePath)
const geoJSON = geobuf.decode(new Pbf(new Uint8Array(file)))
return geoJSON
}
28 changes: 12 additions & 16 deletions importers/gpx/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
// @flow
const Promise = require('bluebird')
const fs = require('fs')
const ogr2ogr = require('ogr2ogr')
const debug = require('../../debug')('importers/gpx')

module.exports = async function (filePath: string, layer_id: number, config?: Object) {
/* eslint-disable security/detect-non-literal-fs-filename */
// file path is a folder from a env var + a GUID, not orginal filename
const ogr = ogr2ogr(fs.createReadStream(filePath), 'GPX')
let geoJSON = await ogr2ogr(fs.createReadStream(filePath), 'GPX')
.format('GeoJSON').skipfailures()
.options(['-t_srs', 'EPSG:4326', '-sql', 'SELECT * FROM tracks'])
.timeout(60000)
const geoJSON = await Promise.promisify(ogr.exec, {context: ogr})()
.promise()
if (geoJSON.features && geoJSON.features.length === 0) {
debug.log('No tracks found, loading waypoints')
const ogrWaypoints = ogr2ogr(fs.createReadStream(filePath), 'GPX')
geoJSON = await ogr2ogr(fs.createReadStream(filePath), 'GPX')
.format('GeoJSON').skipfailures()
.options(['-t_srs', 'EPSG:4326', '-sql', 'SELECT * FROM waypoints'])
.timeout(60000)

const geoJSON = await Promise.promisify(ogrWaypoints.exec)()
return geoJSON
} else {
if (config && config.writeDebugData) {
fs.writeFile(config.tempFilePath + '/gpx-upload-layer-' + layer_id + '.geojson', JSON.stringify(geoJSON), (err) => {
if (err) {
throw err
}
})
}
return geoJSON
.promise()
}
if (config && config.writeDebugData) {
fs.writeFile(config.tempFilePath + '/gpx-upload-layer-' + layer_id + '.geojson', JSON.stringify(geoJSON), (err) => {
if (err) {
throw err
}
})
}
return geoJSON
}
3 changes: 3 additions & 0 deletions importers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module.exports = {
} else if (fileName.endsWith('.kml')) {
debug.log('KML File Detected')
return kml
} else if (fileName.endsWith('.kmz')) {
debug.log('KMZ File Detected')
return kml
} else if (fileName.endsWith('.gpx')) {
debug.log('GPX File Detected')
return gpx
Expand Down
11 changes: 6 additions & 5 deletions importers/kml/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
const Promise = require('bluebird')
const fs = require('fs')
const ogr2ogr = require('ogr2ogr')
const debug = require('../../debug')('importers/kml')
Expand All @@ -8,10 +7,12 @@ module.exports = async function (filePath: string, layer_id: number, config?: Ob
debug.log(`importing KML for layer: ${layer_id}`)
/* eslint-disable security/detect-non-literal-fs-filename */
// file path is a folder from a env var + a GUID, not orginal filename
const ogr = ogr2ogr(fs.createReadStream(filePath), 'KML')
.format('GeoJSON').skipfailures()
.options(['-t_srs', 'EPSG:4326']).timeout(60000)
const geoJSON = await ogr2ogr(filePath, 'KML')
.format('GeoJSON')
.skipfailures()
.options(['-t_srs', 'EPSG:4326'])
.timeout(60000)
.promise()

const geoJSON = await Promise.promisify(ogr.exec, { context: ogr })()
return geoJSON
}
Loading

0 comments on commit 31b42ac

Please sign in to comment.