Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connecting to a nonlocal database #27

Open
iskandari opened this issue Feb 8, 2017 · 11 comments
Open

connecting to a nonlocal database #27

iskandari opened this issue Feb 8, 2017 · 11 comments

Comments

@iskandari
Copy link

iskandari commented Feb 8, 2017

In the server.js file I am attempting to connect remotely to a PostgreSQL database instance on Amazon Web Services. On my local computer, I am able to connect to it through PgAdmin.

Using tilesplash, however, it keeps bouncing back with Cannot GET / This is probably because a password is required. Where would one pass the password argument when creating a new Tilesplash() for example?

var app = new Tilesplash('postgres://[email protected] password="mypassword" /mydb');

@summer4096
Copy link

Are you getting any errors in the terminal where you're running your server?

Your database url isn't valid. That might not be the entire problem, but that URL definitely won't work. What you want is this:

postgres://awsuser:[email protected]/mydb

@iskandari
Copy link
Author

iskandari commented Feb 8, 2017

There are no errors in the terminal. Yes, I've tried that option as well but I receive the same error

@fxi
Copy link

fxi commented Feb 8, 2017

Wrong port ?

var con = {
  user : "<user>",
  database : "<db>",
  password : "<user password>",
  port : 5433,
  host : "amazonaws.com" 
};

var app = new Tilesplash(con);

See also
https://github.com/brianc/node-postgres
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html

@iskandari
Copy link
Author

iskandari commented Feb 8, 2017

Thanks, I've tried this as well but still the same error (the port is correct). I've made sure the db is publicly available and am able to connect via PgAdmin. Is there a way to get more information than Cannot GET / ?

@summer4096
Copy link

Well, tilesplash doesn't actually create a page for /. To get tiles out of it, you need to construct a URL based on the x, y, and z. It's actually kind of buried in the documentation, here. Try:

http://localhost:3000/my_layer_name/0/0/0.topojson

@iskandari
Copy link
Author

iskandari commented Feb 9, 2017

Right, I've added that in the html file with tiles: ['http://localhost:3000/parcel11/{z}/{x}/{y}.mvt'] All of the code is here. Any idea as to where the snag could be?

@fxi
Copy link

fxi commented Feb 9, 2017 via email

@summer4096
Copy link

Hmm. When you open up http://localhost:3000/parcel11/0/0/0.topojson what do you see?

@iskandari
Copy link
Author

It just says localhost refused to connect, and in the terminal, this is repeated:

[debug] "Running Query"
[debug] "  SQL: SELECT ST_AsGeoJSON(wkb_geometry) as the_geom_geojson, parcel11.sptbcode FROM parcel11 WHERE ST_Intersects(wkb_geometry, ST_Transform(ST_SetSRID(ST_MakeBox2D(ST_MakePoint(-20037508.342789244, -20037508.342789236), ST_MakePoint(20037508.342789244, 20037508.342789244)), 3857), 4326))"
[debug] "  Arguments: []"
[debug] "Rendering tile parcel11/0/0/0"

I guess there is an issue with connecting to the database, but don't understand why

@iskandari
Copy link
Author

iskandari commented Feb 19, 2017

I get the same error: Cannot GET / even when I try to connect to localhost. I've tried reinstalling tilesplash but the installation freezes and I get this error:


npm install tilesplash
npm WARN deprecated [email protected]: This module is now under the @mapbox namespace: install @mapbox/sphericalmercator instead

Could this be part of the problem?

Node runs fine after npm start however, when I paste http://localhost:3000/parcel11/0/0/0.mvt into the browser (Chrome), a file 0.mvt is downloaded but it is empty. Not sure where the error is.

@summer4096
Copy link

summer4096 commented Feb 20, 2017

Ok. What's happening is that tilesplash just doesn't serve anything at /. You're getting a 404. Tilesplash is serving the tiles, which is why you got an empty file. You're not seeing an error because there is none. MVT isn't human-readable, so for debugging you want to use the topojson extension, like this http://localhost:3000/parcel11/0/0/0.topojson

If that contains no shapes, that means your sql query isn't returning any. Possible reasons are:

  1. parcel11 is empty
  2. parcel11.wkb_geometry is not a 4326 geometry
  3. parcel11.wkb_geometry is empty
  4. gremlins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants