Merge remote-tracking branch 'openlayers/master' into vector-api
This commit is contained in:
@@ -10,7 +10,7 @@ goog.require('ol.geom.LineString');
|
||||
* @constructor
|
||||
* @extends {ol.geom.LineString}
|
||||
* @param {ol.CoordinateArray} coordinates Vertex array (e.g.
|
||||
* [[x0, y0], [x1, y1]]).
|
||||
* `[[x0, y0], [x1, y1]]`).
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.geom.LinearRing = function(coordinates) {
|
||||
|
||||
@@ -30,7 +30,7 @@ goog.require('ol.structs.RTree');
|
||||
* geometry: ol.geom.Geometry,
|
||||
* index: (number|undefined),
|
||||
* style: ol.style.Style,
|
||||
* segment: (Array.<ol.Extent>|undefined)}}
|
||||
* segment: Array.<ol.Extent>}}
|
||||
*/
|
||||
ol.interaction.SegmentDataType;
|
||||
|
||||
@@ -277,9 +277,11 @@ ol.interaction.Modify.prototype.addSegments_ =
|
||||
var rTree = this.rTree_;
|
||||
var segment, segmentData, coordinates;
|
||||
if (geometry instanceof ol.geom.Point) {
|
||||
coordinates = geometry.getCoordinates();
|
||||
segmentData = /** @type {ol.interaction.SegmentDataType} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
segment: [coordinates, coordinates],
|
||||
style: layer.getStyle()
|
||||
});
|
||||
rTree.insert(geometry.getBounds(), segmentData, uid);
|
||||
@@ -389,20 +391,18 @@ ol.interaction.Modify.prototype.handleDrag = function(evt) {
|
||||
var geometry = segmentData.geometry;
|
||||
var coordinates = geometry.getCoordinates();
|
||||
|
||||
var oldBounds, newBounds;
|
||||
var segment = segmentData.segment;
|
||||
var oldBounds = ol.extent.boundingExtent(segment);
|
||||
if (geometry instanceof ol.geom.Point) {
|
||||
oldBounds = geometry.getBounds();
|
||||
geometry.setCoordinates(vertex);
|
||||
newBounds = geometry.getBounds();
|
||||
coordinates = vertex;
|
||||
segment[0] = segment[1] = vertex;
|
||||
} else {
|
||||
var index = dragSegment[1];
|
||||
coordinates[segmentData.index + index] = vertex;
|
||||
geometry.setCoordinates(coordinates);
|
||||
var segment = segmentData.segment;
|
||||
oldBounds = ol.extent.boundingExtent(segment);
|
||||
segment[index] = vertex;
|
||||
newBounds = ol.extent.boundingExtent(segment);
|
||||
}
|
||||
geometry.setCoordinates(coordinates);
|
||||
var newBounds = ol.extent.boundingExtent(segment);
|
||||
this.createOrUpdateVertexFeature_(segmentData.style, vertex);
|
||||
this.rTree_.remove(oldBounds, segmentData);
|
||||
this.rTree_.insert(newBounds, segmentData, goog.getUid(feature));
|
||||
|
||||
@@ -182,7 +182,8 @@ ol.parser.ogc.Filter_v1 = function() {
|
||||
var args = [], container = {};
|
||||
this.readChildNodes(node, container);
|
||||
if (goog.isDef(container.geometry)) {
|
||||
args.push(new ol.expr.Literal(this.gml_.createGeometry(container)));
|
||||
args.push(new ol.expr.Literal(this.gmlParser_.createGeometry(
|
||||
container)));
|
||||
} else {
|
||||
args = [new ol.expr.Literal(container.bounds[0]),
|
||||
new ol.expr.Literal(container.bounds[1]),
|
||||
@@ -508,7 +509,14 @@ ol.parser.ogc.Filter_v1.prototype.write = function(filter) {
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.writeOgcExpression = function(expr, node) {
|
||||
if (expr instanceof ol.expr.Call) {
|
||||
this.writeNode('Function', expr, null, node);
|
||||
if (ol.expr.isLibCall(expr) === ol.expr.functions.CONCAT) {
|
||||
var args = expr.getArgs();
|
||||
for (var i = 0, ii = args.length; i < ii; ++i) {
|
||||
this.writeOgcExpression(args[i], node);
|
||||
}
|
||||
} else {
|
||||
this.writeNode('Function', expr, null, node);
|
||||
}
|
||||
} else if (expr instanceof ol.expr.Literal) {
|
||||
this.writeNode('Literal', expr, null, node);
|
||||
} else if (expr instanceof ol.expr.Identifier) {
|
||||
@@ -573,29 +581,37 @@ ol.parser.ogc.Filter_v1.prototype.aggregateLogical_ = function(filters,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3}
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.getGmlParser = function() {
|
||||
return this.gmlParser_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3} gml The GML parser to
|
||||
* use.
|
||||
* @protected
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.setGmlParser = function(gml) {
|
||||
this.gml_ = gml;
|
||||
for (var uri in this.gml_.readers) {
|
||||
for (var key in this.gml_.readers[uri]) {
|
||||
this.gmlParser_ = gml;
|
||||
for (var uri in this.gmlParser_.readers) {
|
||||
for (var key in this.gmlParser_.readers[uri]) {
|
||||
if (!goog.isDef(this.readers[uri])) {
|
||||
this.readers[uri] = {};
|
||||
}
|
||||
this.readers[uri][key] = goog.bind(this.gml_.readers[uri][key],
|
||||
this.gml_);
|
||||
this.readers[uri][key] = goog.bind(this.gmlParser_.readers[uri][key],
|
||||
this.gmlParser_);
|
||||
}
|
||||
}
|
||||
for (uri in this.gml_.writers) {
|
||||
for (key in this.gml_.writers[uri]) {
|
||||
for (uri in this.gmlParser_.writers) {
|
||||
for (key in this.gmlParser_.writers[uri]) {
|
||||
if (!goog.isDef(this.writers[uri])) {
|
||||
this.writers[uri] = {};
|
||||
}
|
||||
this.writers[uri][key] = goog.bind(this.gml_.writers[uri][key],
|
||||
this.gml_);
|
||||
this.writers[uri][key] = goog.bind(this.gmlParser_.writers[uri][key],
|
||||
this.gmlParser_);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -91,12 +91,14 @@ ol.parser.ogc.Filter_v1_0_0 = function() {
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
|
||||
var bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
var projection = args[4].getValue();
|
||||
var projection;
|
||||
if (args[4] instanceof ol.expr.Literal) {
|
||||
projection = args[4].getValue();
|
||||
}
|
||||
var property = args[5];
|
||||
// PropertyName is mandatory in 1.0.0, but e.g. GeoServer also
|
||||
// accepts filters without it.
|
||||
@@ -166,8 +168,8 @@ ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) {
|
||||
} else {
|
||||
var child;
|
||||
if (geom !== null) {
|
||||
child = this.writeNode('_geometry', geom,
|
||||
this.gml_.featureNS).firstChild;
|
||||
child = this.writeNode('_geometry', {value: geom},
|
||||
this.gmlParser_.featureNS).firstChild;
|
||||
} else if (bbox.length === 4) {
|
||||
child = this.writeNode('Box', bbox,
|
||||
'http://www.opengis.net/gml');
|
||||
|
||||
@@ -224,8 +224,8 @@ ol.parser.ogc.Filter_v1_1_0.prototype.writeSpatial_ = function(filter, name) {
|
||||
} else {
|
||||
var child;
|
||||
if (geom !== null) {
|
||||
child = this.writeNode('_geometry', geom,
|
||||
this.gml_.featureNS).firstChild;
|
||||
child = this.writeNode('_geometry', {value: geom},
|
||||
this.gmlParser_.featureNS).firstChild;
|
||||
} else if (bbox.length === 4) {
|
||||
child = this.writeNode('Envelope', bbox,
|
||||
'http://www.opengis.net/gml');
|
||||
|
||||
@@ -148,6 +148,9 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
'polygonMember': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'boundedBy': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Point': function(node, container) {
|
||||
var coordinates = [];
|
||||
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,
|
||||
@@ -317,10 +320,10 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
obj.features.push(feature);
|
||||
},
|
||||
'_geometry': function(node, obj) {
|
||||
if (!this.geometryName) {
|
||||
this.geometryName = node.nodeName.split(':').pop();
|
||||
}
|
||||
var local = node.localName || node.nodeName.split(':').pop();
|
||||
this.readChildNodes(node, obj);
|
||||
obj.properties[local] = this.createGeometry({geometry: obj.geometry});
|
||||
delete obj.geometry;
|
||||
},
|
||||
'_attribute': function(node, obj) {
|
||||
var local = node.localName || node.nodeName.split(':').pop();
|
||||
@@ -387,7 +390,8 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
},
|
||||
'geometryMember': function(geometry) {
|
||||
var node = this.createElementNS('gml:geometryMember');
|
||||
var child = this.writeNode('_geometry', geometry, this.featureNS);
|
||||
var child = this.writeNode('_geometry', {value: geometry},
|
||||
this.featureNS);
|
||||
node.appendChild(child.firstChild);
|
||||
return node;
|
||||
}
|
||||
@@ -418,23 +422,25 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
if (goog.isDef(fid)) {
|
||||
this.setAttributeNS(node, this.defaultNamespaceURI, 'fid', fid);
|
||||
}
|
||||
if (feature.getGeometry() !== null) {
|
||||
this.writeNode('_geometry', feature.getGeometry(), this.featureNS,
|
||||
node);
|
||||
}
|
||||
var attributes = feature.getAttributes(true);
|
||||
var attributes = feature.getAttributes();
|
||||
for (var name in attributes) {
|
||||
var value = attributes[name];
|
||||
if (goog.isDefAndNotNull(value)) {
|
||||
this.writeNode('_attribute', {name: name, value: value},
|
||||
this.featureNS, node);
|
||||
if (value instanceof ol.geom.Geometry) {
|
||||
this.writeNode('_geometry', {name: name, value: value},
|
||||
this.featureNS, node);
|
||||
} else {
|
||||
this.writeNode('_attribute', {name: name, value: value},
|
||||
this.featureNS, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'_geometry': function(geometry) {
|
||||
var node = this.createElementNS('feature:' + this.geometryName,
|
||||
'_geometry': function(obj) {
|
||||
var node = this.createElementNS('feature:' + obj.name,
|
||||
this.featureNS);
|
||||
var geometry = obj.value;
|
||||
var type = geometry.getType(), child;
|
||||
if (type === ol.geom.GeometryType.POINT) {
|
||||
child = this.writeNode('Point', geometry, null, node);
|
||||
|
||||
@@ -22,9 +22,10 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
'http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' +
|
||||
'1.0.0/gmlsf.xsd';
|
||||
goog.base(this, opt_options);
|
||||
this.featureNSWiters_['_geometry'] = function(geometry) {
|
||||
var node = this.createElementNS('feature:' + this.geometryName,
|
||||
this.featureNSWiters_['_geometry'] = function(obj) {
|
||||
var node = this.createElementNS('feature:' + obj.name,
|
||||
this.featureNS);
|
||||
var geometry = obj.value;
|
||||
var type = geometry.getType(), child;
|
||||
if (type === ol.geom.GeometryType.POINT) {
|
||||
child = this.writeNode('Point', geometry, null, node);
|
||||
|
||||
27
old/src/ol/parser/ogc/sldparser.js
Normal file
27
old/src/ol/parser/ogc/sldparser.js
Normal file
@@ -0,0 +1,27 @@
|
||||
goog.provide('ol.parser.ogc.SLD');
|
||||
goog.require('ol.parser.ogc.SLD_v1_0_0');
|
||||
goog.require('ol.parser.ogc.Versioned');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable SLD version 1.0.0.
|
||||
*/
|
||||
ol.ENABLE_SLD_1_0_0 = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
* @extends {ol.parser.ogc.Versioned}
|
||||
*/
|
||||
ol.parser.ogc.SLD = function(opt_options) {
|
||||
opt_options = opt_options || {};
|
||||
opt_options['defaultVersion'] = '1.0.0';
|
||||
this.parsers = {};
|
||||
if (ol.ENABLE_SLD_1_0_0) {
|
||||
this.parsers['v1_0_0'] = ol.parser.ogc.SLD_v1_0_0;
|
||||
}
|
||||
goog.base(this, opt_options);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.SLD, ol.parser.ogc.Versioned);
|
||||
732
old/src/ol/parser/ogc/sldparser_v1.js
Normal file
732
old/src/ol/parser/ogc/sldparser_v1.js
Normal file
@@ -0,0 +1,732 @@
|
||||
goog.provide('ol.parser.ogc.SLD_v1');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.parser.XML');
|
||||
goog.require('ol.parser.ogc.Filter_v1_0_0');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Icon');
|
||||
goog.require('ol.style.Rule');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.Text');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read Styled Layer Descriptor (SLD).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1 = function() {
|
||||
this.defaultNamespaceURI = 'http://www.opengis.net/sld';
|
||||
this.readers = {};
|
||||
this.readers[this.defaultNamespaceURI] = {
|
||||
'StyledLayerDescriptor': function(node, sld) {
|
||||
sld.version = node.getAttribute('version');
|
||||
this.readChildNodes(node, sld);
|
||||
},
|
||||
'Name': function(node, obj) {
|
||||
obj.name = this.getChildValue(node);
|
||||
},
|
||||
'Title': function(node, obj) {
|
||||
obj.title = this.getChildValue(node);
|
||||
},
|
||||
'Abstract': function(node, obj) {
|
||||
obj.description = this.getChildValue(node);
|
||||
},
|
||||
'NamedLayer': function(node, sld) {
|
||||
var layer = {
|
||||
userStyles: [],
|
||||
namedStyles: []
|
||||
};
|
||||
this.readChildNodes(node, layer);
|
||||
sld.namedLayers[layer.name] = layer;
|
||||
},
|
||||
'NamedStyle': function(node, layer) {
|
||||
layer.namedStyles.push(
|
||||
this.getChildValue(node.firstChild)
|
||||
);
|
||||
},
|
||||
'UserStyle': function(node, layer) {
|
||||
var obj = {rules: []};
|
||||
this.featureTypeCounter = -1;
|
||||
this.readChildNodes(node, obj);
|
||||
layer.userStyles.push(new ol.style.Style(obj));
|
||||
},
|
||||
'FeatureTypeStyle': function(node, style) {
|
||||
++this.featureTypeCounter;
|
||||
var obj = {
|
||||
rules: style.rules
|
||||
};
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Rule': function(node, obj) {
|
||||
var config = {symbolizers: []};
|
||||
this.readChildNodes(node, config);
|
||||
var rule = new ol.style.Rule(config);
|
||||
obj.rules.push(rule);
|
||||
},
|
||||
'ElseFilter': function(node, rule) {
|
||||
rule.elseFilter = true;
|
||||
},
|
||||
'MinScaleDenominator': function(node, rule) {
|
||||
rule.minResolution = this.getResolutionFromScaleDenominator_(
|
||||
parseFloat(this.getChildValue(node)));
|
||||
},
|
||||
'MaxScaleDenominator': function(node, rule) {
|
||||
rule.maxResolution = this.getResolutionFromScaleDenominator_(
|
||||
parseFloat(this.getChildValue(node)));
|
||||
},
|
||||
'TextSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.color = goog.isDef(config.fill) ? config.fill.fillColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fontColor;
|
||||
delete config.fill;
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Text(/** @type {ol.style.TextOptions} */(config))
|
||||
);
|
||||
},
|
||||
'Label': function(node, symbolizer) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
var value = ogcreaders._expression.call(this, node);
|
||||
if (value) {
|
||||
symbolizer.text = value;
|
||||
}
|
||||
},
|
||||
'Font': function(node, symbolizer) {
|
||||
this.readChildNodes(node, symbolizer);
|
||||
},
|
||||
'Halo': function(node, symbolizer) {
|
||||
var obj = {};
|
||||
this.readChildNodes(node, obj);
|
||||
symbolizer.stroke = new ol.style.Stroke({
|
||||
color: goog.isDef(obj.fill.fillColor) ? obj.fill.fillColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.haloColor,
|
||||
width: goog.isDef(obj.haloRadius) ? obj.haloRadius * 2 :
|
||||
ol.parser.ogc.SLD_v1.defaults_.haloRadius,
|
||||
opacity: goog.isDef(obj.fill.fillOpacity) ? obj.fill.fillOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.haloOpacity
|
||||
});
|
||||
},
|
||||
'Radius': function(node, symbolizer) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
var radius = ogcreaders._expression.call(this, node);
|
||||
goog.asserts.assertInstanceof(radius, ol.expr.Literal,
|
||||
'radius expected to be an ol.expr.Literal');
|
||||
if (goog.isDef(radius)) {
|
||||
symbolizer.haloRadius = radius.getValue();
|
||||
}
|
||||
},
|
||||
'LineSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Stroke(config)
|
||||
);
|
||||
},
|
||||
'PolygonSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
if (goog.isDef(config.fill)) {
|
||||
var fill = {
|
||||
color: config.fill.fillColor.getValue(),
|
||||
opacity: goog.isDef(config.fill.fillOpacity) ?
|
||||
config.fill.fillOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fillOpacity
|
||||
};
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Fill(fill)
|
||||
);
|
||||
delete config.fill;
|
||||
}
|
||||
if (goog.isDef(config.stroke)) {
|
||||
var stroke = {
|
||||
color: config.stroke.strokeColor.getValue(),
|
||||
opacity: goog.isDef(config.stroke.strokeOpacity) ?
|
||||
config.stroke.strokeOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeOpacity,
|
||||
width: goog.isDef(config.stroke.strokeWidth) ?
|
||||
config.stroke.strokeWidth :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeWidth
|
||||
};
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Stroke(stroke)
|
||||
);
|
||||
delete config.stroke;
|
||||
}
|
||||
|
||||
},
|
||||
'PointSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
if (config.fill) {
|
||||
var fillConfig = {
|
||||
color: goog.isDef(config.fill.fillColor) ?
|
||||
config.fill.fillColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fillColor,
|
||||
opacity: goog.isDef(config.fill.fillOpacity) ?
|
||||
config.fill.fillOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fillOpacity
|
||||
};
|
||||
config.fill = new ol.style.Fill(fillConfig);
|
||||
}
|
||||
if (config.stroke) {
|
||||
var strokeConfig = {
|
||||
color: goog.isDef(config.stroke.strokeColor) ?
|
||||
config.stroke.strokeColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeColor,
|
||||
width: goog.isDef(config.stroke.strokeWidth) ?
|
||||
config.stroke.strokeWidth :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeWidth,
|
||||
opacity: goog.isDef(config.stroke.strokeOpacity) ?
|
||||
config.stroke.strokeOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeOpacity
|
||||
};
|
||||
config.stroke = new ol.style.Stroke(strokeConfig);
|
||||
}
|
||||
var symbolizer;
|
||||
if (goog.isDef(config.externalGraphic)) {
|
||||
config.width = config.height = config.size;
|
||||
symbolizer = new ol.style.Icon(
|
||||
/** @type {ol.style.IconOptions} */(config));
|
||||
} else {
|
||||
symbolizer = new ol.style.Shape(config);
|
||||
}
|
||||
rule.symbolizers.push(symbolizer);
|
||||
},
|
||||
'Stroke': function(node, symbolizer) {
|
||||
var stroke = {};
|
||||
this.readChildNodes(node, stroke);
|
||||
symbolizer.stroke = stroke;
|
||||
},
|
||||
'Fill': function(node, symbolizer) {
|
||||
var fill = {};
|
||||
this.readChildNodes(node, fill);
|
||||
symbolizer.fill = fill;
|
||||
},
|
||||
'CssParameter': function(node, symbolizer) {
|
||||
var cssProperty = node.getAttribute('name');
|
||||
var symProperty = ol.parser.ogc.SLD_v1.cssMap_[cssProperty];
|
||||
if (symProperty) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
symbolizer[symProperty] = ogcreaders._expression.call(this, node);
|
||||
}
|
||||
},
|
||||
'Graphic': function(node, symbolizer) {
|
||||
var graphic = {};
|
||||
// painter's order not respected here, clobber previous with next
|
||||
this.readChildNodes(node, graphic);
|
||||
// directly properties with names that match symbolizer properties
|
||||
var properties = [
|
||||
'stroke', 'fill', 'rotation', 'opacity'
|
||||
];
|
||||
var prop, value;
|
||||
for (var i = 0, ii = properties.length; i < ii; ++i) {
|
||||
prop = properties[i];
|
||||
value = graphic[prop];
|
||||
if (goog.isDef(value)) {
|
||||
symbolizer[prop] = value;
|
||||
}
|
||||
}
|
||||
// set other generic properties with specific graphic property names
|
||||
if (goog.isDef(graphic.graphicName)) {
|
||||
symbolizer.type = graphic.graphicName;
|
||||
}
|
||||
if (goog.isDef(graphic.size)) {
|
||||
var pointRadius = graphic.size / 2;
|
||||
if (isNaN(pointRadius)) {
|
||||
// likely a property name
|
||||
symbolizer.size = graphic.size;
|
||||
} else {
|
||||
symbolizer.size = graphic.size / 2;
|
||||
}
|
||||
}
|
||||
if (goog.isDef(graphic.href)) {
|
||||
symbolizer.url = graphic.href;
|
||||
}
|
||||
},
|
||||
'ExternalGraphic': function(node, graphic) {
|
||||
this.readChildNodes(node, graphic);
|
||||
},
|
||||
'Mark': function(node, graphic) {
|
||||
this.readChildNodes(node, graphic);
|
||||
},
|
||||
'WellKnownName': function(node, graphic) {
|
||||
graphic.graphicName = this.getChildValue(node);
|
||||
},
|
||||
'Opacity': function(node, obj) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
obj.opacity = ogcreaders._expression.call(this, node);
|
||||
},
|
||||
'Size': function(node, obj) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
obj.size = ogcreaders._expression.call(this, node);
|
||||
},
|
||||
'Rotation': function(node, obj) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
obj.rotation = ogcreaders._expression.call(this, node);
|
||||
},
|
||||
'OnlineResource': function(node, obj) {
|
||||
obj.href = this.getAttributeNS(
|
||||
node, 'http://www.w3.org/1999/xlink', 'href'
|
||||
);
|
||||
},
|
||||
'Format': function(node, graphic) {
|
||||
graphic.graphicFormat = this.getChildValue(node);
|
||||
}
|
||||
};
|
||||
this.writers = {};
|
||||
this.writers[this.defaultNamespaceURI] = {
|
||||
'StyledLayerDescriptor': function(sld) {
|
||||
var node = this.createElementNS('sld:StyledLayerDescriptor');
|
||||
node.setAttribute('version', this.version);
|
||||
if (goog.isDef(sld.name)) {
|
||||
this.writeNode('Name', sld.name, null, node);
|
||||
}
|
||||
if (goog.isDef(sld.title)) {
|
||||
this.writeNode('Title', sld.title, null, node);
|
||||
}
|
||||
if (goog.isDef(sld.description)) {
|
||||
this.writeNode('Abstract', sld.description, null, node);
|
||||
}
|
||||
goog.object.forEach(sld.namedLayers, function(layer) {
|
||||
this.writeNode('NamedLayer', layer, null, node);
|
||||
}, this);
|
||||
return node;
|
||||
},
|
||||
'Name': function(name) {
|
||||
var node = this.createElementNS('sld:Name');
|
||||
node.appendChild(this.createTextNode(name));
|
||||
return node;
|
||||
},
|
||||
'Title': function(title) {
|
||||
var node = this.createElementNS('sld:Title');
|
||||
node.appendChild(this.createTextNode(title));
|
||||
return node;
|
||||
},
|
||||
'Abstract': function(description) {
|
||||
var node = this.createElementNS('sld:Abstract');
|
||||
node.appendChild(this.createTextNode(description));
|
||||
return node;
|
||||
},
|
||||
'NamedLayer': function(layer) {
|
||||
var node = this.createElementNS('sld:NamedLayer');
|
||||
this.writeNode('Name', layer.name, null, node);
|
||||
var i, ii;
|
||||
if (layer.namedStyles) {
|
||||
for (i = 0, ii = layer.namedStyles.length; i < ii; ++i) {
|
||||
this.writeNode('NamedStyle', layer.namedStyles[i], null, node);
|
||||
}
|
||||
}
|
||||
if (layer.userStyles) {
|
||||
for (i = 0, ii = layer.userStyles.length; i < ii; ++i) {
|
||||
this.writeNode('UserStyle', layer.userStyles[i], null, node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'NamedStyle': function(name) {
|
||||
var node = this.createElementNS('sld:NamedStyle');
|
||||
this.writeNode('Name', name, null, node);
|
||||
return node;
|
||||
},
|
||||
'UserStyle': function(style) {
|
||||
var node = this.createElementNS('sld:UserStyle');
|
||||
var name = style.getName(), title = style.getTitle();
|
||||
if (goog.isDef(name)) {
|
||||
this.writeNode('Name', name, null, node);
|
||||
}
|
||||
if (goog.isDef(title)) {
|
||||
this.writeNode('Title', title, null, node);
|
||||
}
|
||||
// TODO sorting by zIndex
|
||||
this.writeNode('FeatureTypeStyle', style, null, node);
|
||||
return node;
|
||||
},
|
||||
'FeatureTypeStyle': function(style) {
|
||||
var node = this.createElementNS('sld:FeatureTypeStyle');
|
||||
var rules = style.getRules();
|
||||
for (var i = 0, ii = rules.length; i < ii; ++i) {
|
||||
this.writeNode('Rule', rules[i], null, node);
|
||||
}
|
||||
var symbolizers = style.getSymbolizers();
|
||||
if (symbolizers.length > 0) {
|
||||
// wrap this in a Rule with an ElseFilter
|
||||
var rule = new ol.style.Rule({symbolizers: symbolizers});
|
||||
rule.elseFilter = true;
|
||||
this.writeNode('Rule', rule, null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'Rule': function(rule) {
|
||||
var node = this.createElementNS('sld:Rule');
|
||||
var filter = rule.getFilter();
|
||||
var name = rule.getName(), title = rule.getTitle();
|
||||
if (goog.isDef(name)) {
|
||||
this.writeNode('Name', name, null, node);
|
||||
}
|
||||
if (goog.isDef(title)) {
|
||||
this.writeNode('Title', title, null, node);
|
||||
}
|
||||
if (rule.elseFilter === true) {
|
||||
this.writeNode('ElseFilter', null, null, node);
|
||||
} else if (filter) {
|
||||
this.writeNode('Filter', filter, this.filter_.defaultNamespaceURI,
|
||||
node);
|
||||
}
|
||||
var minResolution = rule.getMinResolution();
|
||||
if (minResolution > 0) {
|
||||
this.writeNode('MinScaleDenominator',
|
||||
this.getScaleDenominatorFromResolution_(minResolution),
|
||||
null, node);
|
||||
}
|
||||
var maxResolution = rule.getMaxResolution();
|
||||
if (maxResolution < Infinity) {
|
||||
this.writeNode('MaxScaleDenominator',
|
||||
this.getScaleDenominatorFromResolution_(maxResolution),
|
||||
null, node);
|
||||
}
|
||||
var type, symbolizer, symbolizers = rule.getSymbolizers();
|
||||
if (symbolizers) {
|
||||
for (var i = 0, ii = symbolizers.length; i < ii; ++i) {
|
||||
symbolizer = symbolizers[i];
|
||||
if (symbolizer instanceof ol.style.Text) {
|
||||
type = 'Text';
|
||||
} else if (symbolizer instanceof ol.style.Stroke) {
|
||||
type = 'Line';
|
||||
} else if (symbolizer instanceof ol.style.Fill) {
|
||||
type = 'Polygon';
|
||||
} else if (symbolizer instanceof ol.style.Shape ||
|
||||
symbolizer instanceof ol.style.Icon) {
|
||||
type = 'Point';
|
||||
}
|
||||
if (goog.isDef(type)) {
|
||||
this.writeNode(type + 'Symbolizer', symbolizer, null, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'PointSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:PointSymbolizer');
|
||||
this.writeNode('Graphic', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Mark': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Mark');
|
||||
this.writeNode('WellKnownName', symbolizer.getType(), null, node);
|
||||
var fill = symbolizer.getFill();
|
||||
if (!goog.isNull(fill)) {
|
||||
this.writeNode('Fill', fill, null, node);
|
||||
}
|
||||
var stroke = symbolizer.getStroke();
|
||||
if (!goog.isNull(stroke)) {
|
||||
this.writeNode('Stroke', stroke, null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'WellKnownName': function(name) {
|
||||
var node = this.createElementNS('sld:WellKnownName');
|
||||
node.appendChild(this.createTextNode(name));
|
||||
return node;
|
||||
},
|
||||
'Graphic': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Graphic');
|
||||
var size;
|
||||
if (symbolizer instanceof ol.style.Icon) {
|
||||
this.writeNode('ExternalGraphic', symbolizer, null, node);
|
||||
var opacity = symbolizer.getOpacity();
|
||||
goog.asserts.assertInstanceof(opacity, ol.expr.Literal,
|
||||
'Only ol.expr.Literal supported for graphicOpacity');
|
||||
this.writeNode('Opacity', opacity.getValue(), null, node);
|
||||
size = symbolizer.getWidth();
|
||||
} else if (symbolizer instanceof ol.style.Shape) {
|
||||
this.writeNode('Mark', symbolizer, null, node);
|
||||
size = symbolizer.getSize();
|
||||
}
|
||||
this.writeNode('Size', size, null, node);
|
||||
if (symbolizer instanceof ol.style.Icon) {
|
||||
var rotation = symbolizer.getRotation();
|
||||
goog.asserts.assertInstanceof(rotation, ol.expr.Literal,
|
||||
'Only ol.expr.Literal supported for rotation');
|
||||
this.writeNode('Rotation', rotation.getValue(), null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'PolygonSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:PolygonSymbolizer');
|
||||
this.writeNode('Fill', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Fill': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Fill');
|
||||
var fillColor = symbolizer.getColor();
|
||||
var msg = 'Only ol.expr.Literal supported for Fill properties';
|
||||
goog.asserts.assertInstanceof(fillColor, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: fillColor.getValue(),
|
||||
key: 'fillColor'
|
||||
}, null, node);
|
||||
var fillOpacity = symbolizer.getOpacity();
|
||||
goog.asserts.assertInstanceof(fillOpacity, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: fillOpacity.getValue(),
|
||||
key: 'fillOpacity'
|
||||
}, null, node);
|
||||
return node;
|
||||
},
|
||||
'TextSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:TextSymbolizer');
|
||||
var text = symbolizer.getText();
|
||||
this.writeNode('Label', text, null, node);
|
||||
this.writeNode('Font', symbolizer, null, node);
|
||||
var stroke = symbolizer.getStroke();
|
||||
if (!goog.isNull(stroke)) {
|
||||
this.writeNode('Halo', stroke, null, node);
|
||||
}
|
||||
var color = symbolizer.getColor();
|
||||
goog.asserts.assertInstanceof(color, ol.expr.Literal,
|
||||
'font color should be ol.expr.Literal');
|
||||
this.writeNode('Fill', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Halo': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Halo');
|
||||
goog.asserts.assertInstanceof(symbolizer.getWidth(), ol.expr.Literal,
|
||||
'Only ol.expr.Literal supported for haloRadius');
|
||||
this.writeNode('Radius', symbolizer.getWidth().getValue() / 2, null,
|
||||
node);
|
||||
this.writeNode('Fill', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Radius': function(value) {
|
||||
var node = this.createElementNS('sld:Radius');
|
||||
node.appendChild(this.createTextNode(value));
|
||||
return node;
|
||||
},
|
||||
'LineSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:LineSymbolizer');
|
||||
this.writeNode('Stroke', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Stroke': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Stroke');
|
||||
var strokeColor = symbolizer.getColor();
|
||||
var msg = 'SLD writing of stroke properties only supported ' +
|
||||
'for ol.expr.Literal';
|
||||
goog.asserts.assertInstanceof(strokeColor, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: strokeColor.getValue(),
|
||||
key: 'strokeColor'
|
||||
}, null, node);
|
||||
var strokeOpacity = symbolizer.getOpacity();
|
||||
goog.asserts.assertInstanceof(strokeOpacity, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: strokeOpacity.getValue(),
|
||||
key: 'strokeOpacity'
|
||||
}, null, node);
|
||||
var strokeWidth = symbolizer.getWidth();
|
||||
goog.asserts.assertInstanceof(strokeWidth, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: strokeWidth.getValue(),
|
||||
key: 'strokeWidth'
|
||||
}, null, node);
|
||||
// TODO strokeDashstyle and strokeLinecap
|
||||
return node;
|
||||
},
|
||||
'CssParameter': function(obj) {
|
||||
// not handling ogc:expressions for now
|
||||
var name = ol.parser.ogc.SLD_v1.getCssProperty_(obj.key);
|
||||
if (goog.isDef(name)) {
|
||||
var node = this.createElementNS('sld:CssParameter');
|
||||
node.setAttribute('name', name);
|
||||
node.appendChild(this.createTextNode(obj.value));
|
||||
return node;
|
||||
}
|
||||
},
|
||||
'Label': function(label) {
|
||||
var node = this.createElementNS('sld:Label');
|
||||
this.filter_.writeOgcExpression(label, node);
|
||||
return node;
|
||||
},
|
||||
'Font': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Font');
|
||||
this.writeNode('CssParameter', {
|
||||
key: 'fontFamily',
|
||||
value: symbolizer.getFontFamily().getValue()
|
||||
}, null, node);
|
||||
this.writeNode('CssParameter', {
|
||||
key: 'fontSize',
|
||||
value: symbolizer.getFontSize().getValue()
|
||||
}, null, node);
|
||||
// TODO fontWeight and fontStyle
|
||||
return node;
|
||||
},
|
||||
'MinScaleDenominator': function(scale) {
|
||||
var node = this.createElementNS('sld:MinScaleDenominator');
|
||||
node.appendChild(this.createTextNode(scale));
|
||||
return node;
|
||||
},
|
||||
'MaxScaleDenominator': function(scale) {
|
||||
var node = this.createElementNS('sld:MaxScaleDenominator');
|
||||
node.appendChild(this.createTextNode(scale));
|
||||
return node;
|
||||
},
|
||||
'Size': function(value) {
|
||||
var node = this.createElementNS('sld:Size');
|
||||
this.filter_.writeOgcExpression(value, node);
|
||||
return node;
|
||||
}
|
||||
};
|
||||
this.filter_ = new ol.parser.ogc.Filter_v1_0_0();
|
||||
for (var uri in this.filter_.readers) {
|
||||
for (var key in this.filter_.readers[uri]) {
|
||||
if (!goog.isDef(this.readers[uri])) {
|
||||
this.readers[uri] = {};
|
||||
}
|
||||
this.readers[uri][key] = goog.bind(this.filter_.readers[uri][key],
|
||||
this.filter_);
|
||||
}
|
||||
}
|
||||
for (var uri in this.filter_.writers) {
|
||||
for (var key in this.filter_.writers[uri]) {
|
||||
if (!goog.isDef(this.writers[uri])) {
|
||||
this.writers[uri] = {};
|
||||
}
|
||||
this.writers[uri][key] = goog.bind(this.filter_.writers[uri][key],
|
||||
this.filter_);
|
||||
}
|
||||
}
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.SLD_v1, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.cssMap_ = {
|
||||
'stroke': 'strokeColor',
|
||||
'stroke-opacity': 'strokeOpacity',
|
||||
'stroke-width': 'strokeWidth',
|
||||
'stroke-linecap': 'strokeLinecap',
|
||||
'stroke-dasharray': 'strokeDashstyle',
|
||||
'fill': 'fillColor',
|
||||
'fill-opacity': 'fillOpacity',
|
||||
'font-family': 'fontFamily',
|
||||
'font-size': 'fontSize',
|
||||
'font-weight': 'fontWeight',
|
||||
'font-style': 'fontStyle'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.defaults_ = {
|
||||
fillOpacity: 1,
|
||||
strokeOpacity: 1,
|
||||
strokeWidth: 1,
|
||||
strokeColor: '#000000',
|
||||
haloColor: '#FFFFFF',
|
||||
haloOpacity: 1,
|
||||
haloRadius: 1,
|
||||
fillColor: '#808080',
|
||||
fontColor: '#000000'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {string} sym Symbolizer property.
|
||||
* @return {string|undefined} The css property that matches the symbolizer
|
||||
* property.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.getCssProperty_ = function(sym) {
|
||||
return goog.object.findKey(ol.parser.ogc.SLD_v1.cssMap_,
|
||||
function(value, key, obj) {
|
||||
return (sym === value);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {number} scaleDenominator The scale denominator to convert to
|
||||
* resolution.
|
||||
* @return {number} resolution.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.getResolutionFromScaleDenominator_ =
|
||||
function(scaleDenominator) {
|
||||
var dpi = 25.4 / 0.28;
|
||||
var mpu = ol.METERS_PER_UNIT[this.units];
|
||||
return 1 / ((1 / scaleDenominator) * (mpu * 39.37) * dpi);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {number} resolution The resolution to convert to scale denominator.
|
||||
* @return {number} scale denominator.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.getScaleDenominatorFromResolution_ =
|
||||
function(resolution) {
|
||||
var dpi = 25.4 / 0.28;
|
||||
var mpu = ol.METERS_PER_UNIT[this.units];
|
||||
return resolution * mpu * 39.37 * dpi;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document|Element} data Data to read.
|
||||
* @param {ol.parser.SLDReadOptions=} opt_options Read options.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.read = function(data, opt_options) {
|
||||
var units = 'm';
|
||||
if (goog.isDef(opt_options) && goog.isDef(opt_options.units)) {
|
||||
units = opt_options.units;
|
||||
}
|
||||
this.units = units;
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
if (data && data.nodeType == 9) {
|
||||
data = data.documentElement;
|
||||
}
|
||||
var obj = {namedLayers: {}};
|
||||
this.readNode(data, obj);
|
||||
delete this.units;
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} style The style to write out.
|
||||
* @param {ol.parser.SLDWriteOptions=} opt_options Write options.
|
||||
* @return {string} The serialized SLD.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.write = function(style, opt_options) {
|
||||
var units = 'm';
|
||||
if (goog.isDef(opt_options) && goog.isDef(opt_options.units)) {
|
||||
units = opt_options.units;
|
||||
}
|
||||
this.units = units;
|
||||
var root = this.writeNode('StyledLayerDescriptor', style);
|
||||
this.setAttributeNS(
|
||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'xsi:schemaLocation', this.schemaLocation);
|
||||
var result = this.serialize(root);
|
||||
delete this.units;
|
||||
return result;
|
||||
};
|
||||
18
old/src/ol/parser/ogc/sldparser_v1_0_0.js
Normal file
18
old/src/ol/parser/ogc/sldparser_v1_0_0.js
Normal file
@@ -0,0 +1,18 @@
|
||||
goog.provide('ol.parser.ogc.SLD_v1_0_0');
|
||||
|
||||
goog.require('ol.parser.ogc.SLD_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.SLD_v1}
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1_0_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.0.0';
|
||||
this.schemaLocation = 'http://www.opengis.net/sld ' +
|
||||
'http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd';
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.SLD_v1_0_0,
|
||||
ol.parser.ogc.SLD_v1);
|
||||
37
old/src/ol/parser/ogc/wfsparser.js
Normal file
37
old/src/ol/parser/ogc/wfsparser.js
Normal file
@@ -0,0 +1,37 @@
|
||||
goog.require('ol.parser.ogc.Versioned');
|
||||
goog.provide('ol.parser.ogc.WFS');
|
||||
goog.require('ol.parser.ogc.WFS_v1_0_0');
|
||||
goog.require('ol.parser.ogc.WFS_v1_1_0');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable OGC WFS version 1.0.0.
|
||||
*/
|
||||
ol.ENABLE_WFS_1_0_0 = true;
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable OGC WFS version 1.1.0.
|
||||
*/
|
||||
ol.ENABLE_WFS_1_1_0 = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
* @extends {ol.parser.ogc.Versioned}
|
||||
*/
|
||||
ol.parser.ogc.WFS = function(opt_options) {
|
||||
var options = opt_options || {};
|
||||
options['defaultVersion'] = '1.0.0';
|
||||
this.parsers = {};
|
||||
if (ol.ENABLE_WFS_1_0_0) {
|
||||
this.parsers['v1_0_0'] = ol.parser.ogc.WFS_v1_0_0;
|
||||
}
|
||||
if (ol.ENABLE_WFS_1_1_0) {
|
||||
this.parsers['v1_1_0'] = ol.parser.ogc.WFS_v1_1_0;
|
||||
}
|
||||
goog.base(this, options);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WFS, ol.parser.ogc.Versioned);
|
||||
181
old/src/ol/parser/ogc/wfsparser_v1.js
Normal file
181
old/src/ol/parser/ogc/wfsparser_v1.js
Normal file
@@ -0,0 +1,181 @@
|
||||
goog.provide('ol.parser.ogc.WFS_v1');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{featureNS: string,
|
||||
featurePrefix: string,
|
||||
featureTypes: Array.<string>,
|
||||
handle: string,
|
||||
outputFormat: string,
|
||||
nativeElements: Array.<{
|
||||
vendorId: string,
|
||||
safeToIgnore: boolean,
|
||||
value: string
|
||||
}>,
|
||||
maxFeatures: number}}
|
||||
*/
|
||||
ol.parser.WFSWriteOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1 = function() {
|
||||
this.defaultNamespaceURI = 'http://www.opengis.net/wfs';
|
||||
// TODO set errorProperty
|
||||
this.readers = {};
|
||||
this.readers[this.defaultNamespaceURI] = {
|
||||
'FeatureCollection': function(node, obj) {
|
||||
obj.features = [];
|
||||
this.readChildNodes(node, obj);
|
||||
}
|
||||
};
|
||||
this.writers = {};
|
||||
this.writers[this.defaultNamespaceURI] = {
|
||||
'GetFeature': function(options) {
|
||||
options = /** @type {ol.parser.WFSWriteOptions} */(options);
|
||||
var node = this.createElementNS('wfs:GetFeature');
|
||||
node.setAttribute('service', 'WFS');
|
||||
node.setAttribute('version', this.version);
|
||||
if (goog.isDef(options)) {
|
||||
if (goog.isDef(options.handle)) {
|
||||
node.setAttribute('handle', options.handle);
|
||||
}
|
||||
if (goog.isDef(options.outputFormat)) {
|
||||
node.setAttribute('outputFormat', options.outputFormat);
|
||||
}
|
||||
if (goog.isDef(options.maxFeatures)) {
|
||||
node.setAttribute('maxFeatures', options.maxFeatures);
|
||||
}
|
||||
}
|
||||
for (var i = 0, ii = options.featureTypes.length; i < ii; i++) {
|
||||
options.featureType = options.featureTypes[i];
|
||||
this.writeNode('Query', options, null, node);
|
||||
}
|
||||
this.setAttributeNS(
|
||||
node, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'xsi:schemaLocation', this.schemaLocation);
|
||||
return {node: node, options: options};
|
||||
},
|
||||
'Transaction': function(obj) {
|
||||
obj = obj || {};
|
||||
var options = /** {ol.parser.WFSWriteOptions} */(obj.options || {});
|
||||
var node = this.createElementNS('wfs:Transaction');
|
||||
node.setAttribute('service', 'WFS');
|
||||
node.setAttribute('version', this.version);
|
||||
if (goog.isDef(options.handle)) {
|
||||
node.setAttribute('handle', options.handle);
|
||||
}
|
||||
var i, ii;
|
||||
var features = obj.features;
|
||||
if (goog.isDefAndNotNull(features)) {
|
||||
// TODO implement multi option for geometry types
|
||||
var name, feature;
|
||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||
feature = features[i];
|
||||
// TODO Update (use feature.getOriginal())
|
||||
// TODO Insert and Delete
|
||||
if (goog.isDef(name)) {
|
||||
this.writeNode(name, {
|
||||
feature: feature,
|
||||
options: options
|
||||
}, null, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (goog.isDef(options.nativeElements)) {
|
||||
for (i = 0, ii = options.nativeElements.length; i < ii; ++i) {
|
||||
this.writeNode('Native', options.nativeElements[i], null, node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'Native': function(nativeElement) {
|
||||
var node = this.createElementNS('wfs:Native');
|
||||
node.setAttribute('vendorId', nativeElement.vendorId);
|
||||
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
|
||||
node.appendChild(this.createTextNode(nativeElement.value));
|
||||
return node;
|
||||
}
|
||||
};
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WFS_v1, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.parser.ogc.Filter_v1_0_0|ol.parser.ogc.Filter_v1_1_0}
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1.prototype.getFilterParser = function() {
|
||||
return this.filter_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.parser.ogc.Filter_v1_0_0|ol.parser.ogc.Filter_v1_1_0} filter The
|
||||
* Filter parser to use.
|
||||
* @protected
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1.prototype.setFilterParser = function(filter) {
|
||||
this.filter_ = filter;
|
||||
for (var uri in this.filter_.readers) {
|
||||
for (var key in this.filter_.readers[uri]) {
|
||||
if (!goog.isDef(this.readers[uri])) {
|
||||
this.readers[uri] = {};
|
||||
}
|
||||
// do not overwrite any readers
|
||||
if (!goog.isDef(this.readers[uri][key])) {
|
||||
this.readers[uri][key] = goog.bind(this.filter_.readers[uri][key],
|
||||
this.filter_);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (uri in this.filter_.writers) {
|
||||
for (key in this.filter_.writers[uri]) {
|
||||
if (!goog.isDef(this.writers[uri])) {
|
||||
this.writers[uri] = {};
|
||||
}
|
||||
// do not overwrite any writers
|
||||
if (!goog.isDef(this.writers[uri][key])) {
|
||||
this.writers[uri][key] = goog.bind(this.filter_.writers[uri][key],
|
||||
this.filter_);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document|Element} data Data to read.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1.prototype.read = function(data) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
if (data && data.nodeType == 9) {
|
||||
data = data.documentElement;
|
||||
}
|
||||
var obj = {};
|
||||
this.readNode(data, obj);
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features The features to write out.
|
||||
* @param {ol.parser.WFSWriteOptions} options Write options.
|
||||
* @return {string} A serialized WFS transaction.
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1.prototype.write = function(features, options) {
|
||||
var root = this.writeNode('Transaction', {features: features,
|
||||
options: options});
|
||||
this.setAttributeNS(
|
||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'xsi:schemaLocation', this.schemaLocation);
|
||||
return this.serialize(root);
|
||||
};
|
||||
79
old/src/ol/parser/ogc/wfsparser_v1_0_0.js
Normal file
79
old/src/ol/parser/ogc/wfsparser_v1_0_0.js
Normal file
@@ -0,0 +1,79 @@
|
||||
goog.provide('ol.parser.ogc.WFS_v1_0_0');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.Filter_v1_0_0');
|
||||
goog.require('ol.parser.ogc.WFS_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WFS_v1}
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1_0_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.0.0';
|
||||
this.schemaLocation = this.defaultNamespaceURI + ' ' +
|
||||
'http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd';
|
||||
goog.object.extend(this.readers[this.defaultNamespaceURI], {
|
||||
'WFS_TransactionResponse': function(node, obj) {
|
||||
obj.insertIds = [];
|
||||
obj.success = false;
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'InsertResult': function(node, container) {
|
||||
var obj = {fids: []};
|
||||
this.readChildNodes(node, obj);
|
||||
for (var key in obj.fids) {
|
||||
container.insertIds.push(key);
|
||||
}
|
||||
},
|
||||
'TransactionResult': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Status': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'SUCCESS': function(node, obj) {
|
||||
obj.success = true;
|
||||
}
|
||||
});
|
||||
goog.object.extend(this.writers[this.defaultNamespaceURI], {
|
||||
'GetFeature': goog.functions.compose(
|
||||
function(obj) {
|
||||
return obj.node;
|
||||
},
|
||||
this.writers['http://www.opengis.net/wfs']['GetFeature']
|
||||
),
|
||||
'Query': function(options) {
|
||||
var prefix = goog.isDef(options.featurePrefix) ? options.featurePrefix +
|
||||
':' : '';
|
||||
var node = this.createElementNS('wfs:Query');
|
||||
node.setAttribute('typeName', prefix + options.featureType);
|
||||
if (goog.isDef(options.srsNameInQuery) && goog.isDef(options.srsName)) {
|
||||
node.setAttribute('srsName', options.srsName);
|
||||
}
|
||||
if (goog.isDef(options.featureNS)) {
|
||||
node.setAttribute('xmlns:' + options.featurePrefix, options.featureNS);
|
||||
}
|
||||
if (goog.isDef(options.propertyNames)) {
|
||||
for (var i = 0, ii = options.propertyNames.length; i < ii; i++) {
|
||||
this.writeNode('PropertyName', options.propertyNames[i],
|
||||
'http://www.opengis.net/ogc', node);
|
||||
}
|
||||
}
|
||||
if (goog.isDef(options.filter)) {
|
||||
this.writeNode('Filter', options.filter,
|
||||
'http://www.opengis.net/ogc', node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
});
|
||||
var filter = new ol.parser.ogc.Filter_v1_0_0();
|
||||
delete filter.getGmlParser().featureNS;
|
||||
this.setFilterParser(filter);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WFS_v1_0_0,
|
||||
ol.parser.ogc.WFS_v1);
|
||||
101
old/src/ol/parser/ogc/wfsparser_v1_1_0.js
Normal file
101
old/src/ol/parser/ogc/wfsparser_v1_1_0.js
Normal file
@@ -0,0 +1,101 @@
|
||||
goog.provide('ol.parser.ogc.WFS_v1_1_0');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.parser.ogc.Filter_v1_1_0');
|
||||
goog.require('ol.parser.ogc.WFS_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WFS_v1}
|
||||
*/
|
||||
ol.parser.ogc.WFS_v1_1_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.1.0';
|
||||
this.schemaLocation = this.defaultNamespaceURI + ' ' +
|
||||
'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd';
|
||||
goog.object.extend(this.readers[this.defaultNamespaceURI], {
|
||||
'FeatureCollection': goog.functions.sequence(
|
||||
function(node, obj) {
|
||||
var numberOfFeatures = node.getAttribute('numberOfFeatures');
|
||||
if (!goog.isNull(numberOfFeatures)) {
|
||||
obj.numberOfFeatures = parseInt(numberOfFeatures, 10);
|
||||
}
|
||||
},
|
||||
this.readers['http://www.opengis.net/wfs']['FeatureCollection']
|
||||
),
|
||||
'TransactionResponse': function(node, obj) {
|
||||
obj.insertIds = [];
|
||||
obj.success = false;
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'TransactionSummary': function(node, obj) {
|
||||
// this is a limited test of success
|
||||
obj.success = true;
|
||||
},
|
||||
'InsertResults': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Feature': function(node, container) {
|
||||
var obj = {};
|
||||
this.readChildNodes(node, obj);
|
||||
for (var key in obj.fids) {
|
||||
container.insertIds.push(key);
|
||||
}
|
||||
}
|
||||
});
|
||||
goog.object.extend(this.writers[this.defaultNamespaceURI], {
|
||||
'GetFeature': goog.functions.compose(
|
||||
function(obj) {
|
||||
var options = obj.options;
|
||||
var node = obj.node;
|
||||
if (goog.isDef(options)) {
|
||||
if (goog.isDef(options.resultType)) {
|
||||
node.setAttribute('resultType', options.resultType);
|
||||
}
|
||||
if (goog.isDef(options.startIndex)) {
|
||||
node.setAttribute('startIndex', options.startIndex);
|
||||
}
|
||||
if (goog.isDef(options.count)) {
|
||||
node.setAttribute('count', options.count);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
this.writers['http://www.opengis.net/wfs']['GetFeature']
|
||||
),
|
||||
'Query': function(options) {
|
||||
var prefix = goog.isDef(options.featurePrefix) ? options.featurePrefix +
|
||||
':' : '';
|
||||
var node = this.createElementNS('wfs:Query');
|
||||
node.setAttribute('typeName', prefix + options.featureType);
|
||||
node.setAttribute('srsName', options.srsName);
|
||||
if (goog.isDef(options.featureNS)) {
|
||||
node.setAttribute('xmlns:' + options.featurePrefix, options.featureNS);
|
||||
}
|
||||
if (goog.isDef(options.propertyNames)) {
|
||||
for (var i = 0, ii = options.propertyNames.length; i < ii; i++) {
|
||||
this.writeNode('PropertyName', options.propertyNames[i], null, node);
|
||||
}
|
||||
}
|
||||
if (goog.isDef(options.filter)) {
|
||||
this.writeNode('Filter', options.filter,
|
||||
'http://www.opengis.net/ogc', node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'PropertyName': function(obj) {
|
||||
goog.asserts.assertInstanceof(obj, ol.expr.Identifier);
|
||||
var node = this.createElementNS('wfs:PropertyName');
|
||||
node.appendChild(this.createTextNode(obj.getName()));
|
||||
return node;
|
||||
}
|
||||
});
|
||||
this.setFilterParser(new ol.parser.ogc.Filter_v1_1_0());
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WFS_v1_1_0,
|
||||
ol.parser.ogc.WFS_v1);
|
||||
@@ -1 +1,3 @@
|
||||
@exportSymbol ol.source.WMSGetFeatureInfoMethod
|
||||
@exportProperty ol.source.WMSGetFeatureInfoMethod.IFRAME
|
||||
@exportProperty ol.source.WMSGetFeatureInfoMethod.XHR_GET
|
||||
|
||||
@@ -54,6 +54,20 @@ ol.style.Rule = function(options) {
|
||||
this.maxResolution_ = goog.isDef(options.maxResolution) ?
|
||||
options.maxResolution : Infinity;
|
||||
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.name_ = goog.isDef(options.name) ?
|
||||
options.name : undefined;
|
||||
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.title_ = goog.isDef(options.title) ?
|
||||
options.title : undefined;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -78,3 +92,43 @@ ol.style.Rule.prototype.applies = function(feature, resolution) {
|
||||
ol.style.Rule.prototype.getSymbolizers = function() {
|
||||
return this.symbolizers_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.expr.Expression}
|
||||
*/
|
||||
ol.style.Rule.prototype.getFilter = function() {
|
||||
return this.filter_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
ol.style.Rule.prototype.getMinResolution = function() {
|
||||
return this.minResolution_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
ol.style.Rule.prototype.getMaxResolution = function() {
|
||||
return this.maxResolution_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
ol.style.Rule.prototype.getName = function() {
|
||||
return this.name_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
ol.style.Rule.prototype.getTitle = function() {
|
||||
return this.title_;
|
||||
};
|
||||
|
||||
@@ -215,6 +215,15 @@ ol.style.Text.prototype.getZIndex = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the stroke.
|
||||
* @return {ol.style.Stroke} Stroke.
|
||||
*/
|
||||
ol.style.Text.prototype.getStroke = function() {
|
||||
return this.stroke_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the font color.
|
||||
* @param {ol.expr.Expression} color Font color.
|
||||
|
||||
Reference in New Issue
Block a user