Guest User

Untitled

a guest
Jun 13th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. dl('php_mapscript.so');
  6.  
  7. dl('php_pgsql.so');
  8.  
  9. // Default values and configuration
  10.  
  11.  
  12. $var1=$_POST["v1"];
  13. $src=$_POST["srch"];
  14. $ss="";
  15.  
  16.  
  17. $db_host='localhost';
  18. $db_database ='postgres';
  19. $db_username='postgres';
  20. $db_password='mapserver';
  21.  
  22. $con= pg_connect("host=localhost password=mapserver user=postgres dbname=postgres port=5432");
  23.  
  24. //$db=postgres_select_db($db_database);
  25. //$res="select name from countries";
  26. //$ans=postgres_query($res);
  27.  
  28. if (!$con) {
  29. echo("Connection Failed........");
  30.  
  31. }
  32. else
  33. {
  34. echo("con est");
  35. }
  36.  
  37. if($var1=="on")
  38. {
  39. $ss="MS_ON";
  40. }
  41. else
  42. {
  43. $ss="MS_OFF";
  44. }
  45.  
  46.  
  47.  
  48. echo $ss;
  49.  
  50. $val_zsize=3;
  51.  
  52. $check_pan="CHECKED";
  53.  
  54. $map_path="/opt/fgs/www/htdocs/";
  55.  
  56. $map_file="global.map";
  57.  
  58.  
  59.  
  60. $map = ms_newMapObj($map_path.$map_file);
  61.  
  62.  
  63.  
  64.  
  65. //$layer = ms_newLayerObj($map);
  66.  
  67. $layerobj=$map->getLayerByName('INDIA_DIS');
  68. //$layerrail=$map->getLayerByName('india_rail');
  69. $status = $layerobj->open();
  70.  
  71.  
  72.  
  73. $projInObj = ms_newprojectionobj("proj=latlong");
  74. $projOutObj = ms_newprojectionobj("init=epsg:4326");
  75.  
  76. //$projOutObj = ms_newprojectionobj("init=epsg:4326");
  77. $poPoint = ms_newpointobj();
  78. $poPoint->setXY(-92.0, 62.0);
  79. $poPoint->project($projInObj, $projOutObj);
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. //$statusrail = $layerrail->open();
  88. //$layerrail->set("status",MS_ON);
  89.  
  90. //$layer->set("name", "india");
  91.  
  92. /*if($ss=="MS_ON")
  93.  
  94.  
  95. $layerobj->set("status",MS_ON);
  96.  
  97. else
  98.  
  99. if($ss=="MS_OFF")
  100.  
  101. $layerobj->set("status",MS_OFF);
  102. */
  103.  
  104.  
  105.  
  106. //$layer->set("data","the_geom" );
  107.  
  108.  
  109.  
  110.  
  111. /*
  112.  
  113. //Convert pixels to map units
  114.  
  115. $map_pt = click2map($_GET['image_x'],$_GET['image_y'],$map->extent);
  116.  
  117. //Create the point
  118.  
  119. $pt = ms_newPointObj();
  120.  
  121. $pt-> setXY($map_pt[0],$map_pt[1]);
  122.  
  123.  
  124.  
  125. //Draw the map and add the point
  126.  
  127. $img1 = $map->draw();
  128.  
  129. $layer_inline = $map->getLayerByName('INLINE');
  130. $layer_inline->set("status",MS_ON);
  131.  
  132. $pt->draw($map, $layer_inline, $img1, "adujas" ,'yuhuu');
  133.  
  134. $url = $img1->saveWebImage();
  135.  
  136. */
  137.  
  138.  
  139. $result = pg_query($con, "select state from india_st where state='$src'");
  140. if (!$result) {
  141. echo "An error occured.\n";
  142. exit;
  143. }
  144.  
  145.  
  146.  
  147. $row = pg_fetch_row($result);
  148. echo $row[0];
  149.  
  150.  
  151. if ( isset($HTTP_POST_VARS["mapa_x"]) && isset($HTTP_POST_VARS["mapa_y"])
  152.  
  153. && !isset($HTTP_POST_VARS["full"]) ) {
  154.  
  155.  
  156.  
  157. $extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
  158.  
  159.  
  160.  
  161. $map->setextent($extent_to_set[0],$extent_to_set[1],
  162.  
  163. $extent_to_set[2],$extent_to_set[3]);
  164.  
  165.  
  166.  
  167. $my_point = ms_newpointObj();
  168.  
  169.  
  170. $my_point->setXY($HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);
  171. $my_extent = ms_newrectObj();
  172.  
  173. $my_extent->setextent($extent_to_set[0],$extent_to_set[1],$extent_to_set[2],$extent_to_set[3]);
  174.  
  175. $zoom_factor = $HTTP_POST_VARS["zoom"]*$HTTP_POST_VARS["zsize"];
  176.  
  177.  
  178. if ($zoom_factor == 0) {
  179.  
  180. $zoom_factor = 1;
  181.  
  182. $check_pan = "CHECKED";
  183.  
  184. $check_zout = "";
  185.  
  186. $check_zin = "";
  187.  
  188. } else if ($zoom_factor < 0) {
  189.  
  190. $check_pan = "";
  191.  
  192. $check_zout = "CHECKED";
  193.  
  194. $check_zin = "";
  195.  
  196. } else {
  197.  
  198. $check_pan = "";
  199.  
  200. $check_zout = "";
  201.  
  202. $check_zin = "CHECKED";
  203.  
  204. }
  205.  
  206.  
  207.  
  208. $val_zsize = abs($zoom_factor);
  209.  
  210.  
  211.  
  212. $map->zoompoint($zoom_factor,$my_point,$map->width,$map->height,
  213.  
  214. $my_extent);
  215.  
  216.  
  217. $query=$HTTP_POST_VARS["query"];
  218. if($query!=null)
  219. {
  220.  
  221. $map_pt = click2map($_GET['image_x'],$_GET['image_y'],$map->width,$map->height);
  222.  
  223. $pt = ms_newPointObj();
  224.  
  225.  
  226. $pt-> setXY($map_pt[0],$map_pt[1]);
  227. echo $map_pt[0];
  228. //var $x;
  229. $x=$map->queryByPoint($pt,MS_MULTIPLE,-1);
  230.  
  231. }
  232.  
  233.  
  234.  
  235.  
  236. }
  237.  
  238.  
  239.  
  240. function click2map ($click_x, $click_y,$w,$h)
  241. {
  242.  
  243.  
  244.  
  245. //$e= &$map->extent; //for saving writing
  246.  
  247. echo "x cods". $click_x;
  248.  
  249.  
  250. $x_pct = ($click_x / $w);
  251.  
  252. $y_pct = 1 - ($click_y /$h);
  253.  
  254. $x_map = $e->minx + ( ($e->maxx - $e->minx) * $x_pct);
  255.  
  256. $y_map = $e->miny + ( ($e->maxy - $e->miny) * $y_pct);
  257.  
  258.  
  259.  
  260. return array($x_map, $y_map);
  261.  
  262. }
  263.  
  264.  
  265.  
  266. $image=$map->draw();
  267.  
  268. $image_url=$image->saveWebImage();
  269.  
  270. $extent_to_html = $map->extent->minx." ".$map->extent->miny." "
  271.  
  272. .$map->extent->maxx." ".$map->extent->maxy;
  273.  
  274.  
  275. $layerobj->draw($image);
  276.  
  277. //$layerrail->draw($image);
  278.  
  279.  
  280.  
  281.  
  282. ?>
  283.  
  284. <HTML>
  285.  
  286. <HEAD>
  287.  
  288. <TITLE>Map 2</TITLE>
  289.  
  290. </HEAD>
  291.  
  292. <BODY>
  293.  
  294. <CENTER>
  295.  
  296. <FORM METHOD=POST ACTION=<?php echo $HTTP_SERVER_VARS['PHP_SELF']?>>
  297.  
  298. <TABLE>
  299.  
  300. <TR>
  301.  
  302. <TD>
  303.  
  304. <INPUT TYPE=IMAGE NAME="mapa" SRC="<?php echo $image_url?>">
  305.  
  306.  
  307.  
  308. </TD>
  309.  
  310. </TR>
  311.  
  312. <TR>
  313.  
  314. <TD>
  315.  
  316. Pan
  317.  
  318. </TD>
  319.  
  320. <TD>
  321.  
  322. <INPUT TYPE=RADIO NAME="zoom" VALUE=0 <?php echo $check_pan?>>
  323.  
  324. </TD>
  325.  
  326. </TR>
  327.  
  328. <TR>
  329.  
  330. <TD>
  331.  
  332. Zoom In
  333.  
  334. </TD>
  335.  
  336. <TD>
  337.  
  338. <INPUT TYPE=RADIO NAME="zoom" VALUE=1 <?php echo $check_zin?>>
  339.  
  340. </TD>
  341.  
  342. </TR>
  343.  
  344. <TR>
  345.  
  346. <TD>
  347.  
  348. Zoom Out
  349.  
  350. </TD>
  351.  
  352. <TD>
  353.  
  354. <INPUT TYPE=RADIO NAME="zoom" VALUE=-1 <?php echo $check_zout?>>
  355.  
  356. </TD>
  357.  
  358. </TR>
  359.  
  360. <TR>
  361.  
  362. <TD>
  363.  
  364. Zoom Size
  365.  
  366. </TD>
  367.  
  368. <TD>
  369.  
  370. <INPUT TYPE=TEXT NAME="zsize" VALUE="<?php echo $val_zsize?>"
  371.  
  372. SIZE=2>
  373.  
  374. </TD>
  375.  
  376. <TD>
  377.  
  378. <INPUT TYPE=radio NAME="query" SIZE=2 VALUE=1>
  379.  
  380. </TD>
  381.  
  382. </TR>
  383.  
  384. <TR>
  385.  
  386. <TD>
  387.  
  388. Full Extent
  389.  
  390. </TD>
  391. <TD><INPUT TYPE=CHECKBOX NAME="v1" VALUE="on" SIZE=2></TD>
  392.  
  393. <TD>
  394.  
  395. <INPUT TYPE=SUBMIT NAME="full" VALUE="Go"
  396.  
  397. SIZE=2>
  398.  
  399. </TD>
  400.  
  401. </TR>
  402. <TR>
  403. <TD> LAYER INDIA</TD>
  404.  
  405. </TR>
  406. <tr>
  407. <td>
  408. search
  409. </td>
  410. <TD>
  411.  
  412. <INPUT TYPE=TEXT NAME="srch" SIZE=10>
  413.  
  414. </TD>
  415.  
  416. </tr>
  417.  
  418. </TABLE>
  419.  
  420. <INPUT TYPE=HIDDEN NAME="extent" VALUE="<?php echo $extent_to_html?>">
  421.  
  422. </FORM>
  423.  
  424. </CENTER>
  425.  
  426. </BODY>
  427.  
  428. </HMTL>
Add Comment
Please, Sign In to add comment