Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Query

JMap.Query

A feature query mecanism has been set in JMap to get filtered features.

By example we can get all features that have an attribute equals to a given value.

A query concerns a single layer, and it set a data form that will be filled by users to make a search.

For a given project, a JMap administrator can create query groups and put inside all queries he wants, not depending on a particular layers.

You can get queries definitions (including the form definition) and process a query from this section.

Index

Functions

fetchFeatures

  • fetchFeatures(layerId: JId, queryId: string, data: any): Promise<any[]>
  • JMap.Query.fetchFeatures

    Process a query request to the JMap server, for given layer and query ids, and provided form data

    throws

    if group or query ids are not correct (invalid format or no resource exists)

    example
    
    // returns a promise that when resolved returns the result of the search,
    // an array of features, for layer id=3 and query id=5.
    JMap.Query
      .fetchFeatures(3, 5, {
       "$PARAM1": "test",
       "$PARAM2": 35
      })
      .then(features => console.info(`Found ${features.length} features.`))
      .catch(error => console.error("Error while processing query request.", error))

    Parameters

    • layerId: JId

      The JMap layer id

    • queryId: string

      The JMap query id

    • data: any

      The form data (values mapping the query form definition)

    Returns Promise<any[]>

getAllGroups

  • JMap.Query.getAllGroups

    Returns all query groups defined by JMap administrator.

    example
    
    // returns all query groups defined by JMap administrator
    JMap.Query.getAllGroups()

    Returns JQueryGroup[]

getQueriesByGroupId

  • getQueriesByGroupId(groupId: JId): JQuery[]
  • JMap.Query.getQueriesByGroupId

    Returns all queries for a given query group id.

    throws

    if group id is not correct (invalid format or no resource exists)

    example
    
    // returns all queries of group id=10
    JMap.Query.getQueriesByGroupId(10)

    Parameters

    • groupId: JId

      The JMap query group id

    Returns JQuery[]

getQueriesByLayerId

  • getQueriesByLayerId(layerId: JId): JQuery[]
  • JMap.Query.getQueriesByLayerId

    Returns all queries defined for a given layer id.

    throws

    if layer id is not correct (invalid format or no resource exists)

    example
    
    // returns all queries of layer id=12
    JMap.Query.getQueriesByLayerId(12)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns JQuery[]

getQueryByGroupId

  • getQueryByGroupId(groupId: JId, queryId: string): JQuery
  • JMap.Query.getQueryByGroupId

    Returns the query for a given query group and a given query id.

    throws

    if group or query ids are not correct (invalid format or no resource exists)

    example
    
    // returns the query id=5 of group id=10
    JMap.Query.getQueryByGroupId(10, 5)

    Parameters

    • groupId: JId

      The JMap query group id

    • queryId: string

      The JMap query id

    Returns JQuery

getQueryByLayerId

  • getQueryByLayerId(layerId: JId, queryId: string): JQuery
  • JMap.Query.getQueryByLayerId

    Returns a query for a given query id, and a given layer id.

    throws

    if layer or query ids are not correct (invalid format or no resource exists)

    example
    
    // returns query id=3 of layer id=12
    JMap.Query.getQueryByLayerId(12, 3)

    Parameters

    • layerId: JId

      The JMap layer id

    • queryId: string

      The JMap query id

    Returns JQuery

groupExist

  • groupExist(groupId: JId): boolean
  • JMap.Query.groupExist

    Returns true if group exists, else false, for the given group id.

    throws

    if group id is not correct (invalid format or no resource exists)

    example
    
    // returns true if group exists
    JMap.Query.groupExist(21)

    Parameters

    • groupId: JId

      The JMap query group id

    Returns boolean

initializeQueryFormById

  • initializeQueryFormById(layerId: JId, queryId: string): Promise<JQuery>
  • JMap.Query.initializeQueryFormById

    By default attribute query forms are not fetched from server, because sometime it takes too much time.

    This method will fetch the query form.

    example
    
    // initializes query id="layers/2/attribute-queries/3" form of layer id=2, then returns the filled query
    JMap.Query.initializeQueryFormById(2, "layers/2/attribute-queries/3")
     .then(query => console.log("Query form has been loaded", query))
     .catch(error => console.error("An error occured while loading query id='layers/2/attribute-queries/3'"))

    Parameters

    • layerId: JId

      the JMap layer id

    • queryId: string

      the query id

    Returns Promise<JQuery>

queryExist

  • queryExist(groupId: JId, queryId: string): boolean
  • JMap.Query.queryExist

    Returns true if the query exists for a given query group and a given query id.

    example
    
    // returns true if query id=5 of group id=10 exists
    JMap.Query.queryExist(10, 5)

    Parameters

    • groupId: JId

      The JMap query group id

    • queryId: string

      The JMap query id

    Returns boolean