Rename _ol_format_OSMXML_ OSMXML
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import _ol_Map_ from '../src/ol/Map.js';
|
import _ol_Map_ from '../src/ol/Map.js';
|
||||||
import _ol_View_ from '../src/ol/View.js';
|
import _ol_View_ from '../src/ol/View.js';
|
||||||
import _ol_control_ from '../src/ol/control.js';
|
import _ol_control_ from '../src/ol/control.js';
|
||||||
import _ol_format_OSMXML_ from '../src/ol/format/OSMXML.js';
|
import OSMXML from '../src/ol/format/OSMXML.js';
|
||||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||||
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
|
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
|
||||||
import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js';
|
import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js';
|
||||||
@@ -78,13 +78,13 @@ var styles = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var vectorSource = new _ol_source_Vector_({
|
var vectorSource = new _ol_source_Vector_({
|
||||||
format: new _ol_format_OSMXML_(),
|
format: new OSMXML(),
|
||||||
loader: function(extent, resolution, projection) {
|
loader: function(extent, resolution, projection) {
|
||||||
var epsg4326Extent = transformExtent(extent, projection, 'EPSG:4326');
|
var epsg4326Extent = transformExtent(extent, projection, 'EPSG:4326');
|
||||||
var client = new XMLHttpRequest();
|
var client = new XMLHttpRequest();
|
||||||
client.open('POST', 'https://overpass-api.de/api/interpreter');
|
client.open('POST', 'https://overpass-api.de/api/interpreter');
|
||||||
client.addEventListener('load', function() {
|
client.addEventListener('load', function() {
|
||||||
var features = new _ol_format_OSMXML_().readFeatures(client.responseText, {
|
var features = new OSMXML().readFeatures(client.responseText, {
|
||||||
featureProjection: map.getView().getProjection()
|
featureProjection: map.getView().getProjection()
|
||||||
});
|
});
|
||||||
vectorSource.addFeatures(features);
|
vectorSource.addFeatures(features);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import _ol_xml_ from '../xml.js';
|
|||||||
* @extends {ol.format.XMLFeature}
|
* @extends {ol.format.XMLFeature}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_format_OSMXML_ = function() {
|
var OSMXML = function() {
|
||||||
_ol_format_XMLFeature_.call(this);
|
_ol_format_XMLFeature_.call(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +33,7 @@ var _ol_format_OSMXML_ = function() {
|
|||||||
this.defaultDataProjection = getProjection('EPSG:4326');
|
this.defaultDataProjection = getProjection('EPSG:4326');
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_format_OSMXML_, _ol_format_XMLFeature_);
|
inherits(OSMXML, _ol_format_XMLFeature_);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +41,7 @@ inherits(_ol_format_OSMXML_, _ol_format_XMLFeature_);
|
|||||||
* @param {Array.<*>} objectStack Object stack.
|
* @param {Array.<*>} objectStack Object stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.readNode_ = function(node, objectStack) {
|
OSMXML.readNode_ = function(node, objectStack) {
|
||||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||||
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
var id = node.getAttribute('id');
|
var id = node.getAttribute('id');
|
||||||
@@ -54,7 +54,7 @@ _ol_format_OSMXML_.readNode_ = function(node, objectStack) {
|
|||||||
|
|
||||||
var values = _ol_xml_.pushParseAndPop({
|
var values = _ol_xml_.pushParseAndPop({
|
||||||
tags: {}
|
tags: {}
|
||||||
}, _ol_format_OSMXML_.NODE_PARSERS_, node, objectStack);
|
}, OSMXML.NODE_PARSERS_, node, objectStack);
|
||||||
if (!_ol_obj_.isEmpty(values.tags)) {
|
if (!_ol_obj_.isEmpty(values.tags)) {
|
||||||
var geometry = new Point(coordinates);
|
var geometry = new Point(coordinates);
|
||||||
FeatureFormat.transformWithOptions(geometry, false, options);
|
FeatureFormat.transformWithOptions(geometry, false, options);
|
||||||
@@ -71,13 +71,13 @@ _ol_format_OSMXML_.readNode_ = function(node, objectStack) {
|
|||||||
* @param {Array.<*>} objectStack Object stack.
|
* @param {Array.<*>} objectStack Object stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.readWay_ = function(node, objectStack) {
|
OSMXML.readWay_ = function(node, objectStack) {
|
||||||
var id = node.getAttribute('id');
|
var id = node.getAttribute('id');
|
||||||
var values = _ol_xml_.pushParseAndPop({
|
var values = _ol_xml_.pushParseAndPop({
|
||||||
id: id,
|
id: id,
|
||||||
ndrefs: [],
|
ndrefs: [],
|
||||||
tags: {}
|
tags: {}
|
||||||
}, _ol_format_OSMXML_.WAY_PARSERS_, node, objectStack);
|
}, OSMXML.WAY_PARSERS_, node, objectStack);
|
||||||
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
state.ways.push(values);
|
state.ways.push(values);
|
||||||
};
|
};
|
||||||
@@ -88,7 +88,7 @@ _ol_format_OSMXML_.readWay_ = function(node, objectStack) {
|
|||||||
* @param {Array.<*>} objectStack Object stack.
|
* @param {Array.<*>} objectStack Object stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.readNd_ = function(node, objectStack) {
|
OSMXML.readNd_ = function(node, objectStack) {
|
||||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
values.ndrefs.push(node.getAttribute('ref'));
|
values.ndrefs.push(node.getAttribute('ref'));
|
||||||
};
|
};
|
||||||
@@ -99,7 +99,7 @@ _ol_format_OSMXML_.readNd_ = function(node, objectStack) {
|
|||||||
* @param {Array.<*>} objectStack Object stack.
|
* @param {Array.<*>} objectStack Object stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.readTag_ = function(node, objectStack) {
|
OSMXML.readTag_ = function(node, objectStack) {
|
||||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
values.tags[node.getAttribute('k')] = node.getAttribute('v');
|
values.tags[node.getAttribute('k')] = node.getAttribute('v');
|
||||||
};
|
};
|
||||||
@@ -110,7 +110,7 @@ _ol_format_OSMXML_.readTag_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.NAMESPACE_URIS_ = [
|
OSMXML.NAMESPACE_URIS_ = [
|
||||||
null
|
null
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -120,10 +120,10 @@ _ol_format_OSMXML_.NAMESPACE_URIS_ = [
|
|||||||
* @type {Object.<string, Object.<string, ol.XmlParser>>}
|
* @type {Object.<string, Object.<string, ol.XmlParser>>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.WAY_PARSERS_ = _ol_xml_.makeStructureNS(
|
OSMXML.WAY_PARSERS_ = _ol_xml_.makeStructureNS(
|
||||||
_ol_format_OSMXML_.NAMESPACE_URIS_, {
|
OSMXML.NAMESPACE_URIS_, {
|
||||||
'nd': _ol_format_OSMXML_.readNd_,
|
'nd': OSMXML.readNd_,
|
||||||
'tag': _ol_format_OSMXML_.readTag_
|
'tag': OSMXML.readTag_
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -132,10 +132,10 @@ _ol_format_OSMXML_.WAY_PARSERS_ = _ol_xml_.makeStructureNS(
|
|||||||
* @type {Object.<string, Object.<string, ol.XmlParser>>}
|
* @type {Object.<string, Object.<string, ol.XmlParser>>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.PARSERS_ = _ol_xml_.makeStructureNS(
|
OSMXML.PARSERS_ = _ol_xml_.makeStructureNS(
|
||||||
_ol_format_OSMXML_.NAMESPACE_URIS_, {
|
OSMXML.NAMESPACE_URIS_, {
|
||||||
'node': _ol_format_OSMXML_.readNode_,
|
'node': OSMXML.readNode_,
|
||||||
'way': _ol_format_OSMXML_.readWay_
|
'way': OSMXML.readWay_
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +144,9 @@ _ol_format_OSMXML_.PARSERS_ = _ol_xml_.makeStructureNS(
|
|||||||
* @type {Object.<string, Object.<string, ol.XmlParser>>}
|
* @type {Object.<string, Object.<string, ol.XmlParser>>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.NODE_PARSERS_ = _ol_xml_.makeStructureNS(
|
OSMXML.NODE_PARSERS_ = _ol_xml_.makeStructureNS(
|
||||||
_ol_format_OSMXML_.NAMESPACE_URIS_, {
|
OSMXML.NAMESPACE_URIS_, {
|
||||||
'tag': _ol_format_OSMXML_.readTag_
|
'tag': OSMXML.readTag_
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -159,20 +159,20 @@ _ol_format_OSMXML_.NODE_PARSERS_ = _ol_xml_.makeStructureNS(
|
|||||||
* @return {Array.<ol.Feature>} Features.
|
* @return {Array.<ol.Feature>} Features.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.prototype.readFeatures;
|
OSMXML.prototype.readFeatures;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.prototype.readFeaturesFromNode = function(node, opt_options) {
|
OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||||
var options = this.getReadOptions(node, opt_options);
|
var options = this.getReadOptions(node, opt_options);
|
||||||
if (node.localName == 'osm') {
|
if (node.localName == 'osm') {
|
||||||
var state = _ol_xml_.pushParseAndPop({
|
var state = _ol_xml_.pushParseAndPop({
|
||||||
nodes: {},
|
nodes: {},
|
||||||
ways: [],
|
ways: [],
|
||||||
features: []
|
features: []
|
||||||
}, _ol_format_OSMXML_.PARSERS_, node, [options]);
|
}, OSMXML.PARSERS_, node, [options]);
|
||||||
// parse nodes in ways
|
// parse nodes in ways
|
||||||
for (var j = 0; j < state.ways.length; j++) {
|
for (var j = 0; j < state.ways.length; j++) {
|
||||||
var values = /** @type {Object} */ (state.ways[j]);
|
var values = /** @type {Object} */ (state.ways[j]);
|
||||||
@@ -214,26 +214,26 @@ _ol_format_OSMXML_.prototype.readFeaturesFromNode = function(node, opt_options)
|
|||||||
* @return {ol.proj.Projection} Projection.
|
* @return {ol.proj.Projection} Projection.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.prototype.readProjection;
|
OSMXML.prototype.readProjection;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.prototype.writeFeatureNode = function(feature, opt_options) {};
|
OSMXML.prototype.writeFeatureNode = function(feature, opt_options) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.prototype.writeFeaturesNode = function(features, opt_options) {};
|
OSMXML.prototype.writeFeaturesNode = function(features, opt_options) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_format_OSMXML_.prototype.writeGeometryNode = function(geometry, opt_options) {};
|
OSMXML.prototype.writeGeometryNode = function(geometry, opt_options) {};
|
||||||
export default _ol_format_OSMXML_;
|
export default OSMXML;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||||
import _ol_format_OSMXML_ from '../../../../src/ol/format/OSMXML.js';
|
import OSMXML from '../../../../src/ol/format/OSMXML.js';
|
||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||||
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
||||||
@@ -9,7 +9,7 @@ describe('ol.format.OSMXML', function() {
|
|||||||
|
|
||||||
var format;
|
var format;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
format = new _ol_format_OSMXML_();
|
format = new OSMXML();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#readProjection', function() {
|
describe('#readProjection', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user