2

I am trying to load a layer from a postgis database, MapServer does not return anything. I think I have narrowed the problem down to the fact that the SQL query MapServer is running is returning nothing. Does anyone have any idea why this might be?

Mapfile:

MAP
  CONFIG "MS_ERRORFILE" "/srv/portal/www/Mapservices/mapfiles/maplog.txt"
  debug 5
  EXTENT 506599.271346329 5962705.19473941 526000.205491952 5988176.64534367
  IMAGETYPE PNG
  SIZE 1600 800
  IMAGECOLOR 255 0 1 
  STATUS ON
  WEB
      METADATA
        "wms_title" "TSA-Zones-WMS"
        "wms_onlineresource" "http://{ip}/cgi-bin/mapserv?map=/srv/portal/www/Mapservices/mapfiles/TSAZones.map&version=1.0.0&service=wms"
        "wms_srs" "EPSG:3005 EPSG:4269 EPSG:3857"
        "wms_enable_request" "*"
        "wms_feature_info_mime_type" "text/html"
      END
      QUERYFORMAT text/html
  END
  PROJECTION
    "init=epsg:3005"
  END
  OUTPUTFORMAT
    NAME png
    DRIVER AGG/PNG
    MIMETYPE "image/png"
    IMAGEMODE RGBA
    EXTENSION "png"
    FORMATOPTION "GAMMA=0.75"
    TRANSPARENT ON
  END  
  LAYER
    debug 5
    NAME TSA_Zones
    PROJECTION
        "init=epsg:3005"
    END  
    METADATA
        "wms_srs" "EPSG:3005"
        "title" "TSA Zones"
        "wms_title" "TSA Zones"
        "wms_include_items" "all" 
        "gml_include_items" "all"           
    END
    STATUS OFF
    TYPE POLYGON
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=127.0.0.1 dbname=mapdb user=postgres password=postgres"
    DATA "geom from pgpoly"  
    OPACITY 100
        CLASS
            STYLE
                COLOR 200 200 200 
                OUTLINECOLOR 0 0 0
            END
        END
    END
END

Mapserver log file:

[Fri May 29 10:47:22 2015].637637 CGI Request 1 on process 13779
[Fri May 29 10:47:22 2015].638512 msPostGISLayerOpen called: geom from pgpoly
[Fri May 29 10:47:22 2015].638529 msPostGISLayerOpen: No connection in pool, creating a fresh one.
[Fri May 29 10:47:22 2015].680970 msConnPoolRegister(TSA_Zones,host=127.0.0.1 dbname=mapdb user=postgres password=postgres,0xa2e2658)
[Fri May 29 10:47:22 2015].680989 msPostGISLayerFreeItemInfo called.
[Fri May 29 10:47:22 2015].681031 msPostGISLayerWhichShapes called.
[Fri May 29 10:47:22 2015].681038 msPostGISParseData called.
[Fri May 29 10:47:22 2015].681059 msPostGISRetrievePK called.
[Fri May 29 10:47:22 2015].681069 msPostGISRetrievePK: select attname from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid = pg_class.oid and pg_class.oid = pg_attribute.attrelid and pg_constraint.contype = 'p' and pg_constraint.conkey[1] = pg_attribute.attnum and pg_class.relname = 'pgpoly' and pg_table_is_visible(pg_class.oid) and pg_constraint.conkey[2] is null
[Fri May 29 10:47:22 2015].684293 msPostGISParseData: unique_column=id, srid=, geom_column_name=geom, table_name=pgpoly
[Fri May 29 10:47:22 2015].684308 msPostGISBuildSQL called.
[Fri May 29 10:47:22 2015].684317 msPostGISBuildSQLItems called.
[Fri May 29 10:47:22 2015].684323 msPostGISBuildSQLItems: 0 items requested.
[Fri May 29 10:47:22 2015].684328 msPostGISBuildSQLFrom called.
[Fri May 29 10:47:22 2015].684333 msPostGISBuildSQLWhere called.
[Fri May 29 10:47:22 2015].684337 msPostGISBuildSQLSRID called.
[Fri May 29 10:47:22 2015].684340 msPostGISBuildSQLSRID: Building find_srid line.
[Fri May 29 10:47:22 2015].684344 msPostGISBuildSQLSRID: Found table (pgpoly)
[Fri May 29 10:47:22 2015].684349 msPostGISBuildSQLBox called.
[Fri May 29 10:47:22 2015].684391 msPostGISLayerWhichShapes query: select encode(AsBinary(force_collection(force_2d("geom")),'NDR'),'hex') as geom,"id" from pgpoly where geom && GeomFromText('POLYGON((9783.93962050256 -4999593.14607681,9783.93962050256 -9783.93962050349,4999593.14607681 -9783.93962050349,4999593.14607681 -4999593.14607681,9783.93962050256 -4999593.14607681))',find_srid('','pgpoly','geom'))
[Fri May 29 10:47:22 2015].695342 msPostGISLayerWhichShapes query status: PGRES_TUPLES_OK (2)
[Fri May 29 10:47:22 2015].695355 msPostGISLayerWhichShapes got 0 records in result.
[Fri May 29 10:47:22 2015].695369 msPostGISLayerNextShape called.
[Fri May 29 10:47:22 2015].695374 msPostGISLayerFreeItemInfo called.
[Fri May 29 10:47:22 2015].695378 msPostGISLayerClose called: geom from pgpoly
[Fri May 29 10:47:22 2015].695382 msConnPoolRelease(TSA_Zones,host=127.0.0.1 dbname=mapdb user=postgres password=postgres,0xa2e2658)
[Fri May 29 10:47:22 2015].695389 msConnPoolClose(host=host=127.0.0.1 dbname=mapdb user=postgres password=postgres,0xa2e2658)
[Fri May 29 10:47:22 2015].695559 msDrawMap(): Layer 0 (TSA_Zones), 0.057s
[Fri May 29 10:47:22 2015].695578 msDrawMap(): Drawing Label Cache, 0.000s
[Fri May 29 10:47:22 2015].695585 msDrawMap() total time: 0.058s
[Fri May 29 10:47:22 2015].708344 msSaveImage() total time: 0.013s
[Fri May 29 10:47:22 2015].708431 mapserv request processing time (msLoadMap not incl.): 0.071s
[Fri May 29 10:47:22 2015].708444 msFreeMap(): freeing map at 0xa226e28.
[Fri May 29 10:47:22 2015].708449 msPostGISLayerClose called: geom from pgpoly
[Fri May 29 10:47:22 2015].708464 freeLayer(): freeing layer at 0xa22e898.
[Fri May 29 10:47:22 2015].708468 msPostGISLayerIsOpen called.
  • From the log select encode(AsBinary(force_collection(force_2d("geom")),'NDR'),'hex') as geom,"id" from pgpoly where geom && GeomFromText('POLYGON((9783.93962050256 -4999593.14607681,9783.93962050256 -9783.93962050349,4999593.14607681 -9783.93962050349,4999593.14607681 -4999593.14607681,9783.93962050256 -4999593.14607681))',find_srid('','pgpoly','geom')) result: msPostGISLayerWhichShapes got 0 records in result. Usually that means some problem with projection or extent. Try first to add USING SRID into your data. – user30184 May 29 '15 at 20:48
  • in the title you say MapServer returns a blank image, but in the question it says MapServer returns nothing, which is it? The former indicates an error with the data or request, the latter with the configuration, or with MapServer itself. – nmtoken Nov 20 '16 at 15:51

Your Answer

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

Browse other questions tagged or ask your own question.