un-cli 0.0.75 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
7
7
  import logger from "./logger.mjs"
8
8
  import fetch from "node-fetch"
9
9
  //update version
10
- let version = "0.0.75";
10
+ let version = "0.0.78";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -85,8 +85,7 @@ async function regenerateToken(parameters) {
85
85
  //connect to the service
86
86
  async function connect(parameters) {
87
87
  try{
88
- //print the parameters
89
- logger.info(parameters);
88
+
90
89
  //connect to portal
91
90
 
92
91
  const token = await getToken(parameters);
@@ -316,10 +315,12 @@ const inputs = {
316
315
  //progress
317
316
  //timeouts
318
317
  //in case failure you don't lose everything
319
- "^topology --validate -fn$": async () => {
318
+ "^topology --validate --fishnet$": async () => {
320
319
  logger.info("Validating Network topology ...");
321
320
 
322
- const fullExtent = un.featureServiceJson.fullExtent;
321
+ const fullExtent = un.layerDefinition.extent;
322
+ //console.log(`add_env(${ JSON.stringify(fullExtent)})`)
323
+
323
324
  /*
324
325
  fullExtent.xmin = 0;
325
326
  fullExtent.xmax = 100;
@@ -328,13 +329,14 @@ const inputs = {
328
329
  https://desktop.arcgis.com/en/arcmap/10.3/tools/cartography-toolbox/create-cartographic-partitions.htm
329
330
  */
330
331
  //fish net
331
- const grids = 4;
332
+ const grids = 5; //divide the grid 5 x 5
332
333
  const dx = (fullExtent.xmax - fullExtent.xmin) / grids;
333
334
  const dy = (fullExtent.ymax - fullExtent.ymin) / grids;
334
-
335
- const extents = [];
335
+
336
+ const fishnet = [];
336
337
  for (let i =0; i < grids; i ++) {
337
-
338
+ const row = [];
339
+
338
340
  for (let j = 0; j < grids; j++) {
339
341
  const extent = {
340
342
  "xmin": fullExtent.xmin + j*dx,
@@ -343,24 +345,47 @@ const inputs = {
343
345
  "ymax": fullExtent.ymin + i*dy + dy,
344
346
  "spatialReference": fullExtent.spatialReference
345
347
  }
346
- extents.push(extent);
348
+ row.push({"content": " ", "extent": extent});
349
+
347
350
  }
351
+ fishnet.push(row);
348
352
  }
349
353
 
350
- extents.forEach(async e => {
351
- const fromDate = new Date();
352
354
 
353
- const result = await un.validateNetworkTopology("sde.DEFAULT", e)
354
- const toDate = new Date();
355
- const timeEnable = toDate.getTime() - fromDate.getTime();
356
- const duration = numberWithCommas(Math.round(timeEnable)) + " ms"
357
- console.clear()
358
- logger.info("Validating extent " + e.xmin)
359
- console.table({duration})
360
355
 
361
- })
362
-
363
-
356
+ for (let i = 0; i < fishnet.length; i ++) {
357
+
358
+ for (let j = 0 ; j < fishnet[i].length; j++) {
359
+
360
+ fishnet[i][j].content = '*'
361
+ const e = fishnet[i][j].extent
362
+
363
+ try {
364
+
365
+
366
+ const fromDate = new Date();
367
+ console.log("Validating Extent " + JSON.stringify(e));
368
+ printFishnet(fishnet)
369
+
370
+ const result = await un.validateNetworkTopology( e)
371
+ const toDate = new Date();
372
+ const timeEnable = toDate.getTime() - fromDate.getTime();
373
+ const duration = numberWithCommas(Math.round(timeEnable)) + " ms"
374
+ result.duration = duration
375
+ console.table(result)
376
+ //console.log(`add_env(${ JSON.stringify(e)})`)
377
+ fishnet[i][j].content = 'x'
378
+
379
+ }
380
+ catch(ex){
381
+ console.log(JSON.stringify(ex))
382
+ }
383
+
384
+ }
385
+
386
+ }
387
+ console.log("Done")
388
+
364
389
  },
365
390
 
366
391
  "^topology --validate$": async () => {
@@ -420,7 +445,7 @@ const inputs = {
420
445
  }
421
446
  },
422
447
 
423
- "^update subnetworks --all" : async input => {
448
+ "^update subnetworks --all$" : async input => {
424
449
 
425
450
  let subnetworks;
426
451
  let more = false;
@@ -1407,3 +1432,27 @@ export async function run (){
1407
1432
 
1408
1433
 
1409
1434
 
1435
+ function printFishnet(fishnet) {
1436
+
1437
+ //y is flipped x is ok
1438
+ //i = 0 that is i = fishnet.length -1
1439
+ for (let i =0; i < fishnet.length ; i++){
1440
+
1441
+ for (let j = 0; j < fishnet[i].length;j++)
1442
+ process.stdout.write("+------");
1443
+
1444
+ process.stdout.write("+\n")
1445
+
1446
+ for (let j = 0; j < fishnet[i].length;j++)
1447
+ process.stdout.write(`| ${fishnet[fishnet.length - 1 - i][j].content} `);
1448
+
1449
+ process.stdout.write("|\n")
1450
+ }
1451
+
1452
+
1453
+ for (let j = 0; j < fishnet.length;j++)
1454
+ process.stdout.write("+------");
1455
+
1456
+ process.stdout.write("+\n\n")
1457
+
1458
+ }
package/makerequest.mjs CHANGED
@@ -29,7 +29,7 @@ export function makeRequest (opts) {
29
29
  let f;
30
30
  try {
31
31
 
32
- const nodeFetch = await import ("node-fetch");
32
+ let nodeFetch = await import ("node-fetch");
33
33
  f = nodeFetch.default;
34
34
  }
35
35
  catch(ex) {
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
- {
2
- "name": "un-cli",
3
- "version": "0.0.75",
4
- "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
- "main": "index.mjs",
6
- "bin": {
7
- "uncli": "un.mjs"
8
- },
9
- "scripts": {
10
- "start": "node un.mjs"
11
- },
12
- "keywords": [
13
- "esri",
14
- "ArcGIS",
15
- "utility-network"
16
- ],
17
- "author": "Hussein Nasser",
18
- "license": "ISC",
19
- "dependencies": {
20
- "node-fetch": "^2.6.0"
21
- }
22
- }
1
+ {
2
+ "name": "un-cli",
3
+ "version": "0.0.78",
4
+ "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
+ "main": "index.mjs",
6
+ "bin": {
7
+ "uncli": "un.mjs"
8
+ },
9
+ "scripts": {
10
+ "start": "node un.mjs"
11
+ },
12
+ "keywords": [
13
+ "esri",
14
+ "ArcGIS",
15
+ "utility-network"
16
+ ],
17
+ "author": "Hussein Nasser",
18
+ "license": "ISC",
19
+ "dependencies": {
20
+ "node-fetch": "^2.6.0"
21
+ }
22
+ }
package/portal.mjs CHANGED
@@ -46,7 +46,7 @@ export class Portal{
46
46
  catch(ex){
47
47
  logger.error(ex?.status?.message)
48
48
  console.error(ex?.status?.errno)
49
- reject(`Failed to connect to portal, check your username or password or add --verify false if you are using a self-signed certificate. Normally a production system should have a valid certificate signed by a CA and you should NOT disable verification in that case.) \n\n${ex}`)
49
+ reject(`Failed to connect to portal, check your username or password or add --verify false if you are using a self-signed certificate. Normally a production system should have a valid certificate signed by a CA and you should NOT disable verification in that case.) \n\n${JSON.stringify(ex)}`)
50
50
  }
51
51
 
52
52
  }
package/un.mjs CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node --experimental-modules
2
-
3
- import {run} from "./index.mjs"
1
+ #!/usr/bin/env node --experimental-modules
2
+
3
+ import {run} from "./index.mjs"
4
4
  run();