diff --git a/CHANGELOG.md b/CHANGELOG.md index d2d355a95..18683c182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.1.5] - 2015-04-30 +### Added +* method for getting geohash grids if the installed cache supports it +* saveFile method in lib/BaseModel to give providers that ability to save file centrally + +### Changed +* Fixed registration of services in the lib/Local.js cache + ## [2.1.4] - 2015-04-28 ### Changed * fixed an issue with export shapefiles from datasets with exactly 5k features @@ -214,6 +222,7 @@ Koop is now just a node module that exposes an express middleware app with hooks - koop-server is no more; all central code is in the koop project - to use Koop you must use it as middleware in an app that boots up an http server +[2.1.5]: https://github.com/Esri/koop/compare/v2.1.4...v2.1.5 [2.1.4]: https://github.com/Esri/koop/compare/v2.1.3...v2.1.4 [2.1.3]: https://github.com/Esri/koop/compare/v2.1.2...v2.1.3 [2.1.2]: https://github.com/Esri/koop/compare/v2.1.1...v2.1.2 diff --git a/lib/BaseModel.js b/lib/BaseModel.js index 438c45f56..ffd38c426 100644 --- a/lib/BaseModel.js +++ b/lib/BaseModel.js @@ -116,7 +116,26 @@ var BaseModel = function( koop ){ } } - return { + function getGeoHash (key, options, callback) { + if (!koop.Cache.db.geoHashAgg){ + callback('The installed cache doesnt support geohash aggregation', null); + } else { + var limit = options.limit || 100000, + precision = options.precision || 8; + koop.Cache.db.geoHashAgg(key, limit, precision, options, callback); + } + } + + function saveFile (path, file, data, callback) { + koop.files.write( path, file, data, function( err ){ + if (err){ + return callback(err); + } + return callback(); + }); + }; + + return { log: log, files: files, cacheDir: cacheDir, @@ -127,7 +146,9 @@ var BaseModel = function( koop ){ tileGet: tileGet, generateThumbnail: generateThumbnail, getImageServiceTile: getImageServiceTile, - getServiceTile: getServiceTile + getServiceTile: getServiceTile, + getGeoHash: getGeoHash, + saveFile: saveFile }; }; diff --git a/lib/Local.js b/lib/Local.js index de1efd092..b83a5604b 100644 --- a/lib/Local.js +++ b/lib/Local.js @@ -50,22 +50,32 @@ module.exports = { callback(null, true); }, - serviceRegister: function( type, key, info, callback ){ - this.store.services[type + ':' + info.id] = info; + serviceRegister: function( type, info, callback ){ + if (!this.store.services[type]){ + this.store.services[type] = {}; + } + this.store.services[type][info.id] = info; callback(null, true); }, serviceCount:function(type, callback){ - callback(null, Object.keys(this.store.services).length); + var services = this.store.services[type] || {}; + callback(null, Object.keys(services).length); }, - serviceRemove: function( key, id, callback){ - this.store.services[ key+':'+id ] = null; + serviceRemove: function( type, id, callback){ + if (this.store.services[type] && this.store.services[type][id]){ + this.store.services[type][id] = null; + } callback(null, true); }, serviceGet: function( type, id, callback){ - callback(null, this.store.services[type+':'+id] || {}); + if (!id){ + callback(null, this.store.services[type] || {}); + } else { + callback(null, this.store.services[type][id]); + } }, remove: function( key, callback){ diff --git a/package.json b/package.json index b897c472e..9b372bdd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "koop", - "version": "2.1.4", + "version": "2.1.5", "description": "A node module/express middleware for converting GeoJSON to Esri Feature Services.", "main": "index.js", "scripts": {