Adding a filter format for version 1.0.0 filter encoding. The sld parser extends itself to use readers and writers from the filter parser. r=me (closes #1605)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7651 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -203,6 +203,10 @@
|
||||
"OpenLayers/Format/SLD.js",
|
||||
"OpenLayers/Format/SLD/v1.js",
|
||||
"OpenLayers/Format/SLD/v1_0_0.js",
|
||||
"OpenLayers/Format/SLD/v1.js",
|
||||
"OpenLayers/Format/Filter.js",
|
||||
"OpenLayers/Format/Filter/v1.js",
|
||||
"OpenLayers/Format/Filter/v1_0_0.js",
|
||||
"OpenLayers/Format/Text.js",
|
||||
"OpenLayers/Format/JSON.js",
|
||||
"OpenLayers/Format/GeoJSON.js",
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
* @requires OpenLayers/Filter/FeatureId.js
|
||||
* @requires OpenLayers/Filter/Logical.js
|
||||
* @requires OpenLayers/Filter/Comparison.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.Filter
|
||||
* Read/Wite ogc:Filter. Create a new instance with the <OpenLayers.Format.Filter>
|
||||
* constructor.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
*/
|
||||
OpenLayers.Format.Filter = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
/**
|
||||
* APIProperty: defaultVersion
|
||||
* {String} Version number to assume if none found. Default is "1.0.0".
|
||||
*/
|
||||
defaultVersion: "1.0.0",
|
||||
|
||||
/**
|
||||
* APIProperty: version
|
||||
* {String} Specify a version string if one is known.
|
||||
*/
|
||||
version: null,
|
||||
|
||||
/**
|
||||
* Property: parser
|
||||
* {Object} Instance of the versioned parser. Cached for multiple read and
|
||||
* write calls of the same version.
|
||||
*/
|
||||
parser: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.Filter
|
||||
* Create a new parser for Filter.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: write
|
||||
* Write an ogc:Filter given a filter object.
|
||||
*
|
||||
* Parameters:
|
||||
* filter - {<OpenLayers.Filter>} An filter.
|
||||
* options - {Object} Optional configuration object.
|
||||
*
|
||||
* Returns:
|
||||
* {Elment} An ogc:Filter element node.
|
||||
*/
|
||||
write: function(filter, options) {
|
||||
var version = (options && options.version) ||
|
||||
this.version || this.defaultVersion;
|
||||
if(!this.parser || this.parser.VERSION != version) {
|
||||
var format = OpenLayers.Format.Filter[
|
||||
"v" + version.replace(/\./g, "_")
|
||||
];
|
||||
if(!format) {
|
||||
throw "Can't find a Filter parser for version " +
|
||||
version;
|
||||
}
|
||||
this.parser = new format(this.options);
|
||||
}
|
||||
return this.parser.write(filter);
|
||||
//return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Read and Filter doc and return an object representing the Filter.
|
||||
*
|
||||
* Parameters:
|
||||
* data - {String | DOMElement} Data to read.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Filter>} A filter object.
|
||||
*/
|
||||
read: function(data) {
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.nodeType == 9 ? data.documentElement : data;
|
||||
var version = this.version;
|
||||
if(!version) {
|
||||
version = this.defaultVersion;
|
||||
}
|
||||
if(!this.parser || this.parser.VERSION != version) {
|
||||
var format = OpenLayers.Format.Filter[
|
||||
"v" + version.replace(/\./g, "_")
|
||||
];
|
||||
if(!format) {
|
||||
throw "Can't find a Filter parser for version " +
|
||||
version;
|
||||
}
|
||||
this.parser = new format(this.options);
|
||||
}
|
||||
var filter = this.parser.read(data);
|
||||
return filter;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.Filter"
|
||||
});
|
||||
@@ -0,0 +1,585 @@
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/Filter.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.Filter.v1
|
||||
* Superclass for Filter version 1 parsers.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
*/
|
||||
OpenLayers.Format.Filter.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
/**
|
||||
* Property: namespaces
|
||||
* {Object} Mapping of namespace aliases to namespace URIs.
|
||||
*/
|
||||
namespaces: {
|
||||
ogc: "http://www.opengis.net/ogc",
|
||||
xlink: "http://www.w3.org/1999/xlink",
|
||||
xsi: "http://www.w3.org/2001/XMLSchema-instance"
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: defaultPrefix
|
||||
*/
|
||||
defaultPrefix: "ogc",
|
||||
|
||||
/**
|
||||
* Property: schemaLocation
|
||||
* {String} Schema location for a particular minor version.
|
||||
*/
|
||||
schemaLocation: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.Filter.v1
|
||||
* Instances of this class are not created directly. Use the
|
||||
* <OpenLayers.Format.Filter> constructor instead.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read
|
||||
*
|
||||
* Parameters:
|
||||
* data - {DOMElement} A Filter document element.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Filter>} A filter object.
|
||||
*/
|
||||
read: function(data) {
|
||||
var obj = {}
|
||||
var filter = this.readers.ogc["Filter"].apply(this, [data, obj]);
|
||||
return obj.filter;
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: readers
|
||||
* Contains public functions, grouped by namespace prefix, that will
|
||||
* be applied when a namespaced node is found matching the function
|
||||
* name. The function will be applied in the scope of this parser
|
||||
* with two arguments: the node being read and a context object passed
|
||||
* from the parent.
|
||||
*/
|
||||
readers: {
|
||||
"ogc": {
|
||||
"Filter": function(node, parent) {
|
||||
// Filters correspond to subclasses of OpenLayers.Filter.
|
||||
// Since they contain information we don't persist, we
|
||||
// create a temporary object and then pass on the filter
|
||||
// (ogc:Filter) to the parent obj.
|
||||
var obj = {
|
||||
fids: [],
|
||||
filters: []
|
||||
};
|
||||
this.readChildNodes(node, obj);
|
||||
if(obj.fids.length > 0) {
|
||||
parent.filter = new OpenLayers.Filter.FeatureId({
|
||||
fids: obj.fids
|
||||
});
|
||||
} else if(obj.filters.length > 0) {
|
||||
parent.filter = obj.filters[0];
|
||||
}
|
||||
},
|
||||
"FeatureId": function(node, obj) {
|
||||
var fid = node.getAttribute("fid");
|
||||
if(fid) {
|
||||
obj.fids.push(fid);
|
||||
}
|
||||
},
|
||||
"And": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.AND
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"Or": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.OR
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"Not": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.NOT
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsNotEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsLessThan": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LESS_THAN
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsGreaterThan": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.GREATER_THAN
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsLessThanOrEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsGreaterThanOrEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsBetween": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.BETWEEN
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsLike": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LIKE
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
var wildCard = node.getAttribute("wildCard");
|
||||
var singleChar = node.getAttribute("singleChar");
|
||||
var esc = node.getAttribute("escape");
|
||||
filter.value2regex(wildCard, singleChar, esc);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"Literal": function(node, obj) {
|
||||
obj.value = this.getChildValue(node);
|
||||
},
|
||||
"PropertyName": function(node, filter) {
|
||||
filter.property = this.getChildValue(node);
|
||||
},
|
||||
"LowerBoundary": function(node, filter) {
|
||||
filter.lowerBoundary = this.readOgcExpression(node);
|
||||
},
|
||||
"UpperBoundary": function(node, filter) {
|
||||
filter.upperBoundary = this.readOgcExpression(node);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: readOgcExpression
|
||||
* Limited support for OGC expressions.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement} A DOM element that contains an ogc:expression.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A value to be used in a symbolizer.
|
||||
*/
|
||||
readOgcExpression: function(node) {
|
||||
var obj = {};
|
||||
this.readChildNodes(node, obj);
|
||||
var value = obj.value;
|
||||
if(!value) {
|
||||
value = this.getChildValue(node);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: write
|
||||
*
|
||||
* Parameters:
|
||||
* filter - {<OpenLayers.Filter>} A filter object.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} An ogc:Filter element.
|
||||
*/
|
||||
write: function(filter) {
|
||||
return this.writers.ogc["Filter"].apply(this, [filter]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: writers
|
||||
* As a compliment to the readers property, this structure contains public
|
||||
* writing functions grouped by namespace alias and named like the
|
||||
* node names they produce.
|
||||
*/
|
||||
writers: {
|
||||
"ogc": {
|
||||
"Filter": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Filter");
|
||||
var sub = filter.CLASS_NAME.split(".").pop();
|
||||
if(sub == "FeatureId") {
|
||||
for(var i=0; i<filter.fids.length; ++i) {
|
||||
this.writeNode(node, "FeatureId", filter.fids[i]);
|
||||
}
|
||||
} else {
|
||||
this.writeNode(node, this.getFilterType(filter), filter);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
"FeatureId": function(fid) {
|
||||
return this.createElementNSPlus("ogc:FeatureId", {
|
||||
attributes: {fid: fid}
|
||||
});
|
||||
},
|
||||
"And": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:And");
|
||||
var childFilter;
|
||||
for(var i=0; i<filter.filters.length; ++i) {
|
||||
childFilter = filter.filters[i];
|
||||
this.writeNode(
|
||||
node, this.getFilterType(childFilter), childFilter
|
||||
);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
"Or": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Or");
|
||||
var childFilter;
|
||||
for(var i=0; i<filter.filters.length; ++i) {
|
||||
childFilter = filter.filters[i];
|
||||
this.writeNode(
|
||||
node, this.getFilterType(childFilter), childFilter
|
||||
);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
"Not": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Not");
|
||||
var childFilter = filter.filters[0];
|
||||
this.writeNode(
|
||||
node, this.getFilterType(childFilter), childFilter
|
||||
);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsNotEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsLessThan": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsLessThan");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsGreaterThan": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsLessThanOrEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsGreaterThanOrEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsBetween": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsBetween");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "LowerBoundary", filter);
|
||||
this.writeNode(node, "UpperBoundary", filter);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsLike": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsLike", {
|
||||
attributes: {
|
||||
wildCard: "*", singleChar: ".", escape: "!"
|
||||
}
|
||||
});
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
// convert regex string to ogc string
|
||||
this.writeNode(node, "Literal", filter.regex2value());
|
||||
return node;
|
||||
},
|
||||
"PropertyName": function(filter) {
|
||||
// no ogc:expression handling for now
|
||||
return this.createElementNSPlus("ogc:PropertyName", {
|
||||
value: filter.property
|
||||
});
|
||||
},
|
||||
"Literal": function(value) {
|
||||
// no ogc:expression handling for now
|
||||
return this.createElementNSPlus("ogc:Literal", {
|
||||
value: value
|
||||
});
|
||||
},
|
||||
"LowerBoundary": function(filter) {
|
||||
// no ogc:expression handling for now
|
||||
var node = this.createElementNSPlus("ogc:LowerBoundary");
|
||||
this.writeNode(node, "Literal", filter.lowerBoundary);
|
||||
return node;
|
||||
},
|
||||
"UpperBoundary": function(filter) {
|
||||
// no ogc:expression handling for now
|
||||
var node = this.createElementNSPlus("ogc:UpperBoundary");
|
||||
this.writeNode(node, "Literal", filter.upperBoundary);
|
||||
return node;
|
||||
},
|
||||
"BBOX": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:BBOX");
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
var gml = new OpenLayers.Format.GML();
|
||||
node.appendChild(gml.buildGeometryNode(filter.value));
|
||||
return node;
|
||||
},
|
||||
"DWITHIN": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:DWithin");
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
var gml = new OpenLayers.Format.GML();
|
||||
node.appendChild(gml.buildGeometryNode(filter.value));
|
||||
this.writeNode(node, "Distance", filter);
|
||||
return node;
|
||||
},
|
||||
"INTERSECTS": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Intersects");
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
var gml = new OpenLayers.Format.GML();
|
||||
node.appendChild(gml.buildGeometryNode(filter.value));
|
||||
return node;
|
||||
},
|
||||
"Distance": function(filter) {
|
||||
return this.createElementNSPlus("ogc:Distance",
|
||||
{attributes: {units: filter.distanceUnits},
|
||||
value: filter.distance});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getFilterType
|
||||
*/
|
||||
getFilterType: function(filter) {
|
||||
var filterType = this.filterMap[filter.type];
|
||||
if(!filterType) {
|
||||
throw "Filter writing not supported for rule type: " + filter.type;
|
||||
}
|
||||
return filterType;
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: filterMap
|
||||
* {Object} Contains a member for each filter type. Values are node names
|
||||
* for corresponding OGC Filter child elements.
|
||||
*/
|
||||
filterMap: {
|
||||
"&&": "And",
|
||||
"||": "Or",
|
||||
"!": "Not",
|
||||
"==": "PropertyIsEqualTo",
|
||||
"!=": "PropertyIsNotEqualTo",
|
||||
"<": "PropertyIsLessThan",
|
||||
">": "PropertyIsGreaterThan",
|
||||
"<=": "PropertyIsLessThanOrEqualTo",
|
||||
">=": "PropertyIsGreaterThanOrEqualTo",
|
||||
"..": "PropertyIsBetween",
|
||||
"~": "PropertyIsLike",
|
||||
"BBOX": "BBOX",
|
||||
"DWITHIN": "DWITHIN",
|
||||
"INTERSECTS": "INTERSECTS"
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Methods below this point are of general use for versioned XML parsers.
|
||||
* These are candidates for an abstract class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method: getNamespacePrefix
|
||||
* Get the namespace prefix for a given uri from the <namespaces> object.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A namespace prefix or null if none found.
|
||||
*/
|
||||
getNamespacePrefix: function(uri) {
|
||||
var prefix = null;
|
||||
if(uri == null) {
|
||||
prefix = this.namespaces[this.defaultPrefix];
|
||||
} else {
|
||||
var gotPrefix = false;
|
||||
for(prefix in this.namespaces) {
|
||||
if(this.namespaces[prefix] == uri) {
|
||||
gotPrefix = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!gotPrefix) {
|
||||
prefix = null;
|
||||
}
|
||||
}
|
||||
return prefix;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: readChildNodes
|
||||
*/
|
||||
readChildNodes: function(node, obj) {
|
||||
var children = node.childNodes;
|
||||
var child, group, reader, prefix, local;
|
||||
for(var i=0; i<children.length; ++i) {
|
||||
child = children[i];
|
||||
if(child.nodeType == 1) {
|
||||
prefix = this.getNamespacePrefix(child.namespaceURI);
|
||||
local = child.nodeName.split(":").pop();
|
||||
group = this.readers[prefix];
|
||||
if(group) {
|
||||
reader = group[local];
|
||||
if(reader) {
|
||||
reader.apply(this, [child, obj]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: writeNode
|
||||
* Shorthand for applying one of the named writers and appending the
|
||||
* results to a node. If a qualified name is not provided for the
|
||||
* second argument (and a local name is used instead), the namespace
|
||||
* of the parent node will be assumed.
|
||||
*
|
||||
* Parameters:
|
||||
* parent - {DOMElement} Result will be appended to this node.
|
||||
* name - {String} The name of a node to generate. If a qualified name
|
||||
* (e.g. "pre:Name") is used, the namespace prefix is assumed to be
|
||||
* in the <writers> group. If a local name is used (e.g. "Name") then
|
||||
* the namespace of the parent is assumed.
|
||||
* obj - {Object} Structure containing data for the writer.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} The child node.
|
||||
*/
|
||||
writeNode: function(parent, name, obj) {
|
||||
var prefix, local;
|
||||
var split = name.indexOf(":");
|
||||
if(split > 0) {
|
||||
prefix = name.substring(0, split);
|
||||
local = name.substring(split + 1);
|
||||
} else {
|
||||
prefix = this.getNamespacePrefix(parent.namespaceURI);
|
||||
local = name;
|
||||
}
|
||||
var child = this.writers[prefix][local].apply(this, [obj]);
|
||||
parent.appendChild(child);
|
||||
return child;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: createElementNSPlus
|
||||
* Shorthand for creating namespaced elements with optional attributes and
|
||||
* child text nodes.
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String} The qualified node name.
|
||||
* options - {Object} Optional object for node configuration.
|
||||
*
|
||||
* Returns:
|
||||
* {Element} An element node.
|
||||
*/
|
||||
createElementNSPlus: function(name, options) {
|
||||
options = options || {};
|
||||
var loc = name.indexOf(":");
|
||||
// order of prefix preference
|
||||
// 1. in the uri option
|
||||
// 2. in the prefix option
|
||||
// 3. in the qualified name
|
||||
// 4. from the defaultPrefix
|
||||
var uri = options.uri || this.namespaces[options.prefix];
|
||||
if(!uri) {
|
||||
loc = name.indexOf(":");
|
||||
uri = this.namespaces[name.substring(0, loc)];
|
||||
}
|
||||
if(!uri) {
|
||||
uri = this.namespaces[this.defaultPrefix];
|
||||
}
|
||||
var node = this.createElementNS(uri, name);
|
||||
if(options.attributes) {
|
||||
this.setAttributes(node, options.attributes);
|
||||
}
|
||||
if(options.value) {
|
||||
node.appendChild(this.createTextNode(options.value));
|
||||
}
|
||||
return node;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setAttributes
|
||||
* Set multiple attributes given key value pairs from an object.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {Element} An element node.
|
||||
* obj - {Object || Array} An object whose properties represent attribute
|
||||
* names and values represent attribute values. If an attribute name
|
||||
* is a qualified name ("prefix:local"), the prefix will be looked up
|
||||
* in the parsers {namespaces} object. If the prefix is found,
|
||||
* setAttributeNS will be used instead of setAttribute.
|
||||
*/
|
||||
setAttributes: function(node, obj) {
|
||||
var value, loc, alias, uri;
|
||||
for(var name in obj) {
|
||||
value = obj[name].toString();
|
||||
// check for qualified attribute name ("prefix:local")
|
||||
uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null;
|
||||
this.setAttributeNS(node, uri, name, value);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.Filter.v1"
|
||||
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/Filter/v1.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.Filter.v1_0_0
|
||||
* Write ogc:Filter version 1.0.0.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.Filter.v1>
|
||||
*/
|
||||
OpenLayers.Format.Filter.v1_0_0 = OpenLayers.Class(
|
||||
OpenLayers.Format.Filter.v1, {
|
||||
|
||||
/**
|
||||
* Constant: VERSION
|
||||
* {String} 1.0.0
|
||||
*/
|
||||
VERSION: "1.0.0",
|
||||
|
||||
/**
|
||||
* Property: schemaLocation
|
||||
* {String} http://www.opengis.net/ogc/filter/1.0.0/filter.xsd
|
||||
*/
|
||||
schemaLocation: "http://www.opengis.net/ogc/filter/1.0.0/filter.xsd",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.Filter.v1_0_0
|
||||
* Instances of this class are not created directly. Use the
|
||||
* <OpenLayers.Format.Filter> constructor instead.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.Filter.v1.prototype.initialize.apply(
|
||||
this, [options]
|
||||
);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.Filter.v1_0_0"
|
||||
|
||||
});
|
||||
@@ -9,6 +9,7 @@
|
||||
* @requires OpenLayers/Filter/FeatureId.js
|
||||
* @requires OpenLayers/Filter/Logical.js
|
||||
* @requires OpenLayers/Filter/Comparison.js
|
||||
* @requires OpenLayers/Filter/Spatial.js
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,6 +66,13 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
// extend with ogc:Filter readers and writers
|
||||
this.readers["ogc"] = OpenLayers.Format.Filter.v1.prototype.readers["ogc"];
|
||||
this.writers["ogc"] = OpenLayers.Format.Filter.v1.prototype.writers["ogc"];
|
||||
// extend with custom filter methods that may get changed
|
||||
this.readOgcExpression = OpenLayers.Format.Filter.v1.prototype.readOgcExpression;
|
||||
this.getFilterType = OpenLayers.Format.Filter.v1.prototype.getFilterType;
|
||||
this.filterMap = OpenLayers.Format.Filter.v1.prototype.filterMap;
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
@@ -273,148 +280,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
"Format": function(node, graphic) {
|
||||
graphic.graphicFormat = this.getChildValue(node);
|
||||
}
|
||||
},
|
||||
"ogc": {
|
||||
"Filter": function(node, rule) {
|
||||
// Filters correspond to subclasses of OpenLayers.Filter.
|
||||
// Since they contain information we don't persist, we
|
||||
// create a temporary object and then pass on the filter
|
||||
// (ogc:Filter) to the parent rule (sld:Rule).
|
||||
var obj = {
|
||||
fids: [],
|
||||
filters: []
|
||||
};
|
||||
this.readChildNodes(node, obj);
|
||||
if(obj.fids.length > 0) {
|
||||
rule.filter = new OpenLayers.Filter.FeatureId({
|
||||
fids: obj.fids
|
||||
});
|
||||
} else if(obj.filters.length > 0) {
|
||||
rule.filter = obj.filters[0];
|
||||
}
|
||||
},
|
||||
"FeatureId": function(node, obj) {
|
||||
var fid = node.getAttribute("fid");
|
||||
if(fid) {
|
||||
obj.fids.push(fid);
|
||||
}
|
||||
},
|
||||
"And": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.AND
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"Or": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.OR
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"Not": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.NOT
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsNotEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsLessThan": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LESS_THAN
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsGreaterThan": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.GREATER_THAN
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsLessThanOrEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsGreaterThanOrEqualTo": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsBetween": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.BETWEEN
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"PropertyIsLike": function(node, obj) {
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LIKE
|
||||
});
|
||||
this.readChildNodes(node, filter);
|
||||
var wildCard = node.getAttribute("wildCard");
|
||||
var singleChar = node.getAttribute("singleChar");
|
||||
var esc = node.getAttribute("escape");
|
||||
filter.value2regex(wildCard, singleChar, esc);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
"Literal": function(node, obj) {
|
||||
obj.value = this.getChildValue(node);
|
||||
},
|
||||
"PropertyName": function(node, filter) {
|
||||
filter.property = this.getChildValue(node);
|
||||
},
|
||||
"LowerBoundary": function(node, filter) {
|
||||
filter.lowerBoundary = this.readOgcExpression(node);
|
||||
},
|
||||
"UpperBoundary": function(node, filter) {
|
||||
filter.upperBoundary = this.readOgcExpression(node);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: readOgcExpression
|
||||
* Limited support for OGC expressions.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement} A DOM element that contains an ogc:expression.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A value to be used in a symbolizer.
|
||||
*/
|
||||
readOgcExpression: function(node) {
|
||||
var obj = {};
|
||||
this.readChildNodes(node, obj);
|
||||
var value = obj.value;
|
||||
if(!value) {
|
||||
value = this.getChildValue(node);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: cssMap
|
||||
* {Object} Object mapping supported css property names to OpenLayers
|
||||
@@ -897,175 +765,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
value: format
|
||||
});
|
||||
}
|
||||
},
|
||||
"ogc": {
|
||||
"Filter": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Filter");
|
||||
var sub = filter.CLASS_NAME.split(".").pop();
|
||||
if(sub == "FeatureId") {
|
||||
for(var i=0, len=filter.fids.length; i<len; ++i) {
|
||||
this.writeNode(node, "FeatureId", filter.fids[i]);
|
||||
}
|
||||
} else {
|
||||
this.writeNode(node, this.getFilterType(filter), filter);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
"FeatureId": function(fid) {
|
||||
return this.createElementNSPlus("ogc:FeatureId", {
|
||||
attributes: {fid: fid}
|
||||
});
|
||||
},
|
||||
"And": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:And");
|
||||
var childFilter;
|
||||
for(var i=0, len=filter.filters.length; i<len; ++i) {
|
||||
childFilter = filter.filters[i];
|
||||
this.writeNode(
|
||||
node, this.getFilterType(childFilter), childFilter
|
||||
);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
"Or": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Or");
|
||||
var childFilter;
|
||||
for(var i=0, len=filter.filters.length; i<len; ++i) {
|
||||
childFilter = filter.filters[i];
|
||||
this.writeNode(
|
||||
node, this.getFilterType(childFilter), childFilter
|
||||
);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
"Not": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:Not");
|
||||
var childFilter = filter.filters[0];
|
||||
this.writeNode(
|
||||
node, this.getFilterType(childFilter), childFilter
|
||||
);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsNotEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsLessThan": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsLessThan");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsGreaterThan": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsLessThanOrEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsGreaterThanOrEqualTo": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "Literal", filter.value);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsBetween": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsBetween");
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
this.writeNode(node, "LowerBoundary", filter);
|
||||
this.writeNode(node, "UpperBoundary", filter);
|
||||
return node;
|
||||
},
|
||||
"PropertyIsLike": function(filter) {
|
||||
var node = this.createElementNSPlus("ogc:PropertyIsLike", {
|
||||
attributes: {
|
||||
wildCard: "*", singleChar: ".", escape: "!"
|
||||
}
|
||||
});
|
||||
// no ogc:expression handling for now
|
||||
this.writeNode(node, "PropertyName", filter);
|
||||
// convert regex string to ogc string
|
||||
this.writeNode(node, "Literal", filter.regex2value());
|
||||
return node;
|
||||
},
|
||||
"PropertyName": function(filter) {
|
||||
// no ogc:expression handling for now
|
||||
return this.createElementNSPlus("ogc:PropertyName", {
|
||||
value: filter.property
|
||||
});
|
||||
},
|
||||
"Literal": function(value) {
|
||||
// no ogc:expression handling for now
|
||||
return this.createElementNSPlus("ogc:Literal", {
|
||||
value: value
|
||||
});
|
||||
},
|
||||
"LowerBoundary": function(filter) {
|
||||
// no ogc:expression handling for now
|
||||
var node = this.createElementNSPlus("ogc:LowerBoundary");
|
||||
this.writeNode(node, "Literal", filter.lowerBoundary);
|
||||
return node;
|
||||
},
|
||||
"UpperBoundary": function(filter) {
|
||||
// no ogc:expression handling for now
|
||||
var node = this.createElementNSPlus("ogc:UpperBoundary");
|
||||
this.writeNode(node, "Literal", filter.upperBoundary);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getFilterType
|
||||
*/
|
||||
getFilterType: function(filter) {
|
||||
var filterType = this.filterMap[filter.type];
|
||||
if(!filterType) {
|
||||
throw "SLD writing not supported for rule type: " + filter.type;
|
||||
}
|
||||
return filterType;
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: filterMap
|
||||
* {Object} Contains a member for each filter type. Values are node names
|
||||
* for corresponding OGC Filter child elements.
|
||||
*/
|
||||
filterMap: {
|
||||
"&&": "And",
|
||||
"||": "Or",
|
||||
"!": "Not",
|
||||
"==": "PropertyIsEqualTo",
|
||||
"!=": "PropertyIsNotEqualTo",
|
||||
"<": "PropertyIsLessThan",
|
||||
">": "PropertyIsGreaterThan",
|
||||
"<=": "PropertyIsLessThanOrEqualTo",
|
||||
">=": "PropertyIsGreaterThanOrEqualTo",
|
||||
"..": "PropertyIsBetween",
|
||||
"~": "PropertyIsLike"
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Methods below this point are of general use for versioned XML parsers.
|
||||
* These are candidates for an abstract class.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_initialize(t) {
|
||||
t.plan(3);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var format = new OpenLayers.Format.Filter(options);
|
||||
t.ok(format instanceof OpenLayers.Format.Filter,
|
||||
"new OpenLayers.Format.Filter returns object" );
|
||||
t.eq(format.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof format.read, "function", "format has a read function");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,61 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var test_xml =
|
||||
'<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
|
||||
'<ogc:Or>' +
|
||||
'<ogc:PropertyIsBetween>' +
|
||||
'<ogc:PropertyName>number</ogc:PropertyName>' +
|
||||
'<ogc:LowerBoundary>' +
|
||||
'<ogc:Literal>1064866676</ogc:Literal>' +
|
||||
'</ogc:LowerBoundary>' +
|
||||
'<ogc:UpperBoundary>' +
|
||||
'<ogc:Literal>1065512599</ogc:Literal>' +
|
||||
'</ogc:UpperBoundary>' +
|
||||
'</ogc:PropertyIsBetween>' +
|
||||
'<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">' +
|
||||
'<ogc:PropertyName>cat</ogc:PropertyName>' +
|
||||
'<ogc:Literal>*dog.food!*good</ogc:Literal>' +
|
||||
'</ogc:PropertyIsLike>' +
|
||||
'<ogc:Not>' +
|
||||
'<ogc:PropertyIsLessThanOrEqualTo>' +
|
||||
'<ogc:PropertyName>FOO</ogc:PropertyName>' +
|
||||
'<ogc:Literal>5000</ogc:Literal>' +
|
||||
'</ogc:PropertyIsLessThanOrEqualTo>' +
|
||||
'</ogc:Not>' +
|
||||
'</ogc:Or>' +
|
||||
'</ogc:Filter>';
|
||||
|
||||
function test_read(t) {
|
||||
t.plan(3);
|
||||
|
||||
var parser = new OpenLayers.Format.Filter.v1_0_0();
|
||||
var xml = new OpenLayers.Format.XML();
|
||||
var filter = parser.read(xml.read(test_xml).documentElement);
|
||||
|
||||
t.ok(filter instanceof OpenLayers.Filter.Logical, "instance of correct class");
|
||||
t.eq(filter.type, OpenLayers.Filter.Logical.OR, "correct type");
|
||||
t.eq(filter.filters.length, 3, "correct number of child filters");
|
||||
}
|
||||
|
||||
function test_write(t) {
|
||||
t.plan(1);
|
||||
|
||||
// read first - testing that write produces the ogc:Filter element above
|
||||
var parser = new OpenLayers.Format.Filter.v1_0_0();
|
||||
var xml = new OpenLayers.Format.XML();
|
||||
var filter = parser.read(xml.read(test_xml).documentElement);
|
||||
|
||||
var node = parser.write(filter);
|
||||
t.xml_eq(node, test_xml, "filter correctly written");
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -48,6 +48,8 @@
|
||||
<li>Format/OSM.html</li>
|
||||
<li>Format/SLD.html</li>
|
||||
<li>Format/SLD/v1_0_0.html</li>
|
||||
<li>Format/Filter.html</li>
|
||||
<li>Format/Filter/v1_0_0.html</li>
|
||||
<li>Format/WKT.html</li>
|
||||
<li>Format/WMC.html</li>
|
||||
<li>Format/WMC/v1_1_0.html</li>
|
||||
|
||||
Reference in New Issue
Block a user