Documentation ¶
Overview ¶
Package mapquery provides a Query object suitable to send search queries from the map aspect of the web UI. It is not concurrent safe.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteZoomPredicate ¶
DeleteZoomPredicate looks for a "map:" predicate in expr, and if found, removes it.
func HasZoomParameter ¶
HasZoomParameter returns whether queryString is the "q" parameter of a search query, and whether that parameter contains a map zoom (map predicate).
Types ¶
type Query ¶
type Query struct { // AuthToken is the token for authenticating with Camlistore. AuthToken string // Expr is the search query expression. Expr string // Limit is the maximum number of search results that should be returned. Limit int // Callback is the function to run on the JSON-ified search results, if the search // was successful. Callback func(searchResults string) // Cleanup is run once, right before Callback, or on any error that occurs // before Callback. Cleanup func() // contains filtered or unexported fields }
Query holds the parameters for the current query.
func (*Query) GetExpr ¶
GetExpr returns the search expression of the query.
func (*Query) GetZoom ¶
func (q *Query) GetZoom() *camtypes.LocationBounds
GetZoom returns the location area that was requested for the last successful query.
func (*Query) Send ¶
func (q *Query) Send()
Send sends the search query, and runs the Query's callback on success. It returns immediately if there's already a query in flight.
func (*Query) SetZoom ¶
SetZoom modifies the query's search expression: it uses the given coordinates in a map predicate to constrain the search expression to the defined area, effectively acting like a map zoom.
The map predicate is defined like locrect, and it has a similar meaning. However, it is not defined server-side, and it is specifically meant to represent the area of the world that is visible in the screen when using the map aspect, and in particular when zooming or panning. As such, it follows stricter rules than the other predicates, which are:
1. only one map predicate is allowed in the whole expression. 2. since the map predicate is interpreted as if it were a logical 'and' with the rest of the whole expression (regardless of its position within the expression), logical 'or's around it are forbidden.
The map predicate is also moved to the end of the expression, for clarity.