camlistore.org: camlistore.org/server/camlistored/ui/goui/mapquery Index | Files

package mapquery

import "camlistore.org/server/camlistored/ui/goui/mapquery"

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

Package Files

mapquery.go

func DeleteZoomPredicate Uses

func DeleteZoomPredicate(expr string) string

DeleteZoomPredicate looks for a "map:" predicate in expr, and if found, removes it.

func HasZoomParameter Uses

func HasZoomParameter(queryString string) bool

HasZoomParameter returns whether queryString is the "q" parameter of a search query, and whether that parameter contains a map zoom (map predicate).

func New Uses

func New(authToken string, expr string,
    callback func(searchResults string),
    cleanup func()) *js.Object

New returns a new query as a javascript object, or nil if expr violates the rules about the zoom (map:) predicate. See SetZoom for the rules.

func ShiftZoomPredicate Uses

func ShiftZoomPredicate(expr string) string

ShiftZoomPredicate looks for a "map:" predicate in expr, and if found, moves it at the end of the expression if necessary.

type Query Uses

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 Uses

func (q *Query) GetExpr() string

GetExpr returns the search expression of the query.

func (*Query) GetZoom Uses

func (q *Query) GetZoom() *camtypes.LocationBounds

GetZoom returns the location area that was requested for the last successful query.

func (*Query) Send Uses

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) SetLimit Uses

func (q *Query) SetLimit(limit int)

func (*Query) SetZoom Uses

func (q *Query) SetZoom(north, west, south, east float64)

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.

Package mapquery imports 9 packages (graph) and is imported by 1 packages. Updated 2018-01-02. Refresh now. Tools for package owners.