[GRASS-SVN] r57192 - grass-addons/grass6/general/g.infer

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 17 06:33:12 PDT 2013


Author: neteler
Date: 2013-07-17 06:33:10 -0700 (Wed, 17 Jul 2013)
New Revision: 57192

Modified:
   grass-addons/grass6/general/g.infer/Makefile
   grass-addons/grass6/general/g.infer/description.html
   grass-addons/grass6/general/g.infer/reference.py
   grass-addons/grass6/general/g.infer/spearfish.py
Log:
g.infer: proper HTML formatting started; svn propset


Property changes on: grass-addons/grass6/general/g.infer/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Modified: grass-addons/grass6/general/g.infer/description.html
===================================================================
--- grass-addons/grass6/general/g.infer/description.html	2013-07-17 13:19:36 UTC (rev 57191)
+++ grass-addons/grass6/general/g.infer/description.html	2013-07-17 13:33:10 UTC (rev 57192)
@@ -1,130 +1,160 @@
-
-
 <h2>DESCRIPTION</h2>
 
-<b>g.infer</b> is a tool to create rule-based data-driven workflows from GRASS data layers and additional data sources.
-<b>g.infer</b> can modify existing GRASS data layers, 
-can create new vector layers or can start additional additional GRASS modules. 
-This is controlled by an inference process,
-which applies a knowledge base on a set of known facts (data). 
-g.infer provides a <b>Production System</b> to set up <b>Expert Systems</b> from domain knowledge and GIS data layers. <p>
+<b>g.infer</b> is a tool to create rule-based data-driven workflows 
+from GRASS data layers and additional data sources.
+<b>g.infer</b> can modify existing GRASS data layers, can create new 
+vector layers or can start additional additional GRASS modules. This 
+is controlled by an inference process, which applies a knowledge 
+base on a set of known facts (data). <em>g.infer</em> provides a
+<b>Production System</b> to set up <b>Expert Systems</b> from domain 
+knowledge and GIS data layers. <p>
 
 <p>
-The g.infer inference environment is based on a strict separation of knowledge (rules) and data (facts and  object instances).
- Data consists of GRASS-derived spatial information and other input. 
- The g.infer inference engine applies the knowledge, consisting of rules (stored in the rulebase), to the available data.
- For development and testing, interactive access and logging options are available.
+The <em>g.infer</em> inference environment is based on a strict 
+separation of knowledge (rules) and data (facts and  object 
+instances). Data consists of GRASS-derived spatial information and 
+other input. The <em>g.infer</em> inference engine applies the 
+knowledge, consisting of rules (stored in the rulebase), to the 
+available data. For development and testing, interactive access and 
+logging options are available.
 <p>
-g.infer provides a flexible environment to start rule-based work. 
-For complex tasks there are also advanced capabilities to extend the knowledge modelling whenever necessary.
-This approach can be used for geodata classification, GIS workflow control and other tasks.
+<em>g.infer</em> provides a flexible environment to start rule-based 
+work. For complex tasks there are also advanced capabilities to 
+extend the knowledge modelling whenever necessary. This approach can 
+be used for geodata classification, GIS workflow control and other 
+tasks.
 
 <p>
-The <b>C-Language Integrated Production System (CLIPS) Expert System Shell</b> environment is embedded 
-within g.infer using the <b>pyCLIPS</b> Python module. 
-In depth information is found in the References, 
-which contain also links to literature describing the projects <b>Jess</b> and <b>Drools</b> which are based on CLIPS. 
-Their documentation contains additional clues for CLIPS-related development.
+The <b>C-Language Integrated Production System (CLIPS) Expert System 
+Shell</b> environment is embedded within <em>g.infer</em> using the 
+<b>pyCLIPS</b> Python module. In depth information is found in the 
+References, which contain also links to literature describing the 
+projects <b>Jess</b> and <b>Drools</b> which are based on CLIPS. 
+Their documentation contains additional clues for CLIPS-related 
+development.
 <p>
-The exchange of data between the GRASS and CLIPS environments is handled by extensions of the pyCLIPS functionality, 
-connecting both GRASS and CLIPS. 
-See the "Notes on g.infer pyCLIPS extensions" section for details. <p>
+The exchange of data between the GRASS and CLIPS environments is 
+handled by extensions of the pyCLIPS functionality, connecting both 
+GRASS and CLIPS. See the "Notes on g.infer pyCLIPS 
+extensions" section for details. <p>
 
 
 <h3>Input</h3>
 
-g.infer can ingest multiple input sources as data: Spatial information can be imported 
-from GRASS data layers (raster, rast3d, point-vector) and additional sources. 
-Rule base-related constructs (templates, facts, classes and instances) are read from 
-external files or built-in rule bases via the library option.
+<em>g.infer</em> can ingest multiple input sources as data: Spatial 
+information can be imported from GRASS data layers (raster, rast3d, 
+point-vector) and additional sources. Rule base-related constructs 
+(templates, facts, classes and instances) are read from external 
+files or built-in rule bases via the library option.
 <p>
-Additional data can also be imported during the inference process if requested by the rule base. 
-The user can further enter facts and rulebase elements via an interactive CLIPS prompt.
+Additional data can also be imported during the inference process if 
+requested by the rule base. The user can further enter facts and 
+rulebase elements via an interactive CLIPS prompt.
 
 <h3>Output</h3>
 
-g.infer can manipulate the content of imported GRASS data layers and other sources of data.
-These changes can be written back to the respective GRASS layers using the <b>export</b> option for persistent storage.
-A new vector layer can be created through the <b>output</b> option. 
-The creation of additional GRASS layers can be invoked by the rulebase beyond 
-the limited range of options provided by g.infer module parameters.
+<em>g.infer</em> can manipulate the content of imported GRASS data 
+layers and other sources of data. These changes can be written back 
+to the respective GRASS layers using the <b>export</b> option for 
+persistent storage. A new vector layer can be created through the
+<b>output</b> option. The creation of additional GRASS layers can be 
+invoked by the rulebase beyond the limited range of options provided 
+by <em>g.infer</em> module parameters.
 
 
-
 <h3>Rulebase</h3>
 
-The g.infer rulebases contains the working knowledge for the inference process, which is seperate from the data (facts). 
-They are read from file by the <b>rulebase</b> option or selected using the <b>library</b> option. 
-Rulebases can be edited via the interactive CLIPS prompt (-i flag) before the actual inference run. <p>
+The <em>g.infer</em> rulebases contains the working knowledge for 
+the inference process, which is seperate from the data (facts). They 
+are read from file by the <b>rulebase</b> option or selected using 
+the <b>library</b> option. Rulebases can be edited via the 
+interactive CLIPS prompt (-i flag) before the actual inference run. 
+<p>
+There are three ways  to represent knowledge in g.infer. They are 
+based on concepts from the CLIPS programming language (see CLIPS 
+documentation for details). All of them can be part of the rulebase:
 
-There are three ways  to represent knowledge in g.infer. They are based on concepts from the CLIPS programming language 
-(see CLIPS documentation for details). 
-All of them can be part of the rulebase:
 <ul>
-<li><b>Rules</b>, for heuristic knowledge based on experience. Rules can be applied to facts and objects.
+<li><b>Rules</b>, for heuristic knowledge based on experience. Rules 
+can be applied to facts and objects.
 <p>
-<li><b>Functional Programming</b>, where functions defined as code returning values based on the provided input.
+<li><b>Functional Programming</b>, where functions defined as code 
+returning values based on the provided input.
 <p>
-<li><b>Object-oriented programming</b>, supporting  features such as classes, 
-message-handlers, abstraction, encapsulation, inheritance and polymorphism.
+<li><b>Object-oriented programming</b>, supporting  features such as 
+classes, message-handlers, abstraction, encapsulation, inheritance 
+and polymorphism.
 </ul>
 <p>
- Rules adhere to a IF THEN layout defined by the CLIPS programming language (see below). 
- The condition antecedent ("IF") -part is referred to as left hand side (<b>LHS</b>), 
- while the invoked consequent ("THEN") is  called the right hand side (<b>RHS</b>). 
- LHS and RHS sides of a rule statement are connected by the "<b>=></b>" characters. 
+Rules adhere to a IF THEN layout defined by the CLIPS programming 
+language (see below). The condition antecedent ("IF") -part is 
+referred to as left hand side (<b>LHS</b>), while the invoked 
+consequent ("THEN") is  called the right hand side (<b>RHS</b>). LHS 
+and RHS sides of a rule statement are connected by the "<b>=></b>" 
+characters.
 <p>
 
 
 <h3>Inference Engine</h3>
 
-The inference engine is the part of the g.infer module which evaluates what rules are to be applied, 
-based on the currently available data (facts).
+The inference engine is the part of the <em>g.infer</em> module 
+which evaluates what rules are to be applied, based on the currently 
+available data (facts).
 
-The CLIPS inference engine used in g.infer is based on the Rete algorithm (Forgy 1982), 
-using a forward-chaining data-driven approach.
-The order in which rules are to be executed can be controlled in three ways: 
-By explicitly defining <b>salience</b> values for each rule,
-knowledge base partitioning by <b>modules</b> or implicitly by setting the
-<b>conflict resolution</b> strategy (<b>strategy</b> option).  
-The section "Rulbase Development, Operation and Debugging" holds a more detailed description.
+The CLIPS inference engine used in <em>g.infer</em> is based on the 
+Rete algorithm (Forgy 1982), using a forward-chaining data-driven 
+approach. The order in which rules are to be executed can be 
+controlled in three ways: By explicitly defining <b>salience</b> 
+values for each rule, knowledge base partitioning by <b>modules</b> 
+or implicitly by setting the <b>conflict resolution</b> strategy
+(<b>strategy</b> option). The section "Rulbase Development, Operation 
+and Debugging" holds a more detailed description.
 
-<p>
+<h3>Performance</h3>
 
-<h3>Performance</h3>
-The Rete-algorithm performs well for a change  below 10 percent of the available data (facts) during an inference run.
-Scenarios, in which the complete content of a GRASS layer must be changed, 
+The Rete-algorithm performs well for a change  below 10 percent of 
+the available data (facts) during an inference run. Scenarios, in 
+which the complete content of a GRASS layer must be changed, 
 resulting in 100 percent change, will result in decreased performance.
 <p>
-g.infer uses the current settings of the GRASS region to create facts from the GIS layers which are provided as input. 
-The resolution of the region must be set appropriately for the task, 
-as a very high resolution will result in a large number of facts.
+<em>g.infer</em> uses the current settings of the GRASS region to 
+create facts from the GIS layers which are provided as input. The 
+resolution of the region must be set appropriately for the task, as 
+a very high resolution will result in a large number of facts.
 
 <h3>Knowledge Engineering in g.infer</h3>
 
-Knowledge engineering (modelling) in g.infer involves in most cases the definition of  rules for the rulebase. 
-It can also include more complex programming tasks, 
-such as conditions, loops, functions and object oriented programming.
+Knowledge engineering (modelling) in <em>g.infer</em> involves in 
+most cases the definition of  rules for the rulebase. It can also 
+include more complex programming tasks, such as conditions, loops, 
+functions and object oriented programming.
 
-For knowledge modelling and programming in g.infer, 
-the programming language of the CLIPS Expert System Toolkit is used, 
-which is closely related to the programming language <b>LISP</b>.
-For an in depth description of the CLIPS language, 
-refer to the CLIPS Users's Guide and Reference Manuals (Giarratano 2007, 2008). 
-A useful introduction to LISP is provided by Graham, 1995.<p>
+For knowledge modelling and programming in <em>g.infer</em>, the 
+programming language of the CLIPS Expert System Toolkit is used, 
+which is closely related to the programming language <b>LISP</b>. 
+For an in depth description of the CLIPS language, refer to the 
+CLIPS Users's Guide and Reference Manuals (Giarratano 2007, 2008).
+A useful introduction to LISP is provided by Graham, 1995.
+<p>
 
-In the following, the given <i>examples</i> refer to a rulebase and are imported via a rulebase file, 
-from a built in demo rulebase, or are entered using the interactive CLIPS prompt. 
-This CLIPS-based <b>programming</b> can not be mixed with GRASS GIS scripting, 
-but can invoke GRASS modules as part of the RHS of rules.
+In the following, the given <i>examples</i> refer to a rulebase and 
+are imported via a rulebase file, from a built in demo rulebase, or 
+are entered using the interactive CLIPS prompt. This CLIPS-based
+<b>programming</b> can not be mixed with GRASS GIS scripting, but can 
+invoke GRASS modules as part of the RHS of rules.
 
 <h4>Rulebase Notation</h4>
 
-<b>g.infer</b> rulebase constructs use a fully parenthesized polish prefix notation: 
-Any term, or formula, must be put in braces, with the operator preceding the operands:
-<pre>(operator operand1 operand2 ... operandN)</pre>
+<em>g.infer</em> rulebase constructs use a fully parenthesized polish 
+prefix notation: Any term, or formula, must be put in braces, with 
+the operator preceding the operands:
+
+<div class = "code"><pre>
+(operator operand1 operand2 ... operandN)
+</pre></div>
 <p>
-This differs from the infix notation commonly used in GRASS GIS, like in r.mapcalc:
+This differs from the infix notation commonly used in GRASS GIS, like in
+<em>r.mapcalc</em>:
 <p>
 
 <ul>
@@ -134,88 +164,100 @@
 <p>
 
 <h4>Data Types</h4>
-g.infer's rule engine provides eight primitive data types for representing information.
-As the programming language of the CLIPS Production System is weakly typed, 
-variables can be declared without explicitly setting a type. 
-The available types are 
-<b>float, integer, symbol, string, external-address, fact-address, instance-name</b> and <b>instance-address</b>. 
-<b>Numeric information</b> can be represented using floats and integers. 
-<b>Symbolic information</b> can be represented using symbols and strings. 
-A number consists only of digits (0-9), a decimal point (.), a sign (+ or -), and, optionally, 
-an (e) for exponential notation with its corresponding sign. A number is either stored as a float or an integer. 
-Any number consisting of an optional sign followed by only digits is stored as an integer. 
-All other numbers are stored as floats.
 
-<p>
+<em>g.infer</em>'s rule engine provides eight primitive data types 
+for representing information. As the programming language of the 
+CLIPS Production System is weakly typed, variables can be declared 
+without explicitly setting a type. The available types are 
+<ul>
+<li><b>float, integer, symbol, string, external-address, 
+fact-address, instance-name</b> and <b>instance-address</b>.</li>
+<li><b>Numeric information</b> can be represented using floats and 
+integers.</li>
+<li><b>Symbolic information</b> can be represented using symbols and 
+strings.</li>
+</ul>
+A number consists only of digits (0-9), a decimal point (.), a sign 
+(+ or -), and, optionally, an (e) for exponential notation with its 
+corresponding sign. A number is either stored as a float or an 
+integer. Any number consisting of an optional sign followed by only 
+digits is stored as an integer. All other numbers are stored as 
+floats.
 
 <h4>Facts</h4>
 
-Facts are the common high level form for representing information in g.infer.
-Within the CLIPS Production System, facts are the fundamental unit of data to be processed 
-by the rulebase to infer information by the firing of applicable rules.
-Each fact represents a piece of data which has been placed in the overall <b>fact list</b> of the currently known facts.
+Facts are the common high level form for representing information in 
+g.infer. Within the CLIPS Production System, facts are the 
+fundamental unit of data to be processed by the rulebase to infer 
+information by the firing of applicable rules. Each fact represents 
+a piece of data which has been placed in the overall <b>fact list</b>
+of the currently known facts.
 
-
 <p>
-Facts may be added to the fact list (using the <b>assert</b> command), 
-removed from the fact list (using the <b>retract</b> command),
-modified (using the <b>modify</b> command), or duplicated (using the <b>duplicate</b> command) by 
-either direct user interaction or while the rule base is executed.
-The number of facts in the <b>fact list</b>  and the amount of information that can be stored within a fact 
-is limited only by the amount of available memory.
-If a fact is to be asserted into the fact list which exactly matches an already existing fact, 
-the new assertion will be ignored. This default behaviour can be changed.
+Facts may be added to the fact list (using the <b>assert</b> 
+command), removed from the fact list (using the <b>retract</b> 
+command), modified (using the <b>modify</b> command), or duplicated 
+(using the <b>duplicate</b> command) by either direct user 
+interaction or while the rule base is executed. The number of facts 
+in the <b>fact list</b>  and the amount of information that can be 
+stored within a fact is limited only by the amount of available 
+memory. If a fact is to be asserted into the fact list which exactly 
+matches an already existing fact, the new assertion will be ignored. 
+This default behaviour can be changed.
 
 <p>
-Some CLIPS language commands, including <b>retract, modify,</b> and <b>duplicate</b>, require a fact to be specified by a reference.
-A fact can be specified either by fact index or fact address:
-Whenever a fact is asserted (or modified) it is assigned a unique index number called its <b>fact index</b>.
-Fact indices start at zero and are incremented by one for each new or changed fact. 
-Whenever a <b>reset</b> or <b>clear</b> command is given, the fact indices restart at zero.
-A fact may also be specified through the use of a <b>fact address</b>.
-A fact address can be obtained by capturing the return value of commands 
-which return fact addresses (such as assert, modify, and duplicate)
-or by binding a variable to the fact address of a  fact which matches a pattern on the LHS of a rule.
-A <b>fact identifier</b> is a shorthand notation for printing a fact. 
-It consists of the character <b>f</b>, followed by a dash, followed by the fact index of the fact.
-<p>
 
-
-There are two categories of facts, <b>ordered facts</b> and <b>non-ordered facts</b>. 
-Both types are applied in g.infer to represent information imported from the GRASS GIS environment.
-
-
-
+Some CLIPS language commands, including <b>retract, modify,</b> and 
+<b>duplicate</b>, require a fact to be specified by a reference. A 
+fact can be specified either by fact index or fact address: Whenever 
+a fact is asserted (or modified) it is assigned a unique index 
+number called its <b>fact index</b>. Fact indices start at zero and 
+are incremented by one for each new or changed fact. Whenever a
+<b>reset</b> or <b>clear</b> command is given, the fact indices restart 
+at zero. A fact may also be specified through the use of a
+<b>fact address</b>. A fact address can be obtained by capturing the
+return value of commands which return fact addresses (such as assert, 
+modify, and duplicate) or by binding a variable to the fact address 
+of a  fact which matches a pattern on the LHS of a rule. A
+<b>fact identifier</b> is a shorthand notation for printing a fact. It 
+consists of the character <b>f</b>, followed by a dash, followed by 
+the fact index of the fact.
 <p>
+There are two categories of facts, <b>ordered facts</b> and <b>
+non-ordered facts</b>. Both types are applied in <em>g.infer</em> to 
+represent information imported from the GRASS GIS environment.
 
 <h5> Ordered facts </h5>
+
+Ordered facts consist of a symbol followed by a sequence of zero or 
+more fields separated by spaces and delimited by an opening 
+parenthesis on the left and a closing parenthesis on the right. 
+Ordered facts encode information positionally and can contain 
+multiple data fields. The first field of an ordered fact specifies a 
+<b>relation</b> that applied to the remaining fields in the ordered 
+fact.
 <p>
-Ordered facts consist of a symbol followed by a sequence of zero or more fields separated by spaces 
-and delimited by an opening parenthesis on the left and a closing parenthesis on the right.
-Ordered facts encode information positionally and can contain multiple data fields. 
-The first field of an ordered fact specifies a <b>relation</b> that applied to the remaining fields in the ordered fact.
-
 For example, <pre>(is-a GRASS GIS)</pre> states that GRASS is a GIS.
 
 <p>
+See the CLIPS Introduction and User Guides in the Reference Section 
+for an in-depth discussion.
 
-See the CLIPS Introduction and User Guides in the Reference Section for an in-depth discussion.
-
-
-
 <p>
-
 A simple fact can contain multiple fields for content:
 
 <pre>(assert (trail "OtterTrail" scenic flat))</pre>
 
 <h5> GRASS environment variables as ordered facts </h5>
+
+Ordered facts are used to represent GRASS enironment variables into 
+g.infer, including g.region parameters. These ordered facts can be 
+manipulated within the CLIPS environment and be used when calling 
+GRASS modules from within CLIPS. They must be exported back into 
+GRASS to become permanent within the current session, which is not 
+done by default. The following representations of GRASS environment 
+variables as facts are generated by default:
 <p>
-Ordered facts are used to represent GRASS enironment variables into g.infer, including g.region parameters. 
-These ordered facts can be manipulated within the CLIPS environment and be used when calling GRASS modules from within CLIPS. 
-They must be exported back into GRASS to become permanent within the current session, which is not done by default. 
-The following representations of GRASS environment variables as facts are generated by default:
-<p>
 
 REGION_ROWS, REGION_COLS, REGION_CELLS, REGION_NSRES, REGION_EWRES, 
 REGION_N, REGION_S, REGION_E, REGION_W, 
@@ -223,28 +265,30 @@
 REGION_TBRES, REGION_T, REGION_B, REGION_DEPTHS, 
 GISDBASE, LOCATION_NAME, MAPSET, GRASS_GUI
 
-
-
-
 <h5> Non-ordered facts </h5>
 
+Facts to contain structured information require a <b>template</b> to 
+define the structure:
 <p>
-Facts to contain structured information require a <b>template</b> to define the structure:
+
+Template based, non ordered facts allow to structure the content of 
+a fact by assessing data fields by name (and type). The
+<b>deftemplate</b> construct  is used to create a named template (which 
+can then be used to access fields by name). This approach is used to 
+import GRASS layers in <em>g.infer</em> to create the respective 
+facts.
 <p>
-Template based, non ordered facts allow to structure the content of a fact by assessing data fields by name (and type).
-The <b>deftemplate</b> construct  is used to create a named template (which can then be used to access fields by name). 
-This approach is used to import GRASS layers in g.infer to create the respective facts.
-<p>
 
+The deftemplate construct allows the name of a template to be 
+defined along with zero or more definitions of named fields, also 
+called slots. Unlike ordered facts, the slots of a deftemplate fact 
+may be constrained by type, value, and numeric range. In addition, 
+default values can be specified for a slot. A slot consists of an 
+opening parenthesis followed by the name of the slot, zero or more 
+fields, and a closing parenthesis.
 
-The deftemplate construct allows the name of a template to be defined along with zero or more definitions of named fields, 
-also called slots. Unlike ordered facts, the slots of a deftemplate fact may be constrained by type, 
-value, and numeric range. In addition, default values can be specified for a slot. 
-A slot consists of an opening parenthesis followed by the name of the slot, 
-zero or more fields, and a closing parenthesis.
 <p>
 
-
 Deftemplate facts are easily distinguished from ordered facts by their first field. 
 If the symbol serving as the first field corresponds to the name of a deftemplate, 
 then the fact is a deftemplate fact. Like ordered facts, deftemplate facts are enclosed 
@@ -276,15 +320,15 @@
 
 Rast3d: <pre>(random_slice_00009 (x 599000.0) (y 4921800.0) (z 9.0) (value 1.0))</pre>
 <p>
-<pre>"_slice_000009" has been added by g.infer for internal reference.</pre>
+<pre>"_slice_000009" has been added by <em>g.infer</em> for internal reference.</pre>
 
 
 
 <h4>Rules</h4>
 
 <p>
-The primary method of representing and modifing knowledge in g.infer are rules. 
-Any g.infer rulebase comprises of a set of rules which collectively
+The primary method of representing and modifing knowledge in <em>g.infer</em> are rules. 
+Any <em>g.infer</em> rulebase comprises of a set of rules which collectively
  solve a classification task, establish a workflow or do similar. Rules are used to represent heuristics, or "rules of thumb",
 which specify a set of actions to be performed for a given situation.
 Rules can cause actions such as the creation, modification or deletion of facts or the call-up of GRASS modules and scripts.
@@ -366,9 +410,9 @@
 
 <h3>Rulebase Development, Operation and Debugging:</h3>
 
-g.infer is a tool to set up and operate rule-based workflows for information classification and data processing.
+<em>g.infer</em> is a tool to set up and operate rule-based workflows for information classification and data processing.
 The workflow will be loaded via a 'rulebase'-file or a built in rulebase, consisting of a set of rules, called a knowledge base. <p>
-Rule activiation is controlled by the g.infer rule engine, based on spatial data from the GIS layers.
+Rule activiation is controlled by the <em>g.infer</em> rule engine, based on spatial data from the GIS layers.
 
 When a rule is activated for the first time, it is placed on the <b>agenda</b>, based (in order) on the following factors:
 <p>
@@ -384,7 +428,7 @@
 This arbitrary ordering for the proper execution of rules should not be depended on for knowledge modelling.
 <p>
 
-Once a knowledge base (in the form of rules) has been loaded into g.infer 
+Once a knowledge base (in the form of rules) has been loaded into <em>g.infer</em> 
 and the fact and instance lists are available, the inference engine is ready to execute rules:
 <p>
 <ul>
@@ -435,7 +479,7 @@
 <p>
 The <b>conflict resolution strategy</b> is an implicit mechanism for specifying the order in which rules of equal salience should be executed.
 <p>
-g.infer provides seven conflict resolution strategies. The default strategy is depth. 
+<em>g.infer</em> provides seven conflict resolution strategies. The default strategy is depth. 
 The current strategy can be set by using the set strategy command (which will reorder the agenda based upon the new strategy):
 
 <p>
@@ -472,7 +516,7 @@
 
 <h5>Salience</h5>
 
-The preferred mechanisms in g.infer for ordering the execution of rules are explicitly assigned salience values 
+The preferred mechanisms in <em>g.infer</em> for ordering the execution of rules are explicitly assigned salience values 
 and knowledge base grouping using modules. 
 Salience allows one to explicitly specify that one rule should be executed before another rule.
 <p>
@@ -519,12 +563,12 @@
 <h4>Logging and Debugging</h4>
 
 <p>
-Several features of g.infer support the development and debugging of rule-bases:
+Several features of <em>g.infer</em> support the development and debugging of rule-bases:
 <p>
-<h4>Debugging: g.infer Flags for Logging, Interaction and Abort:</h4>
+<h4>Debugging: <em>g.infer</em> Flags for Logging, Interaction and Abort:</h4>
 <ul>
 <li><b>x-Flag</b>: Stop-option: 
-The stop-option terminates g.infer following an optional invocation of a interactive CLIPS shell and before the automated inference run.
+The stop-option terminates <em>g.infer</em> following an optional invocation of a interactive CLIPS shell and before the automated inference run.
 <li><b>i-Flag</b>: Interactive CLIPS shell: 
 The launching of an CLIPS shell before the automated inference run allows to 
 query interactively all aspects of the current CLIPS session. <b>Ctrl-D</b> exits from the interactive Shell.
@@ -593,7 +637,7 @@
 </DL>
 
 <h4>Rulebase Libraries</h4>
-g.infer provides several pre-configured rulebases. 
+<em>g.infer</em> provides several pre-configured rulebases. 
 The rulebases from the library can be used alone or in combination by user-defined rulebases. 
 They provide a basic interactive user interface to launch specific demo applications and can also be started from the CLIPS prompt (using the <b>(run)</b> command). 
 All demo rulebases contain extensive comments to document their functionaility for the interested user. 
@@ -605,11 +649,11 @@
 </ul>
 
 
-<h2>Notes on g.infer pyCLIPS extensions</h2>
+<h2>Notes on <em>g.infer</em> pyCLIPS extensions</h2>
 
 
 
-g.infer extends the pyCLIPS- amd CLIPS environments with several commands to communicate and interact the GRASS GIS:
+<em>g.infer</em> extends the pyCLIPS- amd CLIPS environments with several commands to communicate and interact the GRASS GIS:
 
 <ul>
 <li><b>ginfer_printout</b>: Extends the CLIPS printout command for use in g.infer:  


Property changes on: grass-addons/grass6/general/g.infer/description.html
___________________________________________________________________
Deleted: svn:executable
   - *
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native


Property changes on: grass-addons/grass6/general/g.infer/reference.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Modified: grass-addons/grass6/general/g.infer/spearfish.py
===================================================================
--- grass-addons/grass6/general/g.infer/spearfish.py	2013-07-17 13:19:36 UTC (rev 57191)
+++ grass-addons/grass6/general/g.infer/spearfish.py	2013-07-17 13:33:10 UTC (rev 57192)
@@ -1,537 +1,537 @@
-# -*- coding: utf-8 -*-
-
-#######################################################################
-### Reference Knowledgebase with Demos for the SPEARFISH location
-#######################################################################
-
-def knowledgebase():
-#this function returns a huge here document, which is ingested by CLIPS instead or in addition to an external rulebase.
-# the string contains a rulebase containing demo rule-based actions in GRASS.
-
-	
-	payload="""
-	;(assert (attract mode))
-;attract mode sollte ein "fallback fact" werden, damit der user die KB wiederholt starten kann
-
-(defrule isspearfish (declare (salience 101)) (LOCATION_NAME spearfish60) => 
-  ;(ginfer_printout t "[Rule#1: Spearfish Location is confirmed]" crlf)
-  (assert (attract mode)))
-
-
-(defrule nospearfish (declare (salience 101)) (not (LOCATION_NAME spearfish60)) => (ginfer_printout t "PLEASE RESTART IN SPEARFISH LOCATION." crlf))
-
-(defrule welcome (declare (salience 100)) (attract mode)  (LOCATION_NAME spearfish60) => 
- (ginfer_printout t " " crlf)
- (ginfer_printout t "******************************************************" crlf)
- (ginfer_printout t "*** Welcome to the g.infer Spearfish knowledgebase ***  " crlf)
- (ginfer_printout t "******************************************************" crlf)
- (ginfer_printout t " " crlf)
- (ginfer_printout t " " crlf)
- (ginfer_printout t "Available Demonstrations:" crlf)
- (ginfer_printout t " " crlf)
- (ginfer_printout t "[1]  Overview g.infer extensions to CLIPS" crlf)
-
-
- ; something with a loop on RHS
- ; something with variables on LHS
- ; something with variables on RHS
- ; mwas auf einem monitor darstellen
- ; dummy template benutzen, dafuer regeln aufstezen, spater ein raster einlesen, auf das dummy template umkopieren, regeln feuern
- (ginfer_printout t "[2] + GRASS: module call-up demo" crlf)
- (ginfer_printout t "[3] partial GRASS: WMS for on-demand raster import / Monitor demo" crlf)
-
- (ginfer_printout t "[4] + CLIPS: CLI-based user input demo" crlf)
- (ginfer_printout t "[5] NO CLIPS time-enabled rules demo" crlf)
- (ginfer_printout t "[6] + GRASS: Raster processing demo" crlf)
- (ginfer_printout t "[7] + GRASS: Vector processing demo" crlf)
- (ginfer_printout t "[8]- GRASS location/region manipulation demo" crlf)
- (ginfer_printout t "[a] tbd CLIPS: Facts manipulation (create / modify / remove) "  crlf)
- (ginfer_printout t "[b] tbd CLIPS: LHS Variables / Pattern Matching"  crlf)
- (ginfer_printout t "[c] tbd CLIPS: RHS Variables"  crlf)
- (ginfer_printout t "[d] tbd CLIPS: RHS sided loops/if then else"  crlf)
- (ginfer_printout t "[c] tbd CLIPS: Salience"  crlf)
- (ginfer_printout t "[e] tbd GRASS: Import a given Raster Layer during Inference runtime"  crlf)
- (ginfer_printout t "[e] tbd GRASS: Change all values of a raster layer like r.mapcal-style"  crlf)
-
-(ginfer_printout t " " crlf)
- (ginfer_printout t "Please select a demo by entering its number/letter:" crlf)
- (ginfer_printout t " " crlf)
- (ginfer_printout t "Hint: this knowledgebase can be written to file using (save FILENAME) from the CLIPS prompt." crlf)
-
- (assert (demo_selection (ginfer_read t)))
- (assert (demo_selection_completed))
-)
-
-(defrule welcome_selection_01 (demo_selection_completed) (demo_selection 1) => 
- (ginfer_printout t "Selection= g.infer extensions overview" crlf)(assert (g.infer commands)))
- 
-(defrule welcome_selection_02 (demo_selection_completed) (demo_selection 2) => 
- (ginfer_printout t "Selection= GRASS modules demo" crlf)(assert (grassmodules demo)))
-
-(defrule welcome_selection_03 (demo_selection_completed) (demo_selection 3) => 
- (ginfer_printout t "Selection= Raster WMS demo" crlf)(assert (raster_wms demo)))
-
-(defrule welcome_selection_04 (demo_selection_completed) (demo_selection 4) => 
-  (ginfer_printout t "Selection= CLIPS: User input / printout demo" crlf)(assert (readline demo)))
-
-(defrule welcome_selection_05 (demo_selection_completed) (demo_selection 5) => 
-  (ginfer_printout t "Selection= CLIPS time-enabled rules demo" crlf)(assert (time demo)))
-
-(defrule welcome_selection_06 (demo_selection_completed) (demo_selection 6) => 
-  (ginfer_printout t "Selection= Raster processing demo" crlf)(assert (raster demo)))
-
-(defrule welcome_selection_07 (demo_selection_completed) (demo_selection 7) => 
-  (ginfer_printout t "Selection= Vector processing demo" crlf)(assert (vector demo)))
-
-(defrule welcome_selection_08 (demo_selection_completed) (demo_selection 8) => 
-  (ginfer_printout t "Selection= GRASS location/region demo" crlf)(assert (region demo)))
-
-(defrule welcome_selection_09 (demo_selection_completed) (demo_selection 9) => 
-  (ginfer_printout t "Selection= bootstrap loader demo" crlf)(assert (bootstrap demo)))
-
-;(defrule welcome_selection_A (demo_selection_completed) (demo_selection A) => (ginfer_printout t "Selection= Cellular automata demo" crlf)(assert (ca demo)))
-;(defrule welcome_selection_B (demo_selection_completed) (demo_selection B) => (ginfer_printout t "Selection= R.mapcalc analogue demo" crlf)(assert (rmapcalc_rules demo)))
-
-(defrule welcome_selection_09a (demo_selection_completed) (demo_selection a) => 
-  (ginfer_printout t "Selection= CLIPS Facts manipulation demo" crlf)(assert (facts_101 demo)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; G.INFER EXTENSION COMMANDS [WORKS]:
-
-(defrule extensions_001 (g.infer commands)  => 
- (ginfer_printout t "=============================================================== " crlf)
- (ginfer_printout t " " crlf)
- (ginfer_printout t "Special g.infer commands for the CLIPS command line interface: " crlf)
- (ginfer_printout t "" crlf)
- (ginfer_printout t " ==>   Invoke the commands by (python-call YOURCOMMAND) <== " crlf)
- (ginfer_printout t " " crlf)
- (ginfer_printout t "*** GENERAL: ***" crlf)
- (ginfer_printout t "* grass_run_command  " crlf)
- (ginfer_printout t "* grass_read_command  " crlf)
- (ginfer_printout t "* grass_start_command  " crlf)
- (ginfer_printout t "* ginfer_printout: CLIPS printout analog" crlf)
- (ginfer_printout t "* grass_message: Print a text message on the GRASS prompt" crlf)
- (ginfer_printout t "* grass_fatal: Print a warning message on the GRASS prompt and exit GRASS" crlf)
-(ginfer_printout t "" crlf)
-(ginfer_printout t "***  REGION / VARIABLES: ***" crlf)
-(ginfer_printout t "* assert_region  " crlf)
-(ginfer_printout t "* assert_gisenv  " crlf)
-(ginfer_printout t "* grass.mapcalc  " crlf)
-(ginfer_printout t "" crlf)
-(ginfer_printout t "*** VECTOR: ***" crlf)
-(ginfer_printout t "* assert_vector_metadata: Create fatcs from the metadata of a GRASS vector layer" crlf)
-(ginfer_printout t "* grassvector2factlayer: Import a GRASS vector layer as facts  " crlf)
-(ginfer_printout t "* grassvector2factlayer_internal  " crlf)
-(ginfer_printout t "" crlf)
-(ginfer_printout t "*** RASTER: ***" crlf)
-(ginfer_printout t "* grass_raster_info  " crlf)
-(ginfer_printout t "* grassraster2factlayer " crlf)
-(ginfer_printout t "* grassraster2factlayer_internal  " crlf)
-(ginfer_printout t "* grassvolume2factlayer  " crlf)
-(ginfer_printout t "* grassvolume2factlayer_internal  " crlf)
-(ginfer_printout t "" crlf)
-(ginfer_printout t "*** OTHER: ***" crlf)
-(ginfer_printout t "* pyprintout " crlf)
-(ginfer_printout t "* pyreadline  " crlf)
-(ginfer_printout t "* pyread  " crlf)
-(ginfer_printout t "* pyclips_load " crlf)
-(ginfer_printout t "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  " crlf)
-)
-
-
-;;;AUSSTEHEND:
-; #clips.RegisterPythonFunction(factslayer_fromraster2grassraster_internal)
-; #clips.RegisterPythonFunction(factslayer_fromraster3d2grassraster3d_internal)
-; #clips.RegisterPythonFunction(factslayer2grassvector_internal)
-; # Diese Funktionen erfordern das zentrale Speichern der EINGANGSINFORMATIONEN !
-; #clips.RegisterPythonFunction(grass.raster_info)
-; #clips.RegisterPythonFunction(LOADFACTS)
-; #clips.RegisterPythonFunction(ASSERT_RASTER_METADATA)
-; #clips.RegisterPythonFunction(DATENBANKZEUGS)
-; #clips.RegisterPythonFunction(MAPCALC)
-; #clips.RegisterPythonFunction("GRASS_LAMBDA")
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;GRASS RUN [WORKS]:
-(defrule grasscommandsdemo01 (grassmodules demo) => 
-; a very simple LHS triggers the lengthy RHS
-(python-call grass_message " ") 
-; note that other print functions like ginfer_printout (the ginfer wrapper for CLIPS printout) could also be used. grass_message is a g.infer wrapper for the GRASS g.message module 
-(python-call grass_message " ") 
-(python-call grass_message "==========================================================================") 
- (python-call grass_message "-GRASS Modules Demo ")
- (python-call grass_message "=> using the grass_run_command extension of g.infer to start GRASS modules") 
- (python-call grass_message "------------------------------------------------------------------") 
- (python-call grass_message "   Invoking: g.version -g -b") 
- (python-call grass_message " ") 
- (python-call grass_run_command "g.version" "gb" )
- ;Note how the flags for g.version are provided without the leading "minus": Proper call on the GRASS shell would be "g.version -gb" or "g.version -g -b" 
- (python-call grass_message "---------------------------") 
- (python-call grass_message "   Invoking: g.region -p") 
- (python-call grass_message " ") 
- (python-call grass_run_command "g.region" "p" )
- (python-call grass_message "---------------------------") 
- (python-call grass_message "   Invoking g.list -f type=vect") 
- (python-call grass_message " ")
- (python-call grass_run_command "g.list" "f" "type=vect")
- ;(python-call grass_message "---------------------------") 
- (python-call grass_message " ")
- (python-call grass_message "==========================================================================") 
-(python-call grass_message " ") 
-)
-
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;READLINE [WORKS]
-(defrule readline_test1 (readline demo) => 
-
- (ginfer_printout t  " " crlf) 
- (ginfer_printout t "==========================================================================" crlf) 
- (ginfer_printout t "- CLIPS: User input / printout demo " crlf)
- (ginfer_printout t "  Using ginfer_printout and ginfer_read g.infer extensions of the CLIPS commands printout and read" clrf)
- (ginfer_printout t  " " crlf) 
- (ginfer_printout  t "Type in some feedback, please:" crlf)
- (assert (userfeedback (ginfer_read t)))
- (ginfer_printout t "Thank you for your feedback." crlf)
- ; TBD: Printout the feedback
-)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;RASTER WMS Import [WORKS]
-
-;; import
-;; -- file r.in.gdal
-; r.in.wms output=akl_srtm mapserver="http://onearth.jpl.nasa.gov/wms.cgi" -c layers=worldwind_dem format=geotiff style=short_int maxcols=100 maxrows=100
-
-(defrule grassrun_rinwms (raster_wms demo) => 
- ;(python-call grass_message "** RHS: r.in.wms **")
- (ginfer_printout t  " " crlf) 
- (ginfer_printout t "==========================================================================" crlf) 
- (ginfer_printout t "- GRASS: Using a WMS to obtain a raster layer and a GRASS monitor to display it." crlf)
-  (ginfer_printout t "*** Online Access Mandatory ! ***" crlf)
- (ginfer_printout t "  This uses r.in.wms, g.remove, g.rename, d.mon and d.rast on the RHS of multiple chained rules" clrf)
- (ginfer_printout t  " " crlf) 
- (ginfer_printout t  " 1) g.region region=landuse" crlf)
- (python-call grass_run_command g.region rast=landuse)
- (ginfer_printout t  " 2) r.in.wms -c -oo output=akl_srtm mapserver=http://onearth.jpl.nasa.gov/wms.cgi  layers=worldwind_dem format=geotiff style=short_int maxcols=100 maxrows=100" crlf) 
- (python-call grass_run_command r.in.wms "c" "-o" output=akl_srtm mapserver=http://onearth.jpl.nasa.gov/wms.cgi  layers=worldwind_dem format=geotiff style=short_int maxcols=100 maxrows=100) 
- (assert (rinwms done))
- )
-
-(defrule grassrun_rinwms_remove (rinwms done) =>
-   (python-call grass_message "  3) r.in.wms remove raster2 **") 
-   (python-call grass_run_command g.remove rast=akl_srtm.2) 
-   (assert (rinwms_remove done)))
-
-(defrule grassrun_rinwms_rename (rinwms_remove done) => 
-   (python-call grass_message " 4) r.in.wms rename raster1 **") 
-   (python-call grass_run_command g.rename rast=akl_srtm.1,rhs_srtm) 
-   (ginfer_printout t " 5) Enter something to proceed:" crlf) 
-   (assert (feedback (ginfer_read t))) 
-   (assert (rinwms_rename done))
- )
-
-(defrule grassrun_rinwms_display2 (rinwms_rename done) => 
-    (python-call grass_message " 5) r.in.wms display **") 
-    (python-call grass_run_command d.mon start=x0) 
-    (python-call grass_run_command d.rast map=rhs_srtm) 
-    (assert (rinwms_display1 done))
- )
-
-(defrule grassrun_rinwms_display1 (rinwms_display1 done) => 
- (ginfer_printout t "Demo: Feedback, please:" crlf) 
- (assert (ducky1 (ginfer_read t))) 
- (assert (rinwms_display2 done))
- )
-
-(defrule grassrun_rinwms_display3 (rinwms_display2 done) => 
- (python-call grass_message "** RHS: r.in.wms display cleanup **") 
- (python-call grass_run_command d.mon stop=x0)
- (assert (rinwms_display_shutdown done))
-)
-
-(defrule grassrun_rinwms_display4 (rinwms_display_shutdown done) => 
-  (python-call grass_message "** RHS: r.in.wms purge raster **") 
-  (python-call grass_run_command g.remove rast=rhs_srtm)
-  (assert (rinwms_gremove done))
-  )
-
-; g.remove akl_srtm.2
-; g.rename rast=akl_srtm.1,rhs_strm
-; r.colors rhs_srtm
-; d.mon d.rast
-; g.erase rhs_srtm
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; CLIPS TIME [WORKS]
-; Muss noch angeschaltet werden !
-
-
-;(defrule grassrun_timetest1 (timetest) => 
-; (python-call grass_message "** RHS: TIMETEST 1 **") (bind ?early (time)) (ginfer_printout t "Before" ?early) (assert (timetest1)) (assert (timestamp ?early)))
-
-;(defrule grassrun_timetest2 (timetest1) => 
-; (python-call grass_message "** RHS: TIMETEST 2 **") (bind ?wait (time)) (ginfer_printout t "Now" ?later crlf) (assert (timetest2)))
-
-;(defrule grassrun_timetest3 (timetest2) => 
-; (python-call grass_message "** RHS: TIMETEST 3 **") (bind ?later (time)) (ginfer_printout t "Now" ?later crlf) (assert (timetest done)))
-
-(deftemplate event (slot tstamp (default-dynamic (time))) (slot value))
-; A template for the time-activated rules.
-; Each instance consists of an automatically assigned timestamp and a user-assigned value
-
-(defrule timedemo0 (time demo) => 
- (ginfer_printout t  " " crlf) 
- (ginfer_printout t "==========================================================================" crlf) 
- (ginfer_printout t "- CLIPS: Time-controlled Rule Demo" crlf)
- (ginfer_printout t "  Added value: Rules can have expiry dates and duration...." clrf)
- (ginfer_printout t  " " crlf) 
- (assert (start-time (time)))
-)
-
-(defrule time0
- (event (tstamp ?t1)(value 3))
- =>
- (ginfer_printout t "time0-rule: A value 3 event was detected. Its timestamp is=" ?t1 crlf)
- )
-
-(defrule time1
- ?foo <- (event (tstamp ?t1)(value 3))
- ?now1 <- (time)
- ;(test (> (- ?now1 ?t1) 0.01))
- ;ES MAG ES NICHT WENN AUF DER LHS SCHON GETESTET WIRD ?!
- =>
- (retract ?foo)
- (ginfer_printout t "time1-rule: Retracting" ?t1 ?now1 crlf)
- )
- 
- (defrule time4
- ?foo <- (event (tstamp ?t1)(value 3))
- (start-time ?t2)
- =>
- 
- (ginfer_printout t "time4-rule: There is Value 3 Event of time #1. Current time is #2:" ?t1 ?t2 crlf)
- )
-
-(defrule time2
- (time demo)
-  =>
- (assert (event (value 3)))
- (ginfer_printout t "time2-rule: Event of value 3 created at time=" (time) crlf)
- )
-
-(defrule time3
- ?foo <- (event (tstamp ?t1)(value 3))
- (start-time ?t2)
- ?now5 <- (time)
- ;(test (> (- ?t1 ?t2) 0.01))
- ;(test (> (- ?now5 ?t1) 0.01))
- ;ES MAG ES NICHT WENN AUF DER LHS SCHON GETESTET WIRD ?!
-
- =>
- (retract ?foo)
- (ginfer_printout t "time3-rule:  Value 3 Event has timestamp #1. Start time was #2. Now its #3 Retracting Event! " ?t1 ?t2 ?now5 crlf)
- )
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; RASTER MAPCALC [WORKS]
-
-;(assert (raster demo))
-
-(defrule grassrun_rmapcalc_random1 (raster demo) => (python-call grass_message "** RHS: r.mapcalc 1 **") (python-call grass_run_command "r.mapcalc" "rhs_mapcalc_1=rand(1,10)") (assert (mapcalc1 done)))
-
-(defrule grassrun_rmapcalc_random2 (raster demo) => (python-call grass_message "** RHS: r.mapcalc 2 **") (python-call grass_run_command "r.mapcalc" "rhs_mapcalc_2=rand(1,2)") (assert (mapcalc2 done)))
-
-; [r.surf.area] run
-
-; [r.null] run
-
-(defrule grassrun_rmapcalc1 (mapcalc1 done) (mapcalc2 done) => (python-call grass_message "** RHS: r.null **") (python-call grass_run_command r.null map=rhs_mapcalc_1 setnull=5) (assert (rnull done)))
-
-; [r.patch] run
-(defrule grassrun_rmapcalc2 (rnull done) => (python-call grass_message "** RHS: r.patch **") (python-call grass_run_command r.patch input=rhs_mapcalc_1,rhs_mapcalc_2 output=rhs_patch) (assert (rpatch done)))
-
-(defrule grassrun_rmapcalc3 (rpatch done) => (python-call grass_message "** RHS: r.stats **") (python-call grass_run_command r.stats "c" input=rhs_patch) (assert (rnull done)))
-
-
-
-;;;HIER FEHLT DIE VERKETTUNG ZU DEN FOLGENDEN RASTER-Subdemos
-
-(defrule grassrun_gremove (rnull done) => (python-call grass_message "[RASTER DEMO]** RHS: g.remove cleanup **") (python-call grass_run_command g.remove rast=rhs_patch,rhs_mapcalc_1,rhs_mapcalc_2) (assert (gremove done)))
-
-; [r.colors] run
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;
-; [r.stats] run
-;(defrule grassrun_rstats (verbose on) => (python-call grass_message "** RHS: r.stats run **") (python-call grass_run_command "r.stats" "cl" "input=geology" "fs=_"))
-
-; [r.quantile] read
-
-; [r.univar] read
-
-; [r.what] read
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;
-; [r.stats] read
-(defrule grassread_rstats (verbose on) => (python-call grass_message "** RHS: r.stats read **") (bind ?result (python-call grass_read_command "r.stats" "cl" "input=geology" "fs=_")) (ginfer_printout t "===========" crlf)(ginfer_printout t ?result) (ginfer_printout t "===========" crlf))
-
-
-;; export
-;; -- file r.out.gdal
-;; -- file r.in.gdal
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;## VECTOR
-
-;;
-;; v.in.external
-;; v.in.region
-;; v.random
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;(assert (vector demo))
-(defrule grassrun_vector1 
- (vector demo) => 
- (python-call grass_message "VECTOR DEMO:") 
- (python-call grass_message "** v.random **")  
- (python-call grass_run_command v.random output=rhs_random10 n=10) (assert (vrandom done))
-)
-
-(defrule grassrun_vector2 
-  (vrandom done) => 
-  (python-call grass_message "** v.info **") 
-  (python-call grass_run_command v.info map=rhs_random10) 
-  (assert (vinfo done)))
-
-(defrule grassrun_vector2a 
-  (vrandom done) => 
-  (python-call grass_message "** v.stats **") 
- 
-  (python-call grass_run_command v.univar -ed map=rhs_random10)
-  (assert (vunivar done)))
-
-
-(defrule grassrun_vector3 
-  (vinfo done) (vunivar done) => 
-  (python-call grass_message "** g.remove vector **") 
-  (python-call grass_run_command g.remove vect=rhs_random10) (assert (gremove_vect done)))
-
-;; create empty vector
-;; v.in.ascii 
-;;
-;; create empty vector with structure
-;;
-;; query vector
-;; v.db.select READ
-;; v.db.univar READ
-;; v.distance
-;; v.normal
-;; v.univar READ
-;;
-;; modify vector ?
-;; v.db.addtable
-;; v.db.join
-;; v.db.update
-;; v.dissolve
-;; v.generalize
-;; v.patch
-;; v.type
-;; v.extract
-;;
-;; report on vector content
-;;
-;; report on vector topology
-;;
-;; convert vector (extract topo features)
-;;
-;;;; v.to.db
-;; v.to.r3
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; R.mapcalc-like rule concatenation:
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;(assert (rmapcalc_rules demo))
-
-(defrule rmapcalc_rules_01 
-  (rmapcalc_rules demo) 
- => 
-  (python-call grass_message "[rules like r.mapcalc] rule 01: Generate random GRASS raster by using r.mapcalc") 
-  (python-call grass_run_command "r.mapcalc" "rmapcalc_rules_demo=rand(1,10)") 
-  (assert (stages_mapcalc_01 done))
-)
-;Rule to create a new GRASS raster of random values
-
-(deftemplate rmapcalc_rules_demo (slot x)(slot y)(slot value))
-;Dummy template to ensure that the rules below will be parsed.
-
-;^^^ Damit gibts die Probleme !!!
-;**************************************
-;**************************************
-;**************************************
-
-(defrule rmapcalc_rules_02 
-  (stages_mapcalc_01 done) 
- => 
-  (python-call grass_message "[rules like r.mapcalc] rule 02: Create CLIPS facts from GRASS raster layer") 
-  (python-call grassraster2factlayer "rmapcalc_rules_demo" "the_comment" True False) 
-  (assert (stages_ingest done))
-)
-;Rule import the new GRASS raster of random values into the CLIPS environment.
-
-;(defrule rmapcalc_rules_03_preparation 
-;  (stages_ingest done)
-;  (not (trigger ?x ?y))
-;  (not (completed ?x ?y))
-;  (rmapcalc_rules_demo (x ?x) (y ?y) (value ?value)) 
-;  ; DAS TEMPLATE wird erst angelegt wenn der GRASSRASTER_FACTLAYER eingeladen wird. Das ist nachdem diese Regel eingelesen wird.
-;  ;Ein Mechanismus wird gebraucht um das generisch zu loesen -> Anlegen des Template explizit hier im Skript....
-; => 
-;  (python-call grass_message "[rules like r.mapcalc] rule 03: Generate Flag-facts for raster facts")
-;  (assert (trigger ?x ?y))
-;)
-;; Rule to ensure that while for all facts created from the random raster layer there are (yet) no additional facs ("trigger"/"completed") sharing the same xy coordinate. While this applies (for all newly created raster-facts), an additional "trigger" fact is created for each coordinate tuple.
-
-;(defrule rmapcalc_rules_04_execution 
-;  ?thiscell <- (rmapcalc_rules_demo (x ?x) (y ?y) (value ?value)) 
-;  ?thistrigger <- (trigger ?x ?y) (not (completed ?x ?y)) 
-; => 
-;  (python-call grass_message "[rules like r.mapcalc] rule 04: Increase each raster facts by 1000000; flag as done")
-;  (modify ?thiscell (value (+ 100000 ?value))) 
-;  (retract ?thistrigger) 
-;  (assert (completed ?x ?y)))
-
-;;;^^^ IF (aka: FOR ANY) there's a coordinate/location where there's a raster-layer-fact and a "trigger"-fact but no "completed"-fact, increase/MODIFY the attribute of the raster fact, remove the "trigger" fact and set a "completed" fact.
-
-(undeftemplate rmapcalc_rules_demo)
-
-; bzw: zwei verfahrenswege: 
-; 1) einlesen, multiplikation * 10 im CLIPS space, export
-; 2) zweiter RHS-rmapcalc aufruf zur multiplikation
-; Zeiten vergleichen
-; -> wenn Mapcalc versagt kann option 1) greifen !
-
-
-
-	"""
-	return payload
-
+# -*- coding: utf-8 -*-
+
+#######################################################################
+### Reference Knowledgebase with Demos for the SPEARFISH location
+#######################################################################
+
+def knowledgebase():
+#this function returns a huge here document, which is ingested by CLIPS instead or in addition to an external rulebase.
+# the string contains a rulebase containing demo rule-based actions in GRASS.
+
+	
+	payload="""
+	;(assert (attract mode))
+;attract mode sollte ein "fallback fact" werden, damit der user die KB wiederholt starten kann
+
+(defrule isspearfish (declare (salience 101)) (LOCATION_NAME spearfish60) => 
+  ;(ginfer_printout t "[Rule#1: Spearfish Location is confirmed]" crlf)
+  (assert (attract mode)))
+
+
+(defrule nospearfish (declare (salience 101)) (not (LOCATION_NAME spearfish60)) => (ginfer_printout t "PLEASE RESTART IN SPEARFISH LOCATION." crlf))
+
+(defrule welcome (declare (salience 100)) (attract mode)  (LOCATION_NAME spearfish60) => 
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t "******************************************************" crlf)
+ (ginfer_printout t "*** Welcome to the g.infer Spearfish knowledgebase ***  " crlf)
+ (ginfer_printout t "******************************************************" crlf)
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t "Available Demonstrations:" crlf)
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t "[1]  Overview g.infer extensions to CLIPS" crlf)
+
+
+ ; something with a loop on RHS
+ ; something with variables on LHS
+ ; something with variables on RHS
+ ; mwas auf einem monitor darstellen
+ ; dummy template benutzen, dafuer regeln aufstezen, spater ein raster einlesen, auf das dummy template umkopieren, regeln feuern
+ (ginfer_printout t "[2] + GRASS: module call-up demo" crlf)
+ (ginfer_printout t "[3] partial GRASS: WMS for on-demand raster import / Monitor demo" crlf)
+
+ (ginfer_printout t "[4] + CLIPS: CLI-based user input demo" crlf)
+ (ginfer_printout t "[5] NO CLIPS time-enabled rules demo" crlf)
+ (ginfer_printout t "[6] + GRASS: Raster processing demo" crlf)
+ (ginfer_printout t "[7] + GRASS: Vector processing demo" crlf)
+ (ginfer_printout t "[8]- GRASS location/region manipulation demo" crlf)
+ (ginfer_printout t "[a] tbd CLIPS: Facts manipulation (create / modify / remove) "  crlf)
+ (ginfer_printout t "[b] tbd CLIPS: LHS Variables / Pattern Matching"  crlf)
+ (ginfer_printout t "[c] tbd CLIPS: RHS Variables"  crlf)
+ (ginfer_printout t "[d] tbd CLIPS: RHS sided loops/if then else"  crlf)
+ (ginfer_printout t "[c] tbd CLIPS: Salience"  crlf)
+ (ginfer_printout t "[e] tbd GRASS: Import a given Raster Layer during Inference runtime"  crlf)
+ (ginfer_printout t "[e] tbd GRASS: Change all values of a raster layer like r.mapcal-style"  crlf)
+
+(ginfer_printout t " " crlf)
+ (ginfer_printout t "Please select a demo by entering its number/letter:" crlf)
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t "Hint: this knowledgebase can be written to file using (save FILENAME) from the CLIPS prompt." crlf)
+
+ (assert (demo_selection (ginfer_read t)))
+ (assert (demo_selection_completed))
+)
+
+(defrule welcome_selection_01 (demo_selection_completed) (demo_selection 1) => 
+ (ginfer_printout t "Selection= g.infer extensions overview" crlf)(assert (g.infer commands)))
+ 
+(defrule welcome_selection_02 (demo_selection_completed) (demo_selection 2) => 
+ (ginfer_printout t "Selection= GRASS modules demo" crlf)(assert (grassmodules demo)))
+
+(defrule welcome_selection_03 (demo_selection_completed) (demo_selection 3) => 
+ (ginfer_printout t "Selection= Raster WMS demo" crlf)(assert (raster_wms demo)))
+
+(defrule welcome_selection_04 (demo_selection_completed) (demo_selection 4) => 
+  (ginfer_printout t "Selection= CLIPS: User input / printout demo" crlf)(assert (readline demo)))
+
+(defrule welcome_selection_05 (demo_selection_completed) (demo_selection 5) => 
+  (ginfer_printout t "Selection= CLIPS time-enabled rules demo" crlf)(assert (time demo)))
+
+(defrule welcome_selection_06 (demo_selection_completed) (demo_selection 6) => 
+  (ginfer_printout t "Selection= Raster processing demo" crlf)(assert (raster demo)))
+
+(defrule welcome_selection_07 (demo_selection_completed) (demo_selection 7) => 
+  (ginfer_printout t "Selection= Vector processing demo" crlf)(assert (vector demo)))
+
+(defrule welcome_selection_08 (demo_selection_completed) (demo_selection 8) => 
+  (ginfer_printout t "Selection= GRASS location/region demo" crlf)(assert (region demo)))
+
+(defrule welcome_selection_09 (demo_selection_completed) (demo_selection 9) => 
+  (ginfer_printout t "Selection= bootstrap loader demo" crlf)(assert (bootstrap demo)))
+
+;(defrule welcome_selection_A (demo_selection_completed) (demo_selection A) => (ginfer_printout t "Selection= Cellular automata demo" crlf)(assert (ca demo)))
+;(defrule welcome_selection_B (demo_selection_completed) (demo_selection B) => (ginfer_printout t "Selection= R.mapcalc analogue demo" crlf)(assert (rmapcalc_rules demo)))
+
+(defrule welcome_selection_09a (demo_selection_completed) (demo_selection a) => 
+  (ginfer_printout t "Selection= CLIPS Facts manipulation demo" crlf)(assert (facts_101 demo)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; G.INFER EXTENSION COMMANDS [WORKS]:
+
+(defrule extensions_001 (g.infer commands)  => 
+ (ginfer_printout t "=============================================================== " crlf)
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t "Special g.infer commands for the CLIPS command line interface: " crlf)
+ (ginfer_printout t "" crlf)
+ (ginfer_printout t " ==>   Invoke the commands by (python-call YOURCOMMAND) <== " crlf)
+ (ginfer_printout t " " crlf)
+ (ginfer_printout t "*** GENERAL: ***" crlf)
+ (ginfer_printout t "* grass_run_command  " crlf)
+ (ginfer_printout t "* grass_read_command  " crlf)
+ (ginfer_printout t "* grass_start_command  " crlf)
+ (ginfer_printout t "* ginfer_printout: CLIPS printout analog" crlf)
+ (ginfer_printout t "* grass_message: Print a text message on the GRASS prompt" crlf)
+ (ginfer_printout t "* grass_fatal: Print a warning message on the GRASS prompt and exit GRASS" crlf)
+(ginfer_printout t "" crlf)
+(ginfer_printout t "***  REGION / VARIABLES: ***" crlf)
+(ginfer_printout t "* assert_region  " crlf)
+(ginfer_printout t "* assert_gisenv  " crlf)
+(ginfer_printout t "* grass.mapcalc  " crlf)
+(ginfer_printout t "" crlf)
+(ginfer_printout t "*** VECTOR: ***" crlf)
+(ginfer_printout t "* assert_vector_metadata: Create fatcs from the metadata of a GRASS vector layer" crlf)
+(ginfer_printout t "* grassvector2factlayer: Import a GRASS vector layer as facts  " crlf)
+(ginfer_printout t "* grassvector2factlayer_internal  " crlf)
+(ginfer_printout t "" crlf)
+(ginfer_printout t "*** RASTER: ***" crlf)
+(ginfer_printout t "* grass_raster_info  " crlf)
+(ginfer_printout t "* grassraster2factlayer " crlf)
+(ginfer_printout t "* grassraster2factlayer_internal  " crlf)
+(ginfer_printout t "* grassvolume2factlayer  " crlf)
+(ginfer_printout t "* grassvolume2factlayer_internal  " crlf)
+(ginfer_printout t "" crlf)
+(ginfer_printout t "*** OTHER: ***" crlf)
+(ginfer_printout t "* pyprintout " crlf)
+(ginfer_printout t "* pyreadline  " crlf)
+(ginfer_printout t "* pyread  " crlf)
+(ginfer_printout t "* pyclips_load " crlf)
+(ginfer_printout t "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  " crlf)
+)
+
+
+;;;AUSSTEHEND:
+; #clips.RegisterPythonFunction(factslayer_fromraster2grassraster_internal)
+; #clips.RegisterPythonFunction(factslayer_fromraster3d2grassraster3d_internal)
+; #clips.RegisterPythonFunction(factslayer2grassvector_internal)
+; # Diese Funktionen erfordern das zentrale Speichern der EINGANGSINFORMATIONEN !
+; #clips.RegisterPythonFunction(grass.raster_info)
+; #clips.RegisterPythonFunction(LOADFACTS)
+; #clips.RegisterPythonFunction(ASSERT_RASTER_METADATA)
+; #clips.RegisterPythonFunction(DATENBANKZEUGS)
+; #clips.RegisterPythonFunction(MAPCALC)
+; #clips.RegisterPythonFunction("GRASS_LAMBDA")
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;GRASS RUN [WORKS]:
+(defrule grasscommandsdemo01 (grassmodules demo) => 
+; a very simple LHS triggers the lengthy RHS
+(python-call grass_message " ") 
+; note that other print functions like ginfer_printout (the ginfer wrapper for CLIPS printout) could also be used. grass_message is a g.infer wrapper for the GRASS g.message module 
+(python-call grass_message " ") 
+(python-call grass_message "==========================================================================") 
+ (python-call grass_message "-GRASS Modules Demo ")
+ (python-call grass_message "=> using the grass_run_command extension of g.infer to start GRASS modules") 
+ (python-call grass_message "------------------------------------------------------------------") 
+ (python-call grass_message "   Invoking: g.version -g -b") 
+ (python-call grass_message " ") 
+ (python-call grass_run_command "g.version" "gb" )
+ ;Note how the flags for g.version are provided without the leading "minus": Proper call on the GRASS shell would be "g.version -gb" or "g.version -g -b" 
+ (python-call grass_message "---------------------------") 
+ (python-call grass_message "   Invoking: g.region -p") 
+ (python-call grass_message " ") 
+ (python-call grass_run_command "g.region" "p" )
+ (python-call grass_message "---------------------------") 
+ (python-call grass_message "   Invoking g.list -f type=vect") 
+ (python-call grass_message " ")
+ (python-call grass_run_command "g.list" "f" "type=vect")
+ ;(python-call grass_message "---------------------------") 
+ (python-call grass_message " ")
+ (python-call grass_message "==========================================================================") 
+(python-call grass_message " ") 
+)
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;READLINE [WORKS]
+(defrule readline_test1 (readline demo) => 
+
+ (ginfer_printout t  " " crlf) 
+ (ginfer_printout t "==========================================================================" crlf) 
+ (ginfer_printout t "- CLIPS: User input / printout demo " crlf)
+ (ginfer_printout t "  Using ginfer_printout and ginfer_read g.infer extensions of the CLIPS commands printout and read" clrf)
+ (ginfer_printout t  " " crlf) 
+ (ginfer_printout  t "Type in some feedback, please:" crlf)
+ (assert (userfeedback (ginfer_read t)))
+ (ginfer_printout t "Thank you for your feedback." crlf)
+ ; TBD: Printout the feedback
+)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;RASTER WMS Import [WORKS]
+
+;; import
+;; -- file r.in.gdal
+; r.in.wms output=akl_srtm mapserver="http://onearth.jpl.nasa.gov/wms.cgi" -c layers=worldwind_dem format=geotiff style=short_int maxcols=100 maxrows=100
+
+(defrule grassrun_rinwms (raster_wms demo) => 
+ ;(python-call grass_message "** RHS: r.in.wms **")
+ (ginfer_printout t  " " crlf) 
+ (ginfer_printout t "==========================================================================" crlf) 
+ (ginfer_printout t "- GRASS: Using a WMS to obtain a raster layer and a GRASS monitor to display it." crlf)
+  (ginfer_printout t "*** Online Access Mandatory ! ***" crlf)
+ (ginfer_printout t "  This uses r.in.wms, g.remove, g.rename, d.mon and d.rast on the RHS of multiple chained rules" clrf)
+ (ginfer_printout t  " " crlf) 
+ (ginfer_printout t  " 1) g.region region=landuse" crlf)
+ (python-call grass_run_command g.region rast=landuse)
+ (ginfer_printout t  " 2) r.in.wms -c -oo output=akl_srtm mapserver=http://onearth.jpl.nasa.gov/wms.cgi  layers=worldwind_dem format=geotiff style=short_int maxcols=100 maxrows=100" crlf) 
+ (python-call grass_run_command r.in.wms "c" "-o" output=akl_srtm mapserver=http://onearth.jpl.nasa.gov/wms.cgi  layers=worldwind_dem format=geotiff style=short_int maxcols=100 maxrows=100) 
+ (assert (rinwms done))
+ )
+
+(defrule grassrun_rinwms_remove (rinwms done) =>
+   (python-call grass_message "  3) r.in.wms remove raster2 **") 
+   (python-call grass_run_command g.remove rast=akl_srtm.2) 
+   (assert (rinwms_remove done)))
+
+(defrule grassrun_rinwms_rename (rinwms_remove done) => 
+   (python-call grass_message " 4) r.in.wms rename raster1 **") 
+   (python-call grass_run_command g.rename rast=akl_srtm.1,rhs_srtm) 
+   (ginfer_printout t " 5) Enter something to proceed:" crlf) 
+   (assert (feedback (ginfer_read t))) 
+   (assert (rinwms_rename done))
+ )
+
+(defrule grassrun_rinwms_display2 (rinwms_rename done) => 
+    (python-call grass_message " 5) r.in.wms display **") 
+    (python-call grass_run_command d.mon start=x0) 
+    (python-call grass_run_command d.rast map=rhs_srtm) 
+    (assert (rinwms_display1 done))
+ )
+
+(defrule grassrun_rinwms_display1 (rinwms_display1 done) => 
+ (ginfer_printout t "Demo: Feedback, please:" crlf) 
+ (assert (ducky1 (ginfer_read t))) 
+ (assert (rinwms_display2 done))
+ )
+
+(defrule grassrun_rinwms_display3 (rinwms_display2 done) => 
+ (python-call grass_message "** RHS: r.in.wms display cleanup **") 
+ (python-call grass_run_command d.mon stop=x0)
+ (assert (rinwms_display_shutdown done))
+)
+
+(defrule grassrun_rinwms_display4 (rinwms_display_shutdown done) => 
+  (python-call grass_message "** RHS: r.in.wms purge raster **") 
+  (python-call grass_run_command g.remove rast=rhs_srtm)
+  (assert (rinwms_gremove done))
+  )
+
+; g.remove akl_srtm.2
+; g.rename rast=akl_srtm.1,rhs_strm
+; r.colors rhs_srtm
+; d.mon d.rast
+; g.erase rhs_srtm
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; CLIPS TIME [WORKS]
+; Muss noch angeschaltet werden !
+
+
+;(defrule grassrun_timetest1 (timetest) => 
+; (python-call grass_message "** RHS: TIMETEST 1 **") (bind ?early (time)) (ginfer_printout t "Before" ?early) (assert (timetest1)) (assert (timestamp ?early)))
+
+;(defrule grassrun_timetest2 (timetest1) => 
+; (python-call grass_message "** RHS: TIMETEST 2 **") (bind ?wait (time)) (ginfer_printout t "Now" ?later crlf) (assert (timetest2)))
+
+;(defrule grassrun_timetest3 (timetest2) => 
+; (python-call grass_message "** RHS: TIMETEST 3 **") (bind ?later (time)) (ginfer_printout t "Now" ?later crlf) (assert (timetest done)))
+
+(deftemplate event (slot tstamp (default-dynamic (time))) (slot value))
+; A template for the time-activated rules.
+; Each instance consists of an automatically assigned timestamp and a user-assigned value
+
+(defrule timedemo0 (time demo) => 
+ (ginfer_printout t  " " crlf) 
+ (ginfer_printout t "==========================================================================" crlf) 
+ (ginfer_printout t "- CLIPS: Time-controlled Rule Demo" crlf)
+ (ginfer_printout t "  Added value: Rules can have expiry dates and duration...." clrf)
+ (ginfer_printout t  " " crlf) 
+ (assert (start-time (time)))
+)
+
+(defrule time0
+ (event (tstamp ?t1)(value 3))
+ =>
+ (ginfer_printout t "time0-rule: A value 3 event was detected. Its timestamp is=" ?t1 crlf)
+ )
+
+(defrule time1
+ ?foo <- (event (tstamp ?t1)(value 3))
+ ?now1 <- (time)
+ ;(test (> (- ?now1 ?t1) 0.01))
+ ;ES MAG ES NICHT WENN AUF DER LHS SCHON GETESTET WIRD ?!
+ =>
+ (retract ?foo)
+ (ginfer_printout t "time1-rule: Retracting" ?t1 ?now1 crlf)
+ )
+ 
+ (defrule time4
+ ?foo <- (event (tstamp ?t1)(value 3))
+ (start-time ?t2)
+ =>
+ 
+ (ginfer_printout t "time4-rule: There is Value 3 Event of time #1. Current time is #2:" ?t1 ?t2 crlf)
+ )
+
+(defrule time2
+ (time demo)
+  =>
+ (assert (event (value 3)))
+ (ginfer_printout t "time2-rule: Event of value 3 created at time=" (time) crlf)
+ )
+
+(defrule time3
+ ?foo <- (event (tstamp ?t1)(value 3))
+ (start-time ?t2)
+ ?now5 <- (time)
+ ;(test (> (- ?t1 ?t2) 0.01))
+ ;(test (> (- ?now5 ?t1) 0.01))
+ ;ES MAG ES NICHT WENN AUF DER LHS SCHON GETESTET WIRD ?!
+
+ =>
+ (retract ?foo)
+ (ginfer_printout t "time3-rule:  Value 3 Event has timestamp #1. Start time was #2. Now its #3 Retracting Event! " ?t1 ?t2 ?now5 crlf)
+ )
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; RASTER MAPCALC [WORKS]
+
+;(assert (raster demo))
+
+(defrule grassrun_rmapcalc_random1 (raster demo) => (python-call grass_message "** RHS: r.mapcalc 1 **") (python-call grass_run_command "r.mapcalc" "rhs_mapcalc_1=rand(1,10)") (assert (mapcalc1 done)))
+
+(defrule grassrun_rmapcalc_random2 (raster demo) => (python-call grass_message "** RHS: r.mapcalc 2 **") (python-call grass_run_command "r.mapcalc" "rhs_mapcalc_2=rand(1,2)") (assert (mapcalc2 done)))
+
+; [r.surf.area] run
+
+; [r.null] run
+
+(defrule grassrun_rmapcalc1 (mapcalc1 done) (mapcalc2 done) => (python-call grass_message "** RHS: r.null **") (python-call grass_run_command r.null map=rhs_mapcalc_1 setnull=5) (assert (rnull done)))
+
+; [r.patch] run
+(defrule grassrun_rmapcalc2 (rnull done) => (python-call grass_message "** RHS: r.patch **") (python-call grass_run_command r.patch input=rhs_mapcalc_1,rhs_mapcalc_2 output=rhs_patch) (assert (rpatch done)))
+
+(defrule grassrun_rmapcalc3 (rpatch done) => (python-call grass_message "** RHS: r.stats **") (python-call grass_run_command r.stats "c" input=rhs_patch) (assert (rnull done)))
+
+
+
+;;;HIER FEHLT DIE VERKETTUNG ZU DEN FOLGENDEN RASTER-Subdemos
+
+(defrule grassrun_gremove (rnull done) => (python-call grass_message "[RASTER DEMO]** RHS: g.remove cleanup **") (python-call grass_run_command g.remove rast=rhs_patch,rhs_mapcalc_1,rhs_mapcalc_2) (assert (gremove done)))
+
+; [r.colors] run
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;
+; [r.stats] run
+;(defrule grassrun_rstats (verbose on) => (python-call grass_message "** RHS: r.stats run **") (python-call grass_run_command "r.stats" "cl" "input=geology" "fs=_"))
+
+; [r.quantile] read
+
+; [r.univar] read
+
+; [r.what] read
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;
+; [r.stats] read
+(defrule grassread_rstats (verbose on) => (python-call grass_message "** RHS: r.stats read **") (bind ?result (python-call grass_read_command "r.stats" "cl" "input=geology" "fs=_")) (ginfer_printout t "===========" crlf)(ginfer_printout t ?result) (ginfer_printout t "===========" crlf))
+
+
+;; export
+;; -- file r.out.gdal
+;; -- file r.in.gdal
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;## VECTOR
+
+;;
+;; v.in.external
+;; v.in.region
+;; v.random
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;(assert (vector demo))
+(defrule grassrun_vector1 
+ (vector demo) => 
+ (python-call grass_message "VECTOR DEMO:") 
+ (python-call grass_message "** v.random **")  
+ (python-call grass_run_command v.random output=rhs_random10 n=10) (assert (vrandom done))
+)
+
+(defrule grassrun_vector2 
+  (vrandom done) => 
+  (python-call grass_message "** v.info **") 
+  (python-call grass_run_command v.info map=rhs_random10) 
+  (assert (vinfo done)))
+
+(defrule grassrun_vector2a 
+  (vrandom done) => 
+  (python-call grass_message "** v.stats **") 
+ 
+  (python-call grass_run_command v.univar -ed map=rhs_random10)
+  (assert (vunivar done)))
+
+
+(defrule grassrun_vector3 
+  (vinfo done) (vunivar done) => 
+  (python-call grass_message "** g.remove vector **") 
+  (python-call grass_run_command g.remove vect=rhs_random10) (assert (gremove_vect done)))
+
+;; create empty vector
+;; v.in.ascii 
+;;
+;; create empty vector with structure
+;;
+;; query vector
+;; v.db.select READ
+;; v.db.univar READ
+;; v.distance
+;; v.normal
+;; v.univar READ
+;;
+;; modify vector ?
+;; v.db.addtable
+;; v.db.join
+;; v.db.update
+;; v.dissolve
+;; v.generalize
+;; v.patch
+;; v.type
+;; v.extract
+;;
+;; report on vector content
+;;
+;; report on vector topology
+;;
+;; convert vector (extract topo features)
+;;
+;;;; v.to.db
+;; v.to.r3
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; R.mapcalc-like rule concatenation:
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;(assert (rmapcalc_rules demo))
+
+(defrule rmapcalc_rules_01 
+  (rmapcalc_rules demo) 
+ => 
+  (python-call grass_message "[rules like r.mapcalc] rule 01: Generate random GRASS raster by using r.mapcalc") 
+  (python-call grass_run_command "r.mapcalc" "rmapcalc_rules_demo=rand(1,10)") 
+  (assert (stages_mapcalc_01 done))
+)
+;Rule to create a new GRASS raster of random values
+
+(deftemplate rmapcalc_rules_demo (slot x)(slot y)(slot value))
+;Dummy template to ensure that the rules below will be parsed.
+
+;^^^ Damit gibts die Probleme !!!
+;**************************************
+;**************************************
+;**************************************
+
+(defrule rmapcalc_rules_02 
+  (stages_mapcalc_01 done) 
+ => 
+  (python-call grass_message "[rules like r.mapcalc] rule 02: Create CLIPS facts from GRASS raster layer") 
+  (python-call grassraster2factlayer "rmapcalc_rules_demo" "the_comment" True False) 
+  (assert (stages_ingest done))
+)
+;Rule import the new GRASS raster of random values into the CLIPS environment.
+
+;(defrule rmapcalc_rules_03_preparation 
+;  (stages_ingest done)
+;  (not (trigger ?x ?y))
+;  (not (completed ?x ?y))
+;  (rmapcalc_rules_demo (x ?x) (y ?y) (value ?value)) 
+;  ; DAS TEMPLATE wird erst angelegt wenn der GRASSRASTER_FACTLAYER eingeladen wird. Das ist nachdem diese Regel eingelesen wird.
+;  ;Ein Mechanismus wird gebraucht um das generisch zu loesen -> Anlegen des Template explizit hier im Skript....
+; => 
+;  (python-call grass_message "[rules like r.mapcalc] rule 03: Generate Flag-facts for raster facts")
+;  (assert (trigger ?x ?y))
+;)
+;; Rule to ensure that while for all facts created from the random raster layer there are (yet) no additional facs ("trigger"/"completed") sharing the same xy coordinate. While this applies (for all newly created raster-facts), an additional "trigger" fact is created for each coordinate tuple.
+
+;(defrule rmapcalc_rules_04_execution 
+;  ?thiscell <- (rmapcalc_rules_demo (x ?x) (y ?y) (value ?value)) 
+;  ?thistrigger <- (trigger ?x ?y) (not (completed ?x ?y)) 
+; => 
+;  (python-call grass_message "[rules like r.mapcalc] rule 04: Increase each raster facts by 1000000; flag as done")
+;  (modify ?thiscell (value (+ 100000 ?value))) 
+;  (retract ?thistrigger) 
+;  (assert (completed ?x ?y)))
+
+;;;^^^ IF (aka: FOR ANY) there's a coordinate/location where there's a raster-layer-fact and a "trigger"-fact but no "completed"-fact, increase/MODIFY the attribute of the raster fact, remove the "trigger" fact and set a "completed" fact.
+
+(undeftemplate rmapcalc_rules_demo)
+
+; bzw: zwei verfahrenswege: 
+; 1) einlesen, multiplikation * 10 im CLIPS space, export
+; 2) zweiter RHS-rmapcalc aufruf zur multiplikation
+; Zeiten vergleichen
+; -> wenn Mapcalc versagt kann option 1) greifen !
+
+
+
+	"""
+	return payload
+


Property changes on: grass-addons/grass6/general/g.infer/spearfish.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list