Title: PHP MapScript
1PHP MapScript
2PHP Configuration
- ????????????? PHP ???????? Extension File ??????
????? php.ini ????????????? ???????
extension_dir - extension_dir /ms4w/Apache/php/ext/
- ????????????/ms4w/Apache/php/ext/ ?????????
php_mapscript.dll ??????????? - ????? php.ini ????????? D\ms4w\Apache\cgi-bin
?????? - extension php_mapscript.dll
3PHP MapScript Configuration
- restart Apache ?????????????????? phpMapScript
???? phpinfo()
4(No Transcript)
5MapScript Architecture
6PHP MapScript
phpms-1.php
- lt?php mapms_newMapObj(ex-01.map) imgmap-
gtdraw() img_urlimg-gt saveWebImage() - ?gt
- ltHTMLgtltHEADgt ltTITLEgtExample 1 Displaying a
maplt/TITLEgt lt/HEADgtltBODYgt - ltIMG SRClt? echo img_url ?gt gt
- lt/BODYgt
- lt/HTMLgt
7phpms-2.php
ltform methodGET action""gt .lt/formgt
8Navigation
ltinput typeradio name"zoom" VALUEF
lt?php echo fullextent?gt gt Full
Extentltbrgt ltinput typeradio name"zoom" VALUE0
lt?php echo pan?gt gt Panltbrgt ltinput
typeradio name"zoom" VALUE1 lt?php
echo zoomin?gt gt Zoom Inltbrgt ltinput typeradio
name"zoom" VALUE-1 lt?php echo
zoomout?gt gt Zoom Outltbrgt ltinput typetext
name"zsize" VALUElt?php echo
zoomsize?gt SIZE2gt Sizeltbrgt ltinput typeSUBMIT
name"refresh" VALUE"Refresh"gt
9Layers
- ltinput type"checkbox" name"layer"
value"amphur" - lt?php echo amphur?gt gt?????ltbrgt
- ltinput type"checkbox" name"layer"
value"tambon" - lt?php echo tambon?gt gt????ltbrgt
- ltinput type"checkbox" name"layer"
value"hospital" - lt?php echo hospital?gt gt?????????ltbrgt
- ltinput type"checkbox" name"layer"
value"healthcenter" - lt?php echo healthcenter?gt
gt???????????ltbrgt
10Map Object
- Create Map Object
- map ms_newMapObj("ex-03.map")
- ????? Layers
- map-gtnumlayers
- Extent
- map-gtextent-gtminx
- map-gtextent-gtminy
- map-gtextent-gtmaxx
- map-gtextent-gtmaxy
- setextent(minx, miny, maxx, maxy)
11Layer Object
- ????? Layer ??????????
- lyr0 map-gtgetLayer(0)
- ????? Class ?? Layer ???????
- lyr0 -gtnumclasses
- ???? Class ?? Layer ???????
- class0 lyr0-gtgetClass(0)
- ????? Labelitem
- class0-gtlabelitem
- Scale
- class0-gtmaxscale
12Class Object
- ????? Class ?? Layer ???????
- class0 lyr0-gtgetClass(0)
- ???? Class ???????
- class0-gtname
- Style
- cstyle class0-gt getStyle(0)
- Expression ??? Class
- class0-gt setexpression(string expression)
- class0-gt getexpression(string expression)
13Style Object
14??????????????????????
- http//172.20.26.100/mapdemo.zip
- Start ? Programs ? PostgreSQL 8.2 ? Command
Prompt - gtcreatedb E win874 mapdemo
- gtpsql U postgres mapsemo lt /tmp/mapdemo.sql
- gtpsql U postgres mapsemo
- mapdemo\d
- mapdemo\dt c_cancer
- mapdemoselect from c_cancer limit 10
- mapdemo\q
15?????????????? PostGIS
- Start ? Programs ? PostgreSQL 8.2 ? Command
Prompt - gtshp2pgsql province.shp province gtprovince.sql
- gtpsql -U postgres -l
- gtcreatedb E win874 mapserver T template_postgis
- gtpsql U postgres mapserver lt /province.sql
- gtpsql U postgres mapserver
- mapserver\d
- mapserver \dt province
- mapserver \q
16PostGIS
- CREATE TABLE
- Data type geometry
- ImportData From Vector
- shp2pgsql
- shp2pgsql province.shp province gt
province.sql - gr2ogr
- ogr2ogr -f "MapInfo File" provinve.tab
PGdbnamegisdb province - -f "ESRI Shapefile"
- -f "TIGER"
- -f "MapInfo File"
- -f "GML"
- -f "PostgreSQL"
17PHP connect to PostgreSQL
- lt?php
- dbconn pg_connect("hostlocalhost
dbnamemapdemo userpostgres - password123456") or die("??????????????
????????????? ".pg_last_error() ) - sql "SELECT FROM c_cancer"
- result pg_query(sql) or
die("??????????????????????????? ".
pg_last_error() ) - // Printing results in HTML
- echo pg_num_rows(result)."ltbrgt"
- echo "lttablegt"
- while (row pg_fetch_row(result))
- echo "lttrgt"
- echo "lttdgtrow0lt/tdgtlttdgtrow1lt/tdgt"
- echo "lt/trgt"
-
- echo "lt/tablegt"
- // Free resultset
- pg_free_result(result)
- // Closing connection
- pg_close(dbconn)
- ?gt
18PostGIS
- ??????????
- SELECT distance(the_geom,the_geom)
- ???????????????????????????
- SELECT provincename FROM thailand
- WHERE touches(thailand.the_geom, (SELECT
the_geom - FROM thailand WHERE province 67))
- ?????????????????????????????
- SELECT provincename FROM thailand
- WHERE province 67 AND distance(the_geom,
SELECT the_geom - FROM thailand WHERE province 67)lt100
- ???????????? non-spatial data