-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHexAscii.bnf
71 lines (56 loc) · 2.12 KB
/
HexAscii.bnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# BNF syntax for ASCII encoded cartographic hexagonal rasters.
#
# Author: Luís de Sousa (luis.de.sousa[@]protonmail.ch)
# Date: 02-02-2016
#
# This specification uses non-formal rules to ease readability:
# . Optional items enclosed in square brackets, e.g. ["+"|"-"]
# . Items existing zero or more times enclosed in curly brackets, e.g {digit}
#
# Verify BNF grammars online:
# http://www.icosaedro.it/bnf_chk/bnf_chk-on-line.html
# -----------------------------------------------
# Basic elements
# A set of one or more blank spaces
blank = " "|"\t" {blank};
# Line break
line_break = "\n"|"\r";
# A digit is any character from 0 to 9:
digit = "0".."9";
# Number is a positive integer:
number = digit {digit};
# Integer numbers have an optional +/- sign followed by one or more digits:
integer = ["+"|"-"] digit {digit};
# Real numbers have an integer part followed either by a fractional part or an exponent part or both:
fraction = "." digit {digit};
exponent = ("E"|"e") integer;
real = integer (fraction | exponent| fraction exponent);
# -----------------------------------------------
# Main structure
# An HexAscii file is composed by three sections:
# . mandatory header
# . optional parameters
# . cell values values
hasc_raster = mandatory_header optional_fields cell_values;
# The mandatory header comprises:
# . number of columns
# . number of rows
# . xx coordinate of the lower left hexagon centroid
# . yy coordinate of the lower left hexagon centroid
# . hexagon side (in map units)
mandatory_header = ncols nrows xll yll side;
ncols = "ncols" blank number line_break;
nrows = "nrows" blank number line_break;
xll = "xll" blank real line_break;
yll = "yll" blank real line_break;
side = "side" blank real line_break;
# The optional fields:
# . no_data, for cell with unknown value
# . angle, specifying a rotation relative to the xx axis
optional_fields = {no_data} {angle};
no_data = "no_data" blank real line_break;
angle = "angle" blank real line_break;
# The data array, with values separated by blanks or line breaks
cell_values = cell_value {cell_value};
cell_value = real blank|line_break;