我使用的是oracle 11g和java。我使用withinCostPolygon api来查找多边形的点。但是我在某些点(lat和lon)和成本上得到了一个例外。
是个例外[oracle.spatial.network.lod.util.JGeometryUtility, ERROR] java.sql.SQLException: Io exception: End of TNS data channel
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:973)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4223)
at oracle.spatial.network.lod.util.JGeometryUtility.concaveHull(JGeometryUtility.java:685)
at oracle.spatial.network.lod.NetworkAnalyst.withinCostPolygonUsingNetworkBuffer(NetworkAnalyst.java:1550)
at oracle.spatial.network.lod.NetworkAnalyst.withinCostPolygonInternal(NetworkAnalyst.java:1318)
at oracle.spatial.network.lod.NetworkAnalyst.withinCostPolygonInternal(NetworkAnalyst.java:1286)
at oracle.spatial.network.lod.NetworkAnalyst.withinCostPolygon(NetworkAnalyst.java:1262)
at oracle.spatial.network.lod.NetworkAnalyst.withinCostPolygon(NetworkAnalyst.java:1244)
at TestDriveTimePolygon.main(TestDriveTimePolygon.java:161)
TestDriveTimePolygon.java是我的java代码
通过传递点的纬度和经度,我通过一个过程找到了linkid和百分比。
PointOnNet startPoint = new PointOnNet(linkId, percentage);
PointOnNet[] startPoints = {startPoint};
JGeometry resultPolygon;
double costThreshold = 0.1; //in km
System.out.println("costThreshold:" + costThreshold);
System.out.println("before resultPolygon");
resultPolygon = analyst.withinCostPolygon(startPoints,
costThreshold, null, null);
System.out.println("aftr rsltplgon");
resultPolygon.setSRID(8307); // set SRID
resultPolygon.setType(resultPolygon.GTYPE_POLYGON);
调试异常来自于withincostpolygon。
这并不是所有的Lat和Lon以及费用。
为什么会发生这些异常? 我的另一个问题是为什么不通过sqlexception捕获这些异常?(我添加了try和catch)
catch(IOException iex)
{
System.out.println("IO Exception ERROR");
iex.printStackTrace();
}
catch(NetworkDataException ndEx)
{
System.out.println("NetworkDataException ERROR");
ndEx.printStackTrace();
}
catch(SQLException sqlEx)
{
System.out.println("sqlEx ERROR");
sqlEx.printStackTrace();
}
catch (LODNetworkException e)
{
System.out.println("LOD ERROR");
//throw e;
//e.printStackTrace();
System.out.println("LOD ERROR: Invalid cost");
System.out.println("LOD ERROR");
}
catch (Exception e)
{
System.out.println("Exception ERROR");
e.printStackTrace();
}