[mapserver-users] Problem with Python MapScript queryByRect

Just van den Broecke justb4 at gmail.com
Sun Jun 28 03:20:21 PDT 2020


Solved, there was some kind of mismatch probably with library versions 
from multi-stage Docker builds/copies.

Made a new Dockerfile from buster-slim with standard Mapserver (7.2.2 ) 
and Lighttpd and apart from some new MapScript syntax, all works!

The Dockerfile is nice and small (296MB uncompressed), works 
out-of-the-box with FastCGI/WSGI, albeit somewhat older MS version:
https://github.com/justb4/mapglow/blob/master/Dockerfile

Best,

Just


On 27-06-20 15:08, Just van den Broecke wrote:
> I got somewhat further: it appears I get a SEGFAULT when calling any 
> MapScript query() method. This is also what FastCGI receives (signal 11).
> 
> For example, bash-ing into the Docker Container and execute MapScript 
> Python:
> 
> $ python
> Python 2.7.16 (default, Oct 10 2019, 22:02:15)
> [GCC 8.3.0] on linux2
>  >>> import mapscript
>  >>> map = mapscript.mapObj('/app1/config/mapserver/app1.map')
>  >>> layer = map.getLayerByName('nlpubs')
>  >>> layer.name
> 'nlpubs'
>  >>> len(layer.metadata)
> 0
>  >>> res = layer.queryByAttributes(map, 'Name', 'Lef', 
> mapscript.MS_MULTIPLE)
> Segmentation fault
> 
> But getting number of Features is ok:
>  >>> layer.getNumFeatures()
> GNM: GNMRegisterAllInternal
> GNM: RegisterGNMFile
> GNM: RegisterGNMdatabase
> GDAL: GDALOpen(/app1/data/pubs, this=0x557ace611b90) succeeds as ESRI 
> Shapefile.
> Shape: DBF Codepage = LDID/87 for /app1/data/pubs/osm-nl-pub.shp
> Shape: Treating as encoding 'ISO-8859-1'.
> GDAL: GDALClose(/app1/data/pubs, this=0x557ace611b90)
> 2864
> 
> The LAYER def is
> LAYER
>      NAME nlpubs
>      STATUS default
>      TYPE POINT
>      PROJECTION
>        "init=epsg:4326"
>      END
> 
>      METADATA
>          "wfs_title"         "NL Pubs from OSM POIs"
>          "wfs_version"     "1.1.0"
>          "wfs_extent"     "4 50 6 54"
>          "wfs_bbox_extended"     "true"
>          "wfs_enable_request"    "*"
>          "wfs_srs"         "epsg:4326 epsg:3857 epsg:900913"
>          "wfs_include_items"     "all"
>          "gml_include_items"     "all"
>          "gml_geometries"        "geom"
>          "wms_title"             "NL Pubs from OSM POIs"
>          "wms_srs"         "epsg:4326 epsg:3857 epsg:900913"
>          "wms_extent"     "4 50 6 54"
>          "wms_feature_info_mime_type" "text/xml"
>          "mapglow_feat_density"     "0.002"
>     END
> 
>      CONNECTIONTYPE OGR
>      CONNECTION "/app1/data/pubs"
>      DATA "osm-nl-pub"
>      TEMPLATE "/app1/config/mapserver/template.html"
> 
>      CLASS
>        NAME "osm-nl-pub"
>        STYLE
>          COLOR 0 102 204
>          SYMBOL "circle"
>          SIZE 10
>        END
>      END
> END
> 
> Data is a shapefile, but GeoJSON also fails. Also strange that 
> layer.metadata is empty. Like said when I delegate any incoming OWS req 
> to map.OWSDispatch() I get proper results for all WMS requests, in 
> particular GetMap with styled output.
> The base Dockerfile used is at:
> https://github.com/PDOK/mapserver-docker/blob/master/Dockerfile from
> which I derived my Dockerfile:
> https://github.com/justb4/mapglow/blob/master/Dockerfile
> 
> Maybe there is some mismatch in lib versions?
> 
> Again thanks. Best,
> 
> Just van den Broecke
> 
> On 26-06-20 17:55, Just van den Broecke wrote:
>> Hi,
>>
>> I am reviving a Python 2 MapServer MapScript app that used to work 7 
>> years ago (and still is in old deployment) but stuck in some MapScript 
>> calls that fail but also throw no Exceptions.
>>
>> Purpose of the app "MapGlow" [1] is to generate a WMS-heatmap 
>> triggered by specific STYLE parameters. When no heatmap STYLE is 
>> requested requests are delegated to map_file.OWSDispatch() etc. The 
>> latter works fine so the overall setup/stack/mapfile is working. Using 
>> MS 7.6.0 in Docker (compose) with Lighttp, FastCGI, WSGI, flup.
>>
>> It is only when  layerObj.queryByRect() is called, a HTTP 500 is 
>> returned after a FastCGI hard error, no means to catch an Exception. 
>> The passed MapFile and Rect objects seem ok. Also I noticed that 
>> layerObj.metadata had 0 items. I can see that I have proper SWIG 
>> objects like
>> <mapscript.layerObj; proxy of <Swig Object of type 'layerObj *' at 
>> 0x7fded06b1de0> >
>> If only I could get a hint, a MapFile setting, maybe some log output 
>> or debug flag I can set? The WIP is on GH, I can point at the failing 
>> line [2] but the code is
>> quite involved (mind, my first Python 7-9 years ago):
>>
>> [1] https://github.com/justb4/mapglow
>> [2] 
>> https://github.com/justb4/mapglow/blob/master/app1/wms/mapglow_ms.py#L249
>>
>> Thanks for any help,
>>
>> Just van den Broecke
>> The Netherlands
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list