[pgrouting-users] add route layer to mapfile

Hello,

I am trying to add a route to a webserver with pmapper and mapserver but i can´t.

I tried like that:

LAYER
     NAME "rota"
     STATUS DEFAULT
     TYPE LINE
     CONNECTIONTYPE postgis
     PROCESSING "CLOSE_CONNECTION=DEFER"
     CONNECTION "user=pedro password=********** dbname=test host=localhost options='-c client_encoding=LATIN1'"

  DATA "the_geom from
         (SELECT id, the_geom
         FROM arcos
         JOIN
         (SELECT * FROM shortest_path('
         SELECT id2 as id,
         source::int4 AS source,
         target::int4 AS target,
         length*estado_actual.custo AS cost
         FROM arcos, estado_actual
         where arcos.estado_a = estado_actual.id_ea',
         438,489,false,false)) AS rota
          ON
   arcos.id2 = rota.edge_id) AS rota2
   using unique id"

     TOLERANCE 3
     TOLERANCEUNITS pixels
     TEMPLATE void
     PROJECTION
     "init=epsg:27492"
      END
     METADATA
     "DESCRIPTION" "rota"
    # "RESULT_FIELDS" "n_rua,rua,compriment"
    # "RESULT_HEADERS" "Nº do Trecho de rua,Nome da Rua,Longitude(m)"
     "ows_title" "Rota"
         END # Metadata
         CLASS
     Name 'ruas'
     COLOR 0 0 0
         END # Class
  END

The error is in the clause 'data'. Mapserver can´t load the route and i don´t know why. The query works fine in database (if I remove 'using unique id' and put 'select' before 'the_geom'.

Anybody know how resolve this problem?

Thanks

Hi Pedro,

It’s long time ago that I have used pgRouting with Mapserver, but I remember that I had to specify the SRID in DATA. Did you already look at this example in the pgRouting documentation?
http://www.pgrouting.org/docs/howto/mapserver.html

Daniel

On Fri, Jun 29, 2012 at 1:44 PM, Pedro Costa <pedrocostaarma@sapo.pt> wrote:

Hello,

I am trying to add a route to a webserver with pmapper and mapserver but i can´t.

I tried like that:

LAYER
NAME “rota”
STATUS DEFAULT
TYPE LINE
CONNECTIONTYPE postgis
PROCESSING “CLOSE_CONNECTION=DEFER”
CONNECTION “user=pedro password=********** dbname=test host=localhost options=‘-c client_encoding=LATIN1’”

DATA “the_geom from
(SELECT id, the_geom
FROM arcos
JOIN
(SELECT * FROM shortest_path(’
SELECT id2 as id,
source::int4 AS source,
target::int4 AS target,
length*estado_actual.custo AS cost
FROM arcos, estado_actual
where arcos.estado_a = estado_actual.id_ea’,
438,489,false,false)) AS rota
ON
arcos.id2 = rota.edge_id) AS rota2
using unique id”

TOLERANCE 3
TOLERANCEUNITS pixels
TEMPLATE void
PROJECTION
“init=epsg:27492”
END
METADATA
“DESCRIPTION” “rota”

“RESULT_FIELDS” “n_rua,rua,compriment”

“RESULT_HEADERS” “Nº do Trecho de rua,Nome da Rua,Longitude(m)”

“ows_title” “Rota”
END # Metadata
CLASS
Name ‘ruas’
COLOR 0 0 0
END # Class
END

The error is in the clause ‘data’. Mapserver can´t load the route and i don´t know why. The query works fine in database (if I remove ‘using unique id’ and put ‘select’ before ‘the_geom’.

Anybody know how resolve this problem?

Thanks


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de

Em 29-06-2012 14:07, Daniel Kastl escreveu:

but I remember that I had to specify the SRID in DATA

Great! I add 'using srid=27493' and works...

Thanks Daniel...