@@ -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