diff --git a/apidoc/template/static/styles/ol.css b/apidoc/template/static/styles/ol.css new file mode 100644 index 0000000000..418fdef48a --- /dev/null +++ b/apidoc/template/static/styles/ol.css @@ -0,0 +1,39 @@ +a:visited { + color: #08c; +} + +.stability { + padding: 8px 35px 8px 14px; + margin-bottom: 20px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + color: #333; + background-color: #fcfcfc; + border: 1px solid #ccc; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.stability-deprecated { + color: #b94a48; + background-color: #f2dede; + border-color: #eed3d7; +} + +.stability-experimental { + color: #c09853; + background-color: #fcf8e3; + border-color: #fbeed5; +} + +.stability-unstable { + color: #3a87ad; + background-color: #d9edf7; + border-color: #bce8f1; +} + +.stability-stable, .stability-locked { + color: #468847; + background-color: #dff0d8; + border-color: #d6e9c6; +} diff --git a/apidoc/template/tmpl/layout.tmpl b/apidoc/template/tmpl/layout.tmpl index dbecd6f857..ed01889839 100644 --- a/apidoc/template/tmpl/layout.tmpl +++ b/apidoc/template/tmpl/layout.tmpl @@ -14,6 +14,7 @@ + diff --git a/build.py b/build.py index 4205641d67..0afe5f6eb8 100755 --- a/build.py +++ b/build.py @@ -153,13 +153,16 @@ PROJ4JS_ZIP_MD5 = '17caad64cf6ebc6e6fe62f292b134897' def report_sizes(t): - t.info('uncompressed: %d bytes', os.stat(t.name).st_size) stringio = StringIO() gzipfile = gzip.GzipFile(t.name, 'w', 9, stringio) with open(t.name) as f: shutil.copyfileobj(f, gzipfile) gzipfile.close() - t.info(' compressed: %d bytes', len(stringio.getvalue())) + rawsize = os.stat(t.name).st_size + gzipsize = len(stringio.getvalue()) + savings = '{:.2%}'.format((rawsize - gzipsize)/float(rawsize)) + t.info('uncompressed: %8d bytes', rawsize) + t.info(' compressed: %8d bytes, (saved %s)', gzipsize, savings) virtual('default', 'build') diff --git a/examples/data/countries.sld b/examples/data/countries.sld new file mode 100644 index 0000000000..9ae5eebea3 --- /dev/null +++ b/examples/data/countries.sld @@ -0,0 +1,43 @@ + + + + countries + + countries + A sample style for countries + 1 + A sample style for countries + + name + + Sample + Sample + + + #ff0000 + 0.6 + + + #00FF00 + 0.5 + 4 + + + + + 20000000 + + + name + + + Arial + 10 + Normal + + + + + + + diff --git a/old/examples/vector-layer-sld.html b/old/examples/vector-layer-sld.html new file mode 100644 index 0000000000..62900c20ac --- /dev/null +++ b/old/examples/vector-layer-sld.html @@ -0,0 +1,56 @@ + + + + + + + + + + + Vector layer with styling from SLD example + + + + + +
+ +
+
+
+
+
+ +
+ +
+

Vector layer example

+

Example of a countries vector layer with country labels at higher zoom levels, styling info coming from SLD.

+
+

See the vector-layer-sld.js source to see how this is done.

+
+
vector, geojson, style, SLD, Styled Layer Descriptor
+
+ +
+ +
+ + + + + + diff --git a/old/examples/vector-layer-sld.js b/old/examples/vector-layer-sld.js new file mode 100644 index 0000000000..585cc66c09 --- /dev/null +++ b/old/examples/vector-layer-sld.js @@ -0,0 +1,52 @@ +goog.require('ol.Map'); +goog.require('ol.RendererHint'); +goog.require('ol.View2D'); +goog.require('ol.control'); +goog.require('ol.control.ScaleLine'); +goog.require('ol.layer.Tile'); +goog.require('ol.layer.Vector'); +goog.require('ol.parser.GeoJSON'); +goog.require('ol.parser.ogc.SLD'); +goog.require('ol.source.MapQuestOpenAerial'); +goog.require('ol.source.Vector'); + + +var raster = new ol.layer.Tile({ + source: new ol.source.MapQuestOpenAerial() +}); + +var xhr = new XMLHttpRequest(); +xhr.open('GET', 'data/countries.sld', true); + + +/** + * onload handler for the XHR request. + */ +xhr.onload = function() { + if (xhr.status == 200) { + var map = new ol.Map({ + controls: ol.control.defaults().extend([ + new ol.control.ScaleLine() + ]), + layers: [raster], + renderer: ol.RendererHint.CANVAS, + target: 'map', + view: new ol.View2D({ + center: [0, 0], + zoom: 1 + }) + }); + var units = map.getView().getProjection().getUnits(); + var sld = new ol.parser.ogc.SLD().read(xhr.responseText, units); + var style = sld.namedLayers['countries'].userStyles[0]; + var vector = new ol.layer.Vector({ + source: new ol.source.Vector({ + parser: new ol.parser.GeoJSON(), + url: 'data/countries.geojson' + }), + style: style + }); + map.getLayers().push(vector); + } +}; +xhr.send(); diff --git a/old/src/ol/geom/linearring.js b/old/src/ol/geom/linearring.js index 31f4ba200e..f2e0789b9b 100644 --- a/old/src/ol/geom/linearring.js +++ b/old/src/ol/geom/linearring.js @@ -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) { diff --git a/old/src/ol/interaction/modifyinteraction.js b/old/src/ol/interaction/modifyinteraction.js index dedabccc05..2966f635e5 100644 --- a/old/src/ol/interaction/modifyinteraction.js +++ b/old/src/ol/interaction/modifyinteraction.js @@ -30,7 +30,7 @@ goog.require('ol.structs.RTree'); * geometry: ol.geom.Geometry, * index: (number|undefined), * style: ol.style.Style, - * segment: (Array.|undefined)}} + * segment: Array.}} */ 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)); diff --git a/old/src/ol/parser/ogc/filterparser_v1.js b/old/src/ol/parser/ogc/filterparser_v1.js index a030b9bf78..b141c98279 100644 --- a/old/src/ol/parser/ogc/filterparser_v1.js +++ b/old/src/ol/parser/ogc/filterparser_v1.js @@ -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_); } } }; diff --git a/old/src/ol/parser/ogc/filterparser_v1_0_0.js b/old/src/ol/parser/ogc/filterparser_v1_0_0.js index b96b1d5552..eecebe2504 100644 --- a/old/src/ol/parser/ogc/filterparser_v1_0_0.js +++ b/old/src/ol/parser/ogc/filterparser_v1_0_0.js @@ -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'); diff --git a/old/src/ol/parser/ogc/filterparser_v1_1_0.js b/old/src/ol/parser/ogc/filterparser_v1_1_0.js index a718fa18f3..42c8388fdc 100644 --- a/old/src/ol/parser/ogc/filterparser_v1_1_0.js +++ b/old/src/ol/parser/ogc/filterparser_v1_1_0.js @@ -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'); diff --git a/old/src/ol/parser/ogc/gmlparser.js b/old/src/ol/parser/ogc/gmlparser.js index 872abfe166..6431298975 100644 --- a/old/src/ol/parser/ogc/gmlparser.js +++ b/old/src/ol/parser/ogc/gmlparser.js @@ -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); diff --git a/old/src/ol/parser/ogc/gmlparser_v3.js b/old/src/ol/parser/ogc/gmlparser_v3.js index 47f06f9531..d32ef5b78f 100644 --- a/old/src/ol/parser/ogc/gmlparser_v3.js +++ b/old/src/ol/parser/ogc/gmlparser_v3.js @@ -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); diff --git a/old/src/ol/parser/ogc/sldparser.js b/old/src/ol/parser/ogc/sldparser.js new file mode 100644 index 0000000000..c9db020b75 --- /dev/null +++ b/old/src/ol/parser/ogc/sldparser.js @@ -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); diff --git a/old/src/ol/parser/ogc/sldparser_v1.js b/old/src/ol/parser/ogc/sldparser_v1.js new file mode 100644 index 0000000000..a1516d8c5a --- /dev/null +++ b/old/src/ol/parser/ogc/sldparser_v1.js @@ -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; +}; diff --git a/old/src/ol/parser/ogc/sldparser_v1_0_0.js b/old/src/ol/parser/ogc/sldparser_v1_0_0.js new file mode 100644 index 0000000000..d86f897f6a --- /dev/null +++ b/old/src/ol/parser/ogc/sldparser_v1_0_0.js @@ -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); diff --git a/old/src/ol/parser/ogc/wfsparser.js b/old/src/ol/parser/ogc/wfsparser.js new file mode 100644 index 0000000000..33625798bd --- /dev/null +++ b/old/src/ol/parser/ogc/wfsparser.js @@ -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); diff --git a/old/src/ol/parser/ogc/wfsparser_v1.js b/old/src/ol/parser/ogc/wfsparser_v1.js new file mode 100644 index 0000000000..892e7a851f --- /dev/null +++ b/old/src/ol/parser/ogc/wfsparser_v1.js @@ -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., + 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.} 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); +}; diff --git a/old/src/ol/parser/ogc/wfsparser_v1_0_0.js b/old/src/ol/parser/ogc/wfsparser_v1_0_0.js new file mode 100644 index 0000000000..28e64c98b8 --- /dev/null +++ b/old/src/ol/parser/ogc/wfsparser_v1_0_0.js @@ -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); diff --git a/old/src/ol/parser/ogc/wfsparser_v1_1_0.js b/old/src/ol/parser/ogc/wfsparser_v1_1_0.js new file mode 100644 index 0000000000..02452be120 --- /dev/null +++ b/old/src/ol/parser/ogc/wfsparser_v1_1_0.js @@ -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); diff --git a/old/src/ol/source/wmssource.exports b/old/src/ol/source/wmssource.exports index 7e9a24f714..ec75424b4f 100644 --- a/old/src/ol/source/wmssource.exports +++ b/old/src/ol/source/wmssource.exports @@ -1 +1,3 @@ @exportSymbol ol.source.WMSGetFeatureInfoMethod +@exportProperty ol.source.WMSGetFeatureInfoMethod.IFRAME +@exportProperty ol.source.WMSGetFeatureInfoMethod.XHR_GET diff --git a/old/src/ol/style/rule.js b/old/src/ol/style/rule.js index b06e03cae9..d8234de95b 100644 --- a/old/src/ol/style/rule.js +++ b/old/src/ol/style/rule.js @@ -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_; +}; diff --git a/old/src/ol/style/textsymbolizer.js b/old/src/ol/style/textsymbolizer.js index bc3e1d3ec7..7b2e8e92cd 100644 --- a/old/src/ol/style/textsymbolizer.js +++ b/old/src/ol/style/textsymbolizer.js @@ -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. diff --git a/old/test/spec/ol/parser/ogc/gml_v2.test.js b/old/test/spec/ol/parser/ogc/gml_v2.test.js index a52dd35137..e482df3d19 100644 --- a/old/test/spec/ol/parser/ogc/gml_v2.test.js +++ b/old/test/spec/ol/parser/ogc/gml_v2.test.js @@ -21,7 +21,7 @@ describe('ol.parser.gml_v2', function() { parser.applyWriteOptions(obj); var geom = parser.createGeometry({geometry: obj.geometry}); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -50,7 +50,7 @@ describe('ol.parser.gml_v2', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -80,7 +80,7 @@ describe('ol.parser.gml_v2', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -109,7 +109,7 @@ describe('ol.parser.gml_v2', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -144,7 +144,7 @@ describe('ol.parser.gml_v2', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -169,7 +169,7 @@ describe('ol.parser.gml_v2', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -188,7 +188,7 @@ describe('ol.parser.gml_v2', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -233,7 +233,7 @@ describe('ol.parser.gml_v2', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); diff --git a/old/test/spec/ol/parser/ogc/gml_v3.test.js b/old/test/spec/ol/parser/ogc/gml_v3.test.js index 8914059975..e99089d047 100644 --- a/old/test/spec/ol/parser/ogc/gml_v3.test.js +++ b/old/test/spec/ol/parser/ogc/gml_v3.test.js @@ -20,7 +20,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -37,7 +37,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -64,7 +64,7 @@ describe('ol.parser.gml_v3', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -92,7 +92,7 @@ describe('ol.parser.gml_v3', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -109,7 +109,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -128,7 +128,7 @@ describe('ol.parser.gml_v3', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -157,7 +157,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -186,7 +186,7 @@ describe('ol.parser.gml_v3', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -213,7 +213,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -231,7 +231,7 @@ describe('ol.parser.gml_v3', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -248,7 +248,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -264,7 +264,7 @@ describe('ol.parser.gml_v3', function() { var geom = parser.createGeometry({geometry: obj.geometry}); parser.applyWriteOptions(obj); var node = parser.featureNSWiters_['_geometry'].apply(parser, - [geom]).firstChild; + [{value: geom}]).firstChild; delete parser.srsName; delete parser.axisOrientation; expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml); @@ -280,7 +280,7 @@ describe('ol.parser.gml_v3', function() { var geom = p.createGeometry({geometry: obj.geometry}); p.applyWriteOptions(obj, {srsName: 'foo'}); var node = p.featureNSWiters_['_geometry'].apply(p, - [geom]).firstChild; + [{value: geom}]).firstChild; delete p.srsName; delete p.axisOrientation; expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml); @@ -300,7 +300,6 @@ describe('ol.parser.gml_v3', function() { var obj = p.read(xml); var output = p.write(obj); expect(goog.dom.xml.loadXml(output)).to.xmleql(xml); - expect(p.geometryName).to.eql('the_geom'); expect(obj.features.length).to.eql(10); var feature = obj.features[0]; expect(feature.getGeometry() instanceof @@ -373,10 +372,21 @@ describe('ol.parser.gml_v3', function() { done(); }); }); + it('More than one geometry', function(done) { + var url = 'spec/ol/parser/ogc/xml/gml_v3/more-geoms.xml'; + afterLoadXml(url, function(xml) { + var obj = parser.read(xml); + var feature = obj.features[0]; + expect(feature.get('center')).to.be.a(ol.geom.Point); + expect(feature.get('the_geom')).to.be.a(ol.geom.MultiPolygon); + done(); + }); + }); }); }); goog.require('goog.dom.xml'); +goog.require('ol.geom.Point'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.parser.ogc.GML_v3'); goog.require('ol.proj'); diff --git a/old/test/spec/ol/parser/ogc/sld_v1_0_0.test.js b/old/test/spec/ol/parser/ogc/sld_v1_0_0.test.js new file mode 100644 index 0000000000..e44fb45ac6 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/sld_v1_0_0.test.js @@ -0,0 +1,90 @@ +goog.provide('ol.test.parser.ogc.SLD_v1_0_0'); + + +describe('ol.parser.ogc.SLD_v1_0_0', function() { + + var parser = new ol.parser.ogc.SLD(); + var obj; + + describe('reading and writing', function() { + it('Handles reading', function(done) { + var url = 'spec/ol/parser/ogc/xml/sld_v1_0_0.xml'; + afterLoadXml(url, function(xml) { + obj = parser.read(xml); + expect(obj.version).to.equal('1.0.0'); + var style = obj.namedLayers['AAA161'].userStyles[0]; + expect(style).to.be.a(ol.style.Style); + expect(style.rules_.length).to.equal(2); + var first = style.rules_[0]; + expect(first).to.be.a(ol.style.Rule); + expect(first.filter_).to.be.a(ol.expr.Comparison); + expect(first.filter_.getLeft()).to.be.a(ol.expr.Identifier); + expect(first.filter_.getLeft().getName()).to.equal('CTE'); + expect(first.filter_.getOperator()).to.equal(ol.expr.ComparisonOp.EQ); + expect(first.filter_.getRight()).to.be.a(ol.expr.Literal); + expect(first.filter_.getRight().getValue()).to.equal('V0305'); + expect(first.getSymbolizers().length).to.equal(3); + expect(first.getSymbolizers()[0]).to.be.a(ol.style.Fill); + expect(first.getSymbolizers()[0].getColor().getValue()).to.equal( + '#ffffff'); + expect(first.getSymbolizers()[0].getOpacity().getValue()).to.equal(1); + expect(first.getSymbolizers()[1]).to.be.a(ol.style.Stroke); + expect(first.getSymbolizers()[1].getColor().getValue()).to.equal( + '#000000'); + expect(first.getSymbolizers()[2]).to.be.a(ol.style.Text); + expect(first.getSymbolizers()[2].getText()).to.be.a(ol.expr.Call); + expect(first.getSymbolizers()[2].getText().getArgs().length).to.equal( + 3); + expect(first.getSymbolizers()[2].getText().getArgs()[0]).to.be.a( + ol.expr.Literal); + expect(first.getSymbolizers()[2].getText().getArgs()[0].getValue()). + to.equal('A'); + expect(first.getSymbolizers()[2].getText().getArgs()[1]).to.be.a( + ol.expr.Identifier); + expect(first.getSymbolizers()[2].getText().getArgs()[1].getName()). + to.equal('FOO'); + expect(first.getSymbolizers()[2].getText().getArgs()[2]).to.be.a( + ol.expr.Literal); + expect(first.getSymbolizers()[2].getText().getArgs()[2].getValue()). + to.equal('label'); + expect(first.getSymbolizers()[2].getColor().getValue()).to.equal( + '#000000'); + expect(first.getSymbolizers()[2].getFontFamily().getValue()).to.equal( + 'Arial'); + expect(first.getSymbolizers()[2].getStroke()).to.be.a(ol.style.Stroke); + expect(first.getSymbolizers()[2].getStroke().getColor().getValue()) + .to.equal('#ffffff'); + expect(first.getSymbolizers()[2].getStroke().getWidth().getValue()) + .to.equal(6); + var second = style.rules_[1]; + expect(second.filter_).to.be.a(ol.expr.Comparison); + expect(second.getSymbolizers().length).to.equal(2); + expect(second.getSymbolizers()[0]).to.be.a(ol.style.Fill); + expect(second.getSymbolizers()[1]).to.be.a(ol.style.Stroke); + done(); + }); + }); + it('Handles write', function(done) { + var url = 'spec/ol/parser/ogc/xml/sld_v1_0_0_write.xml'; + afterLoadXml(url, function(xml) { + expect(goog.dom.xml.loadXml(parser.write(obj))).to.xmleql(xml); + done(); + }); + }); + }); + +}); + +goog.require('goog.dom.xml'); +goog.require('ol.parser.ogc.SLD_v1_0_0'); +goog.require('ol.parser.ogc.SLD'); +goog.require('ol.expr.Call'); +goog.require('ol.expr.Comparison'); +goog.require('ol.expr.ComparisonOp'); +goog.require('ol.expr.Identifier'); +goog.require('ol.expr.Literal'); +goog.require('ol.style.Fill'); +goog.require('ol.style.Rule'); +goog.require('ol.style.Stroke'); +goog.require('ol.style.Style'); +goog.require('ol.style.Text'); diff --git a/old/test/spec/ol/parser/ogc/wfs_v1.test.js b/old/test/spec/ol/parser/ogc/wfs_v1.test.js new file mode 100644 index 0000000000..22bf07fc01 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/wfs_v1.test.js @@ -0,0 +1,92 @@ +goog.provide('ol.test.parser.ogc.WFS_v1'); + +describe('ol.parser.ogc.WFS', function() { + + var parser = new ol.parser.ogc.WFS(); + + describe('reading and writing', function() { + + it('handles read of FeatureCollection', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1/FeatureCollection.xml'; + afterLoadXml(url, function(xml) { + var obj = parser.read(xml); + expect(obj.features.length).to.equal(1); + done(); + }); + }); + + it('handles writing out GetFeature with a handle', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_0_0(); + var output = p.writers[p.defaultNamespaceURI]['GetFeature']. + apply(p, [{ + featureNS: 'http://www.openplans.org/topp', + featureTypes: ['states'], + featurePrefix: 'topp', + handle: 'handle_g', + maxFeatures: 1, + outputFormat: 'json' + } + ]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + it('handles writing out Transaction with a handle', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_0_0(); + var output = p.writers[p.defaultNamespaceURI]['Transaction']. + apply(p, [{ + options: {handle: 'handle_t'} + } + ]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + it('handles writing out Native', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1/Native.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_1_0(); + var output = p.write(null, {nativeElements: [{ + vendorId: 'ORACLE', + safeToIgnore: true, + value: 'ALTER SESSION ENABLE PARALLEL DML' + }, { + vendorId: 'ORACLE', + safeToIgnore: false, + value: 'Another native line goes here' + }]}); + expect(goog.dom.xml.loadXml(output)).to.xmleql(xml); + done(); + }); + }); + + it('handles writing out GetFeature with > 1 typename', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_0_0(); + var output = p.writers[p.defaultNamespaceURI]['GetFeature']. + apply(p, [{ + featureNS: 'http://www.openplans.org/topp', + featureTypes: ['states', 'cities'], + featurePrefix: 'topp' + } + ]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + }); + +}); + +goog.require('goog.dom.xml'); +goog.require('ol.parser.ogc.WFS'); +goog.require('ol.parser.ogc.WFS_v1_0_0'); +goog.require('ol.parser.ogc.WFS_v1_1_0'); diff --git a/old/test/spec/ol/parser/ogc/wfs_v1_0_0.test.js b/old/test/spec/ol/parser/ogc/wfs_v1_0_0.test.js new file mode 100644 index 0000000000..c616061602 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/wfs_v1_0_0.test.js @@ -0,0 +1,72 @@ +goog.provide('ol.test.parser.ogc.WFS_v1_0_0'); + +describe('ol.parser.ogc.WFS_v1_0_0', function() { + + var parser = new ol.parser.ogc.WFS(); + + describe('reading and writing', function() { + + it('handles read of transaction response', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_0_0/Transaction_Response.xml'; + afterLoadXml(url, function(xml) { + var obj = parser.read(xml); + expect(obj.insertIds.length).to.equal(2); + expect(obj.insertIds[0]).to.equal('parcelle.40'); + expect(obj.insertIds[1]).to.equal('parcelle.41'); + expect(obj.version).to.equal('1.0.0'); + expect(obj.success).to.be(true); + done(); + }); + }); + + it('handles writing Query with BBOX Filter', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_0_0/query0.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_0_0(); + var filter = new ol.expr.Call( + new ol.expr.Identifier(ol.expr.functions.EXTENT), + [new ol.expr.Literal(1), new ol.expr.Literal(2), + new ol.expr.Literal(3), new ol.expr.Literal(4), + undefined, + new ol.expr.Identifier('the_geom')]); + p.getFilterParser().getGmlParser().axisOrientation = 'enu'; + var output = p.writers[p.defaultNamespaceURI]['Query'].apply( + p, [{ + filter: filter, + featureType: 'states', + featureNS: 'http://www.openplans.org/topp', + featurePrefix: 'topp' + }]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + it('handles writing GetFeature with PropertyName', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_0_0/getfeature0.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_0_0(); + var output = p.writers[p.defaultNamespaceURI]['GetFeature'].apply( + p, [{ + propertyNames: [new ol.expr.Identifier('STATE_NAME'), + new ol.expr.Identifier('STATE_FIPS'), + new ol.expr.Identifier('STATE_ABBR')], + featureNS: 'http://www.openplans.org/topp', + featurePrefix: 'topp', + featureTypes: ['states'] + }]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + }); + +}); + +goog.require('goog.dom.xml'); +goog.require('ol.expr.Call'); +goog.require('ol.expr.Identifier'); +goog.require('ol.expr.Literal'); +goog.require('ol.parser.ogc.WFS'); +goog.require('ol.parser.ogc.WFS_v1_0_0'); diff --git a/old/test/spec/ol/parser/ogc/wfs_v1_1_0.test.js b/old/test/spec/ol/parser/ogc/wfs_v1_1_0.test.js new file mode 100644 index 0000000000..1e24d2ccbc --- /dev/null +++ b/old/test/spec/ol/parser/ogc/wfs_v1_1_0.test.js @@ -0,0 +1,122 @@ +goog.provide('ol.test.parser.ogc.WFS_v1_1_0'); + +describe('ol.parser.ogc.WFS_v1_1_0', function() { + + var parser = new ol.parser.ogc.WFS(); + + describe('reading and writing', function() { + + it('handles read of transaction response', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/TransactionResponse.xml'; + afterLoadXml(url, function(xml) { + var obj = parser.read(xml); + expect(obj.insertIds.length).to.equal(2); + expect(obj.insertIds[0]).to.equal('parcelle.40'); + expect(obj.insertIds[1]).to.equal('parcelle.41'); + expect(obj.version).to.equal('1.1.0'); + expect(obj.success).to.be(true); + done(); + }); + }); + + it('handles read of number of features', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/NumberOfFeatures.xml'; + afterLoadXml(url, function(xml) { + // the XML does not contain a version attribute on the root node + var p = new ol.parser.ogc.WFS_v1_1_0(); + var obj = p.read(xml); + expect(obj.numberOfFeatures).to.equal(625); + done(); + }); + }); + + it('handles read of boundedBy on the FeatureCollection', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/boundedBy.xml'; + afterLoadXml(url, function(xml) { + // the XML does not contain a version attribute on the root node + var p = new ol.parser.ogc.WFS_v1_1_0(); + var obj = p.read(xml); + expect(obj.bounds[0]).to.equal(3197.88); + expect(obj.bounds[1]).to.equal(306457.313); + expect(obj.bounds[2]).to.equal(280339.156); + expect(obj.bounds[3]).to.equal(613850.438); + done(); + }); + }); + + it('handles writing Query with BBOX Filter', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/query0.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_1_0(); + var srs = 'urn:ogc:def:crs:EPSG::4326'; + var filter = new ol.expr.Call( + new ol.expr.Identifier(ol.expr.functions.EXTENT), + [new ol.expr.Literal(1), new ol.expr.Literal(2), + new ol.expr.Literal(3), new ol.expr.Literal(4), + new ol.expr.Literal(srs), + new ol.expr.Identifier('the_geom')]); + p.getFilterParser().getGmlParser().axisOrientation = + ol.proj.get(srs).getAxisOrientation(); + var output = p.writers[p.defaultNamespaceURI]['Query'].apply( + p, [{ + srsName: srs, + filter: filter, + featureType: 'states', + featureNS: 'http://www.openplans.org/topp', + featurePrefix: 'topp' + }]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + + }); + + it('handles writing GetFeature with resultType hits', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature0.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_1_0(); + var output = p.writers[p.defaultNamespaceURI]['GetFeature'].apply( + p, [{ + resultType: 'hits', + srsName: 'urn:ogc:def:crs:EPSG::4326', + propertyNames: [new ol.expr.Identifier('STATE_NAME'), + new ol.expr.Identifier('STATE_FIPS'), + new ol.expr.Identifier('STATE_ABBR')], + featureNS: 'http://www.openplans.org/topp', + featurePrefix: 'topp', + featureTypes: ['states'] + }]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + it('handles writing GetFeature with paging info', function(done) { + var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature1.xml'; + afterLoadXml(url, function(xml) { + var p = new ol.parser.ogc.WFS_v1_1_0(); + var output = p.writers[p.defaultNamespaceURI]['GetFeature'].apply( + p, [{ + count: 10, + startIndex: 20, + srsName: 'urn:ogc:def:crs:EPSG::4326', + featureNS: 'http://www.openplans.org/topp', + featurePrefix: 'topp', + featureTypes: ['states'] + }]); + expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml); + done(); + }); + }); + + }); + +}); + +goog.require('goog.dom.xml'); +goog.require('ol.expr.Call'); +goog.require('ol.expr.Identifier'); +goog.require('ol.expr.Literal'); +goog.require('ol.parser.ogc.WFS'); +goog.require('ol.parser.ogc.WFS_v1_1_0'); +goog.require('ol.proj'); diff --git a/old/test/spec/ol/parser/ogc/xml/gml_v3/more-geoms.xml b/old/test/spec/ol/parser/ogc/xml/gml_v3/more-geoms.xml new file mode 100644 index 0000000000..b0fa5c5a8e --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/gml_v3/more-geoms.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + 42.397027571297585 -122.88465674265922 42.39702893980587 -122.88509730796012 42.397029086785146 -122.88511582432085 42.39702379767053 -122.88528111596624 42.39748517484964 -122.88529300380065 42.39748473847452 -122.88509914138723 42.39748482219041 -122.8849959517568 42.397485082635576 -122.8846741899541 42.3974853307826 -122.88436529392652 42.39702663751206 -122.88435664014142 42.397027571297585 -122.88465674265922 + + + + + + + + + 1 2 + + + 1 + YES + I-L + 2004-04-12T00:00:00-06:00 + + + 0.95741118624 + + 835.705330224 + 835.705330224 + 41704.8312728 + 835.705330224 + 41704.8312728 + 0.38745056079 + + + diff --git a/old/test/spec/ol/parser/ogc/xml/sld_v1_0_0.xml b/old/test/spec/ol/parser/ogc/xml/sld_v1_0_0.xml new file mode 100644 index 0000000000..6bb9cc654f --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/sld_v1_0_0.xml @@ -0,0 +1,129 @@ + + + + AAA161 + + + + stortsteen + + + CTE + V0305 + + + 50000 + + + #ffffff + + + #000000 + + + + + + Arial + 14 + bold + normal + + + + + 0.5 + 0.5 + + + 5 + 5 + + 45 + + + + 3 + + #ffffff + + + + #000000 + + + + + betonbekleding + + + CTE + 1000 + + + 50000 + + + #ffff00 + + + #0000ff + + + + + + + + Second Layer + + + + first rule second layer + + + + number + + 1064866676 + + + 1065512599 + + + + cat + *dog.food!*good + + + + FOO + 5000 + + + + + 10000 + + + + star + + lime + + + olive + 2 + + + SIZE + + + + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/sld_v1_0_0_write.xml b/old/test/spec/ol/parser/ogc/xml/sld_v1_0_0_write.xml new file mode 100644 index 0000000000..eeff7933ac --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/sld_v1_0_0_write.xml @@ -0,0 +1,133 @@ + + + + AAA161 + + + + stortsteen + + + CTE + V0305 + + + 49999.99999999999 + + + #ffffff + 1 + + + + + #000000 + 1 + 1 + + + + AFOOlabel + + Arial + 14 + + + 3 + + #ffffff + 1 + + + + #000000 + 1 + + + + + betonbekleding + + + CTE + 1000 + + + 49999.99999999999 + + + #ffff00 + 1 + + + + + #0000ff + 1 + 1 + + + + + + + + Second Layer + + + + first rule second layer + + + + + FOO + 5000 + + + + cat + *dog.food!*good + + + number + + 1064866676 + + + 1065512599 + + + + + 10000 + + + + star + + lime + 1 + + + olive + 1 + 2 + + + SIZE + + + + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1/FeatureCollection.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1/FeatureCollection.xml new file mode 100644 index 0000000000..bb7f9d2ad0 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1/FeatureCollection.xml @@ -0,0 +1,41 @@ + + + + + + + + + + -75.70742,38.557476 -75.71106,38.649551 -75.724937,38.83017 -75.752922,39.141548 -75.761658,39.247753 -75.764664,39.295849 -75.772697,39.383007 -75.791435,39.723755 -75.775269,39.724442 -75.745934,39.774818 -75.695114,39.820347 -75.644341,39.838196 -75.583794,39.840008 -75.470345,39.826435 -75.42083,39.79887 -75.412117,39.789658 -75.428009,39.77813 -75.460754,39.763248 -75.475128,39.741718 -75.476334,39.719971 -75.489639,39.714745 -75.610725,39.612793 -75.562996,39.566723 -75.590187,39.463768 -75.515572,39.36694 -75.402481,39.257637 -75.397728,39.073036 -75.324852,39.012386 -75.307899,38.945911 -75.190941,38.80867 -75.083138,38.799812 -75.045998,38.44949 -75.068298,38.449963 -75.093094,38.450451 -75.350204,38.455208 -75.69915,38.463066 -75.70742,38.557476 + + + + + + + Delaware + 10 + S Atl + DE + 5062.456 + 1385.022 + 666168.0 + 175867.0 + 247497.0 + 322968.0 + 343200.0 + 247566.0 + 258087.0 + 42968.0 + 8069.0 + 335147.0 + 13945.0 + 87973.0 + 44140.0 + 0.485 + 0.515 + 102776.0 + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml new file mode 100644 index 0000000000..8d597268c0 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml @@ -0,0 +1,3 @@ + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml new file mode 100644 index 0000000000..e1717ddc38 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml @@ -0,0 +1,4 @@ + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1/Native.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1/Native.xml new file mode 100644 index 0000000000..d3ff10f227 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1/Native.xml @@ -0,0 +1 @@ +ALTER SESSION ENABLE PARALLEL DMLAnother native line goes here diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml new file mode 100644 index 0000000000..b147dc07f4 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml @@ -0,0 +1 @@ + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/Transaction_Response.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/Transaction_Response.xml new file mode 100644 index 0000000000..5d178b8124 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/Transaction_Response.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/getfeature0.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/getfeature0.xml new file mode 100644 index 0000000000..8d7e136cea --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/getfeature0.xml @@ -0,0 +1,11 @@ + + + STATE_NAME + STATE_FIPS + STATE_ABBR + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/query0.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/query0.xml new file mode 100644 index 0000000000..d5fdc88cfa --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_0_0/query0.xml @@ -0,0 +1,10 @@ + + + + the_geom + + 1,2 3,4 + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/NumberOfFeatures.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/NumberOfFeatures.xml new file mode 100644 index 0000000000..dcc67c37d7 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/NumberOfFeatures.xml @@ -0,0 +1,9 @@ + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/TransactionResponse.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/TransactionResponse.xml new file mode 100644 index 0000000000..6a64bddeca --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/TransactionResponse.xml @@ -0,0 +1,16 @@ + + + 0 + 1 + 0 + + + + + + + + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/boundedBy.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/boundedBy.xml new file mode 100644 index 0000000000..4daeb2eadc --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/boundedBy.xml @@ -0,0 +1,47 @@ + + + + 3197.880000 306457.313000 + 280339.156000 613850.438000 + + + + + + + + 196507.469000 502347.938000 + 202430.844000 510383.719000 + + + + + + + + + + 200448.047000 510383.719000 198475.031000 509253.875000 198477.422000 507339.688000 196507.469000 505841.969000 196507.625000 504980.281000 196621.359000 505029.969000 196825.328000 505114.000000 197310.031000 505183.469000 197636.609000 505148.750000 197837.594000 505061.563000 197941.031000 504953.688000 198003.094000 504817.719000 198023.781000 504721.688000 198016.391000 504597.531000 197907.234000 504363.219000 197716.734000 504013.969000 197700.156000 503567.563000 197775.531000 503373.969000 197930.688000 503153.781000 198034.234000 503045.594000 198170.078000 502932.125000 198504.047000 502725.250000 198858.719000 502550.875000 199138.000000 502460.719000 199336.000000 502347.938000 199044.125000 504910.969000 199549.359000 507065.781000 200280.594000 506878.938000 202430.844000 507474.625000 202430.844000 508850.906000 200448.047000 510383.719000 + + + + + + + + 791 + 1800.89 + 4620 + + + 0 + 24305.1 + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature0.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature0.xml new file mode 100644 index 0000000000..7449d7d826 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature0.xml @@ -0,0 +1,11 @@ + + + STATE_NAME + STATE_FIPS + STATE_ABBR + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature1.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature1.xml new file mode 100644 index 0000000000..f79e579d08 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature1.xml @@ -0,0 +1,8 @@ + + + + diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/query0.xml b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/query0.xml new file mode 100644 index 0000000000..30be0808f7 --- /dev/null +++ b/old/test/spec/ol/parser/ogc/xml/wfs_v1_1_0/query0.xml @@ -0,0 +1,11 @@ + + + + the_geom + + 1 2 + 3 4 + + + + diff --git a/resources/layout.css b/resources/layout.css index d9c6ae745f..72a211765c 100644 --- a/resources/layout.css +++ b/resources/layout.css @@ -26,41 +26,3 @@ body, h1, h2, h3, h4, p, li, td, th { color: white; padding: 5px; } - -.stability { - padding: 8px 35px 8px 14px; - margin-bottom: 20px; - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); - color: #333; - background-color: #fcfcfc; - border: 1px solid #ccc; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} - -.stability-deprecated { - color: #b94a48; - background-color: #f2dede; - border-color: #eed3d7; -} - -.stability-experimental { - color: #c09853; - background-color: #fcf8e3; - border-color: #fbeed5; -} - -.stability-unstable { - color: #3a87ad; - background-color: #d9edf7; - border-color: #bce8f1; -} - -.stability-stable, -.stability-locked, -.stability-locked, { - color: #468847; - background-color: #dff0d8; - border-color: #d6e9c6; -} diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 2b07198e81..dd585d951a 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -320,7 +320,7 @@ * modifier (i.e. Shift key) that determines if the interaction is active * or not, default is no modifiers. * @property {number|undefined} pixelDelta Pixel The amount to pan on each key - * press + * press. Default is `128` pixels. * @todo stability experimental */ @@ -330,7 +330,7 @@ * @property {ol.events.ConditionType|undefined} condition A conditional * modifier (i.e. Shift key) that determines if the interaction is active * or not, default is no modifiers. - * @property {number|undefined} delta The amount to zoom on each key press. + * @property {number|undefined} delta The amount to zoom on each key press. Default is `1`. * @todo stability experimental */ @@ -349,7 +349,8 @@ /** * @typedef {Object} ol.interaction.TouchRotateOptions - * @property {number|undefined} threshold Minimal angle to start a rotation. + * @property {number|undefined} threshold Minimal angle in radians to start a rotation. + * Default is `0.3`. * @todo stability experimental */ @@ -361,12 +362,12 @@ /** * @typedef {Object} ol.layer.BaseOptions - * @property {number|undefined} brightness Brightness. - * @property {number|undefined} contrast Contrast. - * @property {number|undefined} hue Hue. - * @property {number|undefined} opacity Opacity. - * @property {number|undefined} saturation Saturation. - * @property {boolean|undefined} visible Visibility. + * @property {number|undefined} brightness Brightness. Default is `0`. + * @property {number|undefined} contrast Contrast. Default is `1`. + * @property {number|undefined} hue Hue. Default is `0`. + * @property {number|undefined} opacity Opacity (0, 1). Default is `1`. + * @property {number|undefined} saturation Saturation. Default is `1`. + * @property {boolean|undefined} visible Visibility. Default is `true`. * @property {number|undefined} minResolution The minimum resolution * (inclusive) at which this layer will be visible. * @property {number|undefined} maxResolution The maximum resolution @@ -376,11 +377,11 @@ /** * @typedef {Object} ol.layer.LayerOptions - * @property {number|undefined} brightness Brightness. - * @property {number|undefined} contrast Contrast. - * @property {number|undefined} hue Hue. - * @property {number|undefined} opacity Opacity. 0-1. Default is `1`. - * @property {number|undefined} saturation Saturation. + * @property {number|undefined} brightness Brightness. Default is `0`. + * @property {number|undefined} contrast Contrast. Default is `1`. + * @property {number|undefined} hue Hue. Default is `0`. + * @property {number|undefined} opacity Opacity (0, 1). Default is `1`. + * @property {number|undefined} saturation Saturation. Default is `1`. * @property {ol.source.Source} source Source for this layer. * @property {boolean|undefined} visible Visibility. Default is `true` (visible). * @property {number|undefined} minResolution The minimum resolution @@ -392,12 +393,12 @@ /** * @typedef {Object} ol.layer.GroupOptions - * @property {number|undefined} brightness Brightness. - * @property {number|undefined} contrast Contrast. - * @property {number|undefined} hue Hue. - * @property {number|undefined} opacity Opacity. - * @property {number|undefined} saturation Saturation. - * @property {boolean|undefined} visible Visibility. + * @property {number|undefined} brightness Brightness. Default is `0`. + * @property {number|undefined} contrast Contrast. Default is `1`. + * @property {number|undefined} hue Hue. Default is `0`. + * @property {number|undefined} opacity Opacity (0, 1). Default is `1`. + * @property {number|undefined} saturation Saturation. Default is `1`. + * @property {boolean|undefined} visible Visibility. Default is `true`. * @property {number|undefined} minResolution The minimum resolution * (inclusive) at which this layer will be visible. * @property {number|undefined} maxResolution The maximum resolution @@ -408,12 +409,12 @@ /** * @typedef {Object} ol.layer.TileOptions - * @property {number|undefined} brightness Brightness. - * @property {number|undefined} contrast Contrast. - * @property {number|undefined} hue Hue. - * @property {number|undefined} opacity Opacity. 0-1. Default is `1`. + * @property {number|undefined} brightness Brightness. Default is `0`. + * @property {number|undefined} contrast Contrast. Default is `1`. + * @property {number|undefined} hue Hue. Default is `0`. + * @property {number|undefined} opacity Opacity (0, 1). Default is `1`. * @property {number|undefined} preload Preload. - * @property {number|undefined} saturation Saturation. + * @property {number|undefined} saturation Saturation. Default is `1`. * @property {ol.source.Source} source Source for this layer. * @property {boolean|undefined} visible Visibility. Default is `true` (visible). * @property {number|undefined} minResolution The minimum resolution @@ -441,7 +442,7 @@ /** * @typedef {Object} ol.source.BingMapsOptions - * @property {string|undefined} culture Culture. + * @property {string|undefined} culture Culture code. Default is `en-us`. * @property {string} key Bing Maps API key. Get yours at * http://bingmapsportal.com/. * @property {string} imagerySet Type of imagery. @@ -481,7 +482,9 @@ * @property {number|undefined} maxZoom Max zoom. * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional * function to load a tile given a URL. - * @property {string|undefined} url URL. + * @property {string|undefined} url URL template. Must include `{x}`, `{y}`, + * and `{z}` placeholders. Default is + * `http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png`. * @todo stability experimental */ @@ -513,7 +516,8 @@ * @property {boolean|undefined} opaque Whether the layer is opaque. * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional * function to load a tile given a URL. - * @property {string|undefined} url URL. + * @property {string|undefined} url URL template. Must include `{x}`, `{y}`, + * and `{z}` placeholders. * @todo stability experimental */ @@ -536,7 +540,7 @@ * requests. * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional * function to load a tile given a URL. - * @property {string} url URL. + * @property {string} url URL to the TileJSON file. * @todo stability experimental */ @@ -604,7 +608,7 @@ * requests. * @property {ol.Extent|undefined} extent Extent. * @property {string|undefined} logo Logo. - * @property {ol.proj.ProjectionLike} projection Projection. + * @property {ol.proj.ProjectionLike} projection Projection. Default is `EPSG:3857`. * @property {number|undefined} maxZoom Optional max zoom level. Default is `18`. * @property {number|undefined} minZoom Unsupported (TODO: remove this). * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional diff --git a/src/ol/control/mousepositioncontrol.js b/src/ol/control/mousepositioncontrol.js index a29e9a8ac3..3697e9f7b6 100644 --- a/src/ol/control/mousepositioncontrol.js +++ b/src/ol/control/mousepositioncontrol.js @@ -40,8 +40,8 @@ ol.control.MousePositionProperty = { * @todo stability experimental * @todo observable projection {ol.proj.Projection} the projection to report * mouse position in - * @todo observable coordinateFormat {string} the format to render the current - * position in + * @todo observable coordinateFormat {ol.CoordinateFormatType} the format to + * render the current position in */ ol.control.MousePosition = function(opt_options) { diff --git a/src/ol/control/zoomslidercontrol.js b/src/ol/control/zoomslidercontrol.js index 2d7bbbad80..52b9e1f2d4 100644 --- a/src/ol/control/zoomslidercontrol.js +++ b/src/ol/control/zoomslidercontrol.js @@ -1,6 +1,5 @@ // FIXME works for View2D only // FIXME should possibly show tooltip when dragging? -// FIXME should possibly be adjustable by clicking on container goog.provide('ol.control.ZoomSlider'); @@ -9,6 +8,7 @@ goog.require('goog.asserts'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('goog.events'); +goog.require('goog.events.Event'); goog.require('goog.events.EventType'); goog.require('goog.fx.Dragger'); goog.require('goog.fx.Dragger.EventType'); @@ -68,29 +68,32 @@ ol.control.ZoomSlider = function(opt_options) { */ this.sliderInitialized_ = false; - /** - * @private - * @type {Array.} - */ - this.draggerListenerKeys_ = null; - var className = goog.isDef(options.className) ? options.className : 'ol-zoomslider'; - var sliderCssCls = className + ' ' + ol.css.CLASS_UNSELECTABLE; - var thumbCssCls = className + '-thumb' + ' ' + ol.css.CLASS_UNSELECTABLE; - var element = goog.dom.createDom(goog.dom.TagName.DIV, sliderCssCls, - goog.dom.createDom(goog.dom.TagName.DIV, thumbCssCls)); + var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV, + [className + '-thumb', ol.css.CLASS_UNSELECTABLE]); + var sliderElement = goog.dom.createDom(goog.dom.TagName.DIV, + [className, ol.css.CLASS_UNSELECTABLE], thumbElement); - this.dragger_ = this.createDraggable_(element); + /** + * @type {goog.fx.Dragger} + * @private + */ + this.dragger_ = new goog.fx.Dragger(thumbElement); + this.registerDisposable(this.dragger_); - // FIXME currently only a do nothing function is bound. - goog.events.listen(element, [ - goog.events.EventType.TOUCHEND, - goog.events.EventType.CLICK - ], this.handleContainerClick_, false, this); + goog.events.listen(this.dragger_, [ + goog.fx.Dragger.EventType.DRAG, + goog.fx.Dragger.EventType.END + ], this.handleSliderChange_, undefined, this); + + goog.events.listen(sliderElement, goog.events.EventType.CLICK, + this.handleContainerClick_, false, this); + goog.events.listen(thumbElement, goog.events.EventType.CLICK, + goog.events.Event.stopPropagation); goog.base(this, { - element: element + element: sliderElement }); }; goog.inherits(ol.control.ZoomSlider, ol.control.Control); @@ -178,7 +181,20 @@ ol.control.ZoomSlider.prototype.handleMapPostrender = function(mapEvent) { * @private */ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) { - // TODO implement proper resolution calculation according to browserEvent + var map = this.getMap(); + var view = map.getView().getView2D(); + var resolution; + var amountDragged = this.amountDragged_(browserEvent.offsetX, + browserEvent.offsetY); + resolution = this.resolutionForAmount_(amountDragged); + goog.asserts.assert(goog.isDef(resolution)); + map.beforeRender(ol.animation.zoom({ + resolution: resolution, + duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION, + easing: ol.easing.easeOut + })); + resolution = view.constrainResolution(resolution); + view.setResolution(resolution); }; @@ -207,17 +223,18 @@ ol.control.ZoomSlider.prototype.positionThumbForResolution_ = function(res) { * Calculates the amount the thumb has been dragged to allow for calculation * of the corresponding resolution. * - * @param {goog.fx.DragDropEvent} e The dragdropevent. + * @param {number} x Pixel position relative to the left of the slider. + * @param {number} y Pixel position relative to the top of the slider. * @return {number} The amount the thumb has been dragged. * @private */ -ol.control.ZoomSlider.prototype.amountDragged_ = function(e) { +ol.control.ZoomSlider.prototype.amountDragged_ = function(x, y) { var draggerLimits = this.dragger_.limits, amount = 0; if (this.direction_ === ol.control.ZoomSlider.direction.HORIZONTAL) { - amount = (e.left - draggerLimits.left) / draggerLimits.width; + amount = (x - draggerLimits.left) / draggerLimits.width; } else { - amount = (e.top - draggerLimits.top) / draggerLimits.height; + amount = (y - draggerLimits.top) / draggerLimits.height; } return amount; }; @@ -268,7 +285,7 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) { var view = map.getView().getView2D(); var resolution; if (e.type === goog.fx.Dragger.EventType.DRAG) { - var amountDragged = this.amountDragged_(e); + var amountDragged = this.amountDragged_(e.left, e.top); resolution = this.resolutionForAmount_(amountDragged); if (resolution !== this.currentResolution_) { this.currentResolution_ = resolution; @@ -285,27 +302,3 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) { view.setResolution(resolution); } }; - - -/** - * Actually enable draggable behaviour for the thumb of the zoomslider and bind - * relvant event listeners. - * - * @param {Element} elem The element for the slider. - * @return {goog.fx.Dragger} The actual goog.fx.Dragger instance. - * @private - */ -ol.control.ZoomSlider.prototype.createDraggable_ = function(elem) { - if (!goog.isNull(this.draggerListenerKeys_)) { - goog.array.forEach(this.draggerListenerKeys_, goog.events.unlistenByKey); - this.draggerListenerKeys_ = null; - } - var dragger = new goog.fx.Dragger(elem.childNodes[0]); - this.draggerListenerKeys_ = [ - goog.events.listen(dragger, [ - goog.fx.Dragger.EventType.DRAG, - goog.fx.Dragger.EventType.END - ], this.handleSliderChange_, undefined, this) - ]; - return dragger; -}; diff --git a/src/ol/extent.exports b/src/ol/extent.exports index c18fc7ca7a..387a75529f 100644 --- a/src/ol/extent.exports +++ b/src/ol/extent.exports @@ -1,4 +1,5 @@ @exportSymbol ol.extent.boundingExtent +@exportSymbol ol.extent.buffer @exportSymbol ol.extent.containsCoordinate @exportSymbol ol.extent.containsExtent @exportSymbol ol.extent.createEmpty diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 20058d73d1..884cac198d 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -62,8 +62,9 @@ ol.GeolocationProperty = { * @todo observable speed {number} readonly the instantaneous speed of the * device in meters per second * @todo observable tracking {number} track the device's position. - * @todo observable trackingOptions {number} PositionOptions as defined by the - * HTML5 Geolocation spec at http://dev.w3.org/geo/api/spec-source.html + * @todo observable trackingOptions {GeolocationPositionOptions} PositionOptions + * as defined by the HTML5 Geolocation spec at + * http://dev.w3.org/geo/api/spec-source.html */ ol.Geolocation = function(opt_options) { diff --git a/src/ol/map.js b/src/ol/map.js index 06608ee639..2e95d3522f 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -245,11 +245,8 @@ ol.Map = function(options) { goog.events.EventType.CLICK, goog.events.EventType.DBLCLICK, goog.events.EventType.MOUSEDOWN, - goog.events.EventType.MOUSEUP, goog.events.EventType.TOUCHSTART, - goog.events.EventType.TOUCHEND, - goog.events.EventType.MSPOINTERDOWN, - goog.events.EventType.MSPOINTERUP + goog.events.EventType.MSPOINTERDOWN ], goog.events.Event.stopPropagation); goog.dom.appendChild(this.viewport_, this.overlayContainerStopEvent_); diff --git a/src/ol/object.js b/src/ol/object.js index 4d82943de0..5b122f601c 100644 --- a/src/ol/object.js +++ b/src/ol/object.js @@ -142,7 +142,7 @@ ol.Object.getAccessors = function(obj) { /** - * @param {string} key Key. + * @param {string} key Key name. * @return {string} Change name. */ ol.Object.getChangeEventType = function(key) { @@ -207,7 +207,7 @@ ol.Object.getSetterName = function(key) { * } * ); * - * @param {string} key Key. + * @param {string} key Key name. * @param {ol.Object} target Target. * @param {string=} opt_targetKey Target key. * @return {ol.ObjectAccessor} @@ -231,7 +231,7 @@ ol.Object.prototype.bindTo = function(key, target, opt_targetKey) { /** * Gets a value. - * @param {string} key Key. + * @param {string} key Key name. * @return {*} Value. * @todo stability experimental */ @@ -291,7 +291,7 @@ ol.Object.prototype.getKeys = function() { * Notify all observers of a change on this property. This notifies both * objects that are bound to the object's property as well as the object * that it is bound to. - * @param {string} key Key. + * @param {string} key Key name. * @todo stability experimental */ ol.Object.prototype.notify = function(key) { @@ -308,7 +308,7 @@ ol.Object.prototype.notify = function(key) { /** - * @param {string} key Key. + * @param {string} key Key name. * @private */ ol.Object.prototype.notifyInternal_ = function(key) { @@ -348,7 +348,7 @@ ol.Object.prototype.once = function(type, listener, opt_scope) { /** * Sets a value. - * @param {string} key Key. + * @param {string} key Key name. * @param {*} value Value. * @todo stability experimental */ @@ -394,7 +394,7 @@ ol.Object.prototype.setValues = function(values) { /** * Removes a binding. Unbinding will set the unbound property to the current * value. The object will not be notified, as the value has not changed. - * @param {string} key Key. + * @param {string} key Key name. * @todo stability experimental */ ol.Object.prototype.unbind = function(key) { diff --git a/src/ol/view2d.js b/src/ol/view2d.js index dc93ceb152..e4716f5726 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -192,8 +192,8 @@ ol.View2D.prototype.constrainCenter = function(center) { /** * Get the constrained the resolution of this view. * @param {number|undefined} resolution Resolution. - * @param {number=} opt_delta Delta. - * @param {number=} opt_direction Direction. + * @param {number=} opt_delta Delta. Default is `0`. + * @param {number=} opt_direction Direction. Default is `0`. * @return {number|undefined} Constrained resolution. * @todo stability experimental */ @@ -208,7 +208,7 @@ ol.View2D.prototype.constrainResolution = function( /** * Get the constrained rotation of this view. * @param {number|undefined} rotation Rotation. - * @param {number=} opt_delta Delta. + * @param {number=} opt_delta Delta. Default is `0`. * @return {number|undefined} Constrained rotation. * @todo stability experimental */