FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


gis application development basic problems i faced and soln





tukun2009manit
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}
tukun2009manit
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}





to get the database entries the following code i used
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes8 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
Statement st2 = null;
ResultSet rs2 = null;
String str=null;
int len=0;
StringBuffer sbr=new StringBuffer();

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;
Connection c2 = 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");
c2 = 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);
st2 = c2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

rs=st.executeQuery("select * from rivers5");

while(rs.next()){
sbr.append(rs.getDouble(2));
sbr.append(" ");
sbr.append(rs.getDouble(3));
sbr.append(',');
}
len=sbr.length();
sbr.deleteCharAt(len-1);
str=new String(sbr);
System.out.println(str);

st2.executeUpdate("insert into rivers8(name,rivers_geom) values ('ganga',GeomFromText('LINESTRING("+str+")',-1))");

/*FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}*/
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}
tukun2009manit
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}




the rain data which was given to me was not normailsed and the coloumn were not in appropriate form to use then i used:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package demogis2;

import java.sql.*;

/**
*
* @author Abhijeet
*/
public class Example2 {

public static void main(String[] argv) throws SQLException {
Statement st = null;
ResultSet rs = null;
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/template_postgis",
"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);

// sql Query editing part
for (int i = 1; i <= 31; i++) {
st.executeUpdate("insert into india2(gid,long,lat,rainfall,day) select gid,long,lat,dec" + i + ",'dec" + i + "' from final;");
}

// st.executeUpdate("insert into india2(gid,long,lat,rainfall,day) select gid,long,lat,jan16,'jan16' from final;");





/* PreparedStatement ps=c.prepareStatement("UPDATE SET day=? WHERE gid=6;");

ps.setString(4,"jan1");
ps.executeUpdate();*/
/*while (rs.next()) {
System.out.println(rs.getString(1));

}*/

if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}

}
}
tukun2009manit
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}



Flood Information System
• Flood Information System contains no data. It’s a Flood Model System which determine the rise in water level of river Ganga due to the rainfall in near by areas
• This is a simple model which first determines the catchment area.
• Then it calculates the water runoff in that catchment area due to previous two days rain.
• Runoff1 of previous day=k1*avg(CA)
• K1 is a constant it is taken 0.6 here which implies 60% of previous day rainwater is contributing to water runoff.
• CA is the catchment area
• Avg() is a function which returns the average rainfall of that catchment area supplied to it as an argument.
• Similarly, runoff2 for day before previous day is calculated where k1 is modified to k2 whose value is 0.4
• So, rise in river water level due to rainfall is given by:-
• deltaH=runoff1+runoff2
tukun2009manit
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}


1 West Bengal, India 24.633286469281973 88.0722427368164
2 West Bengal, India 24.666362395374456 87.97576904296875
3 West Bengal, India 24.728434081751406 87.94212341308594
4 West Bengal, India 24.798890012311823 87.93182373046875
5 West Bengal, India 24.85341911589439 87.94109344482422
6 West Bengal, India 24.93003081950919 87.9510498046875
7 West Bengal, India 24.96427269508287 87.96134948730469
8 West Bengal, India 25.030861410390447 87.92701721191406
9 West Bengal, India 25.057922201071634 87.85491943359375
10 West Bengal, India 25.087153582038205 87.80204772949219
11 West Bengal, India 25.226994247868138 87.77217864990234
12 Bihar, India 25.3015103024096 87.67570495605469
13 Bihar, India 25.323545863751555 87.60292053222656
14 Bihar, India 25.375049976549434 87.56893157958984
15 Bhagalpur, Bihar, India 25.46342450201376 87.35607147216797
16 Bhagalpur, Bihar, India 25.456914906486638 87.30388641357422
17 Bhagalpur, Bihar, India 25.419090293821867 87.27607727050781
18 Bhagalpur, Bihar, India 25.378151933303407 87.26028442382812
19 Bhagalpur, Bihar, India 25.285369039259916 87.2369384765625
20 Bhagalpur, Bihar, India 25.265810400113477 87.21874237060547
21 Bhagalpur, Bihar, India 25.289094136859557 87.12776184082031
22 Bhagalpur, Bihar, India 25.27357214213373 87.02991485595703
23 Bhagalpur, Bihar, India 25.3095801280391 86.96880340576172
24 Bhagalpur, Bihar, India 25.323545863751555 86.92760467529297
25 Bhagalpur, Bihar, India 25.3095801280391 86.85722351074219
26 Bhagalpur, Bihar, India 25.258669159128353 86.72710418701172
27 Bhagalpur, Bihar, India 25.25494312754165 86.65328979492188
28 Bhagalpur, Bihar, India 25.28195426595429 86.61243438720703
29 Khagaria, Bihar, India 25.352713536927975 86.5726089477539
30 Khagaria, Bihar, India 25.453814975335398 86.58393859863281
31 Khagaria, Bihar, India 25.47272331328369 86.55681610107422
32 Khagaria, Bihar, India 25.46373447396954 86.52935028076172
33 Khagaria, Bihar, India 25.447614873538274 86.51012420654297
34 Bihar, India 25.4293227132482 86.49295806884766
35 Bihar, India 25.3502314555209 86.39030456542969
36 Bihar, India 25.31764941620598 86.36661529541016
37 Bihar, India 25.313304481678177 86.31202697753906
38 Bihar, India 25.337199692429877 86.26876831054688
39 Bihar, India 25.329131707091477 86.09539031982422
40 Nalanda, Bihar, India 25.341233483398934 86.03702545166016
41 Patna, Bihar, India 25.456294926643434 85.9075927734375
42 Patna, Bihar, India 25.508981806494198 85.81249237060547
43 Samastipur, Bihar, India 25.519206582498544 85.7314682006836
44 Samastipur, Bihar, India 25.49224847673754 85.66108703613281
45 Vaishali, Bihar, India 25.550495180470026 85.55706024169922
46 Vaishali, Bihar, India 25.576201480190047 85.53852081298828
47 Vaishali, Bihar, India 25.585801212943935 85.46367645263672
48 Vaishali, Bihar, India 25.617381993929506 85.33733367919922
49 Vaishali, Bihar, India 25.638431212648157 85.286865234375
50 Vaishali, Bihar, India 25.609332783044383 85.24772644042969
51 Patna, Bihar, India 25.606546391440727 85.2267837524414
52 Bihar, India 25.65266828598998 85.13031005859375
53 Patna, Bihar, India 25.659476720597404 85.0887680053711
54 Patna, Bihar, India 25.644930956827828 85.05443572998047
55 Patna, Bihar, India 25.64833544346951 85.01941680908203
56 Bihar, India 25.672473561951584 84.97787475585938
57 Bihar, India 25.67433013791529 84.92019653320312
58 Bihar, India 25.709908919785647 84.87556457519531
59 Saran, Bihar, India 25.743312353835837 84.78527069091797
tukun2009manit
tukun2009manit wrote:
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}





to get the database entries the following code i used
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes8 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
Statement st2 = null;
ResultSet rs2 = null;
String str=null;
int len=0;
StringBuffer sbr=new StringBuffer();

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;
Connection c2 = 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");
c2 = 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);
st2 = c2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

rs=st.executeQuery("select * from rivers5");

while(rs.next()){
sbr.append(rs.getDouble(2));
sbr.append(" ");
sbr.append(rs.getDouble(3));
sbr.append(',');
}
len=sbr.length();
sbr.deleteCharAt(len-1);
str=new String(sbr);
System.out.println(str);

st2.executeUpdate("insert into rivers8(name,rivers_geom) values ('ganga',GeomFromText('LINESTRING("+str+")',-1))");

/*FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}*/
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}


1 Saran, Bihar, India 25.741766105738137 84.77806091308594
2 Bihar, India 25.7331067445897 84.65034484863281
3 Bihar, India 25.728776827446488 84.63043212890625
4 Bihar, India 25.661952418647065 84.53842163085938
5 Bihar, India 25.717023400382306 84.44778442382812
6 Bihar, India 25.71516748993636 84.45053100585938
7 Bihar, India 25.755990829182867 84.40589904785156
8 Bihar, India 25.770832202467577 84.38255310058594
9 Bihar, India 25.762793355586624 84.36607360839844
10 Bihar, India 25.741147600865283 84.35783386230469
11 Bihar, India 25.71331155053841 84.33792114257812
12 Bihar, India 25.70588750345636 84.29466247558594
13 Bihar, India 25.70155659545103 84.23011779785156
14 Bihar, India 25.720735134412106 84.19921875
15 Bihar, India 25.72011652011695 84.122314453125
16 Bihar, India 25.692275547735274 84.07768249511719
17 Bihar, India 25.632240651069274 84.03305053710938
18 Buxar, Bihar, India 25.597567576737394 83.99734497070312
19 Buxar, Bihar, India 25.550495180470026 83.91563415527344
20 Buxar, Bihar, India 25.523234285429442 83.902587890625
21 Bihar, India 25.517657429994035 83.84937286376953
22 Bihar, India 25.510531070956958 83.80611419677734
23 Uttar Pradesh, India 25.536245940157283 83.78173828125
24 Ghazipur, Uttar Pradesh, India 25.598496450902395 83.71788024902344
25 Ghazipur, Uttar Pradesh, India 25.610880750315395 83.67084503173828
26 Ghazipur lanka, Uttar Pradesh, India 25.586420524099665 83.60973358154297
27 Ghazipur, Uttar Pradesh, India 25.550185432385575 83.55960845947266
28 Ghazipur, Uttar Pradesh, India 25.483261096987896 83.51531982421875
29 Ghazipur, Uttar Pradesh, India 25.411337882684343 83.5506820678711
30 Ghazipur, Uttar Pradesh, India 25.3970721441564 83.54965209960938
31 Ghazipur, Uttar Pradesh, India 25.392109752773724 83.5400390625
32 Ghazipur, Uttar Pradesh, India 25.395521418766915 83.52149963378906
33 Uttar Pradesh, India 25.48852964248856 83.4085464477539
34 Uttar Pradesh, India 25.49255837439694 83.3807373046875
35 Uttar Pradesh, India 25.47272331328369 83.32855224609375
36 Uttar Pradesh, India 25.517347597093757 83.26160430908203
37 Uttar Pradesh, India 25.532838262237156 83.19568634033203
38 Uttar Pradesh, India 25.493178167318078 83.16547393798828
39 Uttar Pradesh, India 25.4587748268542 83.13526153564453
40 Uttar Pradesh, India 25.434593620577097 83.1441879272461
41 Uttar Pradesh, India 25.419400379899944 83.18195343017578
42 Uttar Pradesh, India 25.3688458240828 83.17611694335938
43 Uttar Pradesh, India 25.326028492609215 83.13629150390625
44 Uttar Pradesh, India 25.33130390989676 83.06694030761719
45 Varanasi, Uttar Pradesh, India 25.313304481678177 83.01921844482422
46 Varanasi, Uttar Pradesh, India 25.301199913769096 83.00994873046875
47 Varanasi, Uttar Pradesh, India 25.274813974793805 83.01681518554688
48 Uttar Pradesh, India 25.243453810607868 83.03054809570312
49 Mirzapur, Uttar Pradesh, India 25.2142598500695 83.01441192626953
50 Mirzapur, Uttar Pradesh, India 25.20649431919982 82.9412841796875
51 Mirzapur, Uttar Pradesh, India 25.198106989381813 82.90695190429688
52 Mirzapur, Uttar Pradesh, India 25.14746010148844 82.88394927978516
53 Mirzapur, Uttar Pradesh, India 25.118553988557046 82.86163330078125
54 Mirzapur, Uttar Pradesh, India 25.111404109921363 82.83451080322266
55 Mirzapur, Uttar Pradesh, India 25.128500949960017 82.77202606201172
56 Mirzapur, Uttar Pradesh, India 25.18288406340071 82.69615173339844
57 Mirzapur, Uttar Pradesh, India 25.227925980729097 82.62611389160156
58 Mirzapur, Uttar Pradesh, India 25.227615403901964 82.5893783569336
59 Mirzapur, Uttar Pradesh, India 25.216744715292 82.56534576416016
60 Mirzapur, Uttar Pradesh, India 25.179155709929145 82.59281158447266
61 Mirzapur, Uttar Pradesh, India 25.16517336866393 82.5900650024414
62 Mirzapur, Uttar Pradesh, India 25.155540156389435 82.56328582763672
63 Mirzapur, Uttar Pradesh, India 25.160512231916684 82.52792358398438
64 Uttar Pradesh, India 25.18288406340071 82.47848510742188
65 Uttar Pradesh, India 25.21891893073226 82.45719909667969
66 Uttar Pradesh, India 25.253701091610008 82.38887786865234
67 Uttar Pradesh, India 25.22854713200372 82.3641586303711
68 Uttar Pradesh, India 25.21519168047479 82.34115600585938
69 Uttar Pradesh, India 25.267052312190323 82.30167388916016
70 Uttar Pradesh, India 25.26829421156167 82.26940155029297
71 Uttar Pradesh, India 25.233205665424844 82.24983215332031
72 Uttar Pradesh, India 25.20494115356912 82.27043151855469
73 Uttar Pradesh, India 25.197796336440597 82.28553771972656
74 Uttar Pradesh, India 25.186301620540558 82.276611328125
75 Uttar Pradesh, India 25.176980784396388 82.23987579345703
76 Uttar Pradesh, India 25.185680253645064 82.20691680908203
77 Uttar Pradesh, India 25.23506902881547 82.20279693603516
78 Uttar Pradesh, India 25.280091621816336 82.2216796875
79 Uttar Pradesh, India 25.303062233688735 82.20691680908203
80 Uttar Pradesh, India 25.312994123248057 82.1725845336914
81 Uttar Pradesh, India 25.278539396522223 82.11868286132812
82 Uttar Pradesh, India 25.272330296765784 82.09636688232422
83 Uttar Pradesh, India 25.290335810632964 82.0785140991211
84 Uttar Pradesh, India 25.32385619514266 82.07542419433594
85 Uttar Pradesh, India 25.350541718482802 82.01946258544922
86 Uttar Pradesh, India 25.339061458818374 81.97345733642578
87 Allahabad, Uttar Pradesh, India 25.424361648676022 81.88522338867188
88 Allahabad, Uttar Pradesh, India 25.425912003292144 81.85741424560547
89 Allahabad, Uttar Pradesh, India 25.413508608042285 81.82273864746094
tukun2009manit
tukun2009manit wrote:
tukun2009manit wrote:
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}





to get the database entries the following code i used
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes8 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
Statement st2 = null;
ResultSet rs2 = null;
String str=null;
int len=0;
StringBuffer sbr=new StringBuffer();

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;
Connection c2 = 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");
c2 = 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);
st2 = c2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

rs=st.executeQuery("select * from rivers5");

while(rs.next()){
sbr.append(rs.getDouble(2));
sbr.append(" ");
sbr.append(rs.getDouble(3));
sbr.append(',');
}
len=sbr.length();
sbr.deleteCharAt(len-1);
str=new String(sbr);
System.out.println(str);

st2.executeUpdate("insert into rivers8(name,rivers_geom) values ('ganga',GeomFromText('LINESTRING("+str+")',-1))");

/*FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}*/
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}


1 Saran, Bihar, India 25.741766105738137 84.77806091308594
2 Bihar, India 25.7331067445897 84.65034484863281
3 Bihar, India 25.728776827446488 84.63043212890625
4 Bihar, India 25.661952418647065 84.53842163085938
5 Bihar, India 25.717023400382306 84.44778442382812
6 Bihar, India 25.71516748993636 84.45053100585938
7 Bihar, India 25.755990829182867 84.40589904785156
8 Bihar, India 25.770832202467577 84.38255310058594
9 Bihar, India 25.762793355586624 84.36607360839844
10 Bihar, India 25.741147600865283 84.35783386230469
11 Bihar, India 25.71331155053841 84.33792114257812
12 Bihar, India 25.70588750345636 84.29466247558594
13 Bihar, India 25.70155659545103 84.23011779785156
14 Bihar, India 25.720735134412106 84.19921875
15 Bihar, India 25.72011652011695 84.122314453125
16 Bihar, India 25.692275547735274 84.07768249511719
17 Bihar, India 25.632240651069274 84.03305053710938
18 Buxar, Bihar, India 25.597567576737394 83.99734497070312
19 Buxar, Bihar, India 25.550495180470026 83.91563415527344
20 Buxar, Bihar, India 25.523234285429442 83.902587890625
21 Bihar, India 25.517657429994035 83.84937286376953
22 Bihar, India 25.510531070956958 83.80611419677734
23 Uttar Pradesh, India 25.536245940157283 83.78173828125
24 Ghazipur, Uttar Pradesh, India 25.598496450902395 83.71788024902344
25 Ghazipur, Uttar Pradesh, India 25.610880750315395 83.67084503173828
26 Ghazipur lanka, Uttar Pradesh, India 25.586420524099665 83.60973358154297
27 Ghazipur, Uttar Pradesh, India 25.550185432385575 83.55960845947266
28 Ghazipur, Uttar Pradesh, India 25.483261096987896 83.51531982421875
29 Ghazipur, Uttar Pradesh, India 25.411337882684343 83.5506820678711
30 Ghazipur, Uttar Pradesh, India 25.3970721441564 83.54965209960938
31 Ghazipur, Uttar Pradesh, India 25.392109752773724 83.5400390625
32 Ghazipur, Uttar Pradesh, India 25.395521418766915 83.52149963378906
33 Uttar Pradesh, India 25.48852964248856 83.4085464477539
34 Uttar Pradesh, India 25.49255837439694 83.3807373046875
35 Uttar Pradesh, India 25.47272331328369 83.32855224609375
36 Uttar Pradesh, India 25.517347597093757 83.26160430908203
37 Uttar Pradesh, India 25.532838262237156 83.19568634033203
38 Uttar Pradesh, India 25.493178167318078 83.16547393798828
39 Uttar Pradesh, India 25.4587748268542 83.13526153564453
40 Uttar Pradesh, India 25.434593620577097 83.1441879272461
41 Uttar Pradesh, India 25.419400379899944 83.18195343017578
42 Uttar Pradesh, India 25.3688458240828 83.17611694335938
43 Uttar Pradesh, India 25.326028492609215 83.13629150390625
44 Uttar Pradesh, India 25.33130390989676 83.06694030761719
45 Varanasi, Uttar Pradesh, India 25.313304481678177 83.01921844482422
46 Varanasi, Uttar Pradesh, India 25.301199913769096 83.00994873046875
47 Varanasi, Uttar Pradesh, India 25.274813974793805 83.01681518554688
48 Uttar Pradesh, India 25.243453810607868 83.03054809570312
49 Mirzapur, Uttar Pradesh, India 25.2142598500695 83.01441192626953
50 Mirzapur, Uttar Pradesh, India 25.20649431919982 82.9412841796875
51 Mirzapur, Uttar Pradesh, India 25.198106989381813 82.90695190429688
52 Mirzapur, Uttar Pradesh, India 25.14746010148844 82.88394927978516
53 Mirzapur, Uttar Pradesh, India 25.118553988557046 82.86163330078125
54 Mirzapur, Uttar Pradesh, India 25.111404109921363 82.83451080322266
55 Mirzapur, Uttar Pradesh, India 25.128500949960017 82.77202606201172
56 Mirzapur, Uttar Pradesh, India 25.18288406340071 82.69615173339844
57 Mirzapur, Uttar Pradesh, India 25.227925980729097 82.62611389160156
58 Mirzapur, Uttar Pradesh, India 25.227615403901964 82.5893783569336
59 Mirzapur, Uttar Pradesh, India 25.216744715292 82.56534576416016
60 Mirzapur, Uttar Pradesh, India 25.179155709929145 82.59281158447266
61 Mirzapur, Uttar Pradesh, India 25.16517336866393 82.5900650024414
62 Mirzapur, Uttar Pradesh, India 25.155540156389435 82.56328582763672
63 Mirzapur, Uttar Pradesh, India 25.160512231916684 82.52792358398438
64 Uttar Pradesh, India 25.18288406340071 82.47848510742188
65 Uttar Pradesh, India 25.21891893073226 82.45719909667969
66 Uttar Pradesh, India 25.253701091610008 82.38887786865234
67 Uttar Pradesh, India 25.22854713200372 82.3641586303711
68 Uttar Pradesh, India 25.21519168047479 82.34115600585938
69 Uttar Pradesh, India 25.267052312190323 82.30167388916016
70 Uttar Pradesh, India 25.26829421156167 82.26940155029297
71 Uttar Pradesh, India 25.233205665424844 82.24983215332031
72 Uttar Pradesh, India 25.20494115356912 82.27043151855469
73 Uttar Pradesh, India 25.197796336440597 82.28553771972656
74 Uttar Pradesh, India 25.186301620540558 82.276611328125
75 Uttar Pradesh, India 25.176980784396388 82.23987579345703
76 Uttar Pradesh, India 25.185680253645064 82.20691680908203
77 Uttar Pradesh, India 25.23506902881547 82.20279693603516
78 Uttar Pradesh, India 25.280091621816336 82.2216796875
79 Uttar Pradesh, India 25.303062233688735 82.20691680908203
80 Uttar Pradesh, India 25.312994123248057 82.1725845336914
81 Uttar Pradesh, India 25.278539396522223 82.11868286132812
82 Uttar Pradesh, India 25.272330296765784 82.09636688232422
83 Uttar Pradesh, India 25.290335810632964 82.0785140991211
84 Uttar Pradesh, India 25.32385619514266 82.07542419433594
85 Uttar Pradesh, India 25.350541718482802 82.01946258544922
86 Uttar Pradesh, India 25.339061458818374 81.97345733642578
87 Allahabad, Uttar Pradesh, India 25.424361648676022 81.88522338867188
88 Allahabad, Uttar Pradesh, India 25.425912003292144 81.85741424560547
89 Allahabad, Uttar Pradesh, India 25.413508608042285 81.82273864746094



1 Allahabad, Uttar Pradesh, India 25.424361648676022 81.8869400024414
2 Allahabad, Uttar Pradesh, India 25.505263490227456 81.87870025634766
3 Allahabad, Uttar Pradesh, India 25.505263490227456 81.87870025634766
4 Allahabad, Uttar Pradesh, India 25.498136395593473 81.83235168457031
5 Allahabad, Uttar Pradesh, India 25.500305556118665 81.79235458374023
6 Allahabad, Uttar Pradesh, India 25.495347417365963 81.78119659423828
7 Uttar Pradesh, India 25.484190857091647 81.77244186401367
8 Uttar Pradesh, India 25.481711480835024 81.7489242553711
9 Uttar Pradesh, India 25.510685996303767 81.72643661499023
10 Uttar Pradesh, India 25.512080315429166 81.71527862548828
11 Uttar Pradesh, India 25.519361496649243 81.66206359863281
12 Uttar Pradesh, India 25.556380241967133 81.64541244506836
13 Uttar Pradesh, India 25.587813962480492 81.63871765136719
14 Uttar Pradesh, India 25.593387553721257 81.60919189453125
15 Uttar Pradesh, India 25.575582116154415 81.5683364868164
16 Uttar Pradesh, India 25.589362208315652 81.54327392578125
17 Uttar Pradesh, India 25.620322916517196 81.51546478271484
18 Uttar Pradesh, India 25.62341854629987 81.49211883544922
19 Uttar Pradesh, India 25.654525170330572 81.43753051757812
20 Uttar Pradesh, India 25.684540788746894 81.40233993530273
21 Uttar Pradesh, India 25.693513062561056 81.37487411499023
22 Uttar Pradesh, India 25.71300222449074 81.37178421020508
23 Uttar Pradesh, India 25.751197906128706 81.40096664428711
24 Uttar Pradesh, India 25.77655181966642 81.38071060180664
25 Uttar Pradesh, India 25.792317985177014 81.34586334228516
26 Uttar Pradesh, India 25.821062654429706 81.31599426269531
27 Uttar Pradesh, India 25.8382134077492 81.28028869628906
28 Uttar Pradesh, India 25.855207197601576 81.2468147277832
29 Uttar Pradesh, India 25.88594430197154 81.2167739868164
30 Uttar Pradesh, India 25.93813270563573 81.21196746826172
31 Uttar Pradesh, India 25.958507702264097 81.17076873779297
32 Uttar Pradesh, India 25.980576635324983 81.09918594360352
33 Uttar Pradesh, India 26.054623875908952 81.02468490600586
34 Uttar Pradesh, India 26.072049034505245 81.0080337524414
35 Uttar Pradesh, India 26.0629512662096 80.9637451171875
36 Uttar Pradesh, India 26.055394955428767 80.87980270385742
37 Uttar Pradesh, India 26.027787148960627 80.83585739135742
38 Fatehpur, Uttar Pradesh, India 26.038584271784487 80.80530166625977
39 Uttar Pradesh, India 26.082225361502278 80.78521728515625
40 Fatehpur, Uttar Pradesh, India 26.079141719460367 80.71535110473633
41 Fatehpur, Uttar Pradesh, India 26.08962577094157 80.70608139038086
42 Fatehpur, Uttar Pradesh, India 26.10766230800967 80.70693969726562
43 Fatehpur, Uttar Pradesh, India 26.110436912971807 80.67895889282227
44 Fatehpur, Uttar Pradesh, India 26.109512051967805 80.67878723144531
45 Uttar Pradesh, India 26.12215118563835 80.66642761230469
46 Uttar Pradesh, India 26.181321125359712 80.64085006713867
47 Uttar Pradesh, India 26.226756806528435 80.58300018310547
48 Uttar Pradesh, India 26.304341448715537 80.54695129394531
49 Kanpur Nagar, Uttar Pradesh, India 26.378644699425063 80.49356460571289
50 Kanpur Nagar, Uttar Pradesh, India 26.4201598738645 80.42438507080078
51 Kanpur Nagar, Uttar Pradesh, India 26.47410726271528 80.37425994873047
52 Kanpur Nagar, Uttar Pradesh, India 26.483633804556618 80.35383224487305
53 Kanpur Nagar, Uttar Pradesh, India 26.483633804556618 80.35383224487305
54 Kanpur Nagar, Uttar Pradesh, India 26.493620460788808 80.33065795898438
55 Kanpur Nagar, Uttar Pradesh, India 26.51835290388326 80.31417846679688
56 Uttar Pradesh, India 26.547686969353208 80.31246185302734
57 Uttar Pradesh, India 26.610476562561598 80.27658462524414
58 Uttar Pradesh, India 26.63748544532147 80.2686882019043
59 Uttar Pradesh, India 26.68534913463835 80.26371002197266
60 Uttar Pradesh, India 26.690717206045928 80.23675918579102
61 Uttar Pradesh, India 26.684428868441266 80.21032333374023
62 Uttar Pradesh, India 26.701299234804004 80.17478942871094
63 Uttar Pradesh, India 26.7293598542805 80.14835357666016
64 Uttar Pradesh, India 26.743464219146883 80.13565063476562
65 Uttar Pradesh, India 26.788371894733142 80.14148712158203
66 Kanpur Nagar, Uttar Pradesh, India 26.810282843485705 80.1177978515625
67 Uttar Pradesh, India 26.870018451179853 80.11178970336914
68 Uttar Pradesh, India 26.935844229523845 80.0328254699707
69 Uttar Pradesh, India 27.011878732230983 79.98939514160156
70 Uttar Pradesh, India 27.03129982997935 79.9746322631836
71 Hardoi, Uttar Pradesh, India 27.05774993780329 79.99197006225586
72 Uttar Pradesh, India 27.120868617323644 79.95180130004883
73 Hardoi, Uttar Pradesh, India 27.143173245679954 79.92639541625977
74 Uttar Pradesh, India 27.153560183685958 79.87438201904297
75 Uttar Pradesh, India 27.176469131898894 79.8211669921875
76 Uttar Pradesh, India 27.185784092839764 79.78374481201172
tukun2009manit
tukun2009manit wrote:
i was given a proj. on devlopment of gis application which based on some data can predict the flooding areas of india. to make it more simpler i have to concentrate only on rain and river data. they provide me rain data but i was not having river data. so the problem begins how to enter above 300 entries into database.

a simple solution was to get the data into text file and then by file handling of any programming language the data can be inserted into database.

i used this link to get the lattitude & longitude of the river ganga http://graargh.returnstrue.com/rajdeep/maps/tools/latlong_tool/v7/lat-long-tool_v7.html


then used this code to handel the file:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package filehandel1;

/**
*
* @author Abhijeet
*/
import java.io.*;
import java.sql.*;

public class ReadBytes6 {

public static void main(String args[]) throws IOException, SQLException {
Statement st = null;
ResultSet rs = null;
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);

FileInputStream in = new FileInputStream("ganga4.txt");
int b;
int count =224;
boolean toogle = true;
StringBuffer sbr = new StringBuffer();
String str = null;
try {
while ((b = in.read()) != -1) {
sbr.append((char) b);
if (b == 9 || b == (int) '\n') {
str = new String(sbr);
sbr = new StringBuffer();

if (toogle == true) {
System.out.println(toogle + " " + str);
toogle=false;
st.executeUpdate("insert into rivers5(lon) values ("+str+")");
}else{
System.out.println(toogle + " " + str);
toogle=true;
st.executeUpdate("update rivers5 set lat="+str+" where gid="+ ++count);
}

}

}

in.close();
} catch (IOException ioe) {
System.out.println(ioe);
}
if (c != null) {
System.out.println("Hooray! We connected to the database!");
} else {
System.out.println("We should never get here.");
}
}
}


1 Uttar Pradesh, India 27.232652495425906 79.69345092773438
2 Uttar Pradesh, India 27.276449745034895 79.6673583984375
3 Uttar Pradesh, India 27.30299438054936 79.64727401733398
4 Farrukhabad, Uttar Pradesh, India 27.343866804104728 79.65551376342773
5 Farrukhabad, Uttar Pradesh, India 27.415662034561 79.61585998535156
6 Farrukhabad, Uttar Pradesh, India 27.415662034561 79.61585998535156
7 Uttar Pradesh, India 27.481014563140143 79.59955215454102
8 Uttar Pradesh, India 27.53887022212607 79.5303726196289
9 Uttar Pradesh, India 27.580111845609515 79.4586181640625
10 Bijnor, Uttar Pradesh, India 27.60871316531578 79.45192337036133
11 Uttar Pradesh, India 27.612211750551875 79.43510055541992
12 Uttar Pradesh, India 27.65251347426449 79.34600830078125
13 Uttar Pradesh, India 27.689456344963386 79.29656982421875
14 Uttar Pradesh, India 27.719244783025815 79.22086715698242
15 Uttar Pradesh, India 27.740061463060663 79.18516159057617
16 Uttar Pradesh, India 27.790339363051864 79.14894104003906
17 Uttar Pradesh, India 27.792009830953607 79.11563873291016
18 Etah, Uttar Pradesh, India 27.817974712034495 79.03650283813477
19 Uttar Pradesh, India 27.847424429843407 79.01041030883789
20 Uttar Pradesh, India 27.848031556420406 78.95702362060547
21 Etah, Uttar Pradesh, India 27.871099847395964 78.90913009643555
22 Uttar Pradesh, India 27.894163227829257 78.90243530273438
23 Etah, Uttar Pradesh, India 27.929204088673075 78.86072158813477
24 Badaun, Uttar Pradesh, India 27.970601372266547 78.8298225402832
25 Etah, Uttar Pradesh, India 27.963930355504193 78.7994384765625
26 Etah, Uttar Pradesh, India 27.967720756531094 78.75308990478516
27 Badaun, Uttar Pradesh, India 27.980303933083693 78.74141693115234
28 Badaun, Uttar Pradesh, India 27.98758028091874 78.67704391479492
29 Etah, Uttar Pradesh, India 27.995007712835296 78.64253997802734
30 Badaun, Uttar Pradesh, India 28.01334672967307 78.62760543823242
31 Badaun, Uttar Pradesh, India 28.03698581298191 78.59790802001953
32 Badaun, Uttar Pradesh, India 28.068799455355123 78.54331970214844
33 Badaun, Uttar Pradesh, India 28.105297792243157 78.5276985168457
34 Badaun, Uttar Pradesh, India 28.107871895167204 78.47705841064453
35 narora, Uttar Pradesh, India 28.15707080401254 78.43706130981445
36 narora, Uttar Pradesh, India 28.17008581167769 78.41989517211914
37 narora, Uttar Pradesh, India 28.190210555026606 78.40169906616211
38 Uttar Pradesh, India 28.243757197957464 78.3680534362793
39 Uttar Pradesh, India 28.27036925991066 78.33749771118164
40 Uttar Pradesh, India 28.274148843416196 78.31792831420898
41 Bulandshahr, Uttar Pradesh, India 28.313901933972783 78.29681396484375
42 Uttar Pradesh, India 28.355452967202044 78.27518463134766
43 Uttar Pradesh, India 28.37433442747635 78.2746696472168
44 Uttar Pradesh, India 28.400007820774032 78.29612731933594
45 Uttar Pradesh, India 28.447562668787487 78.2859992980957
46 Uttar Pradesh, India 28.481819102847485 78.2640266418457
47 Uttar Pradesh, India 28.50822066553574 78.2255744934082
48 Uttar Pradesh, India 28.556480721899916 78.20600509643555
49 Uttar Pradesh, India 28.609089135775704 78.19210052490234
50 Uttar Pradesh, India 28.642690467330322 78.18832397460938
51 Uttar Pradesh, India 28.695406284421967 78.2010269165039
52 Uttar Pradesh, India 28.743279363127904 78.17459106445312
53 Uttar Pradesh, India 28.768862896083874 78.13871383666992
54 Uttar Pradesh, India 28.786466743775446 78.14798355102539
55 Uttar Pradesh, India 28.8348995951331 78.15347671508789
56 Uttar Pradesh, India 28.852341935862928 78.15176010131836
57 Uttar Pradesh, India 28.87594458322063 78.1292724609375
58 Uttar Pradesh, India 28.898940731576268 78.10060501098633
59 Uttar Pradesh, India 28.92824216471701 78.10352325439453
60 Uttar Pradesh, India 28.95032546443703 78.10850143432617
61 Uttar Pradesh, India 28.960088688006795 78.0911636352539
62 Uttar Pradesh, India 28.986069396844684 78.05803298950195
63 Uttar Pradesh, India 29.010242113970257 78.05734634399414
64 Uttar Pradesh, India 29.029756331252763 78.08137893676758
65 Uttar Pradesh, India 29.060071104795817 78.04790496826172
66 Uttar Pradesh, India 29.084376514925058 78.06060791015625
67 Meerut, Uttar Pradesh, India 29.120973840852503 78.07056427001953
68 Uttar Pradesh, India 29.139567493778735 78.05614471435547
69 Bijnor, Uttar Pradesh, India 29.156208959249067 78.08704376220703
70 Bijnor, Uttar Pradesh, India 29.20551782142107 78.10386657714844
71 Uttar Pradesh, India 29.227691585105518 78.09133529663086
72 Uttar Pradesh, India 29.276516858745513 78.09391021728516
73 Uttar Pradesh, India 29.289992122938873 78.0963134765625
74 Bijnor, Uttar Pradesh, India 29.311698531762183 78.09785842895508
75 Bijnor, Uttar Pradesh, India 29.345521384736898 78.05974960327148
76 Muzaffarnagar, Uttar Pradesh, India 29.349411789810265 78.03949356079102
77 Bijnor, Uttar Pradesh, India 29.376490877477423 78.03915023803711
78 Bijnor, Uttar Pradesh, India 29.38217507514529 78.04996490478516
79 Bijnor, Uttar Pradesh, India 29.393392954566497 78.04876327514648
80 Muzaffarnagar, Uttar Pradesh, India 29.427039169044928 78.01116943359375
81 Uttar Pradesh, India 29.451257544903577 78.00756454467773
82 Bijnor, Uttar Pradesh, India 29.476964557202702 78.03108215332031
83 Uttar Pradesh, India 29.546878539265172 78.04378509521484
84 Uttar Pradesh, India 29.614057949691468 78.07657241821289
85 Uttarakhand, India 29.695807117753418 78.17630767822266
86 Uttarakhand, India 29.75618122460728 78.20274353027344
87 Uttarakhand, India 29.82336986059244 78.17047119140625
88 Uttarakhand, India 29.885750787841193 78.15433502197266
89 Uttarakhand, India 29.925779083720542 78.1625747680664
90 Haridwar, Uttarakhand, India 29.943035391587742 78.16446304321289
91 Uttarakhand, India 29.94749774271587 78.1757926940918
92 Haridwar, Uttarakhand, India 29.973524133241206 78.18798065185547
93 Uttarakhand, India 29.97605204798063 78.20154190063477
94 Uttarakhand, India 29.98601437966058 78.21699142456055
95 Uttarakhand, India 29.983040653939447 78.22196960449219
96 Uttarakhand, India 29.991961563931007 78.23158264160156
97 Dehradun, Uttarakhand, India 30.009206383485413 78.23673248291016
98 Dehradun, Uttarakhand, India 30.043835627386027 78.27295303344727
99 Rishikesh, Uttarakhand, India 30.08766215951431 78.29252243041992
100 Rishikesh, Uttarakhand, India 30.099841002166382 78.29166412353516
101 Rishikesh, Uttarakhand, India 30.103999287734677 78.30745697021484
102 Rishikesh, Uttarakhand, India 30.11127586646626 78.30951690673828
103 Rishikesh, Uttarakhand, India 30.12241244907051 78.3134651184082
104 Rishikesh, Uttarakhand, India 30.12419418575852 78.32788467407227
105 Dehradun, Uttarakhand, India 30.131766208006617 78.33097457885742
106 Dehradun, Uttarakhand, India 30.1345870089881 78.34041595458984
107 Dehradun, Uttarakhand, India 30.13206313822174 78.34556579589844
108 Dehradun, Uttarakhand, India 30.12731214760335 78.35174560546875
109 Dehradun, Uttarakhand, India 30.123748754600435 78.36015701293945
110 Dehradun, Uttarakhand, India 30.11855190929639 78.36771011352539
111 Uttarakhand, India 30.11706704612401 78.37457656860352
Related topics
Cheaper to patch--Windows or open source?
[Official] Best PHP Editor
Programming links, info, and tutorials
What to learn first?
Best Programming Language to Use
i want to learn programing
The IDEAL Website... of the future
Which Appllication have you recently downloaded?
gis application dev. for rain,river,flood
PLAVEB - Website Design & Web Development Company
Android Development
How to choose the right PHP Framework for web development?
Facebook Application Development
Some interesting Software
Reply to topic    Frihost Forum Index -> Computers -> Software

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.