Generating a table & map sharing identifiers

Bill Binko bill at BINKO.NET
Sun Aug 21 23:20:27 EDT 2005


Hi everyone,

I have a problem that I'd like some feedback on.  I'm certain it can be 
done, but would like to know how others have solved it in the past.

I need to generate several tables with "nearest X items" to a location.  
For example, "Nearest 5 Schools" to a location.  I then want to generate a 
map showing the area that includes the X items and show the items on the 
map using the id's from the table.

Here's an example:

Table:
Map ID	|School Name	|Students | Teachers
--------------------------------------------
(A)	|Main St. Elem. |100	  | 10
(B)	|Pinewood Elem. |2500	  | 20
(C)	|Forrest Lakes  |800	  | 20

Map:
 ------------------
| (A)              |
|              (B) |
|     (C)          |
 ------------------

So, what approaches are people using for this when using PostGIS and 
Mapserver?  I will probably use PHP/Mapscript as that's what I'm most 
familiar with.

I have two approaches that I think are doable...

1) I use PHP/Mapscript to make the base map
2) I connect to PostGIS and grab the data including the points/shapes I'm 
interested in (OGC WKT format?)
3) I use PHP/Mapscript to create a layer and add the points to the base 
map

OR

1) I connect to PostGIS and create a temporary sequence (one that is local 
to the connection)
2) I select the data with shapes and attributes + the sequence into a 
temporary table (one that is local to the connection)
3) I have PHP/Mapscript draw the map using that temporary table
4) I use the temporary table to generate the HTML

I'm pretty sure everyone will tell me to use approach #1, but of course 
I've started #2 :)  I think I'm having problems because PHP/Mapscript 
opens its own connection to Postgresql, so it won't see my temporary 
table.

Does anyone have any advice?

Bill



More information about the mapserver-users mailing list