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
2 changes: 1 addition & 1 deletion src/geometry/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class Circle extends CenterMixin(Polygon) {
return {
'feature': feature,
'subType': 'Circle',
'coordinates': [center.x, center.y],
'coordinates': center.toArray(),
'radius': this.getRadius()
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/Ellipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class Ellipse extends CenterMixin(Polygon) {
return {
'feature': feature,
'subType': 'Ellipse',
'coordinates': [center.x, center.y],
'coordinates': center.toArray(),
'width': this.getWidth(),
'height': this.getHeight()
};
Expand Down
30 changes: 30 additions & 0 deletions src/geometry/Geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,35 @@ export class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
return this;
}

//@internal
_getEditCenter() {
const center = this.getCenter().copy();
center.z = 0;

const altitude = this.getAltitude();
if (isNumber(altitude)) {
center.z = altitude;
return center;
}
let total = 0, count = 0;
//计算图形海拔的平均值,确定图形中心点的海拔坐标
const checkArray = (altitudeArray) => {
for (let i = 0, len = altitudeArray.length; i < len; i++) {
if (Array.isArray(altitudeArray[i])) {
checkArray(altitudeArray[i]);
} else {
count++;
total += altitudeArray[i];
}
}
}
if (Array.isArray(altitude)) {
checkArray(altitude);
center.z = total / count;
}
return center;
}

}

Geometry.mergeOptions(options);
Expand Down Expand Up @@ -2064,3 +2093,4 @@ function getSegmentAngle(cx: number, cy: number, x: number, y: number): number {

export default Geometry;


2 changes: 1 addition & 1 deletion src/geometry/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class Rectangle extends Polygon {
return {
'feature': feature,
'subType': 'Rectangle',
'coordinates': [nw.x, nw.y],
'coordinates': nw.toArray(),
'width': this.getWidth(),
'height': this.getHeight()
};
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/Sector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class Sector extends Circle {
return {
'feature': feature,
'subType': 'Sector',
'coordinates': [center.x, center.y],
'coordinates': center.toArray(),
'radius': this.getRadius(),
'startAngle': this.getStartAngle(),
'endAngle': this.getEndAngle()
Expand Down
Loading