From: Sally Buechel [mailto:swbuec...@comcast.net]
Sent: Friday, September 13, 2013 3:39 PM
To: Fawcett, David (MNIT)
Subject: RE: [mapserver-users] problem with INTERSECTS query from OpenLayers to 
mapserver

Here are the POST queries output by OpenLayers and the wfs part of the mapfile 
its using if that helps (am also interested in confirming just that this 
general concept works, that someone is actually doing it successfully):


Example of the POST request for a non-spatial query which works

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs"; service="WFS" 
version="1.0.0" maxFeatures="50" xsi:schemaLocation="http://www.opengis.net/wfs 
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd<http://www.opengis.net/wfs%20http:/schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd>"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<wfs:Query typeName="feature:mytable">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc";>
<ogc:And>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>attr2</ogc:PropertyName>
<ogc:Literal>5</ogc:Literal>
</ogc:PropertyIsLessThan>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>attr3</ogc:PropertyName>
<ogc:Literal>78008</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:And>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

Example of the POST for the spatial INTERSECTS query which fails:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs"; service="WFS" 
version="1.0.0" maxFeatures="50" xsi:schemaLocation="http://www.opengis.net/wfs 
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd<http://www.opengis.net/wfs%20http:/schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd>"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<wfs:Query typeName="feature:mytable">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc";>
<ogc:And>
<ogc:Intersects>
<ogc:PropertyName>attr1</ogc:PropertyName>
<gml:Polygon xmlns:gml="http://www.opengis.net/gml"; srsName="EPSG:4326">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">-166.8375,69.723751831055 
-168.75,63.311251831055 -166.3875,60.273751831055 -160.3125,57.573751831055 
-155.5875,59.036251831055 -153.5625,62.748751831055 -156.6,66.911251831055 
-166.8375,69.723751831055</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ogc:Intersects>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>attr2</ogc:PropertyName>
<ogc:Literal>5</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:And>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

Response from failed Spatial query:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
root@localhost and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache Server at localhost Port 80</address>
</body></html>

Apache error log:
[Fri Sep 13 01:49:34 2013] [error] [client 127.0.0.1] Premature end of script 
headers: mapserv, referer: http://localhost/testol6_7w.html

WFS part of Mapfile (note this mapfile works using shp2img when a FILTER is 
added to it):

MAP

<clipped out part>
#
# Set up WFS layer for feeding data to OpenLayers front-end
LAYER
   NAME "mytable"
   TYPE Polygon
   STATUS ON
   DUMP true #added 8/13 can't remember if needed...
   CONNECTIONTYPE postgis
   CONNECTION "host='localhost' dbname='test' user='user1' port=5432"
   PROCESSING "CLOSE_CONNECTION=DEFER"
   # need geometry, doesn't work for geography trying to cast it
   # this worked for mapserver
   DATA "attr1 from mytable USING UNIQUE gid USING srid=4326"
   METADATA
     "wfs_title"   "My_WFS"
     "wfs_version" "1.0.0"
     "wfs_extent" "-180.00 -89.99 180.00 89.99"
     "gml_include_items" "all"
     "gml_featureid" "gid"
     "wfs_enable_request"  "*"
   END
   CLASS
      NAME 'Attr1'
      STYLE
          COLOR -1 -1 -1
          OUTLINECOLOR 0 255 0
      END
   END # end attr1 class
   PROJECTION
       "init=epsg:4326"
   END
END #query layer

END #end map


From: Fawcett, David (MNIT) [mailto:david.fawc...@state.mn.us]
Sent: Friday, September 13, 2013 12:15 PM
To: Sally Buechel; 
mapserver-users@lists.osgeo.org<mailto:mapserver-users@lists.osgeo.org>
Subject: RE: [mapserver-users] problem with INTERSECTS query from OpenLayers to 
mapserver

Sally,

To make it easier for people to help you figure this out, I would suggest 
including the request string produced by OpenLayers and your mapfile text.

David.

From: 
mapserver-users-boun...@lists.osgeo.org<mailto:mapserver-users-boun...@lists.osgeo.org>
 
[mailto:mapserver-users-boun...@lists.osgeo.org]<mailto:[mailto:mapserver-users-boun...@lists.osgeo.org]>
 On Behalf Of Sally Buechel
Sent: Friday, September 13, 2013 1:54 PM
To: mapserver-users@lists.osgeo.org<mailto:mapserver-users@lists.osgeo.org>
Subject: [mapserver-users] problem with INTERSECTS query from OpenLayers to 
mapserver

Am hoping someone can help or at least point me in the right direction 
regarding a problem I'm having trying to send a spatial filter produced in 
OpenLayers to mapserver.  What I'm trying to do is so basic, I'm sure that many 
have done this, yet I've been unsuccessful.  I thought this would be easy.  
With much searching I have found similar questions, but nothing actually 
answering or showing a working example of this.

I'm using mapserver 6.2.1 and the current OpenLayers.js.  I can run the wfs.map 
file using shp2img and get a valid response from mapserver, I can run 
non-spatial filters using my OpenLayers WFS call to mapserver.  The POST 
request sent to mapserver with the spatial query looks fine, but I simply get  
the not very helpful "premature end of script headers : mapserv" in response.  
The spatial input is a hand-drawn polygon in OpenLayers and the intersection at 
the mapserver end is a postgis table containing a polygon field.  The table is 
large, but a spatial restriction should always yield a manageable number of 
records.  Without a spatial restriction in the filter, I've noticed that 
mapserver tried to load all the data, so have currently restricted it to 100 
records for testing/debugging.  I'm assuming once I get the spatial filter that 
this will restrict the number of records retrieved on the server side.  I have 
some assumptions, but as I said I've not been able to find a working example of 
this online, maybe because its too simple and everyone but me has it working?

Should what I'm trying to do work or am I just beating my head against the 
wall?  It doesn't seem that this should be so hard...

Sally


_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to