Personal tools
You are here: Home Documentation References Include

5. Include

Document Actions
Up one level
Defines a file to be included in the mapfile parsing.

When this directive is encountered parsing switches to the included file immediately. As a result the included file can be comprised of any valid mapfile syntax. For example:

INCLUDE 'myLayer.map'

Performance does not seem to be seriously impacted with limited use, however in high performance instances you may want to use includes in a pre-processing step to build a production mapfile. The C pre-processor can also be used (albeit with a differnt syntax) and is far more powerful.

Notes

  • Supported in versions 4.10 and higher.

  • The name of the file to be included MUST be quoted (single or double quotes).

  • Includes may be nested, up to 5 deep.

  • File location can be given as a full path to the file, or (in MapServer >= 4.10.1) as a path relative to the mapfile.

  • Debugging can be problematic since: 1) the file an error occurs in does not get output to the user and 2) the line number counter is not reset for each file. Here is one possible error that is thrown when the include file cannot be found:

    msyylex(): Unable to access file. Error opening included file "parks_include.map"
    

Example

MAP
 NAME 'include'
 EXTENT 0 0 500 500
 SIZE 250 250

 INCLUDE "test_include_symbols.map"
 INCLUDE "test_include_layer.map"
END

where test_include_symbols.map contains:

SYMBOL
   NAME 'square'
   TYPE VECTOR
   FILLED TRUE
   POINTS 0 0 0 1 1 1 1 0 0 0 END
END

and test_include_layer.map contains:

LAYER
  TYPE POINT
  STATUS DEFAULT
  FEATURE
    POINTS 10 10 40 20 300 300 400 10 10 400 END
  END
  CLASS
    NAME 'Church'
    COLOR 0 0 0
    SYMBOL 'square'
    SIZE 7
    STYLE
      SYMBOL "square"
      SIZE 5
      COLOR 255 255 255
    END
    STYLE
      SYMBOL "square"
      SIZE 3
      COLOR 0 0 255
    END
  END
END
by Stephen Lime last modified 2007-03-09 13:16

include on ubuntu/debian

Posted by Till Adams at 2006-10-10 01:52
I tried this on a debian 3.1 and on ubuntu depper drake and it only worked when using FULL PATHES for the include files - also on windows. In the moment I don't have access to any other Linux based OS, so I'm not sure whether this is only debian/ubuntu specific

include on ubuntu/debian

Posted by Stephen Lime at 2006-10-10 12:59
The documentation was wrong, and has just been updated. Files must be given as full path in most cases (depends where the script lives relative to the location of the mapfile). I'll work on fixing this for a 4.10.1 release.

Steve

INCLUDE on Windows

Posted by Javier Sámchez at 2006-10-31 04:34
Since the actual version is 4.10.0... How can I use 'INCLUDE'?
My MAP file is under "f:/ms4w/apps/prjname" and the file to include in "f:/ms4w/apps/prjname/common".
For example, I tried:
INCLUDE "/prjname/common/file.ext"
INCLUDE "./common/file.ext"
INCLUDE "/apps/prjname/common/file.ext"
And many more... And always error: "Premature end of script headers"

Help!!!!!

Full Path

Posted by Markus Weißmann at 2007-01-12 03:44
Read the notice number 4
(File location must be given as a full path to the file. Relative path definition is coming.)

'INCLUDE' from PHP/Mapscript

Posted by Andreina Mendez at 2007-02-07 07:56
Hello, I could use 'INCLUDE' in my mapfile directly, but I don't know how can I make the same thing in code from PHP/Mapscript 4.10. I want to include the 'INCLUDE' in the mapfile using PHP/Mapscript.

In this moment I'm using this: $map->save('mapFileTemp.map'), this create a only one mapfile and I want to create multiple mapfiles included in an one mapfile.

Help me!!! Thank

P.D: I'm using PHP version 5.2.0 (MS4W 2.2), MapServer 4.10.0

Powered by Plone