Merge remote-tracking branch 'openlayers/master' into vector-api
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||||
|
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
|
<title>MapGuide untiled example</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<div class="container">
|
||||||
|
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
|
<div id="map" class="map"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
|
||||||
|
<div class="span12">
|
||||||
|
<h4 id="title">MapGuide untiled example</h4>
|
||||||
|
<p id="shortdesc">Example of a untiled MapGuide map.</p>
|
||||||
|
<div id="docs">
|
||||||
|
<p>See the <a href="mapguide-untiled.js" target="_blank">mapguide-untiled.js source</a> to see how this is done.</p>
|
||||||
|
</div>
|
||||||
|
<div id="tags">mapguide</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="loader.js?id=mapguide-untiled" type="text/javascript"></script>
|
||||||
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.RendererHint');
|
||||||
|
goog.require('ol.View2D');
|
||||||
|
goog.require('ol.layer.Image');
|
||||||
|
goog.require('ol.source.MapGuide');
|
||||||
|
|
||||||
|
var mdf = 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition';
|
||||||
|
var agentUrl =
|
||||||
|
'http://data.mapguide.com/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous';
|
||||||
|
var bounds = [
|
||||||
|
-87.865114442365922,
|
||||||
|
43.665065564837931,
|
||||||
|
-87.595394059497067,
|
||||||
|
43.823852564430069
|
||||||
|
];
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Image({
|
||||||
|
source: new ol.source.MapGuide({
|
||||||
|
projection: 'EPSG:4326',
|
||||||
|
url: agentUrl,
|
||||||
|
useOverlay: false,
|
||||||
|
metersPerUnit: 111319.4908, //value returned from mapguide
|
||||||
|
params: {
|
||||||
|
MAPDEFINITION: mdf,
|
||||||
|
FORMAT: 'PNG'
|
||||||
|
},
|
||||||
|
ratio: 2,
|
||||||
|
extent: bounds
|
||||||
|
})
|
||||||
|
})
|
||||||
|
],
|
||||||
|
renderer: ol.RendererHint.CANVAS,
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View2D({
|
||||||
|
center: [-87.7302542509315, 43.744459064634],
|
||||||
|
projection: 'EPSG:4326',
|
||||||
|
zoom: 12
|
||||||
|
})
|
||||||
|
});
|
||||||
@@ -252,9 +252,9 @@ ol.interaction.Modify.prototype.removeIndex_ = function(features) {
|
|||||||
nodesToRemove.push(node);
|
nodesToRemove.push(node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
for (i = nodesToRemove.length - 1; i >= 0; --i) {
|
||||||
for (i = nodesToRemove.length - 1; i >= 0; --i) {
|
rBush.remove(nodesToRemove[i]);
|
||||||
rBush.remove(nodesToRemove[i]);
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -368,12 +368,6 @@ ol.interaction.Modify.prototype.handleDragStart = function(evt) {
|
|||||||
if (!(goog.getUid(node.feature) in distinctFeatures)) {
|
if (!(goog.getUid(node.feature) in distinctFeatures)) {
|
||||||
var feature = node.feature;
|
var feature = node.feature;
|
||||||
distinctFeatures[goog.getUid(feature)] = true;
|
distinctFeatures[goog.getUid(feature)] = true;
|
||||||
var original = new ol.Feature(feature.getAttributes());
|
|
||||||
original.setGeometry(feature.getGeometry().clone());
|
|
||||||
original.setId(feature.getId());
|
|
||||||
original.setOriginal(feature.getOriginal());
|
|
||||||
original.setSymbolizers(feature.getSymbolizers());
|
|
||||||
feature.setOriginal(original);
|
|
||||||
}
|
}
|
||||||
if (renderIntent == ol.FeatureRenderIntent.TEMPORARY) {
|
if (renderIntent == ol.FeatureRenderIntent.TEMPORARY) {
|
||||||
if (ol.coordinate.equals(segment[0], vertex)) {
|
if (ol.coordinate.equals(segment[0], vertex)) {
|
||||||
|
|||||||
@@ -648,6 +648,7 @@ ol.parser.ogc.Filter_v1.prototype.setFeatureType = function(featureType) {
|
|||||||
ol.parser.ogc.Filter_v1.prototype.setSrsName = function(srsName) {
|
ol.parser.ogc.Filter_v1.prototype.setSrsName = function(srsName) {
|
||||||
this.srsName = srsName;
|
this.srsName = srsName;
|
||||||
if (goog.isDefAndNotNull(this.gmlParser_)) {
|
if (goog.isDefAndNotNull(this.gmlParser_)) {
|
||||||
this.gmlParser_.srsName = this.srsName;
|
this.gmlParser_.applyWriteOptions({},
|
||||||
|
/** @type {ol.parser.GMLWriteOptions} */ ({srsName: srsName}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
|||||||
for (var i = 0; i < numCoordinates; ++i) {
|
for (var i = 0; i < numCoordinates; ++i) {
|
||||||
var coord = coordinates[i];
|
var coord = coordinates[i];
|
||||||
var part = goog.array.concat(coord);
|
var part = goog.array.concat(coord);
|
||||||
if (this.axisOrientation.substr(0, 2) !== 'en') {
|
if (goog.isDef(this.axisOrientation) &&
|
||||||
|
this.axisOrientation.substr(0, 2) !== 'en') {
|
||||||
part[0] = coord[1];
|
part[0] = coord[1];
|
||||||
part[1] = coord[0];
|
part[1] = coord[0];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
@exportProperty ol.parser.ogc.Versioned.prototype.getParser
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
@exportSymbol ol.parser.ogc.WFS
|
||||||
|
@exportProperty ol.parser.ogc.WFS_v1.prototype.writeGetFeature
|
||||||
|
@exportProperty ol.parser.ogc.WFS_v1.prototype.writeTransaction
|
||||||
@@ -1,31 +1,22 @@
|
|||||||
goog.provide('ol.parser.ogc.WFS_v1');
|
goog.provide('ol.parser.ogc.WFS_v1');
|
||||||
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.dom.xml');
|
goog.require('goog.dom.xml');
|
||||||
|
goog.require('ol.expr.Call');
|
||||||
|
goog.require('ol.expr.Identifier');
|
||||||
|
goog.require('ol.expr.Literal');
|
||||||
|
goog.require('ol.geom.Geometry');
|
||||||
goog.require('ol.parser.XML');
|
goog.require('ol.parser.XML');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {{featureNS: string,
|
|
||||||
featurePrefix: string,
|
|
||||||
featureTypes: Array.<string>,
|
|
||||||
handle: string,
|
|
||||||
outputFormat: string,
|
|
||||||
nativeElements: Array.<{
|
|
||||||
vendorId: string,
|
|
||||||
safeToIgnore: boolean,
|
|
||||||
value: string
|
|
||||||
}>,
|
|
||||||
maxFeatures: number}}
|
|
||||||
*/
|
|
||||||
ol.parser.WFSWriteOptions;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.parser.XML}
|
* @extends {ol.parser.XML}
|
||||||
|
* @param {Object=} opt_options Options which will be set on this object.
|
||||||
*/
|
*/
|
||||||
ol.parser.ogc.WFS_v1 = function() {
|
ol.parser.ogc.WFS_v1 = function(opt_options) {
|
||||||
this.defaultNamespaceURI = 'http://www.opengis.net/wfs';
|
this.defaultNamespaceURI = 'http://www.opengis.net/wfs';
|
||||||
|
|
||||||
// TODO set errorProperty
|
// TODO set errorProperty
|
||||||
this.readers = {};
|
this.readers = {};
|
||||||
this.readers[this.defaultNamespaceURI] = {
|
this.readers[this.defaultNamespaceURI] = {
|
||||||
@@ -36,8 +27,13 @@ ol.parser.ogc.WFS_v1 = function() {
|
|||||||
};
|
};
|
||||||
this.writers = {};
|
this.writers = {};
|
||||||
this.writers[this.defaultNamespaceURI] = {
|
this.writers[this.defaultNamespaceURI] = {
|
||||||
|
/**
|
||||||
|
* @param {ol.parser.WFSWriteGetFeatureOptions} options Options.
|
||||||
|
* @return {{node: Node,
|
||||||
|
* options: ol.parser.WFSWriteGetFeatureOptions}} Object.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
'GetFeature': function(options) {
|
'GetFeature': function(options) {
|
||||||
options = /** @type {ol.parser.WFSWriteOptions} */(options);
|
|
||||||
var node = this.createElementNS('wfs:GetFeature');
|
var node = this.createElementNS('wfs:GetFeature');
|
||||||
node.setAttribute('service', 'WFS');
|
node.setAttribute('service', 'WFS');
|
||||||
node.setAttribute('version', this.version);
|
node.setAttribute('version', this.version);
|
||||||
@@ -51,6 +47,9 @@ ol.parser.ogc.WFS_v1 = function() {
|
|||||||
if (goog.isDef(options.maxFeatures)) {
|
if (goog.isDef(options.maxFeatures)) {
|
||||||
node.setAttribute('maxFeatures', options.maxFeatures);
|
node.setAttribute('maxFeatures', options.maxFeatures);
|
||||||
}
|
}
|
||||||
|
if (goog.isDef(options.srsName)) {
|
||||||
|
this.setSrsName(options.srsName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0, ii = options.featureTypes.length; i < ii; i++) {
|
for (var i = 0, ii = options.featureTypes.length; i < ii; i++) {
|
||||||
options.featureType = options.featureTypes[i];
|
options.featureType = options.featureTypes[i];
|
||||||
@@ -61,29 +60,41 @@ ol.parser.ogc.WFS_v1 = function() {
|
|||||||
'xsi:schemaLocation', this.schemaLocation);
|
'xsi:schemaLocation', this.schemaLocation);
|
||||||
return {node: node, options: options};
|
return {node: node, options: options};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @param {{inserts: Array.<ol.Feature>,
|
||||||
|
* updates: Array.<ol.Feature>,
|
||||||
|
* deletes: Array.<ol.Feature>,
|
||||||
|
* options: ol.parser.WFSWriteTransactionOptions}} obj Object.
|
||||||
|
* @return {Element} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
'Transaction': function(obj) {
|
'Transaction': function(obj) {
|
||||||
obj = obj || {};
|
var options = obj.options;
|
||||||
var options = /** {ol.parser.WFSWriteOptions} */(obj.options || {});
|
this.setFeatureType(options.featureType);
|
||||||
|
this.setFeatureNS(options.featureNS);
|
||||||
|
if (goog.isDef(options.srsName)) {
|
||||||
|
this.setSrsName(options.srsName);
|
||||||
|
}
|
||||||
var node = this.createElementNS('wfs:Transaction');
|
var node = this.createElementNS('wfs:Transaction');
|
||||||
node.setAttribute('service', 'WFS');
|
node.setAttribute('service', 'WFS');
|
||||||
node.setAttribute('version', this.version);
|
node.setAttribute('version', this.version);
|
||||||
if (goog.isDef(options.handle)) {
|
if (goog.isDef(options.handle)) {
|
||||||
node.setAttribute('handle', options.handle);
|
node.setAttribute('handle', options.handle);
|
||||||
}
|
}
|
||||||
var i, ii;
|
var i, ii, features, feature;
|
||||||
var features = obj.features;
|
var operations = {
|
||||||
if (goog.isDefAndNotNull(features)) {
|
'Insert': obj.inserts,
|
||||||
// TODO implement multi option for geometry types
|
'Update': obj.updates,
|
||||||
var name, feature;
|
'Delete': obj.deletes
|
||||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
};
|
||||||
feature = features[i];
|
for (var name in operations) {
|
||||||
// TODO Update (use feature.getOriginal())
|
features = operations[name];
|
||||||
// TODO Insert and Delete
|
if (!goog.isNull(features)) {
|
||||||
if (goog.isDef(name)) {
|
// TODO implement multi option for geometry types
|
||||||
this.writeNode(name, {
|
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||||
feature: feature,
|
feature = features[i];
|
||||||
options: options
|
this.writeNode(name, {feature: feature, options: options}, null,
|
||||||
}, null, node);
|
node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,12 +105,135 @@ ol.parser.ogc.WFS_v1 = function() {
|
|||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @param {{vendorId: string, safeToIgnore: boolean, value: string}}
|
||||||
|
* nativeElement Native element.
|
||||||
|
* @return {Node} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
'Native': function(nativeElement) {
|
'Native': function(nativeElement) {
|
||||||
var node = this.createElementNS('wfs:Native');
|
var node = this.createElementNS('wfs:Native');
|
||||||
node.setAttribute('vendorId', nativeElement.vendorId);
|
node.setAttribute('vendorId', nativeElement.vendorId);
|
||||||
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
|
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
|
||||||
node.appendChild(this.createTextNode(nativeElement.value));
|
node.appendChild(this.createTextNode(nativeElement.value));
|
||||||
return node;
|
return node;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {{feature: ol.Feature,
|
||||||
|
* options: ol.parser.WFSWriteTransactionOptions}} obj Object.
|
||||||
|
* @return {Element} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
|
'Insert': function(obj) {
|
||||||
|
var feature = obj.feature;
|
||||||
|
var options = obj.options;
|
||||||
|
var node = this.createElementNS('wfs:Insert');
|
||||||
|
if (goog.isDef(options) && goog.isDef(options.handle)) {
|
||||||
|
this.setAttributeNS(node, this.defaultNamespaceURI, 'handle',
|
||||||
|
options.handle);
|
||||||
|
}
|
||||||
|
if (goog.isDef(options.srsName)) {
|
||||||
|
this.setSrsName(options.srsName);
|
||||||
|
}
|
||||||
|
this.writeNode('_typeName', feature, options.featureNS, node);
|
||||||
|
return node;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {{feature: ol.Feature,
|
||||||
|
* options: ol.parser.WFSWriteTransactionOptions}} obj Object.
|
||||||
|
* @return {Element} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
|
'Update': function(obj) {
|
||||||
|
var feature = obj.feature;
|
||||||
|
var options = obj.options;
|
||||||
|
var node = this.createElementNS('wfs:Update');
|
||||||
|
this.setAttributeNS(node, this.defaultNamespaceURI, 'typeName',
|
||||||
|
(goog.isDef(options.featureNS) ? options.featurePrefix + ':' : '') +
|
||||||
|
options.featureType);
|
||||||
|
if (goog.isDef(options.handle)) {
|
||||||
|
this.setAttributeNS(node, this.defaultNamespaceURI, 'handle',
|
||||||
|
options.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add in fields
|
||||||
|
var attributes = feature.getAttributes();
|
||||||
|
var attribute;
|
||||||
|
for (var key in attributes) {
|
||||||
|
attribute = attributes[key];
|
||||||
|
// TODO Only add geometries whose values have changed
|
||||||
|
if (goog.isDef(attribute)) {
|
||||||
|
this.writeNode('Property', {name: key, value: attribute}, null, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add feature id filter
|
||||||
|
var fid = feature.getId();
|
||||||
|
goog.asserts.assert(goog.isDef(fid));
|
||||||
|
this.writeNode('Filter', new ol.expr.Call(new ol.expr.Identifier(
|
||||||
|
ol.expr.functions.FID), [new ol.expr.Literal(fid)]),
|
||||||
|
'http://www.opengis.net/ogc', node);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
},
|
||||||
|
'Property': function(obj) {
|
||||||
|
var node = this.createElementNS('wfs:Property');
|
||||||
|
this.writeNode('Name', obj.name, null, node);
|
||||||
|
if (!goog.isNull(obj.value)) {
|
||||||
|
this.writeNode('Value', obj.value, null, node);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {string} name Name.
|
||||||
|
* @return {Element} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
|
'Name': function(name) {
|
||||||
|
var node = this.createElementNS('wfs:Name');
|
||||||
|
node.appendChild(this.createTextNode(name));
|
||||||
|
return node;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {string|number|ol.geom.Geometry} obj Object.
|
||||||
|
* @return {Element} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
|
'Value': function(obj) {
|
||||||
|
var node;
|
||||||
|
if (obj instanceof ol.geom.Geometry) {
|
||||||
|
node = this.createElementNS('wfs:Value');
|
||||||
|
node.appendChild(
|
||||||
|
this.getFilterParser().getGmlParser().writeGeometry(obj));
|
||||||
|
} else {
|
||||||
|
node = this.createElementNS('wfs:Value');
|
||||||
|
node.appendChild(this.createTextNode(/** @type {string} */ (obj)));
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {{feature: ol.Feature,
|
||||||
|
* options: ol.parser.WFSWriteTransactionOptions}} obj Object.
|
||||||
|
* @return {Element} Node.
|
||||||
|
* @this {ol.parser.XML}
|
||||||
|
*/
|
||||||
|
'Delete': function(obj) {
|
||||||
|
var feature = obj.feature;
|
||||||
|
var options = obj.options;
|
||||||
|
var node = this.createElementNS('wfs:Delete');
|
||||||
|
this.setAttributeNS(node, this.defaultNamespaceURI, 'typeName',
|
||||||
|
(goog.isDef(options.featureNS) ? options.featurePrefix + ':' : '') +
|
||||||
|
options.featureType);
|
||||||
|
if (goog.isDef(options.handle)) {
|
||||||
|
this.setAttributeNS(node, this.defaultNamespaceURI, 'handle',
|
||||||
|
options.handle);
|
||||||
|
}
|
||||||
|
var fid = feature.getId();
|
||||||
|
goog.asserts.assert(goog.isDef(fid));
|
||||||
|
this.writeNode('Filter', new ol.expr.Call(new ol.expr.Identifier(
|
||||||
|
ol.expr.functions.FID), [new ol.expr.Literal(fid)]),
|
||||||
|
'http://www.opengis.net/ogc', node);
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
@@ -204,13 +338,27 @@ ol.parser.ogc.WFS_v1.prototype.read = function(data) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<ol.Feature>} features The features to write out.
|
* @param {ol.parser.WFSWriteGetFeatureOptions} options Options.
|
||||||
* @param {ol.parser.WFSWriteOptions} options Write options.
|
* @return {string} A serialized WFS GetFeature query.
|
||||||
|
*/
|
||||||
|
ol.parser.ogc.WFS_v1.prototype.writeGetFeature = function(options) {
|
||||||
|
var root = this.writers[this.defaultNamespaceURI]['GetFeature']
|
||||||
|
.call(this, options);
|
||||||
|
return this.serialize(root);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<ol.Feature>} inserts The features to insert.
|
||||||
|
* @param {Array.<ol.Feature>} updates The features to update.
|
||||||
|
* @param {Array.<ol.Feature>} deletes The features to delete.
|
||||||
|
* @param {ol.parser.WFSWriteTransactionOptions} options Write options.
|
||||||
* @return {string} A serialized WFS transaction.
|
* @return {string} A serialized WFS transaction.
|
||||||
*/
|
*/
|
||||||
ol.parser.ogc.WFS_v1.prototype.write = function(features, options) {
|
ol.parser.ogc.WFS_v1.prototype.writeTransaction =
|
||||||
var root = this.writeNode('Transaction', {features: features,
|
function(inserts, updates, deletes, options) {
|
||||||
options: options});
|
var root = this.writeNode('Transaction', {inserts: inserts,
|
||||||
|
updates: updates, deletes: deletes, options: options});
|
||||||
this.setAttributeNS(
|
this.setAttributeNS(
|
||||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'xsi:schemaLocation', this.schemaLocation);
|
'xsi:schemaLocation', this.schemaLocation);
|
||||||
|
|||||||
@@ -19,17 +19,15 @@ describe('ol.parser.ogc.WFS', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml';
|
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var p = new ol.parser.ogc.WFS_v1_0_0();
|
var p = new ol.parser.ogc.WFS_v1_0_0();
|
||||||
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].
|
var output = p.writeGetFeature({
|
||||||
apply(p, [{
|
featureNS: 'http://www.openplans.org/topp',
|
||||||
featureNS: 'http://www.openplans.org/topp',
|
featureTypes: ['states'],
|
||||||
featureTypes: ['states'],
|
featurePrefix: 'topp',
|
||||||
featurePrefix: 'topp',
|
handle: 'handle_g',
|
||||||
handle: 'handle_g',
|
maxFeatures: 1,
|
||||||
maxFeatures: 1,
|
outputFormat: 'json'
|
||||||
outputFormat: 'json'
|
});
|
||||||
}
|
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||||
]);
|
|
||||||
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -38,12 +36,44 @@ describe('ol.parser.ogc.WFS', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml';
|
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var p = new ol.parser.ogc.WFS_v1_0_0();
|
var p = new ol.parser.ogc.WFS_v1_0_0();
|
||||||
var output = p.writers[p.defaultNamespaceURI]['Transaction'].
|
var output = p.writeTransaction(null, null, null, {handle: 'handle_t'});
|
||||||
apply(p, [{
|
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||||
options: {handle: 'handle_t'}
|
done();
|
||||||
}
|
});
|
||||||
]);
|
});
|
||||||
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
|
|
||||||
|
it('handles writing out transactions', function(done) {
|
||||||
|
var url = 'spec/ol/parser/ogc/xml/wfs_v1/TransactionMulti.xml';
|
||||||
|
afterLoadXml(url, function(xml) {
|
||||||
|
var parser = new ol.parser.ogc.WFS_v1_0_0();
|
||||||
|
|
||||||
|
var insertFeature = new ol.Feature({
|
||||||
|
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||||
|
foo: 'bar',
|
||||||
|
nul: null
|
||||||
|
});
|
||||||
|
var inserts = [insertFeature];
|
||||||
|
var updateFeature = new ol.Feature({
|
||||||
|
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||||
|
foo: 'bar',
|
||||||
|
// null value gets Property element with no Value
|
||||||
|
nul: null,
|
||||||
|
// undefined value means don't create a Property element
|
||||||
|
unwritten: undefined
|
||||||
|
});
|
||||||
|
updateFeature.setId('fid.42');
|
||||||
|
var updates = [updateFeature];
|
||||||
|
|
||||||
|
var deleteFeature = new ol.Feature();
|
||||||
|
deleteFeature.setId('fid.37');
|
||||||
|
var deletes = [deleteFeature];
|
||||||
|
|
||||||
|
var output = parser.writeTransaction(inserts, updates, deletes, {
|
||||||
|
featureNS: 'http://www.openplans.org/topp',
|
||||||
|
featureType: 'states',
|
||||||
|
featurePrefix: 'topp'
|
||||||
|
});
|
||||||
|
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -52,7 +82,7 @@ describe('ol.parser.ogc.WFS', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Native.xml';
|
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Native.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var p = new ol.parser.ogc.WFS_v1_1_0();
|
var p = new ol.parser.ogc.WFS_v1_1_0();
|
||||||
var output = p.write(null, {nativeElements: [{
|
var output = p.writeTransaction(null, null, null, {nativeElements: [{
|
||||||
vendorId: 'ORACLE',
|
vendorId: 'ORACLE',
|
||||||
safeToIgnore: true,
|
safeToIgnore: true,
|
||||||
value: 'ALTER SESSION ENABLE PARALLEL DML'
|
value: 'ALTER SESSION ENABLE PARALLEL DML'
|
||||||
@@ -70,14 +100,12 @@ describe('ol.parser.ogc.WFS', function() {
|
|||||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml';
|
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var p = new ol.parser.ogc.WFS_v1_0_0();
|
var p = new ol.parser.ogc.WFS_v1_0_0();
|
||||||
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].
|
var output = p.writeGetFeature({
|
||||||
apply(p, [{
|
featureNS: 'http://www.openplans.org/topp',
|
||||||
featureNS: 'http://www.openplans.org/topp',
|
featureTypes: ['states', 'cities'],
|
||||||
featureTypes: ['states', 'cities'],
|
featurePrefix: 'topp'
|
||||||
featurePrefix: 'topp'
|
});
|
||||||
}
|
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||||
]);
|
|
||||||
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -87,6 +115,8 @@ describe('ol.parser.ogc.WFS', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
goog.require('goog.dom.xml');
|
goog.require('goog.dom.xml');
|
||||||
|
goog.require('ol.Feature');
|
||||||
|
goog.require('ol.geom.MultiPoint');
|
||||||
goog.require('ol.parser.ogc.WFS');
|
goog.require('ol.parser.ogc.WFS');
|
||||||
goog.require('ol.parser.ogc.WFS_v1_0_0');
|
goog.require('ol.parser.ogc.WFS_v1_0_0');
|
||||||
goog.require('ol.parser.ogc.WFS_v1_1_0');
|
goog.require('ol.parser.ogc.WFS_v1_1_0');
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" handle="handle_t" />
|
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.0.0" handle="handle_t" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"/>
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
|
||||||
|
<wfs:Insert>
|
||||||
|
<feature:states xmlns:feature="http://www.openplans.org/topp">
|
||||||
|
<feature:the_geom>
|
||||||
|
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
|
||||||
|
<gml:pointMember>
|
||||||
|
<gml:Point>
|
||||||
|
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
|
||||||
|
</gml:Point>
|
||||||
|
</gml:pointMember>
|
||||||
|
</gml:MultiPoint>
|
||||||
|
</feature:the_geom>
|
||||||
|
<feature:foo>bar</feature:foo>
|
||||||
|
</feature:states>
|
||||||
|
</wfs:Insert>
|
||||||
|
<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
|
||||||
|
<wfs:Property>
|
||||||
|
<wfs:Name>the_geom</wfs:Name>
|
||||||
|
<wfs:Value>
|
||||||
|
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
|
||||||
|
<gml:pointMember>
|
||||||
|
<gml:Point>
|
||||||
|
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
|
||||||
|
</gml:Point>
|
||||||
|
</gml:pointMember>
|
||||||
|
</gml:MultiPoint>
|
||||||
|
</wfs:Value>
|
||||||
|
</wfs:Property>
|
||||||
|
<wfs:Property>
|
||||||
|
<wfs:Name>foo</wfs:Name>
|
||||||
|
<wfs:Value>bar</wfs:Value>
|
||||||
|
</wfs:Property>
|
||||||
|
<wfs:Property>
|
||||||
|
<wfs:Name>nul</wfs:Name>
|
||||||
|
</wfs:Property>
|
||||||
|
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
||||||
|
<ogc:FeatureId fid="fid.42"/>
|
||||||
|
</ogc:Filter>
|
||||||
|
</wfs:Update>
|
||||||
|
<wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
|
||||||
|
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
||||||
|
<ogc:FeatureId fid="fid.37"/>
|
||||||
|
</ogc:Filter>
|
||||||
|
</wfs:Delete>
|
||||||
|
</wfs:Transaction>
|
||||||
@@ -440,6 +440,31 @@
|
|||||||
* @property {boolean|undefined} visible Visibility. Default is `true` (visible).
|
* @property {boolean|undefined} visible Visibility. Default is `true` (visible).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ol.parser.WFSWriteGetFeatureOptions
|
||||||
|
* @property {string} featureNS The namespace URI used for features.
|
||||||
|
* @property {string} featurePrefix The prefix for the feature namespace.
|
||||||
|
* @property {Array.<string>} featureTypes The feature type names.
|
||||||
|
* @property {string|undefined} srsName SRS name. For WFS 1.1.0, this is
|
||||||
|
* required. In WFS 1.0.0, no srsName attribute will be set on geometries
|
||||||
|
* when this is not provided.
|
||||||
|
* @property {string|undefined} handle Handle.
|
||||||
|
* @property {string|undefined} outputFormat Output format.
|
||||||
|
* @property {number} maxFeatures Maximum number of features to fetch.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ol.parser.WFSWriteTransactionOptions
|
||||||
|
* @property {string} featureNS The namespace URI used for features.
|
||||||
|
* @property {string} featurePrefix The prefix for the feature namespace.
|
||||||
|
* @property {string} featureType The feature type name.
|
||||||
|
* @property {string|undefined} srsName SRS name. No srsName attribute will be
|
||||||
|
* set on geometries when this is not provided.
|
||||||
|
* @property {string|undefined} handle Handle.
|
||||||
|
* @property {Array.<Object>} nativeElements Native elements. Currently not
|
||||||
|
* supported.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ol.source.BingMapsOptions
|
* @typedef {Object} ol.source.BingMapsOptions
|
||||||
* @property {string|undefined} culture Culture code. Default is `en-us`.
|
* @property {string|undefined} culture Culture code. Default is `en-us`.
|
||||||
@@ -461,6 +486,22 @@
|
|||||||
* @proprtty {string|undefined} url URL.
|
* @proprtty {string|undefined} url URL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ol.source.MapGuideOptions
|
||||||
|
* @property {string|undefined} url The mapagent url.
|
||||||
|
* @property {number|undefined} metersPerUnit The meters-per-unit value.
|
||||||
|
* @property {ol.Extent|undefined} extent Extent..
|
||||||
|
* @property {boolean|undefined} useOverlay If true, will use
|
||||||
|
* GETDYNAMICMAPOVERLAYIMAGE.
|
||||||
|
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||||
|
* @property {number|undefined} ratio Ratio. 1 means image requests are the size
|
||||||
|
* of the map viewport, 2 means twice the size of the map viewport, and so
|
||||||
|
* on.
|
||||||
|
* @property {Array.<number>|undefined} resolutions Resolutions. If specified,
|
||||||
|
* requests will be made for these resolutions only.
|
||||||
|
* @property {Object|undefined} params Additional parameters.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ol.source.MapQuestOptions
|
* @typedef {Object} ol.source.MapQuestOptions
|
||||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
@exportSymbol ol.source.MapGuide
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
goog.provide('ol.source.MapGuide');
|
||||||
|
|
||||||
|
goog.require('goog.object');
|
||||||
|
goog.require('goog.uri.utils');
|
||||||
|
goog.require('ol.ImageUrlFunction');
|
||||||
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.source.Image');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.source.Image}
|
||||||
|
* @param {ol.source.MapGuideOptions} options Options.
|
||||||
|
*/
|
||||||
|
ol.source.MapGuide = function(options) {
|
||||||
|
|
||||||
|
var imageUrlFunction;
|
||||||
|
if (goog.isDef(options.url)) {
|
||||||
|
var params = goog.isDef(options.params) ? options.params : {};
|
||||||
|
imageUrlFunction = ol.ImageUrlFunction.createFromParamsFunction(
|
||||||
|
options.url, params, goog.bind(this.getUrl, this));
|
||||||
|
} else {
|
||||||
|
imageUrlFunction = ol.ImageUrlFunction.nullImageUrlFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
goog.base(this, {
|
||||||
|
extent: options.extent,
|
||||||
|
projection: options.projection,
|
||||||
|
resolutions: options.resolutions,
|
||||||
|
imageUrlFunction: imageUrlFunction
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.metersPerUnit_ = goog.isDef(options.metersPerUnit) ?
|
||||||
|
options.metersPerUnit : 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.ratio_ = goog.isDef(options.ratio) ? options.ratio : 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.useOverlay_ = goog.isDef(options.useOverlay) ?
|
||||||
|
options.useOverlay : false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Image}
|
||||||
|
*/
|
||||||
|
this.image_ = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol.source.MapGuide, ol.source.Image);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.source.MapGuide.prototype.getImage =
|
||||||
|
function(extent, resolution, projection) {
|
||||||
|
resolution = this.findNearestResolution(resolution);
|
||||||
|
|
||||||
|
var image = this.image_;
|
||||||
|
if (!goog.isNull(image) &&
|
||||||
|
image.getResolution() == resolution &&
|
||||||
|
ol.extent.containsExtent(image.getExtent(), extent)) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.ratio_ != 1) {
|
||||||
|
extent = extent.slice();
|
||||||
|
ol.extent.scaleFromCenter(extent, this.ratio_);
|
||||||
|
}
|
||||||
|
var width = (extent[2] - extent[0]) / resolution;
|
||||||
|
var height = (extent[3] - extent[1]) / resolution;
|
||||||
|
var size = [width, height];
|
||||||
|
|
||||||
|
this.image_ = this.createImage(extent, resolution, size, projection);
|
||||||
|
return this.image_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Extent} extent The map extents.
|
||||||
|
* @param {ol.Size} size the viewport size.
|
||||||
|
* @return {number} The computed map scale.
|
||||||
|
*/
|
||||||
|
ol.source.MapGuide.prototype.getScale = function(extent, size) {
|
||||||
|
var mcsW = extent[2] - extent[0];
|
||||||
|
var mcsH = extent[3] - extent[1];
|
||||||
|
var devW = size[0];
|
||||||
|
var devH = size[1];
|
||||||
|
var dpi = 96;
|
||||||
|
var mpu = this.metersPerUnit_;
|
||||||
|
var mpp = 0.0254 / dpi;
|
||||||
|
if (devH * mcsW > devW * mcsH) {
|
||||||
|
return mcsW * mpu / (devW * mpp); // width limited
|
||||||
|
} else {
|
||||||
|
return mcsH * mpu / (devH * mpp); // height limited
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} baseUrl The mapagent url.
|
||||||
|
* @param {Object.<string, string|number>} params Request parameters.
|
||||||
|
* @param {ol.Extent} extent Extent.
|
||||||
|
* @param {ol.Size} size Size.
|
||||||
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
|
* @return {string} The mapagent map image request URL.
|
||||||
|
*/
|
||||||
|
ol.source.MapGuide.prototype.getUrl =
|
||||||
|
function(baseUrl, params, extent, size, projection) {
|
||||||
|
var scale = this.getScale(extent, size);
|
||||||
|
var baseParams = {
|
||||||
|
'OPERATION': this.useOverlay_ ? 'GETDYNAMICMAPOVERLAYIMAGE' : 'GETMAPIMAGE',
|
||||||
|
'VERSION': '2.0.0',
|
||||||
|
'LOCALE': 'en',
|
||||||
|
'CLIENTAGENT': 'ol.source.MapGuide source',
|
||||||
|
'CLIP': '1',
|
||||||
|
'SETDISPLAYDPI': 96,
|
||||||
|
'SETDISPLAYWIDTH': Math.round(size[0]),
|
||||||
|
'SETDISPLAYHEIGHT': Math.round(size[1]),
|
||||||
|
'SETVIEWSCALE': scale,
|
||||||
|
'SETVIEWCENTERX': (extent[0] + extent[2]) / 2,
|
||||||
|
'SETVIEWCENTERY': (extent[1] + extent[3]) / 2
|
||||||
|
};
|
||||||
|
goog.object.extend(baseParams, params);
|
||||||
|
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user