Hi ,

I have a collection of lat/longs , i want to find out if what all belongs 
to Geometry B and what all not belongs to Geomentry B..
I have given below example, Here i have array of lat/longs,.

Instead of iterating each and every lat/longs and executing query every 
time ,finding out if it is within SAFE ZONE , i am trying to achieve with 
only one query execution and find out all at once.

This is to improve my overall processing performance time.  

Please help me ., how can i achieve multiple here,  I am using this logic 
in In-memory H2



private static final String LOOKUP_QUERY="select top 1  \r\n" + 
" cz.id,\r\n" + 
" cz.THE_GEOM ,\r\n" +  
" cz.name , \r\n" +  
" cz.BOUNDARY \r\n" +  
"from \r\n" + 
" SAFE_ZONE  cz \r\n" + 
"where  \r\n" + 
" st_within( st_makepoint(?,?) ,cz.THE_GEOM)";
public static Address[] findFencesInH2SafeZone(RevGeoInput[] revGeoinputs) {
Address[] arrAddress = new Address[revGeoinputs.length];
PreparedStatement prepStmt = null;
Connection connection = null;
String fenceFound = null; 
Address oAddress = null;
ResultSet rs1 = null;
try {
connection = GetInMemoryConnUtil.getConnection()
prepStmt = connection.prepareStatement(LOOKUP_QUERY);
for(int i=0 ; i<revGeoinputs.length ; i++) {
RevGeoInput oRevGeoInput = revGeoinputs[i];
prepStmt.setDouble(1, oRevGeoInput.getLongitude());
prepStmt.setDouble(2, oRevGeoInput.getLatitude() );
rs1 = prepStmt.executeQuery();
oAddress = new Address();
if (rs1.next()) {
                          fenceFound = rs1.getString("name");
            
                           oAddress.setSafeZone(STR_Y);
                         arrAddress[i] = oAddress;
}else {
oAddress.setSafeZone(STR_N);
arrAddress[i] = oAddress;
}
} 
}catch (SQLException e) {
        } catch (Exception e) {        
} finally { 
} 
return arrAddress; 
}

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/2089555a-da8e-4b0b-b394-1ddee6aa2e83%40googlegroups.com.

Reply via email to