Skip to content
Thomas Bonfort edited this page Apr 6, 2012 · 2 revisions

This page should provide information about generating DXF output from mapserver

If you have any questions or suggestions, contact the author (Attila Csipa).

== What DXF ? ==

DXF is a drawing exchange format. It is mainly used in trasferring vector data between different programs.

== What does this module do ? ==

It generates a DXF file with the same content as a gif or png file would have, only in vector format. Note that this is an export only filter - it does not allow you to use DXF datasets.

== Installing ==

  1. Get the source from CVS and compile it.
  2. Change .MAP file
  3. Change your script to generate two maps
  4. Change HTML code to include the DXF file

== Changing .MAP file ==

First, be sure to make a copy of your existing, working .MAP file. We'll need it later. Just add the following:

 OUTPUTFORMAT                                                                                                                                                                                                                                                                                                                                                                                                                  
    NAME imagemap                                                                                                                                                                                                                                                                                                                                                                                                              
    MIMETYPE "text/plain"                                                                                                                                                                                                                                                                                                                                                                                                      
    DRIVER imagemap                                                                                                                                                                                                                                                                                                                                                                                                            
    EXTENSION dxf                                                                                                                                                                                                                                                                                                                                                                                                              
    FORMATOPTION DXF=ON                                                                                                                                                                                                                                                                                                                                                                                                        
 END                                                                                                                                                                                                                                                                                                                                                                                                                           

DXF output is generated using the !ImageMap outputformat driver.

== Generating two maps ==

The trick is that you have to generate TWO maps. The first map will be your regular .map file, which will generate the image as it was earlier, but you have to generate an additional map, which will contain the dxf. It is essential that the two map files are identical except for the outputformat part. Also, if you intend to manipulate your map from a script, do it for both maps or strange sideeffects may appear.

== How to load two maps in PHPMapScript ==

 $map_path = "/var/www/mappath/";                                                                                                                                                                                                                                                                                                                                                                                              
 $map_file = "regular.map";                                                                                                                                                                                                                                                                                                                                                                                                    
 $map_file2 = "imagemap.map";                                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                               
 $map = ms_newMapObj?($map_path.$map_file);                                                                                                                                                                                                                                                                                                                                                                                    
 $map2 = ms_newMapObj?($map_path.$map_file2);                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                               
 ...                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                               
 $image = $map->draw();                                                                                                                                                                                                                                                                                                                                                                                                        
 $image_url = $image->saveWebImage(MS_PNG,1,1,0);                                                                                                                                                                                                                                                                                                                                                                              
 $image2 = $map2->draw();                                                                                                                                                                                                                                                                                                                                                                                                      
 $imagemap_url=$image2->saveWebImage(MS_IMAGEMAP,1,1,0);                                                                                                                                                                                                                                                                                                                                                                       

This will generate two temp files - one holding an image and the other holding the dxf.

Clone this wiki locally