id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
137,800 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java | SshUtilities.runDemonShellCommand | public static String runDemonShellCommand( Session session, String command ) throws JSchException, IOException {
String remoteResponseStr = launchACommandAndExit(session, command);
return remoteResponseStr;
} | java | public static String runDemonShellCommand( Session session, String command ) throws JSchException, IOException {
String remoteResponseStr = launchACommandAndExit(session, command);
return remoteResponseStr;
} | [
"public",
"static",
"String",
"runDemonShellCommand",
"(",
"Session",
"session",
",",
"String",
"command",
")",
"throws",
"JSchException",
",",
"IOException",
"{",
"String",
"remoteResponseStr",
"=",
"launchACommandAndExit",
"(",
"session",
",",
"command",
")",
";",
"return",
"remoteResponseStr",
";",
"}"
] | Run a daemon command or commands that do not exit quickly.
@param session the session to use.
@param command the command to launch.
@return the output of the command.
@throws JSchException
@throws IOException | [
"Run",
"a",
"daemon",
"command",
"or",
"commands",
"that",
"do",
"not",
"exit",
"quickly",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java#L294-L297 |
137,801 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java | SshUtilities.downloadFile | public static void downloadFile( Session session, String remoteFilePath, String localFilePath ) throws Exception {
// exec 'scp -f rfile' remotely
String command = "scp -f " + remoteFilePath;
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// get I/O streams for remote scp
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
channel.connect();
byte[] buf = new byte[1024];
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
while( true ) {
int c = checkAck(in);
if (c != 'C') {
break;
}
// read '0644 '
in.read(buf, 0, 5);
long filesize = 0L;
while( true ) {
if (in.read(buf, 0, 1) < 0) {
// error
break;
}
if (buf[0] == ' ')
break;
filesize = filesize * 10L + (long) (buf[0] - '0');
}
String file = null;
for( int i = 0;; i++ ) {
in.read(buf, i, 1);
if (buf[i] == (byte) 0x0a) {
file = new String(buf, 0, i);
break;
}
}
System.out.println("filesize=" + filesize + ", file=" + file);
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
// read a content of lfile
FileOutputStream fos = new FileOutputStream(localFilePath);
int foo;
while( true ) {
if (buf.length < filesize)
foo = buf.length;
else
foo = (int) filesize;
foo = in.read(buf, 0, foo);
if (foo < 0) {
// error
break;
}
fos.write(buf, 0, foo);
filesize -= foo;
if (filesize == 0L)
break;
}
fos.close();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
}
} | java | public static void downloadFile( Session session, String remoteFilePath, String localFilePath ) throws Exception {
// exec 'scp -f rfile' remotely
String command = "scp -f " + remoteFilePath;
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// get I/O streams for remote scp
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
channel.connect();
byte[] buf = new byte[1024];
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
while( true ) {
int c = checkAck(in);
if (c != 'C') {
break;
}
// read '0644 '
in.read(buf, 0, 5);
long filesize = 0L;
while( true ) {
if (in.read(buf, 0, 1) < 0) {
// error
break;
}
if (buf[0] == ' ')
break;
filesize = filesize * 10L + (long) (buf[0] - '0');
}
String file = null;
for( int i = 0;; i++ ) {
in.read(buf, i, 1);
if (buf[i] == (byte) 0x0a) {
file = new String(buf, 0, i);
break;
}
}
System.out.println("filesize=" + filesize + ", file=" + file);
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
// read a content of lfile
FileOutputStream fos = new FileOutputStream(localFilePath);
int foo;
while( true ) {
if (buf.length < filesize)
foo = buf.length;
else
foo = (int) filesize;
foo = in.read(buf, 0, foo);
if (foo < 0) {
// error
break;
}
fos.write(buf, 0, foo);
filesize -= foo;
if (filesize == 0L)
break;
}
fos.close();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
}
} | [
"public",
"static",
"void",
"downloadFile",
"(",
"Session",
"session",
",",
"String",
"remoteFilePath",
",",
"String",
"localFilePath",
")",
"throws",
"Exception",
"{",
"// exec 'scp -f rfile' remotely",
"String",
"command",
"=",
"\"scp -f \"",
"+",
"remoteFilePath",
";",
"Channel",
"channel",
"=",
"session",
".",
"openChannel",
"(",
"\"exec\"",
")",
";",
"(",
"(",
"ChannelExec",
")",
"channel",
")",
".",
"setCommand",
"(",
"command",
")",
";",
"// get I/O streams for remote scp",
"OutputStream",
"out",
"=",
"channel",
".",
"getOutputStream",
"(",
")",
";",
"InputStream",
"in",
"=",
"channel",
".",
"getInputStream",
"(",
")",
";",
"channel",
".",
"connect",
"(",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"// send '\\0'",
"buf",
"[",
"0",
"]",
"=",
"0",
";",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"1",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"c",
"=",
"checkAck",
"(",
"in",
")",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
")",
"{",
"break",
";",
"}",
"// read '0644 '",
"in",
".",
"read",
"(",
"buf",
",",
"0",
",",
"5",
")",
";",
"long",
"filesize",
"=",
"0L",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"in",
".",
"read",
"(",
"buf",
",",
"0",
",",
"1",
")",
"<",
"0",
")",
"{",
"// error",
"break",
";",
"}",
"if",
"(",
"buf",
"[",
"0",
"]",
"==",
"'",
"'",
")",
"break",
";",
"filesize",
"=",
"filesize",
"*",
"10L",
"+",
"(",
"long",
")",
"(",
"buf",
"[",
"0",
"]",
"-",
"'",
"'",
")",
";",
"}",
"String",
"file",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
";",
"i",
"++",
")",
"{",
"in",
".",
"read",
"(",
"buf",
",",
"i",
",",
"1",
")",
";",
"if",
"(",
"buf",
"[",
"i",
"]",
"==",
"(",
"byte",
")",
"0x0a",
")",
"{",
"file",
"=",
"new",
"String",
"(",
"buf",
",",
"0",
",",
"i",
")",
";",
"break",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"filesize=\"",
"+",
"filesize",
"+",
"\", file=\"",
"+",
"file",
")",
";",
"// send '\\0'",
"buf",
"[",
"0",
"]",
"=",
"0",
";",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"1",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"// read a content of lfile",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"localFilePath",
")",
";",
"int",
"foo",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"buf",
".",
"length",
"<",
"filesize",
")",
"foo",
"=",
"buf",
".",
"length",
";",
"else",
"foo",
"=",
"(",
"int",
")",
"filesize",
";",
"foo",
"=",
"in",
".",
"read",
"(",
"buf",
",",
"0",
",",
"foo",
")",
";",
"if",
"(",
"foo",
"<",
"0",
")",
"{",
"// error",
"break",
";",
"}",
"fos",
".",
"write",
"(",
"buf",
",",
"0",
",",
"foo",
")",
";",
"filesize",
"-=",
"foo",
";",
"if",
"(",
"filesize",
"==",
"0L",
")",
"break",
";",
"}",
"fos",
".",
"close",
"(",
")",
";",
"if",
"(",
"checkAck",
"(",
"in",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"// send '\\0'",
"buf",
"[",
"0",
"]",
"=",
"0",
";",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"1",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"}"
] | Download a remote file via scp.
@param session the session to use.
@param remoteFilePath the remote file path.
@param localFilePath the local file path to copy into.
@throws Exception | [
"Download",
"a",
"remote",
"file",
"via",
"scp",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java#L307-L392 |
137,802 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java | SshUtilities.uploadFile | public static void uploadFile( Session session, String localFile, String remoteFile ) throws Exception {
boolean ptimestamp = true;
// exec 'scp -t rfile' remotely
String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + remoteFile;
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// get I/O streams for remote scp
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
channel.connect();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
File _lfile = new File(localFile);
if (ptimestamp) {
command = "T " + (_lfile.lastModified() / 1000) + " 0";
// The access time should be sent here,
// but it is not accessible with JavaAPI ;-<
command += (" " + (_lfile.lastModified() / 1000) + " 0\n");
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
}
// send "C0644 filesize filename", where filename should not include '/'
long filesize = _lfile.length();
command = "C0644 " + filesize + " ";
if (localFile.lastIndexOf('/') > 0) {
command += localFile.substring(localFile.lastIndexOf('/') + 1);
} else {
command += localFile;
}
command += "\n";
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
// send a content of lfile
FileInputStream fis = new FileInputStream(localFile);
byte[] buf = new byte[1024];
while( true ) {
int len = fis.read(buf, 0, buf.length);
if (len <= 0)
break;
out.write(buf, 0, len); // out.flush();
}
fis.close();
fis = null;
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
out.close();
channel.disconnect();
} | java | public static void uploadFile( Session session, String localFile, String remoteFile ) throws Exception {
boolean ptimestamp = true;
// exec 'scp -t rfile' remotely
String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + remoteFile;
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// get I/O streams for remote scp
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
channel.connect();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
File _lfile = new File(localFile);
if (ptimestamp) {
command = "T " + (_lfile.lastModified() / 1000) + " 0";
// The access time should be sent here,
// but it is not accessible with JavaAPI ;-<
command += (" " + (_lfile.lastModified() / 1000) + " 0\n");
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
}
// send "C0644 filesize filename", where filename should not include '/'
long filesize = _lfile.length();
command = "C0644 " + filesize + " ";
if (localFile.lastIndexOf('/') > 0) {
command += localFile.substring(localFile.lastIndexOf('/') + 1);
} else {
command += localFile;
}
command += "\n";
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
// send a content of lfile
FileInputStream fis = new FileInputStream(localFile);
byte[] buf = new byte[1024];
while( true ) {
int len = fis.read(buf, 0, buf.length);
if (len <= 0)
break;
out.write(buf, 0, len); // out.flush();
}
fis.close();
fis = null;
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
if (checkAck(in) != 0) {
throw new RuntimeException();
}
out.close();
channel.disconnect();
} | [
"public",
"static",
"void",
"uploadFile",
"(",
"Session",
"session",
",",
"String",
"localFile",
",",
"String",
"remoteFile",
")",
"throws",
"Exception",
"{",
"boolean",
"ptimestamp",
"=",
"true",
";",
"// exec 'scp -t rfile' remotely",
"String",
"command",
"=",
"\"scp \"",
"+",
"(",
"ptimestamp",
"?",
"\"-p\"",
":",
"\"\"",
")",
"+",
"\" -t \"",
"+",
"remoteFile",
";",
"Channel",
"channel",
"=",
"session",
".",
"openChannel",
"(",
"\"exec\"",
")",
";",
"(",
"(",
"ChannelExec",
")",
"channel",
")",
".",
"setCommand",
"(",
"command",
")",
";",
"// get I/O streams for remote scp",
"OutputStream",
"out",
"=",
"channel",
".",
"getOutputStream",
"(",
")",
";",
"InputStream",
"in",
"=",
"channel",
".",
"getInputStream",
"(",
")",
";",
"channel",
".",
"connect",
"(",
")",
";",
"if",
"(",
"checkAck",
"(",
"in",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"File",
"_lfile",
"=",
"new",
"File",
"(",
"localFile",
")",
";",
"if",
"(",
"ptimestamp",
")",
"{",
"command",
"=",
"\"T \"",
"+",
"(",
"_lfile",
".",
"lastModified",
"(",
")",
"/",
"1000",
")",
"+",
"\" 0\"",
";",
"// The access time should be sent here,",
"// but it is not accessible with JavaAPI ;-<",
"command",
"+=",
"(",
"\" \"",
"+",
"(",
"_lfile",
".",
"lastModified",
"(",
")",
"/",
"1000",
")",
"+",
"\" 0\\n\"",
")",
";",
"out",
".",
"write",
"(",
"command",
".",
"getBytes",
"(",
")",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"if",
"(",
"checkAck",
"(",
"in",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"}",
"// send \"C0644 filesize filename\", where filename should not include '/'",
"long",
"filesize",
"=",
"_lfile",
".",
"length",
"(",
")",
";",
"command",
"=",
"\"C0644 \"",
"+",
"filesize",
"+",
"\" \"",
";",
"if",
"(",
"localFile",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
">",
"0",
")",
"{",
"command",
"+=",
"localFile",
".",
"substring",
"(",
"localFile",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"}",
"else",
"{",
"command",
"+=",
"localFile",
";",
"}",
"command",
"+=",
"\"\\n\"",
";",
"out",
".",
"write",
"(",
"command",
".",
"getBytes",
"(",
")",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"if",
"(",
"checkAck",
"(",
"in",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"// send a content of lfile",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"localFile",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"while",
"(",
"true",
")",
"{",
"int",
"len",
"=",
"fis",
".",
"read",
"(",
"buf",
",",
"0",
",",
"buf",
".",
"length",
")",
";",
"if",
"(",
"len",
"<=",
"0",
")",
"break",
";",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"len",
")",
";",
"// out.flush();",
"}",
"fis",
".",
"close",
"(",
")",
";",
"fis",
"=",
"null",
";",
"// send '\\0'",
"buf",
"[",
"0",
"]",
"=",
"0",
";",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"1",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"if",
"(",
"checkAck",
"(",
"in",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"out",
".",
"close",
"(",
")",
";",
"channel",
".",
"disconnect",
"(",
")",
";",
"}"
] | Upload a file to the remote host via scp.
@param session the session to use.
@param localFile the local file path.
@param remoteFile the remote file path to copy into.
@throws Exception | [
"Upload",
"a",
"file",
"to",
"the",
"remote",
"host",
"via",
"scp",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java#L402-L469 |
137,803 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgObject.java | DwgObject.readObjectHeaderV15 | public int readObjectHeaderV15(int[] data, int offset) throws Exception {
int bitPos = offset;
Integer mode = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
setMode(mode.intValue());
Vector v = DwgUtil.getBitLong(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int rnum = ((Integer)v.get(1)).intValue();
setNumReactors(rnum);
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean nolinks = ((Boolean)v.get(1)).booleanValue();
setNoLinks(nolinks);
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int color = ((Integer)v.get(1)).intValue();
setColor(color);
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
float ltscale = ((Double)v.get(1)).floatValue();
Integer ltflag = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
Integer psflag = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int invis = ((Integer)v.get(1)).intValue();
v = DwgUtil.getRawChar(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int weight = ((Integer)v.get(1)).intValue();
return bitPos;
} | java | public int readObjectHeaderV15(int[] data, int offset) throws Exception {
int bitPos = offset;
Integer mode = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
setMode(mode.intValue());
Vector v = DwgUtil.getBitLong(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int rnum = ((Integer)v.get(1)).intValue();
setNumReactors(rnum);
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean nolinks = ((Boolean)v.get(1)).booleanValue();
setNoLinks(nolinks);
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int color = ((Integer)v.get(1)).intValue();
setColor(color);
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
float ltscale = ((Double)v.get(1)).floatValue();
Integer ltflag = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
Integer psflag = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int invis = ((Integer)v.get(1)).intValue();
v = DwgUtil.getRawChar(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int weight = ((Integer)v.get(1)).intValue();
return bitPos;
} | [
"public",
"int",
"readObjectHeaderV15",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"throws",
"Exception",
"{",
"int",
"bitPos",
"=",
"offset",
";",
"Integer",
"mode",
"=",
"(",
"Integer",
")",
"DwgUtil",
".",
"getBits",
"(",
"data",
",",
"2",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"bitPos",
"+",
"2",
";",
"setMode",
"(",
"mode",
".",
"intValue",
"(",
")",
")",
";",
"Vector",
"v",
"=",
"DwgUtil",
".",
"getBitLong",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"int",
"rnum",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"intValue",
"(",
")",
";",
"setNumReactors",
"(",
"rnum",
")",
";",
"v",
"=",
"DwgUtil",
".",
"testBit",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"boolean",
"nolinks",
"=",
"(",
"(",
"Boolean",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"booleanValue",
"(",
")",
";",
"setNoLinks",
"(",
"nolinks",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getBitShort",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"int",
"color",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"intValue",
"(",
")",
";",
"setColor",
"(",
"color",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"float",
"ltscale",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"floatValue",
"(",
")",
";",
"Integer",
"ltflag",
"=",
"(",
"Integer",
")",
"DwgUtil",
".",
"getBits",
"(",
"data",
",",
"2",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"bitPos",
"+",
"2",
";",
"Integer",
"psflag",
"=",
"(",
"Integer",
")",
"DwgUtil",
".",
"getBits",
"(",
"data",
",",
"2",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"bitPos",
"+",
"2",
";",
"v",
"=",
"DwgUtil",
".",
"getBitShort",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"int",
"invis",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"intValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getRawChar",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"int",
"weight",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"intValue",
"(",
")",
";",
"return",
"bitPos",
";",
"}"
] | Reads the header of an object in a DWG file Version 15
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@return int New offset
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines. | [
"Reads",
"the",
"header",
"of",
"an",
"object",
"in",
"a",
"DWG",
"file",
"Version",
"15"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgObject.java#L56-L87 |
137,804 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/style/sld/SLDValidator.java | SLDValidator.validateSLD | public List validateSLD(InputSource xml) {
URL schemaURL = SLDValidator.class.getResource("/schemas/sld/StyledLayerDescriptor.xsd");
return ResponseUtils.validate(xml, schemaURL, false, entityResolver);
} | java | public List validateSLD(InputSource xml) {
URL schemaURL = SLDValidator.class.getResource("/schemas/sld/StyledLayerDescriptor.xsd");
return ResponseUtils.validate(xml, schemaURL, false, entityResolver);
} | [
"public",
"List",
"validateSLD",
"(",
"InputSource",
"xml",
")",
"{",
"URL",
"schemaURL",
"=",
"SLDValidator",
".",
"class",
".",
"getResource",
"(",
"\"/schemas/sld/StyledLayerDescriptor.xsd\"",
")",
";",
"return",
"ResponseUtils",
".",
"validate",
"(",
"xml",
",",
"schemaURL",
",",
"false",
",",
"entityResolver",
")",
";",
"}"
] | validate a .sld against the schema
@param xml input stream representing the .sld file
@return list of SAXExceptions (0 if the file's okay) | [
"validate",
"a",
".",
"sld",
"against",
"the",
"schema"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/style/sld/SLDValidator.java#L199-L202 |
137,805 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java | Utility.pipeMagnitude | public static void pipeMagnitude( double[] magnitude, double[] whereDrain, IHMProgressMonitor pm ) {
int count = 0;
/* whereDrain Contiene gli indici degli stati riceventi. */
/* magnitude Contiene la magnitude dei vari stati. */
int length = magnitude.length;
/* Per ogni stato */
for( int i = 0; i < length; i++ ) {
count = 0;
/* la magnitude viene posta pari a 1 */
magnitude[i]++;
int k = i;
/*
* Si segue il percorso dell'acqua e si incrementa di 1 la mgnitude
* di tutti gli stati attraversati prima di raggiungere l'uscita
*/
while( whereDrain[k] != Constants.OUT_INDEX_PIPE && count < length ) {
k = (int) whereDrain[k];
magnitude[k]++;
count++;
}
if (count > length) {
pm.errorMessage(msg.message("trentoP.error.pipe"));
throw new IllegalArgumentException(msg.message("trentoP.error.pipe"));
}
}
} | java | public static void pipeMagnitude( double[] magnitude, double[] whereDrain, IHMProgressMonitor pm ) {
int count = 0;
/* whereDrain Contiene gli indici degli stati riceventi. */
/* magnitude Contiene la magnitude dei vari stati. */
int length = magnitude.length;
/* Per ogni stato */
for( int i = 0; i < length; i++ ) {
count = 0;
/* la magnitude viene posta pari a 1 */
magnitude[i]++;
int k = i;
/*
* Si segue il percorso dell'acqua e si incrementa di 1 la mgnitude
* di tutti gli stati attraversati prima di raggiungere l'uscita
*/
while( whereDrain[k] != Constants.OUT_INDEX_PIPE && count < length ) {
k = (int) whereDrain[k];
magnitude[k]++;
count++;
}
if (count > length) {
pm.errorMessage(msg.message("trentoP.error.pipe"));
throw new IllegalArgumentException(msg.message("trentoP.error.pipe"));
}
}
} | [
"public",
"static",
"void",
"pipeMagnitude",
"(",
"double",
"[",
"]",
"magnitude",
",",
"double",
"[",
"]",
"whereDrain",
",",
"IHMProgressMonitor",
"pm",
")",
"{",
"int",
"count",
"=",
"0",
";",
"/* whereDrain Contiene gli indici degli stati riceventi. */",
"/* magnitude Contiene la magnitude dei vari stati. */",
"int",
"length",
"=",
"magnitude",
".",
"length",
";",
"/* Per ogni stato */",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"count",
"=",
"0",
";",
"/* la magnitude viene posta pari a 1 */",
"magnitude",
"[",
"i",
"]",
"++",
";",
"int",
"k",
"=",
"i",
";",
"/*\n * Si segue il percorso dell'acqua e si incrementa di 1 la mgnitude\n * di tutti gli stati attraversati prima di raggiungere l'uscita\n */",
"while",
"(",
"whereDrain",
"[",
"k",
"]",
"!=",
"Constants",
".",
"OUT_INDEX_PIPE",
"&&",
"count",
"<",
"length",
")",
"{",
"k",
"=",
"(",
"int",
")",
"whereDrain",
"[",
"k",
"]",
";",
"magnitude",
"[",
"k",
"]",
"++",
";",
"count",
"++",
";",
"}",
"if",
"(",
"count",
">",
"length",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.pipe\"",
")",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.pipe\"",
")",
")",
";",
"}",
"}",
"}"
] | Calculate the magnitudo of the several drainage area.
<p>
It begin from the first state, where the magnitudo is setted to 1, and
then it follow the path of the water until the outlet.
</p>
<p>
During this process the magnitudo of each through areas is incremented of
1 units. This operation is done for every state, so any path of the water
are analized, from the state where she is intercept until the outlet.
<p>
</p>
@param magnitudo is the array where the magnitudo is stored.
@param whereDrain array which contains where a pipe drains.
@param pm the progerss monitor.
@throw IllegalArgumentException if the water through a number of state
which is greater than the state in the network. | [
"Calculate",
"the",
"magnitudo",
"of",
"the",
"several",
"drainage",
"area",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java#L265-L294 |
137,806 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java | Utility.verifyProjectType | public static boolean verifyProjectType( SimpleFeatureType schema, IHMProgressMonitor pm ) {
String searchedField = PipesTrentoP.ID.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.DRAIN_AREA.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.INITIAL_ELEVATION.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.FINAL_ELEVATION.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.RUNOFF_COEFFICIENT.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.KS.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.MINIMUM_PIPE_SLOPE.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.AVERAGE_RESIDENCE_TIME.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.PIPE_SECTION_TYPE.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.AVERAGE_SLOPE.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.PER_AREA.getAttributeName();
String attributeName = findAttributeName(schema, searchedField);
if (attributeName != null) {
return true;
}
return false;
} | java | public static boolean verifyProjectType( SimpleFeatureType schema, IHMProgressMonitor pm ) {
String searchedField = PipesTrentoP.ID.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.DRAIN_AREA.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.INITIAL_ELEVATION.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.FINAL_ELEVATION.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.RUNOFF_COEFFICIENT.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.KS.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.MINIMUM_PIPE_SLOPE.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.AVERAGE_RESIDENCE_TIME.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.PIPE_SECTION_TYPE.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.AVERAGE_SLOPE.getAttributeName();
verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
searchedField = PipesTrentoP.PER_AREA.getAttributeName();
String attributeName = findAttributeName(schema, searchedField);
if (attributeName != null) {
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"verifyProjectType",
"(",
"SimpleFeatureType",
"schema",
",",
"IHMProgressMonitor",
"pm",
")",
"{",
"String",
"searchedField",
"=",
"PipesTrentoP",
".",
"ID",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"DRAIN_AREA",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"INITIAL_ELEVATION",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"FINAL_ELEVATION",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"RUNOFF_COEFFICIENT",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"KS",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"MINIMUM_PIPE_SLOPE",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"AVERAGE_RESIDENCE_TIME",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"PIPE_SECTION_TYPE",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"AVERAGE_SLOPE",
".",
"getAttributeName",
"(",
")",
";",
"verifyFeatureKey",
"(",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
",",
"searchedField",
",",
"pm",
")",
";",
"searchedField",
"=",
"PipesTrentoP",
".",
"PER_AREA",
".",
"getAttributeName",
"(",
")",
";",
"String",
"attributeName",
"=",
"findAttributeName",
"(",
"schema",
",",
"searchedField",
")",
";",
"if",
"(",
"attributeName",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Verify the schema.
<p>
Verify if the FeatureCollection contains all the needed fields.
</p>
@param schema is yhe type for the project mode.
@param pm
@return true if there is the percentage of the area. | [
"Verify",
"the",
"schema",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java#L357-L386 |
137,807 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java | Utility.verifyFeatureKey | private static void verifyFeatureKey( String key, String searchedField, IHMProgressMonitor pm ) {
if (key == null) {
if (pm != null) {
pm.errorMessage(msg.message("trentoP.error.featureKey") + searchedField);
}
throw new IllegalArgumentException(msg.message("trentoP.error.featureKey") + searchedField);
}
} | java | private static void verifyFeatureKey( String key, String searchedField, IHMProgressMonitor pm ) {
if (key == null) {
if (pm != null) {
pm.errorMessage(msg.message("trentoP.error.featureKey") + searchedField);
}
throw new IllegalArgumentException(msg.message("trentoP.error.featureKey") + searchedField);
}
} | [
"private",
"static",
"void",
"verifyFeatureKey",
"(",
"String",
"key",
",",
"String",
"searchedField",
",",
"IHMProgressMonitor",
"pm",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"if",
"(",
"pm",
"!=",
"null",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.featureKey\"",
")",
"+",
"searchedField",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.featureKey\"",
")",
"+",
"searchedField",
")",
";",
"}",
"}"
] | Verify if there is a key of a FeatureCollections.
@param key
@throws IllegalArgumentException
if the key is null. | [
"Verify",
"if",
"there",
"is",
"a",
"key",
"of",
"a",
"FeatureCollections",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java#L395-L403 |
137,808 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/flatfile/validation/FlatFileValidations.java | FlatFileValidations.message | public static ValidationMessage<Origin> message(
LineReader lineReader, Severity severity,
String messageKey, Object... params) {
return message(lineReader.getCurrentLineNumber(), severity, messageKey, params);
} | java | public static ValidationMessage<Origin> message(
LineReader lineReader, Severity severity,
String messageKey, Object... params) {
return message(lineReader.getCurrentLineNumber(), severity, messageKey, params);
} | [
"public",
"static",
"ValidationMessage",
"<",
"Origin",
">",
"message",
"(",
"LineReader",
"lineReader",
",",
"Severity",
"severity",
",",
"String",
"messageKey",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"message",
"(",
"lineReader",
".",
"getCurrentLineNumber",
"(",
")",
",",
"severity",
",",
"messageKey",
",",
"params",
")",
";",
"}"
] | Creates a validation message.
@param lineReader the flat file line reader.
@param severity severity of the message
@param messageKey a key of the message
@param params parameters of the message
@return a validation message | [
"Creates",
"a",
"validation",
"message",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/validation/FlatFileValidations.java#L54-L58 |
137,809 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/flatfile/validation/FlatFileValidations.java | FlatFileValidations.setCDSTranslationReport | public static void setCDSTranslationReport(ExtendedResult<CdsFeatureTranslationCheck.TranslationReportInfo> cdsCheckResult) {
try {
CdsFeatureTranslationCheck.TranslationReportInfo translationInfo = cdsCheckResult.getExtension();
StringWriter translationReportWriter = new StringWriter();
TranslationResult translationResult = translationInfo.getTranslationResult();
CdsFeature cdsFeature = translationInfo.getCdsFeature();
if (translationResult != null && cdsFeature != null) {
String providedTranslation = cdsFeature.getTranslation();
new TranslationResultWriter(translationResult, providedTranslation).write(translationReportWriter);
String translationReport = translationReportWriter.toString();
StringWriter reportString = new StringWriter();
reportString.append("The results of the automatic translation are shown below.\n\n");
CompoundLocation<Location> compoundLocation = translationInfo.getCdsFeature().getLocations();
reportString.append("Feature location : ");
reportString.append(FeatureLocationWriter.renderCompoundLocation(compoundLocation)).append("\n");
reportString.append("Base count : ").append(Integer.toString(translationResult.getBaseCount()))
.append("\n");
reportString.append("Translation length : ")
.append(Integer.toString(translationResult.getTranslation().length())).append("\n\n");
reportString.append("Translation table info : ");
TranslationTable translationTable = translationInfo.getTranslationTable();
String translationTableName = "NOT SET";
String translationTableNumber = "NOT SET";
if (translationTable != null) {
translationTableName = translationTable.getName();
translationTableNumber = Integer.toString(translationTable.getNumber());
}
reportString.append("Table name - \"").append(translationTableName).append("\" ");
reportString.append("Table number - \"").append(translationTableNumber).append("\"\n\n");
if (translationReport != null && !translationReport.isEmpty()) {
reportString.append("The amino acid codes immediately below the dna triplets is the actual " +
"translation based on the information you provided.");
List<Qualifier> providedtranslations =
translationInfo.getCdsFeature().getQualifiers(Qualifier.TRANSLATION_QUALIFIER_NAME);
if (!providedtranslations.isEmpty()) {
reportString
.append("\nThe second row of amino acid codes is the translation you provided in the CDS " +
"feature. These translations should match.");
}
reportString.append("\n\n");
reportString.append(translationReport);
} else {
reportString.append("No translation made\n\n");
}
/**
* set in all messages and the validation result - used differently in webapp to the command line tool
*/
cdsCheckResult.setReportMessage(reportString.toString());
for (ValidationMessage message : cdsCheckResult.getMessages()) {
message.setReportMessage(reportString.toString());
}
}
} catch (IOException e) {
e.printStackTrace();
}
} | java | public static void setCDSTranslationReport(ExtendedResult<CdsFeatureTranslationCheck.TranslationReportInfo> cdsCheckResult) {
try {
CdsFeatureTranslationCheck.TranslationReportInfo translationInfo = cdsCheckResult.getExtension();
StringWriter translationReportWriter = new StringWriter();
TranslationResult translationResult = translationInfo.getTranslationResult();
CdsFeature cdsFeature = translationInfo.getCdsFeature();
if (translationResult != null && cdsFeature != null) {
String providedTranslation = cdsFeature.getTranslation();
new TranslationResultWriter(translationResult, providedTranslation).write(translationReportWriter);
String translationReport = translationReportWriter.toString();
StringWriter reportString = new StringWriter();
reportString.append("The results of the automatic translation are shown below.\n\n");
CompoundLocation<Location> compoundLocation = translationInfo.getCdsFeature().getLocations();
reportString.append("Feature location : ");
reportString.append(FeatureLocationWriter.renderCompoundLocation(compoundLocation)).append("\n");
reportString.append("Base count : ").append(Integer.toString(translationResult.getBaseCount()))
.append("\n");
reportString.append("Translation length : ")
.append(Integer.toString(translationResult.getTranslation().length())).append("\n\n");
reportString.append("Translation table info : ");
TranslationTable translationTable = translationInfo.getTranslationTable();
String translationTableName = "NOT SET";
String translationTableNumber = "NOT SET";
if (translationTable != null) {
translationTableName = translationTable.getName();
translationTableNumber = Integer.toString(translationTable.getNumber());
}
reportString.append("Table name - \"").append(translationTableName).append("\" ");
reportString.append("Table number - \"").append(translationTableNumber).append("\"\n\n");
if (translationReport != null && !translationReport.isEmpty()) {
reportString.append("The amino acid codes immediately below the dna triplets is the actual " +
"translation based on the information you provided.");
List<Qualifier> providedtranslations =
translationInfo.getCdsFeature().getQualifiers(Qualifier.TRANSLATION_QUALIFIER_NAME);
if (!providedtranslations.isEmpty()) {
reportString
.append("\nThe second row of amino acid codes is the translation you provided in the CDS " +
"feature. These translations should match.");
}
reportString.append("\n\n");
reportString.append(translationReport);
} else {
reportString.append("No translation made\n\n");
}
/**
* set in all messages and the validation result - used differently in webapp to the command line tool
*/
cdsCheckResult.setReportMessage(reportString.toString());
for (ValidationMessage message : cdsCheckResult.getMessages()) {
message.setReportMessage(reportString.toString());
}
}
} catch (IOException e) {
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"setCDSTranslationReport",
"(",
"ExtendedResult",
"<",
"CdsFeatureTranslationCheck",
".",
"TranslationReportInfo",
">",
"cdsCheckResult",
")",
"{",
"try",
"{",
"CdsFeatureTranslationCheck",
".",
"TranslationReportInfo",
"translationInfo",
"=",
"cdsCheckResult",
".",
"getExtension",
"(",
")",
";",
"StringWriter",
"translationReportWriter",
"=",
"new",
"StringWriter",
"(",
")",
";",
"TranslationResult",
"translationResult",
"=",
"translationInfo",
".",
"getTranslationResult",
"(",
")",
";",
"CdsFeature",
"cdsFeature",
"=",
"translationInfo",
".",
"getCdsFeature",
"(",
")",
";",
"if",
"(",
"translationResult",
"!=",
"null",
"&&",
"cdsFeature",
"!=",
"null",
")",
"{",
"String",
"providedTranslation",
"=",
"cdsFeature",
".",
"getTranslation",
"(",
")",
";",
"new",
"TranslationResultWriter",
"(",
"translationResult",
",",
"providedTranslation",
")",
".",
"write",
"(",
"translationReportWriter",
")",
";",
"String",
"translationReport",
"=",
"translationReportWriter",
".",
"toString",
"(",
")",
";",
"StringWriter",
"reportString",
"=",
"new",
"StringWriter",
"(",
")",
";",
"reportString",
".",
"append",
"(",
"\"The results of the automatic translation are shown below.\\n\\n\"",
")",
";",
"CompoundLocation",
"<",
"Location",
">",
"compoundLocation",
"=",
"translationInfo",
".",
"getCdsFeature",
"(",
")",
".",
"getLocations",
"(",
")",
";",
"reportString",
".",
"append",
"(",
"\"Feature location : \"",
")",
";",
"reportString",
".",
"append",
"(",
"FeatureLocationWriter",
".",
"renderCompoundLocation",
"(",
"compoundLocation",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"reportString",
".",
"append",
"(",
"\"Base count : \"",
")",
".",
"append",
"(",
"Integer",
".",
"toString",
"(",
"translationResult",
".",
"getBaseCount",
"(",
")",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"reportString",
".",
"append",
"(",
"\"Translation length : \"",
")",
".",
"append",
"(",
"Integer",
".",
"toString",
"(",
"translationResult",
".",
"getTranslation",
"(",
")",
".",
"length",
"(",
")",
")",
")",
".",
"append",
"(",
"\"\\n\\n\"",
")",
";",
"reportString",
".",
"append",
"(",
"\"Translation table info : \"",
")",
";",
"TranslationTable",
"translationTable",
"=",
"translationInfo",
".",
"getTranslationTable",
"(",
")",
";",
"String",
"translationTableName",
"=",
"\"NOT SET\"",
";",
"String",
"translationTableNumber",
"=",
"\"NOT SET\"",
";",
"if",
"(",
"translationTable",
"!=",
"null",
")",
"{",
"translationTableName",
"=",
"translationTable",
".",
"getName",
"(",
")",
";",
"translationTableNumber",
"=",
"Integer",
".",
"toString",
"(",
"translationTable",
".",
"getNumber",
"(",
")",
")",
";",
"}",
"reportString",
".",
"append",
"(",
"\"Table name - \\\"\"",
")",
".",
"append",
"(",
"translationTableName",
")",
".",
"append",
"(",
"\"\\\" \"",
")",
";",
"reportString",
".",
"append",
"(",
"\"Table number - \\\"\"",
")",
".",
"append",
"(",
"translationTableNumber",
")",
".",
"append",
"(",
"\"\\\"\\n\\n\"",
")",
";",
"if",
"(",
"translationReport",
"!=",
"null",
"&&",
"!",
"translationReport",
".",
"isEmpty",
"(",
")",
")",
"{",
"reportString",
".",
"append",
"(",
"\"The amino acid codes immediately below the dna triplets is the actual \"",
"+",
"\"translation based on the information you provided.\"",
")",
";",
"List",
"<",
"Qualifier",
">",
"providedtranslations",
"=",
"translationInfo",
".",
"getCdsFeature",
"(",
")",
".",
"getQualifiers",
"(",
"Qualifier",
".",
"TRANSLATION_QUALIFIER_NAME",
")",
";",
"if",
"(",
"!",
"providedtranslations",
".",
"isEmpty",
"(",
")",
")",
"{",
"reportString",
".",
"append",
"(",
"\"\\nThe second row of amino acid codes is the translation you provided in the CDS \"",
"+",
"\"feature. These translations should match.\"",
")",
";",
"}",
"reportString",
".",
"append",
"(",
"\"\\n\\n\"",
")",
";",
"reportString",
".",
"append",
"(",
"translationReport",
")",
";",
"}",
"else",
"{",
"reportString",
".",
"append",
"(",
"\"No translation made\\n\\n\"",
")",
";",
"}",
"/**\n * set in all messages and the validation result - used differently in webapp to the command line tool\n */",
"cdsCheckResult",
".",
"setReportMessage",
"(",
"reportString",
".",
"toString",
"(",
")",
")",
";",
"for",
"(",
"ValidationMessage",
"message",
":",
"cdsCheckResult",
".",
"getMessages",
"(",
")",
")",
"{",
"message",
".",
"setReportMessage",
"(",
"reportString",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Takes all the messages in a CdsFeatureTranslationCheck ExtendedResult ValidationResult object and writes a
report for the CDS translation. Uses extra information from the ExtendedResult. Have put this here as it uses
Writers from the FF package and the embl-api-core package does not have access to these.
@param cdsCheckResult | [
"Takes",
"all",
"the",
"messages",
"in",
"a",
"CdsFeatureTranslationCheck",
"ExtendedResult",
"ValidationResult",
"object",
"and",
"writes",
"a",
"report",
"for",
"the",
"CDS",
"translation",
".",
"Uses",
"extra",
"information",
"from",
"the",
"ExtendedResult",
".",
"Have",
"put",
"this",
"here",
"as",
"it",
"uses",
"Writers",
"from",
"the",
"FF",
"package",
"and",
"the",
"embl",
"-",
"api",
"-",
"core",
"package",
"does",
"not",
"have",
"access",
"to",
"these",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/validation/FlatFileValidations.java#L116-L183 |
137,810 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/template/CSVWriter.java | CSVWriter.writeTemplateSpreadsheetDownloadFile | public void writeTemplateSpreadsheetDownloadFile(List<TemplateTokenInfo> tokenNames,
TemplateVariablesSet variablesSet,
String filePath) throws TemplateException {
prepareWriter(filePath);
writeDownloadSpreadsheetHeader(tokenNames);
for (int i = 1; i < variablesSet.getEntryCount() + 1; i++) {
TemplateVariables entryVariables = variablesSet.getEntryValues(i);
writeSpreadsheetVariableRow(tokenNames, i, entryVariables);
}
flushAndCloseWriter();
} | java | public void writeTemplateSpreadsheetDownloadFile(List<TemplateTokenInfo> tokenNames,
TemplateVariablesSet variablesSet,
String filePath) throws TemplateException {
prepareWriter(filePath);
writeDownloadSpreadsheetHeader(tokenNames);
for (int i = 1; i < variablesSet.getEntryCount() + 1; i++) {
TemplateVariables entryVariables = variablesSet.getEntryValues(i);
writeSpreadsheetVariableRow(tokenNames, i, entryVariables);
}
flushAndCloseWriter();
} | [
"public",
"void",
"writeTemplateSpreadsheetDownloadFile",
"(",
"List",
"<",
"TemplateTokenInfo",
">",
"tokenNames",
",",
"TemplateVariablesSet",
"variablesSet",
",",
"String",
"filePath",
")",
"throws",
"TemplateException",
"{",
"prepareWriter",
"(",
"filePath",
")",
";",
"writeDownloadSpreadsheetHeader",
"(",
"tokenNames",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"variablesSet",
".",
"getEntryCount",
"(",
")",
"+",
"1",
";",
"i",
"++",
")",
"{",
"TemplateVariables",
"entryVariables",
"=",
"variablesSet",
".",
"getEntryValues",
"(",
"i",
")",
";",
"writeSpreadsheetVariableRow",
"(",
"tokenNames",
",",
"i",
",",
"entryVariables",
")",
";",
"}",
"flushAndCloseWriter",
"(",
")",
";",
"}"
] | Writes the download file for variables for spreadsheet import | [
"Writes",
"the",
"download",
"file",
"for",
"variables",
"for",
"spreadsheet",
"import"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/template/CSVWriter.java#L25-L38 |
137,811 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/template/CSVWriter.java | CSVWriter.writeLargeTemplateSpreadsheetDownloadFile | public void writeLargeTemplateSpreadsheetDownloadFile(List<TemplateTokenInfo> tokenNames,
int entryCount,
TemplateVariables constants,
String filePath) throws TemplateException {
prepareWriter(filePath);
writeDownloadSpreadsheetHeader(tokenNames);
for (int i = 1; i < entryCount + 1; i++) {
writeSpreadsheetVariableRow(tokenNames, i, constants);
}
flushAndCloseWriter();
} | java | public void writeLargeTemplateSpreadsheetDownloadFile(List<TemplateTokenInfo> tokenNames,
int entryCount,
TemplateVariables constants,
String filePath) throws TemplateException {
prepareWriter(filePath);
writeDownloadSpreadsheetHeader(tokenNames);
for (int i = 1; i < entryCount + 1; i++) {
writeSpreadsheetVariableRow(tokenNames, i, constants);
}
flushAndCloseWriter();
} | [
"public",
"void",
"writeLargeTemplateSpreadsheetDownloadFile",
"(",
"List",
"<",
"TemplateTokenInfo",
">",
"tokenNames",
",",
"int",
"entryCount",
",",
"TemplateVariables",
"constants",
",",
"String",
"filePath",
")",
"throws",
"TemplateException",
"{",
"prepareWriter",
"(",
"filePath",
")",
";",
"writeDownloadSpreadsheetHeader",
"(",
"tokenNames",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"entryCount",
"+",
"1",
";",
"i",
"++",
")",
"{",
"writeSpreadsheetVariableRow",
"(",
"tokenNames",
",",
"i",
",",
"constants",
")",
";",
"}",
"flushAndCloseWriter",
"(",
")",
";",
"}"
] | Used to write spreadsheets where entry number exceeds the MEGABULK size. Does not use the variables map stored in
the database, just writes constants. | [
"Used",
"to",
"write",
"spreadsheets",
"where",
"entry",
"number",
"exceeds",
"the",
"MEGABULK",
"size",
".",
"Does",
"not",
"use",
"the",
"variables",
"map",
"stored",
"in",
"the",
"database",
"just",
"writes",
"constants",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/template/CSVWriter.java#L44-L57 |
137,812 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/template/CSVWriter.java | CSVWriter.writeDownloadSpreadsheetHeader | public void writeDownloadSpreadsheetHeader(List<TemplateTokenInfo> variableTokenNames) {
StringBuilder headerBuilder = new StringBuilder();
headerBuilder.append(UPLOAD_COMMENTS);
headerBuilder.append("\n");
for (TemplateTokenInfo tokenInfo : variableTokenNames) {
if (tokenInfo.getName().equals(TemplateProcessorConstants.COMMENTS_TOKEN)) {
headerBuilder.append("#The field '" + tokenInfo.getDisplayName() +
"' allows return characters. To add return characters add '<br>'; e.g. line1<br>line2");
headerBuilder.append("\n");
}
}
headerBuilder.append(HEADER_TOKEN);
headerBuilder.append(UPLOAD_DELIMITER);
for (TemplateTokenInfo variable : variableTokenNames) {
headerBuilder.append(variable.getDisplayName());
headerBuilder.append(UPLOAD_DELIMITER);
}
String headerLine = headerBuilder.toString();
headerLine = headerLine.substring(0, headerLine.length() - 1);//get rid of trailing delimiter
this.lineWriter.println(headerLine);
} | java | public void writeDownloadSpreadsheetHeader(List<TemplateTokenInfo> variableTokenNames) {
StringBuilder headerBuilder = new StringBuilder();
headerBuilder.append(UPLOAD_COMMENTS);
headerBuilder.append("\n");
for (TemplateTokenInfo tokenInfo : variableTokenNames) {
if (tokenInfo.getName().equals(TemplateProcessorConstants.COMMENTS_TOKEN)) {
headerBuilder.append("#The field '" + tokenInfo.getDisplayName() +
"' allows return characters. To add return characters add '<br>'; e.g. line1<br>line2");
headerBuilder.append("\n");
}
}
headerBuilder.append(HEADER_TOKEN);
headerBuilder.append(UPLOAD_DELIMITER);
for (TemplateTokenInfo variable : variableTokenNames) {
headerBuilder.append(variable.getDisplayName());
headerBuilder.append(UPLOAD_DELIMITER);
}
String headerLine = headerBuilder.toString();
headerLine = headerLine.substring(0, headerLine.length() - 1);//get rid of trailing delimiter
this.lineWriter.println(headerLine);
} | [
"public",
"void",
"writeDownloadSpreadsheetHeader",
"(",
"List",
"<",
"TemplateTokenInfo",
">",
"variableTokenNames",
")",
"{",
"StringBuilder",
"headerBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"headerBuilder",
".",
"append",
"(",
"UPLOAD_COMMENTS",
")",
";",
"headerBuilder",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"for",
"(",
"TemplateTokenInfo",
"tokenInfo",
":",
"variableTokenNames",
")",
"{",
"if",
"(",
"tokenInfo",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"TemplateProcessorConstants",
".",
"COMMENTS_TOKEN",
")",
")",
"{",
"headerBuilder",
".",
"append",
"(",
"\"#The field '\"",
"+",
"tokenInfo",
".",
"getDisplayName",
"(",
")",
"+",
"\"' allows return characters. To add return characters add '<br>'; e.g. line1<br>line2\"",
")",
";",
"headerBuilder",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"}",
"headerBuilder",
".",
"append",
"(",
"HEADER_TOKEN",
")",
";",
"headerBuilder",
".",
"append",
"(",
"UPLOAD_DELIMITER",
")",
";",
"for",
"(",
"TemplateTokenInfo",
"variable",
":",
"variableTokenNames",
")",
"{",
"headerBuilder",
".",
"append",
"(",
"variable",
".",
"getDisplayName",
"(",
")",
")",
";",
"headerBuilder",
".",
"append",
"(",
"UPLOAD_DELIMITER",
")",
";",
"}",
"String",
"headerLine",
"=",
"headerBuilder",
".",
"toString",
"(",
")",
";",
"headerLine",
"=",
"headerLine",
".",
"substring",
"(",
"0",
",",
"headerLine",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"//get rid of trailing delimiter",
"this",
".",
"lineWriter",
".",
"println",
"(",
"headerLine",
")",
";",
"}"
] | writes the header for the example download spreadsheet
@param variableTokenNames | [
"writes",
"the",
"header",
"for",
"the",
"example",
"download",
"spreadsheet"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/template/CSVWriter.java#L95-L118 |
137,813 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/tca3d/OmsTca3d.java | OmsTca3d.process | @Execute
public void process() throws Exception {
if (!concatOr(outTca == null, doReset)) {
return;
}
checkNull(inPit, inFlow);
HashMap<String, Double> regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inPit);
cols = regionMap.get(CoverageUtilities.COLS).intValue();
rows = regionMap.get(CoverageUtilities.ROWS).intValue();
xRes = regionMap.get(CoverageUtilities.XRES);
yRes = regionMap.get(CoverageUtilities.YRES);
RenderedImage pitfillerRI = inPit.getRenderedImage();
WritableRaster pitWR = CoverageUtilities.renderedImage2WritableRaster(pitfillerRI, false);
RenderedImage flowRI = inFlow.getRenderedImage();
WritableRaster flowWR = CoverageUtilities.renderedImage2WritableRaster(flowRI, true);
// Initialize new RasterData and set value
WritableRaster tca3dWR = CoverageUtilities.createWritableRaster(cols, rows, null, null, doubleNovalue);
tca3dWR = area3d(pitWR, flowWR, tca3dWR);
outTca = CoverageUtilities.buildCoverage("tca3d", tca3dWR, regionMap, //$NON-NLS-1$
inPit.getCoordinateReferenceSystem());
} | java | @Execute
public void process() throws Exception {
if (!concatOr(outTca == null, doReset)) {
return;
}
checkNull(inPit, inFlow);
HashMap<String, Double> regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inPit);
cols = regionMap.get(CoverageUtilities.COLS).intValue();
rows = regionMap.get(CoverageUtilities.ROWS).intValue();
xRes = regionMap.get(CoverageUtilities.XRES);
yRes = regionMap.get(CoverageUtilities.YRES);
RenderedImage pitfillerRI = inPit.getRenderedImage();
WritableRaster pitWR = CoverageUtilities.renderedImage2WritableRaster(pitfillerRI, false);
RenderedImage flowRI = inFlow.getRenderedImage();
WritableRaster flowWR = CoverageUtilities.renderedImage2WritableRaster(flowRI, true);
// Initialize new RasterData and set value
WritableRaster tca3dWR = CoverageUtilities.createWritableRaster(cols, rows, null, null, doubleNovalue);
tca3dWR = area3d(pitWR, flowWR, tca3dWR);
outTca = CoverageUtilities.buildCoverage("tca3d", tca3dWR, regionMap, //$NON-NLS-1$
inPit.getCoordinateReferenceSystem());
} | [
"@",
"Execute",
"public",
"void",
"process",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"concatOr",
"(",
"outTca",
"==",
"null",
",",
"doReset",
")",
")",
"{",
"return",
";",
"}",
"checkNull",
"(",
"inPit",
",",
"inFlow",
")",
";",
"HashMap",
"<",
"String",
",",
"Double",
">",
"regionMap",
"=",
"CoverageUtilities",
".",
"getRegionParamsFromGridCoverage",
"(",
"inPit",
")",
";",
"cols",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"COLS",
")",
".",
"intValue",
"(",
")",
";",
"rows",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"ROWS",
")",
".",
"intValue",
"(",
")",
";",
"xRes",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"XRES",
")",
";",
"yRes",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"YRES",
")",
";",
"RenderedImage",
"pitfillerRI",
"=",
"inPit",
".",
"getRenderedImage",
"(",
")",
";",
"WritableRaster",
"pitWR",
"=",
"CoverageUtilities",
".",
"renderedImage2WritableRaster",
"(",
"pitfillerRI",
",",
"false",
")",
";",
"RenderedImage",
"flowRI",
"=",
"inFlow",
".",
"getRenderedImage",
"(",
")",
";",
"WritableRaster",
"flowWR",
"=",
"CoverageUtilities",
".",
"renderedImage2WritableRaster",
"(",
"flowRI",
",",
"true",
")",
";",
"// Initialize new RasterData and set value",
"WritableRaster",
"tca3dWR",
"=",
"CoverageUtilities",
".",
"createWritableRaster",
"(",
"cols",
",",
"rows",
",",
"null",
",",
"null",
",",
"doubleNovalue",
")",
";",
"tca3dWR",
"=",
"area3d",
"(",
"pitWR",
",",
"flowWR",
",",
"tca3dWR",
")",
";",
"outTca",
"=",
"CoverageUtilities",
".",
"buildCoverage",
"(",
"\"tca3d\"",
",",
"tca3dWR",
",",
"regionMap",
",",
"//$NON-NLS-1$",
"inPit",
".",
"getCoordinateReferenceSystem",
"(",
")",
")",
";",
"}"
] | Calculates total contributing areas
@throws Exception | [
"Calculates",
"total",
"contributing",
"areas"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/tca3d/OmsTca3d.java#L97-L121 |
137,814 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgSeqend.java | DwgSeqend.readDwgSeqendV15 | public void readDwgSeqendV15(int[] data, int offset) throws Exception {
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
bitPos = readObjectTailV15(data, bitPos);
} | java | public void readDwgSeqendV15(int[] data, int offset) throws Exception {
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
bitPos = readObjectTailV15(data, bitPos);
} | [
"public",
"void",
"readDwgSeqendV15",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"throws",
"Exception",
"{",
"int",
"bitPos",
"=",
"offset",
";",
"bitPos",
"=",
"readObjectHeaderV15",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"readObjectTailV15",
"(",
"data",
",",
"bitPos",
")",
";",
"}"
] | Read a Seqend in the DWG format Version 15
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines. | [
"Read",
"a",
"Seqend",
"in",
"the",
"DWG",
"format",
"Version",
"15"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgSeqend.java#L38-L42 |
137,815 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/network/PfafstetterNumber.java | PfafstetterNumber.isDownStreamOf | public boolean isDownStreamOf(PfafstetterNumber pfafstetterNumber) {
/*
* all the upstreams will have same numbers until the last dot
*/
int lastDot = pfafstetterNumberString.lastIndexOf('.');
String pre = pfafstetterNumberString.substring(0, lastDot + 1);
String lastNum = pfafstetterNumberString.substring(lastDot + 1, pfafstetterNumberString
.length());
int lastNumInt = Integer.parseInt(lastNum);
if (lastNumInt % 2 == 0) {
// it has to be the last piece of a river, therefore no piece contained
return false;
} else {
/*
* check if the passed one is upstream
*/
String pfaff = pfafstetterNumber.toString();
if (pfaff.startsWith(pre)) {
// search for all those with a higher next number
String lastPart = pfaff.substring(lastDot + 1, pfaff.length());
String lastPartParent = StringUtilities.REGEX_PATTER_DOT.split(lastPart)[0];
if (Integer.parseInt(lastPartParent) >= lastNumInt) {
return true;
}
}
}
return false;
} | java | public boolean isDownStreamOf(PfafstetterNumber pfafstetterNumber) {
/*
* all the upstreams will have same numbers until the last dot
*/
int lastDot = pfafstetterNumberString.lastIndexOf('.');
String pre = pfafstetterNumberString.substring(0, lastDot + 1);
String lastNum = pfafstetterNumberString.substring(lastDot + 1, pfafstetterNumberString
.length());
int lastNumInt = Integer.parseInt(lastNum);
if (lastNumInt % 2 == 0) {
// it has to be the last piece of a river, therefore no piece contained
return false;
} else {
/*
* check if the passed one is upstream
*/
String pfaff = pfafstetterNumber.toString();
if (pfaff.startsWith(pre)) {
// search for all those with a higher next number
String lastPart = pfaff.substring(lastDot + 1, pfaff.length());
String lastPartParent = StringUtilities.REGEX_PATTER_DOT.split(lastPart)[0];
if (Integer.parseInt(lastPartParent) >= lastNumInt) {
return true;
}
}
}
return false;
} | [
"public",
"boolean",
"isDownStreamOf",
"(",
"PfafstetterNumber",
"pfafstetterNumber",
")",
"{",
"/*\n * all the upstreams will have same numbers until the last dot\n */",
"int",
"lastDot",
"=",
"pfafstetterNumberString",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"String",
"pre",
"=",
"pfafstetterNumberString",
".",
"substring",
"(",
"0",
",",
"lastDot",
"+",
"1",
")",
";",
"String",
"lastNum",
"=",
"pfafstetterNumberString",
".",
"substring",
"(",
"lastDot",
"+",
"1",
",",
"pfafstetterNumberString",
".",
"length",
"(",
")",
")",
";",
"int",
"lastNumInt",
"=",
"Integer",
".",
"parseInt",
"(",
"lastNum",
")",
";",
"if",
"(",
"lastNumInt",
"%",
"2",
"==",
"0",
")",
"{",
"// it has to be the last piece of a river, therefore no piece contained",
"return",
"false",
";",
"}",
"else",
"{",
"/*\n * check if the passed one is upstream\n */",
"String",
"pfaff",
"=",
"pfafstetterNumber",
".",
"toString",
"(",
")",
";",
"if",
"(",
"pfaff",
".",
"startsWith",
"(",
"pre",
")",
")",
"{",
"// search for all those with a higher next number",
"String",
"lastPart",
"=",
"pfaff",
".",
"substring",
"(",
"lastDot",
"+",
"1",
",",
"pfaff",
".",
"length",
"(",
")",
")",
";",
"String",
"lastPartParent",
"=",
"StringUtilities",
".",
"REGEX_PATTER_DOT",
".",
"split",
"(",
"lastPart",
")",
"[",
"0",
"]",
";",
"if",
"(",
"Integer",
".",
"parseInt",
"(",
"lastPartParent",
")",
">=",
"lastNumInt",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if the actual pfafstetter object is downstream or not of the passed argument
@param pfafstetterNumber the pfafstetterNumber to check against.
@return true if the actual obj is downstream of the passed one. | [
"Checks",
"if",
"the",
"actual",
"pfafstetter",
"object",
"is",
"downstream",
"or",
"not",
"of",
"the",
"passed",
"argument"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/network/PfafstetterNumber.java#L99-L127 |
137,816 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/network/PfafstetterNumber.java | PfafstetterNumber.areConnectedUpstream | public synchronized static boolean areConnectedUpstream(PfafstetterNumber p1,
PfafstetterNumber p2) {
List<Integer> p1OrdersList = p1.getOrdersList();
List<Integer> p2OrdersList = p2.getOrdersList();
int levelDiff = p1OrdersList.size() - p2OrdersList.size();
if (levelDiff == 0) {
if (p1.toStringUpToLastLevel().equals(p2.toStringUpToLastLevel())) {
int p1Last = p1OrdersList.get(p1OrdersList.size() - 1);
int p2Last = p2OrdersList.get(p2OrdersList.size() - 1);
if (p2Last == p1Last + 1 || p2Last == p1Last + 2) {
return p1Last % 2 != 0;
}
}
} else if (levelDiff == -1) {
if (p2.toString().startsWith(p1.toStringUpToLastLevel())) {
int p2Last = p2OrdersList.get(p2OrdersList.size() - 1);
if (p2Last != 1) {
return false;
}
int p1Last = p1OrdersList.get(p1OrdersList.size() - 1);
int p2LastMinus1 = p2OrdersList.get(p2OrdersList.size() - 2);
if (p2LastMinus1 == p1Last + 1 || p2Last == p1Last + 2) {
return p1Last % 2 != 0;
}
}
}
return false;
} | java | public synchronized static boolean areConnectedUpstream(PfafstetterNumber p1,
PfafstetterNumber p2) {
List<Integer> p1OrdersList = p1.getOrdersList();
List<Integer> p2OrdersList = p2.getOrdersList();
int levelDiff = p1OrdersList.size() - p2OrdersList.size();
if (levelDiff == 0) {
if (p1.toStringUpToLastLevel().equals(p2.toStringUpToLastLevel())) {
int p1Last = p1OrdersList.get(p1OrdersList.size() - 1);
int p2Last = p2OrdersList.get(p2OrdersList.size() - 1);
if (p2Last == p1Last + 1 || p2Last == p1Last + 2) {
return p1Last % 2 != 0;
}
}
} else if (levelDiff == -1) {
if (p2.toString().startsWith(p1.toStringUpToLastLevel())) {
int p2Last = p2OrdersList.get(p2OrdersList.size() - 1);
if (p2Last != 1) {
return false;
}
int p1Last = p1OrdersList.get(p1OrdersList.size() - 1);
int p2LastMinus1 = p2OrdersList.get(p2OrdersList.size() - 2);
if (p2LastMinus1 == p1Last + 1 || p2Last == p1Last + 2) {
return p1Last % 2 != 0;
}
}
}
return false;
} | [
"public",
"synchronized",
"static",
"boolean",
"areConnectedUpstream",
"(",
"PfafstetterNumber",
"p1",
",",
"PfafstetterNumber",
"p2",
")",
"{",
"List",
"<",
"Integer",
">",
"p1OrdersList",
"=",
"p1",
".",
"getOrdersList",
"(",
")",
";",
"List",
"<",
"Integer",
">",
"p2OrdersList",
"=",
"p2",
".",
"getOrdersList",
"(",
")",
";",
"int",
"levelDiff",
"=",
"p1OrdersList",
".",
"size",
"(",
")",
"-",
"p2OrdersList",
".",
"size",
"(",
")",
";",
"if",
"(",
"levelDiff",
"==",
"0",
")",
"{",
"if",
"(",
"p1",
".",
"toStringUpToLastLevel",
"(",
")",
".",
"equals",
"(",
"p2",
".",
"toStringUpToLastLevel",
"(",
")",
")",
")",
"{",
"int",
"p1Last",
"=",
"p1OrdersList",
".",
"get",
"(",
"p1OrdersList",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"int",
"p2Last",
"=",
"p2OrdersList",
".",
"get",
"(",
"p2OrdersList",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"p2Last",
"==",
"p1Last",
"+",
"1",
"||",
"p2Last",
"==",
"p1Last",
"+",
"2",
")",
"{",
"return",
"p1Last",
"%",
"2",
"!=",
"0",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"levelDiff",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"p2",
".",
"toString",
"(",
")",
".",
"startsWith",
"(",
"p1",
".",
"toStringUpToLastLevel",
"(",
")",
")",
")",
"{",
"int",
"p2Last",
"=",
"p2OrdersList",
".",
"get",
"(",
"p2OrdersList",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"p2Last",
"!=",
"1",
")",
"{",
"return",
"false",
";",
"}",
"int",
"p1Last",
"=",
"p1OrdersList",
".",
"get",
"(",
"p1OrdersList",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"int",
"p2LastMinus1",
"=",
"p2OrdersList",
".",
"get",
"(",
"p2OrdersList",
".",
"size",
"(",
")",
"-",
"2",
")",
";",
"if",
"(",
"p2LastMinus1",
"==",
"p1Last",
"+",
"1",
"||",
"p2Last",
"==",
"p1Last",
"+",
"2",
")",
"{",
"return",
"p1Last",
"%",
"2",
"!=",
"0",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if two pfafstetter are connected upstream, i.e. p1 is more downstream than p2
@param p1 the first pfafstetter.
@param p2 the second pfafstetter.
@return <code>true</code> if the first is more upstream than the second. | [
"Checks",
"if",
"two",
"pfafstetter",
"are",
"connected",
"upstream",
"i",
".",
"e",
".",
"p1",
"is",
"more",
"downstream",
"than",
"p2"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/network/PfafstetterNumber.java#L174-L203 |
137,817 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.setFeatureField | private Number setFeatureField( SimpleFeature pipe, String key ) {
Number field = ((Number) pipe.getAttribute(key));
if (field == null) {
pm.errorMessage(msg.message("trentoP.error.number") + key);
throw new IllegalArgumentException(msg.message("trentoP.error.number") + key);
}
// return the Number
return field;
} | java | private Number setFeatureField( SimpleFeature pipe, String key ) {
Number field = ((Number) pipe.getAttribute(key));
if (field == null) {
pm.errorMessage(msg.message("trentoP.error.number") + key);
throw new IllegalArgumentException(msg.message("trentoP.error.number") + key);
}
// return the Number
return field;
} | [
"private",
"Number",
"setFeatureField",
"(",
"SimpleFeature",
"pipe",
",",
"String",
"key",
")",
"{",
"Number",
"field",
"=",
"(",
"(",
"Number",
")",
"pipe",
".",
"getAttribute",
"(",
"key",
")",
")",
";",
"if",
"(",
"field",
"==",
"null",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.number\"",
")",
"+",
"key",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.number\"",
")",
"+",
"key",
")",
";",
"}",
"// return the Number",
"return",
"field",
";",
"}"
] | Check if there is the field in a SimpleFeature and if it's a Number.
@param pipe
the feature.
@param key
the key string of the field.
@return the Number associated at this key. | [
"Check",
"if",
"there",
"is",
"the",
"field",
"in",
"a",
"SimpleFeature",
"and",
"if",
"it",
"s",
"a",
"Number",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L576-L585 |
137,818 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.designPipe | public void designPipe( double[][] diameters, double tau, double g, double maxd, double c, StringBuilder strWarnings ) {
switch( this.pipeSectionType ) {
case 1:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
case 2:
designRectangularPipe(tau, g, maxd, c, strWarnings);
break;
case 3:
designTrapeziumPipe(tau, g, maxd, c, strWarnings);
break;
default:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
}
} | java | public void designPipe( double[][] diameters, double tau, double g, double maxd, double c, StringBuilder strWarnings ) {
switch( this.pipeSectionType ) {
case 1:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
case 2:
designRectangularPipe(tau, g, maxd, c, strWarnings);
break;
case 3:
designTrapeziumPipe(tau, g, maxd, c, strWarnings);
break;
default:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
}
} | [
"public",
"void",
"designPipe",
"(",
"double",
"[",
"]",
"[",
"]",
"diameters",
",",
"double",
"tau",
",",
"double",
"g",
",",
"double",
"maxd",
",",
"double",
"c",
",",
"StringBuilder",
"strWarnings",
")",
"{",
"switch",
"(",
"this",
".",
"pipeSectionType",
")",
"{",
"case",
"1",
":",
"designCircularPipe",
"(",
"diameters",
",",
"tau",
",",
"g",
",",
"maxd",
",",
"strWarnings",
")",
";",
"break",
";",
"case",
"2",
":",
"designRectangularPipe",
"(",
"tau",
",",
"g",
",",
"maxd",
",",
"c",
",",
"strWarnings",
")",
";",
"break",
";",
"case",
"3",
":",
"designTrapeziumPipe",
"(",
"tau",
",",
"g",
",",
"maxd",
",",
"c",
",",
"strWarnings",
")",
";",
"break",
";",
"default",
":",
"designCircularPipe",
"(",
"diameters",
",",
"tau",
",",
"g",
",",
"maxd",
",",
"strWarnings",
")",
";",
"break",
";",
"}",
"}"
] | Calculate the dimension of the pipes.
<p>
It switch between several section geometry.
</p>
@param diameters
matrix with the commercial diameters.
@param tau
tangential stress at the bottom of the pipe..
@param g
fill degree.
@param maxd
maximum diameter.
@param c
is a geometric expression b/h where h is the height and b base
(only for rectangular or trapezium shape). | [
"Calculate",
"the",
"dimension",
"of",
"the",
"pipes",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L608-L624 |
137,819 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.designCircularPipe | private void designCircularPipe( double[][] diameters, double tau, double g, double maxd, StringBuilder strWarnings )
{
/* Angolo di riempimento */
double newtheta;
/*
* [%] Pendenza naturale, calcolata in funzione dei dati geometrici
* della rete
*/
double naturalslope;
/* [cm] Diametro tubo */
double D;
/* [cm]Spessore tubo */
double[] dD = new double[1];
/* [%] Pendenza minima per il tratto che si sta dimensionando. */
double ms;
/*
* Dimensiona il diametro del tubo da adottare col criterio di
* autopulizia, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
newtheta = getDiameter(diameters, tau, g, dD, maxd, strWarnings);
/* [%] Pendenza del terreno */
naturalslope = METER2CM * (getInitialElevation() - getFinalElevation()) / getLenght();
/* [%] pendenza minima del tratto che si sta progettando. */
ms = getMinimumPipeSlope();
if (naturalslope < 0) {
/*
* Avvisa l'utente che il tratto che si sta progettando e in
* contropendenza
*/
strWarnings.append(msg.message("trentoP.warning.slope") + id);
}
/* La pendenza del terreno deve essere superiore a quella minima ms */
if (naturalslope < ms) {
naturalslope = ms;
}
/*
* Se la pendenza del terreno e maggiore di quella del tubo, allora la
* pendenza del tubo viene posta uguale a quella del terreno.
*/
if (naturalslope > pipeSlope) {
pipeSlope = (naturalslope);
/*
* Progetta la condotta assegnado una pendenza pari a quella del
* terreno, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
newtheta = getDiameterI(diameters, naturalslope, g, dD, maxd, strWarnings);
}
/* Diametro tubo [cm] */
D = diameter;
/* Velocita media nella sezione [m/s] */
meanSpeed = ((8 * discharge) / (CUBICMETER2LITER * D * D * (newtheta - sin(newtheta)) / METER2CMSQUARED));
/* Quota scavo all'inizio del tubo [m s.l.m.] */
depthInitialPipe = (getInitialElevation() - minimumDepth - (D + 2 * dD[0]) / METER2CM);
/*
* Quota dello scavo alla fine del tubo calcolata considerando la
* pendenza effettiva del tratto [m s.l.m.]
*/
depthFinalPipe = (depthInitialPipe - getLenght() * pipeSlope / METER2CM);
/* Quota pelo libero all'inizio del tubo [m s.l.m.] */
initialFreesurface = depthInitialPipe + emptyDegree * D / METER2CM + dD[0] / METER2CM;
/* Quota pelo libero all'inizio del tubo [m s.l.m.] */
finalFreesurface = depthFinalPipe + emptyDegree * D / METER2CM + dD[0] / METER2CM;
} | java | private void designCircularPipe( double[][] diameters, double tau, double g, double maxd, StringBuilder strWarnings )
{
/* Angolo di riempimento */
double newtheta;
/*
* [%] Pendenza naturale, calcolata in funzione dei dati geometrici
* della rete
*/
double naturalslope;
/* [cm] Diametro tubo */
double D;
/* [cm]Spessore tubo */
double[] dD = new double[1];
/* [%] Pendenza minima per il tratto che si sta dimensionando. */
double ms;
/*
* Dimensiona il diametro del tubo da adottare col criterio di
* autopulizia, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
newtheta = getDiameter(diameters, tau, g, dD, maxd, strWarnings);
/* [%] Pendenza del terreno */
naturalslope = METER2CM * (getInitialElevation() - getFinalElevation()) / getLenght();
/* [%] pendenza minima del tratto che si sta progettando. */
ms = getMinimumPipeSlope();
if (naturalslope < 0) {
/*
* Avvisa l'utente che il tratto che si sta progettando e in
* contropendenza
*/
strWarnings.append(msg.message("trentoP.warning.slope") + id);
}
/* La pendenza del terreno deve essere superiore a quella minima ms */
if (naturalslope < ms) {
naturalslope = ms;
}
/*
* Se la pendenza del terreno e maggiore di quella del tubo, allora la
* pendenza del tubo viene posta uguale a quella del terreno.
*/
if (naturalslope > pipeSlope) {
pipeSlope = (naturalslope);
/*
* Progetta la condotta assegnado una pendenza pari a quella del
* terreno, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
newtheta = getDiameterI(diameters, naturalslope, g, dD, maxd, strWarnings);
}
/* Diametro tubo [cm] */
D = diameter;
/* Velocita media nella sezione [m/s] */
meanSpeed = ((8 * discharge) / (CUBICMETER2LITER * D * D * (newtheta - sin(newtheta)) / METER2CMSQUARED));
/* Quota scavo all'inizio del tubo [m s.l.m.] */
depthInitialPipe = (getInitialElevation() - minimumDepth - (D + 2 * dD[0]) / METER2CM);
/*
* Quota dello scavo alla fine del tubo calcolata considerando la
* pendenza effettiva del tratto [m s.l.m.]
*/
depthFinalPipe = (depthInitialPipe - getLenght() * pipeSlope / METER2CM);
/* Quota pelo libero all'inizio del tubo [m s.l.m.] */
initialFreesurface = depthInitialPipe + emptyDegree * D / METER2CM + dD[0] / METER2CM;
/* Quota pelo libero all'inizio del tubo [m s.l.m.] */
finalFreesurface = depthFinalPipe + emptyDegree * D / METER2CM + dD[0] / METER2CM;
} | [
"private",
"void",
"designCircularPipe",
"(",
"double",
"[",
"]",
"[",
"]",
"diameters",
",",
"double",
"tau",
",",
"double",
"g",
",",
"double",
"maxd",
",",
"StringBuilder",
"strWarnings",
")",
"{",
"/* Angolo di riempimento */",
"double",
"newtheta",
";",
"/*\n * [%] Pendenza naturale, calcolata in funzione dei dati geometrici\n * della rete\n */",
"double",
"naturalslope",
";",
"/* [cm] Diametro tubo */",
"double",
"D",
";",
"/* [cm]Spessore tubo */",
"double",
"[",
"]",
"dD",
"=",
"new",
"double",
"[",
"1",
"]",
";",
"/* [%] Pendenza minima per il tratto che si sta dimensionando. */",
"double",
"ms",
";",
"/*\n * Dimensiona il diametro del tubo da adottare col criterio di\n * autopulizia, calcola altre grandezze correlate come la pendenza e il\n * grado di riempimento, e restituisce il riempimento effettivo nel\n * tratto progettato\n */",
"newtheta",
"=",
"getDiameter",
"(",
"diameters",
",",
"tau",
",",
"g",
",",
"dD",
",",
"maxd",
",",
"strWarnings",
")",
";",
"/* [%] Pendenza del terreno */",
"naturalslope",
"=",
"METER2CM",
"*",
"(",
"getInitialElevation",
"(",
")",
"-",
"getFinalElevation",
"(",
")",
")",
"/",
"getLenght",
"(",
")",
";",
"/* [%] pendenza minima del tratto che si sta progettando. */",
"ms",
"=",
"getMinimumPipeSlope",
"(",
")",
";",
"if",
"(",
"naturalslope",
"<",
"0",
")",
"{",
"/*\n * Avvisa l'utente che il tratto che si sta progettando e in\n * contropendenza\n */",
"strWarnings",
".",
"append",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.warning.slope\"",
")",
"+",
"id",
")",
";",
"}",
"/* La pendenza del terreno deve essere superiore a quella minima ms */",
"if",
"(",
"naturalslope",
"<",
"ms",
")",
"{",
"naturalslope",
"=",
"ms",
";",
"}",
"/*\n * Se la pendenza del terreno e maggiore di quella del tubo, allora la\n * pendenza del tubo viene posta uguale a quella del terreno.\n */",
"if",
"(",
"naturalslope",
">",
"pipeSlope",
")",
"{",
"pipeSlope",
"=",
"(",
"naturalslope",
")",
";",
"/*\n * Progetta la condotta assegnado una pendenza pari a quella del\n * terreno, calcola altre grandezze correlate come la pendenza e il\n * grado di riempimento, e restituisce il riempimento effettivo nel\n * tratto progettato\n */",
"newtheta",
"=",
"getDiameterI",
"(",
"diameters",
",",
"naturalslope",
",",
"g",
",",
"dD",
",",
"maxd",
",",
"strWarnings",
")",
";",
"}",
"/* Diametro tubo [cm] */",
"D",
"=",
"diameter",
";",
"/* Velocita media nella sezione [m/s] */",
"meanSpeed",
"=",
"(",
"(",
"8",
"*",
"discharge",
")",
"/",
"(",
"CUBICMETER2LITER",
"*",
"D",
"*",
"D",
"*",
"(",
"newtheta",
"-",
"sin",
"(",
"newtheta",
")",
")",
"/",
"METER2CMSQUARED",
")",
")",
";",
"/* Quota scavo all'inizio del tubo [m s.l.m.] */",
"depthInitialPipe",
"=",
"(",
"getInitialElevation",
"(",
")",
"-",
"minimumDepth",
"-",
"(",
"D",
"+",
"2",
"*",
"dD",
"[",
"0",
"]",
")",
"/",
"METER2CM",
")",
";",
"/*\n * Quota dello scavo alla fine del tubo calcolata considerando la\n * pendenza effettiva del tratto [m s.l.m.]\n */",
"depthFinalPipe",
"=",
"(",
"depthInitialPipe",
"-",
"getLenght",
"(",
")",
"*",
"pipeSlope",
"/",
"METER2CM",
")",
";",
"/* Quota pelo libero all'inizio del tubo [m s.l.m.] */",
"initialFreesurface",
"=",
"depthInitialPipe",
"+",
"emptyDegree",
"*",
"D",
"/",
"METER2CM",
"+",
"dD",
"[",
"0",
"]",
"/",
"METER2CM",
";",
"/* Quota pelo libero all'inizio del tubo [m s.l.m.] */",
"finalFreesurface",
"=",
"depthFinalPipe",
"+",
"emptyDegree",
"*",
"D",
"/",
"METER2CM",
"+",
"dD",
"[",
"0",
"]",
"/",
"METER2CM",
";",
"}"
] | Dimensiona la tubazione.
<p>
Chiama altre subroutine per il dimensionamento del diametro del tubo
circolare e calcola alcune grandezze correlate.
<ol>
<li>
Inanzittuto dimensiona il tubo chiamando la diameters. Quest'ultimasi
basa sul criterio di autopulizia della rete, e determina, mediante
chiamatead ulteriori funuzioni, tutte le grandezze necessarie (grado di
riempimento,angolo, ecc..)
<li>Dopodiche riprogetta il tratto (chiamata a get_diameter_i) imponendo
unapendenza pari a quella del terreno, qualora questa fosse superioe a
quellaprecedentemete calcolata.
<li>Inoltre ogni volta che dimensiona il tubo, design_pipe (o le altre
funzionida essa chiamate) calcola tutte le grandezze secondarie, ma
alquantofondamentali (quota dello scavo, pelo libero ecc..) e le registra
nellamatrice networkPipes.
<ol>
</p>
@param diameter
matrice dei possibili diametri.
@param tau
sforzo al fondo.
@param g
grado di riempimento.
@param maxd
massimo diametro
@param strWarnings
a string which collect all the warning messages. | [
"Dimensiona",
"la",
"tubazione",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L659-L729 |
137,820 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.getDiameter | private double getDiameter( double[][] diameters, double tau, double g, double[] dD, double maxd, StringBuilder strWarnings ) {
/* Pari a A * ( Rh ^1/6 ) */
double B;
/* Anglo formato dalla sezione bagnata */
double thta;
/* Diametro calcolato imponendo il criterio di autopulizia della rete */
double oldD;
/* [cm]Diametro commerciale */
double D = 0;
/* Costane */
double known;
/*
* [rad]Angolo formato dalla sezione bagnata, adottando un diametro
* commerciale
*/
double newtheta;
/*
* [cm] Nuovo raggio idraulico calcolato in funzione del diametro
* commerciale
*/
double newrh;
/* B=A(Rh^1/6) [m^13/6] */
B = (discharge * sqrt(WSPECIFICWEIGHT / tau)) / (CUBICMETER2LITER * getKs());
/* Angolo formato dalla sezione bagnata [rad] */
thta = 2 * acos(1 - 2 * g);
/* Diametro tubo [cm] */
oldD = TWO_TWENTYOVERTHIRTEEN * pow(B, SIXOVERTHIRTEEN)
/ (pow((1 - sin(thta) / thta), ONEOVERTHIRTEEN) * pow(thta - sin(thta), SIXOVERTHIRTEEN));
/*
* Se il diametro ottenuto e piu piccolo del diametro commerciale piu
* grande, allora lo approssimo per eccesso col diametro commerciale piu
* prossimo.
*/
if (oldD < diameters[diameters.length - 1][0]) {
int j = 0;
for( j = 0; j < diameters.length; j++ ) {
/* Diametro commerciale [cm] */
D = diameters[j][0];
if (D >= oldD)
break;
}
if (D < maxd) {
/*
* Scendendo verso valle i diametri usati non possono diventare
* piu piccoli
*/
D = maxd;
}
diameter = (D);
/* Spessore corrispondente al diametro commerciale scelto [cm] */
dD[0] = diameters[j][1];
known = (B * TWO_TENOVERTHREE) / pow(D / METER2CM, THIRTHEENOVERSIX);
/*
* Angolo formato dalla sezione bagnata considerando un diametro
* commerciale [rad]
*/
newtheta = Utility.thisBisection(thta, known, ONEOVERSIX, minG, accuracy, jMax, pm, strWarnings);
/*
* E ovvio che adottando un diametro commerciale piu grande di
* quello che sarebbe strettamente neccessario, il grado di
* riempimento non puo aumentare
*/
if (newtheta > thta) {
strWarnings.append(msg.message("trentoP.warning.bisection") + id);
}
}
/*
* se il diametro necessario e piu grande del massimo diametro
* commerciale disponibile, allora mantengo il risultato ottenuto senza
* nessuna approssimazione
*/
else {
D = oldD;
diameter = D; /* COSA SUCCEDE ALLO SPESSORE ??!! */
newtheta = thta;
}
/* Grado di riempimento del tubo */
emptyDegree = 0.5 * (1 - cos(newtheta / 2));
/* Rh [cm] */
newrh = 0.25 * D * (1 - sin(newtheta) / newtheta);
/* pendenza del tratto progettato [%] */
pipeSlope = (tau / (WSPECIFICWEIGHT * newrh) * METER2CMSQUARED);
return newtheta;
} | java | private double getDiameter( double[][] diameters, double tau, double g, double[] dD, double maxd, StringBuilder strWarnings ) {
/* Pari a A * ( Rh ^1/6 ) */
double B;
/* Anglo formato dalla sezione bagnata */
double thta;
/* Diametro calcolato imponendo il criterio di autopulizia della rete */
double oldD;
/* [cm]Diametro commerciale */
double D = 0;
/* Costane */
double known;
/*
* [rad]Angolo formato dalla sezione bagnata, adottando un diametro
* commerciale
*/
double newtheta;
/*
* [cm] Nuovo raggio idraulico calcolato in funzione del diametro
* commerciale
*/
double newrh;
/* B=A(Rh^1/6) [m^13/6] */
B = (discharge * sqrt(WSPECIFICWEIGHT / tau)) / (CUBICMETER2LITER * getKs());
/* Angolo formato dalla sezione bagnata [rad] */
thta = 2 * acos(1 - 2 * g);
/* Diametro tubo [cm] */
oldD = TWO_TWENTYOVERTHIRTEEN * pow(B, SIXOVERTHIRTEEN)
/ (pow((1 - sin(thta) / thta), ONEOVERTHIRTEEN) * pow(thta - sin(thta), SIXOVERTHIRTEEN));
/*
* Se il diametro ottenuto e piu piccolo del diametro commerciale piu
* grande, allora lo approssimo per eccesso col diametro commerciale piu
* prossimo.
*/
if (oldD < diameters[diameters.length - 1][0]) {
int j = 0;
for( j = 0; j < diameters.length; j++ ) {
/* Diametro commerciale [cm] */
D = diameters[j][0];
if (D >= oldD)
break;
}
if (D < maxd) {
/*
* Scendendo verso valle i diametri usati non possono diventare
* piu piccoli
*/
D = maxd;
}
diameter = (D);
/* Spessore corrispondente al diametro commerciale scelto [cm] */
dD[0] = diameters[j][1];
known = (B * TWO_TENOVERTHREE) / pow(D / METER2CM, THIRTHEENOVERSIX);
/*
* Angolo formato dalla sezione bagnata considerando un diametro
* commerciale [rad]
*/
newtheta = Utility.thisBisection(thta, known, ONEOVERSIX, minG, accuracy, jMax, pm, strWarnings);
/*
* E ovvio che adottando un diametro commerciale piu grande di
* quello che sarebbe strettamente neccessario, il grado di
* riempimento non puo aumentare
*/
if (newtheta > thta) {
strWarnings.append(msg.message("trentoP.warning.bisection") + id);
}
}
/*
* se il diametro necessario e piu grande del massimo diametro
* commerciale disponibile, allora mantengo il risultato ottenuto senza
* nessuna approssimazione
*/
else {
D = oldD;
diameter = D; /* COSA SUCCEDE ALLO SPESSORE ??!! */
newtheta = thta;
}
/* Grado di riempimento del tubo */
emptyDegree = 0.5 * (1 - cos(newtheta / 2));
/* Rh [cm] */
newrh = 0.25 * D * (1 - sin(newtheta) / newtheta);
/* pendenza del tratto progettato [%] */
pipeSlope = (tau / (WSPECIFICWEIGHT * newrh) * METER2CMSQUARED);
return newtheta;
} | [
"private",
"double",
"getDiameter",
"(",
"double",
"[",
"]",
"[",
"]",
"diameters",
",",
"double",
"tau",
",",
"double",
"g",
",",
"double",
"[",
"]",
"dD",
",",
"double",
"maxd",
",",
"StringBuilder",
"strWarnings",
")",
"{",
"/* Pari a A * ( Rh ^1/6 ) */",
"double",
"B",
";",
"/* Anglo formato dalla sezione bagnata */",
"double",
"thta",
";",
"/* Diametro calcolato imponendo il criterio di autopulizia della rete */",
"double",
"oldD",
";",
"/* [cm]Diametro commerciale */",
"double",
"D",
"=",
"0",
";",
"/* Costane */",
"double",
"known",
";",
"/*\n * [rad]Angolo formato dalla sezione bagnata, adottando un diametro\n * commerciale\n */",
"double",
"newtheta",
";",
"/*\n * [cm] Nuovo raggio idraulico calcolato in funzione del diametro\n * commerciale\n */",
"double",
"newrh",
";",
"/* B=A(Rh^1/6) [m^13/6] */",
"B",
"=",
"(",
"discharge",
"*",
"sqrt",
"(",
"WSPECIFICWEIGHT",
"/",
"tau",
")",
")",
"/",
"(",
"CUBICMETER2LITER",
"*",
"getKs",
"(",
")",
")",
";",
"/* Angolo formato dalla sezione bagnata [rad] */",
"thta",
"=",
"2",
"*",
"acos",
"(",
"1",
"-",
"2",
"*",
"g",
")",
";",
"/* Diametro tubo [cm] */",
"oldD",
"=",
"TWO_TWENTYOVERTHIRTEEN",
"*",
"pow",
"(",
"B",
",",
"SIXOVERTHIRTEEN",
")",
"/",
"(",
"pow",
"(",
"(",
"1",
"-",
"sin",
"(",
"thta",
")",
"/",
"thta",
")",
",",
"ONEOVERTHIRTEEN",
")",
"*",
"pow",
"(",
"thta",
"-",
"sin",
"(",
"thta",
")",
",",
"SIXOVERTHIRTEEN",
")",
")",
";",
"/*\n * Se il diametro ottenuto e piu piccolo del diametro commerciale piu\n * grande, allora lo approssimo per eccesso col diametro commerciale piu\n * prossimo.\n */",
"if",
"(",
"oldD",
"<",
"diameters",
"[",
"diameters",
".",
"length",
"-",
"1",
"]",
"[",
"0",
"]",
")",
"{",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"diameters",
".",
"length",
";",
"j",
"++",
")",
"{",
"/* Diametro commerciale [cm] */",
"D",
"=",
"diameters",
"[",
"j",
"]",
"[",
"0",
"]",
";",
"if",
"(",
"D",
">=",
"oldD",
")",
"break",
";",
"}",
"if",
"(",
"D",
"<",
"maxd",
")",
"{",
"/*\n * Scendendo verso valle i diametri usati non possono diventare\n * piu piccoli\n */",
"D",
"=",
"maxd",
";",
"}",
"diameter",
"=",
"(",
"D",
")",
";",
"/* Spessore corrispondente al diametro commerciale scelto [cm] */",
"dD",
"[",
"0",
"]",
"=",
"diameters",
"[",
"j",
"]",
"[",
"1",
"]",
";",
"known",
"=",
"(",
"B",
"*",
"TWO_TENOVERTHREE",
")",
"/",
"pow",
"(",
"D",
"/",
"METER2CM",
",",
"THIRTHEENOVERSIX",
")",
";",
"/*\n * Angolo formato dalla sezione bagnata considerando un diametro\n * commerciale [rad]\n */",
"newtheta",
"=",
"Utility",
".",
"thisBisection",
"(",
"thta",
",",
"known",
",",
"ONEOVERSIX",
",",
"minG",
",",
"accuracy",
",",
"jMax",
",",
"pm",
",",
"strWarnings",
")",
";",
"/*\n * E ovvio che adottando un diametro commerciale piu grande di\n * quello che sarebbe strettamente neccessario, il grado di\n * riempimento non puo aumentare\n */",
"if",
"(",
"newtheta",
">",
"thta",
")",
"{",
"strWarnings",
".",
"append",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.warning.bisection\"",
")",
"+",
"id",
")",
";",
"}",
"}",
"/*\n * se il diametro necessario e piu grande del massimo diametro\n * commerciale disponibile, allora mantengo il risultato ottenuto senza\n * nessuna approssimazione\n */",
"else",
"{",
"D",
"=",
"oldD",
";",
"diameter",
"=",
"D",
";",
"/* COSA SUCCEDE ALLO SPESSORE ??!! */",
"newtheta",
"=",
"thta",
";",
"}",
"/* Grado di riempimento del tubo */",
"emptyDegree",
"=",
"0.5",
"*",
"(",
"1",
"-",
"cos",
"(",
"newtheta",
"/",
"2",
")",
")",
";",
"/* Rh [cm] */",
"newrh",
"=",
"0.25",
"*",
"D",
"*",
"(",
"1",
"-",
"sin",
"(",
"newtheta",
")",
"/",
"newtheta",
")",
";",
"/* pendenza del tratto progettato [%] */",
"pipeSlope",
"=",
"(",
"tau",
"/",
"(",
"WSPECIFICWEIGHT",
"*",
"newrh",
")",
"*",
"METER2CMSQUARED",
")",
";",
"return",
"newtheta",
";",
"}"
] | Dimensiona il tubo, imponendo uno sforzo tangenziale al fondo.
<p>
<ol>
<li>Calcola l'angolo theta in funzione di g.
<li>Nota la portata di progetto del tratto considerato, determina il
diametro oldD (adottando una pendenza che garantisca l'autopulizia).
<li>Successivamente oldD viene approssimato al diametro commerciale piu
vicino, letto dalla martice diametrs. Lo spessore adottato, anche esso
letto dalla matrice dei diametri, viene assegnato al puntatore dD. Mentre
la varabile maxd fa in modo che andando verso valle i diametri utilizzati
possano solo aumentare.
<li>A questo punto la get_diameter() ricalcola il nuovo valore
dell'angolo theta, chiamando la funzione this_bisection(), theta deve
risultare piu piccolo.
<li>Se invece oldD risulta maggiore del diametro commerciale piu grande
disponibile, allora si mantiene il suo valore.
<li>Infine calcola il grado di riempimento e pendenza del tratto a
partire dal raggio idraulico, e li registra nella matrice networkPipes.
<ol>
</p>
@param diametrs
matrice che contiene i diametri e spessori commerciali.
@param tau
[Pa] Sforzo tangenziale al fondo che garantisca l'autopulizia
della rete
@param dD
@param g
Grado di riempimento da considerare nella progettazione della
rete
@param maxd
Diamtetro o altezza piu' grande adottato nei tratti piu' a
monte
@param strWarnings
a string which collect all the warning messages. | [
"Dimensiona",
"il",
"tubo",
"imponendo",
"uno",
"sforzo",
"tangenziale",
"al",
"fondo",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L770-L861 |
137,821 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.designTrapeziumPipe | private void designTrapeziumPipe( double tau, double g, double maxd, double c, StringBuilder strWarnings ) {
/* [cm] Base della sezione effettivamente adottata. */
double base;
/*
* [%] Pendenza naturale, calcolata in funzione dei dati geometrici
* della rete
*/
double naturalSlope;
/* [cm] Altezza del canale trapezoidale. */
double D;
/*
* [%] Pendenza minima da adottare per il tratto che si sta
* dimensionando.
*/
double ms;
/* DUE FORMULE */
/*
* Dimensiona il diametro del tubo da adottare col criterio di
* autopulizia, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
base = getHeight2(tau, g, maxd, c);
/* [%] pendenza minima per il tratto che si sta dimensionando. */
ms = getMinimumPipeSlope();
/* [%] Pendenza del terreno */
naturalSlope = METER2CM * (initialElevation - finalElevation) / lenght;
/*
* Avvisa l'utente che il tratto che si sta progettando e in
* contropendenza
*/
if (naturalSlope < 0) {
strWarnings.append(msg.message("trentoP.warning.slope") + id);
}
/* La pendenza del terreno deve essere superiore a quella minima ms */
if (naturalSlope < ms) {
naturalSlope = ms;
}
/*
* Se la pendenza del terreno e maggiore di quella del tubo, allora la
* pendenza del tubo viene posta uguale a quella del terreno.
*/
if (naturalSlope > pipeSlope) {
pipeSlope = naturalSlope;
/*
* Progetta la condotta assegnado una pendenza pari a quella del
* terreno, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
base = getHeight2I(naturalSlope, g, maxd, c);
}
/* Diametro tubo [cm] */
D = diameter;
// Velocita media nella sezione [ m / s ]
meanSpeed = (discharge / CUBICMETER2LITER) / (emptyDegree * D * base / METER2CMSQUARED);
// Quota scavo all 'inizio del tubo [ m s . l . m . ]
depthInitialPipe = getInitialElevation() - diameter / METER2CM;
/*
* Quota dello scavo alla fine del tubo calcolata considerando la
* pendenza effettiva del tratto [ m s . l . m . ]
*/
depthFinalPipe = depthInitialPipe - getLenght() * pipeSlope / METER2CM;
// Quota pelo libero all 'inizio del tubo [ m s . l . m . ]
initialFreesurface = depthInitialPipe + emptyDegree * D / METER2CM;
// Quota pelo libero all 'inizio del tubo [ m s . l . m . ]
finalFreesurface = depthFinalPipe + emptyDegree * D / METER2CM;
} | java | private void designTrapeziumPipe( double tau, double g, double maxd, double c, StringBuilder strWarnings ) {
/* [cm] Base della sezione effettivamente adottata. */
double base;
/*
* [%] Pendenza naturale, calcolata in funzione dei dati geometrici
* della rete
*/
double naturalSlope;
/* [cm] Altezza del canale trapezoidale. */
double D;
/*
* [%] Pendenza minima da adottare per il tratto che si sta
* dimensionando.
*/
double ms;
/* DUE FORMULE */
/*
* Dimensiona il diametro del tubo da adottare col criterio di
* autopulizia, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
base = getHeight2(tau, g, maxd, c);
/* [%] pendenza minima per il tratto che si sta dimensionando. */
ms = getMinimumPipeSlope();
/* [%] Pendenza del terreno */
naturalSlope = METER2CM * (initialElevation - finalElevation) / lenght;
/*
* Avvisa l'utente che il tratto che si sta progettando e in
* contropendenza
*/
if (naturalSlope < 0) {
strWarnings.append(msg.message("trentoP.warning.slope") + id);
}
/* La pendenza del terreno deve essere superiore a quella minima ms */
if (naturalSlope < ms) {
naturalSlope = ms;
}
/*
* Se la pendenza del terreno e maggiore di quella del tubo, allora la
* pendenza del tubo viene posta uguale a quella del terreno.
*/
if (naturalSlope > pipeSlope) {
pipeSlope = naturalSlope;
/*
* Progetta la condotta assegnado una pendenza pari a quella del
* terreno, calcola altre grandezze correlate come la pendenza e il
* grado di riempimento, e restituisce il riempimento effettivo nel
* tratto progettato
*/
base = getHeight2I(naturalSlope, g, maxd, c);
}
/* Diametro tubo [cm] */
D = diameter;
// Velocita media nella sezione [ m / s ]
meanSpeed = (discharge / CUBICMETER2LITER) / (emptyDegree * D * base / METER2CMSQUARED);
// Quota scavo all 'inizio del tubo [ m s . l . m . ]
depthInitialPipe = getInitialElevation() - diameter / METER2CM;
/*
* Quota dello scavo alla fine del tubo calcolata considerando la
* pendenza effettiva del tratto [ m s . l . m . ]
*/
depthFinalPipe = depthInitialPipe - getLenght() * pipeSlope / METER2CM;
// Quota pelo libero all 'inizio del tubo [ m s . l . m . ]
initialFreesurface = depthInitialPipe + emptyDegree * D / METER2CM;
// Quota pelo libero all 'inizio del tubo [ m s . l . m . ]
finalFreesurface = depthFinalPipe + emptyDegree * D / METER2CM;
} | [
"private",
"void",
"designTrapeziumPipe",
"(",
"double",
"tau",
",",
"double",
"g",
",",
"double",
"maxd",
",",
"double",
"c",
",",
"StringBuilder",
"strWarnings",
")",
"{",
"/* [cm] Base della sezione effettivamente adottata. */",
"double",
"base",
";",
"/*\n * [%] Pendenza naturale, calcolata in funzione dei dati geometrici\n * della rete\n */",
"double",
"naturalSlope",
";",
"/* [cm] Altezza del canale trapezoidale. */",
"double",
"D",
";",
"/*\n * [%] Pendenza minima da adottare per il tratto che si sta\n * dimensionando.\n */",
"double",
"ms",
";",
"/* DUE FORMULE */",
"/*\n * Dimensiona il diametro del tubo da adottare col criterio di\n * autopulizia, calcola altre grandezze correlate come la pendenza e il\n * grado di riempimento, e restituisce il riempimento effettivo nel\n * tratto progettato\n */",
"base",
"=",
"getHeight2",
"(",
"tau",
",",
"g",
",",
"maxd",
",",
"c",
")",
";",
"/* [%] pendenza minima per il tratto che si sta dimensionando. */",
"ms",
"=",
"getMinimumPipeSlope",
"(",
")",
";",
"/* [%] Pendenza del terreno */",
"naturalSlope",
"=",
"METER2CM",
"*",
"(",
"initialElevation",
"-",
"finalElevation",
")",
"/",
"lenght",
";",
"/*\n * Avvisa l'utente che il tratto che si sta progettando e in\n * contropendenza\n */",
"if",
"(",
"naturalSlope",
"<",
"0",
")",
"{",
"strWarnings",
".",
"append",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.warning.slope\"",
")",
"+",
"id",
")",
";",
"}",
"/* La pendenza del terreno deve essere superiore a quella minima ms */",
"if",
"(",
"naturalSlope",
"<",
"ms",
")",
"{",
"naturalSlope",
"=",
"ms",
";",
"}",
"/*\n * Se la pendenza del terreno e maggiore di quella del tubo, allora la\n * pendenza del tubo viene posta uguale a quella del terreno.\n */",
"if",
"(",
"naturalSlope",
">",
"pipeSlope",
")",
"{",
"pipeSlope",
"=",
"naturalSlope",
";",
"/*\n * Progetta la condotta assegnado una pendenza pari a quella del\n * terreno, calcola altre grandezze correlate come la pendenza e il\n * grado di riempimento, e restituisce il riempimento effettivo nel\n * tratto progettato\n */",
"base",
"=",
"getHeight2I",
"(",
"naturalSlope",
",",
"g",
",",
"maxd",
",",
"c",
")",
";",
"}",
"/* Diametro tubo [cm] */",
"D",
"=",
"diameter",
";",
"// Velocita media nella sezione [ m / s ]",
"meanSpeed",
"=",
"(",
"discharge",
"/",
"CUBICMETER2LITER",
")",
"/",
"(",
"emptyDegree",
"*",
"D",
"*",
"base",
"/",
"METER2CMSQUARED",
")",
";",
"// Quota scavo all 'inizio del tubo [ m s . l . m . ]",
"depthInitialPipe",
"=",
"getInitialElevation",
"(",
")",
"-",
"diameter",
"/",
"METER2CM",
";",
"/*\n * Quota dello scavo alla fine del tubo calcolata considerando la\n * pendenza effettiva del tratto [ m s . l . m . ]\n */",
"depthFinalPipe",
"=",
"depthInitialPipe",
"-",
"getLenght",
"(",
")",
"*",
"pipeSlope",
"/",
"METER2CM",
";",
"// Quota pelo libero all 'inizio del tubo [ m s . l . m . ]",
"initialFreesurface",
"=",
"depthInitialPipe",
"+",
"emptyDegree",
"*",
"D",
"/",
"METER2CM",
";",
"// Quota pelo libero all 'inizio del tubo [ m s . l . m . ]",
"finalFreesurface",
"=",
"depthFinalPipe",
"+",
"emptyDegree",
"*",
"D",
"/",
"METER2CM",
";",
"}"
] | Chiama altre subroutine per dimensionare una sezione di tipo 3, ossia
trapezioidale.
<p>
Oltre al dimensionamento vero e proprio, calcola anche tutte le altre
grandezze correlate.
<ol>
<li>Inizialmente dimensiona il tubo chiamando la get_height_2() la quale
adotta il criterio dell'autopulizia e determina, mediante chiamate ad
ulteriori funuzioni tutte le grandezze necessarie (grado di riempimento,
pendenza, ecc..)
<li>Dopodiche riprogetta il tratto (chiamata a get_height_2_i) imponendo
una pendenza pari a quella del terreno, qualora questa fosse superioe a
quella ottenuta secondo il criterio di autopulizia.
<li>Inoltre ogni volta che dimensiona il tubo, design_pipe_3 (o le altre
funzioni da essa chiamate) calcola tutte le grandezze secondarie, ma
alquanto fondamentali (quota dello scavo, pelo libero ecc..) e le
registra nella matrice networkPipes.
</ol>
</p>
@param tau
[Pa] Sforzo tangenziale al fondo che garantisca l'autopulizia
della rete
@param g
Grado di riempimento da considerare nella progettazione della
rete
@param maxd
Diamtetro o altezza piu' grande adottato nei tratti piu' a
monte
@param c
Rapporto base-altezza della sezione rettangolare. | [
"Chiama",
"altre",
"subroutine",
"per",
"dimensionare",
"una",
"sezione",
"di",
"tipo",
"3",
"ossia",
"trapezioidale",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L1235-L1308 |
137,822 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.verifyEmptyDegree | public double verifyEmptyDegree( StringBuilder strWarnings, double q ) {
/* Pari a A * ( Rh ^1/6 ) */
double B;
/* Anglo formato dalla sezione bagnata */
double thta;
/* Costante */
double known;
/*
* [rad]Angolo formato dalla sezione bagnata, adottando un diametro
* commerciale
*/
double newtheta = 0;
B = (q * sqrt(WSPECIFICWEIGHT / 2.8)) / (CUBICMETER2LITER * getKs());
/* Angolo formato dalla sezione bagnata [rad] */
thta = 2 * acos(1 - 2 * 0.8);
known = (B * TWO_TENOVERTHREE) / pow(diameterToVerify / METER2CM, THIRTHEENOVERSIX);
/*
* Angolo formato dalla sezione bagnata considerando un diametro
* commerciale [rad]
*/
newtheta = Utility.thisBisection(thta, known, ONEOVERSIX, minG, accuracy, jMax, pm, strWarnings);
/* Grado di riempimento del tubo */
emptyDegree = 0.5 * (1 - cos(newtheta / 2));
return newtheta;
} | java | public double verifyEmptyDegree( StringBuilder strWarnings, double q ) {
/* Pari a A * ( Rh ^1/6 ) */
double B;
/* Anglo formato dalla sezione bagnata */
double thta;
/* Costante */
double known;
/*
* [rad]Angolo formato dalla sezione bagnata, adottando un diametro
* commerciale
*/
double newtheta = 0;
B = (q * sqrt(WSPECIFICWEIGHT / 2.8)) / (CUBICMETER2LITER * getKs());
/* Angolo formato dalla sezione bagnata [rad] */
thta = 2 * acos(1 - 2 * 0.8);
known = (B * TWO_TENOVERTHREE) / pow(diameterToVerify / METER2CM, THIRTHEENOVERSIX);
/*
* Angolo formato dalla sezione bagnata considerando un diametro
* commerciale [rad]
*/
newtheta = Utility.thisBisection(thta, known, ONEOVERSIX, minG, accuracy, jMax, pm, strWarnings);
/* Grado di riempimento del tubo */
emptyDegree = 0.5 * (1 - cos(newtheta / 2));
return newtheta;
} | [
"public",
"double",
"verifyEmptyDegree",
"(",
"StringBuilder",
"strWarnings",
",",
"double",
"q",
")",
"{",
"/* Pari a A * ( Rh ^1/6 ) */",
"double",
"B",
";",
"/* Anglo formato dalla sezione bagnata */",
"double",
"thta",
";",
"/* Costante */",
"double",
"known",
";",
"/*\n * [rad]Angolo formato dalla sezione bagnata, adottando un diametro\n * commerciale\n */",
"double",
"newtheta",
"=",
"0",
";",
"B",
"=",
"(",
"q",
"*",
"sqrt",
"(",
"WSPECIFICWEIGHT",
"/",
"2.8",
")",
")",
"/",
"(",
"CUBICMETER2LITER",
"*",
"getKs",
"(",
")",
")",
";",
"/* Angolo formato dalla sezione bagnata [rad] */",
"thta",
"=",
"2",
"*",
"acos",
"(",
"1",
"-",
"2",
"*",
"0.8",
")",
";",
"known",
"=",
"(",
"B",
"*",
"TWO_TENOVERTHREE",
")",
"/",
"pow",
"(",
"diameterToVerify",
"/",
"METER2CM",
",",
"THIRTHEENOVERSIX",
")",
";",
"/*\n * Angolo formato dalla sezione bagnata considerando un diametro\n * commerciale [rad]\n */",
"newtheta",
"=",
"Utility",
".",
"thisBisection",
"(",
"thta",
",",
"known",
",",
"ONEOVERSIX",
",",
"minG",
",",
"accuracy",
",",
"jMax",
",",
"pm",
",",
"strWarnings",
")",
";",
"/* Grado di riempimento del tubo */",
"emptyDegree",
"=",
"0.5",
"*",
"(",
"1",
"-",
"cos",
"(",
"newtheta",
"/",
"2",
")",
")",
";",
"return",
"newtheta",
";",
"}"
] | Verify if the empty degree is greather than the 0.8.
@param strWarnings
a string which collect all the warning messages.
@param q discharge in this pipe. | [
"Verify",
"if",
"the",
"empty",
"degree",
"is",
"greather",
"than",
"the",
"0",
".",
"8",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L1445-L1473 |
137,823 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoGpsLog.java | DaoGpsLog.addGpsLogDataPoint | public static void addGpsLogDataPoint( Connection connection, OmsGeopaparazziProject3To4Converter.GpsPoint point,
long gpslogId ) throws Exception {
Date timestamp = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.parse(point.utctime);
String insertSQL = "INSERT INTO " + TableDescriptions.TABLE_GPSLOG_DATA + "(" + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_ID.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_LOGID.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_ALTIM.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName() + //
") VALUES" + "(?,?,?,?,?,?)";
try (PreparedStatement writeStatement = connection.prepareStatement(insertSQL)) {
writeStatement.setLong(1, point.id);
writeStatement.setLong(2, gpslogId);
writeStatement.setDouble(3, point.lon);
writeStatement.setDouble(4, point.lat);
writeStatement.setDouble(5, point.altim);
writeStatement.setLong(6, timestamp.getTime());
writeStatement.executeUpdate();
}
} | java | public static void addGpsLogDataPoint( Connection connection, OmsGeopaparazziProject3To4Converter.GpsPoint point,
long gpslogId ) throws Exception {
Date timestamp = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.parse(point.utctime);
String insertSQL = "INSERT INTO " + TableDescriptions.TABLE_GPSLOG_DATA + "(" + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_ID.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_LOGID.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_ALTIM.getFieldName() + ", " + //
TableDescriptions.GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName() + //
") VALUES" + "(?,?,?,?,?,?)";
try (PreparedStatement writeStatement = connection.prepareStatement(insertSQL)) {
writeStatement.setLong(1, point.id);
writeStatement.setLong(2, gpslogId);
writeStatement.setDouble(3, point.lon);
writeStatement.setDouble(4, point.lat);
writeStatement.setDouble(5, point.altim);
writeStatement.setLong(6, timestamp.getTime());
writeStatement.executeUpdate();
}
} | [
"public",
"static",
"void",
"addGpsLogDataPoint",
"(",
"Connection",
"connection",
",",
"OmsGeopaparazziProject3To4Converter",
".",
"GpsPoint",
"point",
",",
"long",
"gpslogId",
")",
"throws",
"Exception",
"{",
"Date",
"timestamp",
"=",
"ETimeUtilities",
".",
"INSTANCE",
".",
"TIME_FORMATTER_LOCAL",
".",
"parse",
"(",
"point",
".",
"utctime",
")",
";",
"String",
"insertSQL",
"=",
"\"INSERT INTO \"",
"+",
"TableDescriptions",
".",
"TABLE_GPSLOG_DATA",
"+",
"\"(\"",
"+",
"//",
"TableDescriptions",
".",
"GpsLogsDataTableFields",
".",
"COLUMN_ID",
".",
"getFieldName",
"(",
")",
"+",
"\", \"",
"+",
"//",
"TableDescriptions",
".",
"GpsLogsDataTableFields",
".",
"COLUMN_LOGID",
".",
"getFieldName",
"(",
")",
"+",
"\", \"",
"+",
"//",
"TableDescriptions",
".",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_LON",
".",
"getFieldName",
"(",
")",
"+",
"\", \"",
"+",
"//",
"TableDescriptions",
".",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_LAT",
".",
"getFieldName",
"(",
")",
"+",
"\", \"",
"+",
"//",
"TableDescriptions",
".",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_ALTIM",
".",
"getFieldName",
"(",
")",
"+",
"\", \"",
"+",
"//",
"TableDescriptions",
".",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_TS",
".",
"getFieldName",
"(",
")",
"+",
"//",
"\") VALUES\"",
"+",
"\"(?,?,?,?,?,?)\"",
";",
"try",
"(",
"PreparedStatement",
"writeStatement",
"=",
"connection",
".",
"prepareStatement",
"(",
"insertSQL",
")",
")",
"{",
"writeStatement",
".",
"setLong",
"(",
"1",
",",
"point",
".",
"id",
")",
";",
"writeStatement",
".",
"setLong",
"(",
"2",
",",
"gpslogId",
")",
";",
"writeStatement",
".",
"setDouble",
"(",
"3",
",",
"point",
".",
"lon",
")",
";",
"writeStatement",
".",
"setDouble",
"(",
"4",
",",
"point",
".",
"lat",
")",
";",
"writeStatement",
".",
"setDouble",
"(",
"5",
",",
"point",
".",
"altim",
")",
";",
"writeStatement",
".",
"setLong",
"(",
"6",
",",
"timestamp",
".",
"getTime",
"(",
")",
")",
";",
"writeStatement",
".",
"executeUpdate",
"(",
")",
";",
"}",
"}"
] | Adds a new XY entry to the gps table.
@param connection the db connection.
@param point the point to add.
@param gpslogId the id of the log the point is part of.
@throws IOException if something goes wrong | [
"Adds",
"a",
"new",
"XY",
"entry",
"to",
"the",
"gps",
"table",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoGpsLog.java#L234-L256 |
137,824 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoGpsLog.java | DaoGpsLog.getLogsList | public static List<GpsLog> getLogsList( IHMConnection connection ) throws Exception {
List<GpsLog> logsList = new ArrayList<>();
String sql = "select " + //
GpsLogsTableFields.COLUMN_ID.getFieldName() + "," + //
GpsLogsTableFields.COLUMN_LOG_STARTTS.getFieldName() + "," + //
GpsLogsTableFields.COLUMN_LOG_ENDTS.getFieldName() + "," + //
GpsLogsTableFields.COLUMN_LOG_TEXT.getFieldName() + //
" from " + TABLE_GPSLOGS; //
try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(sql);) {
statement.setQueryTimeout(30); // set timeout to 30 sec.
// first get the logs
while( rs.next() ) {
long id = rs.getLong(1);
long startDateTimeString = rs.getLong(2);
long endDateTimeString = rs.getLong(3);
String text = rs.getString(4);
GpsLog log = new GpsLog();
log.id = id;
log.startTime = startDateTimeString;
log.endTime = endDateTimeString;
log.text = text;
logsList.add(log);
}
}
return logsList;
} | java | public static List<GpsLog> getLogsList( IHMConnection connection ) throws Exception {
List<GpsLog> logsList = new ArrayList<>();
String sql = "select " + //
GpsLogsTableFields.COLUMN_ID.getFieldName() + "," + //
GpsLogsTableFields.COLUMN_LOG_STARTTS.getFieldName() + "," + //
GpsLogsTableFields.COLUMN_LOG_ENDTS.getFieldName() + "," + //
GpsLogsTableFields.COLUMN_LOG_TEXT.getFieldName() + //
" from " + TABLE_GPSLOGS; //
try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(sql);) {
statement.setQueryTimeout(30); // set timeout to 30 sec.
// first get the logs
while( rs.next() ) {
long id = rs.getLong(1);
long startDateTimeString = rs.getLong(2);
long endDateTimeString = rs.getLong(3);
String text = rs.getString(4);
GpsLog log = new GpsLog();
log.id = id;
log.startTime = startDateTimeString;
log.endTime = endDateTimeString;
log.text = text;
logsList.add(log);
}
}
return logsList;
} | [
"public",
"static",
"List",
"<",
"GpsLog",
">",
"getLogsList",
"(",
"IHMConnection",
"connection",
")",
"throws",
"Exception",
"{",
"List",
"<",
"GpsLog",
">",
"logsList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"sql",
"=",
"\"select \"",
"+",
"//",
"GpsLogsTableFields",
".",
"COLUMN_ID",
".",
"getFieldName",
"(",
")",
"+",
"\",\"",
"+",
"//",
"GpsLogsTableFields",
".",
"COLUMN_LOG_STARTTS",
".",
"getFieldName",
"(",
")",
"+",
"\",\"",
"+",
"//",
"GpsLogsTableFields",
".",
"COLUMN_LOG_ENDTS",
".",
"getFieldName",
"(",
")",
"+",
"\",\"",
"+",
"//",
"GpsLogsTableFields",
".",
"COLUMN_LOG_TEXT",
".",
"getFieldName",
"(",
")",
"+",
"//",
"\" from \"",
"+",
"TABLE_GPSLOGS",
";",
"//",
"try",
"(",
"IHMStatement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"IHMResultSet",
"rs",
"=",
"statement",
".",
"executeQuery",
"(",
"sql",
")",
";",
")",
"{",
"statement",
".",
"setQueryTimeout",
"(",
"30",
")",
";",
"// set timeout to 30 sec.",
"// first get the logs",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"long",
"id",
"=",
"rs",
".",
"getLong",
"(",
"1",
")",
";",
"long",
"startDateTimeString",
"=",
"rs",
".",
"getLong",
"(",
"2",
")",
";",
"long",
"endDateTimeString",
"=",
"rs",
".",
"getLong",
"(",
"3",
")",
";",
"String",
"text",
"=",
"rs",
".",
"getString",
"(",
"4",
")",
";",
"GpsLog",
"log",
"=",
"new",
"GpsLog",
"(",
")",
";",
"log",
".",
"id",
"=",
"id",
";",
"log",
".",
"startTime",
"=",
"startDateTimeString",
";",
"log",
".",
"endTime",
"=",
"endDateTimeString",
";",
"log",
".",
"text",
"=",
"text",
";",
"logsList",
".",
"add",
"(",
"log",
")",
";",
"}",
"}",
"return",
"logsList",
";",
"}"
] | Get the list of available logs.
@param connection the connection to use.
@return the list of logs.
@throws SQLException | [
"Get",
"the",
"list",
"of",
"available",
"logs",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoGpsLog.java#L265-L294 |
137,825 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoGpsLog.java | DaoGpsLog.collectDataForLog | public static void collectDataForLog( IHMConnection connection, GpsLog log ) throws Exception {
long logId = log.id;
String query = "select "
+ //
GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ","
+ //
GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + ","
+ //
GpsLogsDataTableFields.COLUMN_DATA_ALTIM.getFieldName() + ","
+ //
GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName()
+ //
" from " + TABLE_GPSLOG_DATA + " where "
+ //
GpsLogsDataTableFields.COLUMN_LOGID.getFieldName() + " = " + logId + " order by "
+ GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName();
try (IHMStatement newStatement = connection.createStatement(); IHMResultSet result = newStatement.executeQuery(query);) {
newStatement.setQueryTimeout(30);
while( result.next() ) {
double lat = result.getDouble(1);
double lon = result.getDouble(2);
double altim = result.getDouble(3);
long ts = result.getLong(4);
GpsPoint gPoint = new GpsPoint();
gPoint.lon = lon;
gPoint.lat = lat;
gPoint.altim = altim;
gPoint.utctime = ts;
log.points.add(gPoint);
}
}
} | java | public static void collectDataForLog( IHMConnection connection, GpsLog log ) throws Exception {
long logId = log.id;
String query = "select "
+ //
GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ","
+ //
GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + ","
+ //
GpsLogsDataTableFields.COLUMN_DATA_ALTIM.getFieldName() + ","
+ //
GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName()
+ //
" from " + TABLE_GPSLOG_DATA + " where "
+ //
GpsLogsDataTableFields.COLUMN_LOGID.getFieldName() + " = " + logId + " order by "
+ GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName();
try (IHMStatement newStatement = connection.createStatement(); IHMResultSet result = newStatement.executeQuery(query);) {
newStatement.setQueryTimeout(30);
while( result.next() ) {
double lat = result.getDouble(1);
double lon = result.getDouble(2);
double altim = result.getDouble(3);
long ts = result.getLong(4);
GpsPoint gPoint = new GpsPoint();
gPoint.lon = lon;
gPoint.lat = lat;
gPoint.altim = altim;
gPoint.utctime = ts;
log.points.add(gPoint);
}
}
} | [
"public",
"static",
"void",
"collectDataForLog",
"(",
"IHMConnection",
"connection",
",",
"GpsLog",
"log",
")",
"throws",
"Exception",
"{",
"long",
"logId",
"=",
"log",
".",
"id",
";",
"String",
"query",
"=",
"\"select \"",
"+",
"//",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_LAT",
".",
"getFieldName",
"(",
")",
"+",
"\",\"",
"+",
"//",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_LON",
".",
"getFieldName",
"(",
")",
"+",
"\",\"",
"+",
"//",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_ALTIM",
".",
"getFieldName",
"(",
")",
"+",
"\",\"",
"+",
"//",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_TS",
".",
"getFieldName",
"(",
")",
"+",
"//",
"\" from \"",
"+",
"TABLE_GPSLOG_DATA",
"+",
"\" where \"",
"+",
"//",
"GpsLogsDataTableFields",
".",
"COLUMN_LOGID",
".",
"getFieldName",
"(",
")",
"+",
"\" = \"",
"+",
"logId",
"+",
"\" order by \"",
"+",
"GpsLogsDataTableFields",
".",
"COLUMN_DATA_TS",
".",
"getFieldName",
"(",
")",
";",
"try",
"(",
"IHMStatement",
"newStatement",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"IHMResultSet",
"result",
"=",
"newStatement",
".",
"executeQuery",
"(",
"query",
")",
";",
")",
"{",
"newStatement",
".",
"setQueryTimeout",
"(",
"30",
")",
";",
"while",
"(",
"result",
".",
"next",
"(",
")",
")",
"{",
"double",
"lat",
"=",
"result",
".",
"getDouble",
"(",
"1",
")",
";",
"double",
"lon",
"=",
"result",
".",
"getDouble",
"(",
"2",
")",
";",
"double",
"altim",
"=",
"result",
".",
"getDouble",
"(",
"3",
")",
";",
"long",
"ts",
"=",
"result",
".",
"getLong",
"(",
"4",
")",
";",
"GpsPoint",
"gPoint",
"=",
"new",
"GpsPoint",
"(",
")",
";",
"gPoint",
".",
"lon",
"=",
"lon",
";",
"gPoint",
".",
"lat",
"=",
"lat",
";",
"gPoint",
".",
"altim",
"=",
"altim",
";",
"gPoint",
".",
"utctime",
"=",
"ts",
";",
"log",
".",
"points",
".",
"add",
"(",
"gPoint",
")",
";",
"}",
"}",
"}"
] | Gather gps points data for a supplied log.
@param connection the connection to use.
@param log the log.
@throws Exception | [
"Gather",
"gps",
"points",
"data",
"for",
"a",
"supplied",
"log",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoGpsLog.java#L303-L338 |
137,826 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/SshTunnelHandler.java | SshTunnelHandler.openTunnel | public static SshTunnelHandler openTunnel( String remoteHost, String remoteSshUser, String remoteSshPwd, int localPort,
int remotePort ) throws JSchException {
int port = 22;
JSch jsch = new JSch();
Session tunnelingSession = jsch.getSession(remoteSshUser, remoteHost, port);
tunnelingSession.setPassword(remoteSshPwd);
HMUserInfo lui = new HMUserInfo("");
tunnelingSession.setUserInfo(lui);
tunnelingSession.setConfig("StrictHostKeyChecking", "no");
tunnelingSession.setPortForwardingL(localPort, "localhost", remotePort);
tunnelingSession.connect();
tunnelingSession.openChannel("direct-tcpip");
return new SshTunnelHandler(tunnelingSession);
} | java | public static SshTunnelHandler openTunnel( String remoteHost, String remoteSshUser, String remoteSshPwd, int localPort,
int remotePort ) throws JSchException {
int port = 22;
JSch jsch = new JSch();
Session tunnelingSession = jsch.getSession(remoteSshUser, remoteHost, port);
tunnelingSession.setPassword(remoteSshPwd);
HMUserInfo lui = new HMUserInfo("");
tunnelingSession.setUserInfo(lui);
tunnelingSession.setConfig("StrictHostKeyChecking", "no");
tunnelingSession.setPortForwardingL(localPort, "localhost", remotePort);
tunnelingSession.connect();
tunnelingSession.openChannel("direct-tcpip");
return new SshTunnelHandler(tunnelingSession);
} | [
"public",
"static",
"SshTunnelHandler",
"openTunnel",
"(",
"String",
"remoteHost",
",",
"String",
"remoteSshUser",
",",
"String",
"remoteSshPwd",
",",
"int",
"localPort",
",",
"int",
"remotePort",
")",
"throws",
"JSchException",
"{",
"int",
"port",
"=",
"22",
";",
"JSch",
"jsch",
"=",
"new",
"JSch",
"(",
")",
";",
"Session",
"tunnelingSession",
"=",
"jsch",
".",
"getSession",
"(",
"remoteSshUser",
",",
"remoteHost",
",",
"port",
")",
";",
"tunnelingSession",
".",
"setPassword",
"(",
"remoteSshPwd",
")",
";",
"HMUserInfo",
"lui",
"=",
"new",
"HMUserInfo",
"(",
"\"\"",
")",
";",
"tunnelingSession",
".",
"setUserInfo",
"(",
"lui",
")",
";",
"tunnelingSession",
".",
"setConfig",
"(",
"\"StrictHostKeyChecking\"",
",",
"\"no\"",
")",
";",
"tunnelingSession",
".",
"setPortForwardingL",
"(",
"localPort",
",",
"\"localhost\"",
",",
"remotePort",
")",
";",
"tunnelingSession",
".",
"connect",
"(",
")",
";",
"tunnelingSession",
".",
"openChannel",
"(",
"\"direct-tcpip\"",
")",
";",
"return",
"new",
"SshTunnelHandler",
"(",
"tunnelingSession",
")",
";",
"}"
] | Open a tunnel to the remote host.
@param remoteHost the host to connect to (where ssh will login).
@param remoteSshUser the ssh user.
@param remoteSshPwd the ssh password.
@param localPort the local port to use for the port forwarding (usually the same as the remote).
@param remotePort the remote port to use.
@return the tunnel manager, used also to disconnect when necessary.
@throws JSchException | [
"Open",
"a",
"tunnel",
"to",
"the",
"remote",
"host",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/SshTunnelHandler.java#L48-L61 |
137,827 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgUtil.java | DwgUtil.getRawLong | public static Vector getRawLong(int[] data, int offset) {
Vector v = new Vector();
// TODO: Incorrecto. Repasar ...
// _val = struct.unpack('<l', _long)[0]
int val = 0;
v.add(new Integer(offset+32));
v.add(new Integer(val));
return v;
} | java | public static Vector getRawLong(int[] data, int offset) {
Vector v = new Vector();
// TODO: Incorrecto. Repasar ...
// _val = struct.unpack('<l', _long)[0]
int val = 0;
v.add(new Integer(offset+32));
v.add(new Integer(val));
return v;
} | [
"public",
"static",
"Vector",
"getRawLong",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"Vector",
"v",
"=",
"new",
"Vector",
"(",
")",
";",
"// TODO: Incorrecto. Repasar ...",
"// _val = struct.unpack('<l', _long)[0]",
"int",
"val",
"=",
"0",
";",
"v",
".",
"add",
"(",
"new",
"Integer",
"(",
"offset",
"+",
"32",
")",
")",
";",
"v",
".",
"add",
"(",
"new",
"Integer",
"(",
"val",
")",
")",
";",
"return",
"v",
";",
"}"
] | Read a long value from a group of unsigned bytes
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines.
@return Vector This vector has two parts. First is an int value that represents
the new offset, and second is the long value | [
"Read",
"a",
"long",
"value",
"from",
"a",
"group",
"of",
"unsigned",
"bytes"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgUtil.java#L388-L396 |
137,828 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgUtil.java | DwgUtil.getTextString | public static Vector getTextString(int[] data, int offset) throws Exception {
int bitPos = offset;
int newBitPos = ((Integer)DwgUtil.getBitShort(data, bitPos).get(0)).intValue();
int len = ((Integer)DwgUtil.getBitShort(data, bitPos).get(1)).intValue();
bitPos = newBitPos;
int bitLen = len * 8;
Object cosa = DwgUtil.getBits(data, bitLen, bitPos);
String string;
if (cosa instanceof byte[]) {
string = new String((byte[])cosa);
} | java | public static Vector getTextString(int[] data, int offset) throws Exception {
int bitPos = offset;
int newBitPos = ((Integer)DwgUtil.getBitShort(data, bitPos).get(0)).intValue();
int len = ((Integer)DwgUtil.getBitShort(data, bitPos).get(1)).intValue();
bitPos = newBitPos;
int bitLen = len * 8;
Object cosa = DwgUtil.getBits(data, bitLen, bitPos);
String string;
if (cosa instanceof byte[]) {
string = new String((byte[])cosa);
} | [
"public",
"static",
"Vector",
"getTextString",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"throws",
"Exception",
"{",
"int",
"bitPos",
"=",
"offset",
";",
"int",
"newBitPos",
"=",
"(",
"(",
"Integer",
")",
"DwgUtil",
".",
"getBitShort",
"(",
"data",
",",
"bitPos",
")",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"int",
"len",
"=",
"(",
"(",
"Integer",
")",
"DwgUtil",
".",
"getBitShort",
"(",
"data",
",",
"bitPos",
")",
".",
"get",
"(",
"1",
")",
")",
".",
"intValue",
"(",
")",
";",
"bitPos",
"=",
"newBitPos",
";",
"int",
"bitLen",
"=",
"len",
"*",
"8",
";",
"Object",
"cosa",
"=",
"DwgUtil",
".",
"getBits",
"(",
"data",
",",
"bitLen",
",",
"bitPos",
")",
";",
"String",
"string",
";",
"if",
"(",
"cosa",
"instanceof",
"byte",
"[",
"]",
")",
"{",
"string",
"=",
"new",
"String",
"(",
"(",
"byte",
"[",
"]",
")",
"cosa",
")",
";",
"}"
] | Read a String from a group of unsigned bytes
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines.
@return Vector This vector has two parts. First is an int value that represents
the new offset, and second is the String | [
"Read",
"a",
"String",
"from",
"a",
"group",
"of",
"unsigned",
"bytes"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgUtil.java#L462-L472 |
137,829 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ds/Tree.java | Tree.toRootOrder | public Iterator<Compound> toRootOrder(final Compound c) {
return new Iterator<Compound>() {
Compound curr;
TreeNode n = node(c);
Compound parent = c;
public boolean hasNext() {
return !n.isRoot();
}
public Compound next() {
if (hasNext()) {
curr = parent;
parent = n.parent;
n = node(n.parent);
return curr;
} else {
throw new NoSuchElementException();
}
}
public void remove() {
throw new UnsupportedOperationException();
}
};
} | java | public Iterator<Compound> toRootOrder(final Compound c) {
return new Iterator<Compound>() {
Compound curr;
TreeNode n = node(c);
Compound parent = c;
public boolean hasNext() {
return !n.isRoot();
}
public Compound next() {
if (hasNext()) {
curr = parent;
parent = n.parent;
n = node(n.parent);
return curr;
} else {
throw new NoSuchElementException();
}
}
public void remove() {
throw new UnsupportedOperationException();
}
};
} | [
"public",
"Iterator",
"<",
"Compound",
">",
"toRootOrder",
"(",
"final",
"Compound",
"c",
")",
"{",
"return",
"new",
"Iterator",
"<",
"Compound",
">",
"(",
")",
"{",
"Compound",
"curr",
";",
"TreeNode",
"n",
"=",
"node",
"(",
"c",
")",
";",
"Compound",
"parent",
"=",
"c",
";",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"!",
"n",
".",
"isRoot",
"(",
")",
";",
"}",
"public",
"Compound",
"next",
"(",
")",
"{",
"if",
"(",
"hasNext",
"(",
")",
")",
"{",
"curr",
"=",
"parent",
";",
"parent",
"=",
"n",
".",
"parent",
";",
"n",
"=",
"node",
"(",
"n",
".",
"parent",
")",
";",
"return",
"curr",
";",
"}",
"else",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"}",
"}",
"public",
"void",
"remove",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Returns all compounds from the Compound argument to the root of
the tree following the path.
@param c the Compound to start with.
@return the set of Compounds in the given order. | [
"Returns",
"all",
"compounds",
"from",
"the",
"Compound",
"argument",
"to",
"the",
"root",
"of",
"the",
"tree",
"following",
"the",
"path",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ds/Tree.java#L77-L103 |
137,830 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/io/CSVPrinter.java | CSVPrinter.println | public void println(String value) {
print(value);
out.println();
out.flush();
newLine = true;
} | java | public void println(String value) {
print(value);
out.println();
out.flush();
newLine = true;
} | [
"public",
"void",
"println",
"(",
"String",
"value",
")",
"{",
"print",
"(",
"value",
")",
";",
"out",
".",
"println",
"(",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"newLine",
"=",
"true",
";",
"}"
] | Print the string as the last value on the line. The value
will be quoted if needed.
@param value value to be outputted. | [
"Print",
"the",
"string",
"as",
"the",
"last",
"value",
"on",
"the",
"line",
".",
"The",
"value",
"will",
"be",
"quoted",
"if",
"needed",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CSVPrinter.java#L98-L103 |
137,831 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/io/CSVPrinter.java | CSVPrinter.println | public void println(String[] values) {
for (int i = 0; i < values.length; i++) {
print(values[i]);
}
out.println();
out.flush();
newLine = true;
} | java | public void println(String[] values) {
for (int i = 0; i < values.length; i++) {
print(values[i]);
}
out.println();
out.flush();
newLine = true;
} | [
"public",
"void",
"println",
"(",
"String",
"[",
"]",
"values",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"print",
"(",
"values",
"[",
"i",
"]",
")",
";",
"}",
"out",
".",
"println",
"(",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"newLine",
"=",
"true",
";",
"}"
] | Print a single line of comma separated values.
The values will be quoted if needed. Quotes and
newLine characters will be escaped.
@param values values to be outputted. | [
"Print",
"a",
"single",
"line",
"of",
"comma",
"separated",
"values",
".",
"The",
"values",
"will",
"be",
"quoted",
"if",
"needed",
".",
"Quotes",
"and",
"newLine",
"characters",
"will",
"be",
"escaped",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CSVPrinter.java#L121-L128 |
137,832 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/io/CSVPrinter.java | CSVPrinter.printlnComment | public void printlnComment(String comment) {
if (this.strategy.isCommentingDisabled()) {
return;
}
if (!newLine) {
out.println();
}
out.print(this.strategy.getCommentStart());
out.print(' ');
for (int i = 0; i < comment.length(); i++) {
char c = comment.charAt(i);
switch (c) {
case '\r':
if (i + 1 < comment.length() && comment.charAt(i + 1) == '\n') {
i++;
}
// break intentionally excluded.
case '\n':
out.println();
out.print(this.strategy.getCommentStart());
out.print(' ');
break;
default:
out.print(c);
break;
}
}
out.println();
out.flush();
newLine = true;
} | java | public void printlnComment(String comment) {
if (this.strategy.isCommentingDisabled()) {
return;
}
if (!newLine) {
out.println();
}
out.print(this.strategy.getCommentStart());
out.print(' ');
for (int i = 0; i < comment.length(); i++) {
char c = comment.charAt(i);
switch (c) {
case '\r':
if (i + 1 < comment.length() && comment.charAt(i + 1) == '\n') {
i++;
}
// break intentionally excluded.
case '\n':
out.println();
out.print(this.strategy.getCommentStart());
out.print(' ');
break;
default:
out.print(c);
break;
}
}
out.println();
out.flush();
newLine = true;
} | [
"public",
"void",
"printlnComment",
"(",
"String",
"comment",
")",
"{",
"if",
"(",
"this",
".",
"strategy",
".",
"isCommentingDisabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"newLine",
")",
"{",
"out",
".",
"println",
"(",
")",
";",
"}",
"out",
".",
"print",
"(",
"this",
".",
"strategy",
".",
"getCommentStart",
"(",
")",
")",
";",
"out",
".",
"print",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"comment",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"comment",
".",
"charAt",
"(",
"i",
")",
";",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"if",
"(",
"i",
"+",
"1",
"<",
"comment",
".",
"length",
"(",
")",
"&&",
"comment",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"==",
"'",
"'",
")",
"{",
"i",
"++",
";",
"}",
"// break intentionally excluded.",
"case",
"'",
"'",
":",
"out",
".",
"println",
"(",
")",
";",
"out",
".",
"print",
"(",
"this",
".",
"strategy",
".",
"getCommentStart",
"(",
")",
")",
";",
"out",
".",
"print",
"(",
"'",
"'",
")",
";",
"break",
";",
"default",
":",
"out",
".",
"print",
"(",
"c",
")",
";",
"break",
";",
"}",
"}",
"out",
".",
"println",
"(",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"newLine",
"=",
"true",
";",
"}"
] | Put a comment among the comma separated values.
Comments will always begin on a new line and occupy a
least one full line. The character specified to star
comments and a space will be inserted at the beginning of
each new line in the comment.
@param comment the comment to output | [
"Put",
"a",
"comment",
"among",
"the",
"comma",
"separated",
"values",
".",
"Comments",
"will",
"always",
"begin",
"on",
"a",
"new",
"line",
"and",
"occupy",
"a",
"least",
"one",
"full",
"line",
".",
"The",
"character",
"specified",
"to",
"star",
"comments",
"and",
"a",
"space",
"will",
"be",
"inserted",
"at",
"the",
"beginning",
"of",
"each",
"new",
"line",
"in",
"the",
"comment",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CSVPrinter.java#L157-L187 |
137,833 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/io/CSVPrinter.java | CSVPrinter.print | public void print(String value) {
boolean quote = false;
if (value.length() > 0) {
char c = value.charAt(0);
if (newLine && (c < '0' || (c > '9' && c < 'A') || (c > 'Z' && c < 'a') || (c > 'z'))) {
quote = true;
}
if (c == ' ' || c == '\f' || c == '\t') {
quote = true;
}
for (int i = 0; i < value.length(); i++) {
c = value.charAt(i);
if (c == '"' || c == this.strategy.getDelimiter() || c == '\n' || c == '\r') {
quote = true;
c = value.charAt(value.length() - 1);
break;
}
}
if (c == ' ' || c == '\f' || c == '\t') {
quote = true;
}
} else if (newLine) {
// always quote an empty token that is the first
// on the line, as it may be the only thing on the
// line. If it were not quoted in that case,
// an empty line has no tokens.
quote = true;
}
if (newLine) {
newLine = false;
} else {
out.print(this.strategy.getDelimiter());
}
if (quote) {
out.print(escapeAndQuote(value));
} else {
out.print(value);
}
out.flush();
} | java | public void print(String value) {
boolean quote = false;
if (value.length() > 0) {
char c = value.charAt(0);
if (newLine && (c < '0' || (c > '9' && c < 'A') || (c > 'Z' && c < 'a') || (c > 'z'))) {
quote = true;
}
if (c == ' ' || c == '\f' || c == '\t') {
quote = true;
}
for (int i = 0; i < value.length(); i++) {
c = value.charAt(i);
if (c == '"' || c == this.strategy.getDelimiter() || c == '\n' || c == '\r') {
quote = true;
c = value.charAt(value.length() - 1);
break;
}
}
if (c == ' ' || c == '\f' || c == '\t') {
quote = true;
}
} else if (newLine) {
// always quote an empty token that is the first
// on the line, as it may be the only thing on the
// line. If it were not quoted in that case,
// an empty line has no tokens.
quote = true;
}
if (newLine) {
newLine = false;
} else {
out.print(this.strategy.getDelimiter());
}
if (quote) {
out.print(escapeAndQuote(value));
} else {
out.print(value);
}
out.flush();
} | [
"public",
"void",
"print",
"(",
"String",
"value",
")",
"{",
"boolean",
"quote",
"=",
"false",
";",
"if",
"(",
"value",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"char",
"c",
"=",
"value",
".",
"charAt",
"(",
"0",
")",
";",
"if",
"(",
"newLine",
"&&",
"(",
"c",
"<",
"'",
"'",
"||",
"(",
"c",
">",
"'",
"'",
"&&",
"c",
"<",
"'",
"'",
")",
"||",
"(",
"c",
">",
"'",
"'",
"&&",
"c",
"<",
"'",
"'",
")",
"||",
"(",
"c",
">",
"'",
"'",
")",
")",
")",
"{",
"quote",
"=",
"true",
";",
"}",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"quote",
"=",
"true",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"c",
"=",
"value",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"this",
".",
"strategy",
".",
"getDelimiter",
"(",
")",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"quote",
"=",
"true",
";",
"c",
"=",
"value",
".",
"charAt",
"(",
"value",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"quote",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"newLine",
")",
"{",
"// always quote an empty token that is the first",
"// on the line, as it may be the only thing on the",
"// line. If it were not quoted in that case,",
"// an empty line has no tokens.",
"quote",
"=",
"true",
";",
"}",
"if",
"(",
"newLine",
")",
"{",
"newLine",
"=",
"false",
";",
"}",
"else",
"{",
"out",
".",
"print",
"(",
"this",
".",
"strategy",
".",
"getDelimiter",
"(",
")",
")",
";",
"}",
"if",
"(",
"quote",
")",
"{",
"out",
".",
"print",
"(",
"escapeAndQuote",
"(",
"value",
")",
")",
";",
"}",
"else",
"{",
"out",
".",
"print",
"(",
"value",
")",
";",
"}",
"out",
".",
"flush",
"(",
")",
";",
"}"
] | Print the string as the next value on the line. The value
will be quoted if needed.
@param value value to be outputted. | [
"Print",
"the",
"string",
"as",
"the",
"next",
"value",
"on",
"the",
"line",
".",
"The",
"value",
"will",
"be",
"quoted",
"if",
"needed",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CSVPrinter.java#L195-L234 |
137,834 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/io/CSVPrinter.java | CSVPrinter.escapeAndQuote | private String escapeAndQuote(String value) {
// the initial count is for the preceding and trailing quotes
int count = 2;
for (int i = 0; i < value.length(); i++) {
switch (value.charAt(i)) {
case '\"':
case '\n':
case '\r':
case '\\':
count++;
break;
default:
break;
}
}
StringBuffer sb = new StringBuffer(value.length() + count);
sb.append(strategy.getEncapsulator());
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (c == strategy.getEncapsulator()) {
sb.append('\\').append(c);
continue;
}
switch (c) {
case '\n':
sb.append("\\n");
break;
case '\r':
sb.append("\\r");
break;
case '\\':
sb.append("\\\\");
break;
default:
sb.append(c);
}
}
sb.append(strategy.getEncapsulator());
return sb.toString();
} | java | private String escapeAndQuote(String value) {
// the initial count is for the preceding and trailing quotes
int count = 2;
for (int i = 0; i < value.length(); i++) {
switch (value.charAt(i)) {
case '\"':
case '\n':
case '\r':
case '\\':
count++;
break;
default:
break;
}
}
StringBuffer sb = new StringBuffer(value.length() + count);
sb.append(strategy.getEncapsulator());
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (c == strategy.getEncapsulator()) {
sb.append('\\').append(c);
continue;
}
switch (c) {
case '\n':
sb.append("\\n");
break;
case '\r':
sb.append("\\r");
break;
case '\\':
sb.append("\\\\");
break;
default:
sb.append(c);
}
}
sb.append(strategy.getEncapsulator());
return sb.toString();
} | [
"private",
"String",
"escapeAndQuote",
"(",
"String",
"value",
")",
"{",
"// the initial count is for the preceding and trailing quotes",
"int",
"count",
"=",
"2",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"switch",
"(",
"value",
".",
"charAt",
"(",
"i",
")",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"count",
"++",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
"value",
".",
"length",
"(",
")",
"+",
"count",
")",
";",
"sb",
".",
"append",
"(",
"strategy",
".",
"getEncapsulator",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"value",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"strategy",
".",
"getEncapsulator",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"c",
")",
";",
"continue",
";",
"}",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"sb",
".",
"append",
"(",
"\"\\\\n\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"sb",
".",
"append",
"(",
"\"\\\\r\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"sb",
".",
"append",
"(",
"\"\\\\\\\\\"",
")",
";",
"break",
";",
"default",
":",
"sb",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"strategy",
".",
"getEncapsulator",
"(",
")",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Enclose the value in quotes and escape the quote
and comma characters that are inside.
@param value needs to be escaped and quoted
@return the value, escaped and quoted | [
"Enclose",
"the",
"value",
"in",
"quotes",
"and",
"escape",
"the",
"quote",
"and",
"comma",
"characters",
"that",
"are",
"inside",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CSVPrinter.java#L243-L283 |
137,835 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/slope/OmsSlope.java | OmsSlope.calculateSlope | public static double calculateSlope( GridNode node, double flowValue ) {
double value = doubleNovalue;
if (!isNovalue(flowValue)) {
int flowDir = (int) flowValue;
if (flowDir != 10) {
Direction direction = Direction.forFlow(flowDir);
double distance = direction.getDistance(node.xRes, node.yRes);
double currentElevation = node.elevation;
double nextElevation = node.getElevationAt(direction);
value = (currentElevation - nextElevation) / distance;
}
}
return value;
} | java | public static double calculateSlope( GridNode node, double flowValue ) {
double value = doubleNovalue;
if (!isNovalue(flowValue)) {
int flowDir = (int) flowValue;
if (flowDir != 10) {
Direction direction = Direction.forFlow(flowDir);
double distance = direction.getDistance(node.xRes, node.yRes);
double currentElevation = node.elevation;
double nextElevation = node.getElevationAt(direction);
value = (currentElevation - nextElevation) / distance;
}
}
return value;
} | [
"public",
"static",
"double",
"calculateSlope",
"(",
"GridNode",
"node",
",",
"double",
"flowValue",
")",
"{",
"double",
"value",
"=",
"doubleNovalue",
";",
"if",
"(",
"!",
"isNovalue",
"(",
"flowValue",
")",
")",
"{",
"int",
"flowDir",
"=",
"(",
"int",
")",
"flowValue",
";",
"if",
"(",
"flowDir",
"!=",
"10",
")",
"{",
"Direction",
"direction",
"=",
"Direction",
".",
"forFlow",
"(",
"flowDir",
")",
";",
"double",
"distance",
"=",
"direction",
".",
"getDistance",
"(",
"node",
".",
"xRes",
",",
"node",
".",
"yRes",
")",
";",
"double",
"currentElevation",
"=",
"node",
".",
"elevation",
";",
"double",
"nextElevation",
"=",
"node",
".",
"getElevationAt",
"(",
"direction",
")",
";",
"value",
"=",
"(",
"currentElevation",
"-",
"nextElevation",
")",
"/",
"distance",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Calculates the slope of a given flowdirection value in currentCol and currentRow.
@param node the current {@link GridNode}.
@param flowValue the value of the flowdirection.
@return | [
"Calculates",
"the",
"slope",
"of",
"a",
"given",
"flowdirection",
"value",
"in",
"currentCol",
"and",
"currentRow",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/slope/OmsSlope.java#L135-L148 |
137,836 | TheHortonMachine/hortonmachine | extras/sideprojects/gps/src/main/java/org/hortonmachine/gps/nmea/SerialNmeaGps.java | SerialNmeaGps.getAvailablePortNames | public static String[] getAvailablePortNames() {
SerialPort[] ports = SerialPort.getCommPorts();
String[] portNames = new String[ports.length];
for( int i = 0; i < portNames.length; i++ ) {
String systemPortName = ports[i].getSystemPortName();
portNames[i] = systemPortName;
}
return portNames;
} | java | public static String[] getAvailablePortNames() {
SerialPort[] ports = SerialPort.getCommPorts();
String[] portNames = new String[ports.length];
for( int i = 0; i < portNames.length; i++ ) {
String systemPortName = ports[i].getSystemPortName();
portNames[i] = systemPortName;
}
return portNames;
} | [
"public",
"static",
"String",
"[",
"]",
"getAvailablePortNames",
"(",
")",
"{",
"SerialPort",
"[",
"]",
"ports",
"=",
"SerialPort",
".",
"getCommPorts",
"(",
")",
";",
"String",
"[",
"]",
"portNames",
"=",
"new",
"String",
"[",
"ports",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"portNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"systemPortName",
"=",
"ports",
"[",
"i",
"]",
".",
"getSystemPortName",
"(",
")",
";",
"portNames",
"[",
"i",
"]",
"=",
"systemPortName",
";",
"}",
"return",
"portNames",
";",
"}"
] | Getter for the available serial ports.
@return the available serial ports system names. | [
"Getter",
"for",
"the",
"available",
"serial",
"ports",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/extras/sideprojects/gps/src/main/java/org/hortonmachine/gps/nmea/SerialNmeaGps.java#L102-L110 |
137,837 | TheHortonMachine/hortonmachine | extras/sideprojects/gps/src/main/java/org/hortonmachine/gps/nmea/SerialNmeaGps.java | SerialNmeaGps.isThisAGpsPort | public static boolean isThisAGpsPort( String port ) throws Exception {
SerialPort comPort = SerialPort.getCommPort(port);
comPort.openPort();
comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 100, 0);
int waitTries = 0;
int parseTries = 0;
while( true && waitTries++ < 10 && parseTries < 2 ) {
while( comPort.bytesAvailable() == 0 )
Thread.sleep(500);
byte[] readBuffer = new byte[comPort.bytesAvailable()];
int numRead = comPort.readBytes(readBuffer, readBuffer.length);
if (numRead > 0) {
String data = new String(readBuffer);
String[] split = data.split("\n");
for( String line : split ) {
if (SentenceValidator.isSentence(line)) {
return true;
}
}
parseTries++;
}
}
return false;
} | java | public static boolean isThisAGpsPort( String port ) throws Exception {
SerialPort comPort = SerialPort.getCommPort(port);
comPort.openPort();
comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 100, 0);
int waitTries = 0;
int parseTries = 0;
while( true && waitTries++ < 10 && parseTries < 2 ) {
while( comPort.bytesAvailable() == 0 )
Thread.sleep(500);
byte[] readBuffer = new byte[comPort.bytesAvailable()];
int numRead = comPort.readBytes(readBuffer, readBuffer.length);
if (numRead > 0) {
String data = new String(readBuffer);
String[] split = data.split("\n");
for( String line : split ) {
if (SentenceValidator.isSentence(line)) {
return true;
}
}
parseTries++;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isThisAGpsPort",
"(",
"String",
"port",
")",
"throws",
"Exception",
"{",
"SerialPort",
"comPort",
"=",
"SerialPort",
".",
"getCommPort",
"(",
"port",
")",
";",
"comPort",
".",
"openPort",
"(",
")",
";",
"comPort",
".",
"setComPortTimeouts",
"(",
"SerialPort",
".",
"TIMEOUT_READ_SEMI_BLOCKING",
",",
"100",
",",
"0",
")",
";",
"int",
"waitTries",
"=",
"0",
";",
"int",
"parseTries",
"=",
"0",
";",
"while",
"(",
"true",
"&&",
"waitTries",
"++",
"<",
"10",
"&&",
"parseTries",
"<",
"2",
")",
"{",
"while",
"(",
"comPort",
".",
"bytesAvailable",
"(",
")",
"==",
"0",
")",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"byte",
"[",
"]",
"readBuffer",
"=",
"new",
"byte",
"[",
"comPort",
".",
"bytesAvailable",
"(",
")",
"]",
";",
"int",
"numRead",
"=",
"comPort",
".",
"readBytes",
"(",
"readBuffer",
",",
"readBuffer",
".",
"length",
")",
";",
"if",
"(",
"numRead",
">",
"0",
")",
"{",
"String",
"data",
"=",
"new",
"String",
"(",
"readBuffer",
")",
";",
"String",
"[",
"]",
"split",
"=",
"data",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"for",
"(",
"String",
"line",
":",
"split",
")",
"{",
"if",
"(",
"SentenceValidator",
".",
"isSentence",
"(",
"line",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"parseTries",
"++",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Makes a blocking check to find out if the given port supplies GPS data.
@param port the port ti check.
@return <code>true</code> if the port supplies NMEA GPS data.
@throws Exception | [
"Makes",
"a",
"blocking",
"check",
"to",
"find",
"out",
"if",
"the",
"given",
"port",
"supplies",
"GPS",
"data",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/extras/sideprojects/gps/src/main/java/org/hortonmachine/gps/nmea/SerialNmeaGps.java#L124-L150 |
137,838 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/InvertibleMatrix.java | InvertibleMatrix.inverse | public InvertibleMatrix inverse() throws MatrixException
{
InvertibleMatrix inverse = new InvertibleMatrix(nRows);
IdentityMatrix identity = new IdentityMatrix(nRows);
// Compute each column of the inverse matrix
// using columns of the identity matrix.
for (int c = 0; c < nCols; ++c) {
ColumnVector col = solve(identity.getColumn(c), true);
inverse.setColumn(col, c);
}
return inverse;
} | java | public InvertibleMatrix inverse() throws MatrixException
{
InvertibleMatrix inverse = new InvertibleMatrix(nRows);
IdentityMatrix identity = new IdentityMatrix(nRows);
// Compute each column of the inverse matrix
// using columns of the identity matrix.
for (int c = 0; c < nCols; ++c) {
ColumnVector col = solve(identity.getColumn(c), true);
inverse.setColumn(col, c);
}
return inverse;
} | [
"public",
"InvertibleMatrix",
"inverse",
"(",
")",
"throws",
"MatrixException",
"{",
"InvertibleMatrix",
"inverse",
"=",
"new",
"InvertibleMatrix",
"(",
"nRows",
")",
";",
"IdentityMatrix",
"identity",
"=",
"new",
"IdentityMatrix",
"(",
"nRows",
")",
";",
"// Compute each column of the inverse matrix",
"// using columns of the identity matrix.",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"ColumnVector",
"col",
"=",
"solve",
"(",
"identity",
".",
"getColumn",
"(",
"c",
")",
",",
"true",
")",
";",
"inverse",
".",
"setColumn",
"(",
"col",
",",
"c",
")",
";",
"}",
"return",
"inverse",
";",
"}"
] | Compute the inverse of this matrix.
@return the inverse matrix
@throws matrix.MatrixException if an error occurred | [
"Compute",
"the",
"inverse",
"of",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/InvertibleMatrix.java#L31-L44 |
137,839 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/InvertibleMatrix.java | InvertibleMatrix.determinant | public double determinant() throws MatrixException
{
decompose();
// Each row exchange during forward elimination flips the sign
// of the determinant, so check for an odd number of exchanges.
double determinant = ((exchangeCount & 1) == 0) ? 1 : -1;
// Form the product of the diagonal elements of matrix U.
for (int i = 0; i < nRows; ++i) {
int pi = permutation[i]; // permuted index
determinant *= LU.at(pi, i);
}
return determinant;
} | java | public double determinant() throws MatrixException
{
decompose();
// Each row exchange during forward elimination flips the sign
// of the determinant, so check for an odd number of exchanges.
double determinant = ((exchangeCount & 1) == 0) ? 1 : -1;
// Form the product of the diagonal elements of matrix U.
for (int i = 0; i < nRows; ++i) {
int pi = permutation[i]; // permuted index
determinant *= LU.at(pi, i);
}
return determinant;
} | [
"public",
"double",
"determinant",
"(",
")",
"throws",
"MatrixException",
"{",
"decompose",
"(",
")",
";",
"// Each row exchange during forward elimination flips the sign",
"// of the determinant, so check for an odd number of exchanges.",
"double",
"determinant",
"=",
"(",
"(",
"exchangeCount",
"&",
"1",
")",
"==",
"0",
")",
"?",
"1",
":",
"-",
"1",
";",
"// Form the product of the diagonal elements of matrix U.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nRows",
";",
"++",
"i",
")",
"{",
"int",
"pi",
"=",
"permutation",
"[",
"i",
"]",
";",
"// permuted index",
"determinant",
"*=",
"LU",
".",
"at",
"(",
"pi",
",",
"i",
")",
";",
"}",
"return",
"determinant",
";",
"}"
] | Compute the determinant.
@return the determinant
@throws matrix.MatrixException if an error occurred | [
"Compute",
"the",
"determinant",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/InvertibleMatrix.java#L51-L66 |
137,840 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/InvertibleMatrix.java | InvertibleMatrix.norm | public double norm()
{
double sum = 0;
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
double v = values[r][c];
sum += v*v;
}
}
return (double) Math.sqrt(sum);
} | java | public double norm()
{
double sum = 0;
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
double v = values[r][c];
sum += v*v;
}
}
return (double) Math.sqrt(sum);
} | [
"public",
"double",
"norm",
"(",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"double",
"v",
"=",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"sum",
"+=",
"v",
"*",
"v",
";",
"}",
"}",
"return",
"(",
"double",
")",
"Math",
".",
"sqrt",
"(",
"sum",
")",
";",
"}"
] | Compute the Euclidean norm of this matrix.
@return the norm | [
"Compute",
"the",
"Euclidean",
"norm",
"of",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/InvertibleMatrix.java#L72-L84 |
137,841 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java | GpsTimeConverter.isleap | private static boolean isleap( double gpsTime ) {
boolean isLeap = false;
double[] leaps = getleaps();
for( int i = 0; i < leaps.length; i += 1 ) {
if (gpsTime == leaps[i]) {
isLeap = true;
break;
}
}
return isLeap;
} | java | private static boolean isleap( double gpsTime ) {
boolean isLeap = false;
double[] leaps = getleaps();
for( int i = 0; i < leaps.length; i += 1 ) {
if (gpsTime == leaps[i]) {
isLeap = true;
break;
}
}
return isLeap;
} | [
"private",
"static",
"boolean",
"isleap",
"(",
"double",
"gpsTime",
")",
"{",
"boolean",
"isLeap",
"=",
"false",
";",
"double",
"[",
"]",
"leaps",
"=",
"getleaps",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"leaps",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"gpsTime",
"==",
"leaps",
"[",
"i",
"]",
")",
"{",
"isLeap",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"isLeap",
";",
"}"
] | Test to see if a GPS second is a leap second | [
"Test",
"to",
"see",
"if",
"a",
"GPS",
"second",
"is",
"a",
"leap",
"second"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java#L57-L67 |
137,842 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java | GpsTimeConverter.countleaps | private static int countleaps( double gpsTime, boolean accum_leaps ) {
int i, nleaps;
double[] leaps = getleaps();
nleaps = 0;
if (accum_leaps) {
for( i = 0; i < leaps.length; i += 1 ) {
if (gpsTime + i >= leaps[i]) {
nleaps += 1;
}
}
} else {
for( i = 0; i < leaps.length; i += 1 ) {
if (gpsTime >= leaps[i]) {
nleaps += 1;
}
}
}
return nleaps;
} | java | private static int countleaps( double gpsTime, boolean accum_leaps ) {
int i, nleaps;
double[] leaps = getleaps();
nleaps = 0;
if (accum_leaps) {
for( i = 0; i < leaps.length; i += 1 ) {
if (gpsTime + i >= leaps[i]) {
nleaps += 1;
}
}
} else {
for( i = 0; i < leaps.length; i += 1 ) {
if (gpsTime >= leaps[i]) {
nleaps += 1;
}
}
}
return nleaps;
} | [
"private",
"static",
"int",
"countleaps",
"(",
"double",
"gpsTime",
",",
"boolean",
"accum_leaps",
")",
"{",
"int",
"i",
",",
"nleaps",
";",
"double",
"[",
"]",
"leaps",
"=",
"getleaps",
"(",
")",
";",
"nleaps",
"=",
"0",
";",
"if",
"(",
"accum_leaps",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"leaps",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"gpsTime",
"+",
"i",
">=",
"leaps",
"[",
"i",
"]",
")",
"{",
"nleaps",
"+=",
"1",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"leaps",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"gpsTime",
">=",
"leaps",
"[",
"i",
"]",
")",
"{",
"nleaps",
"+=",
"1",
";",
"}",
"}",
"}",
"return",
"nleaps",
";",
"}"
] | Count number of leap seconds that have passed | [
"Count",
"number",
"of",
"leap",
"seconds",
"that",
"have",
"passed"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java#L70-L89 |
137,843 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java | GpsTimeConverter.isunixtimeleap | private static boolean isunixtimeleap( double unixTime ) {
double gpsTime = unixTime - 315964800;
gpsTime += countleaps(gpsTime, true) - 1;
return isleap(gpsTime);
} | java | private static boolean isunixtimeleap( double unixTime ) {
double gpsTime = unixTime - 315964800;
gpsTime += countleaps(gpsTime, true) - 1;
return isleap(gpsTime);
} | [
"private",
"static",
"boolean",
"isunixtimeleap",
"(",
"double",
"unixTime",
")",
"{",
"double",
"gpsTime",
"=",
"unixTime",
"-",
"315964800",
";",
"gpsTime",
"+=",
"countleaps",
"(",
"gpsTime",
",",
"true",
")",
"-",
"1",
";",
"return",
"isleap",
"(",
"gpsTime",
")",
";",
"}"
] | Test to see if a unixtime second is a leap second | [
"Test",
"to",
"see",
"if",
"a",
"unixtime",
"second",
"is",
"a",
"leap",
"second"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java#L92-L97 |
137,844 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java | GpsTimeConverter.gpsWeekTime2WeekDay | public static EGpsWeekDays gpsWeekTime2WeekDay( double gpsWeekTime ) {
int seconds = (int) gpsWeekTime;
// week starts with Sunday
EGpsWeekDays day4Seconds = EGpsWeekDays.getDay4Seconds(seconds);
return day4Seconds;
} | java | public static EGpsWeekDays gpsWeekTime2WeekDay( double gpsWeekTime ) {
int seconds = (int) gpsWeekTime;
// week starts with Sunday
EGpsWeekDays day4Seconds = EGpsWeekDays.getDay4Seconds(seconds);
return day4Seconds;
} | [
"public",
"static",
"EGpsWeekDays",
"gpsWeekTime2WeekDay",
"(",
"double",
"gpsWeekTime",
")",
"{",
"int",
"seconds",
"=",
"(",
"int",
")",
"gpsWeekTime",
";",
"// week starts with Sunday",
"EGpsWeekDays",
"day4Seconds",
"=",
"EGpsWeekDays",
".",
"getDay4Seconds",
"(",
"seconds",
")",
";",
"return",
"day4Seconds",
";",
"}"
] | Convert GPS Week Time to the day of the week.
@param gpsWeekTime the gps time.
@return the day of the week. | [
"Convert",
"GPS",
"Week",
"Time",
"to",
"the",
"day",
"of",
"the",
"week",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java#L145-L150 |
137,845 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java | GpsTimeConverter.gpsWeekTime2ISO8601 | public static String gpsWeekTime2ISO8601( double gpsWeekTime ) {
DateTime gps2unix = gpsWeekTime2DateTime(gpsWeekTime);
return gps2unix.toString(ISO8601Formatter);
} | java | public static String gpsWeekTime2ISO8601( double gpsWeekTime ) {
DateTime gps2unix = gpsWeekTime2DateTime(gpsWeekTime);
return gps2unix.toString(ISO8601Formatter);
} | [
"public",
"static",
"String",
"gpsWeekTime2ISO8601",
"(",
"double",
"gpsWeekTime",
")",
"{",
"DateTime",
"gps2unix",
"=",
"gpsWeekTime2DateTime",
"(",
"gpsWeekTime",
")",
";",
"return",
"gps2unix",
".",
"toString",
"(",
"ISO8601Formatter",
")",
";",
"}"
] | Convert GPS Time to ISO8601 time string.
@param gpsWeekTime the gps time.
@return the ISO8601 string of the gps time. | [
"Convert",
"GPS",
"Time",
"to",
"ISO8601",
"time",
"string",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/utils/GpsTimeConverter.java#L158-L161 |
137,846 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/style/JFontChooser.java | JFontChooser.updateComponents | private void updateComponents() {
updatingComponents = true;
Font font = getFont();
fontList.setSelectedValue(font.getName(), true);
sizeList.setSelectedValue(font.getSize(), true);
boldCheckBox.setSelected(font.isBold());
italicCheckBox.setSelected(font.isItalic());
if (previewText == null) {
previewLabel.setText(font.getName());
}
// set the font and fire a property change
Font oldValue = previewLabel.getFont();
previewLabel.setFont(font);
firePropertyChange("font", oldValue, font);
updatingComponents = false;
} | java | private void updateComponents() {
updatingComponents = true;
Font font = getFont();
fontList.setSelectedValue(font.getName(), true);
sizeList.setSelectedValue(font.getSize(), true);
boldCheckBox.setSelected(font.isBold());
italicCheckBox.setSelected(font.isItalic());
if (previewText == null) {
previewLabel.setText(font.getName());
}
// set the font and fire a property change
Font oldValue = previewLabel.getFont();
previewLabel.setFont(font);
firePropertyChange("font", oldValue, font);
updatingComponents = false;
} | [
"private",
"void",
"updateComponents",
"(",
")",
"{",
"updatingComponents",
"=",
"true",
";",
"Font",
"font",
"=",
"getFont",
"(",
")",
";",
"fontList",
".",
"setSelectedValue",
"(",
"font",
".",
"getName",
"(",
")",
",",
"true",
")",
";",
"sizeList",
".",
"setSelectedValue",
"(",
"font",
".",
"getSize",
"(",
")",
",",
"true",
")",
";",
"boldCheckBox",
".",
"setSelected",
"(",
"font",
".",
"isBold",
"(",
")",
")",
";",
"italicCheckBox",
".",
"setSelected",
"(",
"font",
".",
"isItalic",
"(",
")",
")",
";",
"if",
"(",
"previewText",
"==",
"null",
")",
"{",
"previewLabel",
".",
"setText",
"(",
"font",
".",
"getName",
"(",
")",
")",
";",
"}",
"// set the font and fire a property change",
"Font",
"oldValue",
"=",
"previewLabel",
".",
"getFont",
"(",
")",
";",
"previewLabel",
".",
"setFont",
"(",
"font",
")",
";",
"firePropertyChange",
"(",
"\"font\"",
",",
"oldValue",
",",
"font",
")",
";",
"updatingComponents",
"=",
"false",
";",
"}"
] | Updates the font in the preview component according to the selected values. | [
"Updates",
"the",
"font",
"in",
"the",
"preview",
"component",
"according",
"to",
"the",
"selected",
"values",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/style/JFontChooser.java#L293-L313 |
137,847 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/style/JFontChooser.java | JFontChooser.setSelectionModel | public void setSelectionModel(FontSelectionModel newModel ) {
FontSelectionModel oldModel = selectionModel;
selectionModel = newModel;
oldModel.removeChangeListener(labelUpdater);
newModel.addChangeListener(labelUpdater);
firePropertyChange("selectionModel", oldModel, newModel);
} | java | public void setSelectionModel(FontSelectionModel newModel ) {
FontSelectionModel oldModel = selectionModel;
selectionModel = newModel;
oldModel.removeChangeListener(labelUpdater);
newModel.addChangeListener(labelUpdater);
firePropertyChange("selectionModel", oldModel, newModel);
} | [
"public",
"void",
"setSelectionModel",
"(",
"FontSelectionModel",
"newModel",
")",
"{",
"FontSelectionModel",
"oldModel",
"=",
"selectionModel",
";",
"selectionModel",
"=",
"newModel",
";",
"oldModel",
".",
"removeChangeListener",
"(",
"labelUpdater",
")",
";",
"newModel",
".",
"addChangeListener",
"(",
"labelUpdater",
")",
";",
"firePropertyChange",
"(",
"\"selectionModel\"",
",",
"oldModel",
",",
"newModel",
")",
";",
"}"
] | Set the model containing the selected font.
@param newModel the new FontSelectionModel object | [
"Set",
"the",
"model",
"containing",
"the",
"selected",
"font",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/style/JFontChooser.java#L330-L336 |
137,848 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/style/JFontChooser.java | DefaultFontSelectionModel.fireChangeListeners | protected void fireChangeListeners() {
ChangeEvent ev = new ChangeEvent(this);
Object[] l = listeners.getListeners(ChangeListener.class);
for (Object listener : l) {
((ChangeListener) listener).stateChanged(ev);
}
} | java | protected void fireChangeListeners() {
ChangeEvent ev = new ChangeEvent(this);
Object[] l = listeners.getListeners(ChangeListener.class);
for (Object listener : l) {
((ChangeListener) listener).stateChanged(ev);
}
} | [
"protected",
"void",
"fireChangeListeners",
"(",
")",
"{",
"ChangeEvent",
"ev",
"=",
"new",
"ChangeEvent",
"(",
"this",
")",
";",
"Object",
"[",
"]",
"l",
"=",
"listeners",
".",
"getListeners",
"(",
"ChangeListener",
".",
"class",
")",
";",
"for",
"(",
"Object",
"listener",
":",
"l",
")",
"{",
"(",
"(",
"ChangeListener",
")",
"listener",
")",
".",
"stateChanged",
"(",
"ev",
")",
";",
"}",
"}"
] | Fires the listeners registered with this model. | [
"Fires",
"the",
"listeners",
"registered",
"with",
"this",
"model",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/style/JFontChooser.java#L579-L585 |
137,849 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.process | @Execute
public void process() throws Exception {
if (!concatOr(outPit == null, doReset)) {
return;
}
checkNull(inElev);
HashMap<String, Double> regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inElev);
nCols = regionMap.get(CoverageUtilities.COLS).intValue();
nRows = regionMap.get(CoverageUtilities.ROWS).intValue();
xRes = regionMap.get(CoverageUtilities.XRES);
yRes = regionMap.get(CoverageUtilities.YRES);
elevationIter = CoverageUtilities.getRandomIterator(inElev);
// output raster
WritableRaster pitRaster = CoverageUtilities.createWritableRaster(nCols, nRows, null, null, null);
pitIter = CoverageUtilities.getWritableRandomIterator(pitRaster);
for( int i = 0; i < nRows; i++ ) {
if (pm.isCanceled()) {
return;
}
for( int j = 0; j < nCols; j++ ) {
double value = elevationIter.getSampleDouble(j, i, 0);
if (!isNovalue(value)) {
pitIter.setSample(j, i, 0, value);
} else {
pitIter.setSample(j, i, 0, PITNOVALUE);
}
}
}
flood();
if (pm.isCanceled()) {
return;
}
for( int i = 0; i < nRows; i++ ) {
if (pm.isCanceled()) {
return;
}
for( int j = 0; j < nCols; j++ ) {
if (dir[j][i] == 0) {
return;
}
double value = pitIter.getSampleDouble(j, i, 0);
if (value == PITNOVALUE || isNovalue(value)) {
pitIter.setSample(j, i, 0, doubleNovalue);
}
}
}
pitIter.done();
outPit = CoverageUtilities.buildCoverage("pitfiller", pitRaster, regionMap, inElev.getCoordinateReferenceSystem());
} | java | @Execute
public void process() throws Exception {
if (!concatOr(outPit == null, doReset)) {
return;
}
checkNull(inElev);
HashMap<String, Double> regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inElev);
nCols = regionMap.get(CoverageUtilities.COLS).intValue();
nRows = regionMap.get(CoverageUtilities.ROWS).intValue();
xRes = regionMap.get(CoverageUtilities.XRES);
yRes = regionMap.get(CoverageUtilities.YRES);
elevationIter = CoverageUtilities.getRandomIterator(inElev);
// output raster
WritableRaster pitRaster = CoverageUtilities.createWritableRaster(nCols, nRows, null, null, null);
pitIter = CoverageUtilities.getWritableRandomIterator(pitRaster);
for( int i = 0; i < nRows; i++ ) {
if (pm.isCanceled()) {
return;
}
for( int j = 0; j < nCols; j++ ) {
double value = elevationIter.getSampleDouble(j, i, 0);
if (!isNovalue(value)) {
pitIter.setSample(j, i, 0, value);
} else {
pitIter.setSample(j, i, 0, PITNOVALUE);
}
}
}
flood();
if (pm.isCanceled()) {
return;
}
for( int i = 0; i < nRows; i++ ) {
if (pm.isCanceled()) {
return;
}
for( int j = 0; j < nCols; j++ ) {
if (dir[j][i] == 0) {
return;
}
double value = pitIter.getSampleDouble(j, i, 0);
if (value == PITNOVALUE || isNovalue(value)) {
pitIter.setSample(j, i, 0, doubleNovalue);
}
}
}
pitIter.done();
outPit = CoverageUtilities.buildCoverage("pitfiller", pitRaster, regionMap, inElev.getCoordinateReferenceSystem());
} | [
"@",
"Execute",
"public",
"void",
"process",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"concatOr",
"(",
"outPit",
"==",
"null",
",",
"doReset",
")",
")",
"{",
"return",
";",
"}",
"checkNull",
"(",
"inElev",
")",
";",
"HashMap",
"<",
"String",
",",
"Double",
">",
"regionMap",
"=",
"CoverageUtilities",
".",
"getRegionParamsFromGridCoverage",
"(",
"inElev",
")",
";",
"nCols",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"COLS",
")",
".",
"intValue",
"(",
")",
";",
"nRows",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"ROWS",
")",
".",
"intValue",
"(",
")",
";",
"xRes",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"XRES",
")",
";",
"yRes",
"=",
"regionMap",
".",
"get",
"(",
"CoverageUtilities",
".",
"YRES",
")",
";",
"elevationIter",
"=",
"CoverageUtilities",
".",
"getRandomIterator",
"(",
"inElev",
")",
";",
"// output raster",
"WritableRaster",
"pitRaster",
"=",
"CoverageUtilities",
".",
"createWritableRaster",
"(",
"nCols",
",",
"nRows",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"pitIter",
"=",
"CoverageUtilities",
".",
"getWritableRandomIterator",
"(",
"pitRaster",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nRows",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pm",
".",
"isCanceled",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"nCols",
";",
"j",
"++",
")",
"{",
"double",
"value",
"=",
"elevationIter",
".",
"getSampleDouble",
"(",
"j",
",",
"i",
",",
"0",
")",
";",
"if",
"(",
"!",
"isNovalue",
"(",
"value",
")",
")",
"{",
"pitIter",
".",
"setSample",
"(",
"j",
",",
"i",
",",
"0",
",",
"value",
")",
";",
"}",
"else",
"{",
"pitIter",
".",
"setSample",
"(",
"j",
",",
"i",
",",
"0",
",",
"PITNOVALUE",
")",
";",
"}",
"}",
"}",
"flood",
"(",
")",
";",
"if",
"(",
"pm",
".",
"isCanceled",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nRows",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pm",
".",
"isCanceled",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"nCols",
";",
"j",
"++",
")",
"{",
"if",
"(",
"dir",
"[",
"j",
"]",
"[",
"i",
"]",
"==",
"0",
")",
"{",
"return",
";",
"}",
"double",
"value",
"=",
"pitIter",
".",
"getSampleDouble",
"(",
"j",
",",
"i",
",",
"0",
")",
";",
"if",
"(",
"value",
"==",
"PITNOVALUE",
"||",
"isNovalue",
"(",
"value",
")",
")",
"{",
"pitIter",
".",
"setSample",
"(",
"j",
",",
"i",
",",
"0",
",",
"doubleNovalue",
")",
";",
"}",
"}",
"}",
"pitIter",
".",
"done",
"(",
")",
";",
"outPit",
"=",
"CoverageUtilities",
".",
"buildCoverage",
"(",
"\"pitfiller\"",
",",
"pitRaster",
",",
"regionMap",
",",
"inElev",
".",
"getCoordinateReferenceSystem",
"(",
")",
")",
";",
"}"
] | The pitfiller algorithm.
@throws Exception | [
"The",
"pitfiller",
"algorithm",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L145-L199 |
137,850 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.flood | private void flood() throws Exception {
/* define directions */
// Initialise the vector to a supposed dimension, if the number of
// unresolved pixel overload the vector there are a method which resized
// the vectors.
pitsStackSize = (int) (nCols * nRows * 0.1);
pstack = pitsStackSize;
dn = new int[pitsStackSize];
currentPitRows = new int[pitsStackSize];
currentPitCols = new int[pitsStackSize];
ipool = new int[pstack];
jpool = new int[pstack];
firstCol = 0;
firstRow = 0;
lastCol = nCols;
lastRow = nRows;
setdf();
} | java | private void flood() throws Exception {
/* define directions */
// Initialise the vector to a supposed dimension, if the number of
// unresolved pixel overload the vector there are a method which resized
// the vectors.
pitsStackSize = (int) (nCols * nRows * 0.1);
pstack = pitsStackSize;
dn = new int[pitsStackSize];
currentPitRows = new int[pitsStackSize];
currentPitCols = new int[pitsStackSize];
ipool = new int[pstack];
jpool = new int[pstack];
firstCol = 0;
firstRow = 0;
lastCol = nCols;
lastRow = nRows;
setdf();
} | [
"private",
"void",
"flood",
"(",
")",
"throws",
"Exception",
"{",
"/* define directions */",
"// Initialise the vector to a supposed dimension, if the number of",
"// unresolved pixel overload the vector there are a method which resized",
"// the vectors.",
"pitsStackSize",
"=",
"(",
"int",
")",
"(",
"nCols",
"*",
"nRows",
"*",
"0.1",
")",
";",
"pstack",
"=",
"pitsStackSize",
";",
"dn",
"=",
"new",
"int",
"[",
"pitsStackSize",
"]",
";",
"currentPitRows",
"=",
"new",
"int",
"[",
"pitsStackSize",
"]",
";",
"currentPitCols",
"=",
"new",
"int",
"[",
"pitsStackSize",
"]",
";",
"ipool",
"=",
"new",
"int",
"[",
"pstack",
"]",
";",
"jpool",
"=",
"new",
"int",
"[",
"pstack",
"]",
";",
"firstCol",
"=",
"0",
";",
"firstRow",
"=",
"0",
";",
"lastCol",
"=",
"nCols",
";",
"lastRow",
"=",
"nRows",
";",
"setdf",
"(",
")",
";",
"}"
] | Takes the elevation matrix and calculate a matrix with pits filled, using the flooding
algorithm.
@throws Exception | [
"Takes",
"the",
"elevation",
"matrix",
"and",
"calculate",
"a",
"matrix",
"with",
"pits",
"filled",
"using",
"the",
"flooding",
"algorithm",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L207-L227 |
137,851 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.addPitToStack | private void addPitToStack( int row, int col ) {
currentPitsCount = currentPitsCount + 1;
if (currentPitsCount >= pitsStackSize) {
pitsStackSize = (int) (pitsStackSize + nCols * nRows * .1) + 2;
currentPitRows = realloc(currentPitRows, pitsStackSize);
currentPitCols = realloc(currentPitCols, pitsStackSize);
dn = realloc(dn, pitsStackSize);
}
currentPitRows[currentPitsCount] = row;
currentPitCols[currentPitsCount] = col;
} | java | private void addPitToStack( int row, int col ) {
currentPitsCount = currentPitsCount + 1;
if (currentPitsCount >= pitsStackSize) {
pitsStackSize = (int) (pitsStackSize + nCols * nRows * .1) + 2;
currentPitRows = realloc(currentPitRows, pitsStackSize);
currentPitCols = realloc(currentPitCols, pitsStackSize);
dn = realloc(dn, pitsStackSize);
}
currentPitRows[currentPitsCount] = row;
currentPitCols[currentPitsCount] = col;
} | [
"private",
"void",
"addPitToStack",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"currentPitsCount",
"=",
"currentPitsCount",
"+",
"1",
";",
"if",
"(",
"currentPitsCount",
">=",
"pitsStackSize",
")",
"{",
"pitsStackSize",
"=",
"(",
"int",
")",
"(",
"pitsStackSize",
"+",
"nCols",
"*",
"nRows",
"*",
".1",
")",
"+",
"2",
";",
"currentPitRows",
"=",
"realloc",
"(",
"currentPitRows",
",",
"pitsStackSize",
")",
";",
"currentPitCols",
"=",
"realloc",
"(",
"currentPitCols",
",",
"pitsStackSize",
")",
";",
"dn",
"=",
"realloc",
"(",
"dn",
",",
"pitsStackSize",
")",
";",
"}",
"currentPitRows",
"[",
"currentPitsCount",
"]",
"=",
"row",
";",
"currentPitCols",
"[",
"currentPitsCount",
"]",
"=",
"col",
";",
"}"
] | Adds a pit position to the stack.
@param row the row of the pit.
@param col the col of the pit. | [
"Adds",
"a",
"pit",
"position",
"to",
"the",
"stack",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L457-L468 |
137,852 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.resolveFlats | private int resolveFlats( int pitsCount ) {
int stillPitsCount;
currentPitsCount = pitsCount;
do {
if (pm.isCanceled()) {
return -1;
}
pitsCount = currentPitsCount;
currentPitsCount = 0;
for( int ip = 1; ip <= pitsCount; ip++ ) {
dn[ip] = 0;
}
for( int k = 1; k <= 8; k++ ) {
for( int pitIndex = 1; pitIndex <= pitsCount; pitIndex++ ) {
double elevDelta = pitIter.getSampleDouble(currentPitCols[pitIndex], currentPitRows[pitIndex], 0)
- pitIter.getSampleDouble(currentPitCols[pitIndex] + DIR_WITHFLOW_EXITING_INVERTED[k][0],
currentPitRows[pitIndex] + DIR_WITHFLOW_EXITING_INVERTED[k][1], 0);
if ((elevDelta >= 0.)
&& ((dir[currentPitCols[pitIndex] + DIR_WITHFLOW_EXITING_INVERTED[k][0]][currentPitRows[pitIndex]
+ DIR_WITHFLOW_EXITING_INVERTED[k][1]] != 0) && (dn[pitIndex] == 0)))
dn[pitIndex] = k;
}
}
stillPitsCount = 1; /* location of point on stack with lowest elevation */
for( int pitIndex = 1; pitIndex <= pitsCount; pitIndex++ ) {
if (dn[pitIndex] > 0) {
dir[currentPitCols[pitIndex]][currentPitRows[pitIndex]] = dn[pitIndex];
} else {
currentPitsCount++;
currentPitRows[currentPitsCount] = currentPitRows[pitIndex];
currentPitCols[currentPitsCount] = currentPitCols[pitIndex];
if (pitIter.getSampleDouble(currentPitCols[currentPitsCount], currentPitRows[currentPitsCount], 0) < pitIter
.getSampleDouble(currentPitCols[stillPitsCount], currentPitRows[stillPitsCount], 0))
stillPitsCount = currentPitsCount;
}
}
// out.println("vdn n = " + n + "nis = " + nis);
} while( currentPitsCount < pitsCount );
return stillPitsCount;
} | java | private int resolveFlats( int pitsCount ) {
int stillPitsCount;
currentPitsCount = pitsCount;
do {
if (pm.isCanceled()) {
return -1;
}
pitsCount = currentPitsCount;
currentPitsCount = 0;
for( int ip = 1; ip <= pitsCount; ip++ ) {
dn[ip] = 0;
}
for( int k = 1; k <= 8; k++ ) {
for( int pitIndex = 1; pitIndex <= pitsCount; pitIndex++ ) {
double elevDelta = pitIter.getSampleDouble(currentPitCols[pitIndex], currentPitRows[pitIndex], 0)
- pitIter.getSampleDouble(currentPitCols[pitIndex] + DIR_WITHFLOW_EXITING_INVERTED[k][0],
currentPitRows[pitIndex] + DIR_WITHFLOW_EXITING_INVERTED[k][1], 0);
if ((elevDelta >= 0.)
&& ((dir[currentPitCols[pitIndex] + DIR_WITHFLOW_EXITING_INVERTED[k][0]][currentPitRows[pitIndex]
+ DIR_WITHFLOW_EXITING_INVERTED[k][1]] != 0) && (dn[pitIndex] == 0)))
dn[pitIndex] = k;
}
}
stillPitsCount = 1; /* location of point on stack with lowest elevation */
for( int pitIndex = 1; pitIndex <= pitsCount; pitIndex++ ) {
if (dn[pitIndex] > 0) {
dir[currentPitCols[pitIndex]][currentPitRows[pitIndex]] = dn[pitIndex];
} else {
currentPitsCount++;
currentPitRows[currentPitsCount] = currentPitRows[pitIndex];
currentPitCols[currentPitsCount] = currentPitCols[pitIndex];
if (pitIter.getSampleDouble(currentPitCols[currentPitsCount], currentPitRows[currentPitsCount], 0) < pitIter
.getSampleDouble(currentPitCols[stillPitsCount], currentPitRows[stillPitsCount], 0))
stillPitsCount = currentPitsCount;
}
}
// out.println("vdn n = " + n + "nis = " + nis);
} while( currentPitsCount < pitsCount );
return stillPitsCount;
} | [
"private",
"int",
"resolveFlats",
"(",
"int",
"pitsCount",
")",
"{",
"int",
"stillPitsCount",
";",
"currentPitsCount",
"=",
"pitsCount",
";",
"do",
"{",
"if",
"(",
"pm",
".",
"isCanceled",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"pitsCount",
"=",
"currentPitsCount",
";",
"currentPitsCount",
"=",
"0",
";",
"for",
"(",
"int",
"ip",
"=",
"1",
";",
"ip",
"<=",
"pitsCount",
";",
"ip",
"++",
")",
"{",
"dn",
"[",
"ip",
"]",
"=",
"0",
";",
"}",
"for",
"(",
"int",
"k",
"=",
"1",
";",
"k",
"<=",
"8",
";",
"k",
"++",
")",
"{",
"for",
"(",
"int",
"pitIndex",
"=",
"1",
";",
"pitIndex",
"<=",
"pitsCount",
";",
"pitIndex",
"++",
")",
"{",
"double",
"elevDelta",
"=",
"pitIter",
".",
"getSampleDouble",
"(",
"currentPitCols",
"[",
"pitIndex",
"]",
",",
"currentPitRows",
"[",
"pitIndex",
"]",
",",
"0",
")",
"-",
"pitIter",
".",
"getSampleDouble",
"(",
"currentPitCols",
"[",
"pitIndex",
"]",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"0",
"]",
",",
"currentPitRows",
"[",
"pitIndex",
"]",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"1",
"]",
",",
"0",
")",
";",
"if",
"(",
"(",
"elevDelta",
">=",
"0.",
")",
"&&",
"(",
"(",
"dir",
"[",
"currentPitCols",
"[",
"pitIndex",
"]",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"0",
"]",
"]",
"[",
"currentPitRows",
"[",
"pitIndex",
"]",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"1",
"]",
"]",
"!=",
"0",
")",
"&&",
"(",
"dn",
"[",
"pitIndex",
"]",
"==",
"0",
")",
")",
")",
"dn",
"[",
"pitIndex",
"]",
"=",
"k",
";",
"}",
"}",
"stillPitsCount",
"=",
"1",
";",
"/* location of point on stack with lowest elevation */",
"for",
"(",
"int",
"pitIndex",
"=",
"1",
";",
"pitIndex",
"<=",
"pitsCount",
";",
"pitIndex",
"++",
")",
"{",
"if",
"(",
"dn",
"[",
"pitIndex",
"]",
">",
"0",
")",
"{",
"dir",
"[",
"currentPitCols",
"[",
"pitIndex",
"]",
"]",
"[",
"currentPitRows",
"[",
"pitIndex",
"]",
"]",
"=",
"dn",
"[",
"pitIndex",
"]",
";",
"}",
"else",
"{",
"currentPitsCount",
"++",
";",
"currentPitRows",
"[",
"currentPitsCount",
"]",
"=",
"currentPitRows",
"[",
"pitIndex",
"]",
";",
"currentPitCols",
"[",
"currentPitsCount",
"]",
"=",
"currentPitCols",
"[",
"pitIndex",
"]",
";",
"if",
"(",
"pitIter",
".",
"getSampleDouble",
"(",
"currentPitCols",
"[",
"currentPitsCount",
"]",
",",
"currentPitRows",
"[",
"currentPitsCount",
"]",
",",
"0",
")",
"<",
"pitIter",
".",
"getSampleDouble",
"(",
"currentPitCols",
"[",
"stillPitsCount",
"]",
",",
"currentPitRows",
"[",
"stillPitsCount",
"]",
",",
"0",
")",
")",
"stillPitsCount",
"=",
"currentPitsCount",
";",
"}",
"}",
"// out.println(\"vdn n = \" + n + \"nis = \" + nis);",
"}",
"while",
"(",
"currentPitsCount",
"<",
"pitsCount",
")",
";",
"return",
"stillPitsCount",
";",
"}"
] | Try to find a drainage direction for undefinite cell.
<p> If the drainage direction is found
then puts it in the dir matrix else keeps its index in is and js.
</p>
<p>N.B. in the {@link #setDirection(double, int, int, int[][], double[])} method the drainage
directions is set only if the slope between two pixel is positive.<b>At this step the dir
value is set also if the slope is equal to zero.</b></p>
@param pitsCount the number of indefinite cell in the dir matrix.
@return the number of unresolved pixel (still pits) after running the method or -1 if the process has been cancelled. | [
"Try",
"to",
"find",
"a",
"drainage",
"direction",
"for",
"undefinite",
"cell",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L489-L531 |
137,853 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.pool | private int pool( int row, int col, int prevNPool ) {
int in;
int jn;
int npool = prevNPool;
if (apool[col][row] <= 0) { /* not already part of a pool */
if (dir[col][row] != -1) {/* check only dir since dir was initialized */
/* not on boundary */
apool[col][row] = pooln;/* apool assigned pool number */
npool = npool + 1;// the number of pixel in the pool
if (npool >= pstack) {
if (pstack < nCols * nRows) {
pstack = (int) (pstack + nCols * nRows * .1);
if (pstack > nCols * nRows) {
/* Pool stack too large */
}
ipool = realloc(ipool, pstack);
jpool = realloc(jpool, pstack);
}
}
ipool[npool] = row;
jpool[npool] = col;
for( int k = 1; k <= 8; k++ ) {
in = row + DIR_WITHFLOW_EXITING_INVERTED[k][1];
jn = col + DIR_WITHFLOW_EXITING_INVERTED[k][0];
/* test if neighbor drains towards cell excluding boundaries */
if (((dir[jn][in] > 0) && ((dir[jn][in] - k == 4) || (dir[jn][in] - k == -4))) || ((dir[jn][in] == 0)
&& (pitIter.getSampleDouble(jn, in, 0) >= pitIter.getSampleDouble(col, row, 0)))) {
/* so that adjacent flats get included */
npool = pool(in, jn, npool);
}
}
}
}
return npool;
} | java | private int pool( int row, int col, int prevNPool ) {
int in;
int jn;
int npool = prevNPool;
if (apool[col][row] <= 0) { /* not already part of a pool */
if (dir[col][row] != -1) {/* check only dir since dir was initialized */
/* not on boundary */
apool[col][row] = pooln;/* apool assigned pool number */
npool = npool + 1;// the number of pixel in the pool
if (npool >= pstack) {
if (pstack < nCols * nRows) {
pstack = (int) (pstack + nCols * nRows * .1);
if (pstack > nCols * nRows) {
/* Pool stack too large */
}
ipool = realloc(ipool, pstack);
jpool = realloc(jpool, pstack);
}
}
ipool[npool] = row;
jpool[npool] = col;
for( int k = 1; k <= 8; k++ ) {
in = row + DIR_WITHFLOW_EXITING_INVERTED[k][1];
jn = col + DIR_WITHFLOW_EXITING_INVERTED[k][0];
/* test if neighbor drains towards cell excluding boundaries */
if (((dir[jn][in] > 0) && ((dir[jn][in] - k == 4) || (dir[jn][in] - k == -4))) || ((dir[jn][in] == 0)
&& (pitIter.getSampleDouble(jn, in, 0) >= pitIter.getSampleDouble(col, row, 0)))) {
/* so that adjacent flats get included */
npool = pool(in, jn, npool);
}
}
}
}
return npool;
} | [
"private",
"int",
"pool",
"(",
"int",
"row",
",",
"int",
"col",
",",
"int",
"prevNPool",
")",
"{",
"int",
"in",
";",
"int",
"jn",
";",
"int",
"npool",
"=",
"prevNPool",
";",
"if",
"(",
"apool",
"[",
"col",
"]",
"[",
"row",
"]",
"<=",
"0",
")",
"{",
"/* not already part of a pool */",
"if",
"(",
"dir",
"[",
"col",
"]",
"[",
"row",
"]",
"!=",
"-",
"1",
")",
"{",
"/* check only dir since dir was initialized */",
"/* not on boundary */",
"apool",
"[",
"col",
"]",
"[",
"row",
"]",
"=",
"pooln",
";",
"/* apool assigned pool number */",
"npool",
"=",
"npool",
"+",
"1",
";",
"// the number of pixel in the pool",
"if",
"(",
"npool",
">=",
"pstack",
")",
"{",
"if",
"(",
"pstack",
"<",
"nCols",
"*",
"nRows",
")",
"{",
"pstack",
"=",
"(",
"int",
")",
"(",
"pstack",
"+",
"nCols",
"*",
"nRows",
"*",
".1",
")",
";",
"if",
"(",
"pstack",
">",
"nCols",
"*",
"nRows",
")",
"{",
"/* Pool stack too large */",
"}",
"ipool",
"=",
"realloc",
"(",
"ipool",
",",
"pstack",
")",
";",
"jpool",
"=",
"realloc",
"(",
"jpool",
",",
"pstack",
")",
";",
"}",
"}",
"ipool",
"[",
"npool",
"]",
"=",
"row",
";",
"jpool",
"[",
"npool",
"]",
"=",
"col",
";",
"for",
"(",
"int",
"k",
"=",
"1",
";",
"k",
"<=",
"8",
";",
"k",
"++",
")",
"{",
"in",
"=",
"row",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"1",
"]",
";",
"jn",
"=",
"col",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"0",
"]",
";",
"/* test if neighbor drains towards cell excluding boundaries */",
"if",
"(",
"(",
"(",
"dir",
"[",
"jn",
"]",
"[",
"in",
"]",
">",
"0",
")",
"&&",
"(",
"(",
"dir",
"[",
"jn",
"]",
"[",
"in",
"]",
"-",
"k",
"==",
"4",
")",
"||",
"(",
"dir",
"[",
"jn",
"]",
"[",
"in",
"]",
"-",
"k",
"==",
"-",
"4",
")",
")",
")",
"||",
"(",
"(",
"dir",
"[",
"jn",
"]",
"[",
"in",
"]",
"==",
"0",
")",
"&&",
"(",
"pitIter",
".",
"getSampleDouble",
"(",
"jn",
",",
"in",
",",
"0",
")",
">=",
"pitIter",
".",
"getSampleDouble",
"(",
"col",
",",
"row",
",",
"0",
")",
")",
")",
")",
"{",
"/* so that adjacent flats get included */",
"npool",
"=",
"pool",
"(",
"in",
",",
"jn",
",",
"npool",
")",
";",
"}",
"}",
"}",
"}",
"return",
"npool",
";",
"}"
] | function to compute pool recursively and at the same time determine the minimum elevation of
the edge. | [
"function",
"to",
"compute",
"pool",
"recursively",
"and",
"at",
"the",
"same",
"time",
"determine",
"the",
"minimum",
"elevation",
"of",
"the",
"edge",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L537-L576 |
137,854 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.setDirection | private void setDirection( double pitValue, int row, int col, int[][] dir, double[] fact ) {
dir[col][row] = 0; /* This necessary to repeat passes after level raised */
double smax = 0.0;
// examine adjacent cells first
for( int k = 1; k <= 8; k++ ) {
int cn = col + DIR_WITHFLOW_EXITING_INVERTED[k][0];
int rn = row + DIR_WITHFLOW_EXITING_INVERTED[k][1];
double pitN = pitIter.getSampleDouble(cn, rn, 0);
if (isNovalue(pitN)) {
dir[col][row] = -1;
break;
}
if (dir[col][row] != -1) {
double slope = fact[k] * (pitValue - pitN);
if (slope > smax) {
smax = slope;
// maximum slope gives the drainage direction
dir[col][row] = k;
}
}
}
} | java | private void setDirection( double pitValue, int row, int col, int[][] dir, double[] fact ) {
dir[col][row] = 0; /* This necessary to repeat passes after level raised */
double smax = 0.0;
// examine adjacent cells first
for( int k = 1; k <= 8; k++ ) {
int cn = col + DIR_WITHFLOW_EXITING_INVERTED[k][0];
int rn = row + DIR_WITHFLOW_EXITING_INVERTED[k][1];
double pitN = pitIter.getSampleDouble(cn, rn, 0);
if (isNovalue(pitN)) {
dir[col][row] = -1;
break;
}
if (dir[col][row] != -1) {
double slope = fact[k] * (pitValue - pitN);
if (slope > smax) {
smax = slope;
// maximum slope gives the drainage direction
dir[col][row] = k;
}
}
}
} | [
"private",
"void",
"setDirection",
"(",
"double",
"pitValue",
",",
"int",
"row",
",",
"int",
"col",
",",
"int",
"[",
"]",
"[",
"]",
"dir",
",",
"double",
"[",
"]",
"fact",
")",
"{",
"dir",
"[",
"col",
"]",
"[",
"row",
"]",
"=",
"0",
";",
"/* This necessary to repeat passes after level raised */",
"double",
"smax",
"=",
"0.0",
";",
"// examine adjacent cells first",
"for",
"(",
"int",
"k",
"=",
"1",
";",
"k",
"<=",
"8",
";",
"k",
"++",
")",
"{",
"int",
"cn",
"=",
"col",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"0",
"]",
";",
"int",
"rn",
"=",
"row",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"1",
"]",
";",
"double",
"pitN",
"=",
"pitIter",
".",
"getSampleDouble",
"(",
"cn",
",",
"rn",
",",
"0",
")",
";",
"if",
"(",
"isNovalue",
"(",
"pitN",
")",
")",
"{",
"dir",
"[",
"col",
"]",
"[",
"row",
"]",
"=",
"-",
"1",
";",
"break",
";",
"}",
"if",
"(",
"dir",
"[",
"col",
"]",
"[",
"row",
"]",
"!=",
"-",
"1",
")",
"{",
"double",
"slope",
"=",
"fact",
"[",
"k",
"]",
"*",
"(",
"pitValue",
"-",
"pitN",
")",
";",
"if",
"(",
"slope",
">",
"smax",
")",
"{",
"smax",
"=",
"slope",
";",
"// maximum slope gives the drainage direction",
"dir",
"[",
"col",
"]",
"[",
"row",
"]",
"=",
"k",
";",
"}",
"}",
"}",
"}"
] | Calculate the drainage direction with the D8 method.
<p>Find the direction that has the maximum
slope and set it as the drainage direction the in the cell (r,c)
in the dir matrix.
@param pitValue the value of pit in row/col.
@param row row of the cell in the matrix.
@param col col of the cell in the matrix.
@param dir the drainage direction matrix to set the dircetion in. The cell contains an int value in the range 0 to 8
(or 10 if it is an outlet point).
@param fact is the direction factor (1/lenght). | [
"Calculate",
"the",
"drainage",
"direction",
"with",
"the",
"D8",
"method",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L600-L623 |
137,855 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.calculateDirectionFactor | private double[] calculateDirectionFactor( double dx, double dy ) {
// direction factor, where the components are 1/length
double[] fact = new double[9];
for( int k = 1; k <= 8; k++ ) {
fact[k] = 1.0 / (Math.sqrt(DIR_WITHFLOW_EXITING_INVERTED[k][0] * dy * DIR_WITHFLOW_EXITING_INVERTED[k][0] * dy
+ DIR_WITHFLOW_EXITING_INVERTED[k][1] * DIR_WITHFLOW_EXITING_INVERTED[k][1] * dx * dx));
}
return fact;
} | java | private double[] calculateDirectionFactor( double dx, double dy ) {
// direction factor, where the components are 1/length
double[] fact = new double[9];
for( int k = 1; k <= 8; k++ ) {
fact[k] = 1.0 / (Math.sqrt(DIR_WITHFLOW_EXITING_INVERTED[k][0] * dy * DIR_WITHFLOW_EXITING_INVERTED[k][0] * dy
+ DIR_WITHFLOW_EXITING_INVERTED[k][1] * DIR_WITHFLOW_EXITING_INVERTED[k][1] * dx * dx));
}
return fact;
} | [
"private",
"double",
"[",
"]",
"calculateDirectionFactor",
"(",
"double",
"dx",
",",
"double",
"dy",
")",
"{",
"// direction factor, where the components are 1/length",
"double",
"[",
"]",
"fact",
"=",
"new",
"double",
"[",
"9",
"]",
";",
"for",
"(",
"int",
"k",
"=",
"1",
";",
"k",
"<=",
"8",
";",
"k",
"++",
")",
"{",
"fact",
"[",
"k",
"]",
"=",
"1.0",
"/",
"(",
"Math",
".",
"sqrt",
"(",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"0",
"]",
"*",
"dy",
"*",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"0",
"]",
"*",
"dy",
"+",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"1",
"]",
"*",
"DIR_WITHFLOW_EXITING_INVERTED",
"[",
"k",
"]",
"[",
"1",
"]",
"*",
"dx",
"*",
"dx",
")",
")",
";",
"}",
"return",
"fact",
";",
"}"
] | Calculate the drainage direction factor.
@param dx is the resolution of the raster map in the x direction.
@param dy is the resolution of the raster map in the y direction.
@return <b>fact</b> the direction factor (or 1/length) where length is the distance of the
pixel from the central pixel. | [
"Calculate",
"the",
"drainage",
"direction",
"factor",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L633-L641 |
137,856 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/flow/OmsLeastCostFlowDirections.java | OmsLeastCostFlowDirections.assignFlowDirection | private boolean assignFlowDirection( GridNode current, GridNode diagonal, GridNode node1, GridNode node2 ) {
double diagonalSlope = abs(current.getSlopeTo(diagonal));
if (node1 != null) {
double tmpSlope = abs(diagonal.getSlopeTo(node1));
if (diagonalSlope < tmpSlope) {
return false;
}
}
if (node2 != null) {
double tmpSlope = abs(diagonal.getSlopeTo(node2));
if (diagonalSlope < tmpSlope) {
return false;
}
}
return true;
} | java | private boolean assignFlowDirection( GridNode current, GridNode diagonal, GridNode node1, GridNode node2 ) {
double diagonalSlope = abs(current.getSlopeTo(diagonal));
if (node1 != null) {
double tmpSlope = abs(diagonal.getSlopeTo(node1));
if (diagonalSlope < tmpSlope) {
return false;
}
}
if (node2 != null) {
double tmpSlope = abs(diagonal.getSlopeTo(node2));
if (diagonalSlope < tmpSlope) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"assignFlowDirection",
"(",
"GridNode",
"current",
",",
"GridNode",
"diagonal",
",",
"GridNode",
"node1",
",",
"GridNode",
"node2",
")",
"{",
"double",
"diagonalSlope",
"=",
"abs",
"(",
"current",
".",
"getSlopeTo",
"(",
"diagonal",
")",
")",
";",
"if",
"(",
"node1",
"!=",
"null",
")",
"{",
"double",
"tmpSlope",
"=",
"abs",
"(",
"diagonal",
".",
"getSlopeTo",
"(",
"node1",
")",
")",
";",
"if",
"(",
"diagonalSlope",
"<",
"tmpSlope",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"node2",
"!=",
"null",
")",
"{",
"double",
"tmpSlope",
"=",
"abs",
"(",
"diagonal",
".",
"getSlopeTo",
"(",
"node2",
")",
")",
";",
"if",
"(",
"diagonalSlope",
"<",
"tmpSlope",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if the path from the current to the first node is steeper than to the others.
@param current the current node.
@param diagonal the diagonal node to check.
@param node1 the first other node to check.
@param node2 the second other node to check.
@return <code>true</code> if the path to the first node is steeper in module than
that to the others. | [
"Checks",
"if",
"the",
"path",
"from",
"the",
"current",
"to",
"the",
"first",
"node",
"is",
"steeper",
"than",
"to",
"the",
"others",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/flow/OmsLeastCostFlowDirections.java#L339-L354 |
137,857 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/flow/OmsLeastCostFlowDirections.java | OmsLeastCostFlowDirections.nodeOk | private boolean nodeOk( GridNode node ) {
return node != null && !assignedFlowsMap.isMarked(node.col, node.row);
} | java | private boolean nodeOk( GridNode node ) {
return node != null && !assignedFlowsMap.isMarked(node.col, node.row);
} | [
"private",
"boolean",
"nodeOk",
"(",
"GridNode",
"node",
")",
"{",
"return",
"node",
"!=",
"null",
"&&",
"!",
"assignedFlowsMap",
".",
"isMarked",
"(",
"node",
".",
"col",
",",
"node",
".",
"row",
")",
";",
"}"
] | Checks if the node is ok.
<p>A node is ok if:</p>
<ul>
<li>if the node is valid (!= null in surrounding)</li>
<li>if the node has not been processed already (!.isMarked)</li>
</ul> | [
"Checks",
"if",
"the",
"node",
"is",
"ok",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/flow/OmsLeastCostFlowDirections.java#L365-L367 |
137,858 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/PSEngine.java | PSEngine.run | public void run() throws Exception {
if (ranges == null) {
throw new ModelsIllegalargumentException("No ranges have been defined for the parameter space.", this);
}
createSwarm();
double[] previous = null;
while( iterationStep <= maxIterations ) {
updateSwarm();
if (printStep()) {
System.out.println(prefix + " - ITER: " + iterationStep + " global best: " + globalBest + " - for positions: "
+ Arrays.toString(globalBestLocations));
}
if (function.hasConverged(globalBest, globalBestLocations, previous)) {
break;
}
previous = globalBestLocations.clone();
}
} | java | public void run() throws Exception {
if (ranges == null) {
throw new ModelsIllegalargumentException("No ranges have been defined for the parameter space.", this);
}
createSwarm();
double[] previous = null;
while( iterationStep <= maxIterations ) {
updateSwarm();
if (printStep()) {
System.out.println(prefix + " - ITER: " + iterationStep + " global best: " + globalBest + " - for positions: "
+ Arrays.toString(globalBestLocations));
}
if (function.hasConverged(globalBest, globalBestLocations, previous)) {
break;
}
previous = globalBestLocations.clone();
}
} | [
"public",
"void",
"run",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"ranges",
"==",
"null",
")",
"{",
"throw",
"new",
"ModelsIllegalargumentException",
"(",
"\"No ranges have been defined for the parameter space.\"",
",",
"this",
")",
";",
"}",
"createSwarm",
"(",
")",
";",
"double",
"[",
"]",
"previous",
"=",
"null",
";",
"while",
"(",
"iterationStep",
"<=",
"maxIterations",
")",
"{",
"updateSwarm",
"(",
")",
";",
"if",
"(",
"printStep",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"prefix",
"+",
"\" - ITER: \"",
"+",
"iterationStep",
"+",
"\" global best: \"",
"+",
"globalBest",
"+",
"\" - for positions: \"",
"+",
"Arrays",
".",
"toString",
"(",
"globalBestLocations",
")",
")",
";",
"}",
"if",
"(",
"function",
".",
"hasConverged",
"(",
"globalBest",
",",
"globalBestLocations",
",",
"previous",
")",
")",
"{",
"break",
";",
"}",
"previous",
"=",
"globalBestLocations",
".",
"clone",
"(",
")",
";",
"}",
"}"
] | Run the particle swarm engine.
@throws Exception | [
"Run",
"the",
"particle",
"swarm",
"engine",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/PSEngine.java#L91-L111 |
137,859 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/PSEngine.java | PSEngine.parametersInRange | public static boolean parametersInRange( double[] parameters, double[]... ranges ) {
for( int i = 0; i < ranges.length; i++ ) {
if (!NumericsUtilities.isBetween(parameters[i], ranges[i])) {
return false;
}
}
return true;
} | java | public static boolean parametersInRange( double[] parameters, double[]... ranges ) {
for( int i = 0; i < ranges.length; i++ ) {
if (!NumericsUtilities.isBetween(parameters[i], ranges[i])) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"parametersInRange",
"(",
"double",
"[",
"]",
"parameters",
",",
"double",
"[",
"]",
"...",
"ranges",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ranges",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"NumericsUtilities",
".",
"isBetween",
"(",
"parameters",
"[",
"i",
"]",
",",
"ranges",
"[",
"i",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if the parameters are in the ranges.
@param parameters the params.
@param ranges the ranges.
@return <code>true</code>, if they are inside the given ranges. | [
"Checks",
"if",
"the",
"parameters",
"are",
"in",
"the",
"ranges",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/PSEngine.java#L211-L218 |
137,860 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Conversions.java | Conversions.convert | public static <T> T convert(Object from, Class<? extends T> to, Params arg) {
if (from == null) {
throw new NullPointerException("from");
}
if (to == null) {
throw new NullPointerException("to");
}
if (from.getClass() == String.class && to.isArray()) {
return new ArrayConverter((String) from).getArrayForType(to);
}
// get it from the internal cache.
@SuppressWarnings("unchecked")
Converter<Object, T> c = co.get(key(from.getClass(), to));
if (c == null) {
// service provider lookup
c = lookupConversionService(from.getClass(), to);
if (c == null) {
throw new ComponentException("No Converter: " + from + " (" + from.getClass() + ") -> " + to);
}
co.put(key(from.getClass(), to), c);
}
Object param = null;
if (arg != null) {
param = arg.get(from.getClass(), to);
}
return (T) c.convert(from, param);
} | java | public static <T> T convert(Object from, Class<? extends T> to, Params arg) {
if (from == null) {
throw new NullPointerException("from");
}
if (to == null) {
throw new NullPointerException("to");
}
if (from.getClass() == String.class && to.isArray()) {
return new ArrayConverter((String) from).getArrayForType(to);
}
// get it from the internal cache.
@SuppressWarnings("unchecked")
Converter<Object, T> c = co.get(key(from.getClass(), to));
if (c == null) {
// service provider lookup
c = lookupConversionService(from.getClass(), to);
if (c == null) {
throw new ComponentException("No Converter: " + from + " (" + from.getClass() + ") -> " + to);
}
co.put(key(from.getClass(), to), c);
}
Object param = null;
if (arg != null) {
param = arg.get(from.getClass(), to);
}
return (T) c.convert(from, param);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"convert",
"(",
"Object",
"from",
",",
"Class",
"<",
"?",
"extends",
"T",
">",
"to",
",",
"Params",
"arg",
")",
"{",
"if",
"(",
"from",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"from\"",
")",
";",
"}",
"if",
"(",
"to",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"to\"",
")",
";",
"}",
"if",
"(",
"from",
".",
"getClass",
"(",
")",
"==",
"String",
".",
"class",
"&&",
"to",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"new",
"ArrayConverter",
"(",
"(",
"String",
")",
"from",
")",
".",
"getArrayForType",
"(",
"to",
")",
";",
"}",
"// get it from the internal cache.",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Converter",
"<",
"Object",
",",
"T",
">",
"c",
"=",
"co",
".",
"get",
"(",
"key",
"(",
"from",
".",
"getClass",
"(",
")",
",",
"to",
")",
")",
";",
"if",
"(",
"c",
"==",
"null",
")",
"{",
"// service provider lookup",
"c",
"=",
"lookupConversionService",
"(",
"from",
".",
"getClass",
"(",
")",
",",
"to",
")",
";",
"if",
"(",
"c",
"==",
"null",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"No Converter: \"",
"+",
"from",
"+",
"\" (\"",
"+",
"from",
".",
"getClass",
"(",
")",
"+",
"\") -> \"",
"+",
"to",
")",
";",
"}",
"co",
".",
"put",
"(",
"key",
"(",
"from",
".",
"getClass",
"(",
")",
",",
"to",
")",
",",
"c",
")",
";",
"}",
"Object",
"param",
"=",
"null",
";",
"if",
"(",
"arg",
"!=",
"null",
")",
"{",
"param",
"=",
"arg",
".",
"get",
"(",
"from",
".",
"getClass",
"(",
")",
",",
"to",
")",
";",
"}",
"return",
"(",
"T",
")",
"c",
".",
"convert",
"(",
"from",
",",
"param",
")",
";",
"}"
] | Convert a String value into an object of a certain type
@param to the type to convert to
@param from the value to convert
@param arg conversion argument (e.g. Date format)
@return the object of a certain type. | [
"Convert",
"a",
"String",
"value",
"into",
"an",
"object",
"of",
"a",
"certain",
"type"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Conversions.java#L110-L136 |
137,861 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Conversions.java | Conversions.lookupConversionService | @SuppressWarnings("unchecked")
private static <T> Converter<Object, T> lookupConversionService(Class from, Class to) {
for (ConversionProvider converter : convServices) {
Converter c = converter.getConverter(from, to);
if (c != null) {
return c;
}
}
return null;
} | java | @SuppressWarnings("unchecked")
private static <T> Converter<Object, T> lookupConversionService(Class from, Class to) {
for (ConversionProvider converter : convServices) {
Converter c = converter.getConverter(from, to);
if (c != null) {
return c;
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"<",
"T",
">",
"Converter",
"<",
"Object",
",",
"T",
">",
"lookupConversionService",
"(",
"Class",
"from",
",",
"Class",
"to",
")",
"{",
"for",
"(",
"ConversionProvider",
"converter",
":",
"convServices",
")",
"{",
"Converter",
"c",
"=",
"converter",
".",
"getConverter",
"(",
"from",
",",
"to",
")",
";",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"return",
"c",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Lookup a conversion service
@param from
@param to
@return | [
"Lookup",
"a",
"conversion",
"service"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Conversions.java#L150-L159 |
137,862 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Conversions.java | Conversions.getArrayBaseType | private static Class getArrayBaseType(Class array) {
while (array.isArray()) {
array = array.getComponentType();
}
return array;
} | java | private static Class getArrayBaseType(Class array) {
while (array.isArray()) {
array = array.getComponentType();
}
return array;
} | [
"private",
"static",
"Class",
"getArrayBaseType",
"(",
"Class",
"array",
")",
"{",
"while",
"(",
"array",
".",
"isArray",
"(",
")",
")",
"{",
"array",
"=",
"array",
".",
"getComponentType",
"(",
")",
";",
"}",
"return",
"array",
";",
"}"
] | Get the array base type
@param array
@return | [
"Get",
"the",
"array",
"base",
"type"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Conversions.java#L180-L185 |
137,863 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Conversions.java | Conversions.parse | private static Date parse(String date) {
for (int i = 0; i < fmt.length; i++) {
try {
SimpleDateFormat df = new SimpleDateFormat(fmt[i]);
return df.parse(date);
} catch (ParseException E) {
// keep trying
}
}
throw new IllegalArgumentException(date);
} | java | private static Date parse(String date) {
for (int i = 0; i < fmt.length; i++) {
try {
SimpleDateFormat df = new SimpleDateFormat(fmt[i]);
return df.parse(date);
} catch (ParseException E) {
// keep trying
}
}
throw new IllegalArgumentException(date);
} | [
"private",
"static",
"Date",
"parse",
"(",
"String",
"date",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fmt",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"SimpleDateFormat",
"df",
"=",
"new",
"SimpleDateFormat",
"(",
"fmt",
"[",
"i",
"]",
")",
";",
"return",
"df",
".",
"parse",
"(",
"date",
")",
";",
"}",
"catch",
"(",
"ParseException",
"E",
")",
"{",
"// keep trying",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"date",
")",
";",
"}"
] | parse the date using the formats above. This is thread safe.
@param date
@return | [
"parse",
"the",
"date",
"using",
"the",
"formats",
"above",
".",
"This",
"is",
"thread",
"safe",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Conversions.java#L389-L399 |
137,864 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java | Window.fixRowsAndCols | public void fixRowsAndCols() {
rows = (int) Math.round((n - s) / ns_res);
if (rows < 1)
rows = 1;
cols = (int) Math.round((e - w) / we_res);
if (cols < 1)
cols = 1;
} | java | public void fixRowsAndCols() {
rows = (int) Math.round((n - s) / ns_res);
if (rows < 1)
rows = 1;
cols = (int) Math.round((e - w) / we_res);
if (cols < 1)
cols = 1;
} | [
"public",
"void",
"fixRowsAndCols",
"(",
")",
"{",
"rows",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"(",
"n",
"-",
"s",
")",
"/",
"ns_res",
")",
";",
"if",
"(",
"rows",
"<",
"1",
")",
"rows",
"=",
"1",
";",
"cols",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"(",
"e",
"-",
"w",
")",
"/",
"we_res",
")",
";",
"if",
"(",
"cols",
"<",
"1",
")",
"cols",
"=",
"1",
";",
"}"
] | calculate rows and cols from the region and its resolution. Round if required. | [
"calculate",
"rows",
"and",
"cols",
"from",
"the",
"region",
"and",
"its",
"resolution",
".",
"Round",
"if",
"required",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java#L327-L334 |
137,865 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java | Window.snapToNextHigherInActiveRegionResolution | public static Point2D.Double snapToNextHigherInActiveRegionResolution( double x, double y, Window activeWindow ) {
double minx = activeWindow.getRectangle().getBounds2D().getMinX();
double ewres = activeWindow.getWEResolution();
double xsnap = minx + (Math.ceil((x - minx) / ewres) * ewres);
double miny = activeWindow.getRectangle().getBounds2D().getMinY();
double nsres = activeWindow.getNSResolution();
double ysnap = miny + (Math.ceil((y - miny) / nsres) * nsres);
return new Point2D.Double(xsnap, ysnap);
} | java | public static Point2D.Double snapToNextHigherInActiveRegionResolution( double x, double y, Window activeWindow ) {
double minx = activeWindow.getRectangle().getBounds2D().getMinX();
double ewres = activeWindow.getWEResolution();
double xsnap = minx + (Math.ceil((x - minx) / ewres) * ewres);
double miny = activeWindow.getRectangle().getBounds2D().getMinY();
double nsres = activeWindow.getNSResolution();
double ysnap = miny + (Math.ceil((y - miny) / nsres) * nsres);
return new Point2D.Double(xsnap, ysnap);
} | [
"public",
"static",
"Point2D",
".",
"Double",
"snapToNextHigherInActiveRegionResolution",
"(",
"double",
"x",
",",
"double",
"y",
",",
"Window",
"activeWindow",
")",
"{",
"double",
"minx",
"=",
"activeWindow",
".",
"getRectangle",
"(",
")",
".",
"getBounds2D",
"(",
")",
".",
"getMinX",
"(",
")",
";",
"double",
"ewres",
"=",
"activeWindow",
".",
"getWEResolution",
"(",
")",
";",
"double",
"xsnap",
"=",
"minx",
"+",
"(",
"Math",
".",
"ceil",
"(",
"(",
"x",
"-",
"minx",
")",
"/",
"ewres",
")",
"*",
"ewres",
")",
";",
"double",
"miny",
"=",
"activeWindow",
".",
"getRectangle",
"(",
")",
".",
"getBounds2D",
"(",
")",
".",
"getMinY",
"(",
")",
";",
"double",
"nsres",
"=",
"activeWindow",
".",
"getNSResolution",
"(",
")",
";",
"double",
"ysnap",
"=",
"miny",
"+",
"(",
"Math",
".",
"ceil",
"(",
"(",
"y",
"-",
"miny",
")",
"/",
"nsres",
")",
"*",
"nsres",
")",
";",
"return",
"new",
"Point2D",
".",
"Double",
"(",
"xsnap",
",",
"ysnap",
")",
";",
"}"
] | Moves the point given by X and Y to be on the grid of the active region.
@param x the easting of the arbitrary point
@param y the northing of the arbitrary point
@param activeWindow the active window from which to take the grid
@return the snapped point | [
"Moves",
"the",
"point",
"given",
"by",
"X",
"and",
"Y",
"to",
"be",
"on",
"the",
"grid",
"of",
"the",
"active",
"region",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java#L444-L456 |
137,866 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java | Window.getActiveWindowFromMapset | public static Window getActiveWindowFromMapset( String mapsetPath ) {
File windFile = new File(mapsetPath + File.separator + GrassLegacyConstans.WIND);
if (!windFile.exists()) {
return null;
}
return new Window(windFile.getAbsolutePath());
} | java | public static Window getActiveWindowFromMapset( String mapsetPath ) {
File windFile = new File(mapsetPath + File.separator + GrassLegacyConstans.WIND);
if (!windFile.exists()) {
return null;
}
return new Window(windFile.getAbsolutePath());
} | [
"public",
"static",
"Window",
"getActiveWindowFromMapset",
"(",
"String",
"mapsetPath",
")",
"{",
"File",
"windFile",
"=",
"new",
"File",
"(",
"mapsetPath",
"+",
"File",
".",
"separator",
"+",
"GrassLegacyConstans",
".",
"WIND",
")",
";",
"if",
"(",
"!",
"windFile",
".",
"exists",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"Window",
"(",
"windFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}"
] | Get the active region window from the mapset
@param mapsetPath the path to the mapset folder
@return the active Window object of that mapset | [
"Get",
"the",
"active",
"region",
"window",
"from",
"the",
"mapset"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java#L464-L471 |
137,867 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java | Window.writeActiveWindowToMapset | public static void writeActiveWindowToMapset( String mapsetPath, Window window ) throws IOException {
writeWindowFile(mapsetPath + File.separator + GrassLegacyConstans.WIND, window);
} | java | public static void writeActiveWindowToMapset( String mapsetPath, Window window ) throws IOException {
writeWindowFile(mapsetPath + File.separator + GrassLegacyConstans.WIND, window);
} | [
"public",
"static",
"void",
"writeActiveWindowToMapset",
"(",
"String",
"mapsetPath",
",",
"Window",
"window",
")",
"throws",
"IOException",
"{",
"writeWindowFile",
"(",
"mapsetPath",
"+",
"File",
".",
"separator",
"+",
"GrassLegacyConstans",
".",
"WIND",
",",
"window",
")",
";",
"}"
] | Write active region window to the mapset
@param mapsetPath the path to the mapset folder
@param the active Window object
@throws IOException | [
"Write",
"active",
"region",
"window",
"to",
"the",
"mapset"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java#L480-L482 |
137,868 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java | Window.writeDefaultWindowToLocation | public static void writeDefaultWindowToLocation( String locationPath, Window window ) throws IOException {
writeWindowFile(locationPath + File.separator + GrassLegacyConstans.PERMANENT_MAPSET + File.separator
+ GrassLegacyConstans.DEFAULT_WIND, window);
} | java | public static void writeDefaultWindowToLocation( String locationPath, Window window ) throws IOException {
writeWindowFile(locationPath + File.separator + GrassLegacyConstans.PERMANENT_MAPSET + File.separator
+ GrassLegacyConstans.DEFAULT_WIND, window);
} | [
"public",
"static",
"void",
"writeDefaultWindowToLocation",
"(",
"String",
"locationPath",
",",
"Window",
"window",
")",
"throws",
"IOException",
"{",
"writeWindowFile",
"(",
"locationPath",
"+",
"File",
".",
"separator",
"+",
"GrassLegacyConstans",
".",
"PERMANENT_MAPSET",
"+",
"File",
".",
"separator",
"+",
"GrassLegacyConstans",
".",
"DEFAULT_WIND",
",",
"window",
")",
";",
"}"
] | Write default region window to the PERMANENT mapset
@param locationPath the path to the location folder
@param the active Window object
@throws IOException | [
"Write",
"default",
"region",
"window",
"to",
"the",
"PERMANENT",
"mapset"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java#L491-L494 |
137,869 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java | Window.adaptActiveRegionToEnvelope | public static Window adaptActiveRegionToEnvelope( Envelope bounds, Window activeRegion ) {
Point2D eastNorth = Window.snapToNextHigherInActiveRegionResolution(bounds.getMaxX(), bounds.getMaxY(), activeRegion);
Point2D westsouth = Window.snapToNextHigherInActiveRegionResolution(bounds.getMinX() - activeRegion.getWEResolution(),
bounds.getMinY() - activeRegion.getNSResolution(), activeRegion);
Window tmp = new Window(westsouth.getX(), eastNorth.getX(), westsouth.getY(), eastNorth.getY(),
activeRegion.getWEResolution(), activeRegion.getNSResolution());
// activeRegion.setExtent(tmp);
return tmp;
} | java | public static Window adaptActiveRegionToEnvelope( Envelope bounds, Window activeRegion ) {
Point2D eastNorth = Window.snapToNextHigherInActiveRegionResolution(bounds.getMaxX(), bounds.getMaxY(), activeRegion);
Point2D westsouth = Window.snapToNextHigherInActiveRegionResolution(bounds.getMinX() - activeRegion.getWEResolution(),
bounds.getMinY() - activeRegion.getNSResolution(), activeRegion);
Window tmp = new Window(westsouth.getX(), eastNorth.getX(), westsouth.getY(), eastNorth.getY(),
activeRegion.getWEResolution(), activeRegion.getNSResolution());
// activeRegion.setExtent(tmp);
return tmp;
} | [
"public",
"static",
"Window",
"adaptActiveRegionToEnvelope",
"(",
"Envelope",
"bounds",
",",
"Window",
"activeRegion",
")",
"{",
"Point2D",
"eastNorth",
"=",
"Window",
".",
"snapToNextHigherInActiveRegionResolution",
"(",
"bounds",
".",
"getMaxX",
"(",
")",
",",
"bounds",
".",
"getMaxY",
"(",
")",
",",
"activeRegion",
")",
";",
"Point2D",
"westsouth",
"=",
"Window",
".",
"snapToNextHigherInActiveRegionResolution",
"(",
"bounds",
".",
"getMinX",
"(",
")",
"-",
"activeRegion",
".",
"getWEResolution",
"(",
")",
",",
"bounds",
".",
"getMinY",
"(",
")",
"-",
"activeRegion",
".",
"getNSResolution",
"(",
")",
",",
"activeRegion",
")",
";",
"Window",
"tmp",
"=",
"new",
"Window",
"(",
"westsouth",
".",
"getX",
"(",
")",
",",
"eastNorth",
".",
"getX",
"(",
")",
",",
"westsouth",
".",
"getY",
"(",
")",
",",
"eastNorth",
".",
"getY",
"(",
")",
",",
"activeRegion",
".",
"getWEResolution",
"(",
")",
",",
"activeRegion",
".",
"getNSResolution",
"(",
")",
")",
";",
"// activeRegion.setExtent(tmp);",
"return",
"tmp",
";",
"}"
] | Takes an envelope and an active region and creates a new region to match the bounds of the
envelope, but the resolutions of the active region. This is important if the region has to
match some feature layer. The bounds are assured to contain completely the envelope.
@param bounds
@param activeRegion | [
"Takes",
"an",
"envelope",
"and",
"an",
"active",
"region",
"and",
"creates",
"a",
"new",
"region",
"to",
"match",
"the",
"bounds",
"of",
"the",
"envelope",
"but",
"the",
"resolutions",
"of",
"the",
"active",
"region",
".",
"This",
"is",
"important",
"if",
"the",
"region",
"has",
"to",
"match",
"some",
"feature",
"layer",
".",
"The",
"bounds",
"are",
"assured",
"to",
"contain",
"completely",
"the",
"envelope",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Window.java#L504-L512 |
137,870 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/util/cosu/SCE.java | SCE.cceua | public double[] cceua(double s[][], double sf[], double bl[], double bu[]) {
int nps = s.length;
int nopt = s[0].length;
int n = nps;
int m = nopt;
double alpha = 1.0;
double beta = 0.5;
// Assign the best and worst points:
double sb[] = new double[nopt];
double sw[] = new double[nopt];
double fb = sf[0];
double fw = sf[n - 1];
for (int i = 0; i < nopt; i++) {
sb[i] = s[0][i];
sw[i] = s[n - 1][i];
}
// Compute the centroid of the simplex excluding the worst point:
double ce[] = new double[nopt];
for (int i = 0; i < nopt; i++) {
ce[i] = 0;
for (int j = 0; j < n - 1; j++) {
ce[i] += s[j][i];
}
ce[i] /= (n - 1);
}
// Attempt a reflection point
double snew[] = new double[nopt];
for (int i = 0; i < nopt; i++) {
snew[i] = ce[i] + alpha * (ce[i] - sw[i]);
}
// Check if is outside the bounds:
int ibound = 0;
for (int i = 0; i < nopt; i++) {
if ((snew[i] - bl[i]) < 0) {
ibound = 1;
}
if ((bu[i] - snew[i]) < 0) {
ibound = 2;
}
}
if (ibound >= 1) {
snew = randomSampler();
}
double fnew = funct(snew);
// Reflection failed; now attempt a contraction point:
if (fnew > fw) {
for (int i = 0; i < nopt; i++) {
snew[i] = sw[i] + beta * (ce[i] - sw[i]);
}
fnew = funct(snew);
}
// Both reflection and contraction have failed, attempt a random point;
if (fnew > fw) {
snew = randomSampler();
fnew = funct(snew);
}
double result[] = new double[nopt + 1];
for (int i = 0; i < nopt; i++) {
result[i] = snew[i];
}
result[nopt] = fnew;
return result;
} | java | public double[] cceua(double s[][], double sf[], double bl[], double bu[]) {
int nps = s.length;
int nopt = s[0].length;
int n = nps;
int m = nopt;
double alpha = 1.0;
double beta = 0.5;
// Assign the best and worst points:
double sb[] = new double[nopt];
double sw[] = new double[nopt];
double fb = sf[0];
double fw = sf[n - 1];
for (int i = 0; i < nopt; i++) {
sb[i] = s[0][i];
sw[i] = s[n - 1][i];
}
// Compute the centroid of the simplex excluding the worst point:
double ce[] = new double[nopt];
for (int i = 0; i < nopt; i++) {
ce[i] = 0;
for (int j = 0; j < n - 1; j++) {
ce[i] += s[j][i];
}
ce[i] /= (n - 1);
}
// Attempt a reflection point
double snew[] = new double[nopt];
for (int i = 0; i < nopt; i++) {
snew[i] = ce[i] + alpha * (ce[i] - sw[i]);
}
// Check if is outside the bounds:
int ibound = 0;
for (int i = 0; i < nopt; i++) {
if ((snew[i] - bl[i]) < 0) {
ibound = 1;
}
if ((bu[i] - snew[i]) < 0) {
ibound = 2;
}
}
if (ibound >= 1) {
snew = randomSampler();
}
double fnew = funct(snew);
// Reflection failed; now attempt a contraction point:
if (fnew > fw) {
for (int i = 0; i < nopt; i++) {
snew[i] = sw[i] + beta * (ce[i] - sw[i]);
}
fnew = funct(snew);
}
// Both reflection and contraction have failed, attempt a random point;
if (fnew > fw) {
snew = randomSampler();
fnew = funct(snew);
}
double result[] = new double[nopt + 1];
for (int i = 0; i < nopt; i++) {
result[i] = snew[i];
}
result[nopt] = fnew;
return result;
} | [
"public",
"double",
"[",
"]",
"cceua",
"(",
"double",
"s",
"[",
"]",
"[",
"]",
",",
"double",
"sf",
"[",
"]",
",",
"double",
"bl",
"[",
"]",
",",
"double",
"bu",
"[",
"]",
")",
"{",
"int",
"nps",
"=",
"s",
".",
"length",
";",
"int",
"nopt",
"=",
"s",
"[",
"0",
"]",
".",
"length",
";",
"int",
"n",
"=",
"nps",
";",
"int",
"m",
"=",
"nopt",
";",
"double",
"alpha",
"=",
"1.0",
";",
"double",
"beta",
"=",
"0.5",
";",
"// Assign the best and worst points:",
"double",
"sb",
"[",
"]",
"=",
"new",
"double",
"[",
"nopt",
"]",
";",
"double",
"sw",
"[",
"]",
"=",
"new",
"double",
"[",
"nopt",
"]",
";",
"double",
"fb",
"=",
"sf",
"[",
"0",
"]",
";",
"double",
"fw",
"=",
"sf",
"[",
"n",
"-",
"1",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nopt",
";",
"i",
"++",
")",
"{",
"sb",
"[",
"i",
"]",
"=",
"s",
"[",
"0",
"]",
"[",
"i",
"]",
";",
"sw",
"[",
"i",
"]",
"=",
"s",
"[",
"n",
"-",
"1",
"]",
"[",
"i",
"]",
";",
"}",
"// Compute the centroid of the simplex excluding the worst point:",
"double",
"ce",
"[",
"]",
"=",
"new",
"double",
"[",
"nopt",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nopt",
";",
"i",
"++",
")",
"{",
"ce",
"[",
"i",
"]",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"n",
"-",
"1",
";",
"j",
"++",
")",
"{",
"ce",
"[",
"i",
"]",
"+=",
"s",
"[",
"j",
"]",
"[",
"i",
"]",
";",
"}",
"ce",
"[",
"i",
"]",
"/=",
"(",
"n",
"-",
"1",
")",
";",
"}",
"// Attempt a reflection point",
"double",
"snew",
"[",
"]",
"=",
"new",
"double",
"[",
"nopt",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nopt",
";",
"i",
"++",
")",
"{",
"snew",
"[",
"i",
"]",
"=",
"ce",
"[",
"i",
"]",
"+",
"alpha",
"*",
"(",
"ce",
"[",
"i",
"]",
"-",
"sw",
"[",
"i",
"]",
")",
";",
"}",
"// Check if is outside the bounds:",
"int",
"ibound",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nopt",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"snew",
"[",
"i",
"]",
"-",
"bl",
"[",
"i",
"]",
")",
"<",
"0",
")",
"{",
"ibound",
"=",
"1",
";",
"}",
"if",
"(",
"(",
"bu",
"[",
"i",
"]",
"-",
"snew",
"[",
"i",
"]",
")",
"<",
"0",
")",
"{",
"ibound",
"=",
"2",
";",
"}",
"}",
"if",
"(",
"ibound",
">=",
"1",
")",
"{",
"snew",
"=",
"randomSampler",
"(",
")",
";",
"}",
"double",
"fnew",
"=",
"funct",
"(",
"snew",
")",
";",
"// Reflection failed; now attempt a contraction point:",
"if",
"(",
"fnew",
">",
"fw",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nopt",
";",
"i",
"++",
")",
"{",
"snew",
"[",
"i",
"]",
"=",
"sw",
"[",
"i",
"]",
"+",
"beta",
"*",
"(",
"ce",
"[",
"i",
"]",
"-",
"sw",
"[",
"i",
"]",
")",
";",
"}",
"fnew",
"=",
"funct",
"(",
"snew",
")",
";",
"}",
"// Both reflection and contraction have failed, attempt a random point;",
"if",
"(",
"fnew",
">",
"fw",
")",
"{",
"snew",
"=",
"randomSampler",
"(",
")",
";",
"fnew",
"=",
"funct",
"(",
"snew",
")",
";",
"}",
"double",
"result",
"[",
"]",
"=",
"new",
"double",
"[",
"nopt",
"+",
"1",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nopt",
";",
"i",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"snew",
"[",
"i",
"]",
";",
"}",
"result",
"[",
"nopt",
"]",
"=",
"fnew",
";",
"return",
"result",
";",
"}"
] | bu upper bound | [
"bu",
"upper",
"bound"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/util/cosu/SCE.java#L241-L314 |
137,871 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java | FileUtilities.deleteFileOrDirOnExit | public static boolean deleteFileOrDirOnExit( File filehandle ) {
if (filehandle.isDirectory()) {
String[] children = filehandle.list();
for( int i = 0; i < children.length; i++ ) {
boolean success = deleteFileOrDir(new File(filehandle, children[i]));
if (!success) {
return false;
}
}
}
filehandle.deleteOnExit();
return true;
} | java | public static boolean deleteFileOrDirOnExit( File filehandle ) {
if (filehandle.isDirectory()) {
String[] children = filehandle.list();
for( int i = 0; i < children.length; i++ ) {
boolean success = deleteFileOrDir(new File(filehandle, children[i]));
if (!success) {
return false;
}
}
}
filehandle.deleteOnExit();
return true;
} | [
"public",
"static",
"boolean",
"deleteFileOrDirOnExit",
"(",
"File",
"filehandle",
")",
"{",
"if",
"(",
"filehandle",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"[",
"]",
"children",
"=",
"filehandle",
".",
"list",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"boolean",
"success",
"=",
"deleteFileOrDir",
"(",
"new",
"File",
"(",
"filehandle",
",",
"children",
"[",
"i",
"]",
")",
")",
";",
"if",
"(",
"!",
"success",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"filehandle",
".",
"deleteOnExit",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Delete file or folder recursively on exit of the program
@param filehandle
@return true if all went well | [
"Delete",
"file",
"or",
"folder",
"recursively",
"on",
"exit",
"of",
"the",
"program"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java#L212-L224 |
137,872 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java | FileUtilities.readInputStreamToString | public static String readInputStreamToString( InputStream inputStream ) {
try {
// Create the byte list to hold the data
List<Byte> bytesList = new ArrayList<Byte>();
byte b = 0;
while( (b = (byte) inputStream.read()) != -1 ) {
bytesList.add(b);
}
// Close the input stream and return bytes
inputStream.close();
byte[] bArray = new byte[bytesList.size()];
for( int i = 0; i < bArray.length; i++ ) {
bArray[i] = bytesList.get(i);
}
String file = new String(bArray);
return file;
} catch (IOException e) {
e.printStackTrace();
return null;
}
} | java | public static String readInputStreamToString( InputStream inputStream ) {
try {
// Create the byte list to hold the data
List<Byte> bytesList = new ArrayList<Byte>();
byte b = 0;
while( (b = (byte) inputStream.read()) != -1 ) {
bytesList.add(b);
}
// Close the input stream and return bytes
inputStream.close();
byte[] bArray = new byte[bytesList.size()];
for( int i = 0; i < bArray.length; i++ ) {
bArray[i] = bytesList.get(i);
}
String file = new String(bArray);
return file;
} catch (IOException e) {
e.printStackTrace();
return null;
}
} | [
"public",
"static",
"String",
"readInputStreamToString",
"(",
"InputStream",
"inputStream",
")",
"{",
"try",
"{",
"// Create the byte list to hold the data",
"List",
"<",
"Byte",
">",
"bytesList",
"=",
"new",
"ArrayList",
"<",
"Byte",
">",
"(",
")",
";",
"byte",
"b",
"=",
"0",
";",
"while",
"(",
"(",
"b",
"=",
"(",
"byte",
")",
"inputStream",
".",
"read",
"(",
")",
")",
"!=",
"-",
"1",
")",
"{",
"bytesList",
".",
"add",
"(",
"b",
")",
";",
"}",
"// Close the input stream and return bytes",
"inputStream",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"bArray",
"=",
"new",
"byte",
"[",
"bytesList",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"bArray",
"[",
"i",
"]",
"=",
"bytesList",
".",
"get",
"(",
"i",
")",
";",
"}",
"String",
"file",
"=",
"new",
"String",
"(",
"bArray",
")",
";",
"return",
"file",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Read from an inoutstream and convert the readed stuff to a String. Usefull for text files
that are available as streams.
@param inputStream
@return the read string | [
"Read",
"from",
"an",
"inoutstream",
"and",
"convert",
"the",
"readed",
"stuff",
"to",
"a",
"String",
".",
"Usefull",
"for",
"text",
"files",
"that",
"are",
"available",
"as",
"streams",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java#L233-L257 |
137,873 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/util/Validation.java | Validation.hexDigest | public static String hexDigest(String algorithm, File[] files) {
try {
MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] buf = new byte[4096];
for (File f : files) {
FileInputStream in = new FileInputStream(f);
int nread = in.read(buf);
while (nread > 0) {
md.update(buf, 0, nread);
nread = in.read(buf);
}
in.close();
}
return toHex(md.digest(buf));
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
return "<error>";
} | java | public static String hexDigest(String algorithm, File[] files) {
try {
MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] buf = new byte[4096];
for (File f : files) {
FileInputStream in = new FileInputStream(f);
int nread = in.read(buf);
while (nread > 0) {
md.update(buf, 0, nread);
nread = in.read(buf);
}
in.close();
}
return toHex(md.digest(buf));
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
return "<error>";
} | [
"public",
"static",
"String",
"hexDigest",
"(",
"String",
"algorithm",
",",
"File",
"[",
"]",
"files",
")",
"{",
"try",
"{",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"for",
"(",
"File",
"f",
":",
"files",
")",
"{",
"FileInputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"f",
")",
";",
"int",
"nread",
"=",
"in",
".",
"read",
"(",
"buf",
")",
";",
"while",
"(",
"nread",
">",
"0",
")",
"{",
"md",
".",
"update",
"(",
"buf",
",",
"0",
",",
"nread",
")",
";",
"nread",
"=",
"in",
".",
"read",
"(",
"buf",
")",
";",
"}",
"in",
".",
"close",
"(",
")",
";",
"}",
"return",
"toHex",
"(",
"md",
".",
"digest",
"(",
"buf",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
"System",
".",
"out",
")",
";",
"}",
"return",
"\"<error>\"",
";",
"}"
] | Creates a hex encoded sha-256 hash of all files.
@param algorithm the algorithm to be used.
@param files the files to include for this hash.
@return the hexadecimal digest (length 64byte for sha-256). | [
"Creates",
"a",
"hex",
"encoded",
"sha",
"-",
"256",
"hash",
"of",
"all",
"files",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/util/Validation.java#L24-L42 |
137,874 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/databases/LasLevelsTable.java | LasLevelsTable.hasLevel | public static boolean hasLevel( ASpatialDb db, int levelNum ) throws Exception {
String tablename = TABLENAME + levelNum;
return db.hasTable(tablename);
} | java | public static boolean hasLevel( ASpatialDb db, int levelNum ) throws Exception {
String tablename = TABLENAME + levelNum;
return db.hasTable(tablename);
} | [
"public",
"static",
"boolean",
"hasLevel",
"(",
"ASpatialDb",
"db",
",",
"int",
"levelNum",
")",
"throws",
"Exception",
"{",
"String",
"tablename",
"=",
"TABLENAME",
"+",
"levelNum",
";",
"return",
"db",
".",
"hasTable",
"(",
"tablename",
")",
";",
"}"
] | Checks if the given level table exists.
@param db the database.
@param levelNum the level number to check.
@return <code>true</code> if the level table exists.
@throws Exception | [
"Checks",
"if",
"the",
"given",
"level",
"table",
"exists",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/databases/LasLevelsTable.java#L61-L64 |
137,875 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/databases/LasLevelsTable.java | LasLevelsTable.getLasLevels | public static List<LasLevel> getLasLevels( ASpatialDb db, int levelNum, Envelope envelope ) throws Exception {
String tableName = TABLENAME + levelNum;
List<LasLevel> lasLevels = new ArrayList<>();
String sql = "SELECT " + COLUMN_GEOM + "," + //
COLUMN_ID + "," + COLUMN_SOURCE_ID + "," + COLUMN_AVG_ELEV + "," + //
COLUMN_MIN_ELEV + "," + //
COLUMN_MAX_ELEV + "," + //
COLUMN_AVG_INTENSITY + "," + //
COLUMN_MIN_INTENSITY + "," + //
COLUMN_MAX_INTENSITY;
sql += " FROM " + tableName;
if (envelope != null) {
double x1 = envelope.getMinX();
double y1 = envelope.getMinY();
double x2 = envelope.getMaxX();
double y2 = envelope.getMaxY();
sql += " WHERE " + db.getSpatialindexBBoxWherePiece(tableName, null, x1, y1, x2, y2);
}
String _sql = sql;
IGeometryParser gp = db.getType().getGeometryParser();
return db.execOnConnection(conn -> {
try (IHMStatement stmt = conn.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
while( rs.next() ) {
LasLevel lasLevel = new LasLevel();
lasLevel.level = levelNum;
int i = 1;
Geometry geometry = gp.fromResultSet(rs, i++);
if (geometry instanceof Polygon) {
Polygon polygon = (Polygon) geometry;
lasLevel.polygon = polygon;
lasLevel.id = rs.getLong(i++);
lasLevel.sourceId = rs.getLong(i++);
lasLevel.avgElev = rs.getDouble(i++);
lasLevel.minElev = rs.getDouble(i++);
lasLevel.maxElev = rs.getDouble(i++);
lasLevel.avgIntensity = rs.getShort(i++);
lasLevel.minIntensity = rs.getShort(i++);
lasLevel.maxIntensity = rs.getShort(i++);
lasLevels.add(lasLevel);
}
}
return lasLevels;
}
});
} | java | public static List<LasLevel> getLasLevels( ASpatialDb db, int levelNum, Envelope envelope ) throws Exception {
String tableName = TABLENAME + levelNum;
List<LasLevel> lasLevels = new ArrayList<>();
String sql = "SELECT " + COLUMN_GEOM + "," + //
COLUMN_ID + "," + COLUMN_SOURCE_ID + "," + COLUMN_AVG_ELEV + "," + //
COLUMN_MIN_ELEV + "," + //
COLUMN_MAX_ELEV + "," + //
COLUMN_AVG_INTENSITY + "," + //
COLUMN_MIN_INTENSITY + "," + //
COLUMN_MAX_INTENSITY;
sql += " FROM " + tableName;
if (envelope != null) {
double x1 = envelope.getMinX();
double y1 = envelope.getMinY();
double x2 = envelope.getMaxX();
double y2 = envelope.getMaxY();
sql += " WHERE " + db.getSpatialindexBBoxWherePiece(tableName, null, x1, y1, x2, y2);
}
String _sql = sql;
IGeometryParser gp = db.getType().getGeometryParser();
return db.execOnConnection(conn -> {
try (IHMStatement stmt = conn.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
while( rs.next() ) {
LasLevel lasLevel = new LasLevel();
lasLevel.level = levelNum;
int i = 1;
Geometry geometry = gp.fromResultSet(rs, i++);
if (geometry instanceof Polygon) {
Polygon polygon = (Polygon) geometry;
lasLevel.polygon = polygon;
lasLevel.id = rs.getLong(i++);
lasLevel.sourceId = rs.getLong(i++);
lasLevel.avgElev = rs.getDouble(i++);
lasLevel.minElev = rs.getDouble(i++);
lasLevel.maxElev = rs.getDouble(i++);
lasLevel.avgIntensity = rs.getShort(i++);
lasLevel.minIntensity = rs.getShort(i++);
lasLevel.maxIntensity = rs.getShort(i++);
lasLevels.add(lasLevel);
}
}
return lasLevels;
}
});
} | [
"public",
"static",
"List",
"<",
"LasLevel",
">",
"getLasLevels",
"(",
"ASpatialDb",
"db",
",",
"int",
"levelNum",
",",
"Envelope",
"envelope",
")",
"throws",
"Exception",
"{",
"String",
"tableName",
"=",
"TABLENAME",
"+",
"levelNum",
";",
"List",
"<",
"LasLevel",
">",
"lasLevels",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"sql",
"=",
"\"SELECT \"",
"+",
"COLUMN_GEOM",
"+",
"\",\"",
"+",
"//",
"COLUMN_ID",
"+",
"\",\"",
"+",
"COLUMN_SOURCE_ID",
"+",
"\",\"",
"+",
"COLUMN_AVG_ELEV",
"+",
"\",\"",
"+",
"//",
"COLUMN_MIN_ELEV",
"+",
"\",\"",
"+",
"//",
"COLUMN_MAX_ELEV",
"+",
"\",\"",
"+",
"//",
"COLUMN_AVG_INTENSITY",
"+",
"\",\"",
"+",
"//",
"COLUMN_MIN_INTENSITY",
"+",
"\",\"",
"+",
"//",
"COLUMN_MAX_INTENSITY",
";",
"sql",
"+=",
"\" FROM \"",
"+",
"tableName",
";",
"if",
"(",
"envelope",
"!=",
"null",
")",
"{",
"double",
"x1",
"=",
"envelope",
".",
"getMinX",
"(",
")",
";",
"double",
"y1",
"=",
"envelope",
".",
"getMinY",
"(",
")",
";",
"double",
"x2",
"=",
"envelope",
".",
"getMaxX",
"(",
")",
";",
"double",
"y2",
"=",
"envelope",
".",
"getMaxY",
"(",
")",
";",
"sql",
"+=",
"\" WHERE \"",
"+",
"db",
".",
"getSpatialindexBBoxWherePiece",
"(",
"tableName",
",",
"null",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
";",
"}",
"String",
"_sql",
"=",
"sql",
";",
"IGeometryParser",
"gp",
"=",
"db",
".",
"getType",
"(",
")",
".",
"getGeometryParser",
"(",
")",
";",
"return",
"db",
".",
"execOnConnection",
"(",
"conn",
"->",
"{",
"try",
"(",
"IHMStatement",
"stmt",
"=",
"conn",
".",
"createStatement",
"(",
")",
";",
"IHMResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"_sql",
")",
")",
"{",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"LasLevel",
"lasLevel",
"=",
"new",
"LasLevel",
"(",
")",
";",
"lasLevel",
".",
"level",
"=",
"levelNum",
";",
"int",
"i",
"=",
"1",
";",
"Geometry",
"geometry",
"=",
"gp",
".",
"fromResultSet",
"(",
"rs",
",",
"i",
"++",
")",
";",
"if",
"(",
"geometry",
"instanceof",
"Polygon",
")",
"{",
"Polygon",
"polygon",
"=",
"(",
"Polygon",
")",
"geometry",
";",
"lasLevel",
".",
"polygon",
"=",
"polygon",
";",
"lasLevel",
".",
"id",
"=",
"rs",
".",
"getLong",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"sourceId",
"=",
"rs",
".",
"getLong",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"avgElev",
"=",
"rs",
".",
"getDouble",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"minElev",
"=",
"rs",
".",
"getDouble",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"maxElev",
"=",
"rs",
".",
"getDouble",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"avgIntensity",
"=",
"rs",
".",
"getShort",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"minIntensity",
"=",
"rs",
".",
"getShort",
"(",
"i",
"++",
")",
";",
"lasLevel",
".",
"maxIntensity",
"=",
"rs",
".",
"getShort",
"(",
"i",
"++",
")",
";",
"lasLevels",
".",
"add",
"(",
"lasLevel",
")",
";",
"}",
"}",
"return",
"lasLevels",
";",
"}",
"}",
")",
";",
"}"
] | Query the las level table.
@param db the db to use.
@param levelNum the level to query.
@param envelope an optional {@link Envelope} to query spatially.
@return the list of extracted level cells.
@throws Exception | [
"Query",
"the",
"las",
"level",
"table",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/databases/LasLevelsTable.java#L180-L228 |
137,876 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/nap/AnnotationParser.java | AnnotationParser.handle | public static void handle(File srcFile, AnnotationHandler ah) throws Exception {
FileInputStream fis = new FileInputStream(srcFile);
FileChannel fc = fis.getChannel();
// Get a CharBuffer from the source file
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
CharsetDecoder cd = Charset.forName("8859_1").newDecoder();
CharBuffer cb = cd.decode(bb);
// handle the content.
ah.start(cb.toString());
handle(cb.toString(), ah);
ah.done();
fis.close();
} | java | public static void handle(File srcFile, AnnotationHandler ah) throws Exception {
FileInputStream fis = new FileInputStream(srcFile);
FileChannel fc = fis.getChannel();
// Get a CharBuffer from the source file
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
CharsetDecoder cd = Charset.forName("8859_1").newDecoder();
CharBuffer cb = cd.decode(bb);
// handle the content.
ah.start(cb.toString());
handle(cb.toString(), ah);
ah.done();
fis.close();
} | [
"public",
"static",
"void",
"handle",
"(",
"File",
"srcFile",
",",
"AnnotationHandler",
"ah",
")",
"throws",
"Exception",
"{",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"srcFile",
")",
";",
"FileChannel",
"fc",
"=",
"fis",
".",
"getChannel",
"(",
")",
";",
"// Get a CharBuffer from the source file",
"ByteBuffer",
"bb",
"=",
"fc",
".",
"map",
"(",
"FileChannel",
".",
"MapMode",
".",
"READ_ONLY",
",",
"0",
",",
"fc",
".",
"size",
"(",
")",
")",
";",
"CharsetDecoder",
"cd",
"=",
"Charset",
".",
"forName",
"(",
"\"8859_1\"",
")",
".",
"newDecoder",
"(",
")",
";",
"CharBuffer",
"cb",
"=",
"cd",
".",
"decode",
"(",
"bb",
")",
";",
"// handle the content.",
"ah",
".",
"start",
"(",
"cb",
".",
"toString",
"(",
")",
")",
";",
"handle",
"(",
"cb",
".",
"toString",
"(",
")",
",",
"ah",
")",
";",
"ah",
".",
"done",
"(",
")",
";",
"fis",
".",
"close",
"(",
")",
";",
"}"
] | Handle a file with an annotation handler.
@param file
@param ah
@throws java.lang.Exception | [
"Handle",
"a",
"file",
"with",
"an",
"annotation",
"handler",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/nap/AnnotationParser.java#L44-L59 |
137,877 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/nap/AnnotationParser.java | AnnotationParser.handle | public static void handle(String s, AnnotationHandler ah) {
Map<String, Map<String, String>> l = new LinkedHashMap<String, Map<String, String>>();
Matcher m = annPattern.matcher(s);
while (m.find()) {
// for (int i = 1; i <= m.groupCount(); i++) {
// System.out.println("Group " + i + " '" + m.group(i) + "'");
// }
String rest = s.substring(m.end(0)).trim();
String srcLine = null;
if (rest.indexOf('\n') > -1) {
srcLine = rest.substring(0, rest.indexOf('\n'));
} else {
srcLine = rest;
}
Map<String, String> val = new LinkedHashMap<String, String>();
String annArgs = m.group(3);
if (annArgs == null) {
// no annotations arguments
// e.g '@Function'
} else if (annArgs.indexOf('=') > -1) {
// KVP annotation
// e.g. '@Function(name="test", scope="global")'
StringTokenizer t = new StringTokenizer(annArgs, ",");
while (t.hasMoreTokens()) {
String arg = t.nextToken();
String key = arg.substring(0, arg.indexOf('='));
String value = arg.substring(arg.indexOf('=') + 1);
val.put(key.trim(), value.trim());
}
} else {
// single value annotation
// e.g. '@Function("test");
val.put(AnnotationHandler.VALUE, annArgs);
}
l.put(m.group(1), val);
// If the next line also has an annotation
// no source line will be passed into the handler
if (!annTestPattern.matcher(srcLine).find()) {
ah.handle(l, srcLine);
ah.log(" Ann -> " + l);
ah.log(" Src -> " + srcLine);
l = new LinkedHashMap<String, Map<String, String>>();
}
}
} | java | public static void handle(String s, AnnotationHandler ah) {
Map<String, Map<String, String>> l = new LinkedHashMap<String, Map<String, String>>();
Matcher m = annPattern.matcher(s);
while (m.find()) {
// for (int i = 1; i <= m.groupCount(); i++) {
// System.out.println("Group " + i + " '" + m.group(i) + "'");
// }
String rest = s.substring(m.end(0)).trim();
String srcLine = null;
if (rest.indexOf('\n') > -1) {
srcLine = rest.substring(0, rest.indexOf('\n'));
} else {
srcLine = rest;
}
Map<String, String> val = new LinkedHashMap<String, String>();
String annArgs = m.group(3);
if (annArgs == null) {
// no annotations arguments
// e.g '@Function'
} else if (annArgs.indexOf('=') > -1) {
// KVP annotation
// e.g. '@Function(name="test", scope="global")'
StringTokenizer t = new StringTokenizer(annArgs, ",");
while (t.hasMoreTokens()) {
String arg = t.nextToken();
String key = arg.substring(0, arg.indexOf('='));
String value = arg.substring(arg.indexOf('=') + 1);
val.put(key.trim(), value.trim());
}
} else {
// single value annotation
// e.g. '@Function("test");
val.put(AnnotationHandler.VALUE, annArgs);
}
l.put(m.group(1), val);
// If the next line also has an annotation
// no source line will be passed into the handler
if (!annTestPattern.matcher(srcLine).find()) {
ah.handle(l, srcLine);
ah.log(" Ann -> " + l);
ah.log(" Src -> " + srcLine);
l = new LinkedHashMap<String, Map<String, String>>();
}
}
} | [
"public",
"static",
"void",
"handle",
"(",
"String",
"s",
",",
"AnnotationHandler",
"ah",
")",
"{",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"l",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"(",
")",
";",
"Matcher",
"m",
"=",
"annPattern",
".",
"matcher",
"(",
"s",
")",
";",
"while",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"// for (int i = 1; i <= m.groupCount(); i++) {",
"// System.out.println(\"Group \" + i + \" '\" + m.group(i) + \"'\");",
"// }",
"String",
"rest",
"=",
"s",
".",
"substring",
"(",
"m",
".",
"end",
"(",
"0",
")",
")",
".",
"trim",
"(",
")",
";",
"String",
"srcLine",
"=",
"null",
";",
"if",
"(",
"rest",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"-",
"1",
")",
"{",
"srcLine",
"=",
"rest",
".",
"substring",
"(",
"0",
",",
"rest",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
";",
"}",
"else",
"{",
"srcLine",
"=",
"rest",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"val",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"String",
"annArgs",
"=",
"m",
".",
"group",
"(",
"3",
")",
";",
"if",
"(",
"annArgs",
"==",
"null",
")",
"{",
"// no annotations arguments",
"// e.g '@Function'",
"}",
"else",
"if",
"(",
"annArgs",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"-",
"1",
")",
"{",
"// KVP annotation",
"// e.g. '@Function(name=\"test\", scope=\"global\")'",
"StringTokenizer",
"t",
"=",
"new",
"StringTokenizer",
"(",
"annArgs",
",",
"\",\"",
")",
";",
"while",
"(",
"t",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"arg",
"=",
"t",
".",
"nextToken",
"(",
")",
";",
"String",
"key",
"=",
"arg",
".",
"substring",
"(",
"0",
",",
"arg",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
";",
"String",
"value",
"=",
"arg",
".",
"substring",
"(",
"arg",
".",
"indexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"val",
".",
"put",
"(",
"key",
".",
"trim",
"(",
")",
",",
"value",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"// single value annotation",
"// e.g. '@Function(\"test\");",
"val",
".",
"put",
"(",
"AnnotationHandler",
".",
"VALUE",
",",
"annArgs",
")",
";",
"}",
"l",
".",
"put",
"(",
"m",
".",
"group",
"(",
"1",
")",
",",
"val",
")",
";",
"// If the next line also has an annotation",
"// no source line will be passed into the handler",
"if",
"(",
"!",
"annTestPattern",
".",
"matcher",
"(",
"srcLine",
")",
".",
"find",
"(",
")",
")",
"{",
"ah",
".",
"handle",
"(",
"l",
",",
"srcLine",
")",
";",
"ah",
".",
"log",
"(",
"\" Ann -> \"",
"+",
"l",
")",
";",
"ah",
".",
"log",
"(",
"\" Src -> \"",
"+",
"srcLine",
")",
";",
"l",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"(",
")",
";",
"}",
"}",
"}"
] | Handle a string with an annotation handler
@param s the String to process
@param ah the annotation handler to use. | [
"Handle",
"a",
"string",
"with",
"an",
"annotation",
"handler"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/nap/AnnotationParser.java#L66-L114 |
137,878 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/styles/GeopaparazziDatabaseProperties.java | GeopaparazziDatabaseProperties.createPropertiesTable | public static void createPropertiesTable( ASpatialDb database ) throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("CREATE TABLE ");
sb.append(PROPERTIESTABLE);
sb.append(" (");
sb.append(ID);
sb.append(" INTEGER PRIMARY KEY AUTOINCREMENT, ");
sb.append(NAME).append(" TEXT, ");
sb.append(SIZE).append(" REAL, ");
sb.append(FILLCOLOR).append(" TEXT, ");
sb.append(STROKECOLOR).append(" TEXT, ");
sb.append(FILLALPHA).append(" REAL, ");
sb.append(STROKEALPHA).append(" REAL, ");
sb.append(SHAPE).append(" TEXT, ");
sb.append(WIDTH).append(" REAL, ");
sb.append(LABELSIZE).append(" REAL, ");
sb.append(LABELFIELD).append(" TEXT, ");
sb.append(LABELVISIBLE).append(" INTEGER, ");
sb.append(ENABLED).append(" INTEGER, ");
sb.append(ORDER).append(" INTEGER,");
sb.append(DASH).append(" TEXT,");
sb.append(MINZOOM).append(" INTEGER,");
sb.append(MAXZOOM).append(" INTEGER,");
sb.append(DECIMATION).append(" REAL,");
sb.append(THEME).append(" TEXT");
sb.append(" );");
String query = sb.toString();
database.executeInsertUpdateDeleteSql(query);
} | java | public static void createPropertiesTable( ASpatialDb database ) throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("CREATE TABLE ");
sb.append(PROPERTIESTABLE);
sb.append(" (");
sb.append(ID);
sb.append(" INTEGER PRIMARY KEY AUTOINCREMENT, ");
sb.append(NAME).append(" TEXT, ");
sb.append(SIZE).append(" REAL, ");
sb.append(FILLCOLOR).append(" TEXT, ");
sb.append(STROKECOLOR).append(" TEXT, ");
sb.append(FILLALPHA).append(" REAL, ");
sb.append(STROKEALPHA).append(" REAL, ");
sb.append(SHAPE).append(" TEXT, ");
sb.append(WIDTH).append(" REAL, ");
sb.append(LABELSIZE).append(" REAL, ");
sb.append(LABELFIELD).append(" TEXT, ");
sb.append(LABELVISIBLE).append(" INTEGER, ");
sb.append(ENABLED).append(" INTEGER, ");
sb.append(ORDER).append(" INTEGER,");
sb.append(DASH).append(" TEXT,");
sb.append(MINZOOM).append(" INTEGER,");
sb.append(MAXZOOM).append(" INTEGER,");
sb.append(DECIMATION).append(" REAL,");
sb.append(THEME).append(" TEXT");
sb.append(" );");
String query = sb.toString();
database.executeInsertUpdateDeleteSql(query);
} | [
"public",
"static",
"void",
"createPropertiesTable",
"(",
"ASpatialDb",
"database",
")",
"throws",
"Exception",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"CREATE TABLE \"",
")",
";",
"sb",
".",
"append",
"(",
"PROPERTIESTABLE",
")",
";",
"sb",
".",
"append",
"(",
"\" (\"",
")",
";",
"sb",
".",
"append",
"(",
"ID",
")",
";",
"sb",
".",
"append",
"(",
"\" INTEGER PRIMARY KEY AUTOINCREMENT, \"",
")",
";",
"sb",
".",
"append",
"(",
"NAME",
")",
".",
"append",
"(",
"\" TEXT, \"",
")",
";",
"sb",
".",
"append",
"(",
"SIZE",
")",
".",
"append",
"(",
"\" REAL, \"",
")",
";",
"sb",
".",
"append",
"(",
"FILLCOLOR",
")",
".",
"append",
"(",
"\" TEXT, \"",
")",
";",
"sb",
".",
"append",
"(",
"STROKECOLOR",
")",
".",
"append",
"(",
"\" TEXT, \"",
")",
";",
"sb",
".",
"append",
"(",
"FILLALPHA",
")",
".",
"append",
"(",
"\" REAL, \"",
")",
";",
"sb",
".",
"append",
"(",
"STROKEALPHA",
")",
".",
"append",
"(",
"\" REAL, \"",
")",
";",
"sb",
".",
"append",
"(",
"SHAPE",
")",
".",
"append",
"(",
"\" TEXT, \"",
")",
";",
"sb",
".",
"append",
"(",
"WIDTH",
")",
".",
"append",
"(",
"\" REAL, \"",
")",
";",
"sb",
".",
"append",
"(",
"LABELSIZE",
")",
".",
"append",
"(",
"\" REAL, \"",
")",
";",
"sb",
".",
"append",
"(",
"LABELFIELD",
")",
".",
"append",
"(",
"\" TEXT, \"",
")",
";",
"sb",
".",
"append",
"(",
"LABELVISIBLE",
")",
".",
"append",
"(",
"\" INTEGER, \"",
")",
";",
"sb",
".",
"append",
"(",
"ENABLED",
")",
".",
"append",
"(",
"\" INTEGER, \"",
")",
";",
"sb",
".",
"append",
"(",
"ORDER",
")",
".",
"append",
"(",
"\" INTEGER,\"",
")",
";",
"sb",
".",
"append",
"(",
"DASH",
")",
".",
"append",
"(",
"\" TEXT,\"",
")",
";",
"sb",
".",
"append",
"(",
"MINZOOM",
")",
".",
"append",
"(",
"\" INTEGER,\"",
")",
";",
"sb",
".",
"append",
"(",
"MAXZOOM",
")",
".",
"append",
"(",
"\" INTEGER,\"",
")",
";",
"sb",
".",
"append",
"(",
"DECIMATION",
")",
".",
"append",
"(",
"\" REAL,\"",
")",
";",
"sb",
".",
"append",
"(",
"THEME",
")",
".",
"append",
"(",
"\" TEXT\"",
")",
";",
"sb",
".",
"append",
"(",
"\" );\"",
")",
";",
"String",
"query",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"database",
".",
"executeInsertUpdateDeleteSql",
"(",
"query",
")",
";",
"}"
] | Create the properties table.
@param database the db to use.
@throws Exception | [
"Create",
"the",
"properties",
"table",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/styles/GeopaparazziDatabaseProperties.java#L69-L97 |
137,879 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/styles/GeopaparazziDatabaseProperties.java | GeopaparazziDatabaseProperties.createDefaultPropertiesForTable | public static Style createDefaultPropertiesForTable( ASpatialDb database, String spatialTableUniqueName,
String spatialTableLabelField ) throws Exception {
StringBuilder sbIn = new StringBuilder();
sbIn.append("insert into ").append(PROPERTIESTABLE);
sbIn.append(" ( ");
sbIn.append(NAME).append(" , ");
sbIn.append(SIZE).append(" , ");
sbIn.append(FILLCOLOR).append(" , ");
sbIn.append(STROKECOLOR).append(" , ");
sbIn.append(FILLALPHA).append(" , ");
sbIn.append(STROKEALPHA).append(" , ");
sbIn.append(SHAPE).append(" , ");
sbIn.append(WIDTH).append(" , ");
sbIn.append(LABELSIZE).append(" , ");
sbIn.append(LABELFIELD).append(" , ");
sbIn.append(LABELVISIBLE).append(" , ");
sbIn.append(ENABLED).append(" , ");
sbIn.append(ORDER).append(" , ");
sbIn.append(DASH).append(" ,");
sbIn.append(MINZOOM).append(" ,");
sbIn.append(MAXZOOM).append(" ,");
sbIn.append(DECIMATION);
sbIn.append(" ) ");
sbIn.append(" values ");
sbIn.append(" ( ");
Style style = new Style();
style.name = spatialTableUniqueName;
style.labelfield = spatialTableLabelField;
if (spatialTableLabelField != null && spatialTableLabelField.trim().length() > 0) {
style.labelvisible = 1;
}
sbIn.append(style.insertValuesString());
sbIn.append(" );");
if (database != null) {
String insertQuery = sbIn.toString();
database.executeInsertUpdateDeleteSql(insertQuery);
}
return style;
} | java | public static Style createDefaultPropertiesForTable( ASpatialDb database, String spatialTableUniqueName,
String spatialTableLabelField ) throws Exception {
StringBuilder sbIn = new StringBuilder();
sbIn.append("insert into ").append(PROPERTIESTABLE);
sbIn.append(" ( ");
sbIn.append(NAME).append(" , ");
sbIn.append(SIZE).append(" , ");
sbIn.append(FILLCOLOR).append(" , ");
sbIn.append(STROKECOLOR).append(" , ");
sbIn.append(FILLALPHA).append(" , ");
sbIn.append(STROKEALPHA).append(" , ");
sbIn.append(SHAPE).append(" , ");
sbIn.append(WIDTH).append(" , ");
sbIn.append(LABELSIZE).append(" , ");
sbIn.append(LABELFIELD).append(" , ");
sbIn.append(LABELVISIBLE).append(" , ");
sbIn.append(ENABLED).append(" , ");
sbIn.append(ORDER).append(" , ");
sbIn.append(DASH).append(" ,");
sbIn.append(MINZOOM).append(" ,");
sbIn.append(MAXZOOM).append(" ,");
sbIn.append(DECIMATION);
sbIn.append(" ) ");
sbIn.append(" values ");
sbIn.append(" ( ");
Style style = new Style();
style.name = spatialTableUniqueName;
style.labelfield = spatialTableLabelField;
if (spatialTableLabelField != null && spatialTableLabelField.trim().length() > 0) {
style.labelvisible = 1;
}
sbIn.append(style.insertValuesString());
sbIn.append(" );");
if (database != null) {
String insertQuery = sbIn.toString();
database.executeInsertUpdateDeleteSql(insertQuery);
}
return style;
} | [
"public",
"static",
"Style",
"createDefaultPropertiesForTable",
"(",
"ASpatialDb",
"database",
",",
"String",
"spatialTableUniqueName",
",",
"String",
"spatialTableLabelField",
")",
"throws",
"Exception",
"{",
"StringBuilder",
"sbIn",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sbIn",
".",
"append",
"(",
"\"insert into \"",
")",
".",
"append",
"(",
"PROPERTIESTABLE",
")",
";",
"sbIn",
".",
"append",
"(",
"\" ( \"",
")",
";",
"sbIn",
".",
"append",
"(",
"NAME",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"SIZE",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"FILLCOLOR",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"STROKECOLOR",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"FILLALPHA",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"STROKEALPHA",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"SHAPE",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"WIDTH",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"LABELSIZE",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"LABELFIELD",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"LABELVISIBLE",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"ENABLED",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"ORDER",
")",
".",
"append",
"(",
"\" , \"",
")",
";",
"sbIn",
".",
"append",
"(",
"DASH",
")",
".",
"append",
"(",
"\" ,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"MINZOOM",
")",
".",
"append",
"(",
"\" ,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"MAXZOOM",
")",
".",
"append",
"(",
"\" ,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"DECIMATION",
")",
";",
"sbIn",
".",
"append",
"(",
"\" ) \"",
")",
";",
"sbIn",
".",
"append",
"(",
"\" values \"",
")",
";",
"sbIn",
".",
"append",
"(",
"\" ( \"",
")",
";",
"Style",
"style",
"=",
"new",
"Style",
"(",
")",
";",
"style",
".",
"name",
"=",
"spatialTableUniqueName",
";",
"style",
".",
"labelfield",
"=",
"spatialTableLabelField",
";",
"if",
"(",
"spatialTableLabelField",
"!=",
"null",
"&&",
"spatialTableLabelField",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"style",
".",
"labelvisible",
"=",
"1",
";",
"}",
"sbIn",
".",
"append",
"(",
"style",
".",
"insertValuesString",
"(",
")",
")",
";",
"sbIn",
".",
"append",
"(",
"\" );\"",
")",
";",
"if",
"(",
"database",
"!=",
"null",
")",
"{",
"String",
"insertQuery",
"=",
"sbIn",
".",
"toString",
"(",
")",
";",
"database",
".",
"executeInsertUpdateDeleteSql",
"(",
"insertQuery",
")",
";",
"}",
"return",
"style",
";",
"}"
] | Create a default properties table for a spatial table.
@param database the db to use. If <code>null</code>, the style is not inserted in the db.
@param spatialTableUniqueName the spatial table's unique name to create the property record for.
@return
@return the created style object.
@throws Exception if something goes wrong. | [
"Create",
"a",
"default",
"properties",
"table",
"for",
"a",
"spatial",
"table",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/styles/GeopaparazziDatabaseProperties.java#L108-L147 |
137,880 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/styles/GeopaparazziDatabaseProperties.java | GeopaparazziDatabaseProperties.updateStyle | public static void updateStyle( ASpatialDb database, Style style ) throws Exception {
StringBuilder sbIn = new StringBuilder();
sbIn.append("update ").append(PROPERTIESTABLE);
sbIn.append(" set ");
// sbIn.append(NAME).append("='").append(style.name).append("' , ");
sbIn.append(SIZE).append("=?,");
sbIn.append(FILLCOLOR).append("=?,");
sbIn.append(STROKECOLOR).append("=?,");
sbIn.append(FILLALPHA).append("=?,");
sbIn.append(STROKEALPHA).append("=?,");
sbIn.append(SHAPE).append("=?,");
sbIn.append(WIDTH).append("=?,");
sbIn.append(LABELSIZE).append("=?,");
sbIn.append(LABELFIELD).append("=?,");
sbIn.append(LABELVISIBLE).append("=?,");
sbIn.append(ENABLED).append("=?,");
sbIn.append(ORDER).append("=?,");
sbIn.append(DASH).append("=?,");
sbIn.append(MINZOOM).append("=?,");
sbIn.append(MAXZOOM).append("=?,");
sbIn.append(DECIMATION).append("=?,");
sbIn.append(THEME).append("=?");
sbIn.append(" where ");
sbIn.append(NAME);
sbIn.append("='");
sbIn.append(style.name);
sbIn.append("';");
Object[] objects = {style.size, style.fillcolor, style.strokecolor, style.fillalpha, style.strokealpha, style.shape,
style.width, style.labelsize, style.labelfield, style.labelvisible, style.enabled, style.order, style.dashPattern,
style.minZoom, style.maxZoom, style.decimationFactor, style.getTheme()};
String updateQuery = sbIn.toString();
database.executeInsertUpdateDeletePreparedSql(updateQuery, objects);
} | java | public static void updateStyle( ASpatialDb database, Style style ) throws Exception {
StringBuilder sbIn = new StringBuilder();
sbIn.append("update ").append(PROPERTIESTABLE);
sbIn.append(" set ");
// sbIn.append(NAME).append("='").append(style.name).append("' , ");
sbIn.append(SIZE).append("=?,");
sbIn.append(FILLCOLOR).append("=?,");
sbIn.append(STROKECOLOR).append("=?,");
sbIn.append(FILLALPHA).append("=?,");
sbIn.append(STROKEALPHA).append("=?,");
sbIn.append(SHAPE).append("=?,");
sbIn.append(WIDTH).append("=?,");
sbIn.append(LABELSIZE).append("=?,");
sbIn.append(LABELFIELD).append("=?,");
sbIn.append(LABELVISIBLE).append("=?,");
sbIn.append(ENABLED).append("=?,");
sbIn.append(ORDER).append("=?,");
sbIn.append(DASH).append("=?,");
sbIn.append(MINZOOM).append("=?,");
sbIn.append(MAXZOOM).append("=?,");
sbIn.append(DECIMATION).append("=?,");
sbIn.append(THEME).append("=?");
sbIn.append(" where ");
sbIn.append(NAME);
sbIn.append("='");
sbIn.append(style.name);
sbIn.append("';");
Object[] objects = {style.size, style.fillcolor, style.strokecolor, style.fillalpha, style.strokealpha, style.shape,
style.width, style.labelsize, style.labelfield, style.labelvisible, style.enabled, style.order, style.dashPattern,
style.minZoom, style.maxZoom, style.decimationFactor, style.getTheme()};
String updateQuery = sbIn.toString();
database.executeInsertUpdateDeletePreparedSql(updateQuery, objects);
} | [
"public",
"static",
"void",
"updateStyle",
"(",
"ASpatialDb",
"database",
",",
"Style",
"style",
")",
"throws",
"Exception",
"{",
"StringBuilder",
"sbIn",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sbIn",
".",
"append",
"(",
"\"update \"",
")",
".",
"append",
"(",
"PROPERTIESTABLE",
")",
";",
"sbIn",
".",
"append",
"(",
"\" set \"",
")",
";",
"// sbIn.append(NAME).append(\"='\").append(style.name).append(\"' , \");",
"sbIn",
".",
"append",
"(",
"SIZE",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"FILLCOLOR",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"STROKECOLOR",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"FILLALPHA",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"STROKEALPHA",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"SHAPE",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"WIDTH",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"LABELSIZE",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"LABELFIELD",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"LABELVISIBLE",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"ENABLED",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"ORDER",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"DASH",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"MINZOOM",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"MAXZOOM",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"DECIMATION",
")",
".",
"append",
"(",
"\"=?,\"",
")",
";",
"sbIn",
".",
"append",
"(",
"THEME",
")",
".",
"append",
"(",
"\"=?\"",
")",
";",
"sbIn",
".",
"append",
"(",
"\" where \"",
")",
";",
"sbIn",
".",
"append",
"(",
"NAME",
")",
";",
"sbIn",
".",
"append",
"(",
"\"='\"",
")",
";",
"sbIn",
".",
"append",
"(",
"style",
".",
"name",
")",
";",
"sbIn",
".",
"append",
"(",
"\"';\"",
")",
";",
"Object",
"[",
"]",
"objects",
"=",
"{",
"style",
".",
"size",
",",
"style",
".",
"fillcolor",
",",
"style",
".",
"strokecolor",
",",
"style",
".",
"fillalpha",
",",
"style",
".",
"strokealpha",
",",
"style",
".",
"shape",
",",
"style",
".",
"width",
",",
"style",
".",
"labelsize",
",",
"style",
".",
"labelfield",
",",
"style",
".",
"labelvisible",
",",
"style",
".",
"enabled",
",",
"style",
".",
"order",
",",
"style",
".",
"dashPattern",
",",
"style",
".",
"minZoom",
",",
"style",
".",
"maxZoom",
",",
"style",
".",
"decimationFactor",
",",
"style",
".",
"getTheme",
"(",
")",
"}",
";",
"String",
"updateQuery",
"=",
"sbIn",
".",
"toString",
"(",
")",
";",
"database",
".",
"executeInsertUpdateDeletePreparedSql",
"(",
"updateQuery",
",",
"objects",
")",
";",
"}"
] | Update a style definition.
@param database the db to use.
@param style the {@link Style} to set.
@throws Exception if something goes wrong. | [
"Update",
"a",
"style",
"definition",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/styles/GeopaparazziDatabaseProperties.java#L156-L190 |
137,881 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/ui/TableListener.java | TableListener.parseString | private ArrayList<ArrayList<String>> parseString(String text) {
ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
StringTokenizer linetoken = new StringTokenizer(text, "\n");
StringTokenizer token;
String current;
while (linetoken.hasMoreTokens()) {
current = linetoken.nextToken();
if (current.contains(",")) {
token = new StringTokenizer(current, ",");
} else {
token = new StringTokenizer(current);
}
ArrayList<String> line = new ArrayList<String>();
while (token.hasMoreTokens()) {
line.add(token.nextToken());
}
result.add(line);
}
return result;
} | java | private ArrayList<ArrayList<String>> parseString(String text) {
ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
StringTokenizer linetoken = new StringTokenizer(text, "\n");
StringTokenizer token;
String current;
while (linetoken.hasMoreTokens()) {
current = linetoken.nextToken();
if (current.contains(",")) {
token = new StringTokenizer(current, ",");
} else {
token = new StringTokenizer(current);
}
ArrayList<String> line = new ArrayList<String>();
while (token.hasMoreTokens()) {
line.add(token.nextToken());
}
result.add(line);
}
return result;
} | [
"private",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">",
">",
"parseString",
"(",
"String",
"text",
")",
"{",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">>",
"result",
"=",
"new",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">",
">",
"(",
")",
";",
"StringTokenizer",
"linetoken",
"=",
"new",
"StringTokenizer",
"(",
"text",
",",
"\"\\n\"",
")",
";",
"StringTokenizer",
"token",
";",
"String",
"current",
";",
"while",
"(",
"linetoken",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"current",
"=",
"linetoken",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"current",
".",
"contains",
"(",
"\",\"",
")",
")",
"{",
"token",
"=",
"new",
"StringTokenizer",
"(",
"current",
",",
"\",\"",
")",
";",
"}",
"else",
"{",
"token",
"=",
"new",
"StringTokenizer",
"(",
"current",
")",
";",
"}",
"ArrayList",
"<",
"String",
">",
"line",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"token",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"line",
".",
"add",
"(",
"token",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"result",
".",
"add",
"(",
"line",
")",
";",
"}",
"return",
"result",
";",
"}"
] | turns the clipboard into a list of tokens
each array list is a line, each string in the list is a token in the line
@param text
@return | [
"turns",
"the",
"clipboard",
"into",
"a",
"list",
"of",
"tokens",
"each",
"array",
"list",
"is",
"a",
"line",
"each",
"string",
"in",
"the",
"list",
"is",
"a",
"token",
"in",
"the",
"line"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/ui/TableListener.java#L41-L61 |
137,882 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/ui/TableListener.java | TableListener.addContents | private void addContents(String text) {
int firstColSelected = table.getSelectedColumn();
int firstRowSelected = table.getSelectedRow();
int temp = firstColSelected;
if (firstColSelected == -1 || firstRowSelected == -1) {
return;
}
ArrayList<ArrayList<String>> clipboard = parseString(text);
for (int i = 0; i < clipboard.size(); i++) {
for (int j = 0; j < clipboard.get(i).size(); j++) {
try {
table.getModel().setValueAt(clipboard.get(i).get(j), firstRowSelected, temp++);
} catch (Exception e) {
}
}
temp = firstColSelected;
firstRowSelected++;
}
} | java | private void addContents(String text) {
int firstColSelected = table.getSelectedColumn();
int firstRowSelected = table.getSelectedRow();
int temp = firstColSelected;
if (firstColSelected == -1 || firstRowSelected == -1) {
return;
}
ArrayList<ArrayList<String>> clipboard = parseString(text);
for (int i = 0; i < clipboard.size(); i++) {
for (int j = 0; j < clipboard.get(i).size(); j++) {
try {
table.getModel().setValueAt(clipboard.get(i).get(j), firstRowSelected, temp++);
} catch (Exception e) {
}
}
temp = firstColSelected;
firstRowSelected++;
}
} | [
"private",
"void",
"addContents",
"(",
"String",
"text",
")",
"{",
"int",
"firstColSelected",
"=",
"table",
".",
"getSelectedColumn",
"(",
")",
";",
"int",
"firstRowSelected",
"=",
"table",
".",
"getSelectedRow",
"(",
")",
";",
"int",
"temp",
"=",
"firstColSelected",
";",
"if",
"(",
"firstColSelected",
"==",
"-",
"1",
"||",
"firstRowSelected",
"==",
"-",
"1",
")",
"{",
"return",
";",
"}",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">",
">",
"clipboard",
"=",
"parseString",
"(",
"text",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"clipboard",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"clipboard",
".",
"get",
"(",
"i",
")",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"try",
"{",
"table",
".",
"getModel",
"(",
")",
".",
"setValueAt",
"(",
"clipboard",
".",
"get",
"(",
"i",
")",
".",
"get",
"(",
"j",
")",
",",
"firstRowSelected",
",",
"temp",
"++",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"temp",
"=",
"firstColSelected",
";",
"firstRowSelected",
"++",
";",
"}",
"}"
] | this adds the text to the jtable
@param text | [
"this",
"adds",
"the",
"text",
"to",
"the",
"jtable"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/ui/TableListener.java#L67-L87 |
137,883 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/ui/TableListener.java | TableListener.pasteClipboard | public void pasteClipboard() {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
try {
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
addContents((String) t.getTransferData(DataFlavor.stringFlavor));
table.repaint();
}
} catch (Exception e) {
e.printStackTrace();
}
} | java | public void pasteClipboard() {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
try {
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
addContents((String) t.getTransferData(DataFlavor.stringFlavor));
table.repaint();
}
} catch (Exception e) {
e.printStackTrace();
}
} | [
"public",
"void",
"pasteClipboard",
"(",
")",
"{",
"Transferable",
"t",
"=",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getSystemClipboard",
"(",
")",
".",
"getContents",
"(",
"null",
")",
";",
"try",
"{",
"if",
"(",
"t",
"!=",
"null",
"&&",
"t",
".",
"isDataFlavorSupported",
"(",
"DataFlavor",
".",
"stringFlavor",
")",
")",
"{",
"addContents",
"(",
"(",
"String",
")",
"t",
".",
"getTransferData",
"(",
"DataFlavor",
".",
"stringFlavor",
")",
")",
";",
"table",
".",
"repaint",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | this is the function that adds the clipboard contents to the table | [
"this",
"is",
"the",
"function",
"that",
"adds",
"the",
"clipboard",
"contents",
"to",
"the",
"table"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/ui/TableListener.java#L90-L100 |
137,884 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java | ViewControlsLayer.getControlType | public String getControlType(Object control)
{
if (control == null || !(control instanceof ScreenAnnotation))
return null;
if (showPanControls && controlPan.equals(control))
return AVKey.VIEW_PAN;
else if (showLookControls && controlLook.equals(control))
return AVKey.VIEW_LOOK;
else if (showHeadingControls && controlHeadingLeft.equals(control))
return AVKey.VIEW_HEADING_LEFT;
else if (showHeadingControls && controlHeadingRight.equals(control))
return AVKey.VIEW_HEADING_RIGHT;
else if (showZoomControls && controlZoomIn.equals(control))
return AVKey.VIEW_ZOOM_IN;
else if (showZoomControls && controlZoomOut.equals(control))
return AVKey.VIEW_ZOOM_OUT;
else if (showPitchControls && controlPitchUp.equals(control))
return AVKey.VIEW_PITCH_UP;
else if (showPitchControls && controlPitchDown.equals(control))
return AVKey.VIEW_PITCH_DOWN;
else if (showFovControls && controlFovNarrow.equals(control))
return AVKey.VIEW_FOV_NARROW;
else if (showFovControls && controlFovWide.equals(control))
return AVKey.VIEW_FOV_WIDE;
else if (showVeControls && controlVeUp.equals(control))
return AVKey.VERTICAL_EXAGGERATION_UP;
else if (showVeControls && controlVeDown.equals(control))
return AVKey.VERTICAL_EXAGGERATION_DOWN;
return null;
} | java | public String getControlType(Object control)
{
if (control == null || !(control instanceof ScreenAnnotation))
return null;
if (showPanControls && controlPan.equals(control))
return AVKey.VIEW_PAN;
else if (showLookControls && controlLook.equals(control))
return AVKey.VIEW_LOOK;
else if (showHeadingControls && controlHeadingLeft.equals(control))
return AVKey.VIEW_HEADING_LEFT;
else if (showHeadingControls && controlHeadingRight.equals(control))
return AVKey.VIEW_HEADING_RIGHT;
else if (showZoomControls && controlZoomIn.equals(control))
return AVKey.VIEW_ZOOM_IN;
else if (showZoomControls && controlZoomOut.equals(control))
return AVKey.VIEW_ZOOM_OUT;
else if (showPitchControls && controlPitchUp.equals(control))
return AVKey.VIEW_PITCH_UP;
else if (showPitchControls && controlPitchDown.equals(control))
return AVKey.VIEW_PITCH_DOWN;
else if (showFovControls && controlFovNarrow.equals(control))
return AVKey.VIEW_FOV_NARROW;
else if (showFovControls && controlFovWide.equals(control))
return AVKey.VIEW_FOV_WIDE;
else if (showVeControls && controlVeUp.equals(control))
return AVKey.VERTICAL_EXAGGERATION_UP;
else if (showVeControls && controlVeDown.equals(control))
return AVKey.VERTICAL_EXAGGERATION_DOWN;
return null;
} | [
"public",
"String",
"getControlType",
"(",
"Object",
"control",
")",
"{",
"if",
"(",
"control",
"==",
"null",
"||",
"!",
"(",
"control",
"instanceof",
"ScreenAnnotation",
")",
")",
"return",
"null",
";",
"if",
"(",
"showPanControls",
"&&",
"controlPan",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_PAN",
";",
"else",
"if",
"(",
"showLookControls",
"&&",
"controlLook",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_LOOK",
";",
"else",
"if",
"(",
"showHeadingControls",
"&&",
"controlHeadingLeft",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_HEADING_LEFT",
";",
"else",
"if",
"(",
"showHeadingControls",
"&&",
"controlHeadingRight",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_HEADING_RIGHT",
";",
"else",
"if",
"(",
"showZoomControls",
"&&",
"controlZoomIn",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_ZOOM_IN",
";",
"else",
"if",
"(",
"showZoomControls",
"&&",
"controlZoomOut",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_ZOOM_OUT",
";",
"else",
"if",
"(",
"showPitchControls",
"&&",
"controlPitchUp",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_PITCH_UP",
";",
"else",
"if",
"(",
"showPitchControls",
"&&",
"controlPitchDown",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_PITCH_DOWN",
";",
"else",
"if",
"(",
"showFovControls",
"&&",
"controlFovNarrow",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_FOV_NARROW",
";",
"else",
"if",
"(",
"showFovControls",
"&&",
"controlFovWide",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VIEW_FOV_WIDE",
";",
"else",
"if",
"(",
"showVeControls",
"&&",
"controlVeUp",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VERTICAL_EXAGGERATION_UP",
";",
"else",
"if",
"(",
"showVeControls",
"&&",
"controlVeDown",
".",
"equals",
"(",
"control",
")",
")",
"return",
"AVKey",
".",
"VERTICAL_EXAGGERATION_DOWN",
";",
"return",
"null",
";",
"}"
] | Get the control type associated with the given object or null if unknown.
@param control the control object
@return the control type. Can be one of {@link AVKey#VIEW_PAN}, {@link AVKey#VIEW_LOOK}, {@link
AVKey#VIEW_HEADING_LEFT}, {@link AVKey#VIEW_HEADING_RIGHT}, {@link AVKey#VIEW_ZOOM_IN}, {@link
AVKey#VIEW_ZOOM_OUT}, {@link AVKey#VIEW_PITCH_UP}, {@link AVKey#VIEW_PITCH_DOWN}, {@link
AVKey#VIEW_FOV_NARROW} or {@link AVKey#VIEW_FOV_WIDE}. <p> Returns null if the object is not a view
control associated with this layer. </p> | [
"Get",
"the",
"control",
"type",
"associated",
"with",
"the",
"given",
"object",
"or",
"null",
"if",
"unknown",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java#L393-L424 |
137,885 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java | ViewControlsLayer.highlight | public void highlight(Object control)
{
// Manage highlighting of controls.
if (this.currentControl == control)
return; // same thing selected
// Turn off highlight if on.
if (this.currentControl != null)
{
this.currentControl.getAttributes().setImageOpacity(-1); // use default opacity
this.currentControl = null;
}
// Turn on highlight if object selected.
if (control != null && control instanceof ScreenAnnotation)
{
this.currentControl = (ScreenAnnotation) control;
this.currentControl.getAttributes().setImageOpacity(1);
}
} | java | public void highlight(Object control)
{
// Manage highlighting of controls.
if (this.currentControl == control)
return; // same thing selected
// Turn off highlight if on.
if (this.currentControl != null)
{
this.currentControl.getAttributes().setImageOpacity(-1); // use default opacity
this.currentControl = null;
}
// Turn on highlight if object selected.
if (control != null && control instanceof ScreenAnnotation)
{
this.currentControl = (ScreenAnnotation) control;
this.currentControl.getAttributes().setImageOpacity(1);
}
} | [
"public",
"void",
"highlight",
"(",
"Object",
"control",
")",
"{",
"// Manage highlighting of controls.",
"if",
"(",
"this",
".",
"currentControl",
"==",
"control",
")",
"return",
";",
"// same thing selected",
"// Turn off highlight if on.",
"if",
"(",
"this",
".",
"currentControl",
"!=",
"null",
")",
"{",
"this",
".",
"currentControl",
".",
"getAttributes",
"(",
")",
".",
"setImageOpacity",
"(",
"-",
"1",
")",
";",
"// use default opacity",
"this",
".",
"currentControl",
"=",
"null",
";",
"}",
"// Turn on highlight if object selected.",
"if",
"(",
"control",
"!=",
"null",
"&&",
"control",
"instanceof",
"ScreenAnnotation",
")",
"{",
"this",
".",
"currentControl",
"=",
"(",
"ScreenAnnotation",
")",
"control",
";",
"this",
".",
"currentControl",
".",
"getAttributes",
"(",
")",
".",
"setImageOpacity",
"(",
"1",
")",
";",
"}",
"}"
] | Specifies the control to highlight. Any currently highlighted control is un-highlighted.
@param control the control to highlight. | [
"Specifies",
"the",
"control",
"to",
"highlight",
".",
"Any",
"currently",
"highlighted",
"control",
"is",
"un",
"-",
"highlighted",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java#L441-L460 |
137,886 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java | ViewControlsLayer.getImageSource | protected Object getImageSource(String control)
{
if (control.equals(AVKey.VIEW_PAN))
return IMAGE_PAN;
else if (control.equals(AVKey.VIEW_LOOK))
return IMAGE_LOOK;
else if (control.equals(AVKey.VIEW_HEADING_LEFT))
return IMAGE_HEADING_LEFT;
else if (control.equals(AVKey.VIEW_HEADING_RIGHT))
return IMAGE_HEADING_RIGHT;
else if (control.equals(AVKey.VIEW_ZOOM_IN))
return IMAGE_ZOOM_IN;
else if (control.equals(AVKey.VIEW_ZOOM_OUT))
return IMAGE_ZOOM_OUT;
else if (control.equals(AVKey.VIEW_PITCH_UP))
return IMAGE_PITCH_UP;
else if (control.equals(AVKey.VIEW_PITCH_DOWN))
return IMAGE_PITCH_DOWN;
else if (control.equals(AVKey.VIEW_FOV_WIDE))
return IMAGE_FOV_WIDE;
else if (control.equals(AVKey.VIEW_FOV_NARROW))
return IMAGE_FOV_NARROW;
else if (control.equals(AVKey.VERTICAL_EXAGGERATION_UP))
return IMAGE_VE_UP;
else if (control.equals(AVKey.VERTICAL_EXAGGERATION_DOWN))
return IMAGE_VE_DOWN;
return null;
} | java | protected Object getImageSource(String control)
{
if (control.equals(AVKey.VIEW_PAN))
return IMAGE_PAN;
else if (control.equals(AVKey.VIEW_LOOK))
return IMAGE_LOOK;
else if (control.equals(AVKey.VIEW_HEADING_LEFT))
return IMAGE_HEADING_LEFT;
else if (control.equals(AVKey.VIEW_HEADING_RIGHT))
return IMAGE_HEADING_RIGHT;
else if (control.equals(AVKey.VIEW_ZOOM_IN))
return IMAGE_ZOOM_IN;
else if (control.equals(AVKey.VIEW_ZOOM_OUT))
return IMAGE_ZOOM_OUT;
else if (control.equals(AVKey.VIEW_PITCH_UP))
return IMAGE_PITCH_UP;
else if (control.equals(AVKey.VIEW_PITCH_DOWN))
return IMAGE_PITCH_DOWN;
else if (control.equals(AVKey.VIEW_FOV_WIDE))
return IMAGE_FOV_WIDE;
else if (control.equals(AVKey.VIEW_FOV_NARROW))
return IMAGE_FOV_NARROW;
else if (control.equals(AVKey.VERTICAL_EXAGGERATION_UP))
return IMAGE_VE_UP;
else if (control.equals(AVKey.VERTICAL_EXAGGERATION_DOWN))
return IMAGE_VE_DOWN;
return null;
} | [
"protected",
"Object",
"getImageSource",
"(",
"String",
"control",
")",
"{",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_PAN",
")",
")",
"return",
"IMAGE_PAN",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_LOOK",
")",
")",
"return",
"IMAGE_LOOK",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_HEADING_LEFT",
")",
")",
"return",
"IMAGE_HEADING_LEFT",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_HEADING_RIGHT",
")",
")",
"return",
"IMAGE_HEADING_RIGHT",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_ZOOM_IN",
")",
")",
"return",
"IMAGE_ZOOM_IN",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_ZOOM_OUT",
")",
")",
"return",
"IMAGE_ZOOM_OUT",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_PITCH_UP",
")",
")",
"return",
"IMAGE_PITCH_UP",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_PITCH_DOWN",
")",
")",
"return",
"IMAGE_PITCH_DOWN",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_FOV_WIDE",
")",
")",
"return",
"IMAGE_FOV_WIDE",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VIEW_FOV_NARROW",
")",
")",
"return",
"IMAGE_FOV_NARROW",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VERTICAL_EXAGGERATION_UP",
")",
")",
"return",
"IMAGE_VE_UP",
";",
"else",
"if",
"(",
"control",
".",
"equals",
"(",
"AVKey",
".",
"VERTICAL_EXAGGERATION_DOWN",
")",
")",
"return",
"IMAGE_VE_DOWN",
";",
"return",
"null",
";",
"}"
] | Get a control image source.
@param control the control type. Can be one of {@link AVKey#VIEW_PAN}, {@link AVKey#VIEW_LOOK}, {@link
AVKey#VIEW_HEADING_LEFT}, {@link AVKey#VIEW_HEADING_RIGHT}, {@link AVKey#VIEW_ZOOM_IN}, {@link
AVKey#VIEW_ZOOM_OUT}, {@link AVKey#VIEW_PITCH_UP}, {@link AVKey#VIEW_PITCH_DOWN}, {@link
AVKey#VIEW_FOV_NARROW} or {@link AVKey#VIEW_FOV_WIDE}.
@return the image source associated with the given control type. | [
"Get",
"a",
"control",
"image",
"source",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java#L592-L620 |
137,887 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java | ViewControlsLayer.computeLocation | protected Point computeLocation(Rectangle viewport, Rectangle controls)
{
double x;
double y;
if (this.locationCenter != null)
{
x = this.locationCenter.x - controls.width / 2;
y = this.locationCenter.y - controls.height / 2;
}
else if (this.position.equals(AVKey.NORTHEAST))
{
x = viewport.getWidth() - controls.width - this.borderWidth;
y = viewport.getHeight() - controls.height - this.borderWidth;
}
else if (this.position.equals(AVKey.SOUTHEAST))
{
x = viewport.getWidth() - controls.width - this.borderWidth;
y = 0d + this.borderWidth;
}
else if (this.position.equals(AVKey.NORTHWEST))
{
x = 0d + this.borderWidth;
y = viewport.getHeight() - controls.height - this.borderWidth;
}
else if (this.position.equals(AVKey.SOUTHWEST))
{
x = 0d + this.borderWidth;
y = 0d + this.borderWidth;
}
else // use North East as default
{
x = viewport.getWidth() - controls.width - this.borderWidth;
y = viewport.getHeight() - controls.height - this.borderWidth;
}
if (this.locationOffset != null)
{
x += this.locationOffset.x;
y += this.locationOffset.y;
}
return new Point((int) x, (int) y);
} | java | protected Point computeLocation(Rectangle viewport, Rectangle controls)
{
double x;
double y;
if (this.locationCenter != null)
{
x = this.locationCenter.x - controls.width / 2;
y = this.locationCenter.y - controls.height / 2;
}
else if (this.position.equals(AVKey.NORTHEAST))
{
x = viewport.getWidth() - controls.width - this.borderWidth;
y = viewport.getHeight() - controls.height - this.borderWidth;
}
else if (this.position.equals(AVKey.SOUTHEAST))
{
x = viewport.getWidth() - controls.width - this.borderWidth;
y = 0d + this.borderWidth;
}
else if (this.position.equals(AVKey.NORTHWEST))
{
x = 0d + this.borderWidth;
y = viewport.getHeight() - controls.height - this.borderWidth;
}
else if (this.position.equals(AVKey.SOUTHWEST))
{
x = 0d + this.borderWidth;
y = 0d + this.borderWidth;
}
else // use North East as default
{
x = viewport.getWidth() - controls.width - this.borderWidth;
y = viewport.getHeight() - controls.height - this.borderWidth;
}
if (this.locationOffset != null)
{
x += this.locationOffset.x;
y += this.locationOffset.y;
}
return new Point((int) x, (int) y);
} | [
"protected",
"Point",
"computeLocation",
"(",
"Rectangle",
"viewport",
",",
"Rectangle",
"controls",
")",
"{",
"double",
"x",
";",
"double",
"y",
";",
"if",
"(",
"this",
".",
"locationCenter",
"!=",
"null",
")",
"{",
"x",
"=",
"this",
".",
"locationCenter",
".",
"x",
"-",
"controls",
".",
"width",
"/",
"2",
";",
"y",
"=",
"this",
".",
"locationCenter",
".",
"y",
"-",
"controls",
".",
"height",
"/",
"2",
";",
"}",
"else",
"if",
"(",
"this",
".",
"position",
".",
"equals",
"(",
"AVKey",
".",
"NORTHEAST",
")",
")",
"{",
"x",
"=",
"viewport",
".",
"getWidth",
"(",
")",
"-",
"controls",
".",
"width",
"-",
"this",
".",
"borderWidth",
";",
"y",
"=",
"viewport",
".",
"getHeight",
"(",
")",
"-",
"controls",
".",
"height",
"-",
"this",
".",
"borderWidth",
";",
"}",
"else",
"if",
"(",
"this",
".",
"position",
".",
"equals",
"(",
"AVKey",
".",
"SOUTHEAST",
")",
")",
"{",
"x",
"=",
"viewport",
".",
"getWidth",
"(",
")",
"-",
"controls",
".",
"width",
"-",
"this",
".",
"borderWidth",
";",
"y",
"=",
"0d",
"+",
"this",
".",
"borderWidth",
";",
"}",
"else",
"if",
"(",
"this",
".",
"position",
".",
"equals",
"(",
"AVKey",
".",
"NORTHWEST",
")",
")",
"{",
"x",
"=",
"0d",
"+",
"this",
".",
"borderWidth",
";",
"y",
"=",
"viewport",
".",
"getHeight",
"(",
")",
"-",
"controls",
".",
"height",
"-",
"this",
".",
"borderWidth",
";",
"}",
"else",
"if",
"(",
"this",
".",
"position",
".",
"equals",
"(",
"AVKey",
".",
"SOUTHWEST",
")",
")",
"{",
"x",
"=",
"0d",
"+",
"this",
".",
"borderWidth",
";",
"y",
"=",
"0d",
"+",
"this",
".",
"borderWidth",
";",
"}",
"else",
"// use North East as default",
"{",
"x",
"=",
"viewport",
".",
"getWidth",
"(",
")",
"-",
"controls",
".",
"width",
"-",
"this",
".",
"borderWidth",
";",
"y",
"=",
"viewport",
".",
"getHeight",
"(",
")",
"-",
"controls",
".",
"height",
"-",
"this",
".",
"borderWidth",
";",
"}",
"if",
"(",
"this",
".",
"locationOffset",
"!=",
"null",
")",
"{",
"x",
"+=",
"this",
".",
"locationOffset",
".",
"x",
";",
"y",
"+=",
"this",
".",
"locationOffset",
".",
"y",
";",
"}",
"return",
"new",
"Point",
"(",
"(",
"int",
")",
"x",
",",
"(",
"int",
")",
"y",
")",
";",
"}"
] | Compute the screen location of the controls overall rectangle bottom right corner according to either the
location center if not null, or the screen position.
@param viewport the current viewport rectangle.
@param controls the overall controls rectangle
@return the screen location of the bottom left corner - south west corner. | [
"Compute",
"the",
"screen",
"location",
"of",
"the",
"controls",
"overall",
"rectangle",
"bottom",
"right",
"corner",
"according",
"to",
"either",
"the",
"location",
"center",
"if",
"not",
"null",
"or",
"the",
"screen",
"position",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsLayer.java#L736-L779 |
137,888 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java | ValidationMessage.error | public static ValidationMessage<Origin> error(String messageKey,Object... params) {
return ValidationMessage.message(Severity.ERROR, messageKey, params);
} | java | public static ValidationMessage<Origin> error(String messageKey,Object... params) {
return ValidationMessage.message(Severity.ERROR, messageKey, params);
} | [
"public",
"static",
"ValidationMessage",
"<",
"Origin",
">",
"error",
"(",
"String",
"messageKey",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"ValidationMessage",
".",
"message",
"(",
"Severity",
".",
"ERROR",
",",
"messageKey",
",",
"params",
")",
";",
"}"
] | Creates a ValidationMessage - severity ERROR
@param messageKey message key
@param params message parameters
@return a validation message - severity ERROR | [
"Creates",
"a",
"ValidationMessage",
"-",
"severity",
"ERROR"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java#L255-L257 |
137,889 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java | ValidationMessage.warning | public static ValidationMessage<Origin> warning(String messageKey, Object... params) {
return ValidationMessage.message(Severity.WARNING, messageKey, params);
} | java | public static ValidationMessage<Origin> warning(String messageKey, Object... params) {
return ValidationMessage.message(Severity.WARNING, messageKey, params);
} | [
"public",
"static",
"ValidationMessage",
"<",
"Origin",
">",
"warning",
"(",
"String",
"messageKey",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"ValidationMessage",
".",
"message",
"(",
"Severity",
".",
"WARNING",
",",
"messageKey",
",",
"params",
")",
";",
"}"
] | Creates a ValidationMessage - severity WARNING
@param messageKey message key
@param params message parameters
@return a validation message - severity WARNING | [
"Creates",
"a",
"ValidationMessage",
"-",
"severity",
"WARNING"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java#L266-L268 |
137,890 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java | ValidationMessage.info | public static ValidationMessage<Origin> info(String messageKey, Object... params) {
return ValidationMessage.message(Severity.INFO, messageKey, params);
} | java | public static ValidationMessage<Origin> info(String messageKey, Object... params) {
return ValidationMessage.message(Severity.INFO, messageKey, params);
} | [
"public",
"static",
"ValidationMessage",
"<",
"Origin",
">",
"info",
"(",
"String",
"messageKey",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"ValidationMessage",
".",
"message",
"(",
"Severity",
".",
"INFO",
",",
"messageKey",
",",
"params",
")",
";",
"}"
] | Creates a ValidationMessage - severity INFO
@param messageKey message key
@param params message parameters
@return a validation message - severity INFO | [
"Creates",
"a",
"ValidationMessage",
"-",
"severity",
"INFO"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java#L277-L279 |
137,891 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java | ValidationMessage.writeMessage | public void writeMessage( Writer writer, String targetOrigin ) throws IOException
{
writeMessage( writer, messageFormatter, targetOrigin );
} | java | public void writeMessage( Writer writer, String targetOrigin ) throws IOException
{
writeMessage( writer, messageFormatter, targetOrigin );
} | [
"public",
"void",
"writeMessage",
"(",
"Writer",
"writer",
",",
"String",
"targetOrigin",
")",
"throws",
"IOException",
"{",
"writeMessage",
"(",
"writer",
",",
"messageFormatter",
",",
"targetOrigin",
")",
";",
"}"
] | Writes the message with an additional target origin. | [
"Writes",
"the",
"message",
"with",
"an",
"additional",
"target",
"origin",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/ValidationMessage.java#L377-L380 |
137,892 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/ColumnVector.java | ColumnVector.set | protected void set(double values[])
{
this.nRows = values.length;
this.nCols = 1;
this.values = new double[nRows][1];
for (int r = 0; r < nRows; ++r) {
this.values[r][0] = values[r];
}
} | java | protected void set(double values[])
{
this.nRows = values.length;
this.nCols = 1;
this.values = new double[nRows][1];
for (int r = 0; r < nRows; ++r) {
this.values[r][0] = values[r];
}
} | [
"protected",
"void",
"set",
"(",
"double",
"values",
"[",
"]",
")",
"{",
"this",
".",
"nRows",
"=",
"values",
".",
"length",
";",
"this",
".",
"nCols",
"=",
"1",
";",
"this",
".",
"values",
"=",
"new",
"double",
"[",
"nRows",
"]",
"[",
"1",
"]",
";",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"this",
".",
"values",
"[",
"r",
"]",
"[",
"0",
"]",
"=",
"values",
"[",
"r",
"]",
";",
"}",
"}"
] | Set this column vector from an array of values.
@param values the array of values | [
"Set",
"this",
"column",
"vector",
"from",
"an",
"array",
"of",
"values",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/ColumnVector.java#L85-L94 |
137,893 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java | FeatureMate.getAttributesNames | public List<String> getAttributesNames() {
SimpleFeatureType featureType = feature.getFeatureType();
List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
List<String> attributeNames = new ArrayList<String>();
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
String name = attributeDescriptor.getLocalName();
attributeNames.add(name);
}
return attributeNames;
} | java | public List<String> getAttributesNames() {
SimpleFeatureType featureType = feature.getFeatureType();
List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
List<String> attributeNames = new ArrayList<String>();
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
String name = attributeDescriptor.getLocalName();
attributeNames.add(name);
}
return attributeNames;
} | [
"public",
"List",
"<",
"String",
">",
"getAttributesNames",
"(",
")",
"{",
"SimpleFeatureType",
"featureType",
"=",
"feature",
".",
"getFeatureType",
"(",
")",
";",
"List",
"<",
"AttributeDescriptor",
">",
"attributeDescriptors",
"=",
"featureType",
".",
"getAttributeDescriptors",
"(",
")",
";",
"List",
"<",
"String",
">",
"attributeNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"AttributeDescriptor",
"attributeDescriptor",
":",
"attributeDescriptors",
")",
"{",
"String",
"name",
"=",
"attributeDescriptor",
".",
"getLocalName",
"(",
")",
";",
"attributeNames",
".",
"add",
"(",
"name",
")",
";",
"}",
"return",
"attributeNames",
";",
"}"
] | Getter for the list of attribute names.
@return the list of attribute names. | [
"Getter",
"for",
"the",
"list",
"of",
"attribute",
"names",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java#L98-L108 |
137,894 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java | FeatureMate.getAttribute | @SuppressWarnings("unchecked")
public <T> T getAttribute( String attrName, Class<T> adaptee ) {
if (attrName == null) {
return null;
}
if (adaptee == null) {
adaptee = (Class<T>) String.class;
}
Object attribute = feature.getAttribute(attrName);
if (attribute == null) {
return null;
}
if (attribute instanceof Number) {
Number num = (Number) attribute;
if (adaptee.isAssignableFrom(Double.class)) {
return adaptee.cast(num.doubleValue());
} else if (adaptee.isAssignableFrom(Float.class)) {
return adaptee.cast(num.floatValue());
} else if (adaptee.isAssignableFrom(Integer.class)) {
return adaptee.cast(num.intValue());
} else if (adaptee.isAssignableFrom(Long.class)) {
return adaptee.cast(num.longValue());
} else if (adaptee.isAssignableFrom(String.class)) {
return adaptee.cast(num.toString());
} else {
throw new IllegalArgumentException();
}
} else if (attribute instanceof String) {
if (adaptee.isAssignableFrom(Double.class)) {
try {
Double parsed = Double.parseDouble((String) attribute);
return adaptee.cast(parsed);
} catch (Exception e) {
return null;
}
} else if (adaptee.isAssignableFrom(Float.class)) {
try {
Float parsed = Float.parseFloat((String) attribute);
return adaptee.cast(parsed);
} catch (Exception e) {
return null;
}
} else if (adaptee.isAssignableFrom(Integer.class)) {
try {
Integer parsed = Integer.parseInt((String) attribute);
return adaptee.cast(parsed);
} catch (Exception e) {
return null;
}
} else if (adaptee.isAssignableFrom(String.class)) {
return adaptee.cast(attribute);
} else {
throw new IllegalArgumentException();
}
} else if (attribute instanceof Geometry) {
return null;
} else {
throw new IllegalArgumentException("Can't adapt attribute of type: " + attribute.getClass().getCanonicalName());
}
} | java | @SuppressWarnings("unchecked")
public <T> T getAttribute( String attrName, Class<T> adaptee ) {
if (attrName == null) {
return null;
}
if (adaptee == null) {
adaptee = (Class<T>) String.class;
}
Object attribute = feature.getAttribute(attrName);
if (attribute == null) {
return null;
}
if (attribute instanceof Number) {
Number num = (Number) attribute;
if (adaptee.isAssignableFrom(Double.class)) {
return adaptee.cast(num.doubleValue());
} else if (adaptee.isAssignableFrom(Float.class)) {
return adaptee.cast(num.floatValue());
} else if (adaptee.isAssignableFrom(Integer.class)) {
return adaptee.cast(num.intValue());
} else if (adaptee.isAssignableFrom(Long.class)) {
return adaptee.cast(num.longValue());
} else if (adaptee.isAssignableFrom(String.class)) {
return adaptee.cast(num.toString());
} else {
throw new IllegalArgumentException();
}
} else if (attribute instanceof String) {
if (adaptee.isAssignableFrom(Double.class)) {
try {
Double parsed = Double.parseDouble((String) attribute);
return adaptee.cast(parsed);
} catch (Exception e) {
return null;
}
} else if (adaptee.isAssignableFrom(Float.class)) {
try {
Float parsed = Float.parseFloat((String) attribute);
return adaptee.cast(parsed);
} catch (Exception e) {
return null;
}
} else if (adaptee.isAssignableFrom(Integer.class)) {
try {
Integer parsed = Integer.parseInt((String) attribute);
return adaptee.cast(parsed);
} catch (Exception e) {
return null;
}
} else if (adaptee.isAssignableFrom(String.class)) {
return adaptee.cast(attribute);
} else {
throw new IllegalArgumentException();
}
} else if (attribute instanceof Geometry) {
return null;
} else {
throw new IllegalArgumentException("Can't adapt attribute of type: " + attribute.getClass().getCanonicalName());
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getAttribute",
"(",
"String",
"attrName",
",",
"Class",
"<",
"T",
">",
"adaptee",
")",
"{",
"if",
"(",
"attrName",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"adaptee",
"==",
"null",
")",
"{",
"adaptee",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"String",
".",
"class",
";",
"}",
"Object",
"attribute",
"=",
"feature",
".",
"getAttribute",
"(",
"attrName",
")",
";",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"attribute",
"instanceof",
"Number",
")",
"{",
"Number",
"num",
"=",
"(",
"Number",
")",
"attribute",
";",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Double",
".",
"class",
")",
")",
"{",
"return",
"adaptee",
".",
"cast",
"(",
"num",
".",
"doubleValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Float",
".",
"class",
")",
")",
"{",
"return",
"adaptee",
".",
"cast",
"(",
"num",
".",
"floatValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Integer",
".",
"class",
")",
")",
"{",
"return",
"adaptee",
".",
"cast",
"(",
"num",
".",
"intValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Long",
".",
"class",
")",
")",
"{",
"return",
"adaptee",
".",
"cast",
"(",
"num",
".",
"longValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"String",
".",
"class",
")",
")",
"{",
"return",
"adaptee",
".",
"cast",
"(",
"num",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"attribute",
"instanceof",
"String",
")",
"{",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Double",
".",
"class",
")",
")",
"{",
"try",
"{",
"Double",
"parsed",
"=",
"Double",
".",
"parseDouble",
"(",
"(",
"String",
")",
"attribute",
")",
";",
"return",
"adaptee",
".",
"cast",
"(",
"parsed",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Float",
".",
"class",
")",
")",
"{",
"try",
"{",
"Float",
"parsed",
"=",
"Float",
".",
"parseFloat",
"(",
"(",
"String",
")",
"attribute",
")",
";",
"return",
"adaptee",
".",
"cast",
"(",
"parsed",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"Integer",
".",
"class",
")",
")",
"{",
"try",
"{",
"Integer",
"parsed",
"=",
"Integer",
".",
"parseInt",
"(",
"(",
"String",
")",
"attribute",
")",
";",
"return",
"adaptee",
".",
"cast",
"(",
"parsed",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"adaptee",
".",
"isAssignableFrom",
"(",
"String",
".",
"class",
")",
")",
"{",
"return",
"adaptee",
".",
"cast",
"(",
"attribute",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"attribute",
"instanceof",
"Geometry",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't adapt attribute of type: \"",
"+",
"attribute",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
")",
";",
"}",
"}"
] | Gets an attribute from the feature table, adapting to the supplied class.
@param attrName the attribute name to pick.
@param adaptee the class to adapt to.
@return the adapted value if possible. | [
"Gets",
"an",
"attribute",
"from",
"the",
"feature",
"table",
"adapting",
"to",
"the",
"supplied",
"class",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java#L117-L177 |
137,895 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java | FeatureMate.intersects | public boolean intersects( Geometry geometry, boolean usePrepared ) {
if (!getEnvelope().intersects(geometry.getEnvelopeInternal())) {
return false;
}
if (usePrepared) {
if (preparedGeometry == null) {
preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
}
return preparedGeometry.intersects(geometry);
} else {
return getGeometry().intersects(geometry);
}
} | java | public boolean intersects( Geometry geometry, boolean usePrepared ) {
if (!getEnvelope().intersects(geometry.getEnvelopeInternal())) {
return false;
}
if (usePrepared) {
if (preparedGeometry == null) {
preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
}
return preparedGeometry.intersects(geometry);
} else {
return getGeometry().intersects(geometry);
}
} | [
"public",
"boolean",
"intersects",
"(",
"Geometry",
"geometry",
",",
"boolean",
"usePrepared",
")",
"{",
"if",
"(",
"!",
"getEnvelope",
"(",
")",
".",
"intersects",
"(",
"geometry",
".",
"getEnvelopeInternal",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"usePrepared",
")",
"{",
"if",
"(",
"preparedGeometry",
"==",
"null",
")",
"{",
"preparedGeometry",
"=",
"PreparedGeometryFactory",
".",
"prepare",
"(",
"getGeometry",
"(",
")",
")",
";",
"}",
"return",
"preparedGeometry",
".",
"intersects",
"(",
"geometry",
")",
";",
"}",
"else",
"{",
"return",
"getGeometry",
"(",
")",
".",
"intersects",
"(",
"geometry",
")",
";",
"}",
"}"
] | Check for intersection.
@param geometry the geometry to check against.
@param usePrepared use prepared geometry.
@return true if the geometries intersect. | [
"Check",
"for",
"intersection",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java#L186-L198 |
137,896 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java | FeatureMate.covers | public boolean covers( Geometry geometry, boolean usePrepared ) {
if (!getEnvelope().covers(geometry.getEnvelopeInternal())) {
return false;
}
if (usePrepared) {
if (preparedGeometry == null) {
preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
}
return preparedGeometry.covers(geometry);
} else {
return getGeometry().covers(geometry);
}
} | java | public boolean covers( Geometry geometry, boolean usePrepared ) {
if (!getEnvelope().covers(geometry.getEnvelopeInternal())) {
return false;
}
if (usePrepared) {
if (preparedGeometry == null) {
preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
}
return preparedGeometry.covers(geometry);
} else {
return getGeometry().covers(geometry);
}
} | [
"public",
"boolean",
"covers",
"(",
"Geometry",
"geometry",
",",
"boolean",
"usePrepared",
")",
"{",
"if",
"(",
"!",
"getEnvelope",
"(",
")",
".",
"covers",
"(",
"geometry",
".",
"getEnvelopeInternal",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"usePrepared",
")",
"{",
"if",
"(",
"preparedGeometry",
"==",
"null",
")",
"{",
"preparedGeometry",
"=",
"PreparedGeometryFactory",
".",
"prepare",
"(",
"getGeometry",
"(",
")",
")",
";",
"}",
"return",
"preparedGeometry",
".",
"covers",
"(",
"geometry",
")",
";",
"}",
"else",
"{",
"return",
"getGeometry",
"(",
")",
".",
"covers",
"(",
"geometry",
")",
";",
"}",
"}"
] | Check for cover.
@param geometry the geometry to check against.
@param usePrepared use prepared geometry.
@return true if the current geometries covers the supplied one. | [
"Check",
"for",
"cover",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureMate.java#L207-L219 |
137,897 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/hydrogeomorphology/etp/OmsPenmanEtp.java | OmsPenmanEtp.calcAerodynamic | private double calcAerodynamic( double displacement, double roughness, double Zref, double windSpeed,
double snowWaterEquivalent ) {
double ra = 0.0;
double d_Lower;
double K2;
double Z0_Lower;
double tmp_wind;
// only a value of these quantities are input of the method:
// - wind speed
// - relative humidity
// - Zref
// - ra
tmp_wind = windSpeed;
K2 = VON_K * VON_K;
if (displacement > Zref)
Zref = displacement + Zref + roughness;
/* No OverStory, thus maximum one soil layer */
// for bare soil
// if (iveg == Nveg) {
// Z0_Lower = Z0_SOIL; //Z0_SOIL is the soil roughness
// d_Lower = 0;
// } else { //with vegetation
Z0_Lower = roughness;
d_Lower = displacement;
// } if cycle is deleted thinking that bare soil is a vegetation type with roughness and
// displacement
/* With snow on the surface */
if (snowWaterEquivalent > 0) {
windSpeed = Math.log((2. + Z0_SNOW) / Z0_SNOW) / Math.log(Zref / Z0_SNOW);
ra = Math.log((2. + Z0_SNOW) / Z0_SNOW) * Math.log(Zref / Z0_SNOW) / K2;
} else {
/* No snow on the surface*/
windSpeed = Math.log((2. + Z0_Lower) / Z0_Lower) / Math.log((Zref - d_Lower) / Z0_Lower);
ra = Math.log((2. + (1.0 / 0.63 - 1.0) * d_Lower) / Z0_Lower)
* Math.log((2. + (1.0 / 0.63 - 1.0) * d_Lower) / (0.1 * Z0_Lower)) / K2;
}
if (tmp_wind > 0.) {
windSpeed *= tmp_wind;
ra /= tmp_wind;
} else {
windSpeed *= tmp_wind;
ra = HUGE_RESIST;
pm.message("Aerodinamic resistance is set to the maximum value!");
}
return ra;
} | java | private double calcAerodynamic( double displacement, double roughness, double Zref, double windSpeed,
double snowWaterEquivalent ) {
double ra = 0.0;
double d_Lower;
double K2;
double Z0_Lower;
double tmp_wind;
// only a value of these quantities are input of the method:
// - wind speed
// - relative humidity
// - Zref
// - ra
tmp_wind = windSpeed;
K2 = VON_K * VON_K;
if (displacement > Zref)
Zref = displacement + Zref + roughness;
/* No OverStory, thus maximum one soil layer */
// for bare soil
// if (iveg == Nveg) {
// Z0_Lower = Z0_SOIL; //Z0_SOIL is the soil roughness
// d_Lower = 0;
// } else { //with vegetation
Z0_Lower = roughness;
d_Lower = displacement;
// } if cycle is deleted thinking that bare soil is a vegetation type with roughness and
// displacement
/* With snow on the surface */
if (snowWaterEquivalent > 0) {
windSpeed = Math.log((2. + Z0_SNOW) / Z0_SNOW) / Math.log(Zref / Z0_SNOW);
ra = Math.log((2. + Z0_SNOW) / Z0_SNOW) * Math.log(Zref / Z0_SNOW) / K2;
} else {
/* No snow on the surface*/
windSpeed = Math.log((2. + Z0_Lower) / Z0_Lower) / Math.log((Zref - d_Lower) / Z0_Lower);
ra = Math.log((2. + (1.0 / 0.63 - 1.0) * d_Lower) / Z0_Lower)
* Math.log((2. + (1.0 / 0.63 - 1.0) * d_Lower) / (0.1 * Z0_Lower)) / K2;
}
if (tmp_wind > 0.) {
windSpeed *= tmp_wind;
ra /= tmp_wind;
} else {
windSpeed *= tmp_wind;
ra = HUGE_RESIST;
pm.message("Aerodinamic resistance is set to the maximum value!");
}
return ra;
} | [
"private",
"double",
"calcAerodynamic",
"(",
"double",
"displacement",
",",
"double",
"roughness",
",",
"double",
"Zref",
",",
"double",
"windSpeed",
",",
"double",
"snowWaterEquivalent",
")",
"{",
"double",
"ra",
"=",
"0.0",
";",
"double",
"d_Lower",
";",
"double",
"K2",
";",
"double",
"Z0_Lower",
";",
"double",
"tmp_wind",
";",
"// only a value of these quantities are input of the method:",
"// - wind speed",
"// - relative humidity",
"// - Zref",
"// - ra",
"tmp_wind",
"=",
"windSpeed",
";",
"K2",
"=",
"VON_K",
"*",
"VON_K",
";",
"if",
"(",
"displacement",
">",
"Zref",
")",
"Zref",
"=",
"displacement",
"+",
"Zref",
"+",
"roughness",
";",
"/* No OverStory, thus maximum one soil layer */",
"// for bare soil",
"// if (iveg == Nveg) {",
"// Z0_Lower = Z0_SOIL; //Z0_SOIL is the soil roughness",
"// d_Lower = 0;",
"// } else { //with vegetation",
"Z0_Lower",
"=",
"roughness",
";",
"d_Lower",
"=",
"displacement",
";",
"// } if cycle is deleted thinking that bare soil is a vegetation type with roughness and",
"// displacement",
"/* With snow on the surface */",
"if",
"(",
"snowWaterEquivalent",
">",
"0",
")",
"{",
"windSpeed",
"=",
"Math",
".",
"log",
"(",
"(",
"2.",
"+",
"Z0_SNOW",
")",
"/",
"Z0_SNOW",
")",
"/",
"Math",
".",
"log",
"(",
"Zref",
"/",
"Z0_SNOW",
")",
";",
"ra",
"=",
"Math",
".",
"log",
"(",
"(",
"2.",
"+",
"Z0_SNOW",
")",
"/",
"Z0_SNOW",
")",
"*",
"Math",
".",
"log",
"(",
"Zref",
"/",
"Z0_SNOW",
")",
"/",
"K2",
";",
"}",
"else",
"{",
"/* No snow on the surface*/",
"windSpeed",
"=",
"Math",
".",
"log",
"(",
"(",
"2.",
"+",
"Z0_Lower",
")",
"/",
"Z0_Lower",
")",
"/",
"Math",
".",
"log",
"(",
"(",
"Zref",
"-",
"d_Lower",
")",
"/",
"Z0_Lower",
")",
";",
"ra",
"=",
"Math",
".",
"log",
"(",
"(",
"2.",
"+",
"(",
"1.0",
"/",
"0.63",
"-",
"1.0",
")",
"*",
"d_Lower",
")",
"/",
"Z0_Lower",
")",
"*",
"Math",
".",
"log",
"(",
"(",
"2.",
"+",
"(",
"1.0",
"/",
"0.63",
"-",
"1.0",
")",
"*",
"d_Lower",
")",
"/",
"(",
"0.1",
"*",
"Z0_Lower",
")",
")",
"/",
"K2",
";",
"}",
"if",
"(",
"tmp_wind",
">",
"0.",
")",
"{",
"windSpeed",
"*=",
"tmp_wind",
";",
"ra",
"/=",
"tmp_wind",
";",
"}",
"else",
"{",
"windSpeed",
"*=",
"tmp_wind",
";",
"ra",
"=",
"HUGE_RESIST",
";",
"pm",
".",
"message",
"(",
"\"Aerodinamic resistance is set to the maximum value!\"",
")",
";",
"}",
"return",
"ra",
";",
"}"
] | Calculates the aerodynamic resistance for the vegetation layer.
<p>Calculates the aerodynamic resistance for the vegetation layer, and
the wind 2m above the layer boundary.</p>
<p>The values are normalized based on a reference height wind
speed, Uref, of 1 m/s. To get wind speeds and aerodynamic resistances for
other values of Uref, you need to multiply the here calculated wind
speeds by Uref and divide the here calculated aerodynamic resistances
by Uref</p>
@param displacement
@param roughness
@param Zref reference height for windspeed.
@param windSpeed
@return the aerodynamic resistance for the vegetation layer. | [
"Calculates",
"the",
"aerodynamic",
"resistance",
"for",
"the",
"vegetation",
"layer",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/hydrogeomorphology/etp/OmsPenmanEtp.java#L307-L360 |
137,898 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/spatialite/SpatialiteTableNames.java | SpatialiteTableNames.getTablesSorted | public static LinkedHashMap<String, List<String>> getTablesSorted( List<String> allTableNames, boolean doSort ) {
LinkedHashMap<String, List<String>> tablesMap = new LinkedHashMap<>();
tablesMap.put(USERDATA, new ArrayList<String>());
tablesMap.put(STYLE, new ArrayList<String>());
tablesMap.put(METADATA, new ArrayList<String>());
tablesMap.put(INTERNALDATA, new ArrayList<String>());
tablesMap.put(SPATIALINDEX, new ArrayList<String>());
for( String tableName : allTableNames ) {
tableName = tableName.toLowerCase();
if (spatialindexTables.contains(tableName) || tableName.startsWith(startsWithIndexTables)) {
List<String> list = tablesMap.get(SPATIALINDEX);
list.add(tableName);
continue;
}
if (tableName.startsWith(startsWithStyleTables)) {
List<String> list = tablesMap.get(STYLE);
list.add(tableName);
continue;
}
if (metadataTables.contains(tableName)) {
List<String> list = tablesMap.get(METADATA);
list.add(tableName);
continue;
}
if (internalDataTables.contains(tableName)) {
List<String> list = tablesMap.get(INTERNALDATA);
list.add(tableName);
continue;
}
List<String> list = tablesMap.get(USERDATA);
list.add(tableName);
}
if (doSort) {
for( List<String> values : tablesMap.values() ) {
Collections.sort(values);
}
}
return tablesMap;
} | java | public static LinkedHashMap<String, List<String>> getTablesSorted( List<String> allTableNames, boolean doSort ) {
LinkedHashMap<String, List<String>> tablesMap = new LinkedHashMap<>();
tablesMap.put(USERDATA, new ArrayList<String>());
tablesMap.put(STYLE, new ArrayList<String>());
tablesMap.put(METADATA, new ArrayList<String>());
tablesMap.put(INTERNALDATA, new ArrayList<String>());
tablesMap.put(SPATIALINDEX, new ArrayList<String>());
for( String tableName : allTableNames ) {
tableName = tableName.toLowerCase();
if (spatialindexTables.contains(tableName) || tableName.startsWith(startsWithIndexTables)) {
List<String> list = tablesMap.get(SPATIALINDEX);
list.add(tableName);
continue;
}
if (tableName.startsWith(startsWithStyleTables)) {
List<String> list = tablesMap.get(STYLE);
list.add(tableName);
continue;
}
if (metadataTables.contains(tableName)) {
List<String> list = tablesMap.get(METADATA);
list.add(tableName);
continue;
}
if (internalDataTables.contains(tableName)) {
List<String> list = tablesMap.get(INTERNALDATA);
list.add(tableName);
continue;
}
List<String> list = tablesMap.get(USERDATA);
list.add(tableName);
}
if (doSort) {
for( List<String> values : tablesMap.values() ) {
Collections.sort(values);
}
}
return tablesMap;
} | [
"public",
"static",
"LinkedHashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"getTablesSorted",
"(",
"List",
"<",
"String",
">",
"allTableNames",
",",
"boolean",
"doSort",
")",
"{",
"LinkedHashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"tablesMap",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"tablesMap",
".",
"put",
"(",
"USERDATA",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"tablesMap",
".",
"put",
"(",
"STYLE",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"tablesMap",
".",
"put",
"(",
"METADATA",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"tablesMap",
".",
"put",
"(",
"INTERNALDATA",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"tablesMap",
".",
"put",
"(",
"SPATIALINDEX",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"for",
"(",
"String",
"tableName",
":",
"allTableNames",
")",
"{",
"tableName",
"=",
"tableName",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"spatialindexTables",
".",
"contains",
"(",
"tableName",
")",
"||",
"tableName",
".",
"startsWith",
"(",
"startsWithIndexTables",
")",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"tablesMap",
".",
"get",
"(",
"SPATIALINDEX",
")",
";",
"list",
".",
"add",
"(",
"tableName",
")",
";",
"continue",
";",
"}",
"if",
"(",
"tableName",
".",
"startsWith",
"(",
"startsWithStyleTables",
")",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"tablesMap",
".",
"get",
"(",
"STYLE",
")",
";",
"list",
".",
"add",
"(",
"tableName",
")",
";",
"continue",
";",
"}",
"if",
"(",
"metadataTables",
".",
"contains",
"(",
"tableName",
")",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"tablesMap",
".",
"get",
"(",
"METADATA",
")",
";",
"list",
".",
"add",
"(",
"tableName",
")",
";",
"continue",
";",
"}",
"if",
"(",
"internalDataTables",
".",
"contains",
"(",
"tableName",
")",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"tablesMap",
".",
"get",
"(",
"INTERNALDATA",
")",
";",
"list",
".",
"add",
"(",
"tableName",
")",
";",
"continue",
";",
"}",
"List",
"<",
"String",
">",
"list",
"=",
"tablesMap",
".",
"get",
"(",
"USERDATA",
")",
";",
"list",
".",
"add",
"(",
"tableName",
")",
";",
"}",
"if",
"(",
"doSort",
")",
"{",
"for",
"(",
"List",
"<",
"String",
">",
"values",
":",
"tablesMap",
".",
"values",
"(",
")",
")",
"{",
"Collections",
".",
"sort",
"(",
"values",
")",
";",
"}",
"}",
"return",
"tablesMap",
";",
"}"
] | Sorts all supplied table names by type.
<p>
Supported types are:
<ul>
<li>{@value ISpatialTableNames#INTERNALDATA} </li>
<li>{@value ISpatialTableNames#METADATA} </li>
<li>{@value ISpatialTableNames#SPATIALINDEX} </li>
<li>{@value ISpatialTableNames#STYLE} </li>
<li>{@value ISpatialTableNames#USERDATA} </li>
</ul>
@param allTableNames list of all tables.
@param doSort if <code>true</code>, table names are alphabetically sorted.
@return the {@link LinkedHashMap}. | [
"Sorts",
"all",
"supplied",
"table",
"names",
"by",
"type",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/spatialite/SpatialiteTableNames.java#L102-L143 |
137,899 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoBookmarks.java | DaoBookmarks.createTables | public static void createTables(Connection connection) throws IOException, SQLException {
StringBuilder sB = new StringBuilder();
sB.append("CREATE TABLE ");
sB.append(TABLE_BOOKMARKS);
sB.append(" (");
sB.append(COLUMN_ID);
sB.append(" INTEGER PRIMARY KEY, ");
sB.append(COLUMN_LON).append(" REAL NOT NULL, ");
sB.append(COLUMN_LAT).append(" REAL NOT NULL,");
sB.append(COLUMN_ZOOM).append(" REAL NOT NULL,");
sB.append(COLUMN_NORTHBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_SOUTHBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_WESTBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_EASTBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_TEXT).append(" TEXT NOT NULL ");
sB.append(");");
String CREATE_TABLE_BOOKMARKS = sB.toString();
sB = new StringBuilder();
sB.append("CREATE INDEX bookmarks_x_by_y_idx ON ");
sB.append(TABLE_BOOKMARKS);
sB.append(" ( ");
sB.append(COLUMN_LON);
sB.append(", ");
sB.append(COLUMN_LAT);
sB.append(" );");
String CREATE_INDEX_BOOKMARKS_X_BY_Y = sB.toString();
try (Statement statement = connection.createStatement()) {
statement.setQueryTimeout(30); // set timeout to 30 sec.
statement.executeUpdate(CREATE_TABLE_BOOKMARKS);
statement.executeUpdate(CREATE_INDEX_BOOKMARKS_X_BY_Y);
} catch (Exception e) {
throw new IOException(e.getLocalizedMessage());
}
} | java | public static void createTables(Connection connection) throws IOException, SQLException {
StringBuilder sB = new StringBuilder();
sB.append("CREATE TABLE ");
sB.append(TABLE_BOOKMARKS);
sB.append(" (");
sB.append(COLUMN_ID);
sB.append(" INTEGER PRIMARY KEY, ");
sB.append(COLUMN_LON).append(" REAL NOT NULL, ");
sB.append(COLUMN_LAT).append(" REAL NOT NULL,");
sB.append(COLUMN_ZOOM).append(" REAL NOT NULL,");
sB.append(COLUMN_NORTHBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_SOUTHBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_WESTBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_EASTBOUND).append(" REAL NOT NULL,");
sB.append(COLUMN_TEXT).append(" TEXT NOT NULL ");
sB.append(");");
String CREATE_TABLE_BOOKMARKS = sB.toString();
sB = new StringBuilder();
sB.append("CREATE INDEX bookmarks_x_by_y_idx ON ");
sB.append(TABLE_BOOKMARKS);
sB.append(" ( ");
sB.append(COLUMN_LON);
sB.append(", ");
sB.append(COLUMN_LAT);
sB.append(" );");
String CREATE_INDEX_BOOKMARKS_X_BY_Y = sB.toString();
try (Statement statement = connection.createStatement()) {
statement.setQueryTimeout(30); // set timeout to 30 sec.
statement.executeUpdate(CREATE_TABLE_BOOKMARKS);
statement.executeUpdate(CREATE_INDEX_BOOKMARKS_X_BY_Y);
} catch (Exception e) {
throw new IOException(e.getLocalizedMessage());
}
} | [
"public",
"static",
"void",
"createTables",
"(",
"Connection",
"connection",
")",
"throws",
"IOException",
",",
"SQLException",
"{",
"StringBuilder",
"sB",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sB",
".",
"append",
"(",
"\"CREATE TABLE \"",
")",
";",
"sB",
".",
"append",
"(",
"TABLE_BOOKMARKS",
")",
";",
"sB",
".",
"append",
"(",
"\" (\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_ID",
")",
";",
"sB",
".",
"append",
"(",
"\" INTEGER PRIMARY KEY, \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_LON",
")",
".",
"append",
"(",
"\" REAL NOT NULL, \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_LAT",
")",
".",
"append",
"(",
"\" REAL NOT NULL,\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_ZOOM",
")",
".",
"append",
"(",
"\" REAL NOT NULL,\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_NORTHBOUND",
")",
".",
"append",
"(",
"\" REAL NOT NULL,\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_SOUTHBOUND",
")",
".",
"append",
"(",
"\" REAL NOT NULL,\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_WESTBOUND",
")",
".",
"append",
"(",
"\" REAL NOT NULL,\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_EASTBOUND",
")",
".",
"append",
"(",
"\" REAL NOT NULL,\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_TEXT",
")",
".",
"append",
"(",
"\" TEXT NOT NULL \"",
")",
";",
"sB",
".",
"append",
"(",
"\");\"",
")",
";",
"String",
"CREATE_TABLE_BOOKMARKS",
"=",
"sB",
".",
"toString",
"(",
")",
";",
"sB",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sB",
".",
"append",
"(",
"\"CREATE INDEX bookmarks_x_by_y_idx ON \"",
")",
";",
"sB",
".",
"append",
"(",
"TABLE_BOOKMARKS",
")",
";",
"sB",
".",
"append",
"(",
"\" ( \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_LON",
")",
";",
"sB",
".",
"append",
"(",
"\", \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_LAT",
")",
";",
"sB",
".",
"append",
"(",
"\" );\"",
")",
";",
"String",
"CREATE_INDEX_BOOKMARKS_X_BY_Y",
"=",
"sB",
".",
"toString",
"(",
")",
";",
"try",
"(",
"Statement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
")",
"{",
"statement",
".",
"setQueryTimeout",
"(",
"30",
")",
";",
"// set timeout to 30 sec.",
"statement",
".",
"executeUpdate",
"(",
"CREATE_TABLE_BOOKMARKS",
")",
";",
"statement",
".",
"executeUpdate",
"(",
"CREATE_INDEX_BOOKMARKS_X_BY_Y",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"}",
"}"
] | Create bookmarks tables.
@throws IOException if something goes wrong. | [
"Create",
"bookmarks",
"tables",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoBookmarks.java#L55-L91 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.