- works on 6.4.x
- times out on 7.0.2
MapServer 7.0.2 PostgreSQL 9.3.14 PostGIS 2.2
LAYER
NAME "totalozone"
STATUS ON
DEBUG 5
CONNECTION "host=localhost dbname=foo user=foo password=foo"
CONNECTIONTYPE POSTGIS
PROCESSING "CLOSE_CONNECTION=DEFER"
DATA "the_geom from (select * from totalozone order by instance_datetime) as subquery using unique data_payload_id using srid=4326"
TYPE POINT
DUMP TRUE
TEMPLATE "ttt.html"
PROJECTION
"init=epsg:4326"
END
METADATA
"ows_title" "totalozone"
"gml_include_items" "all"
END
END
http://example.org/ows?map=/tmp/foo.map&service=WFS&version=1.1.0&request=GetFeature&outputformat=GeoJSON&typename=totalozone&filter=<ogc:Filter><ogc:And><ogc:BBOX><PropertyName>msGeometry</PropertyName><Box srsName="EPSG:4326"><coordinates>-188.4375,-85.67541458664353 190.546875,83.44032649527307</coordinates></Box></ogc:BBOX><ogc:PropertyIsBetween><ogc:PropertyName>instance_datetime</ogc:PropertyName><ogc:LowerBoundary>1924-01-01 00:00:00</ogc:LowerBoundary><ogc:UpperBoundary>2016-12-31 23:59:59</ogc:UpperBoundary></ogc:PropertyIsBetween></ogc:And></ogc:Filter>&startindex=0&maxfeatures=1
<ogc:Filter>
<ogc:And>
<ogc:BBOX>
<PropertyName>msGeometry</PropertyName>
<Box srsName="EPSG:4326">
<coordinates>-188.4375,-85.67541458664353 190.546875,83.44032649527307</coordinates>
</Box>
</ogc:BBOX>
<ogc:PropertyIsBetween>
<ogc:PropertyName>instance_datetime</ogc:PropertyName>
<ogc:LowerBoundary>1924-01-01 00:00:00</ogc:LowerBoundary>
<ogc:UpperBoundary>2016-12-31 23:59:59</ogc:UpperBoundary>
</ogc:PropertyIsBetween>
</ogc:And>
</ogc:Filter>
select "data_payload_id","data_payload_uri","instance_datetime","url","agency","platform_type","platform_id","platform_name","gaw_id","instrument_name","instrument_model","instrument_number","monthly_date","monthly_columno3","monthly_stddevo3","monthly_npts","daily_date","daily_wlcode","daily_obscode","daily_columno3","daily_stddevo3","daily_utc_begin","daily_utc_end","daily_utc_mean","daily_nobs","daily_mmu","daily_columnso2","latest_observation",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"data_payload_id" from (select * from totalozone order by instance_datetime ASC) as subquery where the_geom && ST_GeomFromText('POLYGON((-188.4375 -85.6754145866435,-188.4375 83.4403264952731,190.546875 83.4403264952731,190.546875 -85.6754145866435,-188.4375 -85.6754145866435))',4326) and ( ("instance_datetime" BETWEEN '1924-01-01 00:00:00' AND '2016-12-31 23:59:59')) limit 1 offset 0
select "data_payload_id","data_payload_uri","instance_datetime","url","agency","platform_type","platform_id","platform_name","gaw_id","instrument_name","instrument_model","instrument_number","monthly_date","monthly_columno3","monthly_stddevo3","monthly_npts","daily_date","daily_wlcode","daily_obscode","daily_columno3","daily_stddevo3","daily_utc_begin","daily_utc_end","daily_utc_mean","daily_nobs","daily_mmu","daily_columnso2","latest_observation",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"data_payload_id" from (select * from totalozone order by instance_datetime ASC) as subquery where the_geom && ST_GeomFromText('POLYGON((-85.6754145866435 -188.4375,-85.6754145866435 190.546875,83.4403264952731 190.546875,83.4403264952731 -188.4375,-85.6754145866435 -188.4375))',4326) and ((st_intersects(the_geom,ST_GeomFromText('POLYGON ((-85.6754145866435266 -188.4375000000000000, -85.6754145866435266 190.5468750000000000, 83.4403264952730694 190.5468750000000000, 83.4403264952730694 -188.4375000000000000, -85.6754145866435266 -188.4375000000000000))',4326)) = TRUE and ("instance_datetime" >= date_trunc('second',timestamp '1924-01-01 00:00:00') and "instance_datetime" <= (date_trunc('second',timestamp '2016-12-31 23:59:59') + interval '1 second' - interval '1 second')))) ORDER BY "instance_datetime"
I've got a test environment setup using total ozone data I nabbed off the web, looks like what you're using. I have instance_datetime set as a timestamp w/o timezone in PostgreSQL. Is that correct?
Anyway with 6.4.3 I get the following SQL from the MapServer log file:
select "gid","data_payload_id","instance_datetime_as_char","url","agency","platform_type","platform_id","platform_name","gaw_id","instrument_name","instrument_model","instrument_number","monthly_date","monthly_column03","monthly_stddev03","monthly_npts","daily_date","daily_wlcode","daily_obscode","daily_column03","daily_stddev03","daily_utc_begin","daily_utc_end","daily_utc_mean","daily_nobs","daily_mmu","daily_columns02","latest_obsevation","instance_datetime",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"data_payload_id" from (select * from totalozone order by instance_datetime) as subquery where the_geom && ST_GeomFromText("POLYGON((-188.4375 -85.6754145866435,-188.4375 83.4403264952731,190.546875 83.4403264952731,190.546875 -85.6754145866435,-188.4375 -85.6754145866435))",4326) and ( ("instance_datetime" BETWEEN 1924-01-01 00:00:00 AND 2016-12-31 23:59:59)) limit 1 offset 0
which of course pukes because the dates in the BETWEEN section aren't quoted. Any idea why that would be? I must be missing something in my mapfile. Am running the exact query you sent minus the GeoJSON output format. If I quote them properly in pgAdmin the query runs fine.