David Niergarth wrote:
Here's an example of what we'd like to accomplish.

DATA "p.the_geom from people_points p, spam_table s, eggs_table e"
FILTER "p.id=s.id and p.id=e.id and s.spam='foo' and e.eggs='bar'"

The only problem with the example above is that mapserver takes everything in the FROM clause and includes it in a find_srid() call. See the generated query below; note especially the last full line.

DECLARE mycursor
BINARY CURSOR FOR
SELECT asbinary(force_collection(force_2d(pp.the_geom)),'NDR'),OID::text
  from people_points p, spam_table s, eggs_table e
 WHERE (p.id = s.id and p.id = e.id)
       and (p.the_geom && setSRID('BOX3D(-91.5260946100404
41.6407165527344,-91.4920023137877 41.667503356933)'::BOX3D,
find_srid('','people_points p, spam_table s, eggs_table e', 'p.the_geom')
))

That last line should be

  find_srid('','people_points','the_geom')

rather than

  find_srid('','people_points p, spam_table s, eggs_table e', 'p.the_geom')

which it gets by grabbing everything following "from" in the DATA string

  DATA "p.the_geom from people_points p, spam_table s, eggs_table e"

If mapserver were to parse the DATA line more precisely, join queries like this would just work. (Would this extra parsing be too postgres-specific?) This seems like such a common sort of query to want to run I'm wondering if I'm missing some obvious other way to do it. (Or maybe I should make this a feature request?)

How are others making this sort of database join for layers?

Thanks,

--David

Reply via email to