Complex query on Shapefiles attributes

Peter H.M. Jacobs peter.jacobs at vs42.nl
Fri Feb 18 11:57:32 EST 2000


Hello Brian,

what you want is to my opinion exactly the same question as I posed a couple
of days ago. The only difference is that I want to highlite just one street
and you want to highlite several polygons. This makes it a bit more
difficult.

My question and answer were the following:


This is the case:
A user enters the name of a streetin a textbox. I query the street in the
following layer with an item/value itemquery and send the result back to
mapserv to create a map with the street in te center of the new map. Finally
I want to mark that street. I thought to do this with these two layers.

LAYER
   NAME QueryLayer18Text # Straatnamen doorlopende wegen
   TYPE ANNOTATION
   STATUS QUERYONLY
   DATA Layer18Text
   QUERYITEM "TEXTSTRING"
   QUERY
     TEMPLATE
"http://../?map=/sites/../delft.map&mode=browse&scale=3000&mapxy=[shpmid]&va
lue=[value]"
   END
END


LAYER
   NAME Layer18Text # Straatnamen doorlopende wegen
   TYPE ANNOTATION
   STATUS DEFAULT
   DATA Layer18Text
   MAXSCALE 12000
   LABELITEM "TEXTSTRING"
   LABELANGLEITEM "TEXT_ANGLE"
   LABELSIZEITEM "TEXT_SIZE"
   CLASSITEM "TEXTSTRING"
   CLASS
     NAME SELECTED
     EXPRESSION ([TEXTSTRING] eq [value])
     SYMBOL 0
     COLOR 0 0 0
     LABEL
        ANTIALIAS
        COLOR 0 0 0
        FONT arial
	  TYPE TRUETYPE
        SIZE 20
        POSITION UR
     END
   END
   CLASS
	NAME NOTSELECTED
	EXPRESSION /./ #the rest
   ...
   END
END

This was the reaction I recieved from Stephen.

Peter and all... At issue here is making queries persistant. An interesting
problem. The current version allows you to tackle the problem 2 ways:

 1) save the item and value as hidden variables
    and use mode=itemquery with a query map

This works but is difficult to use. It actually pretty easy but is not well
documented and lightly tested.

  2. use the [shpmidx] and [shpmidy] to define an
     inline feature in the query object TEMPLATE
     url for the 1st (item/value). Then save that
     feature (and text if necessary) using hidden
     vars in the main pan/zoom template.

To do this your template after the item/value query would contain something
like this:


...map_streetmarker_feature_points=[shpmidx]+[shpmidy]&map_streetmarker_feat
ure_text=some text that is escaped...

This assumes you have a layer called "streetmarker" at the end of your
mapfile (so it'll be drawn and labeled for sure).

Again, this method works and I do have examples where a point is added to
the map in this manner. Problem is that it is really hard to use with more
than one feature. You can use javascript but it ain't easy. In Peters case I
believe this is the
best method.

It ain't perfect. Know, before everyone goes "well, that sucks" I believe I
have a solution to this problem, at least in part. Version 3.3.008 will
allow you to save/load query results so they can be made persistant. For
example, in Peters case the itemvalue query could be saved and the name of
the saved query could be passed to the map generation call for the
mapserver. Instead of simply drawing the map normally, the def for querymap
would be used and the matching road might show up in yellow. It's still in
development but it looks promising.

---
Because you, Brian, want to create a map with several spots highlited, I
think you have to use the querymap. I found some help about the use of the
querymap in one of the articles posted by Ken Boss (december 1999)
I'm sorry I can't give you the solution, but perhaps this will help

Regards,

Peter





More information about the mapserver-users mailing list