MCPcopy Index your code
hub / github.com/Maps4HTML/MapML.js / defineCustomProjection

Method defineCustomProjection

src/web-map.js:1279–1466  ·  view source on GitHub ↗
(jsonTemplate)

Source from the content-addressed store, hash-verified

1277 }
1278
1279 defineCustomProjection(jsonTemplate) {
1280 let t = JSON.parse(jsonTemplate);
1281 if (
1282 t === undefined ||
1283 !t.proj4string ||
1284 !t.projection ||
1285 !t.resolutions ||
1286 !t.origin ||
1287 !t.bounds
1288 )
1289 throw new Error('Incomplete TCRS Definition');
1290 if (t.projection.indexOf(':') >= 0)
1291 throw new Error('":" is not permitted in projection name');
1292 if (M[t.projection.toUpperCase()]) return t.projection.toUpperCase();
1293 let tileSize = [256, 512, 1024, 2048, 4096].includes(t.tilesize)
1294 ? t.tilesize
1295 : M.TILE_SIZE;
1296
1297 M[t.projection] = new Proj.CRS(t.projection, t.proj4string, {
1298 origin: t.origin,
1299 resolutions: t.resolutions,
1300 bounds: bounds(t.bounds),
1301 crs: {
1302 tcrs: {
1303 horizontal: {
1304 name: 'x',
1305 min: 0,
1306 max: (zoom) =>
1307 Math.round(
1308 M[t.projection].options.bounds.getSize().x /
1309 M[t.projection].options.resolutions[zoom]
1310 )
1311 },
1312 vertical: {
1313 name: 'y',
1314 min: 0,
1315 max: (zoom) =>
1316 Math.round(
1317 M[t.projection].options.bounds.getSize().y /
1318 M[t.projection].options.resolutions[zoom]
1319 )
1320 },
1321 bounds: (zoom) =>
1322 bounds(
1323 [
1324 M[t.projection].options.crs.tcrs.horizontal.min,
1325 M[t.projection].options.crs.tcrs.vertical.min
1326 ],
1327 [
1328 M[t.projection].options.crs.tcrs.horizontal.max(zoom),
1329 M[t.projection].options.crs.tcrs.vertical.max(zoom)
1330 ]
1331 )
1332 },
1333 pcrs: {
1334 horizontal: {
1335 name: 'easting',
1336 get min() {

Callers 2

Calls 2

boundsFunction · 0.85
maxMethod · 0.45

Tested by

no test coverage detected