| tukun wrote: | | tukun wrote: | | tukun2009manit wrote: | | tukun2009manit wrote: | | tukun2009manit wrote: | | tukun2009manit wrote: | Introduction:-
To develop a Rain Information System.
To develop a River Information System.
To develop a simple Flood Model System depending on Rain & River Information System.
Software Requirements:-
PostgreSQL (database)
PostGIS (plugin to the database)
GeoServer (server)
Google Maps (google map api’s)
Netbeans with Apache tomcat & java enabled (programming platform)
Note:- all of this software can be easily downloaded from its official website I have also shared it in uhuroo.com for easily.
Rain information System:-
Tables used in this project :-
Raindata(sid,day,rainfall,gid)
Locdata(gid,long,lat,the_geom) |
River Information System
Tables used in this project :-
Rivers10(gid,name,river_geom)
Geoserver :-
For creating a new data store.
setting of geoserver with postgis is provided in a html file please refer it for creating a new data store.
To get this feature on the map use this java script code:-
Algorithms used in Rainfall Information System
It’s a simple logic if rainfall is greater than 0 & less than 10 show marker green at that location.
var temp=0;
for(var count=0;count<1109;count++){
temp=count+1;
if(rain2[temp]>0){
if(rain2[temp]<=10){
var latlng =new GLatLng(lat[temp],lon[temp]);
map.addOverlay(createMarker1(latlng,temp));
}
else if(rain2[temp]>10 && rain2[temp]<=60){
var latlng =new GLatLng(lat[temp],lon[temp]);
map.addOverlay(createMarker2(latlng,temp));
}
else if(rain2[temp]>60){
var latlng =new GLatLng(lat[temp],lon[temp]);
map.addOverlay(createMarker3(latlng,temp));
}
}
}
Query used to show the rainfall on a particular day in this project.
select * from locdata,(select * from raindata where day='jan 9,2001') as rain where locdata.gid=rain.gid
note:-this query is used in user.java file in the source code |
|
|
sorce code for flood
package user2;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Abhijeet
*/
import java.sql.*;
public class UserData2 {
int r1, r2;
Statement st = null;
ResultSet rs = null;
float sum1 = 0, avg1 = 0;
float sum2 = 0, avg2 = 0;
float[] deltaH = new float[11];
String day2 = null;
boolean b = false;
float lon[] = new float[11];
float lat[] = new float[11];
public void connectDemo() throws SQLException {
System.out.println("Checking if Driver is registered with DriverManager.");
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.out.println("Couldn't find the driver!");
System.out.println("Let's print a stack trace, and exit.");
cnfe.printStackTrace();
System.exit(1);
}
System.out.println("Registered the driver ok, so let's make a connection.");
Connection c = null;
try {
// The second and third arguments are the username and password,
// respectively. They should be whatever is necessary to connect
// to the database.
c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test2",
"postgres", "gis12");
} catch (SQLException se) {
System.out.println("Couldn't connect: print out a stack trace and exit.");
se.printStackTrace();
System.exit(1);
}
st = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
for (int i = 0; i <= 10; i++) {
System.out.println("round " + i);
rs = st.executeQuery("select * from raindata,( select * from locdata,(SELECT ST_x(ST_Line_Interpolate_Point(rivers_geom, " + (float) (i * 0.1) + ")),ST_y(ST_Line_Interpolate_Point(rivers_geom, " + (float) (i * 0.1) + ")) from rivers10) as foo where ST_Point_Inside_Circle(the_geom, foo.st_x, foo.st_y, 1)=true) as foo2 where day=date '" + day2 + "' - integer '1' and rainfall>0 and raindata.gid=foo2.gid;");
while (rs.next()) {
sum1 = sum1 + rs.getFloat(3);
if (b == false) {
lon[i] = rs.getFloat(9);
lat[i] = rs.getFloat(10);
System.out.println("longitude =" + lon[i]);
System.out.println("latitude =" + lat[i]);
}
b = true;
}
rs.afterLast();
rs.previous();
r1 = rs.getRow();
System.out.println("no of rows here =" + rs.getRow());
avg1 = sum1 / r1;
System.out.println("avg1=" + avg1);
System.out.println(sum1);
rs = st.executeQuery("select * from raindata,( select * from locdata,(SELECT ST_x(ST_Line_Interpolate_Point(rivers_geom, " + (float) (i * 0.1) + ")),ST_y(ST_Line_Interpolate_Point(rivers_geom, " + (float) (i * 0.1) + ")) from rivers10) as foo where ST_Point_Inside_Circle(the_geom, foo.st_x, foo.st_y, 1)=true) as foo2 where day=date '" + day2 + "' - integer '2' and rainfall>0 and raindata.gid=foo2.gid;");
while (rs.next()) {
sum2 = sum2 + rs.getFloat(3);
}
rs.afterLast();
rs.previous();
r2=rs.getRow();
System.out.println("no of rows here ="+rs.getRow());
avg2=sum2/r2;
System.out.println(sum2);
deltaH[i] = (float) (0.6 * avg1 + 0.4 * avg2);
System.out.println(deltaH[i]);
sum1 = 0;
sum2 = 0;
b = false;
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
String username;
String email;
int age;
public void setUsername(String value) {
username = value;
}
public void setEmail(String value) {
email = value;
}
public void setAge(int value) {
age = value;
}
public void setDay2(String value) {
day2 = value;
}
public String getUsername() {
return username;
}
public String getEmail() {
return email;
}
public int getAge() {
return age;
}
public float[] getDeltaH() {
return deltaH;
}
public float[] getLon() {
return lon;
}
public float[] getLat() {
return lat;
}
} |
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><link rel="stylesheet" type="text/css" href="ex2.css" />
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2 style="text-align:center">
<a href="index.jsp">Home</a>
<a href="help.jsp">Help/FAQ</a></h2>
<h2 style="text-align:center">This projects provide rainfall analysis on the google map for india. along with these,this project construct the river ganga and tried to examine the rise in water level due the the rainfall. </h2>
<a href="http://localhost:8080/geoserver/wms?bbox=67.075,6.65,98.425,36.35&styles=&Format=application/openlayers&request=GetMap&version=1.1.1&layers=topp:india2&width=800&height=711&srs=EPSG:4326" target="_blank"> <img src="rain.jpg" width="400" height="300" alt="rain"/></a>
<a href="river.jsp"> <img src="river.jpg" width="400" height="300" alt="river"/></a>
<a href="http://localhost:8080/geoserver/wms?bbox=77.50433063507077,24.358221442296696,88.57547664642334,30.409652035973405&styles=&Format=application/openlayers&request=GetMap&version=1.1.1&layers=topp:rivers10&width=800&height=410&srs=EPSG:4326" target="_blank"> <img src="flood.jpg" width="400" height="300" alt="flood"/></a>
<form action="SaveName.jsp">Enter the date in date type format,to view to rain data:<input type="text" name="day1" value="" /><input type="submit" value="submitt" /></form>
<form action="SaveName2.jsp">Enter the date in date type format to get raise in water level:<input type="text" name="day2" value="" /><input type="submit" value="submitt" /></form>
<p>note:- date type format implies mmddyy format for eg:- jan 9,2001 or january 9,2001 or 1/9/01 or 1-9-01 etc are valid,to get rain & water level information, entering jan 9,2001 and click submitt button then continue this will show rainfall in 9th of january of 2001.<p>
<p>note:- the database contains rainfall data of year 2001 so, rainfall data for the year 2001 is only available now</p>
</body>
</html> |
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="ex2.css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps with GeoWebCache</title>
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7uRTWxvISQoTUJPuTxW9gRQxny6npzr3gA2BlEj2uSZQZL2GchTHxEUbx0ZrTWw-dmUNBRK-ELHzvQ'></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(28, 77), 4);
var tilelayer = new GTileLayer(null, null, null, {
tileUrlTemplate: 'http://localhost:8080/geoserver/gwc/service/gmaps?layers=topp:rivers10&zoom={Z}&x={X}&y={Y}',
isPng:true,
opacity:0.5 }
);
var myTileLayer = new GTileLayerOverlay(tilelayer);
map.addOverlay(myTileLayer);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<h2 style="text-align:center">
<a href="index.jsp">Home</a>
<a href="help.jsp">Help/FAQ</a></h2>
<div id="map_canvas" style="width: 1200px; height: 500px"></div>
</body>
</html> |