locana-co / PGRestAPI

Node.js REST API for PostGres Spatial Entities. AKA: SpatialServer
Apache License 2.0
436 stars 75 forks source link

non-public schemas #102

Open JulieGoldberg opened 9 years ago

JulieGoldberg commented 9 years ago

I can't seem to make tiles from tables that are not in the public schema. If I add the schema in settings.js, the tables will show up in my table listing, and I can see the detail page about the table. But when I click on the dynamic map or vector tile service link for that table, I get an error "There was an error with the web service. Please try your operation again." The output from the server is pasted below.

---------------------- Output when I have the table in another schema----------------------------

Executing query: select column_name, CASE when data_type = 'USER-DEFINED' THEN udt_name ELSE data_type end as data_type from INFORMATION_SCHEMA.COLUMNS where table_name = $1, granularity_geometries_13 Executing query: select ST_SRID("geometry") as SRID FROM "granularity_geometries_13" LIMIT 1; GET /services/tables/granularity_geometries_13 304 66ms GET /img/logo.png 304 2ms GET /stylesheets/layout.js 304 3ms GET /fonts/fonts.css 304 5ms GET /stylesheets/style.css 304 7ms GET /img/sdlogo.jpg 304 6ms Executing query: select column_name from INFORMATION_SCHEMA.COLUMNS where (data_type = 'USER-DEFINED' AND udt_name = 'geometry') AND table_name = $1, granularity_geometries_13 Executing query: SELECT ST_Extent(geometry) as table_extent FROM "granularity_geometries_13"; TypeError: /opt/emp_eng/PGRestAPI/endpoints/tables/views/table_vector_tiles.jade:98 96| 97| pre.codePreview

98| | #{featureCollection[0].link}/{z}/{x}/{y}.pbf; 99| 100| div.helpLink 101| | Get more help with Cannot read property '0' of undefined at eval (eval at (/opt/emp_eng/PGRestAPI/node_modules/jade/lib/jade.js:152:8), :799:60) at /opt/emp_eng/PGRestAPI/node_modules/jade/lib/jade.js:153:35 at Object.exports.render (/opt/emp_eng/PGRestAPI/node_modules/jade/lib/jade.js:197:10) at Object.exports.renderFile (/opt/emp_eng/PGRestAPI/node_modules/jade/lib/jade.js:233:18) at View.exports.renderFile as engine at View.render (/opt/emp_eng/PGRestAPI/node_modules/express/lib/view.js:76:8) at Function.app.render (/opt/emp_eng/PGRestAPI/node_modules/express/lib/application.js:505:10) at ServerResponse.res.render (/opt/emp_eng/PGRestAPI/node_modules/express/lib/response.js:756:7) at Object.common.respond (/opt/emp_eng/PGRestAPI/common.js:31:13) at Function. (/opt/emp_eng/PGRestAPI/endpoints/tables/index.js:1193:14) /opt/emp_eng/PGRestAPI/endpoints/tables/views/table_vector_tiles.jade:98 96| 97| pre.codePreview

98| | #{featureCollection[0].link}/{z}/{x}/{y}.pbf; 99| 100| div.helpLink 101| | Get more help with Cannot read property '0' of undefined There was an error with the web servcice. Please try your operation again. GET /services/tables/granularity_geometries_13/geometry/vector-tiles 500 51ms - 73b GET /services/tables/ee_districts_districtshape 200 50ms - 4.52kb GET /stylesheets/layout.js 304 2ms GET /img/logo.png 304 2ms GET /fonts/fonts.css 304 9ms GET /stylesheets/style.css 304 11ms GET /img/sdlogo.jpg 304 1ms

JulieGoldberg commented 9 years ago

I tried following instructions to get postgis available everywhere, and it didn't help. I could get the tables to show up in the directory by using the schemas setting, but it failed when trying to select from them. Even if I put the schema with those tables in the global path, it couldn't make tiles from them. I did get an error also when you're trying to select details about column names, selecting columns where the type is 'USER-DEFINED', and in my pg_catalog, they type is 'geometry'. I have to wonder if there's something weird in how postgis describes the table name, because I'm making these tables with a "SELECT INTO" rather than "CREATE TABLE".

MajuSadagopan commented 8 years ago

I had this issue too until I thought of setting the db search path using the ALTER DATABASE db_name SET search_path TO schema1, schema2 ... Your post helped me find this solution so I hope this helps :)