Thursday 16 July 2015

postgresql - Why does Mapserver throw "msQueryByPoint(): Search returned no results."?


I have been trying to configure a QUERY using mapserver. Below is the mapfile:


 MAP
NAME "Fourth"
UNITS dd
EXTENT 58.206740 5.756104 104.793418 33.644106
SIZE 640 320
IMAGECOLOR 200 225 255

IMAGETYPE gif

FONTSET "C:\ms4w\Apache\htdocs\fontset.txt" # pointers to fonts


WEB
# A header/footer defined in a web object is displayed
# before/after any individual query response is made.
# It is displayed only once.
#

HEADER "C:/ms4w/Apache/htdocs/xxx/map/fourth_web_header.html"
FOOTER "C:/ms4w/Apache/htdocs/xxx/map/fourth_web_footer.html"

TEMPLATE "C:/ms4w/Apache/htdocs/xxx/map/fourth.html"
IMAGEPATH "C:/ms4w/Apache/htdocs/tmp/"
IMAGEURL "/tmp/"
END


LEGEND

IMAGECOLOR 255 255 255
STATUS ON
KEYSIZE 14 12
LABEL
TYPE BITMAP
SIZE SMALL
COLOR 0 0 89
END
END


QUERYMAP
STATUS on # draw query map
STYLE hilite # highlight selected feature
COLOR 255 255 0 # in yellow
SIZE 320 160
END

SYMBOL

NAME "circle"

TYPE ellipse # Type of symbol

POINTS
1 1
END # end of POINTS

FILLED true
END



LAYER
NAME 'growth_1'
TYPE POINT
DUMP true
TEMPLATE fooOnlyForWMSGetFeatureInfo
# A header or footer defined at the layer level is displayed
# if that layer is a query layer. It is displayed only once.
#
HEADER "C:/ms4w/Apache/htdocs/xxx/map/fourth_cities_header.html"
FOOTER "C:/ms4w/Apache/htdocs/xxx/map/fourth_cities_footer.html"


TOLERANCE 1 # must be within 1 tolerance unit
TOLERANCEUNITS miles # units for tolerance values is miles

EXTENT 58.206740 5.756104 104.793418 33.644106
CONNECTIONTYPE postgis
CONNECTION "dbname='postgis' host=localhost port=5432 user='postgres' password='xxxxxxx' sslmode=disable"
DATA 'the_geom FROM "growth_1" USING srid=4326'
METADATA
'ows_title' 'growth_1'

END
STATUS ON
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'datum=WGS84'
'no_defs'
END



CLASSITEM 'growth_scale'
CLASS
NAME "growth_scale = BAD"
EXPRESSION "BAD"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 242 115 240
END

END
CLASS
NAME "growth_scale = EXCELLENT"
EXPRESSION "EXCELLENT"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 53 116 77
END

END
CLASS
NAME "growth_scale = FAIR"
EXPRESSION "FAIR"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 92 200 4
END

END
CLASS
NAME "growth_scale = GOOD"
EXPRESSION "GOOD"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 94 8 202
END

END
CLASS
NAME "growth_scale = MARGINALLY BAD"
EXPRESSION "MARGINALLY BAD"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 252 63 172
END

END
CLASS
NAME "growth_scale = NO DATA"
EXPRESSION "NO DATA"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 22 79 25
END

END
CLASS
NAME "growth_scale = POOR"
EXPRESSION "POOR"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 86 98 176
END

END
CLASS
NAME "growth_scale = VERY GOOD"
EXPRESSION "VERY GOOD"
STYLE
SYMBOL "circle"
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR 189 72 76
END



CLASS
# A template defined at the class level is used to display
# the results for each reponse to a query. If a result set
# contains N, then the template will be used N times.
#
TEMPLATE "C:/ms4w/Apache/htdocs/xxx/map/fourth_cities_query.html"
STYLE
COLOR 0 0 0 # symbol color is black

END

END


END

END

But then when I go the query mode I get the following error:



msQueryByPoint(): Search returned no results. No matching record(s) found.


Any idea on why such an error message


Now from today morning I get this window but the attribute is not populated. enter image description here


The following is the query template


  
Layer:growth_1
[lrn]
[code]
[address]
[latitude]

[longitude]
bbbbb
scale
oid

Answer



First of all a few doc pointers


The mapserver documentation addresses this error at:


http://mapserver.org/errors.html#msreturnpage-web-application-error-malformed-template-name


For an explanation of url templates see this doc.


Answer



It seems like you are now a GetFeatureInfo query and using a fooOnlyForWmsGetFeatureInfo template which is missing the proper extension.


The list of allowed extensions is documented in the code here:


https://github.com/mapserver/mapserver/blob/master/mapserver.h#L245


So basically you have edit the mapfile so that this section:


  LAYER
NAME 'growth_1'
TYPE POINT
DUMP true
TEMPLATE fooOnlyForWMSGetFeatureInfo


becomes:


  LAYER
NAME 'growth_1'
TYPE POINT
DUMP true
TEMPLATE path/to/your_template.html

Final note


BTW, your template contains invalid html:





should be:



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...