(axisName, geoLayout, fullLayout)
| 768 | } |
| 769 | |
| 770 | function makeGraticule(axisName, geoLayout, fullLayout) { |
| 771 | // equivalent to the d3 "ε" |
| 772 | var epsilon = 1e-6; |
| 773 | // same as the geoGraticule default |
| 774 | var precision = 2.5; |
| 775 | |
| 776 | var axLayout = geoLayout[axisName]; |
| 777 | var scopeDefaults = constants.scopeDefaults[geoLayout.scope]; |
| 778 | var rng; |
| 779 | var oppRng; |
| 780 | var coordFn; |
| 781 | |
| 782 | if(axisName === 'lonaxis') { |
| 783 | rng = scopeDefaults.lonaxisRange; |
| 784 | oppRng = scopeDefaults.lataxisRange; |
| 785 | coordFn = function(v, l) { return [v, l]; }; |
| 786 | } else if(axisName === 'lataxis') { |
| 787 | rng = scopeDefaults.lataxisRange; |
| 788 | oppRng = scopeDefaults.lonaxisRange; |
| 789 | coordFn = function(v, l) { return [l, v]; }; |
| 790 | } |
| 791 | |
| 792 | var dummyAx = { |
| 793 | type: 'linear', |
| 794 | range: [rng[0], rng[1] - epsilon], |
| 795 | tick0: axLayout.tick0, |
| 796 | dtick: axLayout.dtick |
| 797 | }; |
| 798 | |
| 799 | Axes.setConvert(dummyAx, fullLayout); |
| 800 | var vals = Axes.calcTicks(dummyAx); |
| 801 | |
| 802 | // remove duplicate on antimeridian |
| 803 | if(!geoLayout.isScoped && axisName === 'lonaxis') { |
| 804 | vals.pop(); |
| 805 | } |
| 806 | |
| 807 | var len = vals.length; |
| 808 | var coords = new Array(len); |
| 809 | |
| 810 | for(var i = 0; i < len; i++) { |
| 811 | var v = vals[i].x; |
| 812 | var line = coords[i] = []; |
| 813 | for(var l = oppRng[0]; l < oppRng[1] + precision; l += precision) { |
| 814 | line.push(coordFn(v, l)); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | return { |
| 819 | type: 'MultiLineString', |
| 820 | coordinates: coords |
| 821 | }; |
| 822 | } |
| 823 | |
| 824 | // Returns polygon GeoJSON corresponding to lon/lat range box |
| 825 | // with well-defined direction |
no outgoing calls
no test coverage detected
searching dependent graphs…