Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Content Wrapper. Contains page content -->
- <script src="c3.min.js"> </script>
- <link href="c3.min.css" rel="stylesheet" />
- <script src="d3.min.js"></script>
- <section class="content">
- <div class="row">
- <div class="col-md-3">
- <div class="box box-warning">
- <div class="box-header with-border">
- <h3 class="box-title">Multi-layer Analysis</h3>
- </div>
- <!-- select -->
- <div class="form-group">
- <label>Admin Boundries </label>
- <select id="adminselect" class="form-control" onchange="loadgeojson(this);">
- <option>Select Admin Boundries</option>
- <option value="dist">District</option>
- <option value="vill">village</option>
- <option value="aptaluk50soi2001">taluk</option>
- </select>
- </div>
- <div class="form-group">
- <label>Thematic Layer </label>
- <select id="thematic" class="form-control" onchange="loadthematic(this);">
- <option>Select Thematic Layer</option>
- <option>Forest Area</option>
- <option>Land Use Land Cover</option>
- </select>
- </div>
- <div class="form-group">
- <label>Disaster Type</label>
- <select id="dict" class="form-control" onchange="loadyear();">
- <option>Select disaster</option>
- <option value="Flood">Flood</option>
- <option value="Drought">Drought</option>
- <option value="Cyclone">Cyclone</option>
- <option value="Forest Fire">Forest Fire</option>
- <option value="Forest Fire Hotspot">Forest Fire Hotspot</option>
- </select>
- </div>
- <div class="form-group">
- <label>Year</label>
- <select id="year" class="form-control" onchange="loaddis();">
- <option value="">Select Year</option>
- </select>
- </div>
- <div class="form-group">
- <label>Disaster</label>
- <select id="disaster" class="form-control" onchange="loadflood(this.value);">
- <option>Select Disaster</option>
- </select>
- </div>
- <div id="lyranatable" style=" max-height:250px; text-align:justify;" class="scrollbar"/>
- <div style="border:solid;">
- <b> Geospatial Dataset at 1:50000 scale for all 36 States/UTs </b>
- <div id="scalewise"/>
- </div>
- </div>
- </div>
- <div class="col-md-9">
- <div id="map"/>
- </div>
- </div>
- </section>
- <script>
- function addinteraction() {
- //map.addInteraction(draw_inter);
- }
- function drawaoi(a){
- if(a.checked){
- map.addInteraction(draw_inter);
- }
- else {
- map.removeInteraction(draw_inter);
- }
- }
- style_g = new ol.style.Style({
- fill: new ol.style.Fill({
- color: 'rgba(255, 255, 255, 0.3)'
- }),
- stroke: new ol.style.Stroke({
- color: 'rgba(255, 120, 0, 0.6)',
- width: 1
- })
- });
- styles_g = [style_g];
- olParser = new jsts.io.olParser();
- var poly2 = olParser.read(feature.getGeometry());
- var xmlhttp;
- searchstyles = {
- 'MultiPolygon': [new ol.style.Style({
- fill: new ol.style.Fill({
- color: 'rgba(255,255,0,0.5)'
- }),
- stroke: new ol.style.Stroke({
- color: '#ff0000',
- width: 3
- }),
- })]
- };
- stylesearch = function(feature, resolution) {
- return searchstyles[feature.getGeometry().getType()];
- };
- jsontalukgeom_layer = new ol.layer.Vector({
- source: jsontaluk,
- style: styles_g
- });
- function loadgeojson(b) {
- var adsel = document.getElementById("adminselect").value;
- alert(adsel);
- if( window.XMLHttpRequest )
- {// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp = new XMLHttpRequest();
- }
- else
- {// code for IE6, IE5
- xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
- }
- xmlhttp.onreadystatechange = function( )
- {
- if( xmlhttp.readyState == 4 && xmlhttp.status == 200 )
- { jsontaluk.clear();
- var allgeojson=xmlhttp.responseText;
- alert(allgeojson);
- var test= JSON.parse(allgeojson);
- alert("test "+test);
- //var response = jQuery.parseJSON(allgeojson);
- //alert(response);
- var res = new Array(response);
- alert("response "+res);
- jsontaluk.addFeatures(jsontaluk.getFormat().readFeatures(allgeojson));
- map.getView().setCenter(allgeojson);
- map.getView().setZoom(7);
- }
- }
- var url = "inc/loadgeojson.inc.php";
- url=url+"?val="+adsel;
- //url=url+"&col="+adsel[1];
- // url=url+"&table="+adsel[2];
- //url=url+"&schema="+adsel[3];
- xmlhttp.open( "POST", url, true );
- xmlhttp.send();
- map.addInteraction(draw_inter);
- }
- }
- </script>
- <?php
- $dias=$_POST["adsel"];
- echo $adsel;
- $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";
- $result = pg_query($db,$data_query);
- while($row_p=pg_fetch_row($result)) {
- $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;
- echo json_encode($lat_lon);
- pg_close($db);
- ?>
- `jsontaluk.addFeatures(jsontaluk.getFormat().readFeatures(allgeojson));`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement