1

Here is the relevant portion of my mapfile:

CONNECTIONTYPE POSTGIS  
  CONNECTION "dbname=contours host=localhost user=contour_xxxx password=xxx"  
  PROCESSING "CLOSE_CONNECTION=DEFER"  
  DATA "wkb_geometry from contours USING UNIQUE ogc_fid USING
contourinterval=40"  

I want to limit the contours returned to only include contourinterval=40. As you can see from the Postgres log (below), contourinterval isn't even referenced in the query...

select
    "contourelevation",
    encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex') as geom,
    "ogc_fid" 
from contours 
where wkb_geometry &&
ST_GeomFromText('POLYGON((-111.939697265625
33.4213636331582,-111.939697265625 33.4323499612832,-111.9287109375
33.4323499612832,-111.9287109375 33.4213636331582,-111.939697265625
33.4213636331582))',find_srid('','contours','wkb_geometry'))

I've tried all sorts of subselects and examples found on the web, nothing works. BTW, I assume 'contourelevation' is pulled because it is my LABELITEM. The data is USGS contour data.

  • 1
    If you want return only the rows where contourinterval = 40, you need to use a WHERE. DATA "wkb_geometry from contours where contourinterval = 40 USING UNIQUE ogc_fid". If you try "SELECT wkb_geometry FROM contours WHERE contourinterval = 40" in PGAdmin, what does it do? – TurboGraphxBeige Oct 12 '17 at 0:37
5

If you want Mapserver to use only the rows where contourinterval = 40, you need to use a WHERE.

I think you should use this connection string instead:

CONNECTIONTYPE POSTGIS  
CONNECTION "dbname=contours host=localhost user=contour_xxxx password=xxx"   
DATA "wkb_geometry FROM contours WHERE contourinterval = 40 USING UNIQUE ogc_fid".

Also, make sure the request actually works.

In PGAdmin, try:

SELECT wkb_geometry FROM contours WHERE contourinterval = 40

Make it work outside Mapserver first. Then, you should check the Mapserver logs.

To debug, try setting the log level to 5 (it's in the MAP object).

MAP
  ...
  CONFIG "MS_ERRORFILE" "ms_error.txt"
  DEBUG 5
  ...
  LAYER
    ...
  END
END
0

Thanks for the feedback! Turns out, there were no contourinterval = 40 rows within the bounding box area I was selecting. The Mapserver documentation wasn't clear how the 'using xxx' clause translated into the actual SQL statement. I was assuming it built a 'where' clause with any values stated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.