Merge pull request #714 from bartvde/gmloptions
GML options not always applied (=r@ahocevar)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -308,41 +308,36 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GML2Options
|
||||
* @property {boolean|undefined} extractAttributes Should we extract attributes
|
||||
* from the GML? Default is `true´.
|
||||
* @property {string|undefined} featureNS The feature namespace. If not set it
|
||||
* will be automatically configured from the GML.
|
||||
* @property {Array.<string>|string|undefined} featureType The local
|
||||
* (without prefix) feature typeName(s).
|
||||
* @property {string|undefined} geometryName Geometry element name.
|
||||
* @typedef {Object} ol.parser.GMLOptions
|
||||
* @property {string|undefined} axisOrientation The axis orientation as
|
||||
* specified in Proj4. The default is 'enu'.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GML3Options
|
||||
* @property {boolean|undefined} extractAttributes Should we extract attributes
|
||||
* from the GML? Default is `true´.
|
||||
* @property {string|undefined} featureNS The feature namespace. If not set it
|
||||
* will be automatically configured from the GML.
|
||||
* @property {Array.<string>|string|undefined} featureType The local
|
||||
* (without prefix) feature typeName(s).
|
||||
* @property {string|undefined} geometryName Geometry element name.
|
||||
* @property {string|undefined} axisOrientation The axis orientation as
|
||||
* specified in Proj4. The default is 'enu'.
|
||||
* @property {boolean|undefined} surface Write gml:Surface instead of
|
||||
* gml:Polygon elements. This also affects the elements in multi-part
|
||||
* geometries. Default is `false´.
|
||||
* @property {boolean|undefined} curve Write gml:Curve instead of
|
||||
* gml:LineString elements. This also affects the elements in multi-part
|
||||
* geometries. Default is `false´.
|
||||
* geometries. Default is `false´. This only applies to GML version 3.
|
||||
* @property {boolean|undefined} extractAttributes Should we extract attributes
|
||||
* from the GML? Default is `true´.
|
||||
* @property {string|undefined} featureNS The feature namespace. If not set it
|
||||
* will be automatically configured from the GML.
|
||||
* @property {Array.<string>|string|undefined} featureType The local
|
||||
* (without prefix) feature typeName(s).
|
||||
* @property {string|undefined} geometryName Name of geometry element.
|
||||
* Defaults to `geometry´. If null, it will be set on <read> when the
|
||||
* first geometry is parsed.
|
||||
* @property {boolean|undefined} multiCurve Write gml:MultiCurve instead of
|
||||
* gml:MultiLineString. Since the latter is deprecated in GML 3, the
|
||||
* default is `true´.
|
||||
* default is `true´. This only applies to GML version 3.
|
||||
* @property {boolean|undefined} multiSurface Write gml:multiSurface instead
|
||||
* of gml:MultiPolygon. Since the latter is deprecated in GML 3, the
|
||||
* default is `true´.
|
||||
* default is `true´. This only applies to GML version 3.
|
||||
* @property {string|undefined} schemaLocation Optional schemaLocation to use
|
||||
* when writing out the GML, this will override the default provided.
|
||||
* @property {string|undefined} srsName URI for spatial reference system.
|
||||
* This is optional for single part geometries and mandatory for
|
||||
* collections and multis. If set, the srsName attribute will be written
|
||||
* for all geometries. Default is null.
|
||||
* @property {boolean|undefined} surface Write gml:Surface instead of
|
||||
* gml:Polygon elements. This also affects the elements in multi-part
|
||||
* geometries. Default is `false´. This only applies to GML version 3.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.parser.ogc.GML');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryCollection');
|
||||
@@ -21,19 +20,35 @@ goog.require('ol.parser.XML');
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {ol.parser.StringFeatureParser}
|
||||
* @param {ol.parser.GML2Options|ol.parser.GML3Options=} opt_options
|
||||
* @param {ol.parser.GMLOptions=} opt_options
|
||||
* Optional configuration object.
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.GML = function(opt_options) {
|
||||
if (goog.isDef(opt_options)) {
|
||||
goog.object.extend(this, opt_options);
|
||||
var options = /** @type {ol.parser.GMLOptions} */
|
||||
(goog.isDef(opt_options) ? opt_options : {});
|
||||
this.axisOrientation = goog.isDef(options.axisOrientation) ?
|
||||
options.axisOrientation : 'enu';
|
||||
this.extractAttributes = goog.isDef(options.extractAttributes) ?
|
||||
options.extractAttributes : true;
|
||||
this.surface = goog.isDef(options.surface) ?
|
||||
options.surface : false;
|
||||
this.curve = goog.isDef(options.curve) ?
|
||||
options.curve : false;
|
||||
this.multiCurve = goog.isDef(options.multiCurve) ?
|
||||
options.multiCurve : true;
|
||||
this.multiSurface = goog.isDef(options.multiSurface) ?
|
||||
options.multiSurface : true;
|
||||
this.srsName = goog.isDef(options.srsName) ?
|
||||
options.srsName : null;
|
||||
if (goog.isDef(options.schemaLocation)) {
|
||||
this.schemaLocation = options.schemaLocation;
|
||||
}
|
||||
if (!goog.isDef(this.axisOrientation)) {
|
||||
this.axisOrientation = 'enu';
|
||||
if (goog.isDef(options.featureNS)) {
|
||||
this.featureNS = options.featureNS;
|
||||
}
|
||||
if (!goog.isDef(this.extractAttributes)) {
|
||||
this.extractAttributes = true;
|
||||
if (goog.isDef(options.featureType)) {
|
||||
this.featureType = options.featureType;
|
||||
}
|
||||
this.singleFeatureType = !goog.isDef(opt_options) ||
|
||||
goog.isString(opt_options.featureType);
|
||||
@@ -181,7 +196,7 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
var numPoints = pointList.length;
|
||||
var points = new Array(numPoints);
|
||||
for (var i = 0; i < numPoints; ++i) {
|
||||
coords = pointList[i].split(cs).map(parseFloat);
|
||||
coords = goog.array.map(pointList[i].split(cs), parseFloat);
|
||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
||||
points[i] = coords;
|
||||
} else {
|
||||
@@ -424,7 +439,9 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
return node;
|
||||
}
|
||||
};
|
||||
this.writers[this.featureNS] = this.featureNSWiters_;
|
||||
if (goog.isDef(this.featureNS)) {
|
||||
this.writers[this.featureNS] = this.featureNSWiters_;
|
||||
}
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.GML, ol.parser.XML);
|
||||
|
||||
@@ -8,7 +8,7 @@ goog.require('ol.parser.ogc.GML');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {ol.parser.GML2Options=} opt_options Optional configuration object.
|
||||
* @param {ol.parser.GMLOptions=} opt_options Optional configuration object.
|
||||
* @extends {ol.parser.ogc.GML}
|
||||
*/
|
||||
ol.parser.ogc.GML_v2 = function(opt_options) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
goog.provide('ol.parser.ogc.GML_v3');
|
||||
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.parser.ogc.GML');
|
||||
@@ -9,7 +9,7 @@ goog.require('ol.parser.ogc.GML');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {ol.parser.GML3Options=} opt_options Optional configuration object.
|
||||
* @param {ol.parser.GMLOptions=} opt_options Optional configuration object.
|
||||
* @extends {ol.parser.ogc.GML}
|
||||
*/
|
||||
ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
@@ -17,18 +17,6 @@ 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);
|
||||
if (!goog.isDef(this.surface)) {
|
||||
this.surface = false;
|
||||
}
|
||||
if (!goog.isDef(this.curve)) {
|
||||
this.curve = false;
|
||||
}
|
||||
if (!goog.isDef(this.multiCurve)) {
|
||||
this.multiCurve = true;
|
||||
}
|
||||
if (!goog.isDef(this.multiSurface)) {
|
||||
this.multiSurface = true;
|
||||
}
|
||||
this.featureNSWiters_['_geometry'] = function(geometry) {
|
||||
var node = this.createElementNS('feature:' + this.geometryName,
|
||||
this.featureNS);
|
||||
@@ -111,7 +99,8 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
'pos': function(node, obj) {
|
||||
var str = this.getChildValue(node).replace(
|
||||
this.regExes.trimSpace, '');
|
||||
var coords = str.split(this.regExes.splitSpace).map(parseFloat);
|
||||
var coords = goog.array.map(str.split(this.regExes.splitSpace),
|
||||
parseFloat);
|
||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
||||
obj.push([coords]);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user