Ticket #279 (closed enhancement: fixed)

Opened 10 years ago

Last modified 6 years ago

include directive

Reported by: rich@… Owned by: sdlime
Priority: normal Milestone:
Component: MapServer CGI Version: 4.10
Severity: minor Keywords:
Cc: mapserver@…, uli@…, bill@…

Description

An include directive would be a nice addition to the map file. It would make it 
easier to reuse layer definitions, etc.

Thanks for considering this suggestion,
Rich

Change History

Changed 8 years ago by uli@…

  • cc uli@… added

Changed 8 years ago by uli@…

  • cc bill@… added

Changed 7 years ago by sdlime

  • status changed from new to assigned
  • version changed from 3.6 to 4.10
Geez, wait around long enough and it just might happen (what's 3 years). I
committed a new addition to the lexer tonite that supports this capability.

  e.g. INCLUDE "filename"

Needs comprehensive testing but seems to work ok in what limited tests I've
done. I'll continue to track the development here.

Steve

Changed 7 years ago by sdlime

Here's the e-mail I sent to mapserver-dev about the change...

Hi all: I sat down and actually read the Flex manual last night and discovered a
simple ability to support INCLUDEd files. It's implemented within the lexer so
doesn't impact any of the C source. Only a basic implementation is in place but
it seems to work nicely, so now you can do stuff like:

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

I think this could be extended to non-filebased sources but this'll do for now.
Some caveats:

 - the filename must be double qouted for the moment
 - I'm sure there will be some pathing issues
 - I'm not sure everything (especially file handles) is being cleaned up
properly yet
 - includes are never written when the mapObj is written to disk (I don't think
it's necessary or even possible to do so)

Anyway, it was simple to add and will be simple to back out if necessary.
Figured it was worth testing since it is backwards compatible.

Steve

Changed 7 years ago by dmorissette

  • cc dmorissette@… added

Changed 7 years ago by mapserver@…

  • cc mapserver@… added

Changed 6 years ago by sdlime

  • status changed from assigned to closed
  • resolution set to fixed
Marking as fixed and will tackle errors under new bugs...

Steve
Note: See TracTickets for help on using tickets.