Skip to content

Commit 221545e

Browse files
author
Peter Thorin
authored
Merge pull request #162 from brentfraser/array-bounds
allow array in bounds definition
2 parents 64ad0e8 + 0f60e44 commit 221545e

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/proj4leaflet.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@
8181
code = proj.srsCode;
8282
options = b || {};
8383

84-
this.projection = new L.Proj.Projection(proj, options.bounds);
84+
this.projection = new L.Proj.Projection(proj, L.bounds(options.bounds));
8585
} else {
8686
code = a;
8787
def = b;
8888
options = c || {};
89-
this.projection = new L.Proj.Projection(code, def, options.bounds);
89+
this.projection = new L.Proj.Projection(code, def, L.bounds(options.bounds));
9090
}
9191

9292
L.Util.setOptions(this, options);
@@ -110,7 +110,7 @@
110110
}
111111
}
112112

113-
this.infinite = !this.options.bounds;
113+
this.infinite = !L.bounds(this.options.bounds);
114114

115115
},
116116

test/specs.js

+22
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,29 @@ describe('L.Proj.CRS', function() {
138138
worldSize *= 2;
139139
}
140140
});
141+
142+
it('creates bounds from array', function() {
143+
var resolutions = [2, 1, 0.5],
144+
crs = new L.Proj.CRS(
145+
'EPSG:2400',
146+
'+lon_0=15.808277777799999 +lat_0=0.0 +k=1.0 +x_0=1500000.0 ' +
147+
'+y_0=0.0 +proj=tmerc +ellps=bessel +units=m ' +
148+
'+towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +no_defs', {
149+
bounds: [[0, 0], [4000, 5000]],
150+
resolutions: resolutions,
151+
origin: [0, 5000]
152+
}),
153+
worldSize = 256,
154+
i,
155+
bounds;
141156

157+
for (i = 0; i < resolutions.length; i++) {
158+
bounds = crs.getProjectedBounds(i);
159+
expect(bounds.max.x).to.be(4000 / resolutions[i]);
160+
expect(bounds.max.y).to.be(5000 / resolutions[i]);
161+
worldSize *= 2;
162+
}
163+
});
142164
it('converts zoom to scale and vice versa and returns the same values', function () {
143165
var crs = new L.Proj.CRS('EPSG:3006',
144166
'+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',

0 commit comments

Comments
 (0)