PHP MapScript - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

PHP MapScript

Description:

lyr0 = $map- getLayer(0); ????? Class ?? Layer ??????? $lyr0 - numclasses; ... FROM thailand WHERE province =67)); ????????????????????????????? ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 19
Provided by: Owne1310
Category:
Tags: mapscript | php | map | of | thailand

less

Transcript and Presenter's Notes

Title: PHP MapScript


1
PHP MapScript
  • Day 5

2
PHP 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

3
PHP MapScript Configuration
  • restart Apache ?????????????????? phpMapScript
    ???? phpinfo()

4
(No Transcript)
5
MapScript Architecture
6
PHP 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

7
phpms-2.php
ltform methodGET action""gt .lt/formgt
8
Navigation
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
9
Layers
  • 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

10
Map 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)

11
Layer Object
  • ????? Layer ??????????
  • lyr0 map-gtgetLayer(0)
  • ????? Class ?? Layer ???????
  • lyr0 -gtnumclasses
  • ???? Class ?? Layer ???????
  • class0 lyr0-gtgetClass(0)
  • ????? Labelitem
  • class0-gtlabelitem
  • Scale
  • class0-gtmaxscale

12
Class 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)

13
Style 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

16
PostGIS
  • 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"

17
PHP 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

18
PostGIS
  • ??????????
  • 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
Write a Comment
User Comments (0)
About PowerShow.com