KaRouting

From Ka-Map Wiki

Jump to: navigation, search
only available in cvs
this works only for the A-star (A*) algorithm

This page will explain how to set up the routing module

ominoverde

a special thank to Daniel from geomatic.ch

Contents

[edit] Introduction

Installing this function is not easy as using a MS4W package.

It assumes you have already correctly set up pgRouting module for Postgres. Also Postgis have to be set up correctly. Then you should install the pgRouting (sample) dataset from Orkney PostLBS site and make it work. Default settings on CVS are tuned on pgRouting (sample) dataset.

[edit] setting the right config.php file

FIrst of all we had to add a new config file to set Postgres connection and second mapfile.

so copy

include/config.routing.dist.php

to

include/config.php

then edit it.

line 141
$kaRoute = Array(
                       'routeMap' => '/path/to/mapfile.map',//the second mapfile -should be changed with an SLD file
                       'pgConn' => 'dbname=my_db host=localhost port=5432 user=xxxxxx password=xxxxxx',
                       'myGraphTable' => 'kanagawa',
                       'costColumn' => 'length',
                       'reverseCostColumn' => 'length',
                       'directed' => 'false',//check pgRouting docs for this value
                       'has_reverse_cost' => 'false',//check pgRouting docs for this value
                       'buffer' => '0.01'//should be related to your map unit
               );

set the proper values.

[edit] setting up the mapfile

this is the "routeMap" mapfile

MAP
  IMAGETYPE   png
  EXTENT      139.602 35.413 139.678 35.489
  SIZE        550 450 

   IMAGECOLOR  255 255 255
  SHAPEPATH   "data" #there are no shapes ;-)

   FONTSET     "fonts/fonts.list"
  WEB
    IMAGEPATH "../tmp/"
    IMAGEURL  "/routingj/tmp/" 
  END 

  PROJECTION
   "init=epsg:4612" # JGD2000. the kanagawa one
  END 

  UNITS DD 

  SYMBOL
    NAME "hatch"
    TYPE hatch
  END 

LAYER
      NAME "path"
      CONNECTION "user=me password=mypass dbname=kanagawa host=localhost port=5432"
      CONNECTIONTYPE postgis
      STATUS OFF 
      TYPE LINE 

      CLASS
        NAME "path"
        STYLE
          COLOR 250 0 0
          WIDTH 2
       END
      END
 END


END

[edit] creating the table to store query results

create this table in your DB to store query results.

CREATE TABLE kroute (
    gid serial NOT NULL,
    sessionid text,
    the_geom geometry NOT NULL,
    date timestamp without time zone,
    CONSTRAINT enforce_dims_the_geom CHECK ((ndims(the_geom) = 2)),
    CONSTRAINT enforce_geotype_the_geom CHECK (((geometrytype(the_geom) = 'MULTILINESTRING'::text) OR (the_geom IS NULL))),
    CONSTRAINT enforce_srid_the_geom CHECK ((srid(the_geom) = -1))
);
remember to add the geometry to geometry table with the right SRID
Personal tools