|
1 |
| -import {NetworkAnalystService} from '../../../src/mapboxgl/services/NetworkAnalystService'; |
2 |
| -import {BurstPipelineAnalystParameters} from '../../../src/common/iServer/BurstPipelineAnalystParameters'; |
3 |
| -import {ComputeWeightMatrixParameters} from '../../../src/common/iServer/ComputeWeightMatrixParameters'; |
4 |
| -import {FindClosestFacilitiesParameters} from '../../../src/common/iServer/FindClosestFacilitiesParameters'; |
5 |
| -import {TransportationAnalystResultSetting} from '../../../src/common/iServer/TransportationAnalystResultSetting'; |
6 |
| -import {TransportationAnalystParameter} from '../../../src/common/iServer/TransportationAnalystParameter'; |
7 |
| -import {FindLocationParameters} from '../../../src/common/iServer/FindLocationParameters'; |
8 |
| -import {FindPathParameters} from '../../../src/common/iServer/FindPathParameters'; |
9 |
| -import {FindTSPPathsParameters} from '../../../src/common/iServer/FindTSPPathsParameters'; |
10 |
| -import {FindMTSPPathsParameters} from '../../../src/common/iServer/FindMTSPPathsParameters'; |
11 |
| -import {FindServiceAreasParameters} from '../../../src/common/iServer/FindServiceAreasParameters'; |
12 |
| -import {UpdateEdgeWeightParameters} from '../../../src/common/iServer/UpdateEdgeWeightParameters'; |
13 |
| -import {UpdateTurnNodeWeightParameters} from '../../../src/common/iServer/UpdateTurnNodeWeightParameters'; |
14 |
| -import {SupplyCenter} from '../../../src/common/iServer/SupplyCenter' |
15 |
| -import {SupplyCenterType} from '../../../src/common/REST'; |
| 1 | +import { NetworkAnalystService } from '../../../src/mapboxgl/services/NetworkAnalystService'; |
| 2 | +import { BurstPipelineAnalystParameters } from '../../../src/common/iServer/BurstPipelineAnalystParameters'; |
| 3 | +import { ComputeWeightMatrixParameters } from '../../../src/common/iServer/ComputeWeightMatrixParameters'; |
| 4 | +import { FindClosestFacilitiesParameters } from '../../../src/common/iServer/FindClosestFacilitiesParameters'; |
| 5 | +import { TransportationAnalystResultSetting } from '../../../src/common/iServer/TransportationAnalystResultSetting'; |
| 6 | +import { TransportationAnalystParameter } from '../../../src/common/iServer/TransportationAnalystParameter'; |
| 7 | +import { FindLocationParameters } from '../../../src/common/iServer/FindLocationParameters'; |
| 8 | +import { FindPathParameters } from '../../../src/common/iServer/FindPathParameters'; |
| 9 | +import { FindTSPPathsParameters } from '../../../src/common/iServer/FindTSPPathsParameters'; |
| 10 | +import { FindMTSPPathsParameters } from '../../../src/common/iServer/FindMTSPPathsParameters'; |
| 11 | +import { FindServiceAreasParameters } from '../../../src/common/iServer/FindServiceAreasParameters'; |
| 12 | +import { UpdateEdgeWeightParameters } from '../../../src/common/iServer/UpdateEdgeWeightParameters'; |
| 13 | +import { UpdateTurnNodeWeightParameters } from '../../../src/common/iServer/UpdateTurnNodeWeightParameters'; |
| 14 | +import { FacilityAnalystStreamParameters } from '../../../src/common/iServer/FacilityAnalystStreamParameters'; |
| 15 | +import { SupplyCenter } from '../../../src/common/iServer/SupplyCenter' |
| 16 | +import { SupplyCenterType } from '../../../src/common/REST'; |
16 | 17 | import mapboxgl from 'mapbox-gl';
|
17 | 18 |
|
18 | 19 | var url = GlobeParameter.networkAnalystURL;
|
@@ -453,6 +454,131 @@ describe('mapboxgl_NetworkAnalystService', () => {
|
453 | 454 | }
|
454 | 455 | }, 5000)
|
455 | 456 | });
|
| 457 | + |
| 458 | + //最近设施分析服务 |
| 459 | + it('findClosestFacilities', (done) => { |
| 460 | + //创建最近设施分析参数实例 |
| 461 | + var resultSetting = new TransportationAnalystResultSetting({ |
| 462 | + returnEdgeFeatures: true, |
| 463 | + returnEdgeGeometry: true, |
| 464 | + returnEdgeIDs: true, |
| 465 | + returnNodeFeatures: true, |
| 466 | + returnNodeGeometry: true, |
| 467 | + returnNodeIDs: true, |
| 468 | + returnPathGuides: true, |
| 469 | + returnRoutes: true |
| 470 | + }); |
| 471 | + var analystParameter = new TransportationAnalystParameter({ |
| 472 | + resultSetting: resultSetting, |
| 473 | + turnWeightField: "TurnCost", |
| 474 | + weightFieldName: "length" //length,time |
| 475 | + }); |
| 476 | + var findClosetFacilitiesParameter = new FindClosestFacilitiesParameters({ |
| 477 | + //事件点,必设参数 |
| 478 | + event: new mapboxgl.Point(5000, -3700), |
| 479 | + //要查找的设施点数量。默认值为1 |
| 480 | + expectFacilityCount: 1, |
| 481 | + //设施点集合,必设 |
| 482 | + facilities: [new mapboxgl.Point(2500, -3500), new mapboxgl.Point(5500, -2500), new mapboxgl.Point(7000, -4000)], |
| 483 | + isAnalyzeById: false, |
| 484 | + parameter: analystParameter |
| 485 | + }); |
| 486 | + var service = new NetworkAnalystService(url, options); |
| 487 | + service.findClosestFacilities(findClosetFacilitiesParameter, (result) => { |
| 488 | + serviceResult = result; |
| 489 | + }); |
| 490 | + setTimeout(() => { |
| 491 | + try { |
| 492 | + expect(service).not.toBeNull(); |
| 493 | + expect(serviceResult).not.toBeNull(); |
| 494 | + expect(serviceResult.type).toEqual("processCompleted"); |
| 495 | + expect(serviceResult.result.succeed).toBe(true); |
| 496 | + var facilityPath = serviceResult.result.facilityPathList[0]; |
| 497 | + expect(facilityPath.edgeFeatures.type).toEqual("FeatureCollection"); |
| 498 | + var features = facilityPath.edgeFeatures.features; |
| 499 | + expect(features.length).toEqual(facilityPath.edgeIDs.length); |
| 500 | + for (var i = 0; i < features.length; i++) { |
| 501 | + expect(features[i].id).not.toBeNull(); |
| 502 | + expect(features[i].type).toEqual("Feature"); |
| 503 | + expect(features[i].geometry.type).toEqual("LineString"); |
| 504 | + expect(features[i].geometry.coordinates.length).toBeGreaterThan(0); |
| 505 | + for (var j = 0; j < features[i].geometry.coordinates.length; j++) { |
| 506 | + expect(features[i].geometry.coordinates[j].length).toEqual(2); |
| 507 | + } |
| 508 | + expect(features[i].properties).not.toBeNull(); |
| 509 | + } |
| 510 | + expect(facilityPath.edgeIDs.length).toBeGreaterThan(0); |
| 511 | + expect(facilityPath.facility.x).not.toBeNull(); |
| 512 | + expect(facilityPath.facility.y).not.toBeNull(); |
| 513 | + expect(facilityPath.facilityIndex).toEqual(1); |
| 514 | + expect(facilityPath.nodeFeatures.type).toEqual("FeatureCollection"); |
| 515 | + var node_features = facilityPath.nodeFeatures.features; |
| 516 | + expect(node_features.length).toBeGreaterThan(0); |
| 517 | + for (var i = 0; i < node_features.length; i++) { |
| 518 | + expect(node_features[i].id).not.toBeNull(); |
| 519 | + expect(node_features[i].type).toEqual("Feature"); |
| 520 | + expect(node_features[i].geometry.type).toEqual("Point"); |
| 521 | + expect(node_features[i].geometry.coordinates.length).toEqual(2); |
| 522 | + expect(node_features[i].properties).not.toBeNull(); |
| 523 | + } |
| 524 | + expect(facilityPath.nodeIDs.length).toEqual(node_features.length); |
| 525 | + expect(facilityPath.pathGuideItems.type).toEqual("FeatureCollection"); |
| 526 | + for (var i = 0; i < facilityPath.pathGuideItems.features.length; i++) { |
| 527 | + expect(facilityPath.pathGuideItems.features[i].type).toEqual("Feature"); |
| 528 | + expect(facilityPath.pathGuideItems.features[i].geometry.type).not.toBeNull(); |
| 529 | + expect(facilityPath.pathGuideItems.features[i].geometry.coordinates.length).toBeGreaterThan(0); |
| 530 | + if (facilityPath.pathGuideItems.features[i].geometry.coordinates.length > 2) { |
| 531 | + for (var j = 0; j < facilityPath.pathGuideItems.features[i].geometry.coordinates.length; j++) { |
| 532 | + expect(facilityPath.pathGuideItems.features[i].geometry.coordinates[j].length).toEqual(2); |
| 533 | + } |
| 534 | + } |
| 535 | + expect(facilityPath.pathGuideItems.features[i].properties).not.toBeNull(); |
| 536 | + } |
| 537 | + expect(facilityPath.route.type).toEqual("Feature"); |
| 538 | + expect(facilityPath.route.geometry.type).toEqual("MultiLineString"); |
| 539 | + expect(facilityPath.route.geometry.coordinates[0].length).toBeGreaterThan(0); |
| 540 | + for (var i = 0; i < facilityPath.route.geometry.coordinates[0].length; i++) { |
| 541 | + expect(facilityPath.route.geometry.coordinates[0][i].length).toEqual(3); |
| 542 | + } |
| 543 | + expect(facilityPath.stopWeights).not.toBeNull(); |
| 544 | + expect(facilityPath.weight).not.toBeNull(); |
| 545 | + done(); |
| 546 | + } catch (e) { |
| 547 | + console.log("'findClosestFacilities'案例失败" + e.name + ":" + e.message); |
| 548 | + expect(false).toBeTruthy(); |
| 549 | + done(); |
| 550 | + } |
| 551 | + }, 5000); |
| 552 | + }); |
| 553 | + // 上游/下游 关键设施查找资源服务 |
| 554 | + it('streamFacilityAnalyst', (done) => { |
| 555 | + var facilityAnalystStreamParameters = new FacilityAnalystStreamParameters({ |
| 556 | + edgeID: 84, |
| 557 | + //nodeID:85, |
| 558 | + isUncertainDirectionValid: true, |
| 559 | + sourceNodeIDs: [], |
| 560 | + // 分析类型,只能是 0 (上游关键设施查询) 或者是 1(下游关键设施查询) |
| 561 | + queryType: 1 |
| 562 | + }); |
| 563 | + var service = new NetworkAnalystService(url, options); |
| 564 | + service.streamFacilityAnalyst(facilityAnalystStreamParameters, (result) => { |
| 565 | + serviceResult = result; |
| 566 | + }); |
| 567 | + setTimeout(() => { |
| 568 | + try { |
| 569 | + expect(service).not.toBeNull(); |
| 570 | + expect(serviceResult).not.toBeNull(); |
| 571 | + expect(serviceResult.result).not.toBeNull(); |
| 572 | + expect(serviceResult.type).toEqual("processCompleted"); |
| 573 | + done(); |
| 574 | + } catch (e) { |
| 575 | + console.log("'streamFacilityAnalyst_test'案例失败" + e.name + ":" + e.message); |
| 576 | + expect(false).toBeTruthy(); |
| 577 | + done(); |
| 578 | + } |
| 579 | + }, 5000) |
| 580 | + |
| 581 | + }); |
456 | 582 | });
|
457 | 583 |
|
458 | 584 |
|
0 commit comments