-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial for within postgis
Sarthak agarwal edited this page Sep 28, 2015
·
5 revisions
####This is the tutorial to develop and run test cases for within query in postgis.
######This tutorial is divided into two sections-
- Creating the test case.
- Running them on PostGIS to get the query execution time.
- In this we are assuming that you have running postgres/postgis on your computer and the database and has postgis extension.
- You simply have to run
within.shand it will ask you size of both layers: a. The fisrt layer is the number of rows of lines you want in the layer. b. The second layer is the number of rows of boxes you want in the layer. - We are writting all the queries in a single file and execute that file on the sql console and record the time for just within query without any read and write operation.
-
misc.txtcontains the queries to drop and recreate the geometry tables in the database. -
line_insert.py(line_output.txt) andbox_insert.py(box_output.txt) will create temp files with the sql queries to store those geometries in the database. - The
within.shalso asks whether want to index the datasets or,1for yes and0otherwise. The index queries are stored inindex.txt. - Finally we have
within.pythat will create with sql queries forwithinfunctiona and store them inwithin_output.txt -
script.pystiches them all together and create a within.sql which is to be executed in the postgres console.
- Now that we have within.sql file containing all the queries, we will execute the file on the console.
- On the timing flag by
\timingcommand. - and run the within.sql by command
\i within.sqlin the psql console.
There is no write operation on the above queries. To check the query results remove the following comment in within.py :
#print '''SELECT * FROM lineLayer WHERE '''
Database connectivity:
* sudo -u postgres createuser -P ` USER_NAME`
* sudo -u postgres createdb -O `USER_NAME` `DATABASE_NAME`
* sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" `DATABASE_NAME`
* psql -h localhost -U `USER_NAME` `DATABASE_NAME`