Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
- $data_query = "SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features";
- $data_query .= " FROM (SELECT 'Feature' As type";
- $data_query .= ", ST_AsGeoJSON(lg.geom)::json As geometry";
- $data_query .= ", row_to_json((SELECT l FROM (SELECT taluk) As l";
- $data_query .=" )) As properties";
- $data_query .= " FROM s50k.aptaluk50soi2001 As lg ) As f ) As fc";
- $data = pg_query($db,$data_query);
- while ($row_p = pg_fetch_row($data) )
- {
- $count = count($row_p);
- $y = 0;
- while ($y < $count)
- {
- $c_row = current($row_p);
- $lat_lon.= $c_row . ",";
- next($row_p);
- $y = $y + 1;
- }
- }
- echo $lat_lon;
- ?>
- <?php
- $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
- $mapa = "SELECT geom FROM s50d.aptirupatiff50dsc01042014";
- $dbquery = pg_query($db,$mapa);
- //echo("hello");
- $geojson = array( 'type' => 'FeatureCollection', 'features' => array());
- while($row = pg_fetch_array($dbquery)){
- $marker = array(
- 'type' => 'Feature',
- 'features' => array(
- 'type' => 'Feature',
- 'properties' => array(
- 'gid' => "serial"
- )
- )
- );
- array_push($geojson['features'], $marker['features']);
- }
- ?>
- <?php
- $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
- $data_query = "select st_x(st_centroid(geom)) as long,st_y(st_centroid(geom)) as lat,taluk FROM s50k.aptaluk50soi2001";
- //$data_query = "SELECT ";
- //$data_query .= " ST_AsGeoJSON(lg.geom)::json As geometry";
- //$data_query .= ", row_to_json((SELECT l FROM (SELECT taluk) As l";
- //$data_query .=" )) As properties";
- //$data_query .= " FROM s50k.aptaluk50soi2001 As lg ";
- $data = pg_query($db,$data_query);
- $geojson = array(
- 'type' => 'FeatureCollection',
- 'features' => array()
- );
- // while ($row_p = pg_fetch_row($data) )
- while($edge=pg_fetch_assoc($data)) {
- $feature = array(
- 'type' => 'Feature',
- 'geometry' => array('type'=>$edge['lat'],
- 'coordinates'=>$edge['long']),
- 'crs' => array(
- 'type' => 'lat',
- 'properties' => $edge['taluk']
- ),
- 'properties' => array(
- 'taluk' => $edge['taluk']
- )
- );
- array_push($geojson['features'], $feature);
- }
- echo json_encode(array( $geojson));
- //"{"type":"Feature","geometry":{"type":"Point","coordinates":[83.15783,17.6501960000001]},"properties":{"poi_nme":"Shree Latha Medicals"}}"
- ?>
- <?php
- $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
- $data_query = "select ST_AsGeoJSON(lg.geom)::json As geometry , row_to_json((SELECT l FROM (SELECT taluk) As l )) As properties FROM s50k.aptaluk50soi2001 As lg ";
- //$data_query = "SELECT ";
- //$data_query .= " ST_AsGeoJSON(lg.geom)::json As geometry";
- //$data_query .= ", row_to_json((SELECT l FROM (SELECT taluk) As l";
- //$data_query .=" )) As properties";
- //$data_query .= " FROM s50k.aptaluk50soi2001 As lg ";
- $data = pg_query($db,$data_query);
- $geojson = array(
- 'type' => 'FeatureCollection',
- 'features' => array()
- );
- // while ($row_p = pg_fetch_row($data) )
- while($edge=pg_fetch_assoc($data)) {
- $feature = array(
- 'type' => 'Feature',
- 'geometry' => array( 'type' => 'MultiPolygon',
- 'coordinates'=>$edge['geometry']),
- 'properties' => array(
- 'taluk' => $edge['properties']
- )
- );
- array_push($geojson['features'], $feature);
- }
- echo json_encode(array( $geojson));
- //"{"type":"Feature","geometry":{"type":"Point","coordinates":[83.15783,17.6501960000001]},"properties":{"poi_nme":"Shree Latha Medicals"}}"
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement