Hey
Ich versuche bei der Erzeugung von Dreieckspolygonen diese über einen winkel einzuschränken
Die ersten 50 durchläufe klappt das ganze auch noch ganz gut doch dann kommte eine sql exception bei der ich nicht weiß wie diese zustande kommt.
Hier erstmal mein Quellcode:
11.09.2012 15:33:33 indxf.myWindow ta_tri_Poly
SCHWERWIEGEND: null
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (Domain error)
Die Punkte bei dem es nicht klappt
P1(4510483.0, 5664581.5, 176.51),
P2(4510482.0, 5664573.5, 176.290),
P3(4510504.0, 5664570.0, 159.15)
Bei dem es noch klappt
P1(4510486.5, 5664592.0, 175.41)
P2(4510483.0, 5664581.0, 176.51)
P3(4510509.5, 5664585.0, 158.99)
Vielleicht kann mir einer sagen wieso er die exception rausschmeißt.
Danke
Ich versuche bei der Erzeugung von Dreieckspolygonen diese über einen winkel einzuschränken
Die ersten 50 durchläufe klappt das ganze auch noch ganz gut doch dann kommte eine sql exception bei der ich nicht weiß wie diese zustande kommt.
Hier erstmal mein Quellcode:
Java:
public void ta_tri_Poly()
{
try {
Connection con = dbconnection();
Statement st;
String sql;
ResultSet rs, rs2;
st=con.createStatement();
st.setQueryTimeout(30);
st.execute("SELECT load_extension('libspatialite-2.dll')");
sql ="Drop table if exists ta_tri_winkel";
st.execute(sql);
sql=("CREATE TABLE ta_tri_winkel (id Integer Not Null Primary Key, "
+ "Schnitt Integer Not Null, winkel Double, vwinkel Double)");
st.execute(sql);
sql=("SELECT AddGeometryColumn('ta_tri_winkel','geompoly',3389,'Polygon','XYZ')");
st.execute(sql);
sql =("INSERT INTO ta_tri_winkel VALUES (?,?,?,?, GeomFromText(?,3389))");
PreparedStatement ps = con.prepareStatement(sql);
sql =("Select Count(*) as count from ta_tri_point where Schnitt = ? and Art= 1");
PreparedStatement ps2 = con.prepareStatement(sql);
sql =("Select ST_X(t1.geomp) as p1x, ST_Y(t1.geomp) as p1y, ST_Z(t1.geomp) as p1z, "
+ "ST_X(t2.geomp) as p2x, ST_Y(t2.geomp) as p2y, ST_Z(t2.geomp) as p2z, "
+ "sqrt(Power(Distance(t1.geomp, t3.geomp),2)+ Power((ST_Z(t3.geomp)- ST_Z(t1.geomp)),2)) as b, "
+ "Acos(((Power(Distance(t2.geomp, t3.geomp),2)- Power(Distance(t1.geomp, t3.geomp),2)- Power(Distance(t1.geomp, t2.geomp),2)) "
+ "/(-2* (Distance(t1.geomp, t3.geomp)) *(Distance(t1.geomp, t2.geomp))))) as w1, "
+ "ST_X(t3.geomp) as p3x, ST_Y(t3.geomp) as p3y, ST_Z(t3.geomp) as p3z "
+ "from ta_tri_point t1, ta_tri_point t2, ta_tri_point t3 "
+ "where t1.PointNum = ? and t2.PointNum = ? and t1.Art = 1 and t1.Schnitt = ? "
+ "and t1.Art= t2.Art and t1.Schnitt = t2.Schnitt "
+ "and t1.Art != t3.Art and t1.Schnitt = t3.Schnitt "
+ "order by b "
+ "LIMIT 1");
PreparedStatement ps1 = con.prepareStatement(sql);
int scount = 1;
if(jSchnitt.getText().equals(""))
{
sql = ("Select Count(Distinct(Schnitt)) as sc from ta_tri_line ");
rs = st.executeQuery(sql);
scount = rs.getInt("sc");
}
sql = ("Select Schnitt from ta_tri_line group by Schnitt Limit ?,1");
PreparedStatement ps3 = con.prepareStatement(sql);
int cs = 0;
int id = 1;
while (cs < scount)
{
int s;
if(jSchnitt.getText().equals(""))
{
ps3.setInt(1,cs);
rs =ps3.executeQuery();
s = rs.getInt("Schnitt");
}
else
{
s= Integer.parseInt(jSchnitt.getText());
}
ps2.setInt(1, s);
rs = ps2.executeQuery();
int count = rs.getInt("count");
int i = 1;
while (i != count)
{
ps1.setInt(1, i);
int j = i+1;
ps1.setInt(2, j);
ps1.setInt(3, s);
rs2 = ps1.executeQuery();
double x1 = rs2.getDouble("p1x");
double x2 = rs2.getDouble("p2x");
double x3 = rs2.getDouble("p3x");
double y1 = rs2.getDouble("p1y");
double y2 = rs2.getDouble("p2y");
double y3 = rs2.getDouble("p3y");
double z1 = rs2.getDouble("p1z");
double z2 = rs2.getDouble("p2z");
double z3 = rs2.getDouble("p3z");
String p1 = x1+" "+y1+" "+z1;
String p2 = x2+" "+y2+" "+z2;
String p3 = x3+" "+y3+" "+z3;
String poly = "POLYGONZ(("+p1+", "+p2+", "+p3+", "+p1+"))";
double xn = ((y2-y1)*(z3-z1))-((z2-z1)*(y3-y1));
double yn = ((z2-z1)*(x3-x1))-((x2-x1)*(z3-z1));
double zn = ((x2-x1)*(y3-y1))-((y2-y1)*(x3-x1));
if(jVWinkle.getText().equals(""))
{
vwinkel = 0;
}
else
{
vwinkel = Double.parseDouble(jVWinkle.getText());
}
double winkel =(90-(Math.abs((180/Math.PI)*(zn/(Math.sqrt((xn*xn)+(yn*yn)+ (zn*zn)))))))-vwinkel;
ps.setInt(1, id);
ps.setInt(2, s);
ps.setDouble(3, winkel);
ps.setDouble(4, vwinkel);
ps.setString(5, poly);
ps.executeUpdate();
System.out.println(id+" "+winkel);
i++;
id++;
}
cs++;
}
con.close();
} catch (SQLException ex) {
Logger.getLogger(myWindow.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(myWindow.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(myWindow.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(myWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
11.09.2012 15:33:33 indxf.myWindow ta_tri_Poly
SCHWERWIEGEND: null
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (Domain error)
Die Punkte bei dem es nicht klappt
P1(4510483.0, 5664581.5, 176.51),
P2(4510482.0, 5664573.5, 176.290),
P3(4510504.0, 5664570.0, 159.15)
Bei dem es noch klappt
P1(4510486.5, 5664592.0, 175.41)
P2(4510483.0, 5664581.0, 176.51)
P3(4510509.5, 5664585.0, 158.99)
Vielleicht kann mir einer sagen wieso er die exception rausschmeißt.
Danke