Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

Commit 29816f9

Browse files
committed
feature: add togejson example + use leaflet where bbox is needed
1 parent 70f6c3c commit 29816f9

File tree

19 files changed

+3684
-1592
lines changed

19 files changed

+3684
-1592
lines changed

dist/osm-api.js

Lines changed: 216 additions & 465 deletions
Large diffs are not rendered by default.

dist/osm-full.js

Lines changed: 608 additions & 493 deletions
Large diffs are not rendered by default.

dist/osm-nominatim.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ return /******/ (function(modules) { // webpackBootstrap
5555
/***/ 0:
5656
/***/ function(module, exports, __webpack_require__) {
5757

58-
module.exports = __webpack_require__(18);
58+
module.exports = __webpack_require__(16);
5959

6060

6161
/***/ },
6262

63-
/***/ 18:
63+
/***/ 16:
6464
/***/ function(module, exports, __webpack_require__) {
6565

6666
'use strict';
@@ -69,7 +69,7 @@ return /******/ (function(modules) { // webpackBootstrap
6969
value: true
7070
});
7171

72-
var _nominatim = __webpack_require__(19);
72+
var _nominatim = __webpack_require__(17);
7373

7474
var _nominatim2 = _interopRequireDefault(_nominatim);
7575

@@ -89,7 +89,7 @@ return /******/ (function(modules) { // webpackBootstrap
8989

9090
/***/ },
9191

92-
/***/ 19:
92+
/***/ 17:
9393
/***/ function(module, exports) {
9494

9595
'use strict';
@@ -119,7 +119,7 @@ return /******/ (function(modules) { // webpackBootstrap
119119
//?X-Requested-With=overpass-turbo&format=json&q=vern-sur-seiche
120120
//params['accept-language'] = 'fr';
121121
var params;
122-
if (typeof query === 'string') {
122+
if (typeof query === 'string' || !query) {
123123
params = {
124124
format: 'json',
125125
q: query

dist/osm-oauth.js

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
exports["name"] = factory(require("osm-auth"));
88
else
99
root["angular-osm"] = root["angular-osm"] || {}, root["angular-osm"]["name"] = factory(root["osm-auth"]);
10-
})(this, function(__WEBPACK_EXTERNAL_MODULE_13__) {
10+
})(this, function(__WEBPACK_EXTERNAL_MODULE_11__) {
1111
return /******/ (function(modules) { // webpackBootstrap
1212
/******/ // The module cache
1313
/******/ var installedModules = {};
@@ -54,7 +54,7 @@ return /******/ (function(modules) { // webpackBootstrap
5454
/* 0 */
5555
/***/ function(module, exports, __webpack_require__) {
5656

57-
module.exports = __webpack_require__(11);
57+
module.exports = __webpack_require__(9);
5858

5959

6060
/***/ },
@@ -66,9 +66,7 @@ return /******/ (function(modules) { // webpackBootstrap
6666
/* 6 */,
6767
/* 7 */,
6868
/* 8 */,
69-
/* 9 */,
70-
/* 10 */,
71-
/* 11 */
69+
/* 9 */
7270
/***/ function(module, exports, __webpack_require__) {
7371

7472
'use strict';
@@ -77,7 +75,7 @@ return /******/ (function(modules) { // webpackBootstrap
7775
value: true
7876
});
7977

80-
var _oauth = __webpack_require__(12);
78+
var _oauth = __webpack_require__(10);
8179

8280
var _oauth2 = _interopRequireDefault(_oauth);
8381

@@ -95,7 +93,7 @@ return /******/ (function(modules) { // webpackBootstrap
9593
exports.default = osmOAuthModule;
9694

9795
/***/ },
98-
/* 12 */
96+
/* 10 */
9997
/***/ function(module, exports, __webpack_require__) {
10098

10199
'use strict';
@@ -104,7 +102,7 @@ return /******/ (function(modules) { // webpackBootstrap
104102
value: true
105103
});
106104

107-
var _osmAuth = __webpack_require__(13);
105+
var _osmAuth = __webpack_require__(11);
108106

109107
var _osmAuth2 = _interopRequireDefault(_osmAuth);
110108

@@ -122,19 +120,42 @@ return /******/ (function(modules) { // webpackBootstrap
122120
this.auth = osmAuth(options);
123121
}
124122
}
123+
/**
124+
* @ngdoc method
125+
* @name logout
126+
* @methodOf osm.auth.osmAuthService
127+
*/
125128
this.logout = function () {
126129
this.auth.logout();
127130
};
131+
/**
132+
* @ngdoc method
133+
* @name authenticated
134+
* @methodOf osm.auth.osmAuthService
135+
* @return {boolean} authenticated
136+
*/
128137
this.authenticated = function () {
129138
return this.auth.authenticated();
130139
};
140+
/**
141+
* @ngdoc method
142+
* @name authenticate
143+
* @methodOf osm.auth.osmAuthService
144+
* @return {Promise} true/false
145+
*/
131146
this.authenticate = function () {
132147
var deferred = $q.defer();
133148
this.auth.authenticate(function () {
134149
deferred.resolve(true);
135150
});
136151
return deferred.promise;
137152
};
153+
/**
154+
* @ngdoc method
155+
* @name xhr
156+
* @methodOf osm.auth.osmAuthService
157+
* @return {Promise} http response
158+
*/
138159
this.xhr = function (options) {
139160
var deferred = $q.defer();
140161
this.auth.xhr(options, function (err, data) {
@@ -146,6 +167,11 @@ return /******/ (function(modules) { // webpackBootstrap
146167
});
147168
return deferred.promise;
148169
};
170+
/**
171+
* @ngdoc method
172+
* @name options
173+
* @methodOf osm.auth.osmAuthService
174+
*/
149175
this.options = function (options) {
150176
if (this.auth) {
151177
this.auth.options(options);
@@ -158,10 +184,10 @@ return /******/ (function(modules) { // webpackBootstrap
158184
exports.default = osmAuthService;
159185

160186
/***/ },
161-
/* 13 */
187+
/* 11 */
162188
/***/ function(module, exports) {
163189

164-
module.exports = __WEBPACK_EXTERNAL_MODULE_13__;
190+
module.exports = __WEBPACK_EXTERNAL_MODULE_11__;
165191

166192
/***/ }
167193
/******/ ])

dist/osm-overpass.js

Lines changed: 77 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ return /******/ (function(modules) { // webpackBootstrap
5454
/* 0 */
5555
/***/ function(module, exports, __webpack_require__) {
5656

57-
module.exports = __webpack_require__(14);
57+
module.exports = __webpack_require__(12);
5858

5959

6060
/***/ },
@@ -82,7 +82,7 @@ return /******/ (function(modules) { // webpackBootstrap
8282

8383
var ngStorageModuleName = _ngstorage2.default ? _ngstorage2.default.name : 'ngStorage';
8484

85-
var osmSettingsModule = angular.module('osm.settings', [ngStorageModuleName]).factory('osmSettingsService', _settings2.default);
85+
var osmSettingsModule = angular.module('osm.settings', [ngStorageModuleName]).service('osmSettingsService', _settings2.default);
8686

8787
exports.default = osmSettingsModule;
8888

@@ -96,7 +96,6 @@ return /******/ (function(modules) { // webpackBootstrap
9696
value: true
9797
});
9898

99-
10099
/**
101100
* @ngdoc service
102101
* @name osmSettingsService
@@ -105,50 +104,42 @@ return /******/ (function(modules) { // webpackBootstrap
105104
*/
106105
osmSettingsService.$inject = ['$localStorage'];
107106
function osmSettingsService($localStorage) {
108-
return {
109-
localStorage: $localStorage.$default({
110-
userName: '',
111-
userID: '',
112-
credentials: '',
113-
nodes: [],
114-
changeset: ''
115-
}),
116-
getUserName: function getUserName() {
117-
return this.localStorage.userName;
118-
},
119-
setUserName: function setUserName(username) {
120-
this.localStorage.userName = username;
121-
},
122-
getUserID: function getUserID() {
123-
return this.localStorage.userID;
124-
},
125-
setUserID: function setUserID(userid) {
126-
this.localStorage.userID = userid;
127-
},
128-
getCredentials: function getCredentials() {
129-
return this.localStorage.credentials;
130-
},
131-
setCredentials: function setCredentials(credentials) {
132-
this.localStorage.credentials = credentials;
133-
},
134-
getNodes: function getNodes() {
135-
return this.localStorage.nodes;
136-
},
137-
setNodes: function setNodes(nodes) {
138-
this.localStorage.nodes = nodes;
139-
},
140-
getChangeset: function getChangeset() {
141-
return this.localStorage.changeset;
142-
},
143-
setChangeset: function setChangeset(changeset) {
144-
this.localStorage.changeset = changeset;
145-
},
146-
getOsmAuth: function getOsmAuth() {
147-
return this.localStorage.osmAuth;
148-
},
149-
setOsmAuth: function setOsmAuth(options) {
150-
this.localStorage.osmAuth = options;
151-
}
107+
108+
this.localStorage = $localStorage.$default({
109+
userName: '',
110+
userID: '',
111+
credentials: '',
112+
changeset: ''
113+
});
114+
this.getUserName = function () {
115+
return this.localStorage.userName;
116+
};
117+
this.setUserName = function (username) {
118+
this.localStorage.userName = username;
119+
};
120+
this.getUserID = function () {
121+
return this.localStorage.userID;
122+
};
123+
this.setUserID = function (userid) {
124+
this.localStorage.userID = userid;
125+
};
126+
this.getCredentials = function () {
127+
return this.localStorage.credentials;
128+
};
129+
this.setCredentials = function (credentials) {
130+
this.localStorage.credentials = credentials;
131+
};
132+
this.getChangeset = function () {
133+
return this.localStorage.changeset;
134+
};
135+
this.setChangeset = function (changeset) {
136+
this.localStorage.changeset = changeset;
137+
};
138+
this.getOsmAuth = function () {
139+
return this.localStorage.osmAuth;
140+
};
141+
this.setOsmAuth = function (options) {
142+
this.localStorage.osmAuth = options;
152143
};
153144
}
154145

@@ -166,9 +157,7 @@ return /******/ (function(modules) { // webpackBootstrap
166157
/* 9 */,
167158
/* 10 */,
168159
/* 11 */,
169-
/* 12 */,
170-
/* 13 */,
171-
/* 14 */
160+
/* 12 */
172161
/***/ function(module, exports, __webpack_require__) {
173162

174163
'use strict';
@@ -177,7 +166,7 @@ return /******/ (function(modules) { // webpackBootstrap
177166
value: true
178167
});
179168

180-
var _overpass = __webpack_require__(15);
169+
var _overpass = __webpack_require__(13);
181170

182171
var _overpass2 = _interopRequireDefault(_overpass);
183172

@@ -200,7 +189,7 @@ return /******/ (function(modules) { // webpackBootstrap
200189
exports.default = osmOverpassModule;
201190

202191
/***/ },
203-
/* 15 */
192+
/* 13 */
204193
/***/ function(module, exports) {
205194

206195
'use strict';
@@ -218,10 +207,19 @@ return /******/ (function(modules) { // webpackBootstrap
218207
* @param {any} osmSettingsService
219208
*/
220209
function osmOverpassAPI($http, $q, osmSettingsService, options) {
210+
this.url = options.url;
211+
/**
212+
* @ngdoc method
213+
* @name overpass
214+
* @param {Object/String} query
215+
* http://wiki.openstreetmap.org/wiki/FR:Overpass_API
216+
* @methodOf osm.overpass.osmOverpassAPI
217+
* @return {Promise} $http.get
218+
*/
221219
this.overpass = function (query) {
222-
var url = this.url;
223-
var deferred = $q.defer();
224220
var self = this;
221+
var url = self.url;
222+
var deferred = $q.defer();
225223
var headers = { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' };
226224
$http.post(url, 'data=' + encodeURIComponent(query), { headers: headers }).then(function (data) {
227225
deferred.resolve(data.data);
@@ -230,6 +228,30 @@ return /******/ (function(modules) { // webpackBootstrap
230228
});
231229
return deferred.promise;
232230
};
231+
/**
232+
* @ngdoc method
233+
* @name overpass
234+
* @description
235+
* http://wiki.openstreetmap.org/wiki/FR:Overpass_API/Overpass_QL#By_area_.28area.29
236+
By convention the area id can be calculated from an existing OSM way by adding 2400000000 to its OSM id, or in case of a relation by adding 3600000000 respectively. Note that area creation is subject to some extraction rules, i.e. not all ways/relations have an area counterpart (notably those that are tagged with area=no, and most multipolygons and that don't have a defined name=* will not be part of areas).
237+
* @param {String} type 'r'/'relation' or 'w'/'way'
238+
* @param {String/Number} osmId the id of the element
239+
* @methodOf osm.overpass.osmOverpassAPI
240+
* @return {Number} the area id
241+
*/
242+
this.getAreaId = function (type, osmId) {
243+
var id;
244+
if (typeof osmId === 'string') {
245+
id = parseInt(osmId, 10);
246+
} else {
247+
id = osmId;
248+
}
249+
if (type === 'r' || type === 'relation') {
250+
return 3600000000 + id;
251+
} else if (type === 'w' || type === 'way') {
252+
return 2400000000 + id;
253+
}
254+
};
233255
this.overpassToGeoJSON = function (query, filter) {
234256
var deferred = $q.defer();
235257
var features = [];
@@ -255,7 +277,7 @@ return /******/ (function(modules) { // webpackBootstrap
255277
}
256278
}
257279
return cache[id];
258-
};
280+
}
259281
for (var i = 0; i < data.elements.length; i++) {
260282
node = data.elements[i];
261283
if (node.type === 'node') {

0 commit comments

Comments
 (0)