GeoServer-js is a toolset designed to make accessing and querying a GeoServer instance much more user friendly.
For the time being GeoServer-js is dependant on Tile5
-
GEOSERVER.cql.parseCQL(query, params)
- Takes the query json and params and returns an array of cql queries
- params : {
maxPoints : 50
}
- params : {
maxPoints : 50
- Takes the query json and params and returns an array of cql queries
-
GEOSERVER.ogc.parseOGC(query)
- Takes the query json and returns an array with a single value which is the ogc filter
-
GEOSERVER.buildRequest(requestParams, params, json, callback)
-
Returns an array of objects, each of which is the querystring portion of the geoserver request.
-
requestParams : { service: 'WFS', version: '1.1.0', request: 'GetFeature', maxFeatures: 200, outputFormat: 'json', typeName : null, propertyName : } typeName must be specified
-
params : { queryType: "ogc", maxPoints: undefined }
queryType can either be ogc, which returns an xml-type filter or cql which returns a sql type filter - If the type is ogc an array of one will be returned, cql can be any length
- json - The json to be transformed into a cql query
- callback - The function to handle the returned array
-
-
Chained query example
{
operator: 'AND',
conditions: [{
"type": "like",
"args": {
"property": "Name",
"value": "Cottage"
}
}, {
type: 'compound',
args: {
operator: 'OR',
conditions: [{
"type": "like",
"args": {
"property": "Name",
"value": "Hotel"
}
}, {
"type": "spatial.bbox",
"args": {
"property": "the_geom",
"min": "-28.96 138.08",
"max": "-10.27 153.59"
}
}, {
type: 'compound',
args: {
operator: 'OR',
conditions: [{
"type": "like",
"args": {
"property": "Name",
"value": "Hotel"
}
}, {
"type": "spatial.bbox",
"args": {
"property": "the_geom",
"min": "-28.96 138.08",
"max": "-10.27 153.59"
}
}]
}
}]
}
}
This returns the following : (Name LIKE '%Cottage%' AND (Name LIKE '%Hotel%' OR BBOX(the_geom, -28.96, 138.08, -10.27, 153.59) OR (Name LIKE '%Hotel%' OR BBOX(the_geom, -28.96, 138.08, -10.27, 153.59))))