getreferenceEllipsoid Select available ellipsoid (named so as not to collide with Matlab Mapping Toolbox) inputs ------ name: string of model name. Default: 'wgs84' outputs ------- E: referenceEllipsoid parameter struct
0001 function E = getreferenceEllipsoid(name) 0002 %getreferenceEllipsoid Select available ellipsoid 0003 % 0004 % (named so as not to collide with Matlab Mapping Toolbox) 0005 % 0006 % inputs 0007 % ------ 0008 % name: string of model name. Default: 'wgs84' 0009 % 0010 % 0011 % outputs 0012 % ------- 0013 % E: referenceEllipsoid parameter struct 0014 % 0015 0016 if ~nargin 0017 name='wgs84'; 0018 end 0019 0020 switch name 0021 case 'wgs84' 0022 % WGS-84 ellipsoid parameters. 0023 % http://earth-info.nga.mil/GandG/tr8350_2.html 0024 % ftp://164.214.2.65/pub/gig/tr8350.2/wgs84fin.pdf 0025 E.Code = 7030; 0026 E.Name = 'World Geodetic System 1984'; 0027 E.LengthUnit = 'meter'; 0028 E.SemimajorAxis = 6378137.0; 0029 E.Flattening = 1/298.2572235630; 0030 E.SemiminorAxis = E.SemimajorAxis * (1 - E.Flattening); 0031 E.Eccentricity = get_eccentricity(E); 0032 %E.MeanRadius = meanradius(E); 0033 %E.Volume = spheroidvolume(E); 0034 case 'grs80' 0035 % GRS-80 ellipsoid parameters 0036 % <http://itrf.ensg.ign.fr/faq.php?type=answer> (accessed 2018-01-22) 0037 E.Code = 7019; 0038 E.Name = 'Geodetic Reference System 1980'; 0039 E.LengthUnit = 'meter'; 0040 E.SemimajorAxis = 6378137.0; 0041 E.Flattening = 1/298.257222100882711243; 0042 E.SemiminorAxis = E.SemimajorAxis * (1 - E.Flattening); 0043 E.Eccentricity = get_eccentricity(E); 0044 %E.MeanRadius = meanradius(E); 0045 %E.Volume = spheroidvolume(E); 0046 otherwise 0047 error([name,' not yet implemented']) 0048 end 0049 0050 end % function 0051 0052 function v = spheroidvolume(E) 0053 0054 v = 4*pi/3 * E.SemimajorAxis^2 * E.SemiminorAxis; 0055 0056 assert(v>=0) 0057 0058 end 0059 0060 function r = meanradius(E) 0061 0062 r = (2*E.SemimajorAxis + E.SemiminorAxis) / 3; 0063 0064 assert(r>=0) 0065 0066 end 0067 0068 function ecc = get_eccentricity(E) 0069 0070 ecc = sqrt ( (E.SemimajorAxis^2 - E.SemiminorAxis^2) / (E.SemimajorAxis^2)); 0071 0072 end % function 0073 0074 0075 % Copyright (c) 2014-2018 Michael Hirsch, Ph.D. 0076 % Copyright (c) 2013, Felipe Geremia Nievinski 0077 % 0078 % Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 0079 % 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 0080 % 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 0081 % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.