Geoserver users often use the cql_filter parameter. You can use this library in your javascript codebase. It is convenient and easy a library. A good start for developers who want to improve.
- Jquery used for get values DOM
- json-viewer for View json data
- jquery-tagsinput for add multi values
- jquery.alertable for show the alerts
- Bootstrap 4 for Visual HTML
You may have information about libraries using links!
Basic Usage
var model = {id:{type:"integer"},name:{type:"string"},...};
var cqlFilter = new cql_filter(model);
cqlFilter.addCQLPart('id','=',[23124],'AND');
cqlFilter.addCQLPart('name','!=',['Turkey'],'');
var CQL_string = cqlFilter.getCql(cqlFilter.cqls,"");
// id = 23124 AND name != 'Turkey'
About Methods
-
Class Name : cql_filter Parameter : model | type : object Return : this About : This is Global Class Name
-
Method Name : setModel Parameter : model | type : object Return : this About : Setting new DB Table Model to your cql_filter class
-
Method Name : getModel Parameter : null Return : model | type : object About : Getting already exist DB Table Model at your cql_filter class
-
Method Name : getOperators Parameter : type | string - [string, integer, float, boolean, date, polygon, polyline, point] Return : operators, type : object Array About : Getting cql_filter operators.
-
Method Name : getOperatorsByColumnName Parameter : ColumnName | string - [id, name, geoloc, etc] Return : operators, type : object Array About : Getting cql_filter operators.
-
Method Name : getTypeByColumnName Parameter : ColumnName | string - [id, name, geoloc, etc] Return : Column Data Type , type : string About : Getting Column's data type.
-
Method Name : addCQLPart Parameter : id or time (integer) Return : this About : for delete exist cql query.
-
Method Name : deleteCQLPart Parameter : ColumnName:string, operator:string, values:array, andor:string, id or time (integer) Return : this About : for add a new query.
-
Method Name : getCQLString Parameter : null Return : cqlString - ID=1231 AND name LIKE '%ali%' About : for getting cql_filter string.
-
Method Name : openParentheses Parameter : null Return : this About : Used to open parentheses
-
Method Name : closeParentheses Parameter : null Return : this About : Used to close parentheses
-
Method Name : getCQLArray Parameter : null Return : cql_array About : getting cql_array objects, columnName, operator, values, cql_string, time and "AND, OR",
About Public Variable
-
Method Name : dataTypes Return : object Data : [integer, string, float, boolean, date, point, polyline, polygon]
-
Method Name : operators['dataType'] Return : object Data : [=, !=, LIKE %...%, LIKE %..., LIKE ...%, NOT LIKE %...%, NOT LIKE %..., NOT LIKE ...%, IN, NOT IN, IS NULL, IS NOT NULL, <>, >, >=, <, <=, BETWEEN, NOT BETWEEN, BEFORE, AFTER]
-
Method Name : Spatial Query Operators['dataType'] Return : object Data : [INTERSECTS, DISJOINT, CONTAINS, WITHIN, TOUCHES, CROSSES, OVERLAPS, EQUALS, RELATE, DWITHIN, BEYOND, BBOX]
Familiar Queries
- ID = 23091989
- ID != 2345
- NAME LIKE '%TURKEY%'
- NAME LIKE '%TURK'
- NAME LIKE 'TURKEY%'
- NAME NOT LIKE '%TURKEY%'
- NAME NOT LIKE '%TURK'
- NAME NOT LIKE 'TURKEY%'
- NAME IS NULL
- NAME IS NOT NULL
- POPULATION BETWEEN 12314 AND 12314
- POPULATION NOT BETWEEN 12 AND 1000
- DATE BEFORE '23.09.1989'
- DATE AFTER '23.09.1989'
Spatial Queries
- INTERSECTS(geom, 'WKT STRING')
- DISJOINT(geom, 'WKT STRING')
- CONTAINS(geom, 'WKT STRING')
- WITHIN(geom, 'WKT STRING')
- TOUCHES(geom, 'WKT STRING')
- CROSSES(geom, 'WKT STRING')
- OVERLAPS(geom, 'WKT STRING')
- EQUALS(geom, 'WKT STRING')
- RELATE(geom1, geom2, relationType)
- DWITHIN(geom, 'WKT STRING', distance, units)
- BEYOND(geom, 'WKT STRING', distance, units)
- BBOX(geom, y1, x1, y2, x2 )
!!! You can change parameters between geoloc column and wkt string
- Create your DB table model, like that : {columnName:{type:dataType},...}
- Use class cql_filter and user your model data at parameter
- Add your query cql_filter.addCQLPart( 'id', '=', [123], 'AND' )
- if you have another query please do it
- Get your cql string . var myCqlString = cql_filter.getCQLString();
Notice : If you know to use SQL, cql_filter syntax will be very easy for you.