[Mapserver-users] Please Help...Joins with MapServer PHP/Mapscript

Mike Leahy mgleahy at fes.uwaterloo.ca
Thu May 15 11:16:19 EDT 2003


Many thanks for the replies.

I've used MapEdit to create the mapfile (below), and GMapFactory to
produce the PHP viewer I've been testing.  I've joined a single DBF file
to one of the layers in the mapfile (as you can see below).  Both in the
MapEdit preview, and the output from GMapFactory, there is no evidence
of the join.  I've tried using various combinations of simple templates
(currently just results.html and testjoin.html - also below).  No matter
what I do with the templates, or where I put them (i.e. in the web,
layer, class or join objects), I see no change in the query results
either in the MapEdit preview or the GMapFactory output viewer.  They
always just list the attributes for the selected features.

I will also try the maplab-users list...however, I will eventually be
creating a very specific interface to perform analysis using various
linked tables.  Perhaps someone can give me some tips or refer me to
some documentation that can help get started building my own web
interface that directly uses MapServer from scratch (using ASP for
example) as opposed to working with the GMapFactory output.  This may be
a much better approach for me if I am to try to use MapServer 3.7 when
it is released.

Thanks,
Mike

P.S. yes, I am using MapServer 3.6.5.

------------mapfile---------------

MAP
  NAME "Independencia"
  STATUS ON
  EXTENT 273346 670666 281455 677412 
  SIZE 600 500 
  SHAPEPATH "./Independencia"
  SYMBOLSET "./Independencia/etc/symbols.sym"
  FONTSET "./Independencia/etc/fonts.txt"
  IMAGECOLOR 255 255 255
  TRANSPARENT FALSE
  UNITS METERS
  INTERLACE TRUE
  IMAGETYPE PNG
  IMAGEQUALITY 100
  WEB
    IMAGEPATH "c:/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
  END
  REFERENCE
    STATUS ON
    IMAGE "./vista.gif"
    SIZE 100 60 
    EXTENT 272051 670801 282750 677277 
    COLOR -1 -1 -1
    OUTLINECOLOR 255 0 0
    MINBOXSIZE 3
    MAXBOXSIZE 0
    MARKER 0
    MARKERSIZE 0
  END
  QUERYMAP
    STATUS ON
    SIZE -1 -1 
    COLOR 51 100 255
  END
  LEGEND
    STATUS ON
    OUTLINECOLOR 0 0 0
    IMAGECOLOR 204 204 255
    TRANSPARENT FALSE
    INTERLACE TRUE
    POSITION LL
    KEYSIZE 18 12 
    KEYSPACING 5 5 
    TEMPLATE "c:/msapps/htdocs/mapedit/legend_template.html"
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      OFFSET 0 0 
      BUFFER 0
      MINDISTANCE -1
      MINFEATURESIZE -1
      COLOR 0 0 89
      PARTIALS TRUE
      FORCE FALSE
    END
  END
  SCALEBAR
    STATUS ON
    COLOR 0 0 0
    OUTLINECOLOR 0 0 0
    BACKGROUNDCOLOR 204 204 204
    IMAGECOLOR 255 255 255
    TRANSPARENT FALSE
    UNITS KILOMETERS
    INTERVALS 5
    SIZE 300 8 
    STYLE 0
    POSITION LL
    INTERLACE TRUE
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      OFFSET 0 0 
      BUFFER 0
      MINDISTANCE -1
      MINFEATURESIZE -1
      COLOR 0 0 0
      PARTIALS TRUE
      FORCE FALSE
    END
  END
  LAYER
    NAME "Manzanas - Cono"
    GROUP "Cono"
    STATUS ON
    DATA "./manzanas-cono.shp"
    TYPE POLYGON
    UNITS METERS
    SIZEUNITS PIXELS
    TOLERANCE 3
    TOLERANCEUNITS PIXELS
    TEMPLATE "ttt.html"
    CLASS
      NAME "Mananas - Cono"
      SYMBOL 0
      COLOR 255 255 255
      OUTLINECOLOR 204 204 51
      SIZE 1
      MINSIZE 1
      MAXSIZE 100
    END
  END
  LAYER
    NAME "Escuelas Primarias - Independencia"
    GROUP "Independencia"
    STATUS ON
    DATA "./primary_schools"
    TYPE POINT
    UNITS METERS
    SIZEUNITS PIXELS
    TOLERANCE 3
    TOLERANCEUNITS PIXELS
    TEMPLATE "../Independencia/etc/results.html"
    METADATA
      "fecha"    "2000"
      "origen"    "Ministerio de Educacíon"
    END
    CLASS
      NAME "Escuelas"
      SYMBOL 2
      COLOR 150 0 0
      SIZE 8
      MINSIZE 1
      MAXSIZE 100
      TEMPLATE "./Independencia/etc/results.html"
      JOIN
        NAME "testjoin"
        TYPE SINGLE
        TABLE "./Independencia/blocks.dbf"
        FROM "Cod_mod"
        TO "Cod_mod"
        TEMPLATE "./Independencia/etc/testjoin.html"
      END
    END
  END
  LAYER
    NAME "Sectores - Independencia"
    GROUP "Independencia"
    STATUS ON
    DATA "./sectores"
    TYPE POLYGON
    UNITS METERS
    SIZEUNITS PIXELS
    LABELITEM "Red_nom"
    TOLERANCE 3
    TOLERANCEUNITS PIXELS
    TEMPLATE "ttt.html"
    CLASS
      NAME "Sectores"
      SYMBOL 0
      OUTLINECOLOR 102 0 0
      SIZE 3
      MINSIZE 1
      MAXSIZE 100
      LABEL
        TYPE TRUETYPE
        FONT "Arial-Bold"
        SIZE 10
        MINSIZE 10
        MAXSIZE 10
        POSITION CC
        OFFSET 0 0 
        ANGLE 0.000000
        BUFFER 0
        MINDISTANCE -1
        MINFEATURESIZE -1
        COLOR 0 0 204
        ANTIALIAS TRUE
        PARTIALS TRUE
        FORCE FALSE
      END
    END
  END
END

--------results.html--------------

<html>
<body>
[testjoin]
</body>
<html>

--------testjoin.html-------------

<br>[MANZID]

----------------------------------
_________________________________________________________________

-----Original Message-----
From: Paul Spencer [mailto:pagameba at magma.ca] 
Sent: May 14, 2003 8:24 PM
To: Maplab-users
Cc: Mike Leahy
Subject: Re: [Mapserver-users] Please Help...Joins with MapServer
PHP/Mapscript

Did you mean MapServer 3.6.5?  In any case, there is a problem with 
queries in MapLab 2 that we have not had time to research.

I don't know exactly how you are attempting to link the DBF file, 
perhaps you could provide some details on this.

Also, where are you not getting query results (MapEdit preview, 
MapBrowser, or GMapFactory)?

When the 3.7 branch is released as stable, there is new functionality 
through OGR to link shape files directly to DBF files that was added by 
Frank Warmerdam.  It works like a charm, but unfortunately MapLab has 
not yet been updated for the 3.7 branch (look for it around 30 May).

Finally, since this is a maplab-specific question, you would have more 
luck with it on the maplab-users list.

Cheers,

Paul

Mike Leahy wrote:

> I´m pretty sure I sent a request for info on this question on monday,
but so 
> far there has been no response...I apologize if I am unnecessarily
repeating 
> this request.
> 
> Essentially, I´m trying to link a DBF file to the attributes of a
shapefile.  
> So far, it seems to work (at least there are no errors when the
mapfile is 
> displayed through the PHP web interface).  However, if I query a
location on 
> the map from the PHP web interface, I get no results for the joined
table.
> 
> I tried using results templates, as the documentation suggests, but
that had no 
> impact.  After going through code in the PHP/PHTML scripts, it seems
to me that 
> there is no function included for handling joins in the PHP version.
Is this 
> the case?  If so, how might I go about building such functionality
myself.  If 
> not, perhaps someone can tell me what I have missed.
> 
> Using: MapServer 3.5.6 with MapLab 2, on WinXP running IIS (with all
updates).
> 
> Thanks,
> Mike
> 
> ----------------------------------------
> This mail sent through www.mywaterloo.ca
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 

-- 
Paul Spencer
Applications and Software Development
DM Solutions Group Inc.
http://www.dmsolutions.ca







More information about the mapserver-users mailing list