Ka-Map and Pmapper implementation

From Ka-Map Wiki

Jump to: navigation, search

This page is intended to be an howto on configuring ka-Map and P.mapper on the same machine sharing the same data.

I'm considering that UMN Mapserver and php_mapscript are well installed and configured in the machine. The implementation has general purpose not intended for production servers.

Lorenzo Becchi

Contents

[edit] Data Folder

Let's start with data. P.mapper offers a nice demo data from its site, so we'll use them: http://sourceforge.net/project/showfiles.php?group_id=83770&package_id=146223&release_id=362491

We can put this data in a "data/pmapper" forlder inside user home.

#mkdir ~/data
#mkdir ~/data/pmapper
#cp pmapper-demodata-2.zip ~/data/pmapper
#cd ~/data/pmapper
#unzip pmapper-demodata-2.zip

[edit] Web Folder

Both applications need a folder accessible from the web server. Maybe you already have a folder like that in your home dir (es: public_html, www, ecc.).

#mkdir ~/public_html/pmapper 
#mkdir ~/public_html/ka-map

[edit] Temporary Folder

Both pmapper and ka-map need temporary folders.

#mkdir ~/public_html/tmp
#mkdir ~/public_html/tmp/kamapcache
#chmod 777 ~/public_html/tmp/kamapcache
#mkdir ~/public_html/tmp/pmappercache
#chmod 777 ~/public_html/tmp/pmappercache

777 parameter is a vary bad way to solve all access problems. This approach is presented just to simplify the configuration.

[edit] p.mapper

[edit] download

Last version of p.mapper is available at this page: http://sourceforge.net/projects/pmapper

downloaded file (es: pmapper-1.2.0) has to be expanded in a appropriate folder.

#cp pmapper-1.2.0.zip ~/public_html
#cd ~/public_html
#unzip pmapper-1.2.0.zip
#mv pmapper-1.2.0 pmapper

[edit] configuration

Once you've copied the folder it's the time of the configuration file. To do this we use a generic editor (nano in this case)

#cd ~/public_html/pmapper
#nano config/config.ini

first control, line 59:

msVersion = 46

This means the php_mapscript version. In my server it is php_mapscript_48.so :

msVersion = 48

At line 66

mapFile =  d:/webdoc/pmapper-1.2.0/config/pmapper_demo.map

we'll put the absolute path to our pmapper

mapFile =  /home/miahome/public_html/pmapper/config/pmapper_demo.map

nothing more. Save and exit.

[edit] mapfile

Mapfile too need a little personalization.

#nano /home/miahome/public_html/pmapper/config/pmapper_demo.map

line 24

SHAPEPATH "../../demodata"
#SYMBOLSET "../demodata/symbols/symbols35.sym" 

become

SHAPEPATH "/home/miahome/data/pmapper/"
SYMBOLSET "/home/miahome/data/pmapper/symbols/symbols35.sym"  

while line 84

IMAGEPATH "d:\webdoc\tmp\"
IMAGEURL "/tmp/"

become

IMAGEPATH "/home/miahome/public_html/tmp/pmappercache"
IMAGEURL "../tmp/pmappercache"

[edit] ka-Map

[edit] download

MapTools site offer the last version of ka-Map: http://ka-map.maptools.org/index.phtml?page=downloads.html


#cp ka-map-0.2-20060207.zip ~/public_html
#cd ~/public_html
#unzip ka-map-0.2-20060207.zip
#mv ka-map-0.2-20060207 ka-map

[edit] configuration

In ka-map the ocnfiguration file is not active but it's available as a copy. In the include' folder it is necessary to copy the config.dist.php as config.php

#cd ~/public_html/ka-map
#cp include/config.dist.php include/config.php
#nano include/config.php

lines 49 and 50 has to be changed (as in pmapper) to define php_mapscript and libgd module names.

$szPHPMapScriptModule = 'php_mapscript_46.'.PHP_SHLIB_SUFFIX;
$szPHPGDModule = 'php_gd.'.PHP_SHLIB_SUFFIX;

our version:

$szPHPMapScriptModule = 'php_mapscript_48.'.PHP_SHLIB_SUFFIX;
$szPHPGDModule = 'gd.'.PHP_SHLIB_SUFFIX;

The name of libGD module dipends on your OS distribution.

At line 106 has to be defined all parameters relative to the mapfile as the zoom levels we want to be shown. Last line is for image type (es: PNG).

$aszMapFiles = array(
 "gmap"   => array( "GMap", "../../gmap-ms40/htdocs/gmap75.map",
                    array( 15000000, 7500000, 3000000, 1000000 ),
                    "PNG")

/* Add more elements to this array to offer multiple mapfiles */

);

became:

$aszMapFiles = array(
 "gmap"   => array( "ka-Map", "/home/miahome/public_html/ka-map/include/ka-map_demo.map",
                     array( 50000000, 10000000, 5000000, 1000000 ),
                     "PNG")

/* Add more elements to this array to offer multiple mapfiles */

);

[edit] mapfile ka-map

Last thing to do is the mapfile for ka-map.

#cp ~/public_html/pmapper/config/pmapper_demo.map ~/public_html/ka-map/include/ka-map_demo.map

now we have to edit the pmapper mapfile and adapt it for ka-map.

#nano  ~/public_html/ka-map/include/ka-map_demo.map

Here below an example of a possible configuration (change absolute paths where needed):

# Adapt settings in map file pmapper_demo.map for the following tags to match settings
# on your machine (see additionally MapServer documentation for detailed information):
# MAP
  # SHAPEPATH 
  # FONTSET
  # SYMBOLSET

# WEB
  # IMAGEPATH  
  # IMAGEURL    

#
# Start of map file  
#
MAP
EXTENT  1988372 1400000 6411627 5400000 
UNITS meters
#EXTENT -15 30 40 70
#UNITS dd
SIZE 900 900
SHAPEPATH "/home/myhome/data/pmapper/"
SYMBOLSET "/home/myhome/data/pmapper/symbols/symbols35.sym"   
#FONTSET "../../../data/fonts/msfontset.txt"
RESOLUTION 96
IMAGETYPE png
TRANSPARENT ON #needed to allow multiple layer 
INTERLACE ON
PROJECTION
  # ETRS-LAEA
  # <3035> +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs  no_defs <>
  "proj=laea"   
  "lat_0=52.000000"
  "lon_0=10.000000"
  "x_0=4321000"
  "y_0=3210000"
  "ellps=GRS80"
  "units=m"
  "no_defs"
END  
OUTPUTFORMAT ##added for jpg background
	NAME jpeg
	DRIVER "GD/JPEG"
	IMAGEMODE RGB
	EXTENSION "jpeg"
	FORMATOPTION "QUALITY=75,PROGRESSIVE=TRUE"
END
OUTPUTFORMAT
 NAME png
 DRIVER "GD/PNG"
 MIMETYPE "image/png"
 IMAGEMODE RGB
 FORMATOPTION  INTERLACE=OFF
 TRANSPARENT OFF
END
OUTPUTFORMAT
 NAME png8
 DRIVER "GD/PNG"
 MIMETYPE "image/png"
 IMAGEMODE PC256
 FORMATOPTION  INTERLACE=OFF
 TRANSPARENT OFF
END
OUTPUTFORMAT
 NAME GTiff
 DRIVER "GDAL/GTiff"
 MIMETYPE "image/tiff"
 IMAGEMODE RGB
 #FORMATOPTION "TFW=YES"
 #FORMATOPTION "COMPRESS=PACKBITS"
END
OUTPUTFORMAT
 NAME imagemap
 MIMETYPE "text/html"
 FORMATOPTION SKIPENDTAG=ON
 DRIVER imagemap
END
#
# Start of web interface definition
#
WEB
 TEMPLATE "map.html"
 IMAGEPATH "/myhome/miahome/public_html/tmp/kamapcache/"#change this
 IMAGEURL "../../tmp/kamapcache/" #change this
 METADATA
 END  # Metadata
END  # Web
#
# Start of Reference map definition
#
REFERENCE
 EXTENT 1496247 1332616 7055632 5502154 #2200000 1400000 8000000 5400000
 IMAGE "/home/myhome/data/pmapper/images/reference.jpg" #change this
 SIZE 199 149
 COLOR -1 -1 -1
 OUTLINECOLOR 255 0 0
END  # Reference
LEGEND
END
#
# Start of ScaleBar definition
#
SCALEBAR
 INTERVALS 4
 SIZE 200 3
 UNITS kilometers
 COLOR 250 250 250
 OUTLINECOLOR 0 0 0
 BACKGROUNDCOLOR 100 100 100
 STYLE 0
 POSTLABELCACHE true
 LABEL
   COLOR 255 255 255
   OUTLINECOLOR 0 0 0
   SIZE small
 END  # Label
END  # Reference
# SYMBOLS USED IN PMAPPER
# - 'circle' always necessary (used e.g. for highlight)
# - 'square' used in currecnt map file
# Symbols can also be defined via tag SYMBOLSET (see above)
Symbol
 Name 'circle'
 Type ELLIPSE
 Filled TRUE
 Points
   1 1
 END
END 
Symbol
 Name 'square'
 Type VECTOR
 Filled TRUE
 Points
   0 1
   0 0
   1 0
   1 1
   0 1
 END
END
#================== START OF LAYER SECTION =====================#
#LAYER
#  NAME "jpl_wms_global_mosaic"
#  TYPE RASTER
#  STATUS ON
#  GROUP '__base__'
#  CONNECTION "http://wms.jpl.nasa.gov/wms.cgi?"
#  CONNECTIONTYPE WMS
#  PROJECTION
#    "init=epsg:4326"
#  END
#  METADATA
#    "DESCRIPTION"         "JPL Global Mosaic (WMS)"
#    "wms_name"            "global_mosaic_base"
#    "wms_style"           "visual"
#    "wms_server_version"  "1.1.1"
#    "wms_format"          "image/jpeg"
#  END
#END

#
# LAYER DGM
#
LAYER
 NAME "dem"
 TYPE Raster
 STATUS ON
 DATA 'europa_dem.jpg'
 MINSCALE 3000000
 PROJECTION
   "init=epsg:4326"
 END
 METADATA
	imageformat "jpeg" 
   "DESCRIPTION"   "NGDC Shaded relief"
   "LEGENDICON"    "images/legend/dem.png"
 END
END
#
# Start of Layer Countries.shp
#
LAYER
	STATUS ON #important for ka-map (0.2)
 NAME "countries"
 GROUP "Country"
 TYPE polygon
 DATA "countries"
 #TRANSPARENCY 30# Ka-map, no more needed once I eliminate the color
 PROJECTION
   "init=epsg:4326"
 END
 METADATA 
   "DESCRIPTION" "Countries"
   "RESULT_FIELDS" "NAME,AREA"
   "RESULT_HEADERS" "Name,Area"
 END  # Metadata 
 CLASS
   Name 'Countries'
  # COLOR 200 254 199#Ka-map, not needed
   OUTLINECOLOR 0 0 0
    TEMPLATE void
  END  # Class
END  # Layer

#
# Start of Layer Cities.shp
#
LAYER
  NAME "cities" 
	GROUP 'Cities' #ka-map, a new layer
  TYPE point
  DATA "cities"
  TOLERANCE 10
  TOLERANCEUNITS pixels
  LABELITEM "CITY_NAME"
  LABELMAXSCALE 15000000
  PROJECTION
    "init=epsg:4326"
  END
  METADATA 
	imageformat "PNG" #ka-Map
	"QUERYABLE" "true" #ka-Map: activate identify 
    "DESCRIPTION" "Cities"
    "RESULT_FIELDS" "CITY_NAME,ADMIN_NAME,CNTRY_NAME,STATUS,POP_CLASS"
    "RESULT_HEADERS" "Name,Administrative Entity,Country,Status,Inhabitants"
    "RESULT_HYPERLINK" "CITY_NAME, CNTRY_NAME||Link on detail"
    "LAYER_ENCODING" "UTF-8"
  END  # Metadata 
  CLASS
    NAME "> 5'000'000"
    EXPRESSION ([POP_RANK] = 1)
    COLOR 255 0 0 
    SYMBOL 'square' 
    SIZE 9
    LABEL
      POSITION Auto
      COLOR 0 0 150 
      BACKGROUNDCOLOR 255 255 128
      BACKGROUNDSHADOWCOLOR 150 150 150
      BACKGROUNDSHADOWSIZE 2 2
      BUFFER 2
      #TYPE truetype
      #FONT verdana
      #SIZE 8
      #MAXSIZE 9
      SIZE small
    END #Label  
    TEMPLATE void
  END  # Class
  CLASS
    NAME "1'000'000 - 5'000'000"
    EXPRESSION ([POP_RANK] = 2)
    COLOR 255 0 0
    SYMBOL 'square' 
    SIZE 7
    LABEL
      POSITION Auto
      COLOR 0 0 150 
      BACKGROUNDCOLOR 255 255 128
      BACKGROUNDSHADOWCOLOR 150 150 150
      BACKGROUNDSHADOWSIZE 2 2
      BUFFER 2
      #TYPE truetype
      #FONT verdana
      #SIZE 8
      #MAXSIZE 9
      SIZE small
    END #Label  
    TEMPLATE void
  END  # Class
  CLASS
    NAME "500'000 - 1'000'000"
    EXPRESSION ([POP_RANK] = 3)
    COLOR 255 0 0
    SYMBOL 'circle' 
    SIZE 6
    TEMPLATE void
  END  # Class
  CLASS
    NAME "< 500'000 Inhabitants"
    EXPRESSION ([POP_RANK] = 4)
    COLOR 0 0 0
    SYMBOL 'circle' 
    SIZE 5
    TEMPLATE void
  END  # Class
END  # Layer

#
# Start of Layer Rivers.shp
#
LAYER
  NAME "rivers"
  STATUS ON
  TYPE line
  DATA "rivers"
  TOLERANCE 3
  TOLERANCEUNITS pixels
  PROJECTION
    "init=epsg:4326"
  END
  METADATA
    "DESCRIPTION" "Rivers"
    "RESULT_FIELDS" "NAME,LENGTH"
    "RESULT_HEADERS" "Name,Length"
  END  # Metadata 
  CLASS
    Name 'Rivers'
    COLOR 0 0 255
    TEMPLATE void
  END  # Class
END  # Layer

END  #Map


--Ominiverdi 01:59, 3 June 2006 (CEST)

Personal tools