[Chameleon] RE: LocateByAttribute and WebGIS Analysis

Delfos, Jacob Jacob.Delfos at maunsell.com
Thu May 10 03:20:02 EDT 2007


Hi Ilham,
 
To support multiple (any number) of criteria would be more DHTML than
PHP work, because of having to support any number of search fields. It
could be done, but at this stage I can't afford the time to do it.
By default it does a case-insensitive "string contains". I don't really
see much value in changing that. I don't want to add clutter with
controls that nobody would use, such as a "case sensitive" checkbox.
 
There is another way to achieve multiple-attribute query, however. When
MapServer does a PostGIS query, it does not actually hardcode the
attribute name, which makes it possible to put in any "WHERE" syntax
that PostGIS allows. To take advantage of this, make these changes to
searchlayers.phtml
 
on line 326-333 of searchresults.phtml, replace these lines:
 
   if (!(is_numeric($searchstring)))
   {
   [...]
   }
 
with:
 
         if (strpos($searchstring,"=") === false) // allow use of
postgis functions for anything that sits between [ ], else do string
comparison
         {
            if (!(is_numeric($searchstring)))
            {
            $searchstring = Chr(34)."Lower(".$searchfield.") like
'%".strtolower($searchstring)."%'".Chr(34); // additional quotes due to
PostGIS related bug
            }
            else
            {
            $searchstring = $searchfield."=".$searchstring;
            }
         }
         else
         {
         $searchstring = Chr(34).substr($searchstring, 1,
strlen($searchstring)-1).Chr(34);
         }
 
 
By doing this, a user can specify a multi-attribute query by preceding
it with an equals sign. For example, you could use this as a search
string:
 
=color like 'blue' AND number=5 AND (date>'1 oct 2006' OR date<'1 oct
2004')
 
This is not a clean solution, but hopefully an acceptable compromise.
 
regards,
 
Jacob
 


________________________________

	From: Ilham Adi Afdillah [mailto:ilham.adi at gmail.com] 
	Sent: 10 May 2007 09:15
	To: Delfos, Jacob
	Cc: chameleon at lists.maptools.org
	Subject: LocateByAttribute and WebGIS Analysis
	
	
	Hi Jacob and list,
	 
	Jessica Fendos (on Wed Mar 21 16:48:17 2007) may have ask
this(first) questions.
	1. I try to add more field for the other criteria of my query
(multiple query),
	For the example : 
	First Criteria : I want the user can search on LAYER1 from field
SIZE, then they input the size of the area in text field, 
	and the second criteria : I want the user can search on same
layer (LAYER1) from field TYPE then they input blabla.. in text field.
	so the result will match that 2 criteria.
	Can you tell me the step by step to realize this, because I'm
not really good enough in php?. 

	2. is that query on LocateByAttribute use SQL operators 'AND' by
default or if I have to change it by myself, which file/line should I
change to get the multiple query result that using 'AND' SQL operators.
I need to add it if the first question can be realize. Because I'm feel
it will can be used to GIS Analysis on the web. 

	3. How Can I used the 'Match Case' and/or 'Macth Word Only' in
the LocateByAttribute widget.

	Note : I store data in PostGIS/PostgreSQL

	 

	Best Regards,

	 

	Ilham Adi A.



This email and any attachments are intended solely for the named recipient and are confidential. The copying or distribution of them or any information they contain by anyone other than the named recipient is prohibited. If you have received this document in error, please notify the sender and delete all copies from your computer system and destroy all hard copies. It is the recipient's responsibility to check this email and any attachments to this email for viruses before use.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/chameleon/attachments/20070510/e6b8dffb/attachment-0001.html


More information about the Chameleon mailing list