@@ -17,93 +17,93 @@ describe('mapboxgl_FeatureService_getFeaturesByBounds', () => {
17
17
serviceResult = null ;
18
18
} ) ;
19
19
//数据集Bounds查询服务
20
- // it('getFeaturesByBounds', done => {
21
- // var sw = new mapboxgl.LngLat(-20, -20);
22
- // var ne = new mapboxgl.LngLat(20, 20);
23
- // var lngLatBounds = new mapboxgl.LngLatBounds(sw, ne);
24
- // var boundsParam = new GetFeaturesByBoundsParameters({
25
- // datasetNames: ['World:Capitals'],
26
- // bounds: lngLatBounds,
27
- // fromIndex: 1,
28
- // toIndex: 3
29
- // });
30
- // var service = new FeatureService(url);
31
- // spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
32
- // expect(method).toBe('POST');
33
- // expect(testUrl).toBe(url + '/featureResults?returnContent=true&fromIndex=1&toIndex=3');
34
- // var paramsObj = JSON.parse(params.replace(/'/g, '"'));
35
- // expect(paramsObj.datasetNames[0]).toBe('World:Capitals');
36
- // expect(paramsObj.getFeatureMode).toBe('BOUNDS');
37
- // expect(paramsObj.spatialQueryMode).toBe('CONTAIN');
38
- // expect(options).not.toBeNull();
39
- // return Promise.resolve(new Response(JSON.stringify(getFeaturesResultJson)));
40
- // });
41
- // service.getFeaturesByBounds(boundsParam, testResult => {
42
- // serviceResult = testResult;
43
- // expect(service).not.toBeNull();
44
- // expect(serviceResult.type).toBe('processCompleted');
45
- // expect(serviceResult.object.format).toBe('GEOJSON');
46
- // var result = serviceResult.result;
47
- // expect(result.succeed).toBe(true);
48
- // expect(result.featureCount).toEqual(1);
49
- // expect(result.totalCount).toEqual(1);
50
- // expect(result.features.type).toEqual('FeatureCollection');
51
- // var features = result.features.features;
52
- // expect(features.length).toEqual(1);
53
- // expect(features[0].id).toEqual(127);
54
- // for (var i = 0; i < features.length; i++) {
55
- // expect(features[i].type).toEqual('Feature');
56
- // expect(features[i].properties).not.toBeNull();
57
- // expect(features[i].geometry.type).toEqual('MultiPolygon');
58
- // expect(features[i].geometry.coordinates.length).toEqual(2);
59
- // }
60
- // boundsParam.destroy();
61
- // done();
62
- // });
63
- // });
64
- // it('GetFeaturesByBoundsParameters:targetEpsgCode', done => {
65
- // var sw = new mapboxgl.LngLat(-20, -20);
66
- // var ne = new mapboxgl.LngLat(20, 20);
67
- // var lngLatBounds = new mapboxgl.LngLatBounds(sw, ne);
68
- // var boundsParam = new GetFeaturesByBoundsParameters({
69
- // datasetNames: ['World:Capitals'],
70
- // bounds: lngLatBounds,
71
- // targetEpsgCode: 4326
72
- // });
73
- // var service = new FeatureService(url);
74
- // spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
75
- // var paramsObj = JSON.parse(params.replace(/'/g, '"'));
76
- // expect(paramsObj.targetEpsgCode).toEqual(4326);
77
- // return Promise.resolve(new Response(JSON.stringify(getFeaturesResultJson)));
78
- // });
79
- // service.getFeaturesByBounds(boundsParam, result => {
80
- // serviceResult = result;
81
- // boundsParam.destroy();
82
- // done();
83
- // });
84
- // });
85
- // it('GetFeaturesByBoundsParameters:targetPrj', done => {
86
- // var sw = new mapboxgl.LngLat(-20, -20);
87
- // var ne = new mapboxgl.LngLat(20, 20);
88
- // var lngLatBounds = new mapboxgl.LngLatBounds(sw, ne);
89
- // var boundsParam = new GetFeaturesByBoundsParameters({
90
- // datasetNames: ['World:Capitals'],
91
- // bounds: lngLatBounds,
92
- // targetPrj: { epsgCode: 4326 }
93
- // });
94
- // var service = new FeatureService(url);
20
+ it ( 'getFeaturesByBounds' , done => {
21
+ var sw = new mapboxgl . LngLat ( - 20 , - 20 ) ;
22
+ var ne = new mapboxgl . LngLat ( 20 , 20 ) ;
23
+ var lngLatBounds = new mapboxgl . LngLatBounds ( sw , ne ) ;
24
+ var boundsParam = new GetFeaturesByBoundsParameters ( {
25
+ datasetNames : [ 'World:Capitals' ] ,
26
+ bounds : lngLatBounds ,
27
+ fromIndex : 1 ,
28
+ toIndex : 3
29
+ } ) ;
30
+ var service = new FeatureService ( url ) ;
31
+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( ( method , testUrl , params , options ) => {
32
+ expect ( method ) . toBe ( 'POST' ) ;
33
+ expect ( testUrl ) . toBe ( url + '/featureResults?returnContent=true&fromIndex=1&toIndex=3' ) ;
34
+ var paramsObj = JSON . parse ( params . replace ( / ' / g, '"' ) ) ;
35
+ expect ( paramsObj . datasetNames [ 0 ] ) . toBe ( 'World:Capitals' ) ;
36
+ expect ( paramsObj . getFeatureMode ) . toBe ( 'BOUNDS' ) ;
37
+ expect ( paramsObj . spatialQueryMode ) . toBe ( 'CONTAIN' ) ;
38
+ expect ( options ) . not . toBeNull ( ) ;
39
+ return Promise . resolve ( new Response ( JSON . stringify ( getFeaturesResultJson ) ) ) ;
40
+ } ) ;
41
+ service . getFeaturesByBounds ( boundsParam , testResult => {
42
+ serviceResult = testResult ;
43
+ expect ( service ) . not . toBeNull ( ) ;
44
+ expect ( serviceResult . type ) . toBe ( 'processCompleted' ) ;
45
+ expect ( serviceResult . object . format ) . toBe ( 'GEOJSON' ) ;
46
+ var result = serviceResult . result ;
47
+ expect ( result . succeed ) . toBe ( true ) ;
48
+ expect ( result . featureCount ) . toEqual ( 1 ) ;
49
+ expect ( result . totalCount ) . toEqual ( 1 ) ;
50
+ expect ( result . features . type ) . toEqual ( 'FeatureCollection' ) ;
51
+ var features = result . features . features ;
52
+ expect ( features . length ) . toEqual ( 1 ) ;
53
+ expect ( features [ 0 ] . id ) . toEqual ( 127 ) ;
54
+ for ( var i = 0 ; i < features . length ; i ++ ) {
55
+ expect ( features [ i ] . type ) . toEqual ( 'Feature' ) ;
56
+ expect ( features [ i ] . properties ) . not . toBeNull ( ) ;
57
+ expect ( features [ i ] . geometry . type ) . toEqual ( 'MultiPolygon' ) ;
58
+ expect ( features [ i ] . geometry . coordinates . length ) . toEqual ( 2 ) ;
59
+ }
60
+ boundsParam . destroy ( ) ;
61
+ done ( ) ;
62
+ } ) ;
63
+ } ) ;
64
+ it ( 'GetFeaturesByBoundsParameters:targetEpsgCode' , done => {
65
+ var sw = new mapboxgl . LngLat ( - 20 , - 20 ) ;
66
+ var ne = new mapboxgl . LngLat ( 20 , 20 ) ;
67
+ var lngLatBounds = new mapboxgl . LngLatBounds ( sw , ne ) ;
68
+ var boundsParam = new GetFeaturesByBoundsParameters ( {
69
+ datasetNames : [ 'World:Capitals' ] ,
70
+ bounds : lngLatBounds ,
71
+ targetEpsgCode : 4326
72
+ } ) ;
73
+ var service = new FeatureService ( url ) ;
74
+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( ( method , testUrl , params , options ) => {
75
+ var paramsObj = JSON . parse ( params . replace ( / ' / g, '"' ) ) ;
76
+ expect ( paramsObj . targetEpsgCode ) . toEqual ( 4326 ) ;
77
+ return Promise . resolve ( new Response ( JSON . stringify ( getFeaturesResultJson ) ) ) ;
78
+ } ) ;
79
+ service . getFeaturesByBounds ( boundsParam , result => {
80
+ serviceResult = result ;
81
+ boundsParam . destroy ( ) ;
82
+ done ( ) ;
83
+ } ) ;
84
+ } ) ;
85
+ it ( 'GetFeaturesByBoundsParameters:targetPrj' , done => {
86
+ var sw = new mapboxgl . LngLat ( - 20 , - 20 ) ;
87
+ var ne = new mapboxgl . LngLat ( 20 , 20 ) ;
88
+ var lngLatBounds = new mapboxgl . LngLatBounds ( sw , ne ) ;
89
+ var boundsParam = new GetFeaturesByBoundsParameters ( {
90
+ datasetNames : [ 'World:Capitals' ] ,
91
+ bounds : lngLatBounds ,
92
+ targetPrj : { epsgCode : 4326 }
93
+ } ) ;
94
+ var service = new FeatureService ( url ) ;
95
95
96
- // spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
97
- // var paramsObj = JSON.parse(params.replace(/'/g, '"'));
98
- // expect(paramsObj.targetPrj.epsgCode).toEqual(4326);
99
- // return Promise.resolve(new Response(JSON.stringify(getFeaturesResultJson)));
100
- // });
101
- // service.getFeaturesByBounds(boundsParam, result => {
102
- // serviceResult = result;
103
- // boundsParam.destroy();
104
- // done();
105
- // });
106
- // });
96
+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( ( method , testUrl , params , options ) => {
97
+ var paramsObj = JSON . parse ( params . replace ( / ' / g, '"' ) ) ;
98
+ expect ( paramsObj . targetPrj . epsgCode ) . toEqual ( 4326 ) ;
99
+ return Promise . resolve ( new Response ( JSON . stringify ( getFeaturesResultJson ) ) ) ;
100
+ } ) ;
101
+ service . getFeaturesByBounds ( boundsParam , result => {
102
+ serviceResult = result ;
103
+ boundsParam . destroy ( ) ;
104
+ done ( ) ;
105
+ } ) ;
106
+ } ) ;
107
107
it ( 'MetricsAggParameter' , done => {
108
108
var sw = new mapboxgl . LngLat ( - 20 , - 20 ) ;
109
109
var ne = new mapboxgl . LngLat ( 20 , 20 ) ;
0 commit comments