* TODO: review getBounds for sanity, also getFallbackBounds, perhaps integrate * there is no other kind of bounds but native.... * each rectangle must be established and valid and converted to PCRS coordinates... // "native" bounds = input type=location min max || map-extent/map-meta name
()
| 793 | // "native" bounds = input type=location min max || map-extent/map-meta name=extent min,max || map-layer/map-meta name=extent min,max || layer projection min/max |
| 794 | */ |
| 795 | getBounds() { |
| 796 | let template = this._templateVars; |
| 797 | let inputs = template.values, |
| 798 | projection = this.parentElement.units, |
| 799 | boundsUnit = {}; |
| 800 | boundsUnit.name = M.FALLBACK_CS; |
| 801 | let bnds = M[projection].options.crs.tilematrix.bounds(0), |
| 802 | locInputs = false, |
| 803 | numberOfAxes = 0, |
| 804 | horizontalAxis = false, |
| 805 | verticalAxis = false; |
| 806 | for (let i = 0; i < inputs.length; i++) { |
| 807 | if (inputs[i].getAttribute('type') === 'location') { |
| 808 | if (!inputs[i].getAttribute('max') || !inputs[i].getAttribute('min')) |
| 809 | continue; |
| 810 | let max = +inputs[i].getAttribute('max'), |
| 811 | min = +inputs[i].getAttribute('min'); |
| 812 | switch (inputs[i].getAttribute('axis').toLowerCase()) { |
| 813 | case 'x': |
| 814 | case 'longitude': |
| 815 | case 'column': |
| 816 | case 'easting': |
| 817 | boundsUnit.name = Util.axisToCS( |
| 818 | inputs[i].getAttribute('axis').toLowerCase() |
| 819 | ); |
| 820 | bnds.min.x = min; |
| 821 | bnds.max.x = max; |
| 822 | boundsUnit.horizontalAxis = inputs[i] |
| 823 | .getAttribute('axis') |
| 824 | .toLowerCase(); |
| 825 | break; |
| 826 | case 'y': |
| 827 | case 'latitude': |
| 828 | case 'row': |
| 829 | case 'northing': |
| 830 | boundsUnit.name = Util.axisToCS( |
| 831 | inputs[i].getAttribute('axis').toLowerCase() |
| 832 | ); |
| 833 | bnds.min.y = min; |
| 834 | bnds.max.y = max; |
| 835 | boundsUnit.verticalAxis = inputs[i] |
| 836 | .getAttribute('axis') |
| 837 | .toLowerCase(); |
| 838 | break; |
| 839 | default: |
| 840 | break; |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | if ( |
| 845 | boundsUnit.horizontalAxis && |
| 846 | boundsUnit.verticalAxis && |
| 847 | ((boundsUnit.horizontalAxis === 'x' && boundsUnit.verticalAxis === 'y') || |
| 848 | (boundsUnit.horizontalAxis === 'longitude' && |
| 849 | boundsUnit.verticalAxis === 'latitude') || |
| 850 | (boundsUnit.horizontalAxis === 'column' && |
| 851 | boundsUnit.verticalAxis === 'row') || |
| 852 | (boundsUnit.horizontalAxis === 'easting' && |
no test coverage detected