From f9917f157a1306e49d80b44096f6a3f3785c8226 Mon Sep 17 00:00:00 2001 From: chelm Date: Thu, 30 Apr 2015 11:10:32 -0600 Subject: [PATCH 1/4] fixing service registration in the local, in-mem cache --- lib/Local.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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){ From ea7b8c1acb6a64448daeeddecb623ea7f7e7a3af Mon Sep 17 00:00:00 2001 From: chelm Date: Thu, 30 Apr 2015 11:11:22 -0600 Subject: [PATCH 2/4] adding method to base model for saving files and getting geohash aggs --- lib/BaseModel.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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 }; }; From 73304bba5d2c91e2f4e53a3743c50113a9b41c4a Mon Sep 17 00:00:00 2001 From: chelm Date: Thu, 30 Apr 2015 11:15:14 -0600 Subject: [PATCH 3/4] updating changelog and package --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) 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/package.json b/package.json index b897c472e..b720405b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "koop", - "version": "2.1.4", + "version": "2.1.6", "description": "A node module/express middleware for converting GeoJSON to Esri Feature Services.", "main": "index.js", "scripts": { From 1aa69f0b1c3f38de30bf81782767ab2460469f2c Mon Sep 17 00:00:00 2001 From: chelm Date: Thu, 30 Apr 2015 11:32:14 -0600 Subject: [PATCH 4/4] fixing package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b720405b4..9b372bdd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "koop", - "version": "2.1.6", + "version": "2.1.5", "description": "A node module/express middleware for converting GeoJSON to Esri Feature Services.", "main": "index.js", "scripts": {