Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/*
*.tgz
bin/*.js
.idea
.vscode/launch.json
118 changes: 99 additions & 19 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"shapefile": "0.6.6",
"table": "^5.4.6",
"tmp": "0.0.33",
"user-settings": "0.2.0"
"user-settings": "0.2.0",
"xmldom": "^0.2.1"
},
"devDependencies": {
"@turf/nearest-point-to-line": "6.0.0",
Expand All @@ -50,6 +51,7 @@
"@types/shapefile": "^0.6.0",
"@types/tmp": "0.0.33",
"@types/proj4": "2.5.0",
"@types/xmldom": "^0.1.29",
"capture-console": "^1.0.1",
"chai": "^4.2.0",
"express": "^4.16.4",
Expand Down
13 changes: 12 additions & 1 deletion src/here-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import * as transform from './transformutil';

const prompter = require('prompt');

const commands = ["csv2geo", "shp2geo"];
const commands = ["csv2geo", "shp2geo", "gpx2geo"];

program
.version('0.1.0');
Expand Down Expand Up @@ -61,6 +61,17 @@ program
});
});

program
.command('gpx2geo <path>')
.description('convert gpx to geojson')
.action(async function (path, opt) {
transform.read(path, false, { }).then(async result => {
//console.log(result)
const json = JSON.stringify({ features: await transform.transformGpx(result, opt), type: "FeatureCollection" }, null, 3); //Converted json object from gpx data
console.log(json);
});
});

common.validate(commands, [process.argv[2]], program);
prompter.stop();
program.parse(process.argv);
Expand Down
30 changes: 27 additions & 3 deletions src/here-xyz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ async function listTokens() {
program
.command("upload [id]")
.description("upload GeoJSON, CSV, or a Shapefile to the given id -- if no spaceID is given, a new space will be created")
.option("-f, --file <file>", "upload local GeoJSON, Shapefile, or CSV files (or GeoJSON/CSV URLs)")
.option("-f, --file <file>", "upload local GeoJSON, Shapefile, GPX, or CSV files (or GeoJSON/CSV URLs)")
.option("-c, --chunk [chunk]", "chunk size, default 200")
.option("-t, --tags [tags]", "tags for the xyz space")
.option("--token <token>", "a external token to upload data to another user's space")
Expand Down Expand Up @@ -1440,6 +1440,30 @@ async function uploadToXyzSpace(id: string, options: any) {
await new Promise(done => setTimeout(done, 1000));
}
}
} else if (options.file.indexOf(".gpx") != -1) {
let result = await transform.read(
options.file,
false,
{}
);
const object = {
features: await transform.transformGpx(
result,
options
),
type: "FeatureCollection"
};
await uploadData(
id,
options,
tags,
object,
true,
options.ptag,
options.file,
options.id
);

} else {
if (!options.stream) {
let result = await transform.read(
Expand Down Expand Up @@ -2010,7 +2034,7 @@ async function configXyzSpace(id: string, options: any) {
}

if (!(options.tagrules) &&
(options.update)) {
(options.update)) {
console.log("invalid options, update option can not be used without tagrules options")
process.exit(1);
}
Expand Down Expand Up @@ -2422,7 +2446,7 @@ function composeJsonPath(condition: string) {
function parseJsonPath(jsonPath: string) {
let myRegexp = /.\.features\[\?\((.*)\)\]/g;
let match: any = myRegexp.exec(jsonPath);
if(match) {
if (match) {
let expression = match[1];
let condition = expression.replace(/@\.properties\./g, "p.").replace(/@\./g, "f.");
return condition;
Expand Down
2 changes: 1 addition & 1 deletion src/here.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function start() {
.version(getVersion())
.command('configure [set|verify]', 'setup configuration for authentication').alias('c')
.command('xyz [list|create|upload]', 'work with xyz spaces').alias('xs')
.command('transform [csv2geo|shp2geo]', 'convert from csv/shapefile to geojson').alias('tf')
.command('transform [csv2geo|shp2geo|gpx2geo]', 'convert from csv/shapefile/gpx to geojson').alias('tf')
.command('geocode', 'geocode feature').alias('gc')
.parse(process.argv);
common.validate(commands, program.args, program);
Expand Down
Loading