diff --git a/.jshintignore b/.jshintignore index ba2ecea5..a39c5228 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,3 +1,3 @@ test/support/ test/websocket_test/ -app/models/formats/topojson.js +app/models/formats/pg/topojson.js diff --git a/NEWS.md b/NEWS.md index 2c29312f..0e0c2b9c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ 1.22.1 - 2015-mm-dd ------------------- +Enhancements: + + * Format files split into pg and ogr directories + 1.22.0 - 2015-04-09 ------------------- diff --git a/app/models/formats/index.js b/app/models/formats/index.js index 51ddebd6..25af88f6 100644 --- a/app/models/formats/index.js +++ b/app/models/formats/index.js @@ -1,16 +1,20 @@ -// -// load all the formats -// - +var fs = require("fs"); var formats = {}; -var path = require('path'); -var folder = __dirname + "/"; -require("fs").readdirSync(folder).forEach(function(file) { - if (path.extname(file) === '.js' && file !== 'index.js' && file !== 'ogr.js' && file !== 'pg.js' ) { - var format = require(folder + file); +function formatFilesWithPath(dir) { + var formatDir = __dirname + '/' + dir; + return fs.readdirSync(formatDir).map(function(formatFile) { + return formatDir + '/' + formatFile; + }); +} + +var formatFilesPaths = [] + .concat(formatFilesWithPath('ogr')) + .concat(formatFilesWithPath('pg')); + +formatFilesPaths.forEach(function(file) { + var format = require(file); formats[format.prototype.id] = format; - } }); module.exports = formats; diff --git a/app/models/formats/csv.js b/app/models/formats/ogr/csv.js similarity index 91% rename from app/models/formats/csv.js rename to app/models/formats/ogr/csv.js index bb86a364..1fa4ae15 100644 --- a/app/models/formats/csv.js +++ b/app/models/formats/ogr/csv.js @@ -1,4 +1,4 @@ -var ogr = require('./ogr'); +var ogr = require('./../ogr'); function CsvFormat() {} diff --git a/app/models/formats/kml.js b/app/models/formats/ogr/kml.js similarity index 95% rename from app/models/formats/kml.js rename to app/models/formats/ogr/kml.js index 3c243cc3..9430f647 100644 --- a/app/models/formats/kml.js +++ b/app/models/formats/ogr/kml.js @@ -1,4 +1,4 @@ -var ogr = require('./ogr'); +var ogr = require('./../ogr'); function KmlFormat() {} diff --git a/app/models/formats/shp.js b/app/models/formats/ogr/shp.js similarity index 99% rename from app/models/formats/shp.js rename to app/models/formats/ogr/shp.js index 84a447fc..4dd59f35 100644 --- a/app/models/formats/shp.js +++ b/app/models/formats/ogr/shp.js @@ -3,7 +3,7 @@ var fs = require('fs'); var spawn = require('child_process').spawn; var assert = require('assert'); -var ogr = require('./ogr'); +var ogr = require('./../ogr'); function ShpFormat() { } diff --git a/app/models/formats/arraybuffer.js b/app/models/formats/pg/arraybuffer.js similarity index 96% rename from app/models/formats/arraybuffer.js rename to app/models/formats/pg/arraybuffer.js index 9c525781..41bdbb23 100644 --- a/app/models/formats/arraybuffer.js +++ b/app/models/formats/pg/arraybuffer.js @@ -1,7 +1,7 @@ var _ = require('underscore'); -var pg = require('./pg'); -var ArrayBufferSer = require("../bin_encoder"); +var pg = require('./../pg'); +var ArrayBufferSer = require("../../bin_encoder"); function BinaryFormat() {} diff --git a/app/models/formats/geojson.js b/app/models/formats/pg/geojson.js similarity index 98% rename from app/models/formats/geojson.js rename to app/models/formats/pg/geojson.js index 56dc75da..cdaf9c29 100644 --- a/app/models/formats/geojson.js +++ b/app/models/formats/pg/geojson.js @@ -1,6 +1,6 @@ var _ = require('underscore'); -var pg = require('./pg'); +var pg = require('./../pg'); function GeoJsonFormat() { this.buffer = ''; diff --git a/app/models/formats/json.js b/app/models/formats/pg/json.js similarity index 97% rename from app/models/formats/json.js rename to app/models/formats/pg/json.js index c2529235..f3dfafe8 100644 --- a/app/models/formats/json.js +++ b/app/models/formats/pg/json.js @@ -1,7 +1,7 @@ var _ = require('underscore'); -var pg = require('./pg'); -var PgErrorHandler = require('../../postgresql/error_handler'); +var pg = require('./../pg'); +var PgErrorHandler = require('../../../postgresql/error_handler'); function JsonFormat() { this.buffer = ''; diff --git a/app/models/formats/svg.js b/app/models/formats/pg/svg.js similarity index 99% rename from app/models/formats/svg.js rename to app/models/formats/pg/svg.js index 171676ba..3bedb7c6 100644 --- a/app/models/formats/svg.js +++ b/app/models/formats/pg/svg.js @@ -1,4 +1,4 @@ -var pg = require('./pg'); +var pg = require('./../pg'); var svg_width = 1024.0; var svg_height = 768.0; diff --git a/app/models/formats/topojson.js b/app/models/formats/pg/topojson.js similarity index 99% rename from app/models/formats/topojson.js rename to app/models/formats/pg/topojson.js index c97c6e93..7ee267b3 100644 --- a/app/models/formats/topojson.js +++ b/app/models/formats/pg/topojson.js @@ -1,4 +1,4 @@ -var pg = require('./pg'); +var pg = require('./../pg'); var _ = require('underscore'); var geojson = require('./geojson'); var TopoJSON = require('topojson');