One-to-many attribute queries
Wim Blanken
w.blanken at GEON.NL
Sat Nov 4 01:23:21 PST 2006
Hello Dejan,
In the past I have used the join function of mapserver in combination with
some data pre-processing. I used a desktop GIS program to assign the
locations the ID of the building that they belonged to. After that it is a
simple join operation in mapserver.
I did not have the possibility to use a Geodatabase of some sort, if you can
this can offer a better solutions.
==================================================
the content of the layer buildings in my mapfile
==================================================
LAYER
NAME Buildings
DATA 'buildings.shp'
STATUS ON
TEMPLATE 'q_building.html'
TYPE POLYGON
CLASS
COLOR 100 100 100
END #CLASS
JOIN
NAME locations
TABLE "locations.dbf"
FROM BUILDING_ID
TO BUILDING_ID
TYPE one-to-many
TEMPLATE 'q_locations.html'
END
END # LAYER
==================================================
And the content of the query file: q_building.html
==================================================
[NAME]
[join_locations]
==================================================
And the content of the query file: q_locations.html
==================================================
[locations_STREET]
[locations_ADDRESS]
===================================================
In this example both tables have a field called: BUILDING_ID which is a
primary key of the BUILDINGS Table and a Foreign key inside the LOCATIONS
table. The buildings Table has a NAME attribute and the locations Table has
a STREET and a ADDRESS attribute.
So you put the [join_locations] tag inside the main layer template which
will execute the joined records template for locations that are related to
this building.
Joined template you have to put the name of the join before the attribute
name like: [locations_STREET].
I do not know if Chameleon has limitations of working with joins. Maybe
someone else knows this.
Regards,
Wim Blanken
The Netherlands
-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Gambin Dejan
Sent: vrijdag 3 november 2006 8:45
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] One-to-many attribute queries
Hi,
As a part of my new project, I need to support one-to-many queries. I
have a layer with objects/buildings and each object/building can have
one or more locations inside. I have to implement a query mechanism that
can give me the attributes of each location inside a building when I
click on that building.
Is it only related to the application I am using or there is "something"
on the mapserver side that could help me? I am using Chameleon for this
project. Any suggestions?
thanks very much
regards, dejan
More information about the MapServer-users
mailing list