Here is my working example ONE-TO-MANY JOIN with PostgreSQL :
LAYER
NAME "plan-var-predpis-sel"
STATUS OFF
CONNECTIONTYPE postgis
CONNECTION "user=koper password=koper dbname=gisdb host=localhost"
DATA "the_geom from loki_091"
TYPE POLYGON
JOIN
NAME testjoin
CONNECTIONTYPE postgresql
CONNECTION "user=uname password=pwd dbname=databasename host=hname"
TABLE plan_pia_data
TO pia_osn
FROM akt_id
TYPE ONE-TO-MANY
TEMPLATE "one_to_many.html"
END
CLASS
SYMBOL 'DIAGONALA_D'
SIZE 3
COLOR 255 255 0
END
TEMPLATE "one_to_many_head.html"
TOLERANCE 0
END
one_to_many_head.html :
[join_testjoin]
one_to_many.html :
<BR> FROM_ID :[akt_id]
<BR> TO_ID :[testjoin_pia_sif]
<BR> NAME :[testjoin_name]
<BR> NOTE :[testjoin_note]
Also see http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=2006
lp Alfred
Jeff McKenna wrote:
Thanks Zoltan, that was it.
I'll include my example on the join page.
jeff
Siki Zoltan wrote:
Hi Jeff,
You should refer to the column in the joined table in your template like
[joinname_columnname]
In your case it should be
[test_VAL]
Be carefull with the upper and lower case letters!
Zoltan
On Sun, 14 Jan 2007, Jeff McKenna wrote:
Hello everyone,
For the first time I am trying to use the mapfile JOIN object, and I
can't seem to get it to work. From the mapjoin.c file I can see that
DBF, CSV, PostgreSQL, and MySQL are supported. I have personally
tried to view query results joined from DBF, CSV, and PostgreSQL
tables unsucessfully. (my goal is to also update the sparse
documentation for this also on
http://mapserver.gis.umn.edu/docs/reference/mapfile/join). Here is
my DBF test case:
Test Environment
****************
mapserver 4.10.0
windows
mapfile layer
*************
LAYER
NAME prov_bound
TYPE POLYGON
STATUS DEFAULT
DATA prov
CLASS
NAME "Province"
STYLE
OUTLINECOLOR 120 120 120
COLOR 255 255 0
END
END
TEMPLATE "../htdocs/cgi-query-templates/prov.html"
HEADER "../htdocs/cgi-query-templates/prov-header.html"
FOOTER "../htdocs/cgi-query-templates/footer.html"
JOIN
NAME "test"
TABLE "../data/lookup.dbf"
FROM "ID"
TO "IDENT"
TYPE ONE-TO-ONE
END
END # layer
ogrinfo
*******
>ogrinfo lookup.dbf lookup -summary
INFO: Open of `lookup.dbf'
using driver `ESRI Shapefile' successful.
Layer name: lookup
Geometry: None
Feature Count: 12
Layer SRS WKT:
(unknown)
IDENT: Integer (2.0)
VAL: Integer (2.0)
>ogrinfo prov.shp prov -summary
INFO: Open of `prov.shp'
using driver `ESRI Shapefile' successful.
Layer name: prov
Geometry: Polygon
Feature Count: 12
Extent: (-2340603.750000, -719746.062500) - (3009430.500000,
3836605.250000)
Layer SRS WKT:
(unknown)
NAME: String (30.0)
ID: Integer (2.0)
Template
********
<tr bgcolor="#EFEFEF"><td align="left">[NAME]</td><td
align="left">[VAL]</td></tr>
Query Results
*************
Layer: Provinces
NAME VAL
==== ====
Ontario [VAL]
Other Notes
***********
- the join seems to be happening, because if I specify false FROM/TO
values errors are thrown, yet I cannot get values to appear from the
[VAL] field
- ID/IDENT are integer values from 1 to 12
- the join works with desktop GIS packages
Can someone see what I am doing wrong?
thanks.
jeff