I was tried to get OSM data from my local overpass API. There are four steps to get OSM data.
/srv/osm3s/bin/osm3s_query
encoding remark: Please enter your query and terminate it with CTRL+D.
<query type="node"><bbox-query n="51.0" s="50.9" w="6.9" e="7.0"/><has-kv k="amenity" v="pub"/></query><print/>
my code as below:
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("/srv/osm3s/bin/osm3s_query");
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
System.out.println(line);
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t)
{
t.printStackTrace();
}
The process will hang on step 2 after shown the message encoding remark: Please enter your query and terminate it with CTRL+D.
. I have no idea how to give the process the query string.
Anybody has some idea?
OutputStreamWriter output = proc.getOutputStream();
output.write(yourQuery);
output.write(4); // that's ctrl-d
output.flush();