# 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.
#

# GRID DEFINITION Space view, perspective or orthographic
# grib 1 -> 2
constant gridDefinitionTemplateNumber     = 90;

unsigned[2] Nx  : dump;
alias numberOfPointsAlongXAxis = Nx;
alias Ni = Nx;
alias geography.Nx=Nx;

unsigned[2] Ny  : dump;
alias numberOfPointsAlongYAxis = Ny;
alias Nj = Ny;
alias geography.Ny=Ny;

signed[3] latitudeOfSubSatellitePoint ;
meta geography.latitudeOfSubSatellitePointInDegrees  scale(latitudeOfSubSatellitePoint,oneConstant,grib1divider,truncateDegrees) : dump;
alias Lap=latitudeOfSubSatellitePoint;

signed[3] longitudeOfSubSatellitePoint ;
meta geography.longitudeOfSubSatellitePointInDegrees  scale(longitudeOfSubSatellitePoint,oneConstant,grib1divider,truncateDegrees) : dump;
alias Lap=longitudeOfSubSatellitePoint;

include "grib1/resolution_flags.def";

unsigned[3] dx  : dump;
alias geography.dx=dx;

unsigned[3] dy  : dump;
alias geography.dy=dy;

unsigned[2] XpInGridLengths  : dump;
alias geography.XpInGridLengths=XpInGridLengths;


unsigned[2] YpInGridLengths  : dump;
alias geography.YpInGridLengths=YpInGridLengths;

include "grib1/scanning_mode.def";

unsigned[3] orientationOfTheGrid : edition_specific ;
meta geography.orientationOfTheGridInDegrees  scale(orientationOfTheGrid,oneConstant,grib1divider,truncateDegrees) : dump;

unsigned[3] NrInRadiusOfEarth : edition_specific,can_be_missing,no_copy;
alias altitudeOfTheCameraFromTheEarthSCenterMeasuredInUnitsOfTheEarth = NrInRadiusOfEarth;

unsigned[2]  Xo : dump;
alias xCoordinateOfOriginOfSectorImage=Xo;
alias geography.Xo=Xo;

unsigned[2] Yo  : dump;
alias yCoordinateOfOriginOfSectorImage=Yo;
alias geography.Yo=Yo;

#Ce      Length is normally 32 + stretched and/or rotated
#Ce      parameters + vertical coordinate parameters + list of
#Ce      numbers of points.
#Ce      (Lambert conformal and Mercator are 42 octets in length,
#Ce      while Space view is 40 for ECMWF (44 in GRIB specification)
if ( centre != 98 ) {
  pad padding_grid90_1(6);
}

meta numberOfDataPoints number_of_points(Ni,Nj,PLPresent,pl) : dump;
alias numberOfPoints=numberOfDataPoints;
meta numberOfValues number_of_values(values,bitsPerValue,numberOfDataPoints,bitmapPresent,bitmap,numberOfCodedValues) : dump;
#alias ls.valuesCount=numberOfValues;

