Skip to content

Commit 250c89f

Browse files
committed
adapt glrender
1 parent b3ffe93 commit 250c89f

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
lines changed

src/geometry/Ellipse.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,18 @@ class Ellipse extends CenterMixin(Polygon) {
8888
this.onShapeChanged();
8989
return this;
9090
}
91-
9291
/**
9392
* Gets the shell of the ellipse as a polygon, number of the shell points is decided by [options.numberOfShellPoints]{@link Circle#options}
9493
* @return {Coordinate[]} - shell coordinates
9594
*/
9695
getShell() {
96+
if (this.isRotated()) {
97+
return this.getRotatedShell();
98+
}
99+
return this._getShell();
100+
}
101+
102+
_getShell() {
97103
const measurer = this._getMeasurer(),
98104
center = this.getCoordinates(),
99105
numberOfPoints = this.options['numberOfShellPoints'],
@@ -153,6 +159,9 @@ class Ellipse extends CenterMixin(Polygon) {
153159
}
154160

155161
_computePrjExtent() {
162+
if (this.isRotated()) {
163+
return this._computeRotatedPrjExtent();
164+
}
156165
return Circle.prototype._computePrjExtent.apply(this, arguments);
157166
}
158167

src/geometry/Geometry.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,11 +1132,7 @@ class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
11321132
const p = this._getProjection();
11331133
this._verifyProjection();
11341134
if (!this._extent && p) {
1135-
if (this.isRotated() && this._computePrjExtentForRotated) {
1136-
this._extent = this._computePrjExtentForRotated(p);
1137-
} else {
1138-
this._extent = this._computePrjExtent(p);
1139-
}
1135+
this._extent = this._computePrjExtent(p);
11401136
}
11411137
return this._extent;
11421138
}

src/geometry/Polygon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class Polygon extends Path {
223223
//r.g. for Rectangle
224224
this._verifyProjection();
225225
if (this._getProjection() && !this._prjShell) {
226-
this._prjShell = this._projectCoords(this.getShell());
226+
this._prjShell = this._projectCoords(this._getShell ? this._getShell() : this.getShell());
227227
}
228228
return this._prjShell;
229229
}

src/geometry/Rectangle.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ class Rectangle extends Polygon {
107107
* @return {Coordinate[]} - shell coordinates
108108
*/
109109
getShell() {
110+
if (this.isRotated()) {
111+
return this.getRotatedShell();
112+
}
113+
return this._getShell();
114+
}
115+
116+
_getShell() {
110117
const measurer = this._getMeasurer();
111118
const nw = this._coordinates;
112119
const map = this.getMap();
@@ -223,6 +230,9 @@ class Rectangle extends Polygon {
223230
}
224231

225232
_computePrjExtent(projection) {
233+
if (this.isRotated()) {
234+
return this._computeRotatedPrjExtent();
235+
}
226236
const se = this._getSouthEast(projection);
227237
if (!se) {
228238
return null;

src/geometry/Sector.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ class Sector extends Circle {
8888
* @return {Coordinate[]} - shell coordinates
8989
*/
9090
getShell() {
91+
if (this.isRotated()) {
92+
return this.getRotatedShell();
93+
}
94+
return this._getShell();
95+
}
96+
97+
_getShell() {
9198
const measurer = this._getMeasurer(),
9299
center = this.getCoordinates(),
93100
numberOfPoints = this.options['numberOfShellPoints'] - 2,
@@ -117,6 +124,13 @@ class Sector extends Circle {
117124
return this._rotatePrjCoordinates(shell);
118125
}
119126

127+
_computePrjExtent() {
128+
if (this.isRotated()) {
129+
return this._computeRotatedPrjExtent();
130+
}
131+
return super._computePrjExtent();
132+
}
133+
120134
_containsPoint(point, tolerance) {
121135
const map = this.getMap();
122136
if (map.isTransforming()) {

src/renderer/geometry/VectorRenderer.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Geometry.include({
5050
}
5151
});
5252

53-
function _computePrjExtentForRotated() {
53+
function _computeRotatedPrjExtent() {
5454
const coord = this._getPrjShell();
5555
const bbox = getDefaultBBOX();
5656
//cal all points center
@@ -59,13 +59,25 @@ function _computePrjExtentForRotated() {
5959
return new Extent(minx, miny, maxx, maxy);
6060
}
6161

62+
function getRotatedShell() {
63+
const prjs = this._getPrjShell();
64+
if (!prjs || !Array.isArray(prjs)) {
65+
return [];
66+
}
67+
const projection = this._getProjection();
68+
return prjs.map(prj => {
69+
return projection.unproject(prj);
70+
});
71+
}
72+
6273
const el = {
6374
_redrawWhenPitch: () => true,
6475

6576
_redrawWhenRotate: function () {
6677
return (this instanceof Ellipse) || (this instanceof Sector);
6778
},
68-
_computePrjExtentForRotated,
79+
_computeRotatedPrjExtent,
80+
getRotatedShell,
6981

7082
_paintAsPath: function () {
7183
//why? when rotate need draw by path
@@ -120,7 +132,8 @@ Rectangle.include({
120132
},
121133

122134
_paintOn: Canvas.polygon,
123-
_computePrjExtentForRotated
135+
_computeRotatedPrjExtent,
136+
getRotatedShell
124137
});
125138
//----------------------------------------------------
126139
Sector.include(el, {

0 commit comments

Comments
 (0)