|
899 | 899 | min: crs.crs.tilematrix.horizontal.min, |
900 | 900 | max: crs.crs.tilematrix.horizontal.max(crs.resolutions.length-1) |
901 | 901 | }; |
902 | | - if (!isNaN(Number.parseInt(min,10))) { |
903 | | - col.min = Number.parseInt(min,10); |
| 902 | + if (!isNaN(Number.parseFloat(min))) { |
| 903 | + col.min = Number.parseFloat(min); |
904 | 904 | } |
905 | | - if (!isNaN(Number.parseInt(max,10))) { |
906 | | - col.max = Number.parseInt(max,10); |
| 905 | + if (!isNaN(Number.parseFloat(max))) { |
| 906 | + col.max = Number.parseFloat(max); |
907 | 907 | } |
908 | 908 | break; |
909 | 909 | case("row"): |
|
912 | 912 | min: crs.crs.tilematrix.vertical.min, |
913 | 913 | max: crs.crs.tilematrix.vertical.max(crs.resolutions.length-1) |
914 | 914 | }; |
915 | | - if (!isNaN(Number.parseInt(min,10))) { |
916 | | - row.min = Number.parseInt(min,10); |
| 915 | + if (!isNaN(Number.parseFloat(min))) { |
| 916 | + row.min = Number.parseFloat(min); |
917 | 917 | } |
918 | | - if (!isNaN(Number.parseInt(max,10))) { |
919 | | - row.max = Number.parseInt(max,10); |
| 918 | + if (!isNaN(Number.parseFloat(max))) { |
| 919 | + row.max = Number.parseFloat(max); |
920 | 920 | } |
921 | 921 | break; |
922 | 922 | case('longitude'): |
|
965 | 965 | break; |
966 | 966 | // unsuportted axis value |
967 | 967 | } |
968 | | - } else if (type.toLowerCase() === "zoom") { |
| 968 | + } else if (type && type.toLowerCase() === "zoom") { |
969 | 969 | //<input name="..." type="zoom" value="0" min="0" max="17"> |
970 | 970 | zoom = { |
971 | 971 | name: name, |
|
1012 | 1012 | var transformation = this.options.crs.transformation, |
1013 | 1013 | tileSize = this.options.crs.options.crs.tile.bounds.max.x, |
1014 | 1014 | scale = L.bind(this.options.crs.scale, this.options.crs), |
1015 | | - tilematrix2pcrs = function (c,zoom) { |
1016 | | - return transformation.untransform(c.multiplyBy(tileSize),scale(zoom)); |
1017 | | - }, |
1018 | 1015 | pcrs2tilematrix = function(c,zoom) { |
1019 | 1016 | return transformation.transform(c, scale(zoom)).divideBy(tileSize).floor(); |
1020 | 1017 | }; |
|
1037 | 1034 | template.pcrs.northing = ''; |
1038 | 1035 | } |
1039 | 1036 |
|
1040 | | - template.pcrs.bounds = L.bounds( |
1041 | | - tilematrix2pcrs(L.point([col.min,row.min]),zoom.value), |
1042 | | - tilematrix2pcrs(L.point([col.max,row.max]),zoom.value) |
1043 | | - ); |
| 1037 | + template.pcrs.bounds = M.boundsToPCRSBounds( |
| 1038 | + L.bounds(L.point([col.min,row.min]), |
| 1039 | + L.point([col.max,row.max])), |
| 1040 | + zoom.value, this.options.crs, M.axisToCS("column")); |
1044 | 1041 |
|
1045 | 1042 | template.tilematrix = {}; |
1046 | 1043 | template.tilematrix.col = col; |
|
1363 | 1360 | // it will append its own container for rendering into |
1364 | 1361 | pane: container, |
1365 | 1362 | opacity: opacity, |
1366 | | - imagePath: this.options.imagePath, |
1367 | 1363 | projection:map.options.projection, |
1368 | 1364 | static: true, |
1369 | 1365 | onEachFeature: function(properties, geometry) { |
|
1935 | 1931 | // it will append its own container for rendering into |
1936 | 1932 | pane: this._container, |
1937 | 1933 | opacity: this.options.opacity, |
1938 | | - imagePath: M.detectImagePath(this._map.getContainer()), |
1939 | 1934 | projection:map.options.projection, |
1940 | 1935 | // each owned child layer gets a reference to the root layer |
1941 | 1936 | _leafletLayer: this, |
|
1967 | 1962 | // it will append its own container for rendering into |
1968 | 1963 | pane: this._container, |
1969 | 1964 | opacity: this.options.opacity, |
1970 | | - imagePath: M.detectImagePath(this._map.getContainer()), |
1971 | 1965 | projection:map.options.projection, |
1972 | 1966 | // each owned child layer gets a reference to the root layer |
1973 | 1967 | _leafletLayer: this, |
|
2016 | 2010 | if (this._templateVars) { |
2017 | 2011 | this._templatedLayer = M.templatedLayer(this._templateVars, |
2018 | 2012 | { pane: this._container, |
2019 | | - imagePath: M.detectImagePath(this._map.getContainer()), |
2020 | 2013 | _leafletLayer: this, |
2021 | 2014 | crs: this.crs |
2022 | 2015 | }).addTo(map); |
|
2030 | 2023 | if (this._templateVars) { |
2031 | 2024 | this._templatedLayer = M.templatedLayer(this._templateVars, |
2032 | 2025 | { pane: this._container, |
2033 | | - imagePath: M.detectImagePath(this._map.getContainer()), |
2034 | 2026 | _leafletLayer: this, |
2035 | 2027 | crs: this.crs |
2036 | 2028 | }).addTo(map); |
|
3578 | 3570 | // zoom |
3579 | 3571 | projection: map.options.projection, |
3580 | 3572 | _leafletLayer: layer, |
3581 | | - imagePath: M.detectImagePath(map.getContainer()), |
3582 | 3573 | query: true, |
3583 | 3574 | static:true, |
3584 | 3575 | }); |
|
4328 | 4319 | switch(inputs[i].getAttribute("type")){ |
4329 | 4320 | case "zoom": |
4330 | 4321 | nMinZoom = +inputs[i].getAttribute("min"); |
4331 | | - nMaxZoom = +inputs[i].getAttribute("max"); |
| 4322 | + nMaxZoom = +(inputs[i].hasAttribute("max") ? inputs[i].getAttribute("max") : nMaxZoom); |
4332 | 4323 | value = +inputs[i].getAttribute("value"); |
4333 | 4324 | break; |
4334 | 4325 | case "location": |
|
4434 | 4425 |
|
4435 | 4426 | convertPCRSBounds: function(pcrsBounds, zoom, projection, cs){ |
4436 | 4427 | if(!pcrsBounds || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection || !cs) return undefined; |
| 4428 | + projection = (typeof projection === "string") ? M[projection] : projection; |
4437 | 4429 | switch (cs.toUpperCase()) { |
4438 | 4430 | case "PCRS": |
4439 | 4431 | return pcrsBounds; |
4440 | 4432 | case "TCRS": |
4441 | 4433 | case "TILEMATRIX": |
4442 | | - let minPixel = this[projection].transformation.transform(pcrsBounds.min, this[projection].scale(+zoom)), |
4443 | | - maxPixel = this[projection].transformation.transform(pcrsBounds.max, this[projection].scale(+zoom)); |
| 4434 | + let minPixel = projection.transformation.transform(pcrsBounds.min, projection.scale(+zoom)), |
| 4435 | + maxPixel = projection.transformation.transform(pcrsBounds.max, projection.scale(+zoom)); |
4444 | 4436 | if (cs.toUpperCase() === "TCRS") return L.bounds(minPixel, maxPixel); |
4445 | | - let tileSize = M[projection].options.crs.tile.bounds.max.x; |
| 4437 | + let tileSize = projection.options.crs.tile.bounds.max.x; |
4446 | 4438 | return L.bounds(L.point(minPixel.x / tileSize, minPixel.y / tileSize), L.point(maxPixel.x / tileSize,maxPixel.y / tileSize)); |
4447 | 4439 | case "GCRS": |
4448 | | - let minGCRS = this[projection].unproject(pcrsBounds.min), |
4449 | | - maxGCRS = this[projection].unproject(pcrsBounds.max); |
| 4440 | + let minGCRS = projection.unproject(pcrsBounds.min), |
| 4441 | + maxGCRS = projection.unproject(pcrsBounds.max); |
4450 | 4442 | return L.bounds(L.point(minGCRS.lng, minGCRS.lat), L.point(maxGCRS.lng, maxGCRS.lat)); |
4451 | 4443 | default: |
4452 | 4444 | return undefined; |
|
4455 | 4447 |
|
4456 | 4448 | pointToPCRSPoint: function(point, zoom, projection, cs){ |
4457 | 4449 | if(!point || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !cs || !projection) return undefined; |
4458 | | - let tileSize = M[projection].options.crs.tile.bounds.max.x; |
| 4450 | + projection = (typeof projection === "string") ? M[projection] : projection; |
| 4451 | + let tileSize = projection.options.crs.tile.bounds.max.x; |
4459 | 4452 | switch(cs.toUpperCase()){ |
4460 | 4453 | case "TILEMATRIX": |
4461 | 4454 | return M.pixelToPCRSPoint(L.point(point.x*tileSize,point.y*tileSize),zoom,projection); |
|
4464 | 4457 | case "TCRS" : |
4465 | 4458 | return M.pixelToPCRSPoint(point,zoom,projection); |
4466 | 4459 | case "GCRS": |
4467 | | - return this[projection].project(L.latLng(point.y,point.x)); |
| 4460 | + return projection.project(L.latLng(point.y,point.x)); |
4468 | 4461 | default: |
4469 | 4462 | return undefined; |
4470 | 4463 | } |
4471 | 4464 | }, |
4472 | 4465 |
|
4473 | 4466 | pixelToPCRSPoint: function(point, zoom, projection){ |
4474 | 4467 | if(!point || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection) return undefined; |
4475 | | - return this[projection].transformation.untransform(point,this[projection].scale(zoom)); |
| 4468 | + projection = (typeof projection === "string") ? M[projection] : projection; |
| 4469 | + return projection.transformation.untransform(point,projection.scale(zoom)); |
4476 | 4470 | }, |
4477 | 4471 |
|
4478 | 4472 | boundsToPCRSBounds: function(bounds, zoom, projection, cs){ |
4479 | 4473 | if(!bounds || !bounds.max || !bounds.min || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection || !cs) return undefined; |
| 4474 | + projection = (typeof projection === "string") ? M[projection] : projection; |
4480 | 4475 | return L.bounds(M.pointToPCRSPoint(bounds.min, zoom, projection, cs), M.pointToPCRSPoint(bounds.max, zoom, projection, cs)); |
4481 | 4476 | }, |
4482 | 4477 |
|
4483 | 4478 | //L.bounds have fixed point positions, where min is always topleft, max is always bottom right, and the values are always sorted by leaflet |
4484 | 4479 | //important to consider when working with pcrs where the origin is not topleft but rather bottomleft, could lead to confusion |
4485 | 4480 | pixelToPCRSBounds : function(bounds, zoom, projection){ |
4486 | 4481 | if(!bounds || !bounds.max || !bounds.min || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection) return undefined; |
| 4482 | + projection = (typeof projection === "string") ? M[projection] : projection; |
4487 | 4483 | return L.bounds(M.pixelToPCRSPoint(bounds.min, zoom, projection), M.pixelToPCRSPoint(bounds.max, zoom, projection)); |
4488 | 4484 | }, |
4489 | 4485 | //meta content is the content attribute of meta |
|
0 commit comments