CREATING DEMO APPLICATION MapServer WebGIS - PostGIS

CREATING DEMO APPLICATION MapServer WebGIS - PostGIS
We will modify the demo / sample GIS Web application that you created above, into MapServer WebGIS applications that retrieve data from the geometry and attribute PostgreSQL server that already supports PostGIS. The application also can be downloaded at: http://www.hatma.info/download/gis/Demo_MapServer_PostGIS.zip. After downloading is complete, extract its contents into the appropriate directory, ie: apps, http.d and Apache / htdocs. Then load sql data into your PostgreSQL database. Then restart your Apache by executing apache-restart.bat. open http://localhost in a web browser, then click the demo link on the "Hatma Suryotrisongko Web GIS Demo - PostGIS Spatial Database URLs: ": http://localhost/demo2/demo.phtml Link URL demo second program, on the main page MODIFY FILE CONFIGURATION first (CHAMELEON.MAP) FROM SAMPLE / DEMO APPLICATION ABOVE, BECOME THE APPLICATION WebGIS TAKE DATA FROM THE SERVER PostgreSQL database. We'll change the line calling the data layer definition shp on line, so that direct data retrieval from the database. In general, we will change the way as follows: Step I. comment mark (#) on line data definitions # DATA (data file shp) Step II. Insert definition of data retrieval from the database CONNECTIONTYPE PostGIS CONNECTION "user = [user name] dbname = [database name] host = [host database] port = [port database : 5432] password = [password] " DATA "[geometry column name] FROM [table name] USING UNIQUE [unique index / primary key]" FILTER "[condition / requirements]" www.hatma.info 1 WebgGIS with MapServer - MapLab - Chameleon - PostGIS Please note that the writing column names, table names MUST use lowercase letters, while others use a capital letter (see the section "DATA" and "Filter" above), but it must also comply with the writing command understood by the postgresql database (on the DATA definition does not use the syntax SELECT, FILTER is the definition does not use the WHERE syntax.) "USING UNIQUE [unique index / primary key] "in the definition line DATA is used for speed up queries using indexes. Step III. Adjust another definition line LabelItem "name" CLASSITEM "capital" CLASS EXPRESSION "1" TEMPLATE "ttt_query.html" SYMBOL 2 SIZE 8 NAME "Cities" COLOR 0 0 0 END Please note that the writing of the name attribute on LABELITEM data column, CLASSITEM, and others must use lowercase letters. So also with the contents of EXPRESSION definition, must be in accordance with written instructions understood by postgresql database. So the following changes in the configuration file first (. Map) Layer land_fn # DATA land_fn CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tland_fn USING UNIQUE gid" Layer park # DATA park CONNECTIONTYPE PostGIS www.hatma.info 2 WebgGIS with MapServer - MapLab - Chameleon - PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tpark USING UNIQUE gid" Layer drain_fn # DATA drain_fn CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tdrain_fn USING UNIQUE gid" FILTER "poly_featu = 16 OR poly_featu = 21" CLASSITEM "poly_featu" Drainage layer # DATA drainage CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tdrainage USING UNIQUE gid" FILTER "poly_featu = 0" CLASSITEM "poly_featu" Layer prov_bound # DATA province CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tprovince USING UNIQUE gid" Layer fedlimit # DATA fedlimit CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tfedlimit USING UNIQUE gid" Layer rail # DATA rail CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM trail USING UNIQUE gid" Layer Road # DATA road CONNECTIONTYPE PostGIS www.hatma.info 3 WebgGIS with MapServer - MapLab - Chameleon - PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM troad USING UNIQUE gid" Layer popplace # DATA popplace CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tpopplace USING UNIQUE gid" FILTER "capital> = 1 AND capital <= 3" LabelItem "name" CLASSITEM "capital" Layer "grid" # DATA "grid" CONNECTIONTYPE PostGIS CONNECTION "user = hatma_s dbname = dbspatialdemo host = localhost port = 5432 password = 2006bedogtelu" DATA "the_geom FROM tgrid USING UNIQUE gid" Some changes to the file chameleon.php Once completed the configuration file was changed, then we test whether the application is already we create can run well, and whether the data are shown together with the data are shown in the demo application that is still taking data from the shp file. www.hatma.info 4 WebgGIS with MapServer - MapLab - Chameleon - PostGIS Display program to retrieve data from database