# Copyright 2005-2018 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# 
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#


# START 2/template.3.140 ----------------------------------------------------------------------
# TEMPLATE 3.140, Lambert azimuthal equal area projection
include "grib2/template.3.shape_of_the_earth.def";

#  Nx - number of points along X-axis
unsigned[4] numberOfPointsAlongXAxis : dump  ;
alias Nx  = numberOfPointsAlongXAxis;

#  Ny - number of points along Y-axis
unsigned[4] numberOfPointsAlongYAxis : dump  ;
alias Ny =  numberOfPointsAlongYAxis;

#  La1 - latitude of first grid point
signed[4] latitudeOfFirstGridPoint: edition_specific ;
alias La1 =  latitudeOfFirstGridPoint;
meta  geography.latitudeOfFirstGridPointInDegrees   scale(latitudeOfFirstGridPoint
                                                 ,one,grib2divider,truncateDegrees) : dump;
#meta latitudeOfFirstGridPointInMicrodegrees times(latitudeOfFirstGridPoint,mAngleMultiplier,angleDivisor): no_copy;

#  Lo1 - longitude of first grid point
signed[4] longitudeOfFirstGridPoint: edition_specific ;
alias La1 =  longitudeOfFirstGridPoint;
meta  geography.longitudeOfFirstGridPointInDegrees   scale(longitudeOfFirstGridPoint
                                                 ,one,grib2divider,truncateDegrees) : dump;
#meta longitudeOfFirstGridPointInMicrodegrees times(longitudeOfFirstGridPoint,mAngleMultiplier,angleDivisor) : no_copy;

signed[4] standardParallelInMicrodegrees  : dump;
alias standardParallel=standardParallelInMicrodegrees;

signed[4] centralLongitudeInMicrodegrees  : dump;
alias centralLongitude=centralLongitudeInMicrodegrees;

#  Resolution and component flag
flags[1] resolutionAndComponentFlags 'grib2/tables/[tablesVersion]/3.3.table' : dump ;

#  Dx - X-direction grid length in millimetres
unsigned[4] xDirectionGridLengthInMillimetres  : dump ;
alias Dx  = xDirectionGridLengthInMillimetres ;

#  Dy - Y-direction grid length in millimetres
unsigned[4] yDirectionGridLengthInMillimetres  : dump ;
alias Dy  = yDirectionGridLengthInMillimetres ;

include "grib2/template.3.scanning_mode.def";

iterator lambert_azimuthal_equal_area(numberOfPoints,missingValue,values,
          radius,Nx,Ny,
          latitudeOfFirstGridPointInDegrees,longitudeOfFirstGridPointInDegrees,
          standardParallel,centralLongitude,
          Dx,Dy,
          iScansNegatively,
          jScansPositively,
          jPointsAreConsecutive,
          alternativeRowScanning);

meta latLonValues latlonvalues(values);
alias latitudeLongitudeValues=latLonValues;
meta latitudes latitudes(values,0);
meta longitudes longitudes(values,0);

# END   2/template.3.140 ----------------------------------------------------------------------
