Skip to content

Commit db3c402

Browse files
committed
【feature】新增支持对接iServer GEOCOMPOUND类型Geometry (ICL-1226) review by xiongjj
1 parent 29444ec commit db3c402

File tree

7 files changed

+359
-212
lines changed

7 files changed

+359
-212
lines changed

src/common/REST.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ var GeometryType = SuperMap.GeometryType = {
6969
/** RECTANGLE */
7070
RECTANGLE: "RECTANGLE",
7171
/** UNKNOWN */
72-
UNKNOWN: "UNKNOWN"
72+
UNKNOWN: "UNKNOWN",
73+
/** GEOCOMPOUND */
74+
GEOCOMPOUND:"GEOCOMPOUND"
7375
};
7476
export {
7577
GeometryType

src/common/format/GeoJSON.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ export class GeoJSON extends JSONFormat {
259259
if (!geometry.parts && geometry.points) {
260260
geometry.parts = [geometry.points.length];
261261
}
262-
var geo = new ServerGeometry(geometry).toGeometry() || geometry;
262+
var geo = geometry.hasOwnProperty('geometryType')
263+
? geometry
264+
: new ServerGeometry(geometry).toGeometry() || geometry;
263265
var geometryType = geo.geometryType || geo.type;
264266
var data;
265267
if (geometryType === "LinearRing") {
@@ -544,7 +546,7 @@ export class GeoJSON extends JSONFormat {
544546
}
545547

546548
function isGeometry(input) {
547-
return input.hasOwnProperty("parts") && input.hasOwnProperty("points");
549+
return (input.hasOwnProperty("parts") && input.hasOwnProperty("points")) || input.hasOwnProperty("geoParts");
548550
}
549551

550552
return geojson;

src/common/iServer/ServerGeometry.js

Lines changed: 83 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4-
import {SuperMap} from '../SuperMap';
5-
import {Point} from '../commontypes/geometry/Point';
6-
import {MultiPoint} from '../commontypes/geometry/MultiPoint';
7-
import {LinearRing} from '../commontypes/geometry/LinearRing';
8-
import {LineString} from '../commontypes/geometry/LineString';
9-
import {MultiLineString} from '../commontypes/geometry/MultiLineString';
10-
import {Polygon} from '../commontypes/geometry/Polygon';
11-
import {MultiPolygon} from '../commontypes/geometry/MultiPolygon';
12-
import {ServerStyle} from './ServerStyle';
13-
import {Route} from './Route';
14-
import {Util} from '../commontypes/Util';
15-
import {GeometryType} from '../REST';
4+
import { SuperMap } from '../SuperMap';
5+
import { Point } from '../commontypes/geometry/Point';
6+
import { MultiPoint } from '../commontypes/geometry/MultiPoint';
7+
import { LinearRing } from '../commontypes/geometry/LinearRing';
8+
import { LineString } from '../commontypes/geometry/LineString';
9+
import { MultiLineString } from '../commontypes/geometry/MultiLineString';
10+
import { Polygon } from '../commontypes/geometry/Polygon';
11+
import { MultiPolygon } from '../commontypes/geometry/MultiPolygon';
12+
import { Collection } from '../commontypes/geometry/Collection';
13+
import { ServerStyle } from './ServerStyle';
14+
import { Route } from './Route';
15+
import { Util } from '../commontypes/Util';
16+
import { GeometryType } from '../REST';
1617

1718
/**
1819
* @class SuperMap.ServerGeometry
19-
* @category iServer
20+
* @category iServer
2021
* @classdesc 服务端几何对象类。该类描述几何对象(矢量)的特征数据(坐标点对、几何对象的类型等)。基于服务端的空间分析、空间关系运算、查询等 GIS 服务功能使用服务端几何对象。
2122
* @param {Object} options - 参数。
2223
* @param {string} options.id - 服务端几何对象唯一标识符。
@@ -26,15 +27,13 @@ import {GeometryType} from '../REST';
2627
* @param {SuperMap.ServerStyle} [options.style] - 服务端几何对象的风格。
2728
*/
2829
export class ServerGeometry {
29-
3030
constructor(options) {
31-
3231
/**
3332
* @member {string} SuperMap.ServerGeometry.prototype.id
3433
* @description 服务端几何对象唯一标识符。
3534
*/
3635
this.id = 0;
37-
36+
3837
/**
3938
* @member {SuperMap.ServerStyle} [SuperMap.ServerGeometry.prototype.style]
4039
* @description 服务端几何对象的风格(ServerStyle)。
@@ -84,7 +83,7 @@ export class ServerGeometry {
8483
Util.extend(this, options);
8584
}
8685

87-
this.CLASS_NAME = "SuperMap.ServerGeometry";
86+
this.CLASS_NAME = 'SuperMap.ServerGeometry';
8887
}
8988

9089
/**
@@ -125,6 +124,8 @@ export class ServerGeometry {
125124
return me.toGeoLineEPS();
126125
case GeometryType.REGIONEPS:
127126
return me.toGeoRegionEPS();
127+
case GeometryType.GEOCOMPOUND:
128+
return me.transformGeoCompound();
128129
}
129130
}
130131

@@ -264,14 +265,9 @@ export class ServerGeometry {
264265
var pointList = [];
265266
if (len == 1) {
266267
for (let i = 0; i < geoPoints.length; i++) {
267-
pointList.push(
268-
new Point(geoPoints[i].x, geoPoints[i].y))
268+
pointList.push(new Point(geoPoints[i].x, geoPoints[i].y));
269269
}
270-
polygonArray.push(
271-
new Polygon(
272-
[new LinearRing(pointList)]
273-
)
274-
);
270+
polygonArray.push(new Polygon([new LinearRing(pointList)]));
275271
return new MultiPolygon(polygonArray);
276272
}
277273
//处理复杂面
@@ -283,17 +279,13 @@ export class ServerGeometry {
283279
var CCWIdent = [];
284280
for (let i = 0, pointIndex = 0; i < len; i++) {
285281
for (let j = 0; j < geoParts[i]; j++) {
286-
pointList.push(
287-
new Point(geoPoints[pointIndex + j].x, geoPoints[pointIndex + j].y)
288-
);
282+
pointList.push(new Point(geoPoints[pointIndex + j].x, geoPoints[pointIndex + j].y));
289283
}
290284
pointIndex += geoParts[i];
291-
var polygon = new Polygon(
292-
[new LinearRing(pointList)]
293-
);
285+
var polygon = new Polygon([new LinearRing(pointList)]);
294286
pointList = [];
295287
polygonArrayTemp.push(polygon);
296-
if (geoTopo.length === 0){
288+
if (geoTopo.length === 0) {
297289
polygonBounds.push(polygon.getBounds());
298290
}
299291
CCWIdent.push(1);
@@ -324,7 +316,9 @@ export class ServerGeometry {
324316
if (CCWIdent[i] > 0) {
325317
polygonArray.push(polygonArrayTemp[i]);
326318
} else {
327-
polygonArray[targetArray[i]].components = polygonArray[targetArray[i]].components.concat(polygonArrayTemp[i].components);
319+
polygonArray[targetArray[i]].components = polygonArray[targetArray[i]].components.concat(
320+
polygonArrayTemp[i].components
321+
);
328322
//占位
329323
polygonArray.push('');
330324
}
@@ -338,22 +332,22 @@ export class ServerGeometry {
338332
CCWArray = CCWArray.concat(polygonArrayTemp[i].components);
339333
} else {
340334
if (CCWArray.length > 0 && polygonArray.length > 0) {
341-
polygonArray[polygonArray.length - 1].components = polygonArray[polygonArray.length - 1].components.concat(CCWArray);
335+
polygonArray[polygonArray.length - 1].components = polygonArray[
336+
polygonArray.length - 1
337+
].components.concat(CCWArray);
342338
CCWArray = [];
343339
}
344-
polygonArray.push(
345-
polygonArrayTemp[i]
346-
);
340+
polygonArray.push(polygonArrayTemp[i]);
347341
}
348342
if (i == len - 1) {
349343
var polyLength = polygonArray.length;
350344
if (polyLength) {
351-
polygonArray[polyLength - 1].components = polygonArray[polyLength - 1].components.concat(CCWArray);
345+
polygonArray[polyLength - 1].components = polygonArray[polyLength - 1].components.concat(
346+
CCWArray
347+
);
352348
} else {
353349
for (let k = 0, length = CCWArray.length; k < length; k++) {
354-
polygonArray.push(
355-
new Polygon(CCWArray)
356-
);
350+
polygonArray.push(new Polygon(CCWArray));
357351
}
358352
}
359353
}
@@ -382,16 +376,11 @@ export class ServerGeometry {
382376
var lineEPS;
383377
if (len == 1) {
384378
for (var i = 0; i < geoPoints.length; i++) {
385-
pointList.push(
386-
new Point(geoPoints[i].x, geoPoints[i].y))
379+
pointList.push(new Point(geoPoints[i].x, geoPoints[i].y));
387380
}
388381

389382
lineEPS = LineString.createLineEPS(pointList);
390-
polygonArray.push(
391-
new Polygon(
392-
[new LinearRing(lineEPS)]
393-
)
394-
);
383+
polygonArray.push(new Polygon([new LinearRing(lineEPS)]));
395384
return new MultiPolygon(polygonArray);
396385
}
397386
//处理复杂面
@@ -403,19 +392,15 @@ export class ServerGeometry {
403392
var CCWIdent = [];
404393
for (let i = 0, pointIndex = 0; i < len; i++) {
405394
for (let j = 0; j < geoParts[i]; j++) {
406-
pointList.push(
407-
new Point(geoPoints[pointIndex + j].x, geoPoints[pointIndex + j].y)
408-
);
395+
pointList.push(new Point(geoPoints[pointIndex + j].x, geoPoints[pointIndex + j].y));
409396
}
410397
pointIndex += geoParts[i];
411398

412399
lineEPS = LineString.createLineEPS(pointList);
413-
var polygon = new Polygon(
414-
[new LinearRing(lineEPS)]
415-
);
400+
var polygon = new Polygon([new LinearRing(lineEPS)]);
416401
pointList = [];
417402
polygonArrayTemp.push(polygon);
418-
if (geoTopo.length === 0){
403+
if (geoTopo.length === 0) {
419404
polygonBounds.push(polygon.getBounds());
420405
}
421406
CCWIdent.push(1);
@@ -446,7 +431,9 @@ export class ServerGeometry {
446431
if (CCWIdent[i] > 0) {
447432
polygonArray.push(polygonArrayTemp[i]);
448433
} else {
449-
polygonArray[targetArray[i]].components = polygonArray[targetArray[i]].components.concat(polygonArrayTemp[i].components);
434+
polygonArray[targetArray[i]].components = polygonArray[targetArray[i]].components.concat(
435+
polygonArrayTemp[i].components
436+
);
450437
//占位
451438
polygonArray.push('');
452439
}
@@ -459,29 +446,43 @@ export class ServerGeometry {
459446
CCWArray = CCWArray.concat(polygonArrayTemp[i].components);
460447
} else {
461448
if (CCWArray.length > 0 && polygonArray.length > 0) {
462-
polygonArray[polygonArray.length - 1].components = polygonArray[polygonArray.length - 1].components.concat(CCWArray);
449+
polygonArray[polygonArray.length - 1].components = polygonArray[
450+
polygonArray.length - 1
451+
].components.concat(CCWArray);
463452
CCWArray = [];
464453
}
465-
polygonArray.push(
466-
polygonArrayTemp[i]
467-
);
454+
polygonArray.push(polygonArrayTemp[i]);
468455
}
469456
if (i == len - 1) {
470457
var polyLength = polygonArray.length;
471458
if (polyLength) {
472-
polygonArray[polyLength - 1].components = polygonArray[polyLength - 1].components.concat(CCWArray);
459+
polygonArray[polyLength - 1].components = polygonArray[polyLength - 1].components.concat(
460+
CCWArray
461+
);
473462
} else {
474463
for (let k = 0, length = CCWArray.length; k < length; k++) {
475-
polygonArray.push(
476-
new Polygon(CCWArray)
477-
);
464+
polygonArray.push(new Polygon(CCWArray));
478465
}
479466
}
480467
}
481468
}
482469
}
483470
return new MultiPolygon(polygonArray);
484471
}
472+
transformGeoCompound() {
473+
const me = this,
474+
geoParts = me.geoParts || [],
475+
len = geoParts.length;
476+
if (len <= 0) {
477+
return null;
478+
}
479+
const geometryList = [];
480+
for (let index = 0; index < len; index++) {
481+
const geometry = geoParts[index];
482+
geometryList.push(new ServerGeometry(geometry).toGeometry());
483+
}
484+
return new Collection(geometryList);
485+
}
485486

486487
/**
487488
* @function SuperMap.ServerGeometry.prototype.fromJson
@@ -505,7 +506,6 @@ export class ServerGeometry {
505506
minM: jsonObject.minM,
506507
type: jsonObject.type
507508
});
508-
509509
}
510510

511511
/**
@@ -524,13 +524,17 @@ export class ServerGeometry {
524524
type = null,
525525
icomponents = geometry.components,
526526
className = geometry.CLASS_NAME,
527-
prjCoordSys = {"epsgCode": geometry.SRID};
527+
prjCoordSys = { epsgCode: geometry.SRID };
528528

529529
if (!isNaN(geometry.id)) {
530530
id = geometry.id;
531531
}
532532
//坑爹的改法,没法,为了支持态势标绘,有时间就得全改
533-
if (className != "SuperMap.Geometry.LinearRing" && className != "SuperMap.Geometry.LineString" && (geometry instanceof MultiPoint || geometry instanceof MultiLineString)) {
533+
if (
534+
className != 'SuperMap.Geometry.LinearRing' &&
535+
className != 'SuperMap.Geometry.LineString' &&
536+
(geometry instanceof MultiPoint || geometry instanceof MultiLineString)
537+
) {
534538
let ilen = icomponents.length;
535539
for (let i = 0; i < ilen; i++) {
536540
let partPointsCount = icomponents[i].getVertices().length;
@@ -540,7 +544,7 @@ export class ServerGeometry {
540544
}
541545
}
542546
//这里className不是多点就全部是算线
543-
type = (className == "SuperMap.Geometry.MultiPoint") ? GeometryType.POINT : GeometryType.LINE;
547+
type = className == 'SuperMap.Geometry.MultiPoint' ? GeometryType.POINT : GeometryType.LINE;
544548
} else if (geometry instanceof MultiPolygon) {
545549
let ilen = icomponents.length;
546550
for (let i = 0; i < ilen; i++) {
@@ -551,9 +555,16 @@ export class ServerGeometry {
551555
let partPointsCount = linearRingOfPolygon[j].getVertices().length + 1;
552556
parts.push(partPointsCount);
553557
for (let k = 0; k < partPointsCount - 1; k++) {
554-
points.push(new Point(linearRingOfPolygon[j].getVertices()[k].x, linearRingOfPolygon[j].getVertices()[k].y));
558+
points.push(
559+
new Point(
560+
linearRingOfPolygon[j].getVertices()[k].x,
561+
linearRingOfPolygon[j].getVertices()[k].y
562+
)
563+
);
555564
}
556-
points.push(new Point(linearRingOfPolygon[j].getVertices()[0].x, linearRingOfPolygon[j].getVertices()[0].y));
565+
points.push(
566+
new Point(linearRingOfPolygon[j].getVertices()[0].x, linearRingOfPolygon[j].getVertices()[0].y)
567+
);
557568
}
558569
}
559570
type = GeometryType.REGION;
@@ -578,7 +589,7 @@ export class ServerGeometry {
578589
geometryVerticesCount++;
579590
}
580591
parts.push(geometryVerticesCount);
581-
type = (geometry instanceof Point) ? GeometryType.POINT : GeometryType.LINE;
592+
type = geometry instanceof Point ? GeometryType.POINT : GeometryType.LINE;
582593
}
583594

584595
return new ServerGeometry({
@@ -610,7 +621,7 @@ export class ServerGeometry {
610621
return s * 0.5;
611622
}
612623

613-
static bubbleSort(areaArray, pointList, geoTopo,polygonBounds) {
624+
static bubbleSort(areaArray, pointList, geoTopo, polygonBounds) {
614625
for (var i = 0; i < areaArray.length; i++) {
615626
for (var j = 0; j < areaArray.length; j++) {
616627
if (areaArray[i] > areaArray[j]) {
@@ -634,7 +645,6 @@ export class ServerGeometry {
634645
}
635646
}
636647
}
637-
638648
}
639649

640-
SuperMap.ServerGeometry = ServerGeometry;
650+
SuperMap.ServerGeometry = ServerGeometry;

src/openlayers/mapping/Tianditu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import WMTSTileGrid from 'ol/tilegrid/WMTS';
1111
* @classdesc 天地图图层源。
1212
* @param {Object} opt_options - 参数。
1313
* @param {string} [opt_options.url='http://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?'] - 服务地址。
14-
* @param {string} options.key - 天地图服务密钥。详见{@link http://lbs.tianditu.gov.cn/server/MapService.html}
14+
* @param {string} opt_options.key - 天地图服务密钥。详见{@link http://lbs.tianditu.gov.cn/server/MapService.html}
1515
* @param {string} [opt_options.layerType='vec'] - 图层类型。(vec:矢量图层,img:影像图层,ter:地形图层)
1616
* @param {string} [opt_options.attributions] - 版权描述信息。
1717
* @param {number} [opt_options.cacheSize = 2048] - 缓冲大小。

src/openlayers/mapping/WebMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ export class WebMap extends Observable {
14781478
dataSource = layer.dataSource,
14791479
isSampleData = dataSource && dataSource.type === "SAMPLE_DATA" && !!dataSource.name; //SAMPLE_DATA是本地示例数据
14801480
if(layer.layerType === "MAPBOXSTYLE"){
1481-
that.addMVTMapLayer(mapInfo, layer, layerIndex).then(result => {
1481+
that.addMVTMapLayer(mapInfo, layer, layerIndex).then(() => {
14821482
that.layerAdded++;
14831483
that.sendMapToUser(len);
14841484
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy