Chris Pollett > Students > Pundi Muralidharan
[Bio] [Blog] [Deliverable 1 - WebGL Program: The Logic Behind] [Deliverable 2 - The Study of OSM Data and Vector Tiles] [Deliverable 3 - Importing OSM Data into Postgres Database] [Deliverable 4 - Study of Current Tile Generators in Trend] [CS 298 Report-Intermediate - PDF] [CS 298 - Summary of Intermediate Results - PDF] [CS 298 Project Source Code - ZIP] |
The Query for getting data from the Postgres databaseDescription: This part of the project was to create queries to Postgres Database. A PHP back-end script is used to connect to the database and execute the query. Further, the results of the query are sent to WebGL as JSON objects.The PHP code is as follows:
$hostDb = "host=localhost";
The above code connects to the database using the DB parameters specified, with the help of pg_connect() function. The query is as follows:
SELECT name, ST_AsText(ST_Transform(way,4326))
Here, the MakeEnvelope constructor creates a bounding box using the parameters specified- they are calculated by getting the current geographical position coordinates from the browser and adding and subtracting a specific value from them to calculate the minimums and maximums. The Transform constructor transforms the way geometry into a way that can be read, which is calculated by specifying the SRID for WGS84 projection, which is 4326. The AsText constructor, converts the data into a Well-Known Text representation (WKT). |