if (proj == null) {
Debug.output("MysqlGeometryLayer.prepare: null projection!");
return null;
}
OMGraphicList graphics = new OMGraphicList();
try {
Class.forName(dbClass).newInstance();
try {
conn = DriverManager.getConnection(dbUrl);
} catch (Exception ex) {
ex.printStackTrace();
}
stmt = conn.createStatement();
String q = "SELECT ID, AsText(" + geomColumn + ") FROM "
+ geomTable
+ " WHERE MBRIntersects(GEO, GeomFromText('Polygon(( "
+ getProjection().getUpperLeft().getLongitude() + " "
+ getProjection().getUpperLeft().getLatitude() + ", "
+ getProjection().getUpperLeft().getLongitude() + " "
+ getProjection().getLowerRight().getLatitude() + ", "
+ getProjection().getLowerRight().getLongitude() + " "
+ getProjection().getLowerRight().getLatitude() + ", "
+ getProjection().getLowerRight().getLongitude() + " "
+ getProjection().getUpperLeft().getLatitude() + ", "
+ getProjection().getUpperLeft().getLongitude() + " "
+ getProjection().getUpperLeft().getLatitude() + "))'))";
if (Debug.debugging("mysql")) {
Debug.output("MysqlGeometryLayer query: " + q);
}
stmt.executeQuery(q);
rs = stmt.getResultSet();
graphics.clear();
while (rs.next()) {
String result = rs.getString(2);
if (Debug.debugging("mysql")) {
Debug.output("MysqlGeometryLayer result: " + result);
}
MysqlGeometry mg = MysqlWKTGeometryFactory.createGeometry(result);
OMGraphic omg = createGraphic(mg);
omg.generate(proj);
graphics.add(omg);
}
rs.close();
conn.close();