Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions src/geometry/Geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,34 @@ export class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
return this;
}

getEditCenter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果这个方法只在editor或drag里用到,可以考虑方法名增加_,并加上 @internal 标签不公开出去

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 +2092,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