MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / wrapDateLine

Method wrapDateLine

src/common/commontypes/LonLat.js:126–143  ·  view source on GitHub ↗

* @function LonLat.prototype.wrapDateLine * @description 通过传入的范围对象对坐标对象转换到该范围内。 * 如果经度小于给定范围最小精度,则在原经度基础上加上范围宽度,直到精度在范围内为止,如果经度大于给定范围则在原经度基础上减去范围宽度。 * 即指将不在经度范围内的坐标转换到范围以内(只会转换 lon,不会转换 lat,主要用于转移到日界线以内)。 * @example * var lonLat1 = new LonLat(420,50); * var lonLat2 = lo

(maxExtent)

Source from the content-addressed store, hash-verified

124 * @returns {LonLat} 将坐标转换到范围对象以内,并返回新的坐标。
125 */
126 wrapDateLine(maxExtent) {
127
128 var newLonLat = this.clone();
129
130 if (maxExtent) {
131 //shift right?
132 while (newLonLat.lon < maxExtent.left) {
133 newLonLat.lon += maxExtent.getWidth();
134 }
135
136 //shift left?
137 while (newLonLat.lon > maxExtent.right) {
138 newLonLat.lon -= maxExtent.getWidth();
139 }
140 }
141
142 return newLonLat;
143 }
144
145 /**
146 *

Callers 1

LonLatSpec.jsFile · 0.45

Calls 2

cloneMethod · 0.95
getWidthMethod · 0.45

Tested by

no test coverage detected