Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > c9cfbd1355daacaf3b34517a6d7b18cc > files > 182

libdap-doc-3.11.0-2.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libdap++: GridGeoConstraint.cc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libdap++&#160;<span id="projectnumber">Updated for version 3.8.2</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('GridGeoConstraint_8cc.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>GridGeoConstraint.cc</h1>  </div>
</div>
<div class="contents">
<a href="GridGeoConstraint_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">// -*- mode: c++; c-basic-offset:4 -*-</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment">// This file is part of libdap, A C++ implementation of the OPeNDAP Data</span>
<a name="l00005"></a>00005 <span class="comment">// Access Protocol.</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">// Copyright (c) 2002,2003 OPeNDAP, Inc.</span>
<a name="l00008"></a>00008 <span class="comment">// Author: James Gallagher &lt;jgallagher@opendap.org&gt;</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This library is free software; you can redistribute it and/or</span>
<a name="l00011"></a>00011 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<a name="l00012"></a>00012 <span class="comment">// License as published by the Free Software Foundation; either</span>
<a name="l00013"></a>00013 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// This library is distributed in the hope that it will be useful,</span>
<a name="l00016"></a>00016 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00017"></a>00017 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00018"></a>00018 <span class="comment">// Lesser General Public License for more details.</span>
<a name="l00019"></a>00019 <span class="comment">//</span>
<a name="l00020"></a>00020 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>
<a name="l00021"></a>00021 <span class="comment">// License along with this library; if not, write to the Free Software</span>
<a name="l00022"></a>00022 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00023"></a>00023 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment">// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="comment">// The Grid Selection Expression Clause class.</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="config_8h.html">config.h</a>&quot;</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keywordtype">id</span>[] <a class="code" href="config_8h.html#a05e109ec893d0b12023d5b0cf4f718c4">not_used</a> =
<a name="l00032"></a>00032     { <span class="stringliteral">&quot;$Id: GridGeoConstraint.cc 23447 2010-08-27 19:38:04Z jimg $&quot;</span>
<a name="l00033"></a>00033     };
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="comment">//#define DODS_DEBUG</span>
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="preprocessor">#include &quot;<a class="code" href="debug_8h.html">debug.h</a>&quot;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &quot;<a class="code" href="dods-datatypes_8h.html">dods-datatypes.h</a>&quot;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &quot;<a class="code" href="GridGeoConstraint_8h.html">GridGeoConstraint.h</a>&quot;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &quot;<a class="code" href="Float64_8h.html">Float64.h</a>&quot;</span>
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="Error_8h.html">Error.h</a>&quot;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &quot;<a class="code" href="InternalErr_8h.html">InternalErr.h</a>&quot;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &quot;<a class="code" href="ce__functions_8h.html">ce_functions.h</a>&quot;</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include &quot;<a class="code" href="util_8h.html">util.h</a>&quot;</span>
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 <span class="keyword">using namespace </span>std;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="keyword">namespace </span>libdap {
<a name="l00055"></a>00055 
<a name="l00064"></a><a class="code" href="classlibdap_1_1GridGeoConstraint.html#a96de4a7279f9a8aac7b6526ddd9d641f">00064</a> GridGeoConstraint::GridGeoConstraint(<a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a> *grid)
<a name="l00065"></a>00065         : <a class="code" href="classlibdap_1_1GeoConstraint.html">GeoConstraint</a>(), d_grid(grid), d_latitude(0), d_longitude(0)
<a name="l00066"></a>00066 {
<a name="l00067"></a>00067     <span class="keywordflow">if</span> (d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#afa75d1ff3c75b8359d03b3f382bfd179" title="Return the total number of dimensions in the array.">dimensions</a>() &lt; 2
<a name="l00068"></a>00068         || d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#afa75d1ff3c75b8359d03b3f382bfd179" title="Return the total number of dimensions in the array.">dimensions</a>() &gt; 3)
<a name="l00069"></a>00069         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">&quot;The geogrid() function works only with Grids of two or three dimensions.&quot;</span>);
<a name="l00070"></a>00070 
<a name="l00071"></a>00071     <span class="comment">// Is this Grid a geo-referenced grid? Throw Error if not.</span>
<a name="l00072"></a>00072     <span class="keywordflow">if</span> (!build_lat_lon_maps())
<a name="l00073"></a>00073         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="keywordtype">string</span>(<span class="stringliteral">&quot;The grid &#39;&quot;</span>) + d_grid-&gt;<a class="code" href="classlibdap_1_1BaseType.html#a0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()
<a name="l00074"></a>00074                     + <span class="stringliteral">&quot;&#39; does not have identifiable latitude/longitude map vectors.&quot;</span>);
<a name="l00075"></a>00075 
<a name="l00076"></a>00076     <span class="keywordflow">if</span> (!lat_lon_dimensions_ok())
<a name="l00077"></a>00077         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">&quot;The geogrid() function will only work when the Grid&#39;s Longitude and Latitude\nmaps are the rightmost dimensions.&quot;</span>);
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 
<a name="l00080"></a><a class="code" href="classlibdap_1_1GridGeoConstraint.html#aa6cf945630a8588927b7925cf4a5a1db">00080</a> <a class="code" href="classlibdap_1_1GridGeoConstraint.html#a96de4a7279f9a8aac7b6526ddd9d641f" title="Initialize GeoConstraint with a Grid.">GridGeoConstraint::GridGeoConstraint</a>(<a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a> *grid, <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *lat, <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *lon)
<a name="l00081"></a>00081         : <a class="code" href="classlibdap_1_1GeoConstraint.html">GeoConstraint</a>(), d_grid(grid), d_latitude(0), d_longitude(0)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083     <span class="keywordflow">if</span> (d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#afa75d1ff3c75b8359d03b3f382bfd179" title="Return the total number of dimensions in the array.">dimensions</a>() &lt; 2
<a name="l00084"></a>00084         || d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#afa75d1ff3c75b8359d03b3f382bfd179" title="Return the total number of dimensions in the array.">dimensions</a>() &gt; 3)
<a name="l00085"></a>00085         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">&quot;The geogrid() function works only with Grids of two or three dimensions.&quot;</span>);
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     <span class="comment">// Is this Grid a geo-referenced grid? Throw Error if not.</span>
<a name="l00088"></a>00088     <span class="keywordflow">if</span> (!build_lat_lon_maps(lat, lon))
<a name="l00089"></a>00089         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="keywordtype">string</span>(<span class="stringliteral">&quot;The grid &#39;&quot;</span>) + d_grid-&gt;<a class="code" href="classlibdap_1_1BaseType.html#a0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()
<a name="l00090"></a>00090                     + <span class="stringliteral">&quot;&#39; does not have valid latitude/longitude map vectors.&quot;</span>);
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 
<a name="l00093"></a>00093     <span class="keywordflow">if</span> (!lat_lon_dimensions_ok())
<a name="l00094"></a>00094         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">&quot;The geogrid() function will only work when the Grid&#39;s Longitude and Latitude\nmaps are the rightmost dimensions.&quot;</span>);
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00112"></a>00112 <span class="keywordtype">bool</span> GridGeoConstraint::build_lat_lon_maps()
<a name="l00113"></a>00113 {
<a name="l00114"></a>00114     <a class="code" href="classlibdap_1_1Grid.html#a69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> m = d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>();
<a name="l00115"></a>00115     <span class="comment">// Assume that a Grid is correct and thus has exactly as many maps as its</span>
<a name="l00116"></a>00116     <span class="comment">// array part has dimensions. Thus don&#39;t bother to test the Grid&#39;s array</span>
<a name="l00117"></a>00117     <span class="comment">// dimension iterator for &#39;!= dim_end()&#39;.</span>
<a name="l00118"></a>00118     <a class="code" href="classlibdap_1_1Array.html#a7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> d = d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#ae6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>();
<a name="l00119"></a>00119     <span class="comment">// The fields d_latitude and d_longitude may be initialized to null or they</span>
<a name="l00120"></a>00120     <span class="comment">// may already contain pointers to the maps to use. In the latter case,</span>
<a name="l00121"></a>00121     <span class="comment">// skip the heuristics used in this code. However, given that all this</span>
<a name="l00122"></a>00122     <span class="comment">// method does is find the lat/lon maps, if they are given in the ctor,</span>
<a name="l00123"></a>00123     <span class="comment">// This method will likely not be called at all.</span>
<a name="l00124"></a>00124     <span class="keywordflow">while</span> (m != d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#aaebbf2a5329ec01b6527b4bafde87837">map_end</a>() &amp;&amp; (!d_latitude || !d_longitude)) {
<a name="l00125"></a>00125         <span class="keywordtype">string</span> units_value = (*m)-&gt;get_attr_table().get_attr(<span class="stringliteral">&quot;units&quot;</span>);
<a name="l00126"></a>00126         units_value = <a class="code" href="namespacelibdap.html#a37a24fcba1630ac658ec4c8a902dd92c">remove_quotes</a>(units_value);
<a name="l00127"></a>00127         <span class="keywordtype">string</span> map_name = (*m)-&gt;name();
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         <span class="comment">// The &#39;units&#39; attribute must match exactly; the name only needs to</span>
<a name="l00130"></a>00130         <span class="comment">// match a prefix.</span>
<a name="l00131"></a>00131         <span class="keywordflow">if</span> (!d_latitude
<a name="l00132"></a>00132             &amp;&amp; <a class="code" href="namespacelibdap.html#a2e899171229a834bd84b7ac3bead7e63">unit_or_name_match</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a5a4be0220de32ff2f6e63f9e902f96a2">get_coards_lat_units</a>(), <a class="code" href="classlibdap_1_1GeoConstraint.html#ac8bd8ef923214d85713f7f2ad9ecf50b">get_lat_names</a>(),
<a name="l00133"></a>00133                                   units_value, map_name)) {
<a name="l00134"></a>00134 
<a name="l00135"></a>00135             <span class="comment">// Set both d_latitude (a pointer to the real map vector) and</span>
<a name="l00136"></a>00136             <span class="comment">// d_lat, a vector of the values represented as doubles. It&#39;s easier</span>
<a name="l00137"></a>00137             <span class="comment">// to work with d_lat, but it&#39;s d_latitude that needs to be set</span>
<a name="l00138"></a>00138             <span class="comment">// when constraining the grid. Also, record the grid variable&#39;s</span>
<a name="l00139"></a>00139             <span class="comment">// dimension iterator so that it&#39;s easier to set the Grid&#39;s Array</span>
<a name="l00140"></a>00140             <span class="comment">// (which also has to be constrained).</span>
<a name="l00141"></a>00141             d_latitude = dynamic_cast &lt; <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> * &gt;(*m);
<a name="l00142"></a>00142             <span class="keywordflow">if</span> (!d_latitude)
<a name="l00143"></a>00143                 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">&quot;Expected an array.&quot;</span>);
<a name="l00144"></a>00144             <span class="keywordflow">if</span> (!d_latitude-&gt;<a class="code" href="classlibdap_1_1BaseType.html#a38ff819a432217c55db2e9071928d20c" title="Has this variable been read?">read_p</a>())
<a name="l00145"></a>00145                 d_latitude-&gt;<a class="code" href="classlibdap_1_1BaseType.html#a1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>();
<a name="l00146"></a>00146 
<a name="l00147"></a>00147             <a class="code" href="classlibdap_1_1GeoConstraint.html#a74fbafe177c1fdd9ba657a2f26cbe749">set_lat</a>(<a class="code" href="namespacelibdap.html#ae9717ce6442b4909dcd7add356a7ff88">extract_double_array</a>(d_latitude));   <span class="comment">// throws Error</span>
<a name="l00148"></a>00148             <a class="code" href="classlibdap_1_1GeoConstraint.html#ac2088ce8c8d21dbd8f10bba33b281ada">set_lat_length</a>(d_latitude-&gt;<a class="code" href="classlibdap_1_1Vector.html#a5990bd42b49e44c7b7da76e039896ba3">length</a>());
<a name="l00149"></a>00149 
<a name="l00150"></a>00150             <a class="code" href="classlibdap_1_1GeoConstraint.html#aea6568171e8e75d983c182e216e66f0d">set_lat_dim</a>(d);
<a name="l00151"></a>00151         }
<a name="l00152"></a>00152 
<a name="l00153"></a>00153         <span class="keywordflow">if</span> (!d_longitude        <span class="comment">// &amp;&amp; !units_value.empty()</span>
<a name="l00154"></a>00154             &amp;&amp; <a class="code" href="namespacelibdap.html#a2e899171229a834bd84b7ac3bead7e63">unit_or_name_match</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#aef1c08fe0aab73e2a6ad4797b01e3f56">get_coards_lon_units</a>(), <a class="code" href="classlibdap_1_1GeoConstraint.html#a4e0c90a2cba68f557dda8fa6ce0783a9">get_lon_names</a>(),
<a name="l00155"></a>00155                                   units_value, map_name)) {
<a name="l00156"></a>00156 
<a name="l00157"></a>00157             d_longitude = dynamic_cast &lt; Array * &gt;(*m);
<a name="l00158"></a>00158             <span class="keywordflow">if</span> (!d_longitude)
<a name="l00159"></a>00159                 <span class="keywordflow">throw</span> InternalErr(__FILE__, __LINE__, <span class="stringliteral">&quot;Expected an array.&quot;</span>);
<a name="l00160"></a>00160             <span class="keywordflow">if</span> (!d_longitude-&gt;read_p())
<a name="l00161"></a>00161                 d_longitude-&gt;read();
<a name="l00162"></a>00162 
<a name="l00163"></a>00163             <a class="code" href="classlibdap_1_1GeoConstraint.html#ad20909b77fa99bf52350e9b5f6ecdca8">set_lon</a>(<a class="code" href="namespacelibdap.html#ae9717ce6442b4909dcd7add356a7ff88">extract_double_array</a>(d_longitude));
<a name="l00164"></a>00164             <a class="code" href="classlibdap_1_1GeoConstraint.html#a7af93197ca9a37896a94ad6daa1c7867">set_lon_length</a>(d_longitude-&gt;length());
<a name="l00165"></a>00165 
<a name="l00166"></a>00166             <a class="code" href="classlibdap_1_1GeoConstraint.html#a23040c2d4b4b752190c623f62f7ea4a4">set_lon_dim</a>(d);
<a name="l00167"></a>00167 
<a name="l00168"></a>00168             <span class="keywordflow">if</span> (m + 1 == d_grid-&gt;map_end())
<a name="l00169"></a>00169                 <a class="code" href="classlibdap_1_1GeoConstraint.html#ac20b690e875e481d18b9cc37265dc6dc">set_longitude_rightmost</a>(<span class="keyword">true</span>);
<a name="l00170"></a>00170         }
<a name="l00171"></a>00171 
<a name="l00172"></a>00172         ++m;
<a name="l00173"></a>00173         ++d;
<a name="l00174"></a>00174     }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176     <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1GeoConstraint.html#ae1606e5fc999c32610a2ae2d60205a81">get_lat</a>() &amp;&amp; <a class="code" href="classlibdap_1_1GeoConstraint.html#a695f79c26e7eef89c380788d3c1d5507">get_lon</a>();
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178 
<a name="l00186"></a>00186 <span class="keywordtype">bool</span> GridGeoConstraint::build_lat_lon_maps(Array *lat, Array *lon)
<a name="l00187"></a>00187 {
<a name="l00188"></a>00188     <a class="code" href="classlibdap_1_1Grid.html#a69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> m = d_grid-&gt;map_begin();
<a name="l00189"></a>00189 
<a name="l00190"></a>00190     <a class="code" href="classlibdap_1_1Array.html#a7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> d = d_grid-&gt;get_array()-&gt;dim_begin();
<a name="l00191"></a>00191 
<a name="l00192"></a>00192     <span class="keywordflow">while</span> (m != d_grid-&gt;map_end() &amp;&amp; (!d_latitude || !d_longitude)) {
<a name="l00193"></a>00193         <span class="comment">// Look for the Grid map that matches the variable passed as &#39;lat&#39;</span>
<a name="l00194"></a>00194         <span class="keywordflow">if</span> (!d_latitude &amp;&amp; *m == lat) {
<a name="l00195"></a>00195 
<a name="l00196"></a>00196             d_latitude = lat;
<a name="l00197"></a>00197 
<a name="l00198"></a>00198             <span class="keywordflow">if</span> (!d_latitude-&gt;read_p())
<a name="l00199"></a>00199                 d_latitude-&gt;read();
<a name="l00200"></a>00200 
<a name="l00201"></a>00201             <a class="code" href="classlibdap_1_1GeoConstraint.html#a74fbafe177c1fdd9ba657a2f26cbe749">set_lat</a>(<a class="code" href="namespacelibdap.html#ae9717ce6442b4909dcd7add356a7ff88">extract_double_array</a>(d_latitude));   <span class="comment">// throws Error</span>
<a name="l00202"></a>00202             <a class="code" href="classlibdap_1_1GeoConstraint.html#ac2088ce8c8d21dbd8f10bba33b281ada">set_lat_length</a>(d_latitude-&gt;length());
<a name="l00203"></a>00203 
<a name="l00204"></a>00204             <a class="code" href="classlibdap_1_1GeoConstraint.html#aea6568171e8e75d983c182e216e66f0d">set_lat_dim</a>(d);
<a name="l00205"></a>00205         }
<a name="l00206"></a>00206 
<a name="l00207"></a>00207         <span class="keywordflow">if</span> (!d_longitude &amp;&amp; *m == lon) {
<a name="l00208"></a>00208 
<a name="l00209"></a>00209             d_longitude = lon;
<a name="l00210"></a>00210 
<a name="l00211"></a>00211             <span class="keywordflow">if</span> (!d_longitude-&gt;read_p())
<a name="l00212"></a>00212                 d_longitude-&gt;read();
<a name="l00213"></a>00213 
<a name="l00214"></a>00214             <a class="code" href="classlibdap_1_1GeoConstraint.html#ad20909b77fa99bf52350e9b5f6ecdca8">set_lon</a>(<a class="code" href="namespacelibdap.html#ae9717ce6442b4909dcd7add356a7ff88">extract_double_array</a>(d_longitude));
<a name="l00215"></a>00215             <a class="code" href="classlibdap_1_1GeoConstraint.html#a7af93197ca9a37896a94ad6daa1c7867">set_lon_length</a>(d_longitude-&gt;length());
<a name="l00216"></a>00216 
<a name="l00217"></a>00217             <a class="code" href="classlibdap_1_1GeoConstraint.html#a23040c2d4b4b752190c623f62f7ea4a4">set_lon_dim</a>(d);
<a name="l00218"></a>00218 
<a name="l00219"></a>00219             <span class="keywordflow">if</span> (m + 1 == d_grid-&gt;map_end())
<a name="l00220"></a>00220                 <a class="code" href="classlibdap_1_1GeoConstraint.html#ac20b690e875e481d18b9cc37265dc6dc">set_longitude_rightmost</a>(<span class="keyword">true</span>);
<a name="l00221"></a>00221         }
<a name="l00222"></a>00222 
<a name="l00223"></a>00223         ++m;
<a name="l00224"></a>00224         ++d;
<a name="l00225"></a>00225     }
<a name="l00226"></a>00226 
<a name="l00227"></a>00227     <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1GeoConstraint.html#ae1606e5fc999c32610a2ae2d60205a81">get_lat</a>() &amp;&amp; <a class="code" href="classlibdap_1_1GeoConstraint.html#a695f79c26e7eef89c380788d3c1d5507">get_lon</a>();
<a name="l00228"></a>00228 }
<a name="l00229"></a>00229 
<a name="l00240"></a>00240 <span class="keywordtype">bool</span>
<a name="l00241"></a>00241 GridGeoConstraint::lat_lon_dimensions_ok()
<a name="l00242"></a>00242 {
<a name="l00243"></a>00243     <span class="comment">// get the last two map iterators</span>
<a name="l00244"></a>00244     <a class="code" href="classlibdap_1_1Grid.html#a1c1791bdfac09f6ec42a71089fdccc75">Grid::Map_riter</a> rightmost = d_grid-&gt;map_rbegin();
<a name="l00245"></a>00245     <a class="code" href="classlibdap_1_1Grid.html#a1c1791bdfac09f6ec42a71089fdccc75">Grid::Map_riter</a> next_rightmost = rightmost + 1;
<a name="l00246"></a>00246 
<a name="l00247"></a>00247     <span class="keywordflow">if</span> (*rightmost == d_longitude &amp;&amp; *next_rightmost == d_latitude)
<a name="l00248"></a>00248         <a class="code" href="classlibdap_1_1GeoConstraint.html#ac20b690e875e481d18b9cc37265dc6dc">set_longitude_rightmost</a>(<span class="keyword">true</span>);
<a name="l00249"></a>00249     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*rightmost == d_latitude &amp;&amp; *next_rightmost == d_longitude)
<a name="l00250"></a>00250         <a class="code" href="classlibdap_1_1GeoConstraint.html#ac20b690e875e481d18b9cc37265dc6dc">set_longitude_rightmost</a>(<span class="keyword">false</span>);
<a name="l00251"></a>00251     <span class="keywordflow">else</span>
<a name="l00252"></a>00252         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00253"></a>00253 
<a name="l00254"></a>00254     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256 
<a name="l00278"></a><a class="code" href="classlibdap_1_1GridGeoConstraint.html#affdc6145014a519bef4874d14716b3cf">00278</a> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1GridGeoConstraint.html#affdc6145014a519bef4874d14716b3cf">GridGeoConstraint::apply_constraint_to_data</a>()
<a name="l00279"></a>00279 {
<a name="l00280"></a>00280     <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1GeoConstraint.html#ac572f71506b0214a755b30ba7e0def94">is_bounding_box_set</a>())
<a name="l00281"></a>00281         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(<span class="stringliteral">&quot;The Latitude and Longitude constraints must be set before calling apply_constraint_to_data().&quot;</span>);
<a name="l00282"></a>00282 
<a name="l00283"></a>00283     <a class="code" href="classlibdap_1_1Array.html#a7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> fd = d_latitude-&gt;<a class="code" href="classlibdap_1_1Array.html#ae6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>();
<a name="l00284"></a>00284 
<a name="l00285"></a>00285     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1GeoConstraint.html#ac2f5c3f3e098c91f23e194fe7b775af8">get_latitude_sense</a>() == <a class="code" href="classlibdap_1_1GeoConstraint.html#a2304140a3b6310c6ed8bce30ebdaed7ba77fdac07a46105592ea0707f365f04c6">inverted</a>) {
<a name="l00286"></a>00286         <span class="keywordtype">int</span> tmp = <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>();
<a name="l00287"></a>00287         <a class="code" href="classlibdap_1_1GeoConstraint.html#a58cf100c6ac40095273520035ff3f2ee">set_latitude_index_top</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>());
<a name="l00288"></a>00288         <a class="code" href="classlibdap_1_1GeoConstraint.html#af69dd8771a629e0b6da655e0c31b3dd6">set_latitude_index_bottom</a>(tmp);
<a name="l00289"></a>00289     }
<a name="l00290"></a>00290 
<a name="l00291"></a>00291     <span class="comment">// It&#39;s easy to flip the Latitude values; if the bottom index value</span>
<a name="l00292"></a>00292     <span class="comment">// is before/above the top index, return an error explaining that.</span>
<a name="l00293"></a>00293     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>() &gt; <a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>())
<a name="l00294"></a>00294         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">&quot;The upper and lower latitude indices appear to be reversed. Please provide the latitude bounding box numbers giving the northern-most latitude first.&quot;</span>);
<a name="l00295"></a>00295 
<a name="l00296"></a>00296     <span class="comment">// Constrain the lat vector and lat dim of the array</span>
<a name="l00297"></a>00297     d_latitude-&gt;<a class="code" href="classlibdap_1_1Array.html#a538f7c336e26b873f50e033d553bba26" title="Adds a constraint to an Array dimension.">add_constraint</a>(fd, <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>(), 1,
<a name="l00298"></a>00298                                <a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>());
<a name="l00299"></a>00299     d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#a538f7c336e26b873f50e033d553bba26" title="Adds a constraint to an Array dimension.">add_constraint</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a19dbb0b321d3e195a39dc086cacdfc53">get_lat_dim</a>(),
<a name="l00300"></a>00300                                         <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>(), 1,
<a name="l00301"></a>00301                                         <a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>());
<a name="l00302"></a>00302 
<a name="l00303"></a>00303     <span class="comment">// Does the longitude constraint cross the edge of the longitude vector?</span>
<a name="l00304"></a>00304     <span class="comment">// If so, reorder the grid&#39;s data (array), longitude map vector and the</span>
<a name="l00305"></a>00305     <span class="comment">// local vector of longitude data used for computation.</span>
<a name="l00306"></a>00306     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>() &gt; <a class="code" href="classlibdap_1_1GeoConstraint.html#a8f7a2a062f1fa421de74bd41339c9e1b">get_longitude_index_right</a>()) {
<a name="l00307"></a>00307         <a class="code" href="classlibdap_1_1GeoConstraint.html#ab2060337a35195641d6e0f667b8bf9df">reorder_longitude_map</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>());
<a name="l00308"></a>00308 
<a name="l00309"></a>00309         <span class="comment">// If the longitude constraint is &#39;split&#39;, join the two parts, reload</span>
<a name="l00310"></a>00310         <span class="comment">// the data into the Grid&#39;s Array and make sure the Array is marked as</span>
<a name="l00311"></a>00311         <span class="comment">// already read. This should be true for the whole Grid, but if some</span>
<a name="l00312"></a>00312         <span class="comment">// future modification changes that, the array will be covered here.</span>
<a name="l00313"></a>00313         <span class="comment">// Note that the following method only reads the data out and stores</span>
<a name="l00314"></a>00314         <span class="comment">// it in this object after joining the two parts. The method</span>
<a name="l00315"></a>00315         <span class="comment">// apply_constraint_to_data() transfers the data back from the this</span>
<a name="l00316"></a>00316         <span class="comment">// object to the DAP Grid variable.</span>
<a name="l00317"></a>00317         <a class="code" href="classlibdap_1_1GeoConstraint.html#aa893256d558152f07e08ec6f250fa089">reorder_data_longitude_axis</a>(*d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>(), <a class="code" href="classlibdap_1_1GeoConstraint.html#a5eee5cc9788b429e77bfde9f10bfe751">get_lon_dim</a>());
<a name="l00318"></a>00318 
<a name="l00319"></a>00319         <span class="comment">// Now that the data are all in local storage alter the indices; the</span>
<a name="l00320"></a>00320         <span class="comment">// left index has now been moved to 0, and the right index is now</span>
<a name="l00321"></a>00321         <span class="comment">// at lon_vector_length-left+right.</span>
<a name="l00322"></a>00322         <a class="code" href="classlibdap_1_1GeoConstraint.html#ad2217cd57779104cc3e9633c74b66607">set_longitude_index_right</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a505eb309753eabe0c6a5bb3d412a3579">get_lon_length</a>() - <a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>()
<a name="l00323"></a>00323                                   + <a class="code" href="classlibdap_1_1GeoConstraint.html#a8f7a2a062f1fa421de74bd41339c9e1b">get_longitude_index_right</a>());
<a name="l00324"></a>00324         <a class="code" href="classlibdap_1_1GeoConstraint.html#a2a2256b437d39ca3e868c70cb407cc98">set_longitude_index_left</a>(0);
<a name="l00325"></a>00325     }
<a name="l00326"></a>00326 
<a name="l00327"></a>00327     <span class="comment">// If the constraint used the -180/179 (neg_pos) notation, transform</span>
<a name="l00328"></a>00328     <span class="comment">// the longitude map so it uses the -180/179 notation. Note that at this</span>
<a name="l00329"></a>00329     <span class="comment">// point, d_longitude always uses the pos notation because of the earlier</span>
<a name="l00330"></a>00330     <span class="comment">// conditional transformation.</span>
<a name="l00331"></a>00331 
<a name="l00332"></a>00332     <span class="comment">// Do this _before_ applying the constraint since set_array_using_double()</span>
<a name="l00333"></a>00333     <span class="comment">// tests the array length using Vector::length() and that method returns</span>
<a name="l00334"></a>00334     <span class="comment">// the length _as constrained_. We want to move all of the longitude</span>
<a name="l00335"></a>00335     <span class="comment">// values from d_lon back into the map, not just the number that will be</span>
<a name="l00336"></a>00336     <span class="comment">// sent (although an optimization might do this, it&#39;s hard to imagine</span>
<a name="l00337"></a>00337     <span class="comment">// it would gain much).</span>
<a name="l00338"></a>00338     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1GeoConstraint.html#aee72b66c9ca298aebea679d2c410f7a6">get_longitude_notation</a>() == <a class="code" href="classlibdap_1_1GeoConstraint.html#ad02233f3f59e758747227be620b40d12af4021ad4ef44093b0d31a7dff458059e">neg_pos</a>) {
<a name="l00339"></a>00339         <a class="code" href="classlibdap_1_1GeoConstraint.html#aae44ab86b981a7543697ad8199094df7">transform_longitude_to_neg_pos_notation</a>();
<a name="l00340"></a>00340     }
<a name="l00341"></a>00341 
<a name="l00342"></a>00342     <span class="comment">// Apply constraint; stride is always one and maps only have one dimension</span>
<a name="l00343"></a>00343     fd = d_longitude-&gt;<a class="code" href="classlibdap_1_1Array.html#ae6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>();
<a name="l00344"></a>00344     d_longitude-&gt;<a class="code" href="classlibdap_1_1Array.html#a538f7c336e26b873f50e033d553bba26" title="Adds a constraint to an Array dimension.">add_constraint</a>(fd, <a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>(), 1,
<a name="l00345"></a>00345                                 <a class="code" href="classlibdap_1_1GeoConstraint.html#a8f7a2a062f1fa421de74bd41339c9e1b">get_longitude_index_right</a>());
<a name="l00346"></a>00346 
<a name="l00347"></a>00347     d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Array.html#a538f7c336e26b873f50e033d553bba26" title="Adds a constraint to an Array dimension.">add_constraint</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a5eee5cc9788b429e77bfde9f10bfe751">get_lon_dim</a>(),
<a name="l00348"></a>00348                                         <a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>(),
<a name="l00349"></a>00349                                         1, <a class="code" href="classlibdap_1_1GeoConstraint.html#a8f7a2a062f1fa421de74bd41339c9e1b">get_longitude_index_right</a>());
<a name="l00350"></a>00350 
<a name="l00351"></a>00351     <span class="comment">// Transfer values from the local lat vector to the Grid&#39;s</span>
<a name="l00352"></a>00352     <span class="comment">// Here test the sense of the latitude vector and invert the vector if the</span>
<a name="l00353"></a>00353     <span class="comment">// sense is &#39;inverted&#39; so that the top is always the northern-most value</span>
<a name="l00354"></a>00354     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1GeoConstraint.html#ac2f5c3f3e098c91f23e194fe7b775af8">get_latitude_sense</a>() == <a class="code" href="classlibdap_1_1GeoConstraint.html#a2304140a3b6310c6ed8bce30ebdaed7ba77fdac07a46105592ea0707f365f04c6">inverted</a>) {
<a name="l00355"></a>00355         <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;Inverted latitude sense&quot;</span> &lt;&lt; endl);
<a name="l00356"></a>00356         <a class="code" href="classlibdap_1_1GeoConstraint.html#a681345f3c4b95ae95ce5b49bb8ff248a">transpose_vector</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#ae1606e5fc999c32610a2ae2d60205a81">get_lat</a>() + <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>(),
<a name="l00357"></a>00357                 <a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>() - <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>() + 1);
<a name="l00358"></a>00358         <span class="comment">// Now read the Array data and flip the latitudes.</span>
<a name="l00359"></a>00359         <a class="code" href="classlibdap_1_1GeoConstraint.html#a74bb5010981355c8d688a2fd77613f80">flip_latitude_within_array</a>(*d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>(),
<a name="l00360"></a>00360                 <a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>() - <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>() + 1,
<a name="l00361"></a>00361                 <a class="code" href="classlibdap_1_1GeoConstraint.html#a8f7a2a062f1fa421de74bd41339c9e1b">get_longitude_index_right</a>() - <a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>() + 1);
<a name="l00362"></a>00362     }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364     <a class="code" href="namespacelibdap.html#a5d52ca5c40dd022353469e7b5d8a9ad4">set_array_using_double</a>(d_latitude, <a class="code" href="classlibdap_1_1GeoConstraint.html#ae1606e5fc999c32610a2ae2d60205a81">get_lat</a>() + <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>(),
<a name="l00365"></a>00365                            <a class="code" href="classlibdap_1_1GeoConstraint.html#a3f924c14bc89937c3db0b141f873b238">get_latitude_index_bottom</a>() - <a class="code" href="classlibdap_1_1GeoConstraint.html#ae0593d431954560825dcd96ded2141a7">get_latitude_index_top</a>() + 1);
<a name="l00366"></a>00366 
<a name="l00367"></a>00367     <a class="code" href="namespacelibdap.html#a5d52ca5c40dd022353469e7b5d8a9ad4">set_array_using_double</a>(d_longitude, <a class="code" href="classlibdap_1_1GeoConstraint.html#a695f79c26e7eef89c380788d3c1d5507">get_lon</a>() + <a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>(),
<a name="l00368"></a>00368                            <a class="code" href="classlibdap_1_1GeoConstraint.html#a8f7a2a062f1fa421de74bd41339c9e1b">get_longitude_index_right</a>() - <a class="code" href="classlibdap_1_1GeoConstraint.html#a8550d6aea8efad6f197b3350c19a25dc">get_longitude_index_left</a>() + 1);
<a name="l00369"></a>00369 
<a name="l00370"></a>00370     <span class="comment">// Look for any non-lat/lon maps and make sure they are read correctly</span>
<a name="l00371"></a>00371     <a class="code" href="classlibdap_1_1Grid.html#a69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> i = d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>();
<a name="l00372"></a>00372     <a class="code" href="classlibdap_1_1Grid.html#a69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> end = d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#aaebbf2a5329ec01b6527b4bafde87837">map_end</a>();
<a name="l00373"></a>00373     <span class="keywordflow">while</span> (i != end) {
<a name="l00374"></a>00374         <span class="keywordflow">if</span> (*i != d_latitude &amp;&amp; *i != d_longitude) {
<a name="l00375"></a>00375             <span class="keywordflow">if</span> ((*i)-&gt;send_p()) {
<a name="l00376"></a>00376                 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;reading grid map: &quot;</span> &lt;&lt; (*i)-&gt;name() &lt;&lt; endl);
<a name="l00377"></a>00377                 <span class="comment">//(*i)-&gt;set_read_p(false);</span>
<a name="l00378"></a>00378                 (*i)-&gt;read();
<a name="l00379"></a>00379             }
<a name="l00380"></a>00380         }
<a name="l00381"></a>00381         ++i;
<a name="l00382"></a>00382     }
<a name="l00383"></a>00383 
<a name="l00384"></a>00384     <span class="comment">// ... and then the Grid&#39;s array if it has been read.</span>
<a name="l00385"></a>00385     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1GeoConstraint.html#a05febc86a7353548656d76cbe659d4ed">get_array_data</a>()) {
<a name="l00386"></a>00386         <span class="keywordtype">int</span> size = d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1Vector.html#a96ecf84f2798065878755d9a9014ee69" title="Reads data into the Vector buffer. Thrown if called for Structure, Sequence or Grid.">val2buf</a>(<a class="code" href="classlibdap_1_1GeoConstraint.html#a05febc86a7353548656d76cbe659d4ed">get_array_data</a>());
<a name="l00387"></a>00387 
<a name="l00388"></a>00388         <span class="keywordflow">if</span> (size != <a class="code" href="classlibdap_1_1GeoConstraint.html#a93b13c51f03265b77c26c639253eb84c">get_array_data_size</a>())
<a name="l00389"></a>00389             <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">&quot;Expected data size not copied to the Grid&#39;s buffer.&quot;</span>);
<a name="l00390"></a>00390 
<a name="l00391"></a>00391         d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#adaa3661e737987979357f5e10f208640" title="Sets the value of the read_p property.">set_read_p</a>(<span class="keyword">true</span>);
<a name="l00392"></a>00392     }
<a name="l00393"></a>00393     <span class="keywordflow">else</span> {
<a name="l00394"></a>00394         d_grid-&gt;<a class="code" href="classlibdap_1_1Grid.html#a905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast is required...">get_array</a>()-&gt;<a class="code" href="classlibdap_1_1BaseType.html#a1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>();
<a name="l00395"></a>00395     }
<a name="l00396"></a>00396 }
<a name="l00397"></a>00397 
<a name="l00398"></a>00398 } <span class="comment">// namespace libdap</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="GridGeoConstraint_8cc.html">GridGeoConstraint.cc</a>      </li>
      <li class="footer">Generated on Tue Feb 8 2011 for libdap++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>