Navigation Menu

Skip to content

Commit

Permalink
Updated user.
Browse files Browse the repository at this point in the history
Added Vacuum Analyze on start, and support for 4326 & 3857 for dynamic map services.  Also updated ST_Extent query for dynamicMapLanding page.
  • Loading branch information
apollolm committed Dec 22, 2013
1 parent 4f1b1a1 commit c288dd2
Show file tree
Hide file tree
Showing 84 changed files with 39 additions and 10 deletions.
Empty file modified .gitattributes 100644 → 100755
Empty file.
Empty file modified .gitignore 100644 → 100755
Empty file.
Empty file modified LICENSE 100644 → 100755
Empty file.
Empty file modified Makefile.txt 100644 → 100755
Empty file.
Empty file modified README.md 100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions app.js 100644 → 100755
Expand Up @@ -85,11 +85,16 @@ http.createServer(app).listen(app.get('port'), app.get('ipaddr'), function () {
//Root Request - show table list
app.get('/', function (req, res) { res.redirect('/services/tables') });

//Redirect /services to table list
app.get('/services', function (req, res) { res.redirect('/services/tables') });


if (mapnik)
{
//look thru all tables in PostGres with a geometry column, spin up dynamic map tile services for each one
//on startup. Probably move this to a 'startup' module
common.vacuumAnalyzeAll();

tables.findSpatialTables(function (error, tables) {
if (error) {

Expand All @@ -107,4 +112,6 @@ if (mapnik)
}
}
});


}
7 changes: 7 additions & 0 deletions common.js 100644 → 100755
Expand Up @@ -71,6 +71,13 @@ common.log = function(message) {
console.log(message);
}

common.vacuumAnalyzeAll = function(){
var query = { text: "VACUUM ANALYZE;", values: [] };
common.executePgQuery(query, function (result) {
console.log("Performed VACUUM ANALYZE on ALL;")
});
}

//Determine if a string contains all numbers.
common.IsNumeric = function (sText) {
var ValidChars = "0123456789";
Expand Down
Empty file modified docs/OSX_Install.md 100644 → 100755
Empty file.
Empty file modified docs/Ubuntu_Install.md 100644 → 100755
Empty file.
Empty file modified docs/Windows_Install.md 100644 → 100755
Empty file.
Empty file modified docs/screens/dynamic.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/gpbuffer.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/logo.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/query.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/query2.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/raster.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/tabledetail.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/tablelist.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/screens/wktpreview.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified endpoints/geoprocessing/index.js 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/operations/BufferDissolveZonalStats.js 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/operations/BufferPoint.js 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/operations/CreateRasterFromArray.js 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/operations/GeoOperation.js.example 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/operations/index.js 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/views/geoprocessing_operation.jade 100644 → 100755
Empty file.
Empty file modified endpoints/geoprocessing/views/geoprocessing_operations.jade 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/blueplaid.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified endpoints/mapnik/cartocss/greenplaid.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified endpoints/mapnik/cartocss/grid.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified endpoints/mapnik/cartocss/nigeria_statecapitals.mss 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/pinkplaid.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified endpoints/mapnik/cartocss/style.mss 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/style.xml 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/uganda_coverage.mss 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/uganda_hexbins.mss 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/uganda_states.mss 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/cartocss/uganda_urbanareas.mss 100644 → 100755
Empty file.
9 changes: 6 additions & 3 deletions endpoints/mapnik/index.js 100644 → 100755
Expand Up @@ -7,7 +7,8 @@ var express = require('express'),

//Module-specific requires:
var mapnik = require('mapnik'),
mercator = require('./utils/sphericalmercator.js'),
mercator = require('./utils/sphericalmercator.js'), // 3857
geographic = require('./utils/geographic.js'), //4326
parseXYZ = require('./utils/tile.js').parseXYZ,
path = require('path'),
fs = require("fs"),
Expand Down Expand Up @@ -40,6 +41,7 @@ exports.createPGTileRenderer = flow.define(
function (table, geom_field, epsgSRID, cartoFile) {

this.table = table;
this.epsg = epsgSRID;

var name;
var stylepath = __dirname + '/cartocss/';
Expand Down Expand Up @@ -97,7 +99,7 @@ exports.createPGTileRenderer = flow.define(
try {
//create map and layer
var map = new mapnik.Map(256, 256, mercator.proj4);
var layer = new mapnik.Layer(_self.table, mercator.proj4);
var layer = new mapnik.Layer(_self.table, ((_self.epsg && (_self.epsg == 3857 || _self.epsg == 3587)) ? mercator.proj4 : geographic.proj4)); //check to see if 3857. If not, assume WGS84
var postgis = new mapnik.Datasource(postgis_settings);
var bbox = mercator.xyz_to_envelope(parseInt(params.x),
parseInt(params.y),
Expand Down Expand Up @@ -145,6 +147,7 @@ exports.createPGTileQueryRenderer = flow.define(

this.table = table;
this.geom_field = geom_field;
this.epsg = epsgSRID;

var name;
var stylepath = __dirname + '/cartocss/';
Expand Down Expand Up @@ -242,7 +245,7 @@ exports.createPGTileQueryRenderer = flow.define(
try {
//create map and layer
var map = new mapnik.Map(parseInt(args.width), parseInt(args.height), mercator.proj4); //width, height
var layer = new mapnik.Layer(_self.table, mercator.proj4);
var layer = new mapnik.Layer(_self.table, ((_self.epsg && (_self.epsg == 3857 || _self.epsg == 3587)) ? mercator.proj4 : geographic.proj4)); //check to see if 3857. If not, assume WGS84
var postgis = new mapnik.Datasource(postgis_settings);

var floatbbox = args.bbox.split(",");
Expand Down
Empty file modified endpoints/mapnik/package.json 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/utils/pool.js 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/utils/sphericalmercator.js 100644 → 100755
Empty file.
Empty file modified endpoints/mapnik/utils/tile.js 100644 → 100755
Empty file.
Empty file modified endpoints/services/index.js 100644 → 100755
Empty file.
Empty file modified endpoints/services/views/services.jade 100644 → 100755
Empty file.
26 changes: 19 additions & 7 deletions endpoints/tables/index.js 100644 → 100755
Expand Up @@ -24,7 +24,6 @@ var app = exports.app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');


//Add a route and define response
//Get list of public base tables from postgres
app.all('/services/tables', function (req, res) {
Expand Down Expand Up @@ -827,12 +826,22 @@ if (mapnik) {
getGeometryFieldNames(this.args.table, this);

}, function (geom_fields_array) {


//This should have a value
var srid = app.spatialTables[this.args.table].srid;

//coming back from getGeometryFieldNames
//for now, assume just 1 geometry. TODO
if (geom_fields_array.length > 0) {
//Check for layer extent
var query = { text: "SELECT ST_Extent(" + geom_fields_array[0] + ") as table_extent FROM " + this.args.table + ";", values: [] };
//Transform to 4326 if 3857
var query;
if(srid && (srid == 3857 || srid == 3587)){
query = { text: "SELECT ST_Extent(ST_Transform(" + geom_fields_array[0] + ", 4326)) as table_extent FROM " + this.args.table + ";", values: [] };
}
else{
query = { text: "SELECT ST_Extent(" + geom_fields_array[0] + ") as table_extent FROM " + this.args.table + ";", values: [] };
}
common.executePgQuery(query, this);
}
else {
Expand All @@ -848,7 +857,7 @@ if (mapnik) {
this.args.errorMessage = "Problem getting the extent for this table.";
}
else {

debugger;
var bboxArray = result.rows[0].table_extent.replace("BOX(", "").replace(")", "").split(","); //Should be BOX(XMIN YMIN, XMAX YMAX)
this.args.xmin = bboxArray[0].split(" ")[0];
this.args.ymin = bboxArray[0].split(" ")[1];
Expand Down Expand Up @@ -1026,20 +1035,23 @@ function makeGeoJSONFile(table, filename, callback) {
exports.findSpatialTables = function (callback) {
var spatialTables = [];
var error;

var query = { text: "select * from geometry_columns", values: [] }; //TODO - add options to specify schema and database. Right now it will read all
common.executePgQuery(query, function (result) {
if (result.status == "error") {
//Report error and exit.
error = result.message;
console.log("Error in reading spatial tables from DB. Can't load dynamic tile endopints. Message is: " + result.message);
} else {
app.spatialTables = {};
//Add to list of tables.
result.rows.forEach(function (item) {
spatialTables.push({ table: item.f_table_name, geometry_column:item.f_geometry_column, srid: item.srid });
var spTable = { table: item.f_table_name, geometry_column:item.f_geometry_column, srid: item.srid };
spatialTables.push(spTable);
app.spatialTables[item.f_table_name] = spTable; //Keep a copy in tables for later.
});
}

//return to sender
callback(error, spatialTables);
});
Expand Down
Empty file modified endpoints/tables/views/rasterops.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tables/views/table_details.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tables/views/table_dynamic_map.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tables/views/table_list.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tables/views/table_query.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tables/views/topojson_list.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tables/views/zonalstatistics.jade 100644 → 100755
Empty file.
Empty file modified endpoints/tiles/index.js 100644 → 100755
Empty file.
Empty file modified endpoints/tiles/views/tile_list.jade 100644 → 100755
Empty file.
Empty file modified endpoints/utilities/index.js 100644 → 100755
Empty file.
Empty file modified endpoints/utilities/views/utilities.jade 100644 → 100755
Empty file.
Empty file modified endpoints/utilities/views/wktpreview.jade 100644 → 100755
Empty file.
Empty file modified lib/datablaster/blast_config.js 100644 → 100755
Empty file.
Empty file modified lib/datablaster/index.js 100644 → 100755
Empty file.
Empty file modified lib/datablaster/transformers.js 100644 → 100755
Empty file.
Empty file modified package.json 100644 → 100755
Empty file.
Empty file modified public/blast_output/Bangladesh_Cico_Count.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Bangladesh_Cicos.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Nigeria_Cico_Count.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Nigeria_Cicos.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Tanzania_Cico_Count.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Tanzania_Cicos.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Uganda_Cico_Count.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/Uganda_Cicos.js 100644 → 100755
Empty file.
Empty file modified public/blast_output/index.js 100644 → 100755
Empty file.
Empty file modified public/cached_nodetiles/.gitignore 100644 → 100755
Empty file.
Empty file modified public/geojson/.gitignore 100644 → 100755
Empty file.
Empty file modified public/geojson/output/.gitignore 100644 → 100755
Empty file.
Empty file modified public/img/bg_thatch.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/img/favicon.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/img/logo.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/stylesheets/style.css 100644 → 100755
Empty file.
Empty file modified public/stylesheets/style.less 100644 → 100755
Empty file.
Empty file modified public/topojson/.gitignore 100644 → 100755
Empty file.
Empty file modified public/topojson/output/.gitignore 100644 → 100755
Empty file.
Empty file modified settings.js.example 100644 → 100755
Empty file.
Empty file modified shared_views/layout.jade 100644 → 100755
Empty file.
Empty file modified test/index.js 100644 → 100755
Empty file.

0 comments on commit c288dd2

Please sign in to comment.