./PaxHeaders.3513/mapping-1.2.10000644000000000000000000000013212655504456012712 xustar0030 mtime=1454803246.572993099 30 atime=1454803247.144995051 30 ctime=1454803247.144995051 mapping-1.2.1/0000755000175000017500000000000012655504456015462 5ustar00carandraugcarandraug00000000000000mapping-1.2.1/PaxHeaders.3513/inst0000644000000000000000000000013212655504456013532 xustar0030 mtime=1454803246.572993099 30 atime=1454803247.144995051 30 ctime=1454803247.144995051 mapping-1.2.1/inst/0000755000175000017500000000000012655504456016437 5ustar00carandraugcarandraug00000000000000mapping-1.2.1/inst/PaxHeaders.3513/sm2rad.m0000644000000000000000000000013212655504456015155 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/sm2rad.m0000644000175000017500000000437112655504456020012 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Pooja Rao ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{rad} =} sm2rad (@var{sm}) ## @deftypefnx {Function File} {@var{rad} =} sm2rad (@var{sm}, @var{radius}) ## @deftypefnx {Function File} {@var{rad} =} sm2rad (@var{sm}, @var{sphere}) ## Converts distance to angle by dividing distance by radius. ## ## Calculates the angles @var{rad} for the distances @var{sm} in a sphere with ## @var{radius} (also in statute miles). If unspecified, radius defaults to 6371 km, ## the mean radius of Earth and is converted to statute miles internally. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2rad} ## @end deftypefn ## Author: Pooja Rao function rad = sm2rad (sm, radius = "earth") ## This function converts statute miles (sm) to radians (rad) ## Check arguments if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere and convert its default units (km) ## to statute miles (sm) radius = km2sm (spheres_radius (radius)); ## Check input elseif (! isnumeric (radius) || ! isscalar (radius)) error ("sm2rad: RADIUS must be a numeric scalar"); endif rad = sm/radius; endfunction %!test %! ratio = unitsratio ('km','sm'); %! assert (sm2rad (10), km2rad (ratio*10), 10*eps); %! assert (sm2rad (10, 80), km2rad (ratio*10, ratio*80), 10*eps); %! assert (sm2rad (10, "pluto"), km2rad (ratio*10, "pluto"), 10*eps); mapping-1.2.1/inst/PaxHeaders.3513/rasterdraw.m0000644000000000000000000000013212655504456016143 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/rasterdraw.m0000644000175000017500000001656612655504456021011 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {} {@var{h} =} rasterdraw (@var{data}) ## @deftypefnx {} {@var{h} =} rasterdraw (@var{data}, @var{rinfo}) ## @deftypefnx {} {@var{h} =} rasterdraw (@dots{}, @var{property}, @var{value}, @dots{}) ## Draw a GIS raster map. ## ## @var{data} can be a file name of a GIS raster data file, or a raster ## data struct made by rasterread; in the latter case input arg ## @var{rinfo}, a raster info struct also made by rasterread, is also ## required. ## ## Optionally, property/value pairs can be specified. Only the first ## four characters of the property need to be entered. The following ## property/value pairs are recognized: ## ## @itemize ## @item `bands': ## The value should be a scalar value or vector indicating which band(s) ## will be drawn in case of multi-band raster data. The default is all ## bands if the data contains three bands of integer data type, or the ## first band in all other cases. For non-integer raster data only one ## raster band can be specified. The number of bands must be 1 or 3. ## ## @item `colormap': ## The value should be a valid colormap to be used for indexed raster ## data. ## ## @item `missingvalue': ## A numerical value to substitute for missing values in the raster ## data. Default is NaN (for floating point raster data). ## @end itemize ## ## The optional output argument @var{h} is a graphics handle to the map. ## ## If the raster data to be plotted comprises just one band and a GDAL ## colortable, that colortable is converted to a colormap and used for ## drawing the map. The actual raster data are converted to uint8 if ## no missing data are present. ## ## Behind the scenes imshow() is invoked for the actual drawing for ## integer or single-band data, or pcolor() for floating point data with ## missing values. ## ## Note that drawing raster data can be quite slow for big data sets. ## Drawing maps larger than ~4000x4000 pixels is therefore not advised. ## ## @seealso{mapshow, rasterread, rasterinfo} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2015-12-29 function [hr] = rasterdraw (varargin) if (nargin < 1) print_usage (); endif hr = -1; clrmap = []; misval = NaN; if (ischar (varargin{1})) ## Assume a raster file name. Just convey to rasterread.m fname = varargin{1}; [bands, rinfo] = rasterread (fname); nargin = nargin - 1; varargin(1) = []; elseif (isstruct (varargin{1})) ## Assume a raster struct made by rasterread.m. Checks: if (! isfield ("varargin(1)", "data") && ! ismatrix (varargin{1}(1).data)) error ("rasterdraw.m: unknown info raster struct setup"); else bands = varargin{1}; endif ## Check arg #2 - expecting info struct if (nargin < 2 || ! (isstruct (varargin{2}) && all (ismember ({"bbox", "projection", "height", "width", ... "geotransformation", "nbands"}, ... lower (fieldnames (varargin{2})))))) error ("rasterdraw.m: invalid or missing info struct (arg #2)"); else rinfo = varargin{2}; varargin(1:2) = []; nargin = nargin - 2; endif else ## Unknown "first" argument error ("rasterdraw.m: expecting filename or raster struct"); endif ibands = [1 : numel(bands)]; ## Optional propert/value arguments for ii=1:2:nargin if (nargin < ii+1) error ("rasterdraw.m: missing value for property %s", varargin{ii}); endif switch (lower (varargin{ii}(1:4))) case "band" ## Select raster band(s) to draw ibands = varargin{ii+1}; if (! isnumeric (ibands)) error ("rasterdraw.m: expecting numeric value(s) for 'bands' value"); elseif (any (ibands > numel (bands))) warning ("rasterdraw.m: data contains %d band(s), requested band(s) [%s\ ] ignored.\n", numel (bands), sprintf (" %d", ibands(find (ibands > numel (bands))))); ibands (find (ibands > numel (bands))) = []; endif if (! (numel (ibands) == 1 || numel (ibands) == 3)) error ("rasterdraw.m: either one or three bands must be selected.\n"); elseif (rinfo.BitDepth >= 32) ## Assume floating point data warning ("rasterdraw.m: floating point raster data. only band %d\ will be drawn\n", ibands(1)); endif case "colo" clrmap = varargin{ii+1}; if (! iscolormap (clrmap)) error ("rasterdraw.m: invalid colormap specified"); endif case "miss" misval = varargin{ii+1}; if (! isnumeric (misval)) error ("rasterdraw.m: numerical value expected for missing value"); endif otherwise warning ("rasterdraw.m: unknown or unimplemented property '%s' - skipped\n", ... varargin{ii}); endswitch endfor ## For each band process raster data, First band can be special ## FIXME Implement e.g., white ([1 1 1]) as default missing value for RGB ## multi-band images empdat = 0; ## 1. Treat & signal missing values (only for one-band maps) if (! isempty (bands(ibands(1)).ndv)) ndv = bands(ibands(1)).ndv; if (any (any (bands(1).data == bands(ibands(1)).ndv))) empdat = 1; bands(ibands(1)).data(find (bands(ibands(1)).data == ndv)) = misval; endif endif ## 2. If no missing data found & integer raster data type, cast to uint8 if (! empdat || rinfo.BitDepth <= 8) pic = uint8 (bands(ibands(1)).data); ## Band data no more used, clear - raster data can occupy awfully much RAM bands(ibands(1)).data = []; if (! isempty (bands(ibands(1)).colortable)) clrmap = bands(ibands(1)).colortable(:, 1:3); endif else pic = bands(ibands(1)).data; endif ## If no missing pixels, process next bands if present & requested if (numel (ibands) > 1 && ! empdat) ## Concat bands into picture pic(:, :, 1) = pic; for ii=2:numel (ibands) pic(:, :, ii) = uint8(bands(ibands(ii)).data); bands(ibands(1)).data = []; endfor endif ## Clear bands struct (also clears RAM for bands not requested) clear bands; ## Draw rasters using bbox values for axes limits if (empdat) bbox = rinfo.bbox; XX = [bbox(1, 1) : (diff (bbox(:, 1)) / (rinfo.Width)): bbox(2, 1)]; YY = [bbox(1, 2) : (diff (bbox(:, 2)) / (rinfo.Height)): bbox(2, 2)]; [nr, nc] = size (pic); hr = pcolor (XX, YY, [pic nan(nr, 1); nan(1, nc+1)]); ## Hide mesh: shading flat; else if (isempty (clrmap) || ! iscolormap (clrmap)) hr = imshow (pic, "xdata", rinfo.bbox(:, 1), "ydata", rinfo.bbox(:, 2)); else hr = imshow (pic, "xdata", rinfo.bbox(:, 1), "ydata", rinfo.bbox(:, 2), ... "colormap", clrmap); endif endif set (gca, "YDir", "normal"); axis equal; endfunction mapping-1.2.1/inst/PaxHeaders.3513/wrapTo180.m0000644000000000000000000000013212655504456015472 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/wrapTo180.m0000644000175000017500000000406412655504456020326 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Oscar Monerris Belda ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{xwrap} =} wrapTo180 (@var{x}) ## ## Wraps X into the [-180 to 180] interval. ## ## @var{x}: angle(s) in degrees (single value, vector or ND-matrix). ## ## @var{xwrap}: output value(s) in the range [-180 .. 180] degrees. ## The interval [-180 .. 180] is a closed interval: values equal to ## negative odd multiples of -180 are mapped to -180, values equal ## to an odd multiple of 180 are mapped to 180. ## ## @example ## wrapTo180 ([-181, -180, -50; 180, 200, 460]) ## ans = ## 179 -180 -50 ## 180 -160 100 ## @end example ## ## @seealso{unwrap, wrapToPi, wrapTo2Pi} ## @end deftypefn function xwrap = wrapTo180 (x) xwrap = rem (x, 360); idx = find (abs (xwrap) > 180); xwrap(idx) -= 360 * sign (xwrap(idx)); endfunction %!test %! x = -800:0.1:800; %! xw = wrapTo180 (x); %! assert (sind (x), sind (xw), 16 * eps) %! assert (cosd (x), cosd (xw), 16 * eps) %! assert (! any (xw < -180)) %! assert (! any (xw > 180)) %!test %! c = [-721.1, -718.9, -481.3, -479.99, -361, -359, -200, -180-(1e-14), -180, ... %! -180-(2e-14), -160, -eps, 0, eps, 160, 180, 180+(1e-14), 180+(2e-14), 200]; %! assert (wrapTo180 (c), [-1.10, 1.10, -121.30, -119.99, -1.0, 1.0, 160.0, ... %! -180.0, -180.0, 180.0, -160.0, -0.0, 0.0, 0.0, ... %! 160.0, 180.0, 180.0, -180.0, -160.0], 1e-13); mapping-1.2.1/inst/PaxHeaders.3513/wrapToPi.m0000644000000000000000000000013212655504456015532 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/wrapToPi.m0000644000175000017500000000370212655504456020364 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Oscar Monerris Belda ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{xwrap} =} wrapToPi (@var{x}) ## ## Wraps X into the [-pi to pi] interval ## ## @var{x}: angle(s) in radians (single value, vector or ND-matrix). ## ## @var{xwrap}: output value(s) in the range [-pi .. pi] radians. ## The interval [-pi .. pi] is a closed interval: values equal to ## negative odd multiples of -pi are mapped to -pi, values equal to ## an odd multiple of +pi are mapped to pi. ## ## Example: ## @example ## wrapToPi ([-3*pi, -pi, -pi-1, 0; pi-1, pi, pi+1, 3*pi]) ## ans = ## -3.14159 -3.14159 2.14159 0.00000 ## 2.14159 3.14159 -2.14159 3.14159 ## @end example ## ## @seealso{wrapTo180, wrapTo360, wrapto2Pi} ## @end deftypefn function xwrap = wrapToPi(x) xwrap = rem (x, 2*pi); idx = find (abs (xwrap) > pi); xwrap(idx) -= 2*pi * sign (xwrap(idx)); endfunction %!test %! x = -9:0.1:9; %! xw = wrapToPi (x); %! assert (sin (x), sin (xw), 8 * eps) %! assert (cos (x), cos (xw), 8 * eps) %! assert (! any (xw < -pi)) %! assert (! any (xw > pi)) %% Test Matlab compatibility as regards closed interval (esp. left) %!test %! assert (wrapToPi ([-3*pi, -pi, -pi-1, 0; pi-1, pi, pi+1, 3*pi]), ... %! [-pi, -pi, pi-1, 0.00000 ; ... %! pi-1, pi, -pi+1, pi], 1e-13) mapping-1.2.1/inst/PaxHeaders.3513/nm2rad.m0000644000000000000000000000013212655504456015150 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/nm2rad.m0000644000175000017500000000437712655504456020013 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Pooja Rao ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{rad} =} nm2rad (@var{nm}) ## @deftypefnx {Function File} {@var{rad} =} nm2rad (@var{nm}, @var{radius}) ## @deftypefnx {Function File} {@var{rad} =} nm2rad (@var{nm}, @var{sphere}) ## Converts distance to angle by dividing distance by radius. ## ## Calculates the angles @var{rad} for the distances @var{nm} in a sphere with ## @var{radius} (also in nautical miles). If unspecified, radius defaults to 6371 km, ## the mean radius of Earth and is converted to nautical miles internally. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2rad} ## @end deftypefn ## Author: Pooja Rao function rad = nm2rad (nm, radius = "earth") ## This function converts nautical miles (nm) to radians (rad) ## Check arguments if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere and convert its default units (km) ## to nautical miles (nm) radius = km2nm (spheres_radius (radius)); ## Check input elseif (! isnumeric (radius) || ! isscalar (radius)) error ("nm2rad: RADIUS must be a numeric scalar"); endif rad = nm/radius; endfunction %!test %! ratio = unitsratio ('km','nm'); %! assert (nm2rad (10), km2rad (ratio*10), 10*eps); %! assert (nm2rad (10, 80), km2rad (ratio*10, ratio*80), 10*eps); %! assert (nm2rad (10, "pluto"), km2rad (ratio*10, "pluto"), 10*eps); mapping-1.2.1/inst/PaxHeaders.3513/nm2km.m0000644000000000000000000000013212655504456015011 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/nm2km.m0000644000175000017500000000272012655504456017642 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Eugenio Gianniti ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} nm2km (@var{nm}) ## Convert nautical miles into kilometers. ## ## @seealso{km2nm, km2sm, nm2sm, sm2km, sm2nm} ## @end deftypefn ## Author: Eugenio Gianniti function km = nm2km (nm) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("kilometer", "nautical mile"); km = nm * ratio; endfunction %!test %! km = [10 13.000002880000002 14.9999962 17.000008 19 31.000072400000004]; %! nm = [5.399568034557235 7.01944 8.09935 9.179269978401727 10.259179265658746 16.7387]; %! assert (nm2km (nm), km) %! km = reshape (km, [3 2 1]); %! nm = reshape (nm, [3 2 1]); %! assert (nm2km (nm), km) %!assert (nm2km (8.09935), 14.9999962) mapping-1.2.1/inst/PaxHeaders.3513/sm2km.m0000644000000000000000000000013212655504456015016 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/sm2km.m0000644000175000017500000000264712655504456017657 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Eugenio Gianniti ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} sm2km (@var{sm}) ## Convert U.S. survey miles (statute miles) into kilometers. ## ## @seealso{km2nm, km2sm, nm2km, nm2sm, sm2nm} ## @end deftypefn ## Author: Eugenio Gianniti function km = sm2km (sm) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("kilometer", "U.S. survey mile (statute mile)"); km = sm * ratio; endfunction %!test %! km = [2 6336 4.8326 6.437388874777749]; %! sm = [1.242739898989899 3937 3.002832417929293 4]; %! assert (sm2km (sm), km) %! km = reshape (km, [1 2 2]); %! sm = reshape (sm, [1 2 2]); %! assert (sm2km (sm), km) %!assert (sm2km (3937), 6336) mapping-1.2.1/inst/PaxHeaders.3513/rasterinfo.m0000644000000000000000000000013212655504456016141 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/rasterinfo.m0000644000175000017500000000442712655504456021000 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {} {@var{rinfo} =} rasterinfo (@var{fname}) ## Return various info about a GIS raster file: a.o., file type, bit ## depth, raster size, projection and geotransformation. If the raster ## file is a geotiff file, additional info is returned. ## ## rasterinfo needs the GDAL library. ## ## @seealso{rasterread} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2015-12-23 function [rinfo] = rasterinfo (fname) persistent HAVE_GDAL = []; ## Checks if (! ischar (fname)) print_usage (); elseif (isempty (fname)) print_usage (); elseif (exist (fname) != 2) error ("rasterinfo.m: file '%s' not found\n", fname); endif bands = info = {}; ## Check if we have gdalread.oct installed (depends on GDAL) if (isempty (HAVE_GDAL)) HAVE_GDAL = ! isempty (which ("gdalread")); endif if (! HAVE_GDAL) error ("rasterinfo.m: GDAL library is apparently not installed"); endif ## Try to read data file [rstatus, binfo] = gdalread (fname, 0); if (! rstatus) ## Check if we have a geotiff file. If so, get extra info if (strcmpi (binfo.FileType, 'geotiff')) rinfo = imfinfo (fname); rinfo.FileType = binfo.FileType; rinfo.datatype_name = binfo.datatype_name; rinfo.GeoTransformation = binfo.GeoTransformation; rinfo.Projection = binfo.Projection; else rinfo = binfo; rinfo.Filename = canonicalize_file_name (fname); rinfo.FileSize = stat (fname).size; rinfo.FileModDate = strftime ("%d-%b-%y %H:%M:%S", localtime (stat (fname).mtime)); endif endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/private0000644000000000000000000000013212655504456015204 xustar0030 mtime=1454803246.564993071 30 atime=1454803247.144995051 30 ctime=1454803247.144995051 mapping-1.2.1/inst/private/0000755000175000017500000000000012655504456020111 5ustar00carandraugcarandraug00000000000000mapping-1.2.1/inst/private/PaxHeaders.3513/spheres_radius.m0000644000000000000000000000013212655504456020457 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/private/spheres_radius.m0000644000175000017500000000256212655504456023314 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2013 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see . ## private function with mean planet radius function radius = spheres_radius (obj) objects = struct ("sun", 694460, "mercury", 2439, "venus", 6051, "earth", 6371, "moon", 1738, "mars", 3390, "jupiter", 69882, "saturn", 58235, "uranus", 25362, "neptune", 24622, "pluto", 1151); obj = tolower (obj); if (! isfield (objects, obj)) stack = dbstack; error ("%s: unknown SPHERE object", stack(2).name); endif radius = objects.(obj); endfunction mapping-1.2.1/inst/private/PaxHeaders.3513/clippln.m0000644000000000000000000000013212655504456017100 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/private/clippln.m0000644000175000017500000001724612655504456021742 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} [@var{val}, @var{npts}, @var{pprt}] = clipplg (@var{val}, @var{npts}, @var{pprt}, @var{sbox}, @var{styp}) ## Undocumented internal function for clipping (poly)lines within a bounding ## box and interpolating M and Z-values. ## ## @seealso{} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-12-01 function [val, tnpt, tnpr] = clippln (val, tnpt, tnpr, sbox, styp=3) ## Backup btnpr = tnpr; ## Prepare augmented npr array for easier indexing into subfeatures ttnpr = [tnpr tnpt]; ctnpr = {}; ## Initialize output array valt = []; ## First step is to check all polyline vertices whether they lie in sbox [aa, bb] = inpolygon (val(:, 1), val(:, 2), sbox(:, 1), sbox(:, 2)); if (any (aa) || any (bb)) ## So there are. Morph bounding box into something that OF geometry likes: ## Parametric representation of bounding box. "createLine" is in OF geometry ssbox = createLine (sbox(1:4, :), sbox (2:5, :)); ## Create sbx from sbox ([minx max miny maxy]) sbx = [min(sbox(:, 1)), max(sbox(:, 1)), min(sbox(:, 2)), max(sbox(:, 2))]; ## For those points ON the boundary no interpolation is needed. ## First treat those points requiring interpolation (1st inside, ## 2nd outside or vice versa) for ll=1:numel (tnpr) ## Start at end of polyline-part to avoid mixing up tnpr pointers ii = numel (tnpr) - ll + 1; nprt = []; ## Select polyline part valn = val(ttnpr(ii)+1:ttnpr(ii+1), :); a = aa(ttnpr(ii)+1:ttnpr(ii+1)); if (any (a)) b = bb(ttnpr(ii)+1:ttnpr(ii+1)); da = diff (a); idx = find (da); ## Find out which bounding box segments have been crossed where ## 1. Parametric representation of line lines = createLine (valn(idx, 1:2), valn(idx+1, 1:2)); ## 2. Compute intersections. clipLine & distancePoints are in OF geometry for jj=1:numel (idx) ## Start at end of polyline-part to avoid mixing up tnpr pointers kk = numel (idx) - jj + 1; ## Skip points on border if (! b(idx(kk)+1)) intsc = reshape (clipLine (lines(kk, :), sbx), 2, 2)'; dst = distancePoints (intsc, valn(idx(kk):idx(kk)+1, 1:2)); ## If segment goes out, take nearest point to valn(idx(kk)+1) if (da(idx(kk)) < 1) [~, ix] = min (dst(:, 2)); else [~, ix] = min (dst(:, 1)); endif fac = dst(ix, 2) / sum (dst(2, :)); intsc = intsc (ix, :); ## Insert new intersection point valn(idx(kk)+2:end+1, :) = valn(idx(kk)+1:end, :); valn(idx(kk)+1, 1:2) = intsc(1:2); if (styp > 3) valn(idx(kk)+1, 3:4) = valn(idx(kk)+2, 3:4) + fac * ... (valn(idx(kk), 3:4) - valn(idx(kk)+2, 3:4)); else valn(idx(kk)+1, 3:4) = [NaN NaN]; endif ## Also update a, b, da and idx. Also mark first point outside sbox aa(ttnpr(ii)+idx(kk):ttnpr(ii)+idx(kk)+1) = 1; a = [ a(1:idx(kk)); 1; a(idx(kk)+1:end) ]; b = [ b(1:idx(kk)); 1; b(idx(kk)+1:end) ]; endif if (da(idx(kk)) < 0) ## Segment leaves bbox. Replace first outer point with NaN row valn(idx(kk)+2, :) = NaN (1, 6); ## Be sure to include NaN row a(idx(kk)+2) = 1; endif endfor ## Update valt, ttnpr valn = valn(find(a), :); if (! isempty (valn)) ## Remove last NaN row if present if (all (isnan (valn(end, 1:2)))) valn(end,:) = []; endif isn = 1; while (! isempty (isn)) isn = find (isnan (valn(:, 1))); if (! isempty (isn)) ## Insert new subfeature pointer. npart pointers are 0-based nprt = [ nprt isn(1) ]; valn(isn(1), :) = []; endif endwhile ## Build up new points from top down valt = [ valn; valt ]; ## nprt only gets non-empty if a polyline part was split up ## FIXME moet net als bij polygons ttnpr = [ ttnpr(1:ii) (nprt+ttnpr(ii)-1) ttnpr(ii+1:end) ]; endif endif endfor tnpt = size (valt, 1); tnpr = ttnpr(1:end-1); endif ## There's still the possibility of segments crossing through Bounding Box ## w/o having points inside. Search these segments one by one cc = find (! aa); if (numel (cc) > 1) ## Find discontinuities; and merge wit tnpr (multipart) discontinuities ci = find (diff(cc) > 1)'; ## Make sure to only include multipart discontinuities within range of cc ctnpr = unique ([max(btnpr, cc(1)-1) cc(ci)' min(cc(end), size (val, 1))]); ## Create sbx from sbox ([minx max miny maxy]) sbx = [min(sbox(:, 1)), max(sbox(:, 1)), min(sbox(:, 2)), max(sbox(:, 2))]; for ic=1:numel (ctnpr) - 1 valc = val(ctnpr(ic)+1:ctnpr(ic+1), :); ## Eliminate segments that lie to one outside of the bounding box. ## Step 1: assess which side of the bounding box the segments lie f1 = valc(:, 1) < min (sbox(:, 1)); f2 = valc(:, 1) > max (sbox(:, 1)); f3 = valc(:, 2) < min (sbox(:, 2)); f4 = valc(:, 2) > max (sbox(:, 2)); ff = [f1'; f2' ; f3' ; f4']'; ## Step 2: find those segments that cross > 2 extended sbox boundary line dd = find (sum ([abs(diff(f1)'); abs(diff(f2)'); ... abs(diff(f3)'); abs(diff(f4)')]) > 1); ## If there are any vertices changing orientation w.r.t. bounding box: if (! isempty (dd)) ## Create array of lines potentially crossing sbox lines = []; for ii=1:numel (dd) lines = [ lines; createLine(valc(dd(ii), 1:2), valc(dd(ii)+1, 1:2))]; endfor ## For each of that segment, try to compute intersections with sbox for ii=1:numel (dd) ## clipLine is in OF geometry jntsc = reshape (clipLine (lines, sbx), 2, 2)'; ## Check if there are any intersections at all if (! any (isnan (jntsc))) valn = [ jntsc NaN(2, 4) ]; ## Interpolate M and Z values. valc(dd(ii)+1) also required ... dist = distancePoints (valc(dd(ii):dd(ii)+1, 1:2), valn(:, 1:2)); ## ... for length of original segment: sl = sum (dist(:, 1)); ## Find closest point of original segment valn(1, 3:4) = valc(dd(ii), 3:4) + dist(1, 1) / sl * ... (valc(dd(ii)+1, 3:4) - valc(dd(ii), 3:4)); valn(2, 3:4) = valc(dd(ii), 3:4) + dist(1, 2) / sl * ... (valc(dd(ii)+1, 3:4) - valc(dd(ii), 3:4)); ## Adapt tnpr tnpr = [ tnpr size(valt, 1) ]; valt = [ valt; valn ]; endif endfor tnpr = unique (tnpr); endif endfor endif valt(:, 5:6) = repmat (val(1, 5:6), size (valt, 1), 1); val = valt; endfunction mapping-1.2.1/inst/private/PaxHeaders.3513/clipplg.m0000644000000000000000000000013212655504456017071 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/private/clipplg.m0000644000175000017500000002035012655504456021721 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} [@var{val}, @var{npts}, @var{pptr}] = clipplg (@var{val}, @var{npts}, @var{pptr}, @var{sbox}[, @var{styp]}) ## Undocumented internal function for clipping polygons & interpolating Z & M ## values. ## ## @seealso{} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-11-18 ## Updates: ## 2014-11-22 Create stanza for finding back vertices and interpolating Z & M ## 2014-11-25 Fix interpolating M & Z values, properly treat new corner points ## of clipped polygons ## 2014-11-26 Update tnpt and tnpr arrays ## 2015-07-10 Provision for segments crossed twice by clipping polygon function [val, tnpt, tnpr] = clipplg (val, tnpt, tnpr, sbox, styp=5) ## Indices to start of each subfeature, plus end+1 tnprt = [(tnpr + 1) tnpt+1]; ## Initialize total number of clipped vertices tnptclp = 0; tnprclp = cell (numel (tnpr, 1)); for kk=1:numel (tnpr) ## Work from end back to start of subfeatures to avoid mixing up index arrays jj = numel (tnpr) - kk + 1; ## Select rows belonging to this partial feature. First save non-selected rows b_val = e_val = []; if (jj > 1) ## There's one or more subfeatures lower down b_val = val(1:tnprt(jj)-1, :); endif if (jj < numel (tnpr)) ## There's one or more subfeatures higher up e_val = val(tnprt(jj+1):end, :); endif tval = val(tnprt(jj):tnprt(jj+1)-1, :); ## oc_polybool is in OF geometry package [X, Y, npol, b, c] = oc_polybool (tval(:, 1:2), sbox, 'AND'); ## Initialize new number of points & new part pointers in clipped polygon(s) nptclp = 0; nprclp = 0; valn = []; if (npol) ## Make an XY matrix, remove NaNs on upper and lower row valc = [X Y](2:end-1, :); ## Augment NaNs for Z and M, and augment type + shape record index columns ncl = size (valc, 1); valc = [ valc NaN(ncl, 2) tval(1, 5)*ones(ncl, 1) tval(1, 6)*ones(ncl, 1) ]; ## Pointers to subpolygons resulting from clipping ipt = find (isnan (valc(:, 1)))'; ipt = [ 0 ipt (size (valc, 1) + 1) ]; ## For each new polygon... for ipol=1:npol valn = valc(ipt(ipol)+1:ipt(ipol+1)-1, :); ## Update total number of points in clipped polygon(s) nptclp += size (valn, 1); tnptclp += size (valn, 1); ## Add a new 0-based pointer to next part nprclp = [ nprclp nptclp ]; ## Compute all interdistances. distancePoints is in OF geometry package ## Avoid polygon end point ( = start point) dsts = distancePoints (valn(1:end-1, 1:2), tval(1:end-1, 1:2)); ## Find matching points in sub and out polygon (row, col) [rw, cl] = ind2sub (size (dsts), find (abs (dsts) < eps)); ## Transfer known Z and M-values valn(rw, 3:4) = tval(cl, 3:4); ## cl indices refer to original shape, rw indices to clipped shape if (numel (cl) >= 1) ## Separate polygon segments clipped, or vertex on bounding box side ## For each valn row coords not in tval, interpolate Z and M values im = setdiff ([1:size(valn, 1)-1], rw); ## mi equals cl filled with zeros for non-matches, to easen indexing mi = zeros (1, size (valn, 1) - 1); mi(rw) = cl; ## Find direction of polyline pdir = find (abs (diff (rw)) - 1 < eps); if (isempty (pdir)) ## Single point within bounding box. Direction doesn't matter then drctn = 1; else drctn = sign (diff (rw([pdir pdir+1])))(1); endif for ii=1:numel (im) ## Get matching outer vertex. Below IF-ELSEIF order = critical to ## avoid index out-of-range errors if (im(ii) == 1) ## Clipped off outer vertex = previous in tval. diff(cl) = direction intpl = true; idx = mi(im(ii)+1) - drctn; ovtx = tval(idx, :); cvtx = tval(mi(im(ii)+1), :); elseif ((! ismember (im(ii)-1, rw)) && (! ismember (im(ii)+1, rw))) ## Probably a corner point. Just retain NaN values intpl = false; elseif (! ismember (im(ii)-1, rw)) ## Clipped off outer vertex = previous in tval. diff(cl) = direction intpl = true; idx = mi(im(ii)+1) - drctn; ovtx = tval(idx, :); cvtx = tval(mi(im(ii)+1), :); elseif (! ismember (im(ii)+1, rw)) ## Clipped off outer vertex = next in tval. diff(cl) = direction intpl = true; idx = mi(im(ii)-1) + drctn; ovtx = tval(idx, :); cvtx = tval(mi(im(ii)-1), :); endif ## Parent points found, now interpolate M and Z (if appropriate) if (intpl && styp > 5) ## Compute missing M and Z values. Invoke largest diff of X/Y coordinates difx = abs (cvtx(1) - ovtx(1)); dify = abs (cvtx(2) - ovtx(2)); if (difx > dify) ## X distance is greater fac = (valn(im(ii), 1) - cvtx(1)) / difx; else ## Y distance is greater fac = (valn(im(ii), 2) - cvtx(2)) / dify; endif fac = abs(fac); ## FIXME a debug stmt to detect wrong interpolation => wrong vertices if (fac > 1.0) printf ("Oops - fac > 1..\n"); % keyboard endif if (isfinite (ovtx(3))) valn(im(ii), 3) = fac * (ovtx(3) - cvtx(3)) + cvtx(3); ## Z-value endif if (isfinite (ovtx(4))) valn(im(ii), 4) = fac * (ovtx(4) - cvtx(4)) + cvtx(4); ## M-value endif endif endfor ## Remove last nprclp entry and temporarily store it in a cell arr tnprclp(jj) = nprclp; elseif (numel (cl) == 0) ## One polygon segment clipped twice. Simply assign nearest Z & M values ## FIXME proper interpolation required ## Find points interpolated on segment(s); they're not in sbox [im, ix] = min (distancePoints (sbox(1:end-1, :), valn(1:end-1, 1:2))); im = find (im > 0); ix = ix(im); ## Find nearest polygon points (could be on another polygon segment !) [~, ix] = min (distancePoints (tval(1:end-1, 1:2), valn(im, 1:2))); ## Assign Z and M values valn(im, 3:4) = tval(ix, 3:4); ## Remove last nprclp entry and temporarily store it in a cell arr tnprclp(jj) = nprclp; endif ## Last row of polygon equals first valn(end, :) = valn(1, :); ## Augment new polygon after (yet untouched) previous polygons b_val = [ b_val; valn ]; endfor ## clipped subpolygons else ## No intersection at all. Just drop tval % tnprclp = {}; endif val = [b_val ; e_val]; tnprt(jj+1:end) -= tnprt(jj+1) - tnprt(jj) - size (valn, 1); if (isempty (valn)) ## This subfeature has no points in boundingbox +> drop from list tnprt(jj+1) = []; endif endfor ## Adapt & clean up npt tnpt = tnptclp; ## Adapt & clean up npr. Concatenate all pointers created by oc_polybool tnpr = [ tnprclp{1} ]; for ii=2:numel (tnprclp) ## Skip empty entries if (! isempty (tnprclp{ii})) tnpr = [tnpr(1:end-1) (tnprclp{ii} + tnpr(end)) ]; endif endfor if (! isempty (tnpr)) tnpr(end) = []; endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/rasterread.m0000644000000000000000000000013212655504456016121 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/rasterread.m0000644000175000017500000000622412655504456020755 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{bands}, @var{info}] =} rasterread (@var{fname}) ## Read a GIS raster file ## ## @var{fname} can be about any type of GIS raster file recognized by the ## GDAL library. For .adf files, either the name of the subdirectory ## containing the various component files, or the name of one of those ## component files can be specified. ## ## Output argument @var{bands} is a struct, or if multiple bands were read, ## a struct array, with data of each band: data, min, max, bbox, and ## (if present for the band) a GDAL colortable (see GDAL on-line ## reference). ## ## Outpur argument @var{binfo} contains various info of the raster file: ## overall bounding box, geotransformation, projection, size, nr. of columns ## and rows, datatype, nr. of bands. ## ## rasterread.m needs the GDAL library. ## ## @seealso{gdalread, gdalwrite} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2015-10-15 function [bands, binfo] = rasterread (fname="") ## Checks if (! ischar (fname)) print_usage (); elseif (isempty (fname)) print_usage (); elseif (exist (fname) != 2) error ("rasterread.m: file '%s' not found\n", fname); endif bands = info = {}; ## Try to read data [status, binfo, bands] = gdalread (fname); if (! status) binfo.bbox = [Inf Inf; -Inf -Inf]; for ii=1:numel (bands) ## gdalread() rotates bands 90 degrees probably due to fortran_vec bands(ii).data = rot90 (bands(ii).data, 1); binfo.bbox(1, 1:2) = min (binfo.bbox(1, 1:2), bands(ii).bbox(1, 1:2)); binfo.bbox(2, 1:2) = max (binfo.bbox(2, 1:2), bands(ii).bbox(2, 1:2)); if (bands(ii).has_ndv) bands(ii).ndv = bands(ii).ndv_val; else bands(ii).ndv = []; endif if (! isempty (bands(ii).colortable) && all (abs (bands(ii).colortable(:, 4)) > 1e-10)) bands(ii).colortable(:, 1:3) = bands(ii).colortable(:, 1:3) ./ ... bands(ii).colortable(:, 4); endif endfor ## Remove fieldnames that are no longer needed dflds = setdiff (fieldnames (bands), {"data", "bbox", "min", "max", ... "ndv", "colortable"}); bands = rmfield (bands, dflds); ## Add file info to binfo binfo.Filename = canonicalize_file_name (fname); binfo.FileSize = stat (fname).size; binfo.FileModDate = strftime ("%d-%b-%y %H:%M:%S", localtime (stat (fname).mtime)); endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/dm2degrees.m0000644000000000000000000000013212655504456016006 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/dm2degrees.m0000644000175000017500000000536312655504456020645 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} dm2degrees (@var{dm}) ## Convert degrees, minutes, and seconds components into decimal degrees. ## ## @var{dm} must be a 2 column matrix with one row per angle, each ## column correspoding to its degrees (an integer), and minutes (a less ## than 60 value, possibly fractional) components. ## ## The sign of the angle must be defined on its first non-zero component only, ## i.e., if an angle is negative, the minutes component must be positive ## unless its degrees component is zero. ## ## @seealso{degrees2dm, degree2dms, dms2degrees} ## @end deftypefn ## Author: Carnë Draug function deg = dm2degrees (dm) if (nargin != 1) print_usage (); elseif (! isnumeric (dm) || ndims (dm) != 2 || columns (dm) != 2) error ("dm2degrees: DM must be a numeric matrix with 2 columns"); elseif (any (fix (dm(:,1)) != dm(:,1))) error ("dm2degrees: degrees component (first column) must be an integer"); elseif (any (dm(:,2) >= 60)) error ("dm2degrees: minutes component (second column) must be less than 60"); endif ## join the degrees and minutes parts adm = abs (dm); deg = sum ([adm(:,1) adm(:,2)/60], 2); ## change the sign if any part is negative and check that negative ## sign is present on the first non-zero part only negs = dm < 0; if (any (dm(:,1) != 0 & negs(:,2))) error ("dm2degrees: minutes must be positive if degree is non-zero"); endif deg(any (negs, 2)) *= -1; endfunction %!test %! deg = [10 10.5 -10.5 -0.5 0.5]'; %! dm = [ 10 0 %! 10 30 %! -10 30 %! 0 -30 %! 0 30]; %! for i = 1:rows (dm) %! assert (dm2degrees (dm(i,:)), deg(i)); %! endfor %! assert (dm2degrees (dm), deg); %! assert (dm2degrees (single (dm)), single (deg)); %!error dm2degrees ([5 60]) %!error dm2degrees ([5 61]) %!error <2 columns> dm2degrees ([5 50 3]) %!error dm2degrees ([5 -40]) %!error dm2degrees ([-5 -40]) %!error dm2degrees (rand (7, 2, 3)) mapping-1.2.1/inst/PaxHeaders.3513/km2deg.m0000644000000000000000000000013212655504456015136 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/km2deg.m0000644000175000017500000000404612655504456017772 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2008 Alexander Barth ## Copyright (C) 2013 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{deg} =} km2deg (@var{km}) ## @deftypefnx {Function File} {@var{deg} =} km2deg (@var{km}, @var{radius}) ## @deftypefnx {Function File} {@var{deg} =} km2deg (@var{km}, @var{sphere}) ## Convert distance to angle. ## ## Calculates the angles @var{deg} for the distances @var{km} in a sphere with ## @var{radius} (also in kilometers). If unspecified, radius defaults to 6371, ## the mean radius of Earth. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{deg2km} ## @end deftypefn ## Author: Alexander Barth function deg = km2deg (km, radius = "earth") if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere with default units (km) radius = spheres_radius (radius); elseif (! isnumeric (radius) || ! isscalar (radius)) error ("km2deg: RADIUS must be a numeric scalar"); endif deg = 180 * km/(pi*radius); endfunction %!assert (deg2km (km2deg (10)), 10, 10*eps) %!assert (deg2km (km2deg (10, 80), 80), 10, 10*eps) %!assert (deg2km (km2deg (10, "pluto"), "pluto"), 10, 10*eps) mapping-1.2.1/inst/PaxHeaders.3513/validateLengthUnit.m0000644000000000000000000000013212655504456017560 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/validateLengthUnit.m0000644000175000017500000002121112655504456022405 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} validateLengthUnit (@var{unit}) ## @deftypefnx {Function File} {} validateLengthUnit (@var{unit}, @var{ind}) ## @deftypefnx {Function File} {} validateLengthUnit (@var{unit}, @var{func}) ## @deftypefnx {Function File} {} validateLengthUnit (@var{unit}, @var{func}, @var{name}) ## @deftypefnx {Function File} {} validateLengthUnit (@var{unit}, @var{func}, @var{name}, @var{ind}) ## Check validity and standardize unit of length. ## ## Confirms that the argument @var{input} is a valid length unit as ## described on the table below, and returns a string with its standard ## name. If @var{unit} is not a valid length unit, throws an error with ## a message following the Octave guidelines. For a more informative error ## message, the function name @var{func}, the argument name @var{name}, ## and its position in the input @var{ind} can be defined. ## ## @table @asis ## @item @qcode{"meter"} ## m, meter(s), metre(s) ## ## @item @qcode{"centimeter"} ## cm, centimeter(s), centimetre(s) ## ## @item @qcode{"millimeter"} ## mm, millimeter(s), millimetre(s) ## ## @item @qcode{"micron"} ## micron(s) ## ## @item @qcode{"kilometer"} ## km, kilometer(s), kilometre(s) ## ## @item @qcode{"nautical mile"} ## nm, naut mi, nautical mile(s) ## ## @item @qcode{"foot"} ## ft, international ft, foot, international foot, feet, international feet ## ## @item @qcode{"inch"} ## in, inch, inches ## ## @item @qcode{"yard"} ## yd, yds, yard(s) ## ## @item @qcode{"mile"} ## mi, mile(s), international mile(s) ## ## @item @qcode{"U.S. survey foot"} ## sf, survey ft, US survey ft, U.S. survey ft, survey foot, US survey foot, ## U.S. survey foot, survey feet, US survey feet, U.S. survey feet ## ## @item @qcode{"U.S. survey mile (statute mile)"} ## sm, survey mile(s), statute mile(s), US survey mile(s), U.S. survey mile(s) ## ## @item @qcode{"Clarke's foot"} ## Clarke's foot, Clarkes foot ## ## @item @qcode{"German legal metre"} ## German legal metre, German legal meter ## ## @item @qcode{"Indian foot"} ## Indian foot ## ## @end table ## ## @seealso{units, unitsratio, validateattributes, validatestring} ## @end deftypefn ## Author: Carnë Draug function std_unit = validateLengthUnit (unit, varargin) ## keep it persistent to save us the trouble of building the struct ## each time we are called persistent units = struct ( ## keys are all lowercase since the search must be case-insensitive "m", "meter", "meter", "meter", "meters", "meter", "metre", "meter", "metres", "meter", "cm", "centimeter", "centimeter", "centimeter", "centimeters", "centimeter", "centimetre", "centimeter", "centimetres", "centimeter", "mm", "millimeter", "millimeter", "millimeter", "millimeters", "millimeter", "millimetre", "millimeter", "millimetres", "millimeter", "micron", "micron", "microns", "micron", "km", "kilometer", "kilometer", "kilometer", "kilometers", "kilometer", "kilometre", "kilometer", "kilometres", "kilometer", "nm", "nautical mile", "naut mi", "nautical mile", "nautical mile", "nautical mile", "nautical miles", "nautical mile", "ft", "foot", "international ft", "foot", "foot", "foot", "international foot", "foot", "feet", "foot", "international feet", "foot", "in", "inch", "inch", "inch", "inches", "inch", "yd", "yard", "yds", "yard", "yard", "yard", "yards", "yard", "mi", "mile", "mile", "mile", "miles", "mile", "international mile", "mile", "international miles", "mile", "sf", "U.S. survey foot", "survey ft", "U.S. survey foot", "us survey ft", "U.S. survey foot", "u.s. survey ft", "U.S. survey foot", "survey foot", "U.S. survey foot", "us survey foot", "U.S. survey foot", "u.s. survey foot", "U.S. survey foot", "survey feet", "U.S. survey foot", "us survey feet", "U.S. survey foot", "u.s. survey feet", "U.S. survey foot", "sm", "U.S. survey mile (statute mile)", "survey mile", "U.S. survey mile (statute mile)", "survey miles", "U.S. survey mile (statute mile)", "statute mile", "U.S. survey mile (statute mile)", "statute miles", "U.S. survey mile (statute mile)", "us survey mile", "U.S. survey mile (statute mile)", "us survey miles", "U.S. survey mile (statute mile)", "u.s. survey mile", "U.S. survey mile (statute mile)", "u.s. survey miles", "U.S. survey mile (statute mile)", "u.s. survey mile (statute mile)", "U.S. survey mile (statute mile)", "clarke's foot", "Clarke's foot", "clarkes foot", "Clarke's foot", "german legal metre", "German legal metre", "german legal meter", "German legal metre", "indian foot", "Indian foot" ); ## Built start of error message from the extra optional arguments func_name = ""; arg_id = "input"; if (nargin > 1) second = varargin{1}; if (ischar (second)) func_name = [second ": "]; elseif (nargin == 2 && isindex (second)) arg_id = sprintf ("input #%i", second); else error ("validateLengthUnit: 2nd input argument must be IND or FUNC"); endif if (nargin > 2) arg_id = varargin{2}; if (! ischar (arg_id)) error ("validateLengthUnit: NAME must be a string"); endif if (nargin > 3) arg_ind = varargin{3}; if (! isindex (arg_ind)) error ("validateLengthUnit: IND must be a positive integer"); endif arg_id = sprintf ("%s (argument #%i)", arg_id, arg_ind); endif endif endif if (! ischar (unit)) ## if it's not a string, error message must be different error ("%s%s must be a string", func_name, arg_id); endif lunit = tolower (unit); if (isfield (units, lunit)) std_unit = units.(lunit); else error ("%sunknown unit `%s' for %s", func_name, unit, arg_id); endif endfunction %!error validateLengthUnit ("bad", 7) %!error validateLengthUnit ("bad", "foo") %!error validateLengthUnit ("bad", "foo", "ARG") %!error validateLengthUnit ("bad", "foo", "ARG", 7) %!error validateLengthUnit (9) %!error validateLengthUnit (9, 7) %!error validateLengthUnit (9, "foo") %!error validateLengthUnit (9, "foo", "ARG") %!error validateLengthUnit (9, "foo", "ARG", 7) ## typical usage and case insensitivity %!assert (validateLengthUnit ("m"), "meter") %!assert (validateLengthUnit ("meter"), "meter") %!assert (validateLengthUnit ("meters"), "meter") %!assert (validateLengthUnit ("mETErs"), "meter") ## names with spaces and dots %!assert (validateLengthUnit ("us survey feet"), "U.S. survey foot") %!assert (validateLengthUnit ("US survey feet"), "U.S. survey foot") %!assert (validateLengthUnit ("U.S. survey feet"), "U.S. survey foot") %!assert (validateLengthUnit ("u.s. survey feet"), "U.S. survey foot") ## names with apostrophes %!assert (validateLengthUnit ("clarke's foot"), "Clarke's foot") mapping-1.2.1/inst/PaxHeaders.3513/deg2km.m0000644000000000000000000000013212655504456015136 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.556993044 30 ctime=1454803247.144995051 mapping-1.2.1/inst/deg2km.m0000644000175000017500000000362712655504456017776 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2013 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{km} =} deg2km (@var{deg}) ## @deftypefnx {Function File} {@var{km} =} deg2km (@var{deg}, @var{radius}) ## @deftypefnx {Function File} {@var{km} =} deg2km (@var{deg}, @var{sphere}) ## Convert angle to distance. ## ## Calculates the distances @var{km} in a sphere with @var{radius} (also in ## kilometers) for the angles @var{deg}. If unspecified, radius defaults to ## 6371, the mean radius of Earth. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2deg} ## @end deftypefn ## Author: Alexander Barth function km = deg2km (deg, radius = "earth") if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) radius = spheres_radius (radius); elseif (! isnumeric (radius) || ! isscalar (radius)) error ("deg2km: RADIUS must be a numeric scalar"); endif km = (deg * pi * radius) / 180; endfunction %!assert (km2deg (deg2km (10)), 10) %!assert (km2deg (deg2km (10, 80), 80), 10) %!assert (km2deg (deg2km (10, "pluto"), "pluto"), 10) mapping-1.2.1/inst/PaxHeaders.3513/distance.m0000644000000000000000000000013212655504456015557 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/distance.m0000644000175000017500000000637312655504456020420 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2004 Andrew Collier ## Copyright (C) 2011 Alexander Barth ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} [@var{dist},@var{az}] = distance(@var{pt1}, @var{pt2}) ## @deftypefnx {Function File} {} [@var{dist},@var{az}] = distance(@var{pt1}, @var{pt2},@var{units}) ## @deftypefnx {Function File} {} [@var{dist},@var{az}] = distance(@var{lat1},@var{lon1},@var{lat2},@var{lon2}) ## @deftypefnx {Function File} {} [@var{dist},@var{az}] = distance(@var{lat1},@var{lon1},@var{lat2},@var{lon2},@var{units}) ## ## Calculates the great circle distance @var{dist} between @var{pt1} and @var{pt2} and optionally the azimuth @var{az}. ## @var{pt1} and @var{pt2} are two-column matrices of the form [latitude longitude]. ## The coordinates can also be given by the parameters @var{lat1}, @var{lon1}, @var{lat2} and @var{lon2}. ## Units can be either 'degrees' (the default) or 'radians'. ## ## ## @example ## >> distance([37,-76], [37,-9]) ## ans = 52.309 ## >> distance([37,-76], [67,-76]) ## ans = 30.000 ## >> distance(0,0, 0,pi,'radians') ## ans = 3.1416 ## @end example ## ## @seealso{azimuth,elevation} ## @end deftypefn ## Author: Andrew Collier ## Adapted-by: Alexander Barth ## Uses "cosine formula". function [dist,az] = distance(varargin) ## default units are degrees units = 'degrees'; [reg,prop] = parseparams(varargin); if length(reg) == 2 pt1 = reg{1}; pt2 = reg{2}; a = pt1(:,1); b = pt2(:,1); C = pt2(:,2) - pt1(:,2); elseif length(reg) == 4 a = reg{1}; b = reg{3}; C = reg{4} - reg{2}; else error('Wrong number of type of arguments'); end if length(prop) == 1 units = prop{1}; if (~strcmp(units,'degrees') && ~strcmp(units,'radians')) error('Only degrees and radians are allowed as units'); end elseif length(prop) > 1 error('Wrong number of type of arguments'); end if (strcmp(units,'degrees')) a = deg2rad(a); b = deg2rad(b); C = deg2rad(C); end dist = acos(sin(b) .* sin(a) + cos(b) .* cos(a) .* cos(C)); if (strcmp(units,'degrees')) dist = rad2deg(dist); end if nargout == 2 az = atan2(sin(C) , cos(a) .* tan(b) - sin(a) .* cos(C) ); ## bring the angle in the interval [0 2*pi[ az = mod(az,2*pi); ## convert to degrees if desired if (strcmp(units,'degrees')) az = rad2deg(az); end end endfunction %!assert(distance([37,-76], [37,-9]), 52.30942093, 1e-7) %!test %! [d,az] = distance(0,0, 0,pi,'radians'); %! assert(d,pi,1e-7) %! assert(az,pi/2,1e-7) mapping-1.2.1/inst/PaxHeaders.3513/makesymbolspec.m0000644000000000000000000000013212655504456017003 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/makesymbolspec.m0000644000175000017500000001701612655504456021640 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{symspec} =} makesymbolspec (@var{geometry}, @var{rule#1}...@var{rule#n}) ## @deftypefnx {Function File} {@var{symspec} =} makesymbolspec (@var{geometry}, @{"Default", @var{property1}, @var{value1}, ...@}) ## @deftypefnx {Function File} {@var{symspec} =} makesymbolspec (@var{geometry}, @{@var{attr}, @var{attval}, @var{Property1}, @var{Value1}, ...@}) ## Create a symbol specification structure for use with mapshow. ## ## Each symbolspec refers to one geometry type. @var{geometry} can be one of ## "Point", "MultiPoint", "Line", "PolyLine", "Polygon", or "Patch". ## The following argument(s) are rules. Each rule is a separate cell array. ## The first entry of a rule must be the string "Default" of an attribute/value ## pair. The attribute @var{attr} should conform to the attributes of the map ## feature to be drawn with the symbolspec; often these are the attributes of ## shapefiles. The value @var{attval} can be a: ## ## @itemize ## @item ## Numeric value or range of values (row vector). Map features with ## attribute @var{attr} values equal to, or in the range @var{ATTVAL} (end ## points inclusive) will be drawn with the propety/value pairs in the rest ## of the rule. These include X and Y coordinates. ## ## @item ## Logical value. The map features with values for attribute @var{attr} ## equal to @var{attval} will be drawn with the propety/value pairs in the ## rest of the rule. ## ## @item ## Character string. Those map features with @var{attr} text strings ## corresponding to @var{attval} will be drawn with the propety/value pairs ## in the rest of the rule. ## @end itemize ## ## In case of oct-type structs (see shaperead.m) additional attributes are ## available: ## ## @table @code ## @item X ## @itemx Y ## @itemx Z ## @itemx M ## X, Y, Z or M-values of vertices of polylines / polygons / multipatches are ## used to indicate the matching shape features are to be drawn. A matching ## value of just one sigle vertex of poit in the specified range suffices to ## match a shape feature. ## ## @item npt ## npt encodes for the number of vertices for each multipoint, polygon, ## polyline or multipatch shape feature in the original shapefile. ## ## @item npr ## npr encodes for the number of parts of each shape feature. ## @end table ## ## The property/value pairs for each rule should conform to the geometry type. ## That is, for (Multi)Point features only marker properties may be specified, ## similarly for Lines/Polylines (line properties) and Polygons/Patches (patch ## and fill properties). ## ## The case of input geometries and properties does not matter; makesymbolspec ## will turn them into the "official" casing. ## ## @example ## symsp1 = makesymbolspec ("Line", @{"TAG1", "road", ... ## "color", "b"@}) ## (draw polylines tagged "road" as blue lines) ## @end example ## ## @example ## symsp2 = makesymbolspec ... ## ("Line", @{"TAG1", "road", "color", "b", ... ## "linestyle", "-", "linewidth", 3@} ... ## @{"TAG1", "rail", "color", ... ## [0.7 0.5 0.2], ... ## "linestyle", "--", "linewidth", 2@}) ## (like above, but with polylines tagged "rail" as dashed ## light brown lines) ## @end example ## ## @example ## symsp3 = makesymbolspec ## ("Polygon", @{"M", [ 0 10], "Facecolor", "c"@}, ... ## @{"M", [10.01 20], "Facecolor", "b"@}, ... ## @{"M", [20.01 30], "Facecolor", "m"@}) ## (Note: only possible with oct-style shapestructs; create a ## symbolspec using M-values in three classes) ## @end example ## ## @seealso{mapshow, geoshow} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2015-01-05 ## Updates: ## 2015-01-10 Input checks; allow multiple properties per rule; add tests ## 2015-01-13 More error checks ## 2015-02-11 Improve graphics properties checks function [symspec] = makesymbolspec (geom, varargin) ## Input validation if (nargin < 2 || ! ischar (geom) || ! iscell (varargin)) print_usage; endif ## ML-compatible properties geometries = { "Point", "MultiPoint", "Line", "Polyline", "Polygon", ... "Patch"}; pt_properties = {"Marker", "Color", "LineStyle", "MarkerEdgeColor", ... "MarkerFaceColor", "MarkerSize", "Visible"}; pl_properties = {"Color", "LineStyle", "LineWidth", "Visible"}; pg_properties = {"FaceColor", "FaceAlpha", "LineStyle", "LineWidth", ... "EdgeColor", "EdgeAlpha", "Visible"}; ## Create cell structure idx = ismember (lower (geometries), lower (geom)); if (any (idx)) symspec = geometries (find (idx)); else error ("makesymbolspec: unknown Geometry: %s\n", geom); endif ## Check varargin for ii=1:numel (varargin) ## Select properties set for Geometry at hand switch lower (geom) case {"point", "multipoint"} templ_props = pt_properties; case {"line", "polyline"} templ_props = pl_properties; case {"polygon", "patch"} templ_props = pg_properties; otherwise endswitch ## Get attribute att = varargin{ii}{1}; if (! ischar (att)) error ("makesymbolspec: attribute name expected for rule $%d\n", ii); elseif (strcmpi (att, "default")) rule = {"Default", 0}; props = varargin{ii}(2:end); else rule = {att, varargin{ii}{2}}; props = varargin{ii}(3:end); endif ## Check properties try props = reshape (props, 2, []); ## Eliminate unrecognized property/value pairs illp = find (! ismember (lower (props(1,:)), lower (templ_props))); if (any (illp)) warning ("makesymbolspec.m: properties '%s' for geometry '%s' ignored\n", ... strjoin (props(1, illp), "' | '"), geom); props(:, illp) = []; endif ## Replace properties by official case, just to be sure props (1, :) = templ_props (find (ismember (lower (templ_props), ... lower (props(1,:))))); ## Reshape varargin back. We trust the user-supplied values to be OK rule = {rule{:} props{:}}; symspec(end+1) = {rule}; catch if (rem (size (varargin{ii}(3:end), 1), 2) != 0) error ("makesymbolspec: a property or value missing in rule #%d\n", ii); else error ("makesymbolspec: uncomprehensible input in rul #%d\n", ii); endif end_try_catch endfor endfunction %!test %% Illegal graphics properties & case of properties %! ssp = makesymbolspec ("Line", {"LENGTH", [100 150], "color", "b", ... %! "nonsense", "?", "lineWidth", 3, "markersize", "BS", "Visible", 1}); %! assert (reshape (ssp{2}(3:end), 2, [])(1, :), {"Color", "LineWidth", ... %! "Visible"}); %! assert (ssp{1}, "Line"); mapping-1.2.1/inst/PaxHeaders.3513/shapedraw.m0000644000000000000000000000013212655504456015743 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/shapedraw.m0000644000175000017500000006726212655504456020610 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014,2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} [@var{h}] = shapedraw (@var{shp}) ## @deftypefnx {Function File} [@var{h}] = shapedraw (@var{shp}, @var{clr}) ## @deftypefnx {Function File} [@var{h}] = shapedraw (@var{shp}, @var{clr}, ...) ## @deftypefnx {Function File} [@var{h}] = shapedraw (@var{shp}, ...) ## Plot contents of a shapefile, a map-/geostruct or a struct made by ## shaperead.m. ## ## @var{shp} can be a shapefile (will be read and plotted), a struct made by ## shaperead, or a mapstruct or geostruct, possibly made by some other ## function. shapeplot.m will try to determine the type. Points, MultiPoints, ## Polylines, Polygons and MultiPatch shape features can be plotted. ## ## The optional argument @var{clr} can be a predefined color name ('b', 'green', ## etc.) or an RGB triplet. The default is [0.6, 0.6, 0.6] which produces a ## grey plot. Polygons and MultiPatches can also be plotted as solid patches; ## then @var{clr} needs to have a second row indicating the fill color. Octave ## does not support transparent fills yet. Single-character color codes can be ## combined with linestyle indicators ":", "-", "--", "-.", ".-" and/or marker ## style indicators ## "*", ".", "+", "@@", "v", "^", ">", "<", "d", "h", "o", "p", "s" ## to modify the linestyle for polylines. ## ## Other graphics properties for drawing can be supplied either instead of, ## or after the color argument and will be conveyed as-is to the actual drawing ## routines. Depending on shapetype, the following proqperties are accepted: ## ## @itemize ## @item All shape types: ## Visible, LineStyle, LineWidth, Marker, MarkerEdgeColor, MarkerFaceColor, ## MarkerSize ## ## @item Point, MultiPoints, Line, Polyline: ## Color ## ## @item Polygon, MultiPatch: ## FaceColor, EdgeColor ## @end itemize ## ## Polygons with holes can be properly plotted provided the holes are separate ## shape feature parts comprising counterclockwise polylines; the first partial ## feature must be the clockwise outer polygon. The Octave-Forge geometry ## package is required to assess whether multipart polygons have holes and to ## properly draw them. shapedraw.m will search for the geometry package the ## first time it is instructed to plot filled polygons. To initiate a new ## search later on (e.g., after the geometry package has been loaded), simply ## invoke shapedraw without any arguments. ## ## Optional output argument @var{h} is the figure handle of the plot. ## ## @seealso{geoshow, mapshow, shapeinfo, shaperead} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-11-15 ## Updates: ## 2014-11-15 First draft ## 2014-11-17 Add support for geostructs ## 2014-11-29 Solid fill (patches) ## 2014-12-16 Solid fill (polygons) with holes ## 2014-12-17 MultiPatch plots (3D) ## 2014-12-18 3D Points/Polylines/-gons ## 2014-12-30 Transpose npr values for MultiPatch prior to drawing patches ## 2015-01-01 Fix function name in error message ## 2015-01-06 Improve plotting of polygons with holes - optimize branch cuts ## 2015-01-07 Largely rewritten; ## - Combined line and patch sections into one switch ## - More rigorous checks on input parameters ## 2015-01-08 More rewrites, better input checks ## '' Allow marker indicators for (multi)point ## 2015-01-09 Add code to check if individual polygon parts are holes (not all) ## '' Improve code for single color code/stle arguments ## 2015-01-10 Renamed to shapedraw.m (shapeplot is already in OF-geometry) ## '' Fixed argument checking for "color" property (swapping if checks) ## 2015-01-20 Change "color" to "edgecolor" for multipatch ## '' Add undocumented "center" argument to cope with large coordinates ## (OpenGL chokes there as it only works with single precision) ## 2015-01-21 Apply varargin to 3D-patches using "set" command ## '' Simplify input args, eliminate "clr" arg ## '' Support for extended mapstructs ## 2015-01-24 Restructured a bit, debugged MultiPatch drawing ## 2015-01-27 Texinfo header, check on Z-values ## 2015-01-30 Simplify ML style struct test; allow Point types (no BoundingBox) ## 2015-01-31 Fix wrong indexing in MultiPatch-triangle processing ## 2015-02-03 Swap checks for first color arg and graphics properties ## 2015-02-04 Check for Z and make it a column vector before calling plot3 ## '' Morefixes for color argument checks ## 2015-02-11 Eliminate duplicate code, move to subfunc chk_props ## 2015-02-17 Markerstyle => Marker in point draw switch stmt ## '' Don't reshape back args in chk_props subfuc ## '' Improve checks for default color ## 2015-04-19 Make warning state changes local ## 2015-07-10 Add try-catch around varargin reshape to catch wrong input ## '' Simplify polygon plot code ## '' Fix 3D-plotting for "extended" map/geostructs ## 2015-12-27 Improve speed of drawing many polygons ## 2015-12-30 Improve multipatch drawing speed function [h] = shapedraw (shpf, varargin) ## Keep track of OF geometry package presence persistent ofgeom = []; ## What this function does in what order: ## 1. Input checks & analysis. ## Get a struct & assess its type; or read data from .shp file set. ## 2. Morph XY[Z} in a suitable form for faster plotting (avoid for loops). ## On the way, explore multipart polygons and if found, get separators. ## 3. Process input args; first of all marker/line & fill colors & style. ## A bit involved as there are many interfering options. ## 4. Find out if plot is on top of existing figure or must be a new figure. ## 5. Depending on geometry type, draw the shape features. ## For Polygons, explore and process "holes". ## FIXME Holes must be implemented for Multipatch as well - pending ## 1. Input checks & analyses if (nargin < 1) if (! isempty (ofgeom)) ## Reset ofgeom ofgeom = []; return; endif print_usage () endif if (isempty (shpf)) ## Nothing to plot return; if (isempty (varargin)) ## Supply default color varargin = {[0.6, 0.6, 0.6]}; endif elseif (isstruct (shpf)) ## Yep. Find out what type fldn = fieldnames (shpf); if (ismember ("vals", fldn) && ismember ("shpbox", fldn)) ## Assume it is an Octave-style struct read by shaperead type = 0; elseif (all (ismember ({"Geometry", "X", "Y"}, fldn))) ## Assume it is a Matlab-style mapstruct type = 1; elseif (all (ismember ({"Geometry", "Lat", "Lon"}, fldn))) ## Assume it is a Matlab-style geostruct type = 2; else ## Not a supported struct type error ("shapedraw: unsupported struct type.\n") endif elseif (ischar (shpf)) ## Filename? let's see: [pth, fnm, ext] = fileparts (shpf); if (isempty (ext) || ! strcmpi (ext, ".shp")) ## Just add a .shp suffix shpf = [shpf ".shp"]; endif fid = fopen (shpf); if (fid < 0) error ("File %s not found", shpf); else fclose (fid); endif ## Read shapefile in ML style into mapstruct shpf = shaperead (shpf, 1); type = 1; else error ("struct name of file name expected"); endif ## 2. Morph XY[Z} data in a suitable form for fastest plotting ## Prepare XY plot. Get vertices & prepare some geometry data mp = []; if (type == 0) ## Octave style with intermediate NaN rows. Easy except MultiPatch geom = shpf.vals(1, 6); X = shpf.vals(:, 1); Y = shpf.vals(:, 2); Z = shpf.vals(:, 3); ## Find multipart shape features to be able to plot polygons with holes if (ismember (shpf.vals(1, 6), [5 15 25 31])) ## Yep we have polygons jdx = [ 0 find(isnan (shpf.vals(:, 1))') ] + 1; idx = shpf.idx'; if (numel (jdx) > numel (idx)) ## Multipart features present. Find them mp = find (diff (find (ismember (jdx, idx))) - 1); ## The last feature is a bit special... if (jdx(end) > idx(end)) mp = [ mp numel(idx) ]; endif endif npr = shpf.npr; endif elseif (type == 1 || type == 2) ## Matlab struct type switch lower (shpf(1).Geometry) case "point" geom = 1; case "multipoint" geom = 8; case {"polyline", "line"} geom = 3; case "polygon" geom = 5; case "multipatch" geom = 31; otherwise endswitch tmp = cell (1, 2*numel (shpf)); if (type == 1) ## mapstruct. Needs some preparation: insert a NaN after each subshape [tmp(1:2:2*numel(shpf))] = deal ({shpf.X}); [tmp(2:2:2*numel(shpf)-1)] = NaN; X = [tmp{:}]; [tmp(1:2:2*numel(shpf))] = deal ({shpf.Y}); [tmp(2:2:2*numel(shpf)-1)] = NaN; Y = [tmp{:}]; else ## geostruct. Needs some preparation: insert a NaN after each subshape [tmp(1:2:2*numel(shpf))] = deal ({shpf.Lon}); [tmp(2:2:2*numel(shpf)-1)] = NaN; X = [tmp{:}]; [tmp(1:2:2*numel(shpf))] = deal ({shpf.Lat}); [tmp(2:2:2*numel(shpf)-1)] = NaN; Y = [tmp{:}]; endif ## For "extended" (not strictly ML-compatible) mapstructs: if (isfield (shpf, "Z")) ## Give it a try. Could be one Z per shape, rather than one per vertex ## if Z values came in from xBase (dbf) rather than .shp [tmp(1:2:2*numel(shpf))] = deal ({shpf.Z}); [tmp(2:2:2*numel(shpf)-1)] = NaN; Z = [tmp{:}]; ## Check nr. of Z values if (numel (Z) == numel (X)) ## Z values apparently originate from .shp if (isfield (shpf, "Parts")) ## Multipatch. Get Parts (contains multipatch subtypes) geom = 31; npr = {shpf.Parts}; else ## Bump shape type to Z-type equivalent. Could've been 1/3/5/8 or 23... geom = mod (geom, 10) + 10; endif else Z = []; endif else Z = []; endif ## Find multipart shape features to be able to plot polygons with holes if (mod (geom, 10) == 5 || geom == 31) ## Polygons jdx = [ 0 find(isnan (X)) ] + 1; ## A little trick.... idx = [ 0 (cumsum (cellfun (@(x) numel(x), {shpf(1:end-1).X})) + ... cumsum (ones (1, numel (shpf) - 1))) ] + 1; if (numel (jdx) > numel (idx)) ## Multipart features present. Find them mp = find (diff (find (ismember (jdx, idx))) - 1); ## The last feature is a bit special... if (jdx(end) > idx(end)) mp = [ mp numel(idx) ]; endif endif endif endif ## Check for "verbose" arg verbose = find (strncmpi (varargin, "ver", 3)); varargin (verbose) = []; verbose = ! isempty (verbose); ## If requested, reduce coordinates (subtract means). May help to get better ## plots for large coordinates as OpenGL (w. single accuracy) fouls those up center = find (strncmpi (varargin, "cen", 3)); varargin (center) = []; if (! isempty (center)) X -= mean (X(isfinite (X))); Y -= mean (Y(isfinite (Y))); if (ismember (geom, [13, 15, 18, 31])) Z -= mean (Z(isfinite (Z))); endif endif ## 3. Process input args; mainly marker/line & fill colors ## Predefine some properties to be able to check later pt_properties = {"Marker", "Color", "LineStyle", "MarkerEdgeColor", ... "MarkerFaceColor", "MarkerSize", "Visible"}; pl_properties = {"Color", "LineStyle", "LineWidth", "Visible"}; pg_properties = {"FaceColor", "FaceAlpha", "LineStyle", "LineWidth", ... "EdgeColor", "EdgeAlpha", "Visible"}; color_codes = { ... "b", "k", "c", "g", "m", "y", "w", "r", "blue", "black", "cyan", "green", ... "magenta", "yellow", "white", "red", "blue"}; clrptn = [ '(^[kbcgmprwy](--|\.-|-\.|[:\-osdhv^<>*\.\+@])' '|' ... '^([:\-osdhv^<>*\.\+@]|--|\.-|-\.)[bcgkmprwy])' ]; ## Check color arg ## FIXME support for colormaps would be great... if (isempty (varargin)) ## Restore default color if (ismember (geom, [5, 15, 25, 31])) ## polygons and multipatches varargin = {"facecolor" [0.6 0.7 0.9] "edgecolor" [0.5, 0.5, 0.5]}; else varargin = { "color" [0.6, 0.6, 0.6] }; endif elseif (ischar (varargin{1})) ## Check if arg#1 is a color code if (ismember (varargin{1}(1, :), color_codes) || ! isempty (cell2mat (regexp (varargin{1}(1, :), clrptn, "match")))) ## Color OK clrtyp = 1; if (size (varargin{1}, 1) == 1 && ... (size (varargin{1}, 2) == 2 || size (varargin{1}, 2) == 3)) ## Line- or markerstyle color. Draw polygons as polylines ([3/13/23] if (ismember (geom, [5, 15, 25])) geom -= 2; endif elseif (ismember (geom, [5, 15, 25, 31])) colr = varargin{1}; varargin(1) = []; varargin = {"edgecolor" colr(1, :) varargin{:}}; if (size (colr, 1) > 1) varargin = {"facecolor" colr(2, :) varargin{:}}; endif else varargin = {"color" varargin{1}(1, :) varargin{2:end}}; endif ## Check if it's a graphics property elseif (ismember (lower (varargin{1}(1, :)), lower (unique ([pt_properties, ... pl_properties, pg_properties])))) ## Yes. Do some checks if (numel (varargin) > 1) props = lower ({reshape(varargin, 2, []){1, :}}); endif gr_props_ok = ismember (props, ... unique (lower ([pt_properties pl_properties pg_properties]))); if (! all (gr_props_ok)) warning ("shapedraw: unknown graphics properties\n") endif ## Restore default color if required if (ismember (geom, [5, 15, 25, 31])) if (! ismember ("facecolor", props)) ## Introduce polygon edge/face colors varargin = { varargin{:} "facecolor" [0.5 0.7 0.9]}; endif if (! ismember ("edgecolor", props)) ## Introduce polygon edge/face colors varargin = { varargin{:} "edgecolor" [0.6, 0.6, 0.6]}; endif elseif (! any (ismember ({"color", "markeredgecolor"}, props))) varargin = { "color", [0.6, 0.6, 0.6], varargin{:} }; endif else error ("shapedraw: incomprehensible arg#1: %s\n", varargin{1}); endif elseif (isnumeric (varargin{1})) ## Assume it's a color RGB triplet, or array of triplets if (size (varargin{1}, 2) != 3) ## Too few or too many error ("shapeplot: incomprehensible argument #2\n"); else if (ismember (geom, [5, 15, 25, 31])) if (size (varargin{1}, 1) < 2) varargin{1}(2, :) = [0.5 0.7 0.9]; endif varargin = {"edgecolor", varargin{1}(1, :) "facecolor" varargin{1}(2, :)}; else varargin = {"color" clr(1, :) varargin{:}}; endif endif endif ## 4. Find out if plot is on top of existing figure or must be a new figure hh = ishold (); ## ishold automatically creates an empty figure if none found hold ("on"); if (nargout > 0) h = get (gcf); endif ## 5. Depending on geometry type, draw the shape features ## For each shape type check drawing options if (numel (varargin) > 1) try varargin = reshape (varargin, 2, []); catch varargin error ("shapedraw.m: ^^^^ looks like invalid drawing properties were entered"); end_try_catch endif switch geom case {1, 21, 8, 28} ## (Multi-)Points[M] varargin = chk_props (varargin, pt_properties, color_codes, clrptn, "(Multi)Point"); ## Check for some marker style or marker color code (latter always arg #1) if (! ismember ("marker", lower (varargin(1, :))) && ... ! ismember (varargin(1), color_codes)) varargin = { "marker", "." varargin{:} }; endif plot (X, Y, varargin{:}); case {11, 18} ## (Multi-)PointsZ varargin = chk_props (varargin, pt_properties, color_codes, clrptn, "(Multi)PointZ"); ## Check for some marker style or marker color code (latter always arg #1) if (! ismember ("marker", lower (varargin(1, :))) && ... ! ismember (varargin(1), color_codes)) varargin = {"marker", "." varargin{:} }; endif plot3 (X, Y, Z, varargin{:}); case {3, 13, 23} ## Polylines varargin = chk_props (varargin, pl_properties, color_codes, clrptn, "(Poly)Lines"); ## Make sure we have an Nx2 matrix X = [X(:)]; Y = [Y(:)]; if (geom == 13 && ! isempty (Z)) Z = [Z(:)]; plot3 (X, Y, Z, varargin{:}); else Z = []; plot (X, Y, varargin{:}); endif case {5, 15, 25} ## Polygons varargin = chk_props (varargin, pg_properties, color_codes, clrptn, "Polygons"); ## Make sure we have an Nx2 matrix X = [X(:)]; Y = [Y(:)]; if (! isempty (Z)) Z = [Z(:)]; endif idx = [ idx (numel(X)+2) ]; ## Check for holes in multipart poygon. Outer polygon must be clockwise has_holes = 0; ## Check if we have the OF geometry pacakage loaded if (isempty (ofgeom)) ofgeom = ! isempty (which ("polygonArea")); if (! ofgeom) warning ("shapedraw: function 'polygonArea' not found.\n"); printf (" (OF geometry package installed and loaded?)\n"); printf (" => Holes in polygons will be filled\n"); endif endif ipt = [ 0; (find (isnan (X))); (numel (X) + 1) ]; if (ofgeom && ! isempty (mp)) hdx = cell (mp, 1); ## Search multipart polygons for holes, backwards to save mp order for ii=numel(mp):-1:1 ## Depending on struct type, get shape feature XT = X(idx(mp):idx(mp+1)-2); YT = Y(idx(mp):idx(mp+1)-2); jpt = [ 0; (find (isnan (XT))); (numel (XT) + 1) ]; ## Check for hole h_idx = []; for jj=2:numel (jpt) - 1 ## A clockwise polygon has area < 1, counterclockwise > 1 hole = (polygonArea (XT(jpt(jj)+1:jpt(jj+1)-1), ... YT(jpt(jj)+1:jpt(jj+1)-1)) > 1); has_holes = has_holes || hole; if (hole) h_idx = [ h_idx jj ]; endif endfor if (isempty (h_idx)) mp(ii) = []; else hdx(mp) = h_idx; endif endfor endif ## Draw polygon parts one by one if (! ofgeom || isempty (mp)) ## If no holes can be left open, draw each feature part separately idx = [ jdx (numel(X)+2) ]; endif ## Prepare 'faces' argument for patch faces = NaN (numel(idx)-1, max (diff (find (isnan ([NaN; X; NaN]))))); for ii=1:numel (idx) - 1 XT = X(idx(ii):idx(ii+1)-2); YT = Y(idx(ii):idx(ii+1)-2); if (! isempty (Z)) ZT = Z(idx(ii):idx(ii+1)-2); endif if (has_holes && ofgeom && ismember (ii, mp)) ## To be able to not fill holes in polygons we need a trick. That ## comprises connecting the holes to the outline through "branch ## cuts" that do not run across other holes or even the outline. ## To obtain the latter we need to find optimal locations for the ## vertices on both ends of the branch cut. [XT, YT, ZT] = optimize_branch_cuts (XT, YT, hdx{ii}); X(idx(ii):idx(ii+1)-2) = XT; Y(idx(ii):idx(ii+1)-2) = YT; if (! isempty (Z)) Z(idx(ii):idx(ii+1)-2) = ZT; endif faces (ii, 1:numel(XT)) = [1:numel(XT)] + idx(ii) - 1; else faces (ii, 1:numel(XT)) = [idx(ii):idx(ii+1)-2]; endif endfor if (geom == 5) p_h = patch ("vertices", [X Y], "faces", faces, ... "facecolor", "none", "edgecolor", "none"); else p_h = patch ("vertices", [X Y Z], "faces", faces, ... "facecolor", "none", "edgecolor", "none"); endif set (p_h, varargin{:}); case {31} ## MultiPatch ## Multipatch. Process individual subfeatures one by one ## First check drawing options varargin = chk_props (varargin, pg_properties, color_codes, clrptn, ... "MultiPatch"); ## Add a NaN row index so below loops will work up to max loop counter idx = [ idx numel(X)+2 ]; if (verbose) printf ("\n"); endif ## Make sure we have column vectors X = [X(:)]; Y = [Y(:)]; Z = [Z(:)]; ## Init patch 'faces' ptrs. First find out nr. of triangle strips/fans prts = [shpf.Parts]; it = find (prts(2, :) <= 1); ## Preallocate 'faces' argument for subfeature patches. faces = NaN (size (prts, 2), max (diff (prts(1, :))-1)); clear prts; ## can be large ipf = 0; ## ptr into faces for jj=1:numel (npr) ## For each feature sep = [ (npr{jj}(1, :)) (diff (idx)(jj)) ]; ibase = idx(jj) - 1; lastyp = []; for ii=1:size (npr{jj}, 2) ## For each subfeature if (verbose) printf ("Shape part %d, subpart %d\r", jj, ii); endif switch npr{jj}(2, ii) case 0 ## Triangle strip faces(++ipf, 1:3) = [sep(ii)+1:sep(ii)+3] + ibase; ## Each following point forms next triangle with previous two. for kk=sep(ii)+4:sep(ii+1)-1 faces(++ipf, 1:3) = [kk-2:kk] + ibase; endfor lastyp = 0; case 1 ## Triangle fan faces(++ipf, 1:3) = [sep(ii)+1:sep(ii)+3] + ibase; ## Each following point forms next triangle with first and last ## points for kk=sep(ii)+4:sep(ii+1)-1 faces(++ipf, 1:3) = [1 kk-1:kk] + ibase; endfor lastyp = 1; case 2 ## Outer ring ## FIXME Plotting holes hasn't been implemented yet for MultiPatch # (although it seems to work with files found in the wild) faces(++ipf, 1:(sep(ii+1)-sep(ii)-1)) = ... [sep(ii)+1:sep(ii+1)-1] + ibase; lastyp = 2; case 3 ## Inner ring ## FIXME Plotting holes hasn't been implemented yet for MultiPatch ## (although it seems to work with files found in the wild) ## FIXME untested code faces(++ipf, 1:(sep(ii+1)-sep(ii)-1)) = ... [sep(ii)+1:sep(ii+1)-1] + ibase; lastyp = 3; case 4 ## First ring ## FIXME untested code faces(++ipf, 1:(sep(ii+1)-sep(ii)-1)) = ... [sep(ii)+1:sep(ii+1)-1] + ibase; case 5 ## Ring ## FIXME untested code faces(++ipf, 1:(sep(ii+1)-sep(ii)-1)) = ... [sep(ii)+1:sep(ii+1)-1] + ibase; lastyp = 4; otherwise endswitch endfor vals = []; endfor ## Just to be sure, weed out Nan rows out of faces faces(isnan (faces(:, 1)), :) = []; if (! all (isnan (faces(:)))) p_h = patch ("vertices", [X Y Z], "faces", faces, ... "facecolor", "none", "edgecolor", "none"); set (p_h, varargin{:}); endif if (verbose) printf ("\n"); endif otherwise ## Other shape feature type? endswitch axis equal; if (! hh) hold ("off"); endif endfunction ##----------------------------------------------------------------------------- ## Copyright (C) 2015 Philip Nienhuis ## ## Optimize branch cuts for inner polygons (holes) function [XX, YY, ZZ, kdx, mdx] = optimize_branch_cuts (XX, YY, varargin); ## Check args #3 and #4 ZZ = []; hdx = {}; if (! isempty (varargin)) if (nargin == 3) ## Assume it's a hdx file indicating which subshapes are holes hdx = varargin{1}; elseif (nargin == 4) ## Assume they're Z coordinates ZZ = varargin{1}; hdx = varargin{2}; endif endif ## Also keep track of Z. Z isn't (yet) in the branch cut optimization (but ## that could be done easily) if (isempty (ZZ)) ## At least provide pointers where Z coordinates have gone in output arrays ZZ = [1:numel(XX)]'; endif XY = [ XX YY ZZ]; ## Find NAN separators ipt = [0; find(isnan (XX)); numel(XX)+1]; if (numel (ipt) < 3) ## No NaN separators => no subfeatures. Return return endif for ii=1:numel (ipt) - 1 XY(ipt(ii)+1:ipt(ii+1)-1, 4) = [ ipt(ii)+1:ipt(ii+1)-1 ]'; endfor if (isempty (hdx)) ## Assume all except first subfeatures are holes hdx = [ 2:numel(ipt)-1 ]; endif ## Silence broadcasting warning warning ("off", "Octave:broadcast", "local"); ## 1. Locate locate optimal branch cut vertices in outer and inner polygons ## FIXME Below we only relate holes to the outer polygon. That bears risk ## for inner holes shielded from the outer boundary by other holes. ## It's better to find the hole closest to the outer boundary, start ## there, and then successively process each hole in turn and find the ## smallest distance to either the outer polygon or already processed ## holes. Such a strategy is neither robust nor easily devised, however. for ii=2:numel (ipt) - 1 b1 = distancePoints (XY(ipt(1)+1:ipt(2)-1, :), XY(ipt(ii)+1:ipt(ii+1)-1, :)); [~, col(ii-1)] = min (min (b1)); [~, row] = min (b1(:, col(ii-1))); ## Copy vertices of outer polygon down to make room for marker XY(row+2:end+2, :) = XY(row:end, :); ## Add marker & pointer to inner polygon XY(row+1, 1) = Inf; XY(row+1, 2:3) = [ii ii]; ipt(2:end) += 2; endfor ## 2. ---- Insert inner polygons into outer ---- ## Update ipt ipt = [find(isnan (XY(:, 1))); size(XY, 1)+1]; jpt = [find(isinf (XY(:, 1))) ; ipt(1)]; XYXY = XY(1:jpt(1)-1, :); for ii=1:numel(jpt) - 1 ## First rotate inner polygon vertices. Closed polygon => no cirshift tmp = XY(ipt(ii)+1:ipt(ii+1)-1, :); tmp = [ tmp(col(ii):end-1, :) ; tmp(1:col(ii), :) ]; XYXY = [ XYXY ; tmp ]; XYXY = [ XYXY ; XY(jpt(ii)+1:jpt(ii+1)-1, :) ]; endfor XX = XYXY(:, 1); YY = XYXY(:, 2); if (nargout == 3) ZZ = XYXY(:, 3); endif endfunction ##----------------------------------------------------------------------------- ## Copyright (C) 2015 Philip Nienhuis ## ## Check graphics properties for various geometries function args = chk_props (args, properties, color_codes, clrptn, geometry) gr_props = ! ismember (lower (args(1, :)), [lower(properties) color_codes]); if (any (gr_props) && isempty (cell2mat (regexp (args(1, :), ... clrptn, "match")))) printf ("shapedraw: illegal drawing options for %s ignored\n", geometry); printf ("(%s)\n", strjoin (args(1, :)(gr_props))); else gr_props = []; endif args(:, gr_props) = []; endfunction mapping-1.2.1/inst/PaxHeaders.3513/geoshow.m0000644000000000000000000000013212655504456015440 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/geoshow.m0000644000175000017500000000401312655504456020266 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} geoshow (@var{shps}) ## @deftypefnx {Function File} geoshow (@var{shps}, @var{clr}) ## Plot a mapstruct created by shaperead. ## ## @var{shps} is the name of a geostruct created by shaperead. ## ## Optional argument @var{clr} can be a predefined color ("k", "c", etc.), an ## RGB triplet, or a 2 X 1 column vector of RGB triplets (each row containing ## a triplet). The uppermost row will be used for points and lines, the ## lowermost row for solid shape features (not yet implemented). ## ## @seealso{mapshow, shapedraw, shapeinfo, shaperead} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-11-17 based on a suggestion by Carnë Draug function geoshow (varargin) if (isshape (varargin{1})) ## Assume a shape struct plotshape (varargin{:}); axis equal; else error ("geoshow: plotting of non-shapes is not yet implemented\n") endif endfunction function retval = isshape (s) retval = false; ## Check if s is a recognized shape file struct; just a brief check if (isstruct (s)) ## Yep. Find out what type fldn = fieldnames (s); if (ismember ("Geometry", fldn) && ismember ("BoundingBox", fldn) && ... ismember ("Lon", fldn)) ## Assume it is a Matlab-style geostruct retval = true; endif endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/toRadians.m0000644000000000000000000000013212655504456015711 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/toRadians.m0000644000175000017500000000465512655504456020553 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{rad1}, @var{rad2}, @dots{}] =} toRadians (@var{toUnit}, @var{a1}, @var{a2}, @dots{}) ## Convert angles into radians. ## ## Converts any number of input arguments, @var{a1}, @var{a2}, @dots{} ## with angles in @var{fromUnit}, into radians. @var{fromUnit} may be ## @qcode{"radians"} or @qcode{"degrees"}. ## ## @example ## @group ## [rad1, rad2] = toRadians ("degrees", 180, [180 360]) ## @result{rad1} [ 3.1416 ] ## @result{rad2} [ 3.1416 6.2832 ] ## @end group ## @end example ## ## @seealso{deg2rad, fromDegrees, fromRadians, toDegrees, unitsratio} ## @end deftypefn ## Author: Carnë Draug function varargout = toRadians (fromUnit, varargin) if (nargin < 1) print_usage (); endif valid_unit = validatestring (fromUnit, {"radians", "degrees"}, "toRadians", "FROMUNIT"); switch (valid_unit(1)) case {"d"} varargout = cellfun (@deg2rad, varargin, "UniformOutput", false); case {"r"} varargout = varargin; endswitch endfunction %!test %! rad{1} = pi; %! rad{2} = [pi 2*pi]; %! rad{3} = [0 pi; 2*pi 0]; %! deg{1} = 180; %! deg{2} = [180 360]; %! deg{3} = [0 180; 360 0]; %! for i=1:3 %! assert (toRadians ("degrees", deg{i}), rad{i}) %! assert (toRadians ("radians", rad{i}), rad{i}) %! endfor %! %! ## test multiple angles same time %! assert (nthargout (1:3, @toRadians, "degrees", deg{:}), rad) %! assert (nthargout (1:2, @toRadians, "degrees", deg{:}), rad(1:2)) %! %! ## test abbreviations of degrees %! assert (nthargout (1:3, @toRadians, "degree", deg{:}), rad) %! assert (nthargout (1:3, @toRadians, "deg", deg{:}), rad) %! assert (nthargout (1:3, @toRadians, "d", deg{:}), rad) %!error toRadians ("INVALID") mapping-1.2.1/inst/PaxHeaders.3513/degrees2dm.m0000644000000000000000000000013212655504456016006 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/degrees2dm.m0000644000175000017500000000726512655504456020650 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} degrees2dm (@var{deg}) ## Convert decimal degrees to its degrees and minutes components. ## ## Separates the fractional part of an angle in decimal degrees and converts ## it into minutes. Each row of the output corresponds to one angle, ## the first column to the degree component (an integer), and the second ## to the minutes (which may have a fractional part). ## ## @example ## @group ## degrees2dm (10 + 20/60) ## @result{} [ 10 20 ] ## ## degrees2dm (10 + pi) ## @result{} [ 10 8.4956 ] ## @end group ## @end example ## ## The sign of the first non-zero component indicates the sign of ## the angle, i.e., if the degree component is zero, the sign of the minutes ## indicates the sign of the angle, but if the degree component is non-zero, ## the minute component will be positive independently of the sign of the ## angle. For example: ## ## @example ## @group ## angles = [ 10.5 ## -10.5 ## -0.5 ## 0.5 ]; ## degrees2dm (angless) ## @result{} ## 10 30 ## -10 30 ## -0 -30 ## 0 30 ## @end group ## @end example ## ## @seealso{degrees2dms, dm2degrees, dms2degrees} ## @end deftypefn ## Author: Carnë Draug function dm = degrees2dm (deg) if (nargin != 1) print_usage (); endif if (! iscolumn (deg)) warning ("Octave:array-to-vector", "degrees2dm: DEG reshaped into column vector"); endif if (isinteger (deg)) ## If the angles are integers, there is no decimal part ## so this is easy. Also, class must be conserved. dm = [deg(:) zeros(numel (deg), 1, class (deg))]; else ## Everything else is valid and will be converted to double (including ## text and logical). Only class single will be conserved. d = fix (deg(:)); m = rem (deg(:) * 60, 60); dm = [d m]; ## We could have also calculated the seconds part with ## (deg(:) - d) * 60 ## but while that performs almost twice as fast, it also ## leads to some precision errors. ## remove sign from any minute where its degree part is non-zero nnzd = logical (dm(:,1)); dm(nnzd, 2) = abs (dm(nnzd, 2)); endif endfunction %!test %! deg = [10 10.5 -10.5 -0.5 0.5]'; %! dm = [ 10 0 %! 10 30 %! -10 30 %! 0 -30 %! 0 30]; %! for i = 1:rows (deg) %! assert (degrees2dm (deg(i)), dm(i,:)); %! assert (degrees2dm (single (deg(i))), single (dm(i,:))); %! endfor %! assert (degrees2dm (deg), dm); %! assert (degrees2dm (single (deg)), single (dm)); %! %! warning ("error", "Octave:array-to-vector", "local") %! got_warn = false; %! try %! degrees2dm (deg'); %! catch %! got_warn = true; %! end_try_catch %! assert (got_warn, true) %!assert (degrees2dm ("f"), [102 0]) %!assert (degrees2dm ("fm"), [102 0; 109 0]) %!assert (degrees2dm (true), [1 0]) %!assert (degrees2dm ([true false]), [1 0; 0 0]) %!assert (degrees2dm (uint8 ([5 48 9]')), uint8 ([5 0; 48 0; 9 0])) mapping-1.2.1/inst/PaxHeaders.3513/azimuth.m0000644000000000000000000000013212655504456015446 xustar0030 mtime=1454803246.556993044 30 atime=1454803246.556993044 30 ctime=1454803247.144995051 mapping-1.2.1/inst/azimuth.m0000644000175000017500000000602012655504456020274 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2004 Andrew Collier ## Copyright (C) 2006 Alexander Barth ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} @var{az} = azimuth(@var{lat1},@var{lon1},@var{lat2},@var{lon2}) ## @deftypefnx {Function File} {} @var{az} = azimuth(@var{lat1},@var{lon1},@var{lat2},@var{lon2},@var{units}) ## @deftypefnx {Function File} {} @var{az} = azimuth(@var{pt1}, @var{pt2}) ## @deftypefnx {Function File} {} @var{az} = azimuth(@var{pt1}, @var{pt2},@var{units}) ## ## Calculates the great circle azimuth from a point 1 to a point 2. ## The latitude and longitude of these two points can either be given ## independently or as columns of the matrices @var{pt1} and @var{pt2} in ## the form [latitude longitude]. ## ## The units for the input coordinates and output angles can be ## "degrees" (the default) or "radians". ## ## @example ## >> azimuth([10,10], [10,40]) ## ans = 87.336 ## >> azimuth([0,10], [0,40]) ## ans = 90 ## >> azimuth(pi/4,0,pi/4,-pi/2,"radians") ## ans = 5.3279 ## @end example ## ## @seealso{elevation,distance} ## @end deftypefn ## Author: Andrew Collier ## Adapted-by: Alexander Barth ## Uses "four-parts" formula. function az = azimuth(varargin) ## default units are degrees units = "degrees"; [reg,prop] = parseparams(varargin); if length(reg) == 2 pt1 = reg{1}; pt2 = reg{2}; a = pt1(:,1); b = pt2(:,1); C = pt2(:,2) - pt1(:,2); elseif length(reg) == 4 a = reg{1}; b = reg{3}; C = reg{4} - reg{2}; else error("Wrong number of type of arguments"); end if length(prop) == 1 units = prop{1}; if (~strcmp(units,"degrees") && ~strcmp(units,"radians")) error("Only degrees and radians are allowed as units"); end elseif length(prop) > 1 error("Wrong number of type of arguments"); end if (strcmp(units,"degrees")) a = deg2rad(a); b = deg2rad(b); C = deg2rad(C); end az = atan2(sin(C) , cos(a) .* tan(b) - sin(a) .* cos(C) ); ## bring the angle in the interval [0 2*pi[ az = mod(az,2*pi); ## convert to degrees if desired if (strcmp(units,"degrees")) az = rad2deg(az); end endfunction %!test %! assert(azimuth([10,10], [10,40]), 87.336, 1e-3) %! assert(azimuth([0,10], [0,40]), 90, 1e-3) %! assert(azimuth(pi/4,0,pi/4,-pi/2,"radians"), 5.3279, 1e-4) mapping-1.2.1/inst/PaxHeaders.3513/mapshow.m0000644000000000000000000000013212655504456015443 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/mapshow.m0000644000175000017500000003571212655504456020303 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014,2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} @var{H} = mapshow (@var{data}) ## @deftypefnx {Function File} @var{H} = mapshow (@var{data}, @var{clr}) ## @deftypefnx {Function File} @var{H} = mapshow (@var{data}, @var{clr}, ...) ## @deftypefnx {Function File} @var{H} = mapshow (@var{data}, ...) ## @deftypefnx {Function File} @var{H} = mapshow (@var{X}, @var{Y}) ## @deftypefnx {Function File} @var{H} = mapshow (@var{X}, @var{Y}, @var{clr}) ## Draw a map based on raster or shapefile data. ## ## @var{data} can be: ## ## @itemize ## @item The filename of a GIS raster file (any file supported by the GDAL ## library) or of an ArcGIS shapefile. mapshow will invoke rasterread.m ## and rasterdraw.m. ## ## @item A raster band struct created by rasterread.m; in that case the ## corresponding raster info struct (also made by rasterread.m) is required ## as second input argument. ## ## @item A struct created by shaperead.m. @var{data} can be a mapstruct or ## an Octave-style shape struct. ## ## @item The base name or full file name of an ArcGis shape file. mapshow ## will invoke shaperead.m and shapedraw.m ## @end itemize ## ## If the first two arguments to mapshow.m contain numeric vectors, mapshow ## will simply draw the vectors as XY lines. The vectors can contain NaNs (in ## identical positions) to separate parts. ## ## For raster maps currently no further input arguments are recognized. ## For shapefile data, optional argument @var{clr} can be a predefined color ## ("k", "c", etc.), and RGB triplet, or a 2 X 1 column vector of predefined ## colors or RGB triplets (each row containing a predefined color or triplet). ## The upper row will be used for points and lines, the lower row for solid ## shape features. For XY data, only the first row is used. One-character ## color codes can be preceded by one-character linestyle indicators ## (":", "-", "--", "-.") to modify the linestyle for polylines, or marker ## styles ("o", "*", ".", "+", "@", ">", "<", "s", "d", "h", "v", "^") for ## points. ## ## Any other arguments are considered graphics properties for (multi-)points, ## polylines and polygons and will be conveyed as-is to the actual plotting ## routines. ## ## Additionally, if the first argument is a shape struct, mapshow accepts a ## property-value pair "symbolspec" (minimum abbreviation "symb") with a value ## comprising a cell array containing instructions on how to display the ## shape contents. Multiple sympolspec property/value pairs can be specified. ## ## Return argument @var{h} is a handle to the plot figure. ## ## ## Examples: ## ## @example ## H = mapshow ("/full/path/to/map") ## (draws a raster map and returns the figure handle in H) ## @end example ## ## @example ## H = mapshow ("shape.shp", ":g") ## H = mapshow ("shape.shp", "color", "g", "linestyle", ":") ## (draws a polygon shapefile "shape.shp" with green ## dotted lines and return figure handle in H) ## @end example ## ## @example ## mapshow (X, Y, "k") ## (plot vectors X and Y in black color) ## @end example ## ## @example ## mapshow (X, Y, "-.r", "linewidth", 5) ## (plot vectors X and Y as a dashdotted thick red line) ## @end example ## ## @example ## mapshow (data, "symbolspec", symsp1, "symb", symsp2) ## (draw contents of shapestruct (or mapstruct) data ## according to the symbolspecs symsp1 and symsp2) ## @end example ## ## @seealso{geoshow, shapedraw, shapeinfo, shaperead, shapewrite, makesymbolspec, rasterread, rasterdraw, rasterinfo} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-11-17 after a suggestion by Carnë Draug ## Updates: ## 2014-2015 many many fixes ## 2015-02-04 Relax check for mapstructs; don't test BoundingBox (Point shapes) ## 2015-02-11 Fix minor syntax error in do_symspecs rule check function h = mapshow (varargin) ## Check "hold" state; creates a new figure if none was present if (ishold()) old_holdstate = "on"; else old_holdstate = "off"; endif hold on; if ischar (varargin{1}) [~, ~, ext] = fileparts (varargin{1}); if (strncmpi (ext, ".shp", 4)) ## Directly plot shapefile. Strip away symbolspecs isym = find (strncmpi ("symbolspec", varargin(2:end), 4)); if (! isempty (isym)) warning ("mapshow.m: ignoring symbolspecs when drawing .shp directly"); endif varargin(isym:isym+1) = []; h = shapedraw (varargin{:}); else ## Assume any raster file h = rasterdraw (varargin{1}); endif elseif (nargin > 1 && israster (varargin{1}) && isstruct (varargin{2})) ## Assume raster structs h = rasterdraw (varargin{:}); elseif (isshape (varargin{1})) ## Assume a shape struct or a shape file name. Get optional symbolspec isym = find (strncmpi("symbolspec", varargin(2:end), 4)); if (! isempty (isym)) ## FIXME move this stanze into a separate subfunction ## Found symbolspec. Check if it can be invoked if (ischar (varargin{1})) ## Symbolspec not applicable to shape file argument error ("mapshow: symbolspec not supported when plotting shape files directly\n"); endif ## First get & check geometry symspecs = {varargin{isym+2}}; h = do_symspecs (varargin{1}, symspecs, old_holdstate); else ## No symbolspec to process; plot shape(file) directly endif elseif (nargin >= 2 && isvector (varargin{1}) && isvector (varargin{2})) ## Assume args #1 & #2 are lines. Find optional color argument. if (nargin >= 3) if (ischar (varargin{3})) ## Assume arg #3 is a valid color name or character like 'b' h = plot (varargin{1}, varargin{2}, varargin{3}); elseif (isnumeric (varargin{3} && size (varargin{3}, 2) == 3)) ## Assume arg#3 is a valid color triplet h = plot (varargin{1}, varargin{2}, "color", varargin{3}); else error ("mapshow.m: color argment expected for arg. #3\n"); endif axis equal; else ## Plot args #1 & #2 without further ado h = plot (varargin{1}, varargin{2}, "color", [0.6 0.6 0.6]); endif else error ("mapshow: only plotting of shapes or vector data is implemented\n"); endif ## Reset hold state hold (old_holdstate); axis equal; if (! nargout) h = 0; endif endfunction ##-------------------------------------------------------------------------- ## Copyright (C) 2014,2015 Philip Nienhuis function retval = isshape (s) retval = false; ## Check if s is a recognized shape file struct; just a brief check if (isstruct (s)) ## Yep. Find out what type fldn = fieldnames (s); if (all (ismember ({"vals", "shpbox"}, fldn))) ## Assume it is an Octave-style struct read by shaperead retval = 2; elseif (all (ismember ({"Geometry", "X"}, fldn))) ## Assume it is a Matlab-style mapstruct retval = 1; endif endif endfunction ##-------------------------------------------------------------------------- ## Copyright (C) 2015 Philip Nienhuis function retval = israster (s) retval = 0; ## Check if s is a recognized raster struct; just a brief check if (isstruct (s)) ## Yep. Find out what type fldn = fieldnames (s); if (ismember ("data", fldn) && ismatrix (s.data)) ## Assume it is an Octave-style struct read by shaperead retval = 1; endif endif endfunction ##-------------------------------------------------------------------------- ## Copyright (C) 2015 Philip Nienhuis ## ## Process symbolspecs one by one function h = do_symspecs (shp, symspecs) for jj=1:numel (symspecs); symspec = symspecs{jj}; geom = lower (symspec {1}); if (! ischar (geom)) error ("mapshow: char argument expected for Geometry field in symbolspec\n"); elseif (! ismember (lower (geom), {"point", "multipoint", "line", ... "polyline", "polygon", "patch"})) error ("mapshow: unknown Geometry: %s in symbolspec\n", geom); endif for ii=2:numel (symspec) rule = symspec{ii}; if (! ischar (rule{1})) warning ("mapshow: char string expected for attribute of rule %d in symbolspec\n", ii-1); endif ## Get property or attribute if (strcmpi (rule{1}, "default")) ## Rule applies to all shape features with geom. Plot shape features if (isshape (shp) == 1) ## mapstruct shapes are allowed to be heterogeneous gdx = find (strcmpi (geom, {shp.Geometry})); h = shapedraw (shp(gdx), rule(3:end){:}); elseif (isshape (shp) == 2) h = shapedraw (shp, rule(3:end){:}); else error ("mapshow: improper shape struct type\n"); end elseif (isshape (shp) == 1) ## ML mapstruct type shape struct. Apply to proper geometry features gdx = find (strcmpi (geom, {shp.Geometry})); ## Rule applies to one specific attribute. Check if it exists if (ismember (rule{1}, fieldnames (shp))) ## Try to apply rule. We need try-catch to catch non-matching classes if (islogical (rule{2})) ## Find attributes that are true. FIXME catches zero attributes too try idx = find ([shp(gdx).(rule{1})]); catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch elseif (isnumeric (rule{2})) ## Check which shape features have attribute values in the range minr = min (rule{2}); maxr = max (rule{2}); try idx = find ([shp(gdx).(rule{1})] >= minr & ... [shp(gdx).(rule{1})] <= maxr); catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch elseif (ischar (rule{2})) ## Match strings try idx = find (strcmp (rule{2}, {shp(gdx).(rule{1})})); catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch endif ## Plot shape features h = shapedraw (shp(gdx(idx)), rule(3:end){:}); else ## Attribute not found warning ("mapshow: attribute '%s' in rule #%d not found\n", rule(ii){1}); endif elseif (isshape (shp) == 2) ## Oct-style shp struct. Prepare indexing into coords shp.idx = [ shp.idx; (size(shp.vals, 1) + 2) ]; ## Some fields are not explicitly in the shape switch rule{1} ## Coordinates case "X" shp_field = shp.vals(:, 1); case "Y" shp_field = shp.vals(:, 2); case "Z" shp_field = shp.vals(:, 3); case "M" ## Measure shp_field = shp.vals(:, 4); case "npt" ## Nr. or points/vertices shp_field = shp.npt; case "npr" ## Nr. of parts try shp_field = cellfun (@numel, shp.npr); catch warning ("mapshow: rule %d attribute 'npr' not found\n", ii-1); shp_field = NaN; end_try_catch #case "bbox" # shp_field = shp.bbox; otherwise ## "Regular" attributes if (ismember (rule{1}, fieldnames(shp))) shp_field = shp.(rule{1}); else warning ("mapshow: rule %d attribute '%s' not found\n", ... ii-1, rule{1}); endif endswitch ## Try to apply rule. We need try-catch to catch non-matching classes if (islogical (rule{2})) ## Find attributes that are true. FIXME catches zero attributes too try idx = find (shp_field); catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch elseif (isnumeric (shp_field)) ## Check which shape features have attribute values in the range minr = min (rule{2}); maxr = max (rule{2}); if (ismember (rule{1}, {"X", "Y", "Z", "M"})) ## Multiple attribute values per shape feature (polylines, ...) idx = []; try for jj=1:numel (shp.idx) ## Include all polylines/-gons/multipatches with at least ## one value in the range idx = [idx; (any ( ... shp_field(shp.idx(jj:shp.idx(jj+1)-2)) >= minr & ... shp_field(shp.idx(jj:shp.idx(jj+1)-2)) <= maxr)) ]; endfor catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch else ## Single attribute values per shape feature try idx = find (shp_field >= minr & ... shp_field <= maxr); catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch endif elseif (iscellstr (shp_field)) ## Match strings try idx = find (strcmp (rule{2}, shp_field)); catch warning ("mapshow: rule %d not applicable to atribute %s\n", ... ii-1, rule{1}); end_try_catch endif ## Plot shape features; but first set up struct vals = zeros(0, 6); jdx = []; for jj=1:numel (idx) jdx = [ jdx ; (size (vals, 1) + 1) ]; vals = [ vals; ... shp.vals(shp.idx(idx(jj)):shp.idx(idx(jj)+1)-2, :); ... NaN(1, 6) ]; endfor vals(end, :) = []; sct.shpbox = shp.shpbox; sct.vals = vals; sct.bbox = shp.bbox(idx, :); sct.npt = shp.npt(idx); sct.npr = shp.npr(idx); sct.idx = jdx; sct.(rule{1}) = shp.(rule{1})(idx); ## Draw results h = shapedraw (sct, rule(3:end){:}); else ## Unrecognized shape type error ("mapshow: improper shape struct type\n"); endif endfor endfor endfunction mapping-1.2.1/inst/PaxHeaders.3513/fromDegrees.m0000644000000000000000000000013212655504456016227 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/fromDegrees.m0000644000175000017500000000465412655504456021070 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{a1}, @var{a2}, @dots{}] =} fromDegrees (@var{toUnit}, @var{deg1}, @var{deg2}, @dots{}) ## Convert angles from radians. ## ## Converts any number of input arguments, @var{deg1}, @var{deg2}, @dots{} ## with angles in degrees, into @var{toUnit} which may be @qcode{"radians"} or ## @qcode{"degrees"}. ## ## @example ## @group ## [a1, a2] = fromDegrees ("radians", 180, [180 360]) ## @result{a1} [ 3.1416 ] ## @result{a2} [ 3.1416 6.2832 ] ## @end group ## @end example ## ## @seealso{deg2rad, fromRadians, toDegrees, toRadians, unitsratio} ## @end deftypefn ## Author: Carnë Draug function varargout = fromDegrees (toUnit, varargin) if (nargin < 1) print_usage (); endif valid_unit = validatestring (toUnit, {"radians", "degrees"}, "fromDegrees", "TOUNIT"); switch (valid_unit(1)) case {"r"} varargout = cellfun (@deg2rad, varargin, "UniformOutput", false); case {"d"} varargout = varargin; endswitch endfunction %!test %! rad{1} = pi; %! rad{2} = [pi 2*pi]; %! rad{3} = [0 pi; 2*pi 0]; %! deg{1} = 180; %! deg{2} = [180 360]; %! deg{3} = [0 180; 360 0]; %! for i=1:3 %! assert (fromDegrees ("degrees", deg{i}), deg{i}) %! assert (fromDegrees ("radians", deg{i}), rad{i}) %! endfor %! %! ## test multiple angles same time %! assert (nthargout (1:3, @fromDegrees, "radians", deg{:}), rad) %! assert (nthargout (1:2, @fromDegrees, "radians", deg{:}), rad(1:2)) %! %! ## test abbreviations of degrees %! assert (nthargout (1:3, @fromDegrees, "radian", deg{:}), rad) %! assert (nthargout (1:3, @fromDegrees, "rad", deg{:}), rad) %! assert (nthargout (1:3, @fromDegrees, "r", deg{:}), rad) %!error fromDegrees ("INVALID") mapping-1.2.1/inst/PaxHeaders.3513/reckon.m0000644000000000000000000000013212655504456015246 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/reckon.m0000644000175000017500000000643512655504456020106 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2008 Alexander Barth ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{lato},@var{lono}] = } reckon(@var{lat},@var{lon},@var{range},@var{azimuth}) ## @deftypefnx {Function File} {[@var{lato},@var{lono}] = } reckon(@var{lat},@var{lon},@var{range},@var{azimuth},@var{units}) ## Compute the coordinates of the end-point of a displacement on a ## sphere. @var{lat},@var{lon} are the coordinates of the starting point, @var{range} ## is the covered distance of the displacements along a great circle and ## @var{azimuth} is the direction of the displacement relative to the North. ## The units of all input and output parameters can be either 'degrees' (default) ## or 'radians'. ## ## This function can also be used to define a spherical coordinate system ## with rotated poles. ## @end deftypefn ## Author: Alexander Barth function [lato,lono] = reckon(varargin); units = "degrees"; [reg,prop] = parseparams(varargin); ## Input checking if length(reg) != 4 print_usage (); endif sz = [1 1]; for i=1:4 if !isscalar(reg{i}) sz = size(reg{i}); break; endif endfor for i=1:4 if isscalar(reg{i}) reg{i} = repmat(reg{i},sz); elseif !isequal(size(reg{i}),sz) print_usage(); endif endfor if length(prop) == 1 units = prop{1}; elseif length(prop) > 1 error("reckon: wrong number of type of arguments"); end lat = reg{1}; lon = reg{2}; range = reg{3}; azimuth = reg{4}; if strcmp(units,"degrees") d = pi/180; elseif strcmp(units,"radians") d = 1; else error(["reckon: unknown units: " units]); endif ## convert to radians lat = lat*d; lon = lon*d; range = range*d; azimuth = azimuth*d; lato = pi/2 - acos(sin(lat).*cos(range) + cos(lat).*sin(range).*cos(azimuth)); cos_gamma = (cos(range) - sin(lato).*sin(lat))./(cos(lato).*cos(lat)); sin_gamma = sin(azimuth).*sin(range)./cos(lato); gamma = atan2(sin_gamma,cos_gamma); lono = lon + gamma; ## bring the lono in the interval [-pi pi[ lono = mod(lono+pi,2*pi)-pi; ## convert to degrees lono = lono/d; lato = lato/d; endfunction %!test %! [lato,lono] = reckon(30,-80,20,40); %! assert(lato,44.16661401448592,1e-10) %! assert(lono,-62.15251496909770,1e-10) %!test %! [lato,lono] = reckon(-30,80,[5 10],[40 45]); %! assert(lato,[-26.12155703039504 -22.70996703614572],1e-10) %! assert(lono,[83.57732793979254 87.64920016442251],1e-10) %!test %! [lato,lono] = reckon([-30 31],[80 81],[5 10],[40 45]); %! assert(lato,[-26.12155703039504 37.76782079033356],1e-10) %! assert(lono,[83.57732793979254 89.93590456974810],1e-10) mapping-1.2.1/inst/PaxHeaders.3513/km2sm.m0000644000000000000000000000013212655504456015016 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/km2sm.m0000644000175000017500000000267412655504456017657 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Eugenio Gianniti ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} km2sm (@var{km}) ## Convert kilometers into U.S. survey miles (statute miles). ## ## @seealso{km2nm, nm2km, nm2sm, sm2km, sm2nm} ## @end deftypefn ## Author: Eugenio Gianniti function sm = km2sm (km) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("U.S. survey mile (statute mile)", "kilometer"); sm = km * ratio; endfunction %!test %! km = [2 3.218694437388875 4.8326 6.437388874777749]; %! sm = [1.242739898989899 2 3.002832417929293 4]; %! assert (km2sm (km), sm) %! km = reshape (km, [2 2]); %! sm = reshape (sm, [2 2]); %! assert (km2sm (km), sm) %!assert (km2sm (4.8326), 3.002832417929293) mapping-1.2.1/inst/PaxHeaders.3513/toDegrees.m0000644000000000000000000000013212655504456015706 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/toDegrees.m0000644000175000017500000000464512655504456020547 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{deg1}, @var{deg2}, @dots{}] =} toDegrees (@var{fromUnit}, @var{a1}, @var{a2}, @dots{}) ## Convert angles into degrees. ## ## Converts any number of input arguments, @var{a1}, @var{a2}, @dots{} ## with angles in @var{fromUnit}, into degrees. @var{fromUnit} may be ## @qcode{"radians"} or @qcode{"degrees"}. ## ## @example ## @group ## [deg1, deg2] = toDegrees ("radians", pi, [pi 2*pi]) ## @result{deg1} [ 180 ] ## @result{deg2} [ 180 360 ] ## @end group ## @end example ## ## @seealso{fromDegrees, fromRadians, rad2deg, toRadians, unitsratio} ## @end deftypefn ## Author: Carnë Draug function varargout = toDegrees (fromUnit, varargin) if (nargin < 1) print_usage (); endif valid_unit = validatestring (fromUnit, {"radians", "degrees"}, "toDegrees", "FROMUNIT"); switch (valid_unit(1)) case {"r"} varargout = cellfun (@rad2deg, varargin, "UniformOutput", false); case {"d"} varargout = varargin; endswitch endfunction %!test %! rad{1} = pi; %! rad{2} = [pi 2*pi]; %! rad{3} = [0 pi; 2*pi 0]; %! deg{1} = 180; %! deg{2} = [180 360]; %! deg{3} = [0 180; 360 0]; %! for i=1:3 %! assert (toDegrees ("degrees", deg{i}), deg{i}) %! assert (toDegrees ("radians", rad{i}), deg{i}) %! endfor %! %! ## test multiple angles same time %! assert (nthargout (1:3, @toDegrees, "radians", rad{:}), deg) %! assert (nthargout (1:2, @toDegrees, "radians", rad{:}), deg(1:2)) %! %! ## test abbreviations of degrees %! assert (nthargout (1:3, @toDegrees, "radian", rad{:}), deg) %! assert (nthargout (1:3, @toDegrees, "rad", rad{:}), deg) %! assert (nthargout (1:3, @toDegrees, "r", rad{:}), deg) %!error toRadians ("INVALID") mapping-1.2.1/inst/PaxHeaders.3513/roundn.m0000644000000000000000000000013212655504456015272 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/roundn.m0000644000175000017500000000327112655504456020125 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Markus Bergholz ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} roundn (@var{X}) ## @deftypefnx {Function File} {} roundn (@var{X}, @var{n}) ## Round to multiples of 10. ## ## Returns the double nearest to multiply of 10^@var{n}, while @var{n} ## has to be an integer scalar. @var{n} defaults to zero. ## ## When @var{X} is an integer, it rounds to the nearest decimal power. ## ## @seealso{round ceil floor fix roundb} ## @end deftypefn function ret = roundn (x, n = 0) if (nargin < 1 || nargin > 2) print_usage (); endif if (mod (x, 1) != 0) ret = round (10^abs (n) * x) / (10^abs (n)); else ret = round (x / 10^abs (n)) * 10 ^ abs (n); endif endfunction %!assert (roundn (pi), 3) %!assert (roundn (e, -2), 2.7200) %!assert (roundn (pi, 4), 3.1416) %!assert (roundn (e, 3), 2.718) %!assert (roundn ([0.197608841252122, 0.384415323084123; 0.213847642260694, 0.464622347858917], 2), [0.20, 0.38; 0.21, 0.46]) %!assert (roundn (401189, 3), 401000) %!assert (roundn (5), 5) %!assert (roundn (-5), -5) mapping-1.2.1/inst/PaxHeaders.3513/extractfield.m0000644000000000000000000000013212655504456016443 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/extractfield.m0000644000175000017500000000665412655504456021306 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} extractfield (@var{s}, @var{field}) ## Extract field values from struct array. ## ## Concatenates all the values from the field member @var{field} in the ## structure array @var{s}. The values are all concatenated into a row ## vector of the same type as the values. ## ## @group ## @example ## s(1).field = 1:3; ## s(2).field = 4:9; ## extractfield (s, "field") ## @result{} [ 1 2 3 4 5 6 7 8 9 ] ## @end example ## @end group ## ## If any of the values is a string, or if the class is not the same for ## all the elements, a cell array with the intact elements is returned ## instead. ## ## @group ## @example ## s(1).field = 1:3; ## s(2).field = uint8 (4:6); ## extractfield (s, "field") ## @result{[1, 1] } [ 1 2 3 ] ## @result{[1, 2] } [ 4 5 6 ] ## @end example ## ## @example ## s(1).field = "text"; ## s(2).field = 1:3; ## extractfield (s, "field") ## @result{[1, 1] } text ## @result{[1, 2] } [ 1 2 3 ] ## @end example ## @end group ## ## @seealso{cell2mat, cellfun, getfield} ## @end deftypefn ## Author: Carnë Draug function vals = extractfield (s, name) if (nargin != 2) print_usage (); elseif (! isstruct (s)) error ("extractfield: S must be a struct"); elseif (! isfield (s, name)) error ("extractfield: NAME is a not a field of S"); endif vals = {s(:).(name)}; ## If none of them is char and they are all of the same class, ## get a vector out of it if (! any (cellfun ("isclass", vals, "char")) && all (cellfun ("isclass", vals, class (vals{1})))) ## matlab compatibility, all values in single row foo = @(x) vec (x, 2); vals = cell2mat (cellfun (foo, vals, "UniformOutput", false)); endif endfunction %!test %! a = {1:3, 4:6, [7:9]', 10:11, uint8(12:13), "text"}; %! s(1).a = a{1}; %! s(2).a = a{2}; %! assert (extractfield (s, "a"), 1:6); %! s(3).a = a{3}; %! assert (extractfield (s, "a"), 1:9); %! s(4).a = a{4}; %! assert (extractfield (s, "a"), 1:11); %! s(5).a = a{5}; %! assert (extractfield (s, "a"), a(1:5)); %! s(6).a = a{6}; %! assert (extractfield (s, "a"), a); ## we don't mess up when transposing complex numbers %!test %! s(1).a = [4 5]; %! s(2).a = [6i 7i 8]; %! assert (extractfield (s, "a"), [4 5 6i 7i 8]); %!test %! s(1).a = 0; %! s(2).a = false; %! assert (extractfield (s, "a"), {0, false}); ## check we don't mess up when there's other fields %!test %! s = struct ("a", mat2cell (1:10, 1, [3 3 4]), %! "b", mat2cell (11:20, 1, [5 2 3])); %! assert (extractfield (s, "a"), 1:10); %! assert (extractfield (s, "b"), 11:20); %!error extractfield (5, "name") %!error extractfield (struct ("name", 5), "not a name") mapping-1.2.1/inst/PaxHeaders.3513/removeExtraNanSeparators.m0000644000000000000000000000013212655504456020767 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/removeExtraNanSeparators.m0000644000175000017500000001175112655504456023624 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{x}, @var{y}, @dots{}] =} removeExtraNanSeparators (@var{x}, @var{y}, @dots{}) ## Remove groups of NaN and leave a single separator. ## ## For any number of vectors, @var{x}, @var{y}, @var{z}, @dots{}, reduce ## groups of contiguous NaNs into a single NaN separator. The vectors must ## all have the same dimensions and the NaNs must be locations. Leading NaNs ## are removed, and trailing NaNs are reduced to one. ## ## @example ## @group ## removeExtraNanSeparators ([NaN NaN 3 4 5 NaN NaN 8 NaN], [NaN NaN 7 6 5 NaN NaN 2 NaN]) ## @result{x } [3 4 5 NaN 8 NaN] ## @result{y } [7 6 5 NaN 2 NaN] ## @end group ## @end example ## ## @seealso{diff, isnan, isna} ## @end deftypefn ## Author: Carnë Draug function [varargout] = removeExtraNanSeparators (varargin) if (nargin < 1) print_usage (); elseif (! isvector (varargin{1}) || ! size_equal (varargin{:})) error ("removeExtraNanSeparators: X, Y, Z, ... must be vectors with equal sizes"); endif ## one row per input argument if (iscolumn (varargin{1})) ins = cell2mat (varargin)'; else ins = cell2mat (varargin'); endif nans = isnan (ins); if (any (nans(:))) if (any (any (nans) != all (nans))) error ("removeExtraNanSeparators: NaN and NA positions must be equal on X, Y, Z, ..."); endif ## This will create a mask that selects the first change from a non-NaN ## into a NaN. If there are leaading NaN it will not identify them but ## it will identify the first of trailing NaNs. nan_sep = diff ([true nans(1,:)]) == 1; line_mask = ! nans(1,:) | nan_sep; full_mask = repmat (line_mask, [nargin 1]); elems = nnz (line_mask); outs = reshape (ins(full_mask), [nargin elems]); if (iscolumn (varargin{1})) varargout = mat2cell (outs', elems, ones (nargin, 1)); else varargout = mat2cell (outs, ones (nargin, 1), elems); endif else ## there are no NaNs, so give the input back varargout = varargin; endif endfunction ## We remove trailing NaN and leave only one at the end %!assert (nthargout (1:2, @removeExtraNanSeparators, %! [NaN NaN 3 4 5 6 NaN NaN], [NaN NaN 4 5 5 7 NaN NaN]), %! {[ 3 4 5 6 NaN ], [ 4 5 5 7 NaN ]}); ## We leave individual NaN in the middle intact %!assert (nthargout (1:2, @removeExtraNanSeparators, %! [NaN NaN 3 4 NaN 6 NaN], [NaN NaN 2 4 NaN 3 NaN]), %! {[ 3 4 NaN 6 NaN], [ 2 4 NaN 3 NaN]}); ## We turn a group of NaN into a single separator %!assert (nthargout (1:2, @removeExtraNanSeparators, %! [NaN 2 NaN NaN 6 NaN], [NaN 1 NaN NaN 8 NaN]), %! {[ 2 NaN 6 NaN], [ 1 NaN 8 NaN]}); %!assert (nthargout (1:2, @removeExtraNanSeparators, %! [1 2 NaN NaN 6 NaN], [8 1 NaN NaN 8 NaN]), %! {[1 2 NaN 6 NaN], [8 1 NaN 8 NaN]}); ## We don't mess up when there's no trailing(s) NaN %!assert (nthargout (1:2, @removeExtraNanSeparators, %! [1 2 NaN NaN 6], [8 1 NaN NaN 8]), %! {[1 2 NaN 6], [8 1 NaN 8]}); ## We don't mess up when there's no NaN's at all %!assert (nthargout (1:2, @removeExtraNanSeparators, 1:9, 1:9), {1:9 1:9}) %!assert (nthargout (1:2, @removeExtraNanSeparators, 9:-1:-9, 9:-1:-9), {9:-1:-9 9:-1:-9}) ## We don't mess up for x, y, z, etc %!assert (nthargout (1:3, @removeExtraNanSeparators, %! [1 2 NaN NaN 6], [8 1 NaN NaN 8], [5 6 NaN NaN 7]), %! {[1 2 NaN 6], [8 1 NaN 8], [5 6 NaN 7]}); ## We don't mess up when we get column vector instead of row vectors %!assert (nthargout (1:3, @removeExtraNanSeparators, %! [1 2 NaN NaN 6]', [8 1 NaN NaN 8]', [5 6 NaN NaN 7]'), %! {[1 2 NaN 6]', [8 1 NaN 8]', [5 6 NaN 7]'}); %!error removeExtraNanSeparators (rand (5), rand (5)) %!error removeExtraNanSeparators (rand (5, 1), rand (6, 1)) %!error removeExtraNanSeparators (rand (5, 1), rand (5, 1), rand (5)) %!error removeExtraNanSeparators (rand (5, 1), rand (5, 1), rand (6, 1)) %!error removeExtraNanSeparators ([NaN NaN 3 4 5 6 NaN], [NaN 2 3 4 5 6 NaN]) %!error removeExtraNanSeparators ([NaN NaN 3 4 5 6 NaN], [NaN NaN 3 4 5 6 NaN], [NaN 2 3 4 5 6 NaN]) mapping-1.2.1/inst/PaxHeaders.3513/shapewrite.m0000644000000000000000000000013212655504456016140 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/shapewrite.m0000644000175000017500000002403712655504456020776 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014,2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{status} =} shapewrite (@var{shpstr}, @var{fname}) ## Write contents of map- or geostruct to a GIS shape file. ## ## @var{shpstr} must be a valid mapstruct or geostruct, a struct array with an ## entry for each shape feature, with fields Geometry, BoundingBox, and X and Y ## (mapstruct) or Lat and Lon (geostruct). For geostructs, Lat and Lon field ## data will be written as X and Y data. Field Geometry can have data values ## of "Point", "MultiPoint", "Line", or "Polygon", all case-insensitive. For ## each shape feature, field BoundingBox should contain the minimum and maximum ## (X,Y) coordinates in a 2x2 array [minX, minY; maxX, maxY]. The X and Y ## fields should contain X (or Latitude) and Y (or Longitude) coordinates for ## each point or vertex as row vectors; for polylines and polygons vertices of ## each subfeature (if present) should be separated by NaN entries. ## ## @var{fname} should be a valid shape file name, optionally with a '.shp' ## suffix. ## ## shapewrite produces 2 or 3 files, i.e. a .shp file (the actual shape file), ## a .shx file (index file), and if @var{shpstr} contained additional fields, ## a .dbf file (dBase type 3) with the contents of those additional fields. ## ## @var{status} is 1 if the shape file set was written successfully, 0 ## otherwise. ## ## @seealso{shapedraw, shapeinfo, shaperead} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-12-30 ## 2015-06-26 Three fixes by Jan Heckman function [status] = shapewrite (shp, fname, atts=[]) status = 0; ## Input validation if (nargin < 1) print_usage; endif ## Assess shape variable type (oct or ml/geo ml/map) if (! isstruct (shp)) error ("shapewrite: [map-, geo-] struct expected for argument #2"); else ## Yep. Find out what type fldn = fieldnames (shp); if (ismember ("vals", fldn) && ismember ("shpbox", fldn)) ## Assume it is an Octave-style struct read by shaperead otype = 0; warning ("shapewrite: only Matlab-type map/geostructs can be written\n"); return; elseif (ismember ("Geometry", fldn) && all (ismember ({"X", "Y"}, fldn))) ## Assume it is a Matlab-style mapstruct otype = 1; elseif (ismember ("Geometry", fldn) && all (ismember ({"Lat", "Lon"}, fldn))) ## Assume it is a Matlab-style geostruct otype = 2; else ## Not a supported struct type error ("shapewrite: unsupported struct type.\n") endif if (any (ismember ({"M", "Z"}, fldn))) otype = -otype; endif endif ## Check file name [pth, fnm, ext] = fileparts (fname); if (isempty (ext)) bname = fname; fname = [fname ".shp"]; else ## Later on bname.shx and bname.dbf will be read bname = [pth fnm]; endif ## Prepare a few things numfeat = numel (shp); if (abs (otype) >= 1) stype = find (strcmpi (shp(1).Geometry, ... {"Point", "MultiPoint", "Line", "Polygon"})); stype = [1, 8, 3, 5](stype); if (abs (otype) == 2) ## Change Lat/Lon fields into X/Y [shp.X] = deal (shp.Lon); [shp.Y] = deal (shp.Lat); %% shp = rmfield (shp, {"Lat", "Lon"}); endif ## "Point" need not have a BoundingBox field => add a dummy if not found if (stype == 1 && ! ismember ("BoundingBox", fldn)) [shp.BoundingBox] = deal (repmat (zeros (0, 0), numel (shp))); endif endif ## Only now (after input checks) open .shp and .shx files & rewind just to be sure fids = fopen (fname, "w"); if (fids < 0) error ("shapewrite: shapefile %s can't be opened for writing\n", fname); endif fseek (fids, 0, "bof"); fidx = fopen ([ bname ".shx" ], "w"); if (fidx < 0) error ("shapewrite: indexfile %s can't be opened for writing\n", fname); endif fseek (fidx, 0, "bof"); ## Write headers in .shp & .shx (identical). First magic number 9994 + 5 zeros fwrite (fids, [9994 0 0 0 0 0 0], "int32", 0, "ieee-be"); fwrite (fidx, [9994 0 0 0 0 0], "int32", 0, "ieee-be"); ## In between here = filelength in 16-bit words (single). For .shx it's known fwrite (fidx, ((numfeat * 4) + 50), "int32", 0, "ieee-be"); ## Next, shp file version fwrite (fids, 1000, "int32"); fwrite (fidx, 1000, "int32"); ## Shape feature type fwrite (fids, stype, "int32"); fwrite (fidx, stype, "int32"); ## Bounding box. Can be run later for ML type shape structs. Fill with zeros fwrite (fids, [0 0 0 0 0 0 0 0], "double"); fwrite (fidx, [0 0 0 0 0 0 0 0], "double"); ## Prepare BoundingBox limits xMin = yMin = Inf; xMax = yMax = -Inf; ## Skip to start of first record position % fseek (fids, 100, "bof"); % fseek (fidx, 100, "bof"); ## Write shape features one by one if (abs (otype) >= 1) for ishp=1:numfeat ## Write record start pos to .shx file fwrite (fidx, ftell (fids) / 2, "int32", 0, "ieee-be"); ## Write record contents switch (stype) case 1 ## Point ## Record index number fwrite (fids, ishp, "int32", 0, "ieee-be"); ## Record length (fixed) reclen = 20; fwrite (fids, reclen, "int32", 0, "ieee-be"); fwrite (fidx, reclen, "int32", 0, "ieee-be"); ## Shape type fwrite (fids, stype, "int32"); ## Simply write XY cordinates fwrite (fids, [shp(ishp).X shp(ishp).Y], "double"); ## Update overall BoundingBox xMin = min (xMin, shp(ishp).BoundingBox(1, 1)); xMax = max (xMax, shp(ishp).BoundingBox(1, 2)); yMin = min (yMin, shp(ishp).BoundingBox(2, 1)); yMax = max (yMax, shp(ishp).BoundingBox(2, 2)); case 8 ## MultiPoint ## Record index number fwrite (fids, ishp, "int32", 0, "ieee-be"); ## Record length reclen = (48 + 16 * numel (shp(ishp).X)) / 2; fwrite (fids, reclen, "int32", 0, "ieee-be"); fwrite (fidx, reclen, "int32", 0, "ieee-be"); ## Shape type fwrite (fids, stype, "int32"); ## Bounding box fwrite (fids, [shp(ishp).BoundingBox'(:)]', "double"); xMin = min (xMin, shp(ishp).BoundingBox(1, 1)); xMax = max (xMax, shp(ishp).BoundingBox(1, 2)); yMin = min (yMin, shp(ishp).BoundingBox(2, 1)); yMax = max (yMax, shp(ishp).BoundingBox(2, 2)); ## Nr of points fwrite (fids, numel (shp(ishp).X), "int32"); fwrite (fids, [shp(ishp).X shp(ishp).Y]', "double"); reclen = (44 + 16 * numel (shp(ishp).X)) / 2; case {3, 5} ## Polyline/-gon ## Record index number fwrite (fids, ishp, "int32", 0, "ieee-be"); ## Prepare multipart polygons idx = [ 0 find(isnan (shp(ishp).X)) ]; npt = numel (shp(ishp).X) - numel (idx) + 1; ## Augment idx for later on, & this trick eliminates trailing NaN rows idx = unique ([ idx npt ]); ## Record length reclen = (44 + (numel(idx)-1)*4 + 2*8*npt) / 2; fwrite (fids, reclen, "int32", 0, "ieee-be"); fwrite (fidx, reclen, "int32", 0, "ieee-be"); ## Shape type fwrite (fids, stype, "int32"); ## Bounding box fwrite (fids, [shp(ishp).BoundingBox'(:)]', "double"); xMin = min (xMin, shp(ishp).BoundingBox(1, 1)); xMax = max (xMax, shp(ishp).BoundingBox(1, 2)); yMin = min (yMin, shp(ishp).BoundingBox(2, 1)); yMax = max (yMax, shp(ishp).BoundingBox(2, 2)); ## Number of parts, number of points, part pointers fwrite (fids, [(numel(idx)-1) npt idx(1:end-1) ], "int32"); for ii=1:numel(idx)-1 fwrite (fids, [shp(ishp).X(idx(ii)+1:idx(ii+1)) ... shp(ishp).Y(idx(ii)+1:idx(ii+1))](:)', "double"); endfor otherwise ## Future shape types or types unsupported yet (M, Z, MultiPatch) endswitch endfor endif ## Write file length and overall BoundingBox into .shp header flen = ftell (fids); fseek (fids, 24, "bof"); fwrite (fids, flen/2, "int32", 0, "ieee-be"); fseek (fids, 36, "bof"); fwrite (fids, [xMin yMin xMax yMax], "double"); fseek (fidx, 36, "bof"); fwrite (fidx, [xMin yMin xMax yMax], "double"); ## Close files fclose (fids); fclose (fidx); ## Check for dbfwrite function if (isempty (which ("dbfwrite"))) printf ("shaperead.m: dbfwrite function not found. No attributes written.\n"); printf (" (io package 2.2.6+ installed and loaded?)\n"); return; endif ## Write rest of attributes if (nargin == 3) shp = atts; else if (otype == 1) ## Attributes + shp data in mapstruct shp = rmfield (shp, {"Geometry", "BoundingBox", "X", "Y"}); elseif (otype == 2) ## Attributes + shp data in geostruct shp = rmfield (shp, {"Geometry", "BoundingBox", "Lat", "Lon", "X", "Y"}); endif endif attribs = cell (numfeat + 1, numel (fieldnames (shp))); attribs(1, :) = fieldnames (shp); attribs(2:end, :) = (squeeze (struct2cell (shp)))'; if (! isempty (attribs)) try status = dbfwrite ([ bname ".dbf"], attribs); catch warning ("shapewrite: writing attributes to file %s failed\n", [bname ".dbf"]); end_try_catch else status = 1; endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/sm2nm.m0000644000000000000000000000013212655504456015021 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/sm2nm.m0000644000175000017500000000264312655504456017656 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Eugenio Gianniti ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} sm2nm (@var{sm}) ## Convert U.S. survey miles (statute miles) into nautical miles. ## ## @seealso{km2nm, km2sm, nm2km, nm2sm, sm2km} ## @end deftypefn ## Author: Eugenio Gianniti function nm = sm2nm (sm) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("nautical mile", "U.S. survey mile (statute mile)"); nm = sm * ratio; endfunction %!test %! nm = [50.292 100.584 25.146 10058.4]; %! sm = [57.875 115.75 28.9375 11575]; %! assert (sm2nm (sm), nm) %! sm = reshape (sm, [2 2 1]); %! nm = reshape (nm, [2 2 1]); %! assert (sm2nm (sm), nm) %!assert (sm2nm (28.9375), 25.146) mapping-1.2.1/inst/PaxHeaders.3513/rad2km.m0000644000000000000000000000013212655504456015145 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/rad2km.m0000644000175000017500000000414012655504456017774 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Pooja Rao ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{km} =} rad2km (@var{rad}) ## @deftypefnx {Function File} {@var{km} =} rad2km (@var{rad}, @var{radius}) ## @deftypefnx {Function File} {@var{km} =} rad2km (@var{rad}, @var{sphere}) ## Converts angle to distance by multiplying angle with radius. ## ## Calculates the distances @var{km} in a sphere with @var{radius} (also in ## kilometers) for the angles @var{rad}. If unspecified, radius defaults to ## 6371, the mean radius of Earth. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2rad} ## @end deftypefn ## Author: Pooja Rao function km = rad2km (rad, radius = "earth") ## This function converts radians (rad) to kilometers (km) ## Check arguments if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere with its default units (km) radius = spheres_radius (radius); ## Check input elseif (! isnumeric (radius) || ! isscalar (radius)) error ("rad2km: RADIUS must be a numeric scalar"); endif km = (rad * radius) ; endfunction %!test %!assert (km2rad (rad2km (10)), 10, 10*eps); %!assert (km2rad (rad2km (10, 80), 80), 10, 10*eps); %!assert (km2rad (rad2km (10, "pluto"), "pluto"), 10, 10*eps); mapping-1.2.1/inst/PaxHeaders.3513/wrapTo2Pi.m0000644000000000000000000000013212655504456015614 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/wrapTo2Pi.m0000644000175000017500000000365712655504456020457 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Oscar Monerris Belda ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{xwrap} =} wrapTo2Pi (@var{x}) ## ## Wraps x into the [0 to 2pi] interval ## ## @var{x}: angle in radians (single value, vector or ND matrix). ## ## @var{xwrap}: output value(s) in the range [0 .. 2*pi] radians. ## The interval [0 .. 2*pi] is a closed interval: values equal to ## zero or negative even multiples of pi are mapped to 0, values ## equal to an even multiple of pi are mapped to 2*pi. ## ## Example: ## @example ## wrapTo2Pi ([-2*pi, -pi, 0, pi; 0.1, pi, 4*pi, 5*pi]) ## ans = ## 0.00000 3.14159 0.00000 3.14159 ## 0.10000 3.14159 6.28319 3.14159 ## @end example ## ## @seealso{wrapTo180, wrapTo360, wraptoPi} ## @end deftypefn function xwrap = wrapTo2Pi(x) xwrap = rem (x-pi, 2*pi); idx = find (abs (xwrap) > pi); xwrap(idx) -= 2*pi * sign (xwrap(idx)); xwrap += pi; endfunction %!test %! x = -9:0.1:9; %! xw = wrapTo2Pi (x); %! assert (sin (x), sin (xw), 8 * eps) %! assert (cos (x), cos (xw), 8 * eps) %! assert (! any (xw < 0)) %! assert (! any (xw > 2 * pi)) %% Test Matlab compatibility as regards closed interval (esp. left) %!test %! assert (wrapTo2Pi ([-2*pi, -pi, 0, pi; 0.1, pi, 4*pi, 5*pi]), ... %! [0, pi, 0, pi; 0.1, pi, 2*pi, pi], 1e-13); mapping-1.2.1/inst/PaxHeaders.3513/nm2deg.m0000644000000000000000000000013212655504456015141 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/nm2deg.m0000644000175000017500000000441012655504456017770 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Pooja Rao ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{deg} =} nm2deg (@var{nm}) ## @deftypefnx {Function File} {@var{deg} =} nm2deg (@var{nm}, @var{radius}) ## @deftypefnx {Function File} {@var{deg} =} nm2deg (@var{nm}, @var{sphere}) ## Converts distance to angle by dividing distance by radius. ## ## Calculates the angles @var{deg} for the distances @var{nm} in a sphere with ## @var{radius} (also in nautical miles). If unspecified, radius defaults to 6371 km, ## the mean radius of Earth and is converted to nautical miles internally. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2deg} ## @end deftypefn ## Author: Pooja Rao function deg = nm2deg (nm, radius = "earth") ## This function converts nautical miles (nm) to degrees (deg) ## Check arguments if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere and convert its default units (km) ## to nautical miles (nm) radius = km2nm (spheres_radius (radius)); ## Check input elseif (! isnumeric (radius) || ! isscalar (radius)) error ("nm2deg: RADIUS must be a numeric scalar"); endif deg = 180 * nm/(pi*radius); endfunction %!test %! ratio = unitsratio ('km','nm'); %! assert (nm2deg (10), km2deg (ratio*10), 10*eps); %! assert (nm2deg (10, 80), km2deg (ratio*10, ratio*80), 10*eps); %! assert (nm2deg (10, "pluto"), km2deg (ratio*10, "pluto"), 10*eps); mapping-1.2.1/inst/PaxHeaders.3513/shapeinfo.m0000644000000000000000000000013212655504456015741 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/shapeinfo.m0000644000175000017500000001273412655504456020600 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014,2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{infs} ] = shapeinfo (@var{fname}) ## Returns a struct with info on shapefile @var{fname}. ## ## Input: ## @table @code ## @item @var{fname} ## (character string). Does not need to have a .shp suffix. ## @end table ## ## Output: a struct with fields: ## ## @table @code ## @item Filename ## Contains the filename of the shapefile. ## ## @item ShapeType ## The type of shapefile. ## ## @item ShapeTypeName ## The name of the shape type. ## ## @item BoundingBox ## The minimum and maximum X and Y coordinates of all items in the shapefile in ## a 2 X 2 array, upper rox min and min Y, lower row max X and max Y. ## ## @item NumFeatures ## The number of features (items, records) in the shapefile. ## ## @item Attributes ## A structure with fields Name and Type (containng the names and types of all ## attributes in the shapefile). Type can be Numeric, Character or Data. ## @end table ## ## @seealso{geoshow, mapshow, shapedraw, shaperead, shapewrite} ## @end deftypefn ## Author: Philip Nienhuis char"); until (ftell (fidp) > flngt - 3); ## i.e., within last ## file byte printf (" \n"); ## Wipe "Counting.." else ## shx file found; no counting required fseek (fidx, 24, "bof"); fxlng = fread (fidx, 1, "int32", 72, "ieee-be"); recn = (fxlng - 50) / 4; fclose (fidx); endif fclose (fidp); ## Return info infs.NumFeatures = recn; ## ====================== 3. .dbf ====================== ## Check if dbfread is available if (isempty (which ("dbfread"))) printf ("shaperead.m: dbfread function not found. No attributes will be added.\n"); printf (" (io package installed and loaded?)\n"); else ## Try to read the .dbf file try [~, B] = dbfread ([bname ".dbf"], 0); infs.Attributes.Name = {B.data.fldnam}; types = {B.data.fldtyp}; types = strrep (types, "N", "Numeric"); types = strrep (types, "C", "Character"); types = strrep (types, "D", "Date"); types = strrep (types, "F", "Floating"); ## FIXME dbase also has type "Logical" infs.Attributes.Type = types; catch printf ("shaperead: file %s couldn't be opened;\n", [ bname ".dbf" ]); printf (" no attributes appended\n"); end_try_catch endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/degtorad.m0000644000000000000000000000013212655504456015556 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/degtorad.m0000644000175000017500000000233412655504456020410 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} deg2rad (@var{anglin}) ## @deftypefnx {Function File} {} degtorad (@var{anglin}) ## Converts angles input in degrees to the equivalent in radians. ## ## @seealso{rad2deg, unitsratio} ## @end deftypefn function anglout = degtorad (anglin) ## This function only exists for Matlab compatibility, but really, ## naming it deg2rad is much more standard (deg2km, ind2rgb, sub2ind) anglout = deg2rad (anglin); endfunction %!assert (degtorad(180),pi,10*eps) mapping-1.2.1/inst/PaxHeaders.3513/radtodeg.m0000644000000000000000000000013212655504456015556 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/radtodeg.m0000644000175000017500000000233412655504456020410 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} rad2deg (@var{anglin}) ## @deftypefnx {Function File} {} radtodeg (@var{anglin}) ## Converts angles input in radians to the equivalent in degrees. ## ## @seealso{deg2rad, unitsratio} ## @end deftypefn function anglout = radtodeg (anglin) ## This function only exists for Matlab compatibility, but really, ## naming it rad2deg is much more standard (deg2km, ind2rgb, sub2ind) anglout = rad2deg (anglin); endfunction %!assert (radtodeg(pi),180,10*eps) mapping-1.2.1/inst/PaxHeaders.3513/degrees2dms.m0000644000000000000000000000013212655504456016171 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/degrees2dms.m0000644000175000017500000001026112655504456021021 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} degrees2dms (@var{deg}) ## Convert decimal degrees to its degrees, minutes, and seconds components. ## ## Separates the fractional part of an angle in decimal degrees and converts ## it into minutes and seconds. Each row of the output corresponds to one ## angle the first and second column to the degree and minute component ## (both integers), and the third to the seconds (which may have a ## fractional part). ## ## @example ## @group ## degrees2dms (10 + 20/60 + 20/3600) ## @result{} [ 10 20 20 ] ## ## degrees2dms (10 + 20/60 + pi) ## @result{} [ 10 28 29.734 ] ## @end group ## @end example ## ## The sign of the first non-zero component indicates the sign of ## the angle, i.e., if the degree and minute components are zero, the sign ## of the seconds indicates the sign of the angle, but if the degree component ## is non-zero, both the minute and second components will be positive ## independently of the sign of the angle. ## ## @example ## @group ## angles = [ 10.5 ## -10.5 ## -0.5 ## 0.5 ]; ## degrees2dms (angles) ## @result{} ## 10 30 0 ## -10 30 0 ## -0 -30 0 ## 0 30 0 ## @end group ## @end example ## ## @seealso{degrees2dm, dm2degrees, dms2degrees} ## @end deftypefn ## Author: Carnë Draug function dms = degrees2dms (deg) if (nargin != 1) print_usage (); endif if (! iscolumn (deg)) warning ("Octave:array-to-vector", "degrees2dms: DEG reshaped into column vector"); endif if (isinteger (deg)) ## If the angles are integers, there is no decimal part ## so this is easy. Also, class must be conserved. dms = [deg(:) zeros(numel (deg), 2, class (deg))]; else ## Everything else is valid and will be converted to double (including ## text and logical). Only class single will be conserved. d = fix (deg(:)); m = fix ((deg(:) - d) * 60); s = rem (deg(:) * 3600, 60); dms = [d m s]; ## We could have also calculated the seconds part with ## (m - fm) * 60 ## where m and fm are the minutes before and after fix(). While ## that performs almost twice as fast, it also leads to some ## precision errors. ## remove sign from any minute and second where its degree part is non-zero nnzd = logical (dms(:,1)); dms(nnzd, 2:3) = abs (dms(nnzd, 2:3)); ## remove sign from any second where its minute is non-zero nnzm = logical (dms(:,2)); dms(nnzm, 3) = abs (dms(nnzm, 3)); endif endfunction %!test %! hs = 0.5/60; %! deg = [ 10 10.5 -10.5 -10 -0.5 0.5 hs 0 -1/60 ]' + hs; %! dms = [ 10 0 30 %! 10 30 30 %! -10 29 30 %! -9 59 30 %! 0 -29 30 %! 0 30 30 %! 0 1 0 %! 0 0 30 %! 0 0 -30]; %! for i = 1:rows (deg) %! assert (degrees2dms (deg(i)), dms(i,:)); %! endfor %! assert (degrees2dms (deg), dms); %! assert (degrees2dms (single (deg)), single (dms), 4*10^-6); %! %! warning ("error", "Octave:array-to-vector", "local") %! got_warn = false; %! try %! degrees2dms (deg'); %! catch %! got_warn = true; %! end_try_catch %! assert (got_warn, true) %!assert (degrees2dms ("f"), [102 0 0]) %!assert (degrees2dms ("fm"), [102 0 0; 109 0 0]) %!assert (degrees2dms (true), [1 0 0]) %!assert (degrees2dms ([true false]), [1 0 0; 0 0 0]) %!assert (degrees2dms (uint8 ([5 48 9]')), uint8 ([5 0 0; 48 0 0; 9 0 0])) mapping-1.2.1/inst/PaxHeaders.3513/shaperead.m0000644000000000000000000000013212655504456015721 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/shaperead.m0000644000175000017500000011322712655504456020557 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014,2015 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} [@var{outstruct} ] = shaperead (@var{shp_filename}) ## @deftypefnx {Function File} [@var{outstruct} ] = shaperead (@var{shp_filename}, @var{outstyle}) ## @deftypefnx {Function File} [@var{outstruct} ] = shaperead (@var{shp_filename}, @var{outstyle}, @var{opts}) ## @deftypefnx {Function File} [@var{outstruct}, @var{atts} ] = shaperead (@var{shp_filename}, ...) ## Read an ArcGis shapefile set (shp, shx and dbf). ## ## Depending on the value of @var{outstyle} some different output formats ## will be returned: ## ## @table @code ## @item 0 (numeric) ## @itemx ml (case-insensitive) ## @itemx m ## Return a Matlab-compatible M X 1 struct with a separate entry for each shape ## feature in the shape file. Each struct element contains fields "Geometry" ## (shape type), "BoundingBox" ([minX minY ; maxX maxY]), X, Y (coordinates of ## points in the shape item as row vectors). For multi-part items, the ## coordinates of each part are separated by NaNs. This output format supports ## neither M and Z type nor MultiPatch shape features. For M and Z type shape ## features the M and Z values will simply be ignored. ## The struct is augmented with attributes found in the accompanying .dbf file, ## if found. ## ## For ML-style output, if only one output argument is requested the attributes ## in the .dbf file will be augmented to that struct. If two output arguments ## are requested, the attributes will be returned separately in output struct ## @var{atts}. ## ## @item 1 (numeric) ## @itemx ext (case-insensitive) ## @itemx e ## Same as 1 but M and Z type and MultiPatch shape features are accepted. The ## resulting output struct is no more ML-compatible. If the shapefile contains ## M and/or Z type shape features the mapstruct or gestruct has extra fields M ## and -optionally- Z. Note that MultiPatch shape features may not have ## M-values even if Z-values are present. For MultiPatch shapes another field ## Parts is added, a Px2 array with zero-based indices to the first vertex of ## each subfeature in the XYZ fields in column 1 and the type of each ## subfeature in column 2; P is the number of shape feature parts. ## ## @item 2 (numeric) ## @itemx oct (case-insensitive) ## @itemx o ## Return a struct containing a N X 6 double array "vals" containing the X, Y, ## and Z coordinates, M-values, record nr. and type of each point in the shape ## file. If no M or Z values were present the relevant columns contain ## NaNs. Individual shape features and shape parts are separated by a row of ## NaN values. The field "idx" contains 1-based pointers into field vals to ## the first vertex of each shape feature. ## Field "bbox" contains an 8 X M double array of XYZ coordinates of the ## bounding boxes and min/max M-values corresponding to the M items found in ## the .shp file; for point shapes these contain NaNs. ## Field "npt" contains a 1 X M array of the number of points for each item. ## Field "npr" contains a 1 X M cell array containing a row of P part indices ## (zero-based) for each Polyline, Polygon or MultiPatch part in the shape ## file; for multipatch each cell contains another row with the part types; ## for other item types (point etc.) the cell array contains empty rows. ## A separate field "shpbox" contains the overall bounding box X, Y and Z ## coordinates and min/max M-values in a 4 X 2 double array. If the shape file ## contains no Z or M values the corresponding columns are filled with NaNs. ## ## The struct field "fields" contains a cellstr array with names of the columns. ## If a corresponding .dbf file was read, the struct array also contains ## a field for each attribute found in the .dbf file with the corresponding ## field name, each containing a 1 X M array of attribute values matching the ## M items in the .shp file. These arrays can be double, char or logical, ## depending on the type found in the .dbf file. ## ## @item 3 (numeric) ## @itemx dat (case-insensitive) ## @itemx d ## Same as OCT or 0 but without a row of NaN values between each shape ## file item in the VALS array. ## @end table ## ## If a character option is given, just one character will suffice. The default ## for @var{outstyle} is "ml". ## ## The output of 'shaperead' can be influenced by property-value pairs. The ## following properties are recognized (of which only the first three ## characters are significant, case doesn't matter): ## ## @table @code ## @item BoundingBox ## Select only those shape items (features) whose bounding box lies within, or ## intersets in at least one point with the limits of the BoundingBox value (a ## 2 X 2 double array [Minx, MinY; MaxX, MaxY]). ## No intersection or clipping with the BoundingBox value will be done by ## default! ## ## @item Clip ## (only useful in conjuction with the BoundingBox property) If a value of 1 or ## true is supplied, clip all shapes to the bounding box limits. This option ## may take quite a bit of processing time. If a value of "0" or false is ## given, do not perform clipping. The default value is 0. ## Clipping is merely meant to be performed in the XY plane. Clipping 3D ## shapes may work to some extent but can lead to unpredictable results; this ## is especially true for MultiPatch shape types. ## For M and Z type polylines and polygons, the M and Z values are linearly ## interpolated for segments crossing the bounding box. As no M and Z values ## can be computed for "new" corner nodes, NaN values are inserted there. ## For clipping polylines and polygons the Octave-Forge geometry and octclip ## packages need to be installed and loaded. ## ## @item Debug ## If a value of 'true' or 1 is given, shaperead echoes the current record ## number while reading. Can be useful for very big shapefiles. The default ## value is 0 (no feedback). If a Matlab-compatible output structarray is ## requested and the Bounding Box property is specified, the extracted shape ## feature indices are added to the field "___Shape_feature_nr___". ## ## @item RecordNumbers ## Select only those records whose numbers are listed as integer values in ## an array following RecordNumbers property. Neither the size nor the class of ## the array matters as long as it is a numeric array. ## ## @item UseGeoCoords ## (Only applicable if a Matlab-style output struct is requested). If a value ## of 'true' (or 1) is supplied, return a geostruct rather than a mapstruct. ## If a value of 0 or false is given, return a mapstruct. ## The mere difference is that in a geostruct the fields 'X' and 'Y' are ## replaced by 'Long' and 'Lat'. The default value is 'false' (return a ## mapstruct'). ## @end table ## ## @seealso{geoshow, mapshow, shapedraw, shapeinfo} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2014-11-07 ## Updates: **** FIXME Please leave this until the next mapping package release *** ## 2014-11-07/10 First draft ## 2014-11-12 Rewrite into more logical struct array ## 2014-11-13 Fix indexing in NaN row insertion for outopts=1 ## 2014-11-14 Added Matlab-compatible output mapstruct option ## 2014-11-15 Removed redundant code leading to a 75 X speed increase ## '' Fix ML-style X and Y coordinates ## 2014-11-16 Add shape type to each struct element for ML-style output ## '' Initial input options parsing ## '' RecordNumbers, UseGeoCoords and BoundingBox implemented ## 2014-11-17 Double output structs (ML-compatible) ## 2014-11-18 Polygon clipping & test for geometry package ## 2014-11-26 Polygon clipping debugged & working ## 2014-11-28 Return empty cell arr if no shape features read ## '' Return full mapstruct array for no output arg ## 2014-11-29 Doubly run inpolygon to include features > and < BoundingBox ## 2014-11-30 Implement Polygon & Point clipping ## 2014-12-15 Last debug of Polyline clipping ## 2014-12-17 Fix MultiPatch reading, esp. detection of missing M (measure) ## 2014-12-29 Implement selecting cellstr attributes in .dbf file ## 2014-12-30 Do not transpose npr values for MultiPatch ## 2015-01-01 Catch null shapes and prevent reading their attributes ## 2015-01-10 Use .shx (if present) to speed up RecordNumbers searches ## 2015-01-12 For outopts=1, apply cell2mat to numeric & logical attributes ## 2015-01-14 Swap outopts values for ml (now 0) and plt style (now 3). In ## passing, fix wrong switch case id at ~L.651. ## '' Reserve outopts = 1 for future use (ML-comp. mapstruct w. Z & M ## atts & multipatch feature type ## 2015-01-19 Do not include/process NULL shape types once record has been read ## 2015-01-27 Stricter checks on ML compatibility for outopts=1; fix some ## wrong references to outopts type, add ext/e for outopts=1; ## update texinfo header; speed-up reading MultiPatch ## 2015-04-19 Make warning setting local ## '' Add filesep to basename ## 2015-07-10 Separate checks for octclip and geometry package ## '' Make rest of warning settings local ## '' Avoid leading filesep in case of no full path name in basename ## '' Improve struct type check and error message ## **** FIXME Please leave this until the next mapping package release *** function [ outs, oatt ] = shaperead (fname, varargin); ## FIXME Implementation needed of these ML input arguments: ## - Selector (supposedly difficult. I'd prefer myself to leave this ## outside of shaperead, it needlessly complicates and slows ## this function /PRN) ## Check input if (nargin < 1) print_usage (); endif ## Check file name [pth, fnm, ext] = fileparts (fname); if (isempty (ext)) bname = fname; fname = [fname ".shp"]; elseif (isempty (pth)) ## Later on bname.shx and bname.dbf will be read bname = fnm; else ## Later on bname.shx and bname.dbf will be read bname = [pth filesep fnm]; endif ## Find out what args have been supplied if (nargin == 1) ## Only filename supplied. Set "ml" (Matlab) type as default outopts = 0; elseif (nargin == 2) ## Assume filename + outopts was supplied outopts = varargin{1}; varargin = {}; elseif (rem (nargin, 2) == 0) ## Even number of input args => Outopts & at least one pair of varargin outopts = varargin{1}; varargin(1) = []; else ## Only filename and varargin supplied outopts = 0; ## Just to be sure check, if output type was selected anyway; it would ## imply a missing opts value if (any (strncmp (varargin{1}, {"ml", "ext", "oct", "dat"}, 1)) || ... isnumeric (varargin{1})) outopts = varargin{1}; varargin(1) = []; endif endif ## Check output type arg if (isnumeric (outopts)) if (outopts < 0 || outopts > 3) error ("shaperead: value for arg. #2 out of range 0-3\n"); endif elseif (ischar (outopts)) outopts = lower (outopts); if (! any (strncmp (outopts, {"ml", "ext", "oct", "dat"}, 1))) error ("shaperead: value for arg. #2 should be one of 'ml', 'ext', 'oct' or 'dat'\n"); endif switch outopts case {"ml", "m"} outopts = 0; case {"ext", "e"} outopts = 0; case {"oct", "o"} outopts = 2; case {"dat", "d"} outopts = 3; otherwise error ("shaperead: illegal value for arg. #2: '%s' - expected 'ml', 'ext', 'oct' of 'dat'", ... outopts); endswitch else error ("shaperead: numeric or character type expected for arg. #2\n"); endif ## ---------------------- 1. .shx ---------------------- ## Open .shx file to help speed up seeks to next records. We need this info ## for s_recs check below have_shx = 0; fidx = fopen ([bname ".shx"], "r"); if (fidx < 0) warning ("shaperead: index file %s not found\n", [fnm ".shx"]); else fseek (fidx, 24, "bof"); fxlng = fread (fidx, 1, "int32", 72, "ieee-be"); nrec = (fxlng - 50) / 4; fseek (fidx, 100, "bof"); ## Get record start positions & -lengths in 16-bit words ridx = reshape (fread (fidx, nrec*2, "int32", 0, "ieee-be"), 2, [])'; fclose (fidx); ## Get indices & lengths in bytes ridx *= 2; endif ## Parse options; first set defaults clip = 0; dbug = 0; s_atts = {}; s_bbox = []; s_geo = 0; s_recs = []; ## Init collection of records that meet BB criteria bb_union = []; ## Process input args for ii = 1:2:length (varargin) switch (lower (varargin{ii})(1:3)) case "att" ## Select records based on attribute values s_atts = varargin{ii+1}; case "bou" ## Select whether record / shape feature points lie inside or outside limits try s_bbox = double (varargin{ii+1}); if (numel (s_bbox) != 4) error ("shaperead: 2 X 2 numeric array expected for BoundingBox\n"); endif catch error ("shaperead: numeric2 X 2 array expected for BoundingBox\n"); end_try_catch ## Initialize supplementary polygon array here sbox = [s_bbox(1) s_bbox(2); s_bbox(1) s_bbox(4); s_bbox(3) s_bbox(4); ... s_bbox(3) s_bbox(2); s_bbox(1) s_bbox(2)]; case "cli" ## Clip polygons to requested BoundingBox try clip = logical (varargin{ii+1}); catch error ("numeric or logical value expected for 'Clip'\n"); end_try_catch case "deb" ## Set verbose output (count records) try dbug = logical (varargin{ii+1}); catch error ("numeric or logical value expected for 'Debug'\n"); end_try_catch case "rec" ## Select record nrs directly. Check for proper type & clean up try s_recs = sort (unique (double (varargin{ii+1}(:)))); have_shx = fidx > 0; if (have_shx && any (s_recs > nrec)) printf ("shaperead: requ. record nos. > nr. of records (%d) ignored\n", ... nrec); s_recs (find (srecs > nrec)) = []; endif catch error ("shaperead: numeric value or array expected for RecordNumbers\n"); end_try_catch case "sel" ## A hard one, to be implemented later? printf ("shaperead: 'Selector' option not implemented, option ignored\n"); case "use" ## Return a geostruct or a mapstruct (default). Only for ML-structs if (outopts != 0) error ("shaperead: UseGeoCoords only valid for Matlab-style output\n"); endif try s_geo = logical (varargin{ii+1}); catch error ("shaperead: logical value type expected for 'UseGeoCoords'\n"); end_try_catch otherwise warning ("shaperead: unknown option '%s' - ignored\n", varargin{ii}); endswitch endfor ## Post-processing if (clip) if (isempty (s_bbox)) warning ("shaperead: no BoundingBox supplied => Clip option ignored.\n"); clip = 0; endif if (isempty (which ("oc_polybool"))) ## No OF octclip package? printf ("shaperead: function 'oc_polybool' not found. Clip option ignored\n"); warning (" (OF octclip package installed and loaded?)\n"); clip = 0; endif if (isempty (which ("distancePoints"))) ## No OF geometry package? printf ("shaperead: function 'distancePoints' not found. Clip option ignored\n"); warning (" (OF geometry package installed and loaded?)\n"); clip = 0; endif endif ## ============= Preparations done, now we can start reading ============ ## ---------------------- 2. Read .shp file proper ---------------------- ## Start reading header fidp = fopen (fname, 'r'); if (fidp < 0) error ("shaperead: couldn't open file %s\n", fname); endif fseek (fidp, 0, "bof"); ## Read & check file code fcode = fread (fidp, 1, "int32", 20, "ieee-be"); if (fcode != 9994) error ("%s is not a valid shapefile\n", fname); endif flngt = fread (fidp, 1, "int32", 0, "ieee-be") * 2; fvsn = fread (fidp, 1, "int32", 0, "ieee-le"); shpt = fread (fidp, 1, "int32"); ## Shape file type shpbox.X(1) = fread (fidp, 1, "double"); shpbox.Y(1) = fread (fidp, 1, "double"); shpbox.X(2) = fread (fidp, 1, "double"); shpbox.Y(2) = fread (fidp, 1, "double"); shpbox.Z(1) = fread (fidp, 1, "double"); shpbox.Z(2) = fread (fidp, 1, "double"); shpbox.M(1) = fread (fidp, 1, "double"); shpbox.M(2) = fread (fidp, 1, "double"); ## FIXME: scan shp file in advance to assess nr of XY points, to be able to ## preallocate rec array. May be difficult, .shp is not favorable for ## it. Initial tries showed no significant speed advantage yet over ## the incremental allocation scheme implemented in Ls. 611+ & 631+ ## for oct/plt style output. For ml-style it is much harder as ## we'd need to preallocate a potentially very heterogeneous strtuct ## array. ## Prepare for unsupported (in ML output) shape types unsupp = 0; ign_mz = (outopts == 0); ## Buffer for record data BUFSIZE = 10000; ## Read records, 1 by 1. Initialize final array vals = npt = npr = bbox = idx = nullsh = []; ## Init nr. of shapes read nshp = 0; ## Temp pointer to keep track of array size and increase it w. BUFSIZE rows ivals = 1; ## Assume file has M (measure) values has_M = true; ## Record index number (equals struct element number) ir = 1; do ## If the .shx file is there, skip directly to requested record if (have_shx) fseek (fidp, ridx(s_recs(ir), 1), "bof"); endif if (dbug) printf ("Reading record %d ...\r", ir); endif val = NaN(1, 6); ## Read record index number & record length val(5) = fread (fidp, 1, "int32", 0, "ieee-be"); rlen = fread (fidp, 1, "int32", 0, "ieee-be"); ## Here we decide if the record need be read at all, based on s_recs if (isempty (s_recs) || ismember (double (val(5)), s_recs)) ## => this record # has been desired; proceed. Read shape feature type val(6) = fread (fidp, 1, "int32"); rincl = 1; ## see s_bbox, below ## Init values for this shape item tbbox = NaN(1, 8); switch val(6) case 1 ## Point val(1:2) = fread (fidp, 2, "double"); val(3:4) = NaN; tnpt = 1; tnpr = 0; case 11 ## PointZ val(1:4) = fread (fidp, 4, "double"); tnpt = 1; tnpr = 0; case 21 ## PointM val(1:2) = fread (fidp, 2, "double"); ## "Z" val(3) = 0; ## M val(4) = fread (fidp, 1, "double"); tnpt = 1; tnpr = 0; case 8 ## Multipoint ## Read bounding box tbbox = fread (fidp, 4, "double"); tnpt = fread (fidp, 1, "int32"); val = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; val(1:tnpt, 3:4) = NaN; ## Copy rec index & type down val(2:tnpt, 5:6) = val(1, 5:6); tnpr = 0; case 18 ## MultipointZ tbbox = fread (fidp, 4, "double"); tnpt = fread (fidp, 1, "int32"); val(1:tnpt, 1:2) = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; ## Z min & max values tbbox(5:6) = fread (fidp, 2, "double"); ## Augment val array with Z values val(1:tnpt, 3) = [ rec(ir).points fread(fidp, tnpt, "double")' ]; ## M min & max values tbbox(7:8) = fread (fidp, 2, "double"); ## Augment val array with M values val(1:tnpt, 4) = [ rec(ir).points fread(fidp, tnpt, "double")' ]; ## Copy rec index & type down val(2:tnpt, 5:6) = repmat (val(1, 5:6), tnpt-1, 1); tnpr = 0; case 28 ## MultipointM tbbox(1:4) = fread (fidp, 4, "double"); tnpt = fread (fidp, 1, "int32"); val(1:tnpt, 1:2) = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; ## Insert empty column for Z val(1:tnpt, 4) = NaN; ## M min & max values bbox(7:8) = fread (fidp, 2, "double"); ## Augment val array with Z values val(1:tnpt, 4) = [ rec(ir).points fread(fidp, tnpt, "double")' ]; ## Copy rec index & type down val(2:tnpt, 5:6) = repmat (val(1, 5:6), tnpt-1, 1); tnpr = 0; case {3, 5} ## Polyline/-gon tbbox(1:4) = fread (fidp, 4, "double"); ## Read nparts, npoints, nparts pointers nparts = fread (fidp, 1, "int32"); tnpt = fread (fidp, 1, "int32"); tnpr = fread (fidp, nparts, "int32")'; ## Read XY point coordinates val(1:tnpt, 1:2) = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; ## No Z or M data val(1:tnpt, 3:4) = NaN; ## Copy rec index and type down val(2:tnpt, 5:6) = repmat (val(1, 5:6), tnpt-1, 1); case {13, 15} ## Polyline/-gonZ tbbox(1:4) = fread (fidp, 4, "double"); ## Read nparts, npoints, nparts pointers nparts = fread (fidp, 1, "int32"); tnpt = fread (fidp, 1, "int32"); tnpr = fread (fidp, nparts, "int32")'; ## Read XY point coordinates val(1:tnpt, 1:2) = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; ## Z min & max values + data tbbox(5:6) = fread (fidp, 2, "double"); val(1:tnpt, 3) = fread(fidp, tnpt, "double")'; ## M min & max values + data tbbox(7:8) = fread (fidp, 2, "double"); val(1:tnpt, 4) = fread(fidp, tnpt, "double")'; ## Copy rec index and type down val(2:tnpt, 5:6) = repmat (val(1, 5:6), tnpt-1, 1); case {23, 25} ## Polyline/-gonM tbbox(1:4) = fread (fidp, 4, "double"); ## Read nparts, npoints, nparts pointers nparts = fread (fidp, 1, "int32"); tnpt = fread (fidp, 1, "int32"); tnpr = fread (fidp, nparts, "int32")'; ## Read XY point coordinates val(1:tnpt, 1:2) = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; ## No Z data val(1:tnpt, 3) = NaN; ## M min & max values + data tbbox(7:8) = fread (fidp, 2, "double"); val(1:tnpt, 4) = fread(fidp, tnpt, "double")'; ## Copy rec index and type down val(2:tnpt, 5:6) = repmat (val(1, 5:6), tnpt-1, 1); case 31 ## Multipatch tbbox(1:4) = fread (fidp, 4, "double"); ## Read nparts, npoints, nparts pointers, npart types nparts = fread (fidp, 1, "int32"); tnpt = fread (fidp, 1, "int32"); ## Npart types is just another row under npart pointers => read both. ## Provisionally transpose, this is later on reset after NaN insertion tnpr = reshape (fread (fidp, nparts*2, "int32")', [], 2)'; ## Read XY point coordinates % val = NaN (tnpt + size (tnpr, 2) - 1, 6); % ipt = 1; % ttnpr = [tnpr(1, :) tnpt]; % for ii=2:numel (ttnpr) % val(ipt:ipt+ttnpr(ii)-1, 1:2) = ... % reshape (fread (fidp, ttnpr(ii)*2, "double"), 2, [])'; % ipt +=ttnpr(ii) + 1; % endfor val(1:tnpt, 1:2) = reshape (fread (fidp, tnpt*2, "double"), 2, [])'; ## Z min & max values + data. Watch out for incomplete .shp file EOF = (ftell (fidp) > flngt-2); if (! EOF) tbbox(5:6) = fread (fidp, 2, "double"); val(1:tnpt, 3) = fread(fidp, tnpt, "double")'; endif fptr = ftell (fidp); EOF = (fptr > flngt-2); if (! EOF && has_M) ## Check if the file really contains M values: try to read ("peek") ## three int32 record numbers matching the next record nr. to be ## read, the next record length and 31 (= MultiPatch type) tmp = fread (fidp, 2, "int32", 0, "ieee-be"); tmp(3) = fread (fidp, 1, "int32"); fseek (fidp, fptr, "bof"); if (tmp(1) == (val(1, 5) + 1) && tmp(3) == 31) ## Undoubtedly a record index number. has_M = false; ## Empirically the min/maxM values in file header mean nothing, so shpbox.M(1) = 0; shpbox.M(2) = 0; endif endif ## M min & max values + data. Watch out for incomplete .shp file if (! EOF && has_M) tbbox(7:8) = fread (fidp, 2, "double"); val(1:tnpt, 4) = fread(fidp, tnpt, "double")'; endif ## Copy rec index and type down val(2:tnpt, 5:6) = repmat (val(1, 5:6), tnpt-1, 1); otherwise ## E.g., null shape (0) ## Keep track of null shapes to avoid reading associated attributes if (val(1, 6) == 0) nullsh = [ nullsh ir ]; rincl = 0; elseif (abs(val(1, 6)) > 31) error ("shaperead.m: unexpected shapetype value %f for feature # %d\n\ Looks like a faulty shape file.", val(1, 6), ir); endif endswitch ## Detect if shape lies (partly) within or completely out of BoundingBox. ## Null shapes are automatically skipped if (! isempty (s_bbox)) ## Just check if any shape feature bounding box corner lies in s_bbox tbox = [tbbox(1) tbbox(2); tbbox(1) tbbox(4); ... tbbox(3) tbbox(4); tbbox(3) tbbox(2); tbbox(1) tbbox(2)]; rincl = 0; ## For polygons, polylines & multipatches: if (ismember (val(1, 6), [3, 13, 23, 5, 15, 25, 31])) ## Polygon/line ## To avoid undue CPU time for large shapes we take a shortcut: ## Check if shape feature lies in BoundingBox... [a, b] = inpolygon (tbox(:, 1), tbox(:, 2), sbox(:, 1), sbox(:, 2)); ## ...or BoundingBox lies in polyline/gon. Faster than indiv. points [c, d] = inpolygon (sbox(:, 1), sbox(:, 2), tbox(:, 1), tbox(:, 2)); if (any ([a; b; c; d])) ## At least one of the shape item bbox corners lies within s_bbox rincl = 1; bb_union = unique ([bb_union val(1, 5)]); ## FIXME still the case of polygon edges intersecting bounding box ## w/o vertices inside bounding box. Clipping required for that endif elseif (ismember (val(1, 6), [1, 11, 21])) ## (Multi-)Point ## Simply select all points within or on boundaries [a, b] = inpolygon (val(:, 1), val(:, 2), sbox(:, 1), sbox(:, 2)); val = val(find(a), :); tnpt = size (val, 1); if (tnpt) rincl = 1; endif endif ## If clipping has been selected, clip all parts of the shape feature if (rincl && clip) ## What to do depends on shape type. Null and MultiPatch aren't clipped switch val(1, 6) case {3, 13, 33} ## Polyline ## Temporarily silence Octave a bit, then call clipplg warning ("off", "Octave:broadcast", "local"); [val, tnpt, tnpr] = clippln (val, tnpt, tnpr, sbox, val(1, 6)); case {5, 15, 25, 31} ## Polygon, Multipatch ## Temporarily silence Octave a bit, then call clipplg warning ("off", "Octave:broadcast", "local"); [val, tnpt, tnpr] = clipplg (val, tnpt, tnpr, sbox, val(1, 6)); otherwise warning ("shaperead: unknown shape type found (%d) - ignored\n", ... val(1, 6)); rincl = 0; val = []; endswitch if (isempty (val)) ## Don't include it and remove last added bb_union entry bb_union(end) = []; rincl = 0; else ## Update bounding box tbbox(1) = min (val(:, 1)); tbbox(2) = min (val(:, 2)); tbbox(3) = max (val(:, 1)); tbbox(4) = max (val(:, 2)); endif endif endif ## What to do with the val data, if to be included if (rincl) ## Keep track of nr of shape features read ++nshp; if (outopts < 3) ## Prepare an Octave or Matlab style struct optimized for fast ## plotting by inserting a NaN row after each polyline/-gon part nn = size (tnpr, 2); valt = NaN(tnpt + nn - 1, 6); ipt = 1; ttnpr = [tnpr(1, :) tnpt]; dtnpr = diff (ttnpr); for ii=2:numel (ttnpr) valt(ipt:ipt+dtnpr(ii-1)-1, :) = val(ttnpr(ii-1)+1:ttnpr(ii), :); ipt += dtnpr(ii-1) + 1; endfor val = valt; tnpr(1, :) = (tnpr(1, :) + [0:numel(dtnpr)-1]); endif ## Shape either included by default or it lies in requested BoundingBox switch outopts case {0, 1, "ml", "e"} ## Return a ML compatible mapstruct. Attributes will be added later if (ign_mz && val(1, 6) >= 10) printf ("shaperead: M and Z values ignored for ml-style output\n"); ign_mz = 0; endif switch val(1, 6) case {1, 11, 21} ## Point outs(end+1).Geometry = "Point"; case {8, 18, 28} ## Multipoint outs(end+1).Geometry = "MultiPoint"; case {3, 13, 23} ## Polyline outs(end+1).Geometry = "Line"; case {5, 15, 25} ## Polygon outs(end+1).Geometry = "Polygon"; otherwise if (outopts == 1) ## "Extended" ML-style output struct if (val(1, 6) == 31) ## MultiPatch outs(end+1).Geometry = "MultiPatch"; outs(end).Parts = tnpr; endif else if (! unsupp) warning ("shaperead: shapefile contains unsupported shape types\n"); outs = []; return endif outs(end+1).Geometry = val(1, 6); endif endswitch outs(end).BoundingBox = reshape (tbbox(1:4), 2, [])'; if (s_geo) outs(end).Lon = val(:, 1)'; outs(end).Lat = val(:, 2)'; else outs(end).X = val(:, 1)'; outs(end).Y = val(:, 2)'; endif ## (ML-incompatible) add Z- and optional M-values, if any if (outopts == 1 && any (isfinite (val(:, 4)))) outs(end).M = val(:, 4)'; ## FIXME Decision needed if field Geometry should reflect the type ## outs{end}.Geometry = [ outs{end}.Geometry "M"]; endif if (outopts == 1 && any (isfinite (val(:, 3)))) outs(end).Z = val(:, 3)'; ## FIXME Decision needed if field Geometry should reflect the type ## outs{end}.Geometry = [ outs{end}.Geometry "Z"]; endif ## (ML-incompatible) add Z- and optional M-values, if any if (dbug) ## Add a field with shape feature identifier for boundingbox outs(end).___Shape_feature_nr___ = val(1, 5); endif case {2, "oct"} ## Append to vals array; keep track of appended nr. of rows lvals = size (vals, 1); lval = size (val, 1); if ((size (vals, 1) - ivals) < lval) ## Increase size of vals vals = [ vals; NaN(BUFSIZE, 6) ]; endif vals(ivals:ivals+lval-1, :) = val; idx = [idx ; ivals]; ivals += lval; ## Add a row of NaNs vals(ivals, :) = NaN(1,6); ++ivals; ## Append the other arrays npt = [npt; tnpt]; if (isempty (npr)) npr = {tnpr}; else npr = [npr; {tnpr}]; endif bbox = [bbox; tbbox]; case {3, "dat"} ## Return an Octave style struct. ## Simply append to vals array; keep track of appended nr. of rows lvals = size (vals, 1); lval = size (val, 1); if ((size (vals, 1) - ivals) < lval) ## Increase size of vals vals = [ vals; NaN(BUFSIZE, 6) ]; endif vals(ivals:ivals+lval-1, :) = val; idx = [idx ; ivals]; ivals += lval; ## Append the other arrays npt = [npt; tnpt]; if (isempty (npr)) npr = {tnpr}; else npr = [npr; {tnpr}]; endif bbox = [bbox; tbbox]; otherwise endswitch endif else ## Record not in s_recs list, skip rest of record fread (fidp, (rlen*2), "char=>char"); endif ## Next .shp record ++ir; until (ftell (fidp) > flngt - 3 || (have_shx && ir > numel (s_recs))); ## i.e., within last ## file bytes or fclose (fidp); ## If no shape was read, or none fitted within BoundingBox, return empty if (nshp < 1) outs = {}; return; endif ## ------------------------ Post-processing ------------------------ if (outopts > 1) ## Octave-style outstruct. Truncate vals to proper length vals = vals(1:ivals-1, :); if (outopts == 2 && ! isempty (vals)) ## Remove last NaN row vals(end, :) = []; endif if (isempty (vals)) s_recs = 0; endif endif if (dbug) if (outopts <= 1) ii = numel (outs); else ii = numel (npt); endif printf ("\n%d records read. \n", ii); endif ## For Octave style output, add separate arrays to output struct if (outopts >= 2) outs.shpbox = shpbox; outs.vals = vals; outs.bbox = bbox; outs.npt = npt; outs.npr = npr; outs.idx = idx; ## Clear memory (for very large shape files) clear shpbox vals bbox npt npr idx val; outs = setfield (outs, "fields", {"shpbox", "vals", "bbox", "npt", "npr"}); endif ## Clean up s_recs and bb_union if (! isempty (s_bbox)) s_recs = sort (unique (bb_union)); else s_recs = sort (unique (s_recs)); endif ## Weed out any null shape records to prevent reading their attributes if (! isempty (nullsh)) if (! isempty (s_recs)) s_recs = [1:numel (npt)]; endif s_recs (ismember (nullsh, s_recs)) = []; endif ## ---------------------- 3. .dbf ---------------------- ## Check if dbfread is available if (isempty (which ("dbfread"))) printf ("shaperead.m: dbfread function not found. No attributes will be added.\n"); printf (" (io package installed and loaded?)\n"); else ## Try to read the .dbf file try atts = dbfread ([ bname ".dbf" ], s_recs, s_atts); if (outopts < 2) ## First check if any attributes match fieldnames; if so, pre-/append "_" tags = {"shpbox", "vals", "bbox", "npt", "npr", "idx", "Geometry", ... "BoundingBox", "X", "Y", "Lat", "Lon"}; for ii=1:numel (tags) idx = find (strcmp (tags{ii}, atts(1, :))); if (! isempty (idx)) atts(1, idx) = ["_" atts{1, idx} "_"]; endif endfor ## Matlab style map-/geostruct. Divide attribute values over struct elems if (nargout < 2) ## Attributes appended to outs struct for ii=1:size (atts, 2) [outs.(atts{1, ii})] = deal (atts(2:end, ii){:}); endfor oatt = []; else ## Attributes separately in oatt struct oatt(size (atts, 1) - 1).(atts{1, 1}) = []; for ii=1:size (atts, 2) [oatt.(atts{1, ii})] = deal (atts(2:end, ii){:}); endfor endif else ## Octave output struct. Add attributes columns as struct fields for ii=1:size (atts, 2) outs.fields(end+1) = atts{1, ii}; if (islogical (atts{2, ii}) || isnumeric (atts{2, ii})) outs = setfield (outs, atts{1, ii}, cell2mat (atts(2:end, ii))); else outs = setfield (outs, atts{1, ii}, atts(2:end, ii)); endif endfor atts = []; endif catch printf ("shaperead: file %s couldn't be read;\n", [ bname ".dbf" ]); printf (" no attributes appended\n"); end_try_catch endif endfunction mapping-1.2.1/inst/PaxHeaders.3513/wrapTo360.m0000644000000000000000000000013212655504456015472 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/wrapTo360.m0000644000175000017500000000354212655504456020326 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2015 Oscar Monerris Belda ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{xwrap} =} wrapTo360 (@var{x}) ## ## Wraps X into the [0 to 360] interval. ## ## @var{x}: angle(s) in degrees (single value, vector or ND matrix). ## ## @var{xwrap}: output value(s) in the range [0 .. 360] degrees. ## The interval [0 .. 360] is a closed interval: values equal to ## zero or negative even multiples of 360 are mapped to 0, values ## equal to an even multiple of 360 are mapped to 360. ## ## Example: ## @example ## wrapTo360 ([-720, -360, 0; 10, 360, 720]) ## ans = ## 0 0 0 ## 10 360 360 ## @end example ## ## @seealso{wrapTo180, wrapToPi, wrapto2Pi} ## @end deftypefn function xwrap = wrapTo360(x) xwrap = rem (x-180, 360); idx = find (abs (xwrap) > 180); xwrap(idx) -= 360 * sign (xwrap(idx)); xwrap += 180; endfunction %!test %! x = -800:0.1:800; %! xw = wrapTo360 (x); %! assert (sind (x), sind (xw), 16 * eps) %! assert (cosd (x), cosd (xw), 16 * eps) %! assert (! any (xw < 0)) %! assert (! any (xw > 360)) %% Test Matlab compatibility as regards closed interval (esp. left) %!test %! assert (wrapTo360 ([-720, -360, 0; 10, 360, 720]), ... %! [0, 0, 0; 10, 360, 360], 1e-13); mapping-1.2.1/inst/PaxHeaders.3513/dms2degrees.m0000644000000000000000000000013212655504456016171 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/dms2degrees.m0000644000175000017500000000671112655504456021026 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} dms2degrees (@var{dms}) ## Convert degrees, and minutes components into decimal degrees. ## ## @var{dms} must be a 3 column matrix with one row per angle, and each ## column correspoding to its degrees (an integer), minutes (a less than ## 60 integer, and seconds (a less than 60 value, possibly fractional) ## components. ## ## The sign of the angle must be defined on its first non-zero component only, ## i.e., if an angle is negative, the seconds component must be positive ## unless both minutes and degrees are zero, and the minutes component ## must be positive unless the degrees component is zero. ## ## @seealso{degrees2dm, degree2dms, dm2degrees} ## @end deftypefn ## Author: Carnë Draug function deg = dms2degrees (dms) if (nargin != 1) print_usage (); elseif (! isnumeric (dms) || ndims (dms) != 2 || columns (dms) != 3) error ("dms2degrees: DMS must be a numeric matrix with 3 columns"); elseif (any (fix (dms(:,1)) != dms(:,1))) error ("dms2degrees: degrees component (first column) must be an integer"); elseif (any (dms(:,2) >= 60)) error ("dms2degrees: minutes component (second column) must be less than 60"); elseif (any (dms(:,3) >= 60)) error ("dms2degrees: seconds component (third column) must be less than 60"); endif ## join the degrees and minutes parts adms = abs (dms); deg = sum ([adms(:,1) adms(:,2)/60 adms(:,3)/3600], 2); ## change the sign if any part is negative and check that negative ## sign is present on the first non-zero part only negs = dms < 0; nnz_d = dms(:,1) != 0; nnz_m = dms(:,2) != 0; if (any ((nnz_d | nnz_m) & negs(:,3))) error ("dms2degrees: second must be positive if degree or minute is non-zero"); elseif (any (nnz_d & negs(:,2))) error ("dms2degrees: minute must be positive if degree is non-zero"); endif deg(any (negs, 2)) *= -1; endfunction %!test %! hs = 0.5/60; %! deg = [ 10 10.5 -10.5 -10 -0.5 0.5 hs 0 -1/60 ]' + hs; %! dms = [ 10 0 30 %! 10 30 30 %! -10 29 30 %! -9 59 30 %! 0 -29 30 %! 0 30 30 %! 0 1 0 %! 0 0 30 %! 0 0 -30]; %! for i = 1:rows (dms) %! assert (dms2degrees (dms(i,:)), deg(i), 2*10^-15); %! endfor %! assert (dms2degrees (dms), deg, eps*10); %! assert (dms2degrees (single (dms)), single (deg), 3*10^-8); %!error dms2degrees ([5 40 60]) %!error dms2degrees ([5 40 61]) %!error <3 columns> dms2degrees ([5 50]) %!error dms2degrees ([5 -40 9]) %!error dms2degrees ([-5 -40 9]) %!error dms2degrees ([0 -40 -9]) %!error <3 columns> dms2degrees (rand (7, 3, 3)) mapping-1.2.1/inst/PaxHeaders.3513/km2nm.m0000644000000000000000000000013212655504456015011 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/km2nm.m0000644000175000017500000000257312655504456017650 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Eugenio Gianniti ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} km2nm (@var{km}) ## Convert kilometers into nautical miles. ## ## @seealso{km2sm, nm2km, nm2sm, sm2km, sm2nm} ## @end deftypefn ## Author: Eugenio Gianniti function nm = km2nm (km) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("nautical mile", "kilometer"); nm = km * ratio; endfunction %!test %! km = [1.8520 3.7040 5.5560 7.4080 12.9640 14.8160]; %! nm = [1 2 3 4 7 8]; %! assert (km2nm (km), nm) %! km = reshape (km, [1 3 2]); %! nm = reshape (nm, [1 3 2]); %! assert (km2nm (km), nm) %!assert (km2nm (1.852), 1) mapping-1.2.1/inst/PaxHeaders.3513/unitsratio.m0000644000000000000000000000013212655504456016166 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/inst/unitsratio.m0000644000175000017500000004256512655504456021032 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} unitsratio (@var{to}, @var{from}) ## Return ratio for conversion between units. ## ## Returns the conversion ratio between two units, @var{to} and @var{from}, so ## that: ## ## @group ## @example ## unitsratio ("meter", "centimeter") ## @result{ratio } 100 ## ## unitsratio ("inch", "foot") ## @result{ratio } 12 ## @end example ## @end group ## ## This allows for easy conversion between units, for example: ## ## @group ## @example ## unitsratio ("mile", "km") * 156 ## @result{156 km in miles }96.93391 ## @end example ## @end group ## ## For conversion between angle units, @qcode{"degrees"} and ## @qcode{"radians"} are supported. For conversion between length units, ## supports units defined in @code{validateLengthUnit}. ## ## @seealso{units, validateLengthUnit} ## @end deftypefn ## Author: Carnë Draug function ratio = unitsratio (to, from) if (nargin != 2) print_usage (); endif try valid_to = validatestring (to, {"radians", "degrees"}); valid_from = validatestring (from, {"radians", "degrees"}); catch valid_to = validateLengthUnit (to, "unitsratio", "TO"); valid_from = validateLengthUnit (from, "unitsratio", "FROM"); end_try_catch persistent ratios = struct ( ## angle units "degrees", struct ( "degrees", 1, "radians", pi / 180 ), "radians", struct ( "degrees", 180 / pi, "radians", 1 ), ## length units "meter", struct ( "meter", 1, "centimeter", 100, "millimeter", 1000, "micron", 10^6, "kilometer", 0.001, "nautical mile", 1 / 1852, "foot", 1 / 0.3048, "inch", 1 / 0.0254, "yard", 1 / 0.9144, "mile", 1 / 1609.344, "U.S. survey foot", 3937 / 1200, "U.S. survey mile (statute mile)", 3937 / (1200 * 5280), # 5280 survey foot "Clarke's foot", 1 / 0.3047972654, "German legal metre", 1 / 1.0000135965, "Indian foot", 1 / 0.3047996 ), ## same as meter times 0.01 "centimeter", struct ( "meter", 0.01, "centimeter", 0.01 * 100, "millimeter", 0.01 * 1000, "micron", 0.01 * 10^6, "kilometer", 0.01 * 0.001, "nautical mile", 0.01 / 1852, "foot", 0.01 / 0.3048, "inch", 0.01 / 0.0254, "yard", 0.01 / 0.9144, "mile", 0.01 / 1609.344, "U.S. survey foot", 0.01 * (3937 / 1200), "U.S. survey mile (statute mile)", 0.01 * 3937 / (1200 * 5280), "Clarke's foot", 0.01 / 0.3047972654, "German legal metre", 0.01 / 1.0000135965, "Indian foot", 0.01 / 0.3047996 ), ## same as meter times 0.001 "millimeter", struct ( "meter", 0.001, "centimeter", 0.001 * 100, "millimeter", 0.001 * 1000, "micron", 0.001 * 10^6, "kilometer", 0.001 * 0.001, "nautical mile", 0.001 / 1852, "foot", 0.001 / 0.3048, "inch", 0.001 / 0.0254, "yard", 0.001 / 0.9144, "mile", 0.001 / 1609.344, "U.S. survey foot", 0.001 * (3937 / 1200), "U.S. survey mile (statute mile)", 0.001 * 3937 / (1200 * 5280), "Clarke's foot", 0.001 / 0.3047972654, "German legal metre", 0.001 / 1.0000135965, "Indian foot", 0.001 / 0.3047996 ), ## same as meter times 10^-6 "micron", struct ( "meter", 10^-6, "centimeter", 10^-6 * 100, "millimeter", 10^-6 * 1000, "micron", 10^-6 * 10^6, "kilometer", 10^-6 * 0.001, "nautical mile", 10^-6 / 1852, "foot", 10^-6 / 0.3048, "inch", 10^-6 / 0.0254, "yard", 10^-6 / 0.9144, "mile", 10^-6 / 1609.344, "U.S. survey foot", 10^-6 * (3937 / 1200), "U.S. survey mile (statute mile)", 10^-6 * 3937 / (1200 * 5280), "Clarke's foot", 10^-6 / 0.3047972654, "German legal metre", 10^-6 / 1.0000135965, "Indian foot", 10^-6 / 0.3047996 ), ## same as meter times 1000 "kilometer", struct ( "meter", 1000, "centimeter", 1000 * 100, "millimeter", 1000 * 1000, "micron", 1000 * 1000000, "kilometer", 1000 * 0.001, "nautical mile", 1000 / 1852, "foot", 1000 / 0.3048, "inch", 1000 / 0.0254, "yard", 1000 / 0.9144, "mile", 1000 / 1609.344, "U.S. survey foot", 1000 * (3937 / 1200), "U.S. survey mile (statute mile)", 1000 * 3937 / (1200 * 5280), "Clarke's foot", 1000 / 0.3047972654, "German legal metre", 1000 / 1.0000135965, "Indian foot", 1000 / 0.3047996 ), ## exactly 1852 meters "nautical mile", struct ( "meter", 1852, "centimeter", 1852 * 100, "millimeter", 1852 * 1000, "micron", 1852 * 10^6, "kilometer", 1852 * 0.001, "nautical mile", 1, "foot", 2315000 / 381, # thank you wikipedia "inch", 27780000 / 381, "yard", 2315000 / 1143, # thank you wikipedia "mile", 1852 / 1609.344, # from how many meters are in a mile "U.S. survey foot", 1852 * 3937 / 1200, # from how many meters are in US survey foot "U.S. survey mile (statute mile)", 57875 / 50292, "Clarke's foot", 1852 / 0.3047972654, "German legal metre", 1852 / 1.0000135965, "Indian foot", 1852 / 0.3047996 # from how many meters are in an indian foot ), ## exactly 0.3048 meters. Also 12 inch "foot", struct ( "meter", 0.3048, "centimeter", 0.3048 * 100, "millimeter", 0.3048 * 1000, "micron", 0.3048 * 10^6, "kilometer", 0.3048 * 0.001, "nautical mile", 381 / 2315000, # inverse from nautical mile to foot "foot", 1, "inch", 12, "yard", 1 / 3, "mile", 1 / 5280, "U.S. survey foot", 0.3048 / (1200 / 3937), "U.S. survey mile (statute mile)", (5280 * 3977) / (0.3048 * 1200), "Clarke's foot", 0.3048 / 0.3047972654, "German legal metre", 0.3048 / 1.0000135965, "Indian foot", 0.3048 / 0.3047996 ), ## exactly 0.0254 meters "inch", struct ( "meter", 0.0254, "centimeter", 0.0254 * 100, "millimeter", 0.0254 * 1000, "micron", 0.0254 * 10^6, "kilometer", 0.0254 * 0.001, "nautical mile", 381 / 27780000, # inverse from nautical mile to inch "foot", 1 / 12, "inch", 1, "yard", 1 / 36, "mile", 1 / (5280 * 12), "U.S. survey foot", 0.0254 / (1200 / 3937), "U.S. survey mile (statute mile)", (5280 * 3977) / (0.0254 * 1200), "Clarke's foot", 0.0254 / 0.3047972654, "German legal metre", 0.0254 / 1.0000135965, "Indian foot", 0.0254 / 0.3047996 ), ## exactly 0.9144 meters. Also 3 feet "yard", struct ( "meter", 0.9144, "centimeter", 0.9144 * 100, "millimeter", 0.9144 * 1000, "micron", 0.9144 * 10^6, "kilometer", 0.9144 * 0.001, "nautical mile", 1143 / 2315000, # inverse from nautical mile to yard "foot", 3, "inch", 36, "yard", 1, "mile", 3 / 5280, "U.S. survey foot", 0.9144 / (1200 / 3937), "U.S. survey mile (statute mile)", (5280 * 3977) / (0.9144 * 1200), "Clarke's foot", 0.9144 / 0.3047972654, "German legal metre", 0.9144 / 1.0000135965, "Indian foot", 0.9144 / 0.3047996 ), ## exactly 1609.344 meters. Also 5280 feet "mile", struct ( "meter", 1609.344, "centimeter", 1609.344 * 100, "millimeter", 1609.344 * 1000, "micron", 1609.344 * 10^6, "kilometer", 1609.344 * 0.001, "nautical mile", 1609.344 / 1852, "foot", 5280, "inch", 5280 * 12, "yard", 5280 / 3, "mile", 1, "U.S. survey foot", 1609.344 / (1200 / 3937), "U.S. survey mile (statute mile)", (5280 * 3977) / (1609.344 * 1200), "Clarke's foot", 1609.344 / 0.3047972654, "German legal metre", 1609.344 / 1.0000135965, "Indian foot", 1609.344 / 0.3047996 ), ## exactly 1200 / 3937 "U.S. survey foot", struct ( "meter", 1200 / 3937, "centimeter", 100 * 1200 / 3937, "millimeter", 1000 * 1200 / 3937, "micron", 10^6 * 1200 / 3937, "kilometer", 0.001 * 1200 / 3937, "nautical mile", 1200 / (1852 * 3937), "foot", (1200 / 3937) / 0.3048, "inch", (1200 / 3937) / 0.0254, "yard", (1200 / 3937) / 0.9144, "mile", (1200 / 3937) / 1609.344, "U.S. survey foot", 1, "U.S. survey mile (statute mile)", 1 / 5280, "Clarke's foot", 1200 / (0.3047972654 * 3937), "German legal metre", 1200 / (1.0000135965 * 3937), "Indian foot", 1200 / (0.3047996 * 3937) ), ## the U.S. survey mile is 5280 survey feet (survey foot = 1200 / 3937 meters) "U.S. survey mile (statute mile)", struct ( "meter", 5280 * 1200 / 3937, "centimeter", 100 * 5280 * 1200 / 3937, "millimeter", 1000 * 5280 * 1200 / 3937, "micron", 10^6 * 5280 * 1200 / 3937, "kilometer", 0.001 * 5280 * 1200 / 3937, "nautical mile", 50292 / 57875, "foot", (0.3048 * 1200) / (5280 * 3977), "inch", (0.0254 * 1200) / (5280 * 3977), "yard", (0.9144 * 1200) / (5280 * 3977), "mile", (1609.344 * 1200) / (5280 * 3977), "U.S. survey foot", 5280, "U.S. survey mile (statute mile)", 1, "Clarke's foot", (5280 * 1200) / (0.3047972654 * 3937), "German legal metre", (5280 * 1200) / (1.0000135965 * 3937), "Indian foot", (5280 * 1200) / (0.3047996 * 3937) ), ## Defined as 0.3047972654 meters (from georepository.com) "Clarke's foot", struct ( "meter", 0.3047972654, "centimeter", 0.3047972654 * 100, "millimeter", 0.3047972654 * 1000, "micron", 0.3047972654 * 10^6, "kilometer", 0.3047972654 * 0.001, "nautical mile", 0.3047972654 / 1852, "foot", 0.3047972654 / 0.3048, "inch", 0.3047972654 / 0.0254, "yard", 0.3047972654 / 0.9144, "mile", 0.3047972654 / 1609.344, "U.S. survey foot", (0.3047972654 * 3937) / 1200, "U.S. survey mile (statute mile)", (0.3047972654 * 3937) / (5280 * 1200), "Clarke's foot", 1, "German legal metre", 0.3047972654 / 1.0000135965, "Indian foot", 0.3047972654 / 0.3047996 ), ## Defined as 1.0000135965 meters (longer than a meter by 13.5965 micrometers) "German legal metre", struct ( "meter", 1.0000135965, "centimeter", 1.0000135965 * 100, "millimeter", 1.0000135965 * 1000, "micron", 1.0000135965 * 10^6, "kilometer", 1.0000135965 * 0.001, "nautical mile", 1.0000135965 / 1852, "foot", 1.0000135965 / 0.3048, "inch", 1.0000135965 / 0.0254, "yard", 1.0000135965 / 0.9144, "mile", 1.0000135965 / 1609.344, "U.S. survey foot", (1.0000135965 * 3937) / 1200, "U.S. survey mile (statute mile)", (1.0000135965 * 3937) / (5280 * 1200), "Clarke's foot", 1.0000135965 / 0.3047972654, "German legal metre", 1, "Indian foot", 1.0000135965 / 0.3047996 ), ## The Indian survey foot is defined as exactly 0.3047996 m (wikipedia) "Indian foot", struct ( "meter", 0.3047996, "centimeter", 0.3047996 * 100, "millimeter", 0.3047996 * 1000, "micron", 0.3047996 * 10^6, "kilometer", 0.3047996 * 0.001, "nautical mile", 0.3047996 / 1852, "foot", 0.3047996 / 0.3048, "inch", 0.3047996 / 0.0254, "yard", 0.3047996 / 0.9144, "mile", 0.3047996 / 1609.344, "U.S. survey foot", (0.3047996 * 3937) / 1200, "U.S. survey mile (statute mile)", (0.3047996 * 3937) / (5280 * 1200), "Clarke's foot", 0.3047996 / 0.3047972654, "German legal metre", 0.3047996 / 1.0000135965, "Indian foot", 1 ) ); try ratio = ratios.(valid_from).(valid_to); catch error ("unitsratio: unknown conversion from %s to %s", from, to); end_try_catch endfunction %!assert (unitsratio ("inch", "foot"), 12) %!assert (unitsratio ("m", "cm"), 0.01) %!assert (unitsratio ("cm", "m"), 100) %!assert (unitsratio ("meter", "meter"), 1) %!assert (unitsratio ("degrees", "radians"), 180 / pi) %!assert (unitsratio ("radians", "degrees"), pi / 180) %!error unitsratio ("NOT A UNIT", "meter") %!error unitsratio ("meter", "NOT A UNIT") mapping-1.2.1/inst/PaxHeaders.3513/fromRadians.m0000644000000000000000000000013212655504456016232 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/fromRadians.m0000644000175000017500000000464212655504456021070 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{a1}, @var{a2}, @dots{}] =} fromRadians (@var{toUnit}, @var{rad1}, @var{rad2}, @dots{}) ## Convert angles from radians. ## ## Converts any number of input arguments, @var{rad1}, @var{rad2}, @dots{} ## with angles in radians, into @var{toUnit} which may be @qcode{"radians"} or ## @qcode{"degrees"}. ## ## @example ## @group ## [a1, a2] = fromRadians ("degrees", pi, [pi 2*pi]) ## @result{a1} [ 180 ] ## @result{a2} [ 180 360 ] ## @end group ## @end example ## ## @seealso{fromDegrees, rad2deg, toDegrees, toRadians, unitsratio} ## @end deftypefn ## Author: Carnë Draug function varargout = fromRadians (toUnit, varargin) if (nargin < 1) print_usage (); endif valid_unit = validatestring (toUnit, {"radians", "degrees"}, "fromRadians", "TOUNIT"); switch (valid_unit(1)) case {"d"} varargout = cellfun (@rad2deg, varargin, "UniformOutput", false); case {"r"} varargout = varargin; endswitch endfunction %!test %! rad{1} = pi; %! rad{2} = [pi 2*pi]; %! rad{3} = [0 pi; 2*pi 0]; %! deg{1} = 180; %! deg{2} = [180 360]; %! deg{3} = [0 180; 360 0]; %! for i=1:3 %! assert (fromRadians ("degrees", rad{i}), deg{i}) %! assert (fromRadians ("radians", rad{i}), rad{i}) %! endfor %! %! ## test multiple angles same time %! assert (nthargout (1:3, @fromRadians, "degrees", rad{:}), deg) %! assert (nthargout (1:2, @fromRadians, "degrees", rad{:}), deg(1:2)) %! %! ## test abbreviations of degrees %! assert (nthargout (1:3, @fromRadians, "degree", rad{:}), deg) %! assert (nthargout (1:3, @fromRadians, "deg", rad{:}), deg) %! assert (nthargout (1:3, @fromRadians, "d", rad{:}), deg) %!error fromRadians ("INVALID") mapping-1.2.1/inst/PaxHeaders.3513/sm2deg.m0000644000000000000000000000013212655504456015146 xustar0030 mtime=1454803246.568993085 30 atime=1454803246.568993085 30 ctime=1454803247.144995051 mapping-1.2.1/inst/sm2deg.m0000644000175000017500000000440412655504456020000 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Pooja Rao ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{deg} =} sm2deg (@var{sm}) ## @deftypefnx {Function File} {@var{deg} =} sm2deg (@var{sm}, @var{radius}) ## @deftypefnx {Function File} {@var{deg} =} sm2deg (@var{sm}, @var{sphere}) ## Converts distance to angle by dividing distance by radius. ## ## Calculates the angles @var{deg} for the distances @var{sm} in a sphere with ## @var{radius} (also in statute miles). If unspecified, radius defaults to 6371 km, ## the mean radius of Earth and is converted to statute miles internally. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2deg} ## @end deftypefn ## Author: Pooja Rao function deg = sm2deg (sm, radius = "earth") ## This function converts statute miles (sm) to degrees (deg) ## Check arguments if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere and convert its default units (km) ## to statute miles (sm) radius = km2sm (spheres_radius (radius)); ## Check input elseif (! isnumeric (radius) || ! isscalar (radius)) error ("sm2deg: RADIUS must be a numeric scalar"); endif deg = 180 * sm/(pi*radius); endfunction %!test %! ratio = unitsratio ('km','sm'); %! assert (sm2deg (10), km2deg (ratio*10), 10*eps); %! assert (sm2deg (10, 80), km2deg (ratio*10, ratio*80), 10*eps); %! assert (sm2deg (10, "pluto"), km2deg (ratio*10, "pluto"), 10*eps); mapping-1.2.1/inst/PaxHeaders.3513/km2rad.m0000644000000000000000000000013212655504456015145 xustar0030 mtime=1454803246.560993057 30 atime=1454803246.560993057 30 ctime=1454803247.144995051 mapping-1.2.1/inst/km2rad.m0000644000175000017500000000417512655504456020004 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Pooja Rao ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{rad} =} km2rad (@var{km}) ## @deftypefnx {Function File} {@var{rad} =} km2rad (@var{km}, @var{radius}) ## @deftypefnx {Function File} {@var{rad} =} km2rad (@var{km}, @var{sphere}) ## Converts distance to angle by dividing distance by radius. ## ## Calculates the angles @var{rad} for the distances @var{km} in a sphere with ## @var{radius} (also in kilometers). If unspecified, radius defaults to 6371, ## the mean radius of Earth. ## ## Alternatively, @var{sphere} can be one of "sun", "mercury", "venus", "earth", ## "moon", "mars", "jupiter", "saturn", "uranus", "neptune", or "pluto", in ## which case radius will be set to that object mean radius. ## ## @seealso{km2deg} ## @end deftypefn ## Author: Pooja Rao function rad = km2rad (km, radius = "earth") ## This function converts kilometers (km) to radians (rad) ## Check arguments if (nargin < 1 || nargin > 2) print_usage(); elseif (ischar (radius)) ## Get radius of sphere with default units (km) radius = spheres_radius (radius); ## Check input elseif (! isnumeric (radius) || ! isscalar (radius)) error ("km2rad: RADIUS must be a numeric scalar"); endif rad = km/radius; endfunction %!test %! ratio = pi/180; %! assert (km2rad (10), ratio*km2deg (10), 10*eps); %! assert (km2rad (10, 80), ratio*km2deg (10, 80), 10*eps); %! assert (km2rad (10, "pluto"), ratio*km2deg (10, "pluto"), 10*eps); mapping-1.2.1/inst/PaxHeaders.3513/nm2sm.m0000644000000000000000000000013212655504456015021 xustar0030 mtime=1454803246.564993071 30 atime=1454803246.564993071 30 ctime=1454803247.144995051 mapping-1.2.1/inst/nm2sm.m0000644000175000017500000000267412655504456017662 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2014 Eugenio Gianniti ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} nm2sm (@var{nm}) ## Convert nautical miles into U.S. survey miles (statute miles). ## ## @seealso{km2nm, km2sm, nm2km, sm2km, sm2nm} ## @end deftypefn ## Author: Eugenio Gianniti function sm = nm2sm (nm) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("U.S. survey mile (statute mile)", "nautical mile"); sm = nm * ratio; endfunction %!test %! nm = [50292 50.292 100.584 25.146 10058.4 12.573]; %! sm = [57875 57.875 115.75 28.9375 11575 14.46875]; %! assert (nm2sm (nm), sm) %! sm = reshape (sm, [2 1 3]); %! nm = reshape (nm, [2 1 3]); %! assert (nm2sm (nm), sm) %!assert (nm2sm (50292), 57875) mapping-1.2.1/PaxHeaders.3513/INDEX0000644000000000000000000000013212655504456013424 xustar0030 mtime=1454803246.556993044 30 atime=1454803246.556993044 30 ctime=1454803247.144995051 mapping-1.2.1/INDEX0000644000175000017500000000114012655504456016250 0ustar00carandraugcarandraug00000000000000mapping >> Mapping Functions Paths in curves azimuth distance reckon Lengths and angles deg2rad degtorad degrees2dm degrees2dms dm2degrees dms2degrees fromDegrees fromRadians km2deg km2rad km2nm km2sm nm2km nm2sm nm2rad nm2deg rad2deg radtodeg rad2km sm2km sm2nm sm2rad sm2deg toDegrees toRadians unitsratio wrapTo180 wrapTo360 wrapToPi wrapTo2Pi Utilities extractfield removeExtraNanSeparators roundn validateLengthUnit Shape files mapshow geoshow makesymbolspec shapedraw shapeinfo shaperead shapewrite Raster files gdalread rasterdraw rasterinfo rasterread mapping-1.2.1/PaxHeaders.3513/COPYING0000644000000000000000000000013212655504456013665 xustar0030 mtime=1454803246.556993044 30 atime=1454803246.556993044 30 ctime=1454803247.144995051 mapping-1.2.1/COPYING0000644000175000017500000010451312655504456016521 0ustar00carandraugcarandraug00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . mapping-1.2.1/PaxHeaders.3513/NEWS0000644000000000000000000000013212655504456013331 xustar0030 mtime=1454803246.556993044 30 atime=1454803246.556993044 30 ctime=1454803247.144995051 mapping-1.2.1/NEWS0000644000175000017500000000640712655504456016170 0ustar00carandraugcarandraug00000000000000Summary of important user-visible changes for mapping 1.2.1: ------------------------------------------------------------------- ** The following functions are new in mapping 1.2.1: rasterread rasterinfo rasterdraw gdalread wrapToPi wrapTo2Pi wrapTo180 wrapTo360 ** New features Reading GIS raster data: A first go is provided using functions rasterread.m and rasterinfo.m. Both invoke binary function gdalread() of which an initial version was provided by Shashank Khare. rasterread.m and rasterinfo.m can read and return info on any raster data type that the underlying GDAL library can read. As such, separate functions for e.g., GeoTIFF and ArcGrid etc. are not required. To make use of these functions the GDAL library must be present on your system => GDAL is a suggested dependency. mapshow.m: drawing raster data is now supported. shapedraw.m: drawing speed of filled polygons and multipatches is much improved wrapTo180.m, wrapTo360.m, wrapToPi.m, wrapTo2Pi.m: Provided by Oscar Monerris Belda and turned into their present versions with help of a.o., Andreas Weber ** Bug fixes: shapewrite.m: correct Lat/Lon mix-up update overall BoundingBox for Point type shaperead.m: improve reading Nr. of parts (of Polylines/-gons) ** To avoid shadowing core functions rad2deg and deg2rad, these functions are only copied into place if Octave (< 4.2) does not have them. Summary of important user-visible changes for mapping 1.2.0: ------------------------------------------------------------------- ** The following functions are new in mapping 1.2.0: deg2km degtorad degrees2dm degrees2dms dm2degrees dms2degrees extractfield fromDegrees fromRadians geoshow km2deg km2rad km2nm km2sm makesymbolspec mapshow nm2km nm2sm nm2rad nm2deg radtodeg rad2km removeExtraNanSeparators roundn shapedraw shapeinfo shaperead shapewrite sm2km sm2nm sm2rad sm2deg toDegrees toRadians unitsratio validateLengthUnit ** The function `distance' has been greatly improved with more options including calculating the azimuth between points and support different angle units. ** The function km2deg can accept an optional radius or the name of some Solar System objects. ** Test functions for deg2rad, km2deg and rad2deg have been added. ** Functions shapeinfo, shaperead, shapewrite and shapedraw are meant to process ArcGIS shape files. Functions mapshow and geoshow are simple Matlab-compatible wrappers for shapedraw. A basic implementation of makesymbolspec is also present. For some functionality of shaperead.m, shapewrite.m and shapedraw.m the Octave-Forge geometry, io and octclip packages are required. The shape* functions are considered experimental yet. Only projected data files can be drawn and several limitations apply. On the other hand some functionality is present that supersedes ML compatibility. See the help for each function. mapping-1.2.1/PaxHeaders.3513/src0000644000000000000000000000013212655504457013345 xustar0030 mtime=1454803247.144995051 30 atime=1454803247.144995051 30 ctime=1454803247.144995051 mapping-1.2.1/src/0000755000175000017500000000000012655504457016252 5ustar00carandraugcarandraug00000000000000mapping-1.2.1/src/PaxHeaders.3513/misc.h0000644000000000000000000000013212655504456014525 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/misc.h0000644000175000017500000000226712655504456017364 0ustar00carandraugcarandraug00000000000000/* The MIT License (MIT) Copyright (C) 2015 Shashank Khare Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _MISCH_ #define _MISCH_ #include void get_null_values (int args_num, octave_value_list *list); #endif mapping-1.2.1/src/PaxHeaders.3513/deg2rad.m.in0000644000000000000000000000013212655504456015514 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/deg2rad.m.in0000644000175000017500000000234112655504456020344 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2004 Andrew Collier ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} deg2rad (@var{anglin}) ## @deftypefnx {Function File} {} degtorad (@var{anglin}) ## Converts angles input in degrees to the equivalent in radians. ## ## @seealso{rad2deg, unitsratio} ## @end deftypefn ## Author: Andrew Collier function anglout = deg2rad (anglin) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("radians", "degrees"); anglout = anglin * ratio; endfunction %!assert (deg2rad(180),pi,10*eps) mapping-1.2.1/src/PaxHeaders.3513/configure0000644000000000000000000000013212655504457015326 xustar0030 mtime=1454803247.140995037 30 atime=1454803247.112994942 30 ctime=1454803247.144995051 mapping-1.2.1/src/configure0000755000175000017500000034115312655504457020170 0ustar00carandraugcarandraug00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for Octave-Forge mapping package 1.2.0+. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Octave-Forge mapping package' PACKAGE_TARNAME='octave-forge-mapping-package' PACKAGE_VERSION='1.2.0+' PACKAGE_STRING='Octave-Forge mapping package 1.2.0+' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_subst_vars='LTLIBOBJS LIBOBJS GDAL_CONFIG GDAL_LIBS GDAL_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX OCTAVE MKOCTFILE target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias MKOCTFILE OCTAVE CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR GDAL_CFLAGS GDAL_LIBS GDAL_CONFIG' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Octave-Forge mapping package 1.2.0+ to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/octave-forge-mapping-package] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Octave-Forge mapping package 1.2.0+:";; esac cat <<\_ACEOF Some influential environment variables: MKOCTFILE Compiler for Octave dynamic-load modules (default=mkoctfile -Wall) OCTAVE Octave executable for the installation (default=octave) CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path GDAL_CFLAGS C compiler flags for GDAL, overriding pkg-config GDAL_LIBS linker flags for GDAL, overriding pkg-config GDAL_CONFIG path to gdal-config utility Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Octave-Forge mapping package configure 1.2.0+ generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Octave-Forge mapping package $as_me 1.2.0+, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" if test -z "$MKOCTFILE"; then MKOCTFILE='mkoctfile -Wall' fi if test -z "$OCTAVE"; then OCTAVE=octave fi HAS_RAD2DEG=`$OCTAVE -qf --eval "printf ('%i', exist ('rad2deg'))"` HAS_DEG2RAD=`$OCTAVE -qf --eval "printf ('%i', exist ('deg2rad'))"` if test "$HAS_RAD2DEG" == 0; then ac_config_files="$ac_config_files rad2deg.m" fi if test "$HAS_DEG2RAD" == 0; then ac_config_files="$ac_config_files deg2rad.m" fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ## Older versions of gdal did not support pkg-config. Instead, they ## wrote their own application, gdal-config, to do the same thing. ## So we first try pkg-config and if that fails, check for gdal-config. if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GDAL" >&5 $as_echo_n "checking for GDAL... " >&6; } if test -n "$GDAL_CFLAGS"; then pkg_cv_GDAL_CFLAGS="$GDAL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gdal\""; } >&5 ($PKG_CONFIG --exists --print-errors "gdal") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GDAL_CFLAGS=`$PKG_CONFIG --cflags "gdal" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GDAL_LIBS"; then pkg_cv_GDAL_LIBS="$GDAL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gdal\""; } >&5 ($PKG_CONFIG --exists --print-errors "gdal") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GDAL_LIBS=`$PKG_CONFIG --libs "gdal" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GDAL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gdal" 2>&1` else GDAL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gdal" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GDAL_PKG_ERRORS" >&5 have_gdal=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_gdal=no else GDAL_CFLAGS=$pkg_cv_GDAL_CFLAGS GDAL_LIBS=$pkg_cv_GDAL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_gdal=yes fi if test $have_gdal = no; then # Extract the first word of "gdal-config", so it can be a program name with args. set dummy gdal-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_GDAL_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$GDAL_CONFIG"; then ac_cv_prog_GDAL_CONFIG="$GDAL_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_GDAL_CONFIG="gdal-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi GDAL_CONFIG=$ac_cv_prog_GDAL_CONFIG if test -n "$GDAL_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDAL_CONFIG" >&5 $as_echo "$GDAL_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -n "$GDAL_CONFIG"; then have_gdal=yes GDAL_LIBS=`gdal-config --libs` GDAL_CFLAGS=`gdal-config --cflags` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GDALAllRegister in -lgdal" >&5 $as_echo_n "checking for GDALAllRegister in -lgdal... " >&6; } if ${ac_cv_lib_gdal_GDALAllRegister+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgdal $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char GDALAllRegister (); int main () { return GDALAllRegister (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_gdal_GDALAllRegister=yes else ac_cv_lib_gdal_GDALAllRegister=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdal_GDALAllRegister" >&5 $as_echo "$ac_cv_lib_gdal_GDALAllRegister" >&6; } if test "x$ac_cv_lib_gdal_GDALAllRegister" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGDAL 1 _ACEOF LIBS="-lgdal $LIBS" fi fi fi if test $have_gdal = yes; then $as_echo "#define HAVE_GDAL 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GDAL library not found. Reading of raster files will be disabled." >&5 $as_echo "$as_me: WARNING: GDAL library not found. Reading of raster files will be disabled." >&2;} fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Octave-Forge mapping package $as_me 1.2.0+, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Octave-Forge mapping package config.status 1.2.0+ configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "rad2deg.m") CONFIG_FILES="$CONFIG_FILES rad2deg.m" ;; "deg2rad.m") CONFIG_FILES="$CONFIG_FILES deg2rad.m" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi mapping-1.2.1/src/PaxHeaders.3513/aclocal.m40000644000000000000000000000013212655504456015261 xustar0030 mtime=1454803246.976994478 30 atime=1454803247.068994792 30 ctime=1454803247.144995051 mapping-1.2.1/src/aclocal.m40000644000175000017500000000126212655504456020112 0ustar00carandraugcarandraug00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_include([m4/pkg.m4]) mapping-1.2.1/src/PaxHeaders.3513/rad2deg.m.in0000644000000000000000000000013212655504456015514 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/rad2deg.m.in0000644000175000017500000000234112655504456020344 0ustar00carandraugcarandraug00000000000000## Copyright (C) 2004 Andrew Collier ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} rad2deg (@var{anglin}) ## @deftypefnx {Function File} {} radtodeg (@var{anglin}) ## Converts angles input in radians to the equivalent in degrees. ## ## @seealso{deg2rad, unitsratio} ## @end deftypefn ## Author: Andrew Collier function anglout = rad2deg (anglin) if (nargin != 1) print_usage (); endif persistent ratio = unitsratio ("degrees", "radians"); anglout = anglin * ratio; endfunction %!assert (rad2deg(pi),180,10*eps) mapping-1.2.1/src/PaxHeaders.3513/config.h.in0000644000000000000000000000013212655504456015444 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/config.h.in0000644000175000017500000000006712655504456020277 0ustar00carandraugcarandraug00000000000000/* Define to 1 if gdal is present. */ #undef HAVE_GDAL mapping-1.2.1/src/PaxHeaders.3513/configure.ac0000644000000000000000000000013212655504456015707 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.624993276 30 ctime=1454803247.144995051 mapping-1.2.1/src/configure.ac0000644000175000017500000000302312655504456020535 0ustar00carandraugcarandraug00000000000000AC_PREREQ([2.67]) AC_INIT([Octave-Forge mapping package], [1.2.0+]) AC_CONFIG_HEADERS([config.h]) AC_ARG_VAR([MKOCTFILE], [Compiler for Octave dynamic-load modules (default=mkoctfile -Wall)]) if test -z "$MKOCTFILE"; then MKOCTFILE='mkoctfile -Wall' fi AC_ARG_VAR([OCTAVE], [Octave executable for the installation (default=octave)]) if test -z "$OCTAVE"; then OCTAVE=octave fi HAS_RAD2DEG=`$OCTAVE -qf --eval "printf ('%i', exist ('rad2deg'))"` HAS_DEG2RAD=`$OCTAVE -qf --eval "printf ('%i', exist ('deg2rad'))"` if test "$HAS_RAD2DEG" == 0; then AC_CONFIG_FILES([rad2deg.m]) fi if test "$HAS_DEG2RAD" == 0; then AC_CONFIG_FILES([deg2rad.m]) fi AC_PROG_CXX AC_LANG(C++) ## Older versions of gdal did not support pkg-config. Instead, they ## wrote their own application, gdal-config, to do the same thing. ## So we first try pkg-config and if that fails, check for gdal-config. PKG_CHECK_MODULES(GDAL, [gdal], [have_gdal=yes], [have_gdal=no]) if test $have_gdal = no; then AC_ARG_VAR([GDAL_CONFIG], [path to gdal-config utility]) AC_CHECK_PROG([GDAL_CONFIG], gdal-config, gdal-config, []) if test -n "$GDAL_CONFIG"; then have_gdal=yes GDAL_LIBS=`gdal-config --libs` GDAL_CFLAGS=`gdal-config --cflags` AC_CHECK_LIB(gdal, [GDALAllRegister]) fi AC_SUBST(GDAL_LIBS) AC_SUBST(GDAL_CFLAGS) fi if test $have_gdal = yes; then AC_DEFINE(HAVE_GDAL, 1, [Define to 1 if gdal is present.]) else AC_MSG_WARN([GDAL library not found. Reading of raster files will be disabled.]) fi AC_CONFIG_FILES([Makefile]) AC_OUTPUT mapping-1.2.1/src/PaxHeaders.3513/m40000644000000000000000000000013212655504456013664 xustar0030 mtime=1454803246.572993099 30 atime=1454803247.144995051 30 ctime=1454803247.144995051 mapping-1.2.1/src/m4/0000755000175000017500000000000012655504456016571 5ustar00carandraugcarandraug00000000000000mapping-1.2.1/src/m4/PaxHeaders.3513/pkg.m40000644000000000000000000000013212655504456014764 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.628993289 30 ctime=1454803247.144995051 mapping-1.2.1/src/m4/pkg.m40000644000175000017500000001716712655504456017630 0ustar00carandraugcarandraug00000000000000# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # PKG_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable pkgconfigdir as the location where a module # should install pkg-config .pc files. By default the directory is # $libdir/pkgconfig, but the default can be changed by passing # DIRECTORY. The user can override through the --with-pkgconfigdir # parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_INSTALLDIR # PKG_NOARCH_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable noarch_pkgconfigdir as the location where a # module should install arch-independent pkg-config .pc files. By # default the directory is $datadir/pkgconfig, but the default can be # changed by passing DIRECTORY. The user can override through the # --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_NOARCH_INSTALLDIR # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ------------------------------------------- # Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR mapping-1.2.1/src/PaxHeaders.3513/misc.cpp0000644000000000000000000000013212655504456015060 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/misc.cpp0000644000175000017500000000243412655504456017713 0ustar00carandraugcarandraug00000000000000/* The MIT License (MIT) Copyright (C) 2015 Shashank Khare Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // in case of error the function fill a value_list // with -1 #include "misc.h" void get_null_values (int args_num, octave_value_list *list) { for (int i=0; i < args_num; i++) (*list)(i) = octave_value (-1); } mapping-1.2.1/src/PaxHeaders.3513/gdalread.cc0000644000000000000000000000013212655504456015473 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/gdalread.cc0000644000175000017500000002545712655504456020340 0ustar00carandraugcarandraug00000000000000/* The MIT License (MIT) Copyright (C) 2015 Shashank Khare, skhare at hotmail dot com Copyright (C) 2015 Philip Nienhuis Large parts of the below code originate from http://www.gdal.org/gdal_tutorial.html Acknowledgement: Snow and Avalanche Studies Establishment, DRDO, Chandigarh, India Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef HAVE_CONFIG_H #include "./config.h" #endif #include #include #include #include #include #include "misc.h" #include "stdio.h" #ifdef HAVE_GDAL #include #include #endif /* INPUT : string filepath RETURNS: int containing return code, struct array containing band data, struct array containing metadata */ /* See code examples here [1]: http://www.gdal.org/gdal_tutorial.html */ DEFUN_DLD (gdalread, args, , "-*- texinfo -*-\n\ @deftypefn {} {[@var{rstat}, @var{rinfo}, @var{bands}] =} gdalread (@var{fname})\n\ @deftypefnx {} {[@var{rstat}, @var{rinfo}, @var{bands}] =} gdalread (@var{fname}, @var{info})\n\ Get raster data and info or (optionally) just info from a GIS raster file.\n\ For normal raster data reading it is better to use rasterread.m as that \n\ takes care of postprocessing gdalread output.\n\ \n\ @var{fname} is the name (or full path name) of a raster file to be read.\n\ \n\ @var{info} is any non-null value. If present, only raster info is\n\ returned. This option can be useful if only raster information is\n\ required and reading the raster data can be skipped.\n\ \n\ @var{rstat} is set to zero if reading was successful, -1 otherwise.\n\ \n\ @var{rinfo} is a scalar struct containing information about the raster\n\ data: datatype_index (a numerical GDAL datatype index); datatype_name\n\ (GDAL type name); BitDepth; geotransformation (1x6 double vector);\n\ projection (a string containing projection information); Width (nr. of\n\ raster data columns); Height (nr. of raster data rows); FileType; and\n\ nbands (the number of raster bands in the file).\n\ \n\ @var{bands} is a struct array containing raster data for each band in\n\ the file. If only raster info was requested, bands is empty.\n\ When data is read, each band is a struct element containing: bbox\n\ (bounding box: [xmin ymin; xmax ymax]), data (a matrix with the actual\n\ raster data); min (minimum raster data value); max (maximum raster\n\ data value); has_ndv (indicates whether the band as a special value\n\ indicating pixels that shouldn't be processed); ndv_val (the special\n\ value for improper pixels), and colortable. If the band has a\n\ colortable, field ``colortable'' contains an Mx4 array of colortable\n\ entries (see GDAL reference), otherwise this field is empty.\n\ Note that the actual raster data array (field ``data'' is rotated\n\ 90 degrees clockwise.\n\ @seealso{rasterread,rot90}\n\ @end deftypefn") { #ifndef HAVE_GDAL error ("gdalread: reading of raster file with GDAL was disabled during installation"); return octave_value_list (); #else int nargin = args.length (); octave_value_list ret_list(3); int num_items = 0; int XSize = 0, YSize = 0; if (nargin < 1) { get_null_values (3, &ret_list); print_usage (); return ret_list; }; // [1] "Opening the file" std::string arg_file = args(0).string_value (); GDALDataset* poDS; GDALAllRegister (); poDS = (GDALDataset*) GDALOpen (arg_file.c_str(), GA_ReadOnly); if (poDS == NULL) { octave_stdout << "Error: Open failed.\n"; get_null_values (3, &ret_list); return ret_list; } // [1] "Getting dataset information" double adfGeoTransform[6]; int rasterX; // = poDS->GetRasterXSize(); int rasterY; // = poDS->GetRasterYSize(); octave_idx_type band_count = poDS->GetRasterCount (); if (!(poDS->GetGeoTransform(adfGeoTransform) == CE_None)) { // error could not get geotransformation data // put origin as 0,0 and pixel size as 1,1 // should not happen but if it does proceed with 0,0 as origin octave_stdout << "Warning: GetGeoTransform failed.\n"; adfGeoTransform[0] = 0; adfGeoTransform[3] = 0; adfGeoTransform[1] = 1; adfGeoTransform[5] = 1; } /************************READING RASTER DATA **********************/ GDALRasterBand* poBand; int raster_data_type, raster_type_size; const char* raster_type_name; // Only get raster data when no info request was given if (nargin <= 1) { static const char *fields[] = {"bbox", "data", "min", "max", "has_ndv", "ndv_val", "colortable", 0}; // Output struct octave_map m_band (dim_vector (band_count, 1), string_vector (fields)); octave_scalar_map band_struct = (string_vector (fields)); // temp variables in below loop int nBlockXSize, nBlockYSize; int bGotMin, bGotMax; double adfMinMax[2]; Matrix raster_data, raster_data_tmp, X_tmp, Y_tmp, colortable; Matrix bbox(2, 2); int clrs; GDALColorTable* GDALclr_table; const GDALColorEntry* clr_entry; for (octave_idx_type curr_band = 0; curr_band < band_count; curr_band++) { // [1] "Fetch a raster band" // Get actual raster data poBand = poDS->GetRasterBand (curr_band + 1); poBand->GetBlockSize (&nBlockXSize, &nBlockYSize); raster_data_type = (int)poBand->GetRasterDataType (); raster_type_name = GDALGetDataTypeName (poBand->GetRasterDataType ()); raster_type_size = (int)GDALGetDataTypeSize (poBand->GetRasterDataType ()); adfMinMax[0] = poBand->GetMinimum (&bGotMin); adfMinMax[1] = poBand->GetMaximum (&bGotMax); if (!(bGotMin && bGotMax)) GDALComputeRasterMinMax ((GDALRasterBandH)poBand, TRUE, adfMinMax); // Get colortable, if present clrs = 0; GDALclr_table = poBand->GetColorTable (); if (GDALclr_table != NULL) { clrs = GDALclr_table->GetColorEntryCount (); colortable = Matrix (dim_vector(clrs, 4)); for (octave_idx_type c_entry = 0; c_entry < clrs; c_entry++) { clr_entry = GDALclr_table->GetColorEntry (c_entry); colortable(c_entry, 0) = (double) clr_entry->c1; colortable(c_entry, 1) = (double) clr_entry->c2; colortable(c_entry, 2) = (double) clr_entry->c3; colortable(c_entry, 3) = (double) clr_entry->c4; } } else int colortable = -1; /******************* READING RASTER DATA *******************************************/ rasterX = poBand->GetXSize (); rasterY = poBand->GetYSize (); /////////////////////////////////////////////////// raster_data = Matrix(dim_vector(rasterX, rasterY)); long int nXBlocks = (rasterX + nBlockXSize - 1) / nBlockXSize; long int nYBlocks = (rasterY + nBlockYSize - 1) / nBlockYSize; // read the data into memory GByte* data_ptr = (GByte*) raster_data.fortran_vec (); long int* pafScanline = (long int*) CPLMalloc (sizeof (double) * rasterX * rasterY); long int read_size_x = 0, read_size_y = 0, nXOff, nYOff; CPLErr read_err = poBand->RasterIO (GF_Read, 0, 0, rasterX, rasterY, pafScanline, rasterX, rasterY, GDT_Float64, 0, 0); if (read_err != CE_None) { ret_list(0) = -1; return ret_list; } // TODO: memcpy is not needed memcpy (data_ptr, pafScanline, sizeof (double) * rasterX * rasterY); /************ calculate bounds for the band *********************/ double minx = adfGeoTransform[0]; double maxy = adfGeoTransform[3]; double maxx = minx + adfGeoTransform[1] * rasterX; double miny = maxy + adfGeoTransform[5] * rasterY; bbox(0, 0) = minx; bbox(0, 1) = miny; bbox(1, 0) = maxx; bbox(1, 1) = maxy; band_struct.setfield ("bbox", bbox); band_struct.setfield ("data", raster_data); band_struct.setfield ("min", adfMinMax[0]); band_struct.setfield ("max", adfMinMax[1]); int ndv_present = 0; double ndvalue = poBand->GetNoDataValue(&ndv_present); if (ndv_present) band_struct.setfield ("has_ndv", ndv_present); else band_struct.setfield ("has_ndv", -1); band_struct.setfield ("ndv_val", ndvalue); band_struct.setfield ("colortable", colortable); // Assign temp struct to output struct m_band.fast_elem_insert (curr_band, band_struct); CPLFree (pafScanline); } ret_list(2) = octave_value(m_band); } else { // Get raster info poBand = poDS->GetRasterBand (1); raster_data_type = (int)poBand->GetRasterDataType (); raster_type_name = GDALGetDataTypeName (poBand->GetRasterDataType ()); raster_type_size = (int)GDALGetDataTypeSize (poBand->GetRasterDataType ()); rasterX = poBand->GetXSize (); rasterY = poBand->GetYSize (); ret_list(2) = -1; } /*********************** generate meta data **************/ Matrix geom(1, 6); geom(0, 0) = adfGeoTransform[0]; geom(0, 1) = adfGeoTransform[1]; geom(0, 2) = adfGeoTransform[2]; geom(0, 3) = adfGeoTransform[3]; geom(0, 4) = adfGeoTransform[4]; geom(0, 5) = adfGeoTransform[5]; // Output info struct octave_scalar_map meta_data; meta_data.assign(std::string("FileType"), poDS->GetDriver()->GetMetadataItem (GDAL_DMD_LONGNAME)); meta_data.assign(std::string("datatype_index"), raster_data_type); meta_data.assign(std::string("datatype_name"), raster_type_name); meta_data.assign(std::string("BitDepth"), raster_type_size); meta_data.assign(std::string("GeoTransformation"), geom); meta_data.assign(std::string("Projection"), poDS->GetProjectionRef()); meta_data.assign(std::string("Width"), rasterX); meta_data.assign(std::string("Height"), rasterY); meta_data.assign(std::string("nbands"), band_count); ret_list(0) = octave_value(0); ret_list(1) = octave_value(meta_data); GDALClose ((GDALDatasetH) poDS); return ret_list; #endif } mapping-1.2.1/src/PaxHeaders.3513/Makefile.in0000644000000000000000000000013212655504456015466 xustar0030 mtime=1454803246.572993099 30 atime=1454803246.572993099 30 ctime=1454803247.144995051 mapping-1.2.1/src/Makefile.in0000644000175000017500000000041012655504456020311 0ustar00carandraugcarandraug00000000000000MKOCTFILE = @MKOCTFILE@ CXXFLAGS = @CXXFLAGS@ GDAL_LIBS = @GDAL_LIBS@ GDAL_CFLAGS = @GDAL_CFLAGS@ DEFS = @DEFS@ gdalread.oct : gdalread.cc misc.cpp $(MKOCTFILE) $(DEFS) $(CXXFLAGS) $(GDAL_CFLAGS) $(GDAL_LIBS) -o $@ $^ clean: rm misc.o gdalread.o gdalread.oct mapping-1.2.1/PaxHeaders.3513/bootstrap0000644000000000000000000000013212655504456014572 xustar0030 mtime=1454803246.556993044 30 atime=1454803246.580993126 30 ctime=1454803247.144995051 mapping-1.2.1/bootstrap0000755000175000017500000000025512655504456017427 0ustar00carandraugcarandraug00000000000000#!/bin/bash ## Octave-Forge: mapping package bootstrap script ## Run this to generate the configure script set -e # halt if unhandled error cd src/ aclocal -Im4 autoconf mapping-1.2.1/PaxHeaders.3513/DESCRIPTION0000644000000000000000000000013212655504456014340 xustar0030 mtime=1454803246.556993044 30 atime=1454803246.556993044 30 ctime=1454803247.144995051 mapping-1.2.1/DESCRIPTION0000644000175000017500000000061312655504456017170 0ustar00carandraugcarandraug00000000000000Name: mapping Version: 1.2.1 Date: 2016-02-06 Author: various authors Maintainer: Philip Nienhuis Title: Mapping Functions Description: Simple mapping and GIS .shp and raster file functions. Categories: Mathematics Depends: octave (>= 3.8.0) Suggested: io (>= 2.2.7), geometry (>= 1.4.0), octclip (>= 1.0.3), GDAL Autoload: no License: GPLv3+ Url: http://octave.sf.net