.. _newmtg_syntax: File syntax ########### .. todo:: revise the entire document to check tabulation of the examples .. contents:: General conventions =================== In general, words can be separated by any combination of whitespace characters (SPACE, TAB, EOL). In certain files, TABs or EOL are meaningful (e.g. MTG coding files), and therefore are not considered as a whitespace character in these files. Comments may be introduced anywhere in a file using the sharp sign #, meaning that the rest of the line is a comment. In some files, block comments can be introduced by bracketing the comment text with (# and #). Files used by AML can be located anywhere in the UNIX hierachical file system, provided the user can access them. All references to files from within a file or from AML must be given explicitly. References to files must always be made relatively to the location where the reference is made. In various files, user-defined names must be given to objects, attributes, etc. Unless specified otherwise, names always consist of strings of alphanumeric characters (including underscore '_') starting by a non-numeric character. A name may start by an underscore. Some names correspond to reserved keywords. Since reserved keywords always start in AMAPmod with uppercase letter, it is advised, though not mandatory, to define user-defined names starting with lowercase letter to avoid name collision. MTGs ==== Coding strategy --------------- A plant multiscale topology is represented by a string of characters (see 3.2.2). The string is made up of a series of labels representing plant components (a label is made up of an alphabetic character in A-Z,a-z and a numeric index) and of symbols representing either the physical relationships between the components. Character '/' is used for decomposition relationship (see next paragraph), '+' is used for branching relationship and '<' for successor relationship. For example:: /I11, can only appear if scale i-1 has appeared before. :: CLASSES SYMBOL SCALE DECOMPOSITION INDEXATION DEFINITION $ 0 FREE FREE IMPLICIT P 1 CONNECTED FREE IMPLICIT U 2 <-LINEAR FREE EXPLICIT I 2 <-LINEAR FREE EXPLICIT E 3 NONE FREE IMPLICIT Symbol $ represent the entire database and is defined by definition at scale 0. Keyword DECOMPOSITION defines the types of decomposition that can have a vertex (i.e. a plant constituent) : CONNECTED, LINEAR, <-LINEAR, +-LINEAR, FREE, NONE. Key word CONNECTED means that the decomposition graph of a vertex at the next scale is connected. Keyword LINEAR means that the decomposition graph of a vertex at the next scale is a linear sequence of vertices. Besides, if this all the constituents of this sequence are connected using a single type of edge (respectively < or +), then keyword <-LINEAR et +-LINEAR can respectively be used. Keyword FREE allows any type of decomposition structure while keyword NONE, specifies that the components of a unit must not be decomposed. Column INDEXATION is not used. Column DEFINITION must be filled with value EXPLICIT if any entity of that class has feature values (i.e. attributes). IMPLICIT should be used otherwise. This section is mandatory. **Topological constraints section** Topological constraints are described in the next section, beginning with keyword DESCRIPTION. Here, each line defines for a pair of classes at the same scale one allowed type of connection. It contains 4 columns, LEFT, RIGHT, RELTYPE, and MAX. For any class in column LEFT, the column RIGHT defines a list of class (appearing at the same scale) which can be connected to it using a connection of type RELTYPE. The maximum number of connections of type RELTYPE that can be made on an entity from column is defined in column MAX. If column MAX contains a question mark '?', the number of connections is not bounded. If a class does not appear in the column LEFT, then entities of this class cannot be connected to other entities in the MTG. :: DESCRIPTION: LEFT RIGHT RELTYPE MAX U U,I + ? U U,I < 1 I I + ? E E < 1 E E + 1 Let us resume on the example from the above CLASS section with its DESCRIPTION section. Since class P does not appear in the left column, a P cannot be connected to any other entity at scale 1, e.g. to any other P. Entities of type U can be connected to entities of either type I or U, for any of the connection types < et +. An entity of type U can be connected by relation + to any number of Us or Is. However, they can only be connected by relation < to at most one entity of either type U or I. Entities of type I cannot be connected by relation < to any type of entity, while they can be connected to other I's by relation +. At scale 3, any E can be connected to only one other E by either relation + or <. This section is mandatory but can contain no topology description. **Attribute section** The third and last part of the header contains a list of names defining the features that can be attached to plant entities and their types. This part begins with keyword FEATURES. Thelist of names appears in column NAME and the corresponding types in column TYPE. The name of an attribute might be either a reserved keyword (see a list below) or a user-defined name. The types of attributes can be INT (integer), REAL (real number), STRING (string of characters from {A...Za...z-+. /} and which are bounded to 14 characters max), DD/MM, DD/MM/YY, MM/YY, DD/MM-TIME, DD/MM/YY-TIME (Dates), GEOMETRY (geometric objects defined in a .geom file), APPEARANCE (appearance objects defined in a .app file), OBJECT (general object defined in generic type of file). :: FEATURES: NAME TYPE Alias STRING Date DD/MM NbEl INT State STRING flowerNb INT len INT TopDiameter REAL geom GEOMETRY geom1.geom appear APPEARANCE material.app Certain names of attributes are reserved keywords. They all start by an upper-case letter. If they appear in the feature list, they must be in the same order as in the following description. Alias, of type STRING (formerly ALPHA), must come first if used. It allows the user to define aliases for plant entities to simplify some code strings. Date, is used to define the observation date of an entity. NbEl (NumBer of ELements), defines the number of components on any entity at the next scale. Length is the length of an entity. BottomDiameter et TopDiameter respectively define the bottom and top stretching values of a tapered transformed that is applied to the geometric symbol representing this entity (for branch segments associated with cylinder as a basic geometrc model, this defines cone frustums). State of type STRING defines the state of an entity at the time of observation. This state can be D (Dead), A (Alive), B (Broken) , P (Pruned), G (Growing), V (Vegetative), R (Resting), C (Completed), M (Modified). These letters can be combined to form a string of characters, provided they consistent with one another. Such state descriptions are checked during the parsing of the MTG and possible inconsistencies are detected. This section is mandatory but can contain no features. Coding section ~~~~~~~~~~~~~~ The section containing the code of a MTG starts by keyword MTG. The next line contains a list of column names. In the first column, the keyword TOPO indicates that this column and the next unlabelled column are reserved for the topological code. On the same line, all the names that appear in the FEATURE section of the header must appear, in the same order, one column after the other, starting with the first feature name in a column sufficiently far from the TOPO column to leave enough space for the topological code (see examples below). The topological code must necessarily start by a '/' like in:: /P1/A1... It can spread on all the columns before the first feature column. Since entity names have a nested definition, a plant description can be made on a single line. However, if one wants to declare feature values attached to some entity, the plant code must be interrupted after the label of this entity, attributes must be entered on the same line in corresponding columns, and the plant code must continue at the next line. Note that in the current implementation of the parser, an entity which has no features uses obviously 0 bytes of memory for recording features, however, assuming that the total number of features is F, if an entity has at least one feature value defined, it uses a constant space F*14 bytes to record its feature (whatever the actual number of features defined for this entity). **Example** Here is an example of a coding file corresponding to plant illustrated on Figure 4-1:: CODE: FORM-A CLASSES: SYMBOL SCALE DECOMPOSITION INDEXATION DEFINITION $ 0 FREE FREE IMPLICIT P 1 CONNECTED FREE IMPLICIT A 2 <-LINEAR FREE EXPLICIT S 2 CONNECTED FREE EXPLICIT U 3 NONE FREE IMPLICIT DESCRIPTION: LEFT RIGHT RELTYPE MAX A A,S + ? U U < 1 U U + ? FEATURES: NAME TYPE MTG: TOPO /P1/A1 /P1/A1/U1, Dec 2009 Documentation adapted from the AMAPmod user manual version 1.8.