_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q175100 | GMLFeatureWriter.writeLine | test | private String writeLine(Line line) {
String xml = "";
xml += "<gml:LineString><gml:posList>";
for (Point point: line.getPoints()) {
xml += point.getX() + " " + point.getY() + " ";
}
xml += "</gml:posList></gml:LineString>";
return xml;
} | java | {
"resource": ""
} |
q175101 | GMLFeatureWriter.writePolygon | test | private String writePolygon(Polygon poly) {
String xml = "";
xml += "<gml:Polygon>";
Polygon polygon = poly;
// while (polygon != null) {
if (!polygon.getInteriorRing()) {
xml += "<gml:exterior><gml:LinearRing><gml:posList>";
for (Point point : polygon.getPoints()) {
xml += point.getX() + " " + point.getY() + " ";
}
xml += "</gml:posList></gml:LinearRing></gml:exterior>";
}
else {
xml += "<gml:interior><gml:LinearRing><gml:posList>";
for (Point point : polygon.getPoints()) {
xml += point.getX() + " " + point.getY() + " ";
}
xml += "</gml:posList></gml:LinearRing></gml:interior>";
}
// polygon = polygon.getNext();
// }
xml += "</gml:Polygon>";
return xml;
} | java | {
"resource": ""
} |
q175102 | DOM4Parser.pull | test | protected String
pull(Node n, String name)
{
NamedNodeMap map = n.getAttributes();
Node attr = map.getNamedItem(name);
if(attr == null)
return null;
return attr.getNodeValue();
} | java | {
"resource": ""
} |
q175103 | DOM4Parser.getSubnodes | test | List<Node>
getSubnodes(Node parent)
{
List<Node> subs = new ArrayList<>();
NodeList nodes = parent.getChildNodes();
for(int i = 0; i < nodes.getLength(); i++) {
Node n = nodes.item(i);
if(n.getNodeType() == Node.ELEMENT_NODE)
subs.add(n);
}
return subs;
} | java | {
"resource": ""
} |
q175104 | DOM4Parser.parseresponse | test | protected void
parseresponse(Node root)
throws ParseException
{
String elemname = root.getNodeName();
if(elemname.equalsIgnoreCase("Error")) {
parseerror(root);
} else if(elemname.equalsIgnoreCase("Dataset")) {
parsedataset(root);
} else
throw new ParseException("Unexpected response root: " + elemname);
} | java | {
"resource": ""
} |
q175105 | DOM4Parser.passReserved | test | protected void
passReserved(Node node, DapNode dap)
throws ParseException
{
try {
NamedNodeMap attrs = node.getAttributes();
for(int i = 0; i < attrs.getLength(); i++) {
Node n = attrs.item(i);
String key = n.getNodeName();
String value = n.getNodeValue();
if(isReserved(key))
dap.addXMLAttribute(key, value);
}
} catch (DapException de) {
throw new ParseException(de);
}
} | java | {
"resource": ""
} |
q175106 | CFSimpleGeometryHelper.getSubsetString | test | public static String getSubsetString(Variable var, int beginInd, int endInd, int id){
if(var == null) return null;
String subStr = "";
List<Dimension> dimList = var.getDimensions();
// Enforce two dimension arrays
if(dimList.size() > 2 || dimList.size() < 1) {
return null;
}
for(int i = 0; i < dimList.size(); i++) {
Dimension dim = dimList.get(i);
if(dim == null) continue;
// If not CF Time then select only that ID
if(!CF.TIME.equalsIgnoreCase(dim.getShortName()) && !CF.TIME.equalsIgnoreCase(dim.getFullNameEscaped())) {
subStr += id;
}
// Otherwise subset based on time
else {
if(beginInd < 0 || endInd < 0) subStr += ":";
else subStr += (beginInd + ":" + endInd);
}
if(i < dimList.size() - 1) {
subStr += ",";
}
}
return subStr;
} | java | {
"resource": ""
} |
q175107 | ArrayStructureMA.factoryMA | test | static public ArrayStructureMA factoryMA(ArrayStructure from) throws IOException {
if (from instanceof ArrayStructureMA)
return (ArrayStructureMA) from;
// To create an ArrayStructureMA that we can iterate over later, we need to know the shape of "from".
if (from.getSize() > 0) {
ArrayStructureMA to = new ArrayStructureMA(new StructureMembers(from.getStructureMembers()), from.getShape());
for (StructureMembers.Member m : from.getMembers()) {
to.setMemberArray(m.getName(), from.extractMemberArray(m));
}
return to;
}
// from.getSize() <= 0. This usually means that "from" is an ArraySequence, and that we won't know its size until
// we iterate over it. extractMemberArray() will do that iteration for us, and then we can use the size of the
// array it returns to determine the shape of "from".
int numRecords = -1;
Map<String, Array> memberArrayMap = new LinkedHashMap<>();
for (StructureMembers.Member m : from.getMembers()) {
Array array = from.extractMemberArray(m);
assert array.getSize() > 0 : "array's size should have been computed in extractMemberArray().";
int firstDimLen = array.getShape()[0];
if (numRecords == -1) {
numRecords = firstDimLen;
} else {
assert numRecords == firstDimLen : String.format("Expected all structure members to have the same first" +
"dimension length, but %d != %d.", numRecords, firstDimLen);
}
memberArrayMap.put(m.getName(), array);
}
int[] shape;
if (numRecords == -1) {
shape = new int[] { 0 }; // "from" really was empty.
} else {
shape = new int[] { numRecords };
}
ArrayStructureMA to = new ArrayStructureMA(new StructureMembers(from.getStructureMembers()), shape);
for (Map.Entry<String, Array> entry : memberArrayMap.entrySet()) {
to.setMemberArray(entry.getKey(), entry.getValue());
}
return to;
} | java | {
"resource": ""
} |
q175108 | ArrayStructureMA.setMemberArray | test | public void setMemberArray( String memberName, Array data) {
StructureMembers.Member m = members.findMember( memberName);
m.setDataArray( data);
} | java | {
"resource": ""
} |
q175109 | ArrayStructureMA.factoryMA | test | static public ArrayStructureMA factoryMA(Structure from, int[] shape) throws IOException {
StructureMembers sm = from.makeStructureMembers();
for (Variable v : from.getVariables()) {
Array data;
if (v instanceof Sequence) {
data = Array.factory(DataType.SEQUENCE, shape); // an array sequence - one for each parent element
//Structure s = (Structure) v;
//StructureMembers smn = s.makeStructureMembers();
// data = new ArraySequenceNested(smn, (int) Index.computeSize(v.getShapeAll())); // ??
} else if (v instanceof Structure)
data = ArrayStructureMA.factoryMA((Structure) v, combine(shape, v.getShape()));
else
data = Array.factory(v.getDataType(), combine(shape, v.getShape()));
StructureMembers.Member m = sm.findMember(v.getShortName());
m.setDataArray(data);
}
return new ArrayStructureMA(sm, shape);
} | java | {
"resource": ""
} |
q175110 | SimpleGeometryReader.getGeometryType | test | public GeometryType getGeometryType(String name) {
Variable geometryVar = ds.findVariable(name);
if(geometryVar == null) return null;
// CFConvention
if(ds.findGlobalAttribute(CF.CONVENTIONS) != null)
if(ucar.nc2.dataset.conv.CF1Convention.getVersion(ds.findGlobalAttribute(CF.CONVENTIONS).getStringValue()) >= 8)
{
Attribute geometryTypeAttr = null;
String geometry_type = null;
geometryTypeAttr = geometryVar.findAttribute(CF.GEOMETRY_TYPE);
if(geometryTypeAttr == null) return null;
geometry_type = geometryTypeAttr.getStringValue();
switch(geometry_type)
{
case CF.POLYGON:
return GeometryType.POLYGON;
case CF.LINE:
return GeometryType.LINE;
case CF.POINT:
return GeometryType.POINT;
default:
return null;
}
}
return null;
} | java | {
"resource": ""
} |
q175111 | StandardStationCollectionImpl.makeStation | test | public StationTimeSeriesFeature makeStation(StructureData stationData, int recnum) {
StationFeature s = ft.makeStation(stationData);
if (s == null) return null;
return new StandardStationFeatureImpl(s, timeUnit, stationData, recnum);
} | java | {
"resource": ""
} |
q175112 | CECompiler.compileAST | test | protected void
compileAST(CEAST ast)
throws DapException
{
switch (ast.sort) {
case CONSTRAINT:
for(CEAST clause : ast.clauses) {
compileAST(clause);
}
// invoke semantic checks
this.ce.expand();
this.ce.finish();
break;
case PROJECTION:
scopestack.clear();
compileAST(ast.tree);
break;
case SEGMENT:
compilesegment(ast);
break;
case SELECTION:
scopestack.clear();
compileselection(ast);
break;
case DEFINE:
dimredef(ast);
break;
default:
assert false : "uknown CEAST node type";
}
} | java | {
"resource": ""
} |
q175113 | CECompiler.compilefilter | test | public void
compilefilter(DapVariable var, DapSequence seq, CEAST expr)
throws DapException
{
if(expr == null)
return;
if(expr.sort == CEAST.Sort.SEGMENT) {
// This must be a simple segment and it must appear in seq
if(expr.subnodes != null)
throw new DapException("compilefilter: Non-simple segment:" + expr.name);
// Look for the name in the top-level field of seq
DapVariable field = seq.findByName(expr.name);
if(field == null)
throw new DapException("compilefilter: Unknown filter variable:" + expr.name);
expr.field = field;
} else if(expr.sort == CEAST.Sort.EXPR) {
if(expr.lhs != null)
compilefilter(var, seq, expr.lhs);
if(expr.rhs != null)
compilefilter(var, seq, expr.rhs);
// If both lhs and rhs are non-null,
// canonicalize any comparison so that it is var op const
if(expr.lhs != null && expr.rhs != null) {
boolean leftvar = (expr.lhs.sort == CEAST.Sort.SEGMENT);
boolean rightvar = (expr.rhs.sort == CEAST.Sort.SEGMENT);
if(rightvar && !leftvar) { // swap operands
CEAST tmp = expr.lhs;
expr.lhs = expr.rhs;
expr.rhs = tmp;
// fix operator
switch (expr.op) {
case LT: //x<y -> y>x
expr.op = CEAST.Operator.GT;
break;
case LE: //x<=y -> y>=x
expr.op = CEAST.Operator.GE;
break;
case GT: //x>y -> y<x
expr.op = CEAST.Operator.LT;
break;
case GE: //x>=y -> y<=x
expr.op = CEAST.Operator.LE;
break;
default:
break; // leave as is
}
}
}
} else if(expr.sort == CEAST.Sort.CONSTANT) {
return;
} else
throw new DapException("compilefilter: Unexpected node type:" + expr.sort);
} | java | {
"resource": ""
} |
q175114 | CECompiler.dimredef | test | protected void
dimredef(CEAST node)
throws DapException
{
DapDimension dim = (DapDimension) dataset.findByFQN(node.name, DapSort.DIMENSION);
if(dim == null)
throw new DapException("Constraint dim redef: no dimension name: " + node.name);
Slice slice = node.slice;
slice.finish();
ce.addRedef(dim, slice);
} | java | {
"resource": ""
} |
q175115 | ArrayObject.createView | test | protected Array createView( Index index) {
return ArrayObject.factory( dataType, elementType, isVlen, index, storage);
} | java | {
"resource": ""
} |
q175116 | LatLonRect.containedIn | test | public boolean containedIn(LatLonRect b) {
return (b.getWidth() >= width) && b.contains(upperRight)
&& b.contains(lowerLeft);
} | java | {
"resource": ""
} |
q175117 | LatLonRect.extend | test | public void extend(LatLonPoint p) {
if (contains(p))
return;
double lat = p.getLatitude();
double lon = p.getLongitude();
// lat is easy to deal with
if (lat > upperRight.getLatitude()) {
upperRight.setLatitude(lat);
}
if (lat < lowerLeft.getLatitude()) {
lowerLeft.setLatitude(lat);
}
// lon is uglier
if (allLongitude) {
// do nothing
} else if (crossDateline) {
// bounding box crosses the +/- 180 seam
double d1 = lon - upperRight.getLongitude();
double d2 = lowerLeft.getLongitude() - lon;
if ((d1 > 0.0) && (d2 > 0.0)) { // needed ?
if (d1 > d2) {
lowerLeft.setLongitude(lon);
} else {
upperRight.setLongitude(lon);
}
}
} else {
// normal case
if (lon > upperRight.getLongitude()) {
if (lon - upperRight.getLongitude() > lowerLeft.getLongitude() - lon + 360) {
crossDateline = true;
lowerLeft.setLongitude(lon);
} else {
upperRight.setLongitude(lon);
}
} else if (lon < lowerLeft.getLongitude()) {
if (lowerLeft.getLongitude() - lon > lon + 360.0 - upperRight.getLongitude()) {
crossDateline = true;
upperRight.setLongitude(lon);
} else {
lowerLeft.setLongitude(lon);
}
}
}
// recalc delta, center
width = upperRight.getLongitude() - lowerLeft.getLongitude();
lon0 = (upperRight.getLongitude() + lowerLeft.getLongitude()) / 2;
if (crossDateline) {
width += 360;
lon0 -= 180;
}
this.allLongitude = this.allLongitude || (this.width >= 360.0);
} | java | {
"resource": ""
} |
q175118 | LatLonRect.extend | test | public void extend(LatLonRect r) {
Preconditions.checkNotNull(r);
// lat is easy
double latMin = r.getLatMin();
double latMax = r.getLatMax();
if (latMax > upperRight.getLatitude()) {
upperRight.setLatitude(latMax);
}
if (latMin < lowerLeft.getLatitude()) {
lowerLeft.setLatitude(latMin);
}
// lon is uglier
if (allLongitude)
return;
// everything is reletive to current LonMin
double lonMin = getLonMin();
double lonMax = getLonMax();
double nlonMin = LatLonPointImpl.lonNormal( r.getLonMin(), lonMin);
double nlonMax = nlonMin + r.getWidth();
lonMin = Math.min(lonMin, nlonMin);
lonMax = Math.max(lonMax, nlonMax);
width = lonMax - lonMin;
allLongitude = width >= 360.0;
if (allLongitude) {
width = 360.0;
lonMin = -180.0;
} else {
lonMin = LatLonPointImpl.lonNormal(lonMin);
}
lowerLeft.setLongitude(lonMin);
upperRight.setLongitude(lonMin+width);
lon0 = lonMin+width/2;
crossDateline = lowerLeft.getLongitude() > upperRight.getLongitude();
} | java | {
"resource": ""
} |
q175119 | LatLonRect.intersect | test | public LatLonRect intersect(LatLonRect clip) {
double latMin = Math.max(getLatMin(), clip.getLatMin());
double latMax = Math.min(getLatMax(), clip.getLatMax());
double deltaLat = latMax - latMin;
if (deltaLat < 0)
return null;
// lon as always is a pain : if not intersection, try +/- 360
double lon1min = getLonMin();
double lon1max = getLonMax();
double lon2min = clip.getLonMin();
double lon2max = clip.getLonMax();
if (!intersect(lon1min, lon1max, lon2min, lon2max)) {
lon2min = clip.getLonMin() + 360;
lon2max = clip.getLonMax() + 360;
if (!intersect(lon1min, lon1max, lon2min, lon2max)) {
lon2min = clip.getLonMin() - 360;
lon2max = clip.getLonMax() - 360;
}
}
// we did our best to find an intersection
double lonMin = Math.max(lon1min, lon2min);
double lonMax = Math.min(lon1max, lon2max);
double deltaLon = lonMax - lonMin;
if (deltaLon < 0)
return null;
return new LatLonRect(new LatLonPointImpl(latMin, lonMin), deltaLat, deltaLon);
} | java | {
"resource": ""
} |
q175120 | MAMath.add | test | public static Array add(Array a, Array b) throws IllegalArgumentException {
Array result = Array.factory(a.getDataType(), a.getShape());
if (a.getElementType() == double.class) {
addDouble(result, a, b);
} else
throw new UnsupportedOperationException();
return result;
} | java | {
"resource": ""
} |
q175121 | MAMath.conformable | test | public static boolean conformable(Array a, Array b) {
return conformable(a.getShape(), b.getShape());
} | java | {
"resource": ""
} |
q175122 | MAMath.conformable | test | public static boolean conformable(int[] shapeA, int[] shapeB) {
if (reducedRank(shapeA) != reducedRank(shapeB))
return false;
int rankB = shapeB.length;
int dimB = 0;
for (int aShapeA : shapeA) {
//System.out.println(dimA + " "+ dimB);
//skip length 1 dimensions
if (aShapeA == 1)
continue;
while (dimB < rankB)
if (shapeB[dimB] == 1) dimB++;
else break;
// test same shape (NB dimB cant be > rankB due to first test)
if (aShapeA != shapeB[dimB])
return false;
dimB++;
}
return true;
} | java | {
"resource": ""
} |
q175123 | MAMath.convert | test | public static Array convert( Array org, DataType wantType) {
if (org == null) return null;
Class wantClass = wantType.getPrimitiveClassType();
if (org.getElementType().equals(wantClass))
return org;
Array result = Array.factory(wantType, org.getShape());
copy(wantType, org.getIndexIterator(), result.getIndexIterator());
return result;
} | java | {
"resource": ""
} |
q175124 | MAMath.copy | test | public static void copy(Array result, Array a) throws IllegalArgumentException {
Class classType = a.getElementType();
if (classType == double.class) {
copyDouble(result, a);
} else if (classType == float.class) {
copyFloat(result, a);
} else if (classType == long.class) {
copyLong(result, a);
} else if (classType == int.class) {
copyInt(result, a);
} else if (classType == short.class) {
copyShort(result, a);
} else if (classType == char.class) {
copyChar(result, a);
} else if (classType == byte.class) {
copyByte(result, a);
} else if (classType == boolean.class) {
copyBoolean(result, a);
} else
copyObject(result, a);
} | java | {
"resource": ""
} |
q175125 | MAMath.copyBoolean | test | public static void copyBoolean(Array result, Array a) throws IllegalArgumentException {
if (!conformable(a, result))
throw new IllegalArgumentException("copy arrays are not conformable");
IndexIterator iterA = a.getIndexIterator();
IndexIterator iterR = result.getIndexIterator();
while (iterA.hasNext())
iterR.setBooleanNext(iterA.getBooleanNext());
} | java | {
"resource": ""
} |
q175126 | MAMath.copyObject | test | public static void copyObject(Array result, Array a) throws IllegalArgumentException {
if (!conformable(a, result))
throw new IllegalArgumentException("copy arrays are not conformable");
IndexIterator iterA = a.getIndexIterator();
IndexIterator iterR = result.getIndexIterator();
while (iterA.hasNext()) {
iterR.setObjectNext( iterA.getObjectNext());
}
} | java | {
"resource": ""
} |
q175127 | MAMath.getMinMax | test | public static MAMath.MinMax getMinMax(Array a) {
IndexIterator iter = a.getIndexIterator();
double max = -Double.MAX_VALUE;
double min = Double.MAX_VALUE;
while (iter.hasNext()) {
double val = iter.getDoubleNext();
if (Double.isNaN(val)) continue;
if (val > max)
max = val;
if (val < min)
min = val;
}
return new MinMax(min, max);
} | java | {
"resource": ""
} |
q175128 | MAMath.setDouble | test | public static void setDouble(Array result, double val) {
IndexIterator iter = result.getIndexIterator();
while (iter.hasNext()) {
iter.setDoubleNext(val);
}
} | java | {
"resource": ""
} |
q175129 | ConfigCatalog.makeCatalogBuilder | test | public CatalogBuilder makeCatalogBuilder() {
CatalogBuilder builder = new CatalogBuilder(this);
for (Dataset ds : getDatasetsLocal()) {
builder.addDataset(makeDatasetBuilder(null, ds));
}
return builder;
} | java | {
"resource": ""
} |
q175130 | ProjectionAdapter.factory | test | static public ProjectionImpl factory(Projection proj) {
if (proj instanceof ProjectionImpl) {
return (ProjectionImpl) proj;
}
return new ProjectionAdapter(proj);
} | java | {
"resource": ""
} |
q175131 | EscapeStrings.unescapeDAPIdentifier | test | public static String unescapeDAPIdentifier(String id) {
String s;
try {
s = unescapeString(id);
} catch (Exception e) {
s = null;
}
return s;
} | java | {
"resource": ""
} |
q175132 | EscapeStrings.urlDecode | test | public static String urlDecode(String s) {
try {
//s = unescapeString(s, _URIEscape, "", false);
s = URLDecoder.decode(s, "UTF-8");
} catch (Exception e) {
s = null;
}
return s;
} | java | {
"resource": ""
} |
q175133 | EscapeStrings.unescapeURL | test | public static String unescapeURL(String url) {
String newurl;
newurl = urlDecode(url);
return newurl;
} | java | {
"resource": ""
} |
q175134 | EscapeStrings.backslashEscape | test | static public String backslashEscape(String x, String reservedChars) {
if (x == null) {
return null;
} else if (reservedChars == null) {
return x;
}
boolean ok = true;
for (int pos = 0; pos < x.length(); pos++) {
char c = x.charAt(pos);
if (reservedChars.indexOf(c) >= 0) {
ok = false;
break;
}
}
if (ok) return x;
// gotta do it
StringBuilder sb = new StringBuilder(x);
for (int pos = 0; pos < sb.length(); pos++) {
char c = sb.charAt(pos);
if (reservedChars.indexOf(c) < 0) {
continue;
}
sb.setCharAt(pos, '\\');
pos++;
sb.insert(pos, c);
pos++;
}
return sb.toString();
} | java | {
"resource": ""
} |
q175135 | EscapeStrings.backslashUnescape | test | static public String backslashUnescape(String x) {
if (!x.contains("\\")) return x;
// gotta do it
StringBuilder sb = new StringBuilder(x.length());
for (int pos = 0; pos < x.length(); pos++) {
char c = x.charAt(pos);
if (c == '\\') {
c = x.charAt(++pos); // skip backslash, get next cha
}
sb.append(c);
}
return sb.toString();
} | java | {
"resource": ""
} |
q175136 | EscapeStrings.tokenizeEscapedName | test | public static List<String> tokenizeEscapedName(String escapedName) {
List<String> result = new ArrayList<>();
int pos = 0;
int start = 0;
while (true) {
pos = escapedName.indexOf(sep, pos + 1);
if (pos <= 0) break;
if ((pos > 0) && escapedName.charAt(pos - 1) != '\\') {
result.add(escapedName.substring(start, pos));
start = pos + 1;
}
}
result.add(escapedName.substring(start, escapedName.length())); // remaining
return result;
} | java | {
"resource": ""
} |
q175137 | EscapeStrings.indexOf | test | public static int indexOf(String escapedName, char c) {
int pos = 0;
while (true) {
pos = escapedName.indexOf(c, pos + 1);
if (pos <= 0) return pos;
if ((pos > 0) && escapedName.charAt(pos - 1) != '\\') return pos;
}
} | java | {
"resource": ""
} |
q175138 | EscapeStrings.backslashToDAP | test | public static String backslashToDAP(String bs) {
StringBuilder buf = new StringBuilder();
int len = bs.length();
for (int i = 0; i < len; i++) {
char c = bs.charAt(i);
if (i < (len - 1) && c == '\\') {
c = bs.charAt(++i);
}
if (_allowableInDAP.indexOf(c) < 0) {
buf.append(_URIEscape);
// convert the char to hex
String ashex = Integer.toHexString((int) c);
if (ashex.length() < 2) buf.append('0');
buf.append(ashex);
} else
buf.append(c);
}
return buf.toString();
} | java | {
"resource": ""
} |
q175139 | Nc4Cursor.readAtomicScalar | test | protected Object
readAtomicScalar(VarNotes vi, TypeNotes ti)
throws DapException
{
DapVariable atomvar = (DapVariable) getTemplate();
// Get into memory
Nc4prototypes nc4 = ((Nc4DSP) this.dsp).getJNI();
int ret;
DapType basetype = ti.getType();
Object result = null;
if(basetype.isFixedSize()) {
long memsize = ((DapType) ti.get()).getSize();
Nc4Pointer mem = Nc4Pointer.allocate(memsize);
readcheck(nc4, ret = nc4.nc_get_var(vi.gid, vi.id, mem.p));
setMemory(mem);
result = getatomicdata(ti.getType(), 1, mem.size, mem);
} else if(basetype.isStringType()) {
String[] s = new String[1];
readcheck(nc4, ret = nc4.nc_get_var_string(vi.gid, vi.id, s));
result = s;
} else if(basetype.isOpaqueType()) {
Nc4Pointer mem = Nc4Pointer.allocate(ti.getSize());
readcheck(nc4, ret = nc4.nc_get_var(vi.gid, vi.id, mem.p));
setMemory(mem);
ByteBuffer[] buf = new ByteBuffer[1];
buf[0] = mem.p.getByteBuffer(0, ti.getSize());
result = buf;
} else
throw new DapException("Unexpected atomic type: " + basetype);
return result;
} | java | {
"resource": ""
} |
q175140 | Nc4Cursor.getCursorPath | test | static List<Nc4Cursor>
getCursorPath(Nc4Cursor cursor)
{
List<Nc4Cursor> path = new ArrayList<>();
for(; ; ) {
if(!cursor.getScheme().isCompoundArray()) // suppress
path.add(0, cursor);
if(cursor.getScheme() == Scheme.SEQUENCE) {
// Stop here because the sequence has the vlen mem as its mem
break;
}
Nc4Cursor next = (Nc4Cursor) cursor.getContainer();
if(next == null) {
assert cursor.getTemplate().isTopLevel();
break;
}
assert next.getTemplate().getSort() == DapSort.VARIABLE;
cursor = next;
}
return path;
} | java | {
"resource": ""
} |
q175141 | SwingUtils.getUIDefaultOfClass | test | public static Object getUIDefaultOfClass(Class clazz, String property) {
Object retVal = null;
UIDefaults defaults = getUIDefaultsOfClass(clazz);
List<Object> listKeys = Collections.list(defaults.keys());
for (Object key : listKeys) {
if (key.equals(property)) {
return defaults.get(key);
}
if (key.toString().equalsIgnoreCase(property)) {
retVal = defaults.get(key);
}
}
return retVal;
} | java | {
"resource": ""
} |
q175142 | SwingUtils.getJClass | test | public static <T extends JComponent> Class getJClass(T component) {
Class<?> clazz = component.getClass();
while (!clazz.getName().matches("javax.swing.J[^.]*$")) {
clazz = clazz.getSuperclass();
}
return clazz;
} | java | {
"resource": ""
} |
q175143 | D4DataCompiler.compile | test | public void
compile()
throws DapException
{
assert (this.dataset != null && this.databuffer != null);
// iterate over the variables represented in the databuffer
for(DapVariable vv : this.dataset.getTopVariables()) {
D4Cursor data = compileVar(vv, null);
this.dsp.addVariableData(vv, data);
}
} | java | {
"resource": ""
} |
q175144 | D4DataCompiler.compileStructureArray | test | protected D4Cursor
compileStructureArray(DapVariable var, D4Cursor container)
throws DapException
{
DapStructure dapstruct = (DapStructure) var.getBaseType();
D4Cursor structarray = new D4Cursor(Scheme.STRUCTARRAY, this.dsp, var, container)
.setOffset(getPos(this.databuffer));
List<DapDimension> dimset = var.getDimensions();
long dimproduct = DapUtil.dimProduct(dimset);
D4Cursor[] instances = new D4Cursor[(int) dimproduct];
Odometer odom = Odometer.factory(DapUtil.dimsetToSlices(dimset), dimset);
while(odom.hasNext()) {
Index index = odom.next();
D4Cursor instance = compileStructure(var, dapstruct, structarray);
instance.setIndex(index);
instances[(int) index.index()] = instance;
}
structarray.setElements(instances);
return structarray;
} | java | {
"resource": ""
} |
q175145 | D4DataCompiler.compileStructure | test | protected D4Cursor
compileStructure(DapVariable var, DapStructure dapstruct, D4Cursor container)
throws DapException
{
int pos = getPos(this.databuffer);
D4Cursor d4ds = new D4Cursor(Scheme.STRUCTURE, (D4DSP) this.dsp, var, container)
.setOffset(pos);
List<DapVariable> dfields = dapstruct.getFields();
for(int m = 0; m < dfields.size(); m++) {
DapVariable dfield = dfields.get(m);
D4Cursor dvfield = compileVar(dfield, d4ds);
d4ds.addField(m, dvfield);
assert dfield.getParent() != null;
}
return d4ds;
} | java | {
"resource": ""
} |
q175146 | D4DataCompiler.compileSequenceArray | test | protected D4Cursor
compileSequenceArray(DapVariable var, D4Cursor container)
throws DapException
{
DapSequence dapseq = (DapSequence) var.getBaseType();
D4Cursor seqarray = new D4Cursor(Scheme.SEQARRAY, this.dsp, var, container)
.setOffset(getPos(this.databuffer));
List<DapDimension> dimset = var.getDimensions();
long dimproduct = DapUtil.dimProduct(dimset);
D4Cursor[] instances = new D4Cursor[(int) dimproduct];
Odometer odom = Odometer.factory(DapUtil.dimsetToSlices(dimset), dimset);
while(odom.hasNext()) {
Index index = odom.next();
D4Cursor instance = compileSequence(var, dapseq, seqarray);
instance.setIndex(index);
instances[(int) index.index()] = instance;
}
seqarray.setElements(instances);
return seqarray;
} | java | {
"resource": ""
} |
q175147 | D4DataCompiler.compileSequence | test | public D4Cursor
compileSequence(DapVariable var, DapSequence dapseq, D4Cursor container)
throws DapException
{
int pos = getPos(this.databuffer);
D4Cursor seq = new D4Cursor(Scheme.SEQUENCE, this.dsp, var, container)
.setOffset(pos);
List<DapVariable> dfields = dapseq.getFields();
// Get the count of the number of records
long nrecs = getCount(this.databuffer);
for(int r = 0; r < nrecs; r++) {
pos = getPos(this.databuffer);
D4Cursor rec = (D4Cursor) new D4Cursor(D4Cursor.Scheme.RECORD, this.dsp, var, container)
.setOffset(pos).setRecordIndex(r);
for(int m = 0; m < dfields.size(); m++) {
DapVariable dfield = dfields.get(m);
D4Cursor dvfield = compileVar(dfield, rec);
rec.addField(m, dvfield);
assert dfield.getParent() != null;
}
seq.addRecord(rec);
}
return seq;
} | java | {
"resource": ""
} |
q175148 | BeLeDataInputStream.readLELong | test | public long readLELong() throws IOException {
readFully(w, 0, 8);
return
(long) (w[7] & 0xff) << 56 |
(long) (w[6] & 0xff) << 48 |
(long) (w[5] & 0xff) << 40 |
(long) (w[4] & 0xff) << 32 |
(long) (w[3] & 0xff) << 24 |
(long) (w[2] & 0xff) << 16 |
(long) (w[1] & 0xff) << 8 |
(long) (w[0] & 0xff);
} | java | {
"resource": ""
} |
q175149 | PrefPanel.getField | test | public Field getField(String name) {
Field fld = flds.get(name);
if (fld == null) return null;
return (fld instanceof FieldResizable) ? ((FieldResizable)fld).getDelegate() : fld;
} | java | {
"resource": ""
} |
q175150 | PrefPanel.getFieldValue | test | public Object getFieldValue(String name) {
Field fld = getField(name);
if (fld == null) throw new IllegalArgumentException("no field named "+name);
return fld.getValue();
} | java | {
"resource": ""
} |
q175151 | PrefPanel.setFieldValue | test | public void setFieldValue(String name, Object value) {
Field fld = getField(name);
if (fld == null) throw new IllegalArgumentException("no field named "+name);
fld.setValue(value);
} | java | {
"resource": ""
} |
q175152 | PrefPanel.addField | test | public Field addField(Field fld) {
addField( fld, cursorCol, cursorRow, null);
cursorRow++;
return fld;
} | java | {
"resource": ""
} |
q175153 | PrefPanel.addCheckBoxField | test | public Field.CheckBox addCheckBoxField(String fldName, String label, boolean defValue) {
Field.CheckBox fld = new Field.CheckBox(fldName, label, defValue, storeData);
addField( fld);
return fld;
} | java | {
"resource": ""
} |
q175154 | PrefPanel.addDateField | test | public Field.Date addDateField(String fldName, String label, Date defValue) {
Field.Date fld = new Field.Date(fldName, label, defValue, storeData);
addField( new FieldResizable(fld, this));
return fld;
} | java | {
"resource": ""
} |
q175155 | PrefPanel.addDoubleField | test | public Field.Double addDoubleField(String fldName, String label, double defValue) {
Field.Double fld = new Field.Double(fldName, label, defValue, -1, storeData);
addField( new FieldResizable(fld, this));
return fld;
} | java | {
"resource": ""
} |
q175156 | PrefPanel.addIntField | test | public Field.Int addIntField(String fldName, String label, int defValue) {
Field.Int fld = new Field.Int(fldName, label, defValue, storeData);
addField( new FieldResizable(fld, this));
return fld;
} | java | {
"resource": ""
} |
q175157 | PrefPanel.addPasswordField | test | public Field.Password addPasswordField(String fldName, String label, String defValue) {
Field.Password fld = new Field.Password(fldName, label, defValue, storeData);
addField( new FieldResizable(fld, this));
return fld;
} | java | {
"resource": ""
} |
q175158 | PrefPanel.addTextField | test | public Field.Text addTextField(String fldName, String label, String defValue) {
Field.Text fld = new Field.Text(fldName, label, defValue, storeData);
addField( new FieldResizable(fld, this));
return fld;
} | java | {
"resource": ""
} |
q175159 | PrefPanel.addTextComboField | test | public Field.TextCombo addTextComboField(String fldName, String label, java.util.Collection defValues, int nKeep, boolean editable) {
Field.TextCombo fld = new Field.TextCombo(fldName, label, defValues, nKeep, storeData);
addField( fld);
fld.setEditable( editable);
return fld;
} | java | {
"resource": ""
} |
q175160 | PrefPanel.addTextAreaField | test | public Field.TextArea addTextAreaField(String fldName, String label, String def, int nrows) {
Field.TextArea fld = new Field.TextArea(fldName, label, def, nrows, storeData);
addField( fld);
return fld;
} | java | {
"resource": ""
} |
q175161 | PrefPanel.addHeading | test | public void addHeading(String heading, int row) {
layoutComponents.add( new LayoutComponent( heading, 0, row, null));
} | java | {
"resource": ""
} |
q175162 | PrefPanel.addComponent | test | public void addComponent(Component comp, int col, int row, String constraint) {
layoutComponents.add( new LayoutComponent( comp, col, row, constraint));
} | java | {
"resource": ""
} |
q175163 | PrefPanel.addEmptyRow | test | public void addEmptyRow(int row, int size) {
layoutComponents.add( new LayoutComponent( null, size, row, null));
} | java | {
"resource": ""
} |
q175164 | PrefPanel.findActiveFrame | test | static public Frame findActiveFrame() {
Frame[] frames = JFrame.getFrames();
for (Frame frame : frames) {
if (frame.isVisible())
return frame;
}
return null;
} | java | {
"resource": ""
} |
q175165 | DoradeRADD.getCellSpacing | test | public float getCellSpacing() throws DescriptorException {
float[] cellRanges = myCELV.getCellRanges();
//
// use the first cell spacing as our expected value
//
float cellSpacing = cellRanges[1] - cellRanges[0];
//
// Check the rest of the cells against the expected value, allowing
// 1% fudge
//
for (int i = 2; i < cellRanges.length; i++) {
float space = cellRanges[i] - cellRanges[i - 1];
if (!Misc.nearlyEquals(space, cellSpacing) && (Math.abs(space / cellSpacing - 1.0) > 0.01)) {
throw new DescriptorException("variable cell spacing");
}
}
return cellSpacing;
} | java | {
"resource": ""
} |
q175166 | Dimension.getFactors | test | public final Factor[] getFactors() {
final Factor[] factors = new Factor[_factors.length];
System.arraycopy(_factors, 0, factors, 0, factors.length);
return factors;
} | java | {
"resource": ""
} |
q175167 | Dimension.mult | test | protected Factor[] mult(final Dimension that) {
// relys on _factors always sorted
final Factor[] factors1 = _factors;
final Factor[] factors2 = that._factors;
int i1 = 0;
int i2 = 0;
int k = 0;
Factor[] newFactors = new Factor[factors1.length + factors2.length];
for (;;) {
if (i1 == factors1.length) {
final int n = factors2.length - i2;
System.arraycopy(factors2, i2, newFactors, k, n);
k += n;
break;
}
if (i2 == factors2.length) {
final int n = factors1.length - i1;
System.arraycopy(factors1, i1, newFactors, k, n);
k += n;
break;
}
final Factor f1 = factors1[i1];
final Factor f2 = factors2[i2];
final int comp = f1.getID().compareTo(f2.getID());
if (comp < 0) {
newFactors[k++] = f1;
i1++;
}
else if (comp == 0) {
final int exponent = f1.getExponent() + f2.getExponent();
if (exponent != 0) {
newFactors[k++] = new Factor(f1, exponent);
}
i1++;
i2++;
}
else {
newFactors[k++] = f2;
i2++;
}
}
if (k < newFactors.length) {
final Factor[] tmp = new Factor[k];
System.arraycopy(newFactors, 0, tmp, 0, k);
newFactors = tmp;
}
return newFactors;
} | java | {
"resource": ""
} |
q175168 | Dimension.pow | test | protected Factor[] pow(final int power) {
Factor[] factors;
if (power == 0) {
factors = new Factor[0];
}
else {
factors = getFactors();
if (power != 1) {
for (int i = factors.length; --i >= 0;) {
factors[i] = factors[i].pow(power);
}
}
}
return factors;
} | java | {
"resource": ""
} |
q175169 | Dimension.isReciprocalOf | test | public final boolean isReciprocalOf(final Dimension that) {
final Factor[] theseFactors = _factors;
final Factor[] thoseFactors = that._factors;
boolean isReciprocalOf;
if (theseFactors.length != thoseFactors.length) {
isReciprocalOf = false;
}
else {
int i;
for (i = theseFactors.length; --i >= 0;) {
if (!theseFactors[i].isReciprocalOf(thoseFactors[i])) {
break;
}
}
isReciprocalOf = i < 0;
}
return isReciprocalOf;
} | java | {
"resource": ""
} |
q175170 | Dimension.isDimensionless | test | public final boolean isDimensionless() {
for (int i = _factors.length; --i >= 0;) {
if (!_factors[i].isDimensionless()) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q175171 | Grib1ParamTables.factory | test | public static Grib1ParamTables factory(String paramTablePath, String lookupTablePath) throws IOException {
if (paramTablePath == null && lookupTablePath == null) return new Grib1ParamTables();
Lookup lookup = null;
Grib1ParamTableReader override = null;
Grib1ParamTableReader table;
if (paramTablePath != null) {
table = localTableHash.get(paramTablePath);
if (table == null) {
table = new Grib1ParamTableReader(paramTablePath);
localTableHash.put(paramTablePath, table);
override = table;
}
}
if (lookupTablePath != null) {
lookup = new Lookup();
if (!lookup.readLookupTable(lookupTablePath))
throw new FileNotFoundException("cant read lookup table=" + lookupTablePath);
}
return new Grib1ParamTables(lookup, override);
} | java | {
"resource": ""
} |
q175172 | Grib1ParamTables.factory | test | public static Grib1ParamTables factory(org.jdom2.Element paramTableElem) {
if (paramTableElem == null) return new Grib1ParamTables();
return new Grib1ParamTables(null, new Grib1ParamTableReader(paramTableElem));
} | java | {
"resource": ""
} |
q175173 | Grib1ParamTables.addParameterTableLookup | test | public static boolean addParameterTableLookup(String lookupFilename) throws IOException {
Lookup lookup = new Lookup();
if (!lookup.readLookupTable(lookupFilename))
return false;
synchronized (lock) {
standardLookup.tables.addAll(standardTablesStart, lookup.tables);
standardTablesStart += lookup.tables.size();
}
return true;
} | java | {
"resource": ""
} |
q175174 | Grib1ParamTables.addParameterTable | test | public static void addParameterTable(int center, int subcenter, int tableVersion, String tableFilename) {
Grib1ParamTableReader table = new Grib1ParamTableReader(center, subcenter, tableVersion, tableFilename);
synchronized (lock) {
standardLookup.tables.add(standardTablesStart, table);
standardTablesStart++;
}
} | java | {
"resource": ""
} |
q175175 | LogarithmicUnit.myRaiseTo | test | @Override
protected Unit myRaiseTo(final int power) throws RaiseException {
if (power == 0) {
return DerivedUnitImpl.DIMENSIONLESS;
}
if (power == 1) {
return this;
}
throw new RaiseException(this);
} | java | {
"resource": ""
} |
q175176 | LogarithmicUnit.toDerivedUnit | test | public float[] toDerivedUnit(final float[] input, final float[] output)
throws ConversionException {
for (int i = input.length; --i >= 0;) {
output[i] = (float) (Math.exp(input[i] * lnBase));
}
return reference.toDerivedUnit(output, output);
} | java | {
"resource": ""
} |
q175177 | Vis5DIosp.initUnitTable | test | private static void initUnitTable() {
unitTable = new Hashtable<>();
// temperatures
unitTable.put("t", "K");
unitTable.put("td", "K");
unitTable.put("thte", "K");
// winds
unitTable.put("u", "m/s");
unitTable.put("v", "m/s");
unitTable.put("w", "m/s");
// pressure
unitTable.put("p", "hPa");
unitTable.put("mmsl", "hPa");
// moisture
unitTable.put("rh", "%");
// misc
unitTable.put("rhfz", "%");
unitTable.put("zagl", "m");
} | java | {
"resource": ""
} |
q175178 | Vis5DIosp.makeVerticalVariable | test | private Variable makeVerticalVariable(int vert_sys, int n_levels,
float[] vert_args)
throws IOException {
String vert_unit = null;
String vert_type;
ArrayFloat.D1 data = new ArrayFloat.D1(n_levels);
AxisType axisType = null;
switch (vert_sys) {
case (0):
vert_unit = null;
vert_type = "height";
break;
case (1):
case (2):
vert_unit = "km";
vert_type = "altitude";
axisType = AxisType.Height;
break;
case (3):
vert_unit = "mbar";
vert_type = "pressure";
axisType = AxisType.Pressure;
break;
default:
throw new IOException("vert_sys unknown");
}
Variable vertVar = new Variable(ncfile, null, null, vert_type);
vertVar.setDimensions(LEVEL);
vertVar.setDataType(DataType.FLOAT);
if (vert_unit != null) {
vertVar.addAttribute(new Attribute(CDM.UNITS, vert_unit));
}
if (axisType != null) {
vertVar.addAttribute(new Attribute(_Coordinate.AxisType,
axisType.toString()));
}
switch (vert_sys) {
case (0):
case (1):
for (int i = 0; i < n_levels; i++) {
data.set(i, vert_args[0] + vert_args[1] * i);
}
break;
case (2): // Altitude in km - non-linear
for (int i = 0; i < n_levels; i++) {
data.set(i, vert_args[i]);
}
break;
case (3): // heights of pressure surfaces in km - non-linear
try {
Vis5DVerticalSystem.Vis5DVerticalCoordinateSystem vert_cs =
new Vis5DVerticalSystem.Vis5DVerticalCoordinateSystem();
float[][] pressures = new float[1][n_levels];
System.arraycopy(vert_args, 0, pressures[0], 0, n_levels);
for (int i = 0; i < n_levels; i++) {
pressures[0][i] *= 1000; // km->m
}
pressures = vert_cs.fromReference(pressures); // convert to pressures
for (int i = 0; i < n_levels; i++) {
data.set(i, pressures[0][i]);
}
} catch (VisADException ve) {
throw new IOException("unable to make vertical system");
}
break;
}
vertVar.setCachedData(data, false);
return vertVar;
} | java | {
"resource": ""
} |
q175179 | DoradeDescriptor.peekName | test | protected static String peekName(RandomAccessFile file)
throws DescriptorException {
try {
long filepos = file.getFilePointer();
byte[] nameBytes = new byte[4];
if (file.read(nameBytes) == -1)
return null; // EOF
file.seek(filepos);
return new String(nameBytes, CDM.utf8Charset);
} catch (IOException ex) {
throw new DescriptorException(ex);
}
} | java | {
"resource": ""
} |
q175180 | DoradeDescriptor.grabShort | test | protected short grabShort(byte[] bytes, int offset) {
int ndx0 = offset + (littleEndianData ? 1 : 0);
int ndx1 = offset + (littleEndianData ? 0 : 1);
// careful that we only allow sign extension on the highest order byte
return (short) (bytes[ndx0] << 8 | (bytes[ndx1] & 0xff));
} | java | {
"resource": ""
} |
q175181 | DoradeDescriptor.grabInt | test | protected static int grabInt(byte[] bytes, int offset,
boolean littleEndianData) {
int ndx0 = offset + (littleEndianData ? 3 : 0);
int ndx1 = offset + (littleEndianData ? 2 : 1);
int ndx2 = offset + (littleEndianData ? 1 : 2);
int ndx3 = offset + (littleEndianData ? 0 : 3);
// careful that we only allow sign extension on the highest order byte
return (bytes[ndx0] << 24 |
(bytes[ndx1] & 0xff) << 16 |
(bytes[ndx2] & 0xff) << 8 |
(bytes[ndx3] & 0xff));
} | java | {
"resource": ""
} |
q175182 | DoradeDescriptor.grabFloat | test | protected float grabFloat(byte[] bytes, int offset)
throws DescriptorException {
try {
byte[] src;
if (littleEndianData) {
src = new byte[4];
src[0] = bytes[offset + 3];
src[1] = bytes[offset + 2];
src[2] = bytes[offset + 1];
src[3] = bytes[offset];
offset = 0;
} else {
src = bytes;
}
DataInputStream stream =
new DataInputStream(new ByteArrayInputStream(src, offset, 4));
return stream.readFloat();
} catch (Exception ex) {
throw new DescriptorException(ex);
}
} | java | {
"resource": ""
} |
q175183 | DoradeDescriptor.grabDouble | test | protected double grabDouble(byte[] bytes, int offset)
throws DescriptorException {
try {
byte[] src;
if (littleEndianData) {
src = new byte[8];
src[0] = bytes[offset + 7];
src[1] = bytes[offset + 6];
src[2] = bytes[offset + 5];
src[3] = bytes[offset + 4];
src[4] = bytes[offset + 3];
src[5] = bytes[offset + 2];
src[6] = bytes[offset + 1];
src[7] = bytes[offset];
offset = 0;
} else {
src = bytes;
}
DataInputStream stream =
new DataInputStream(new ByteArrayInputStream(src, offset, 8));
return stream.readDouble();
} catch (Exception ex) {
throw new DescriptorException(ex);
}
} | java | {
"resource": ""
} |
q175184 | StandardUnitDB.aa | test | private void aa(final String alias, final String name)
throws UnitExistsException, NoSuchUnitException,
UnitParseException, SpecificationException, UnitDBException,
PrefixDBException, OperationException, NameException,
UnitSystemException {
aa(alias, name, null);
} | java | {
"resource": ""
} |
q175185 | StandardUnitDB.as | test | private void as(final String symbol, final String name)
throws UnitExistsException, NoSuchUnitException,
UnitParseException, SpecificationException, UnitDBException,
PrefixDBException, OperationException, NameException,
UnitSystemException {
addSymbol(symbol, name);
} | java | {
"resource": ""
} |
q175186 | ConverterImpl.create | test | public static Converter
create(Unit fromUnit, Unit toUnit)
throws ConversionException
{
return fromUnit.getConverterTo(toUnit);
} | java | {
"resource": ""
} |
q175187 | StructureTable.setStructureData | test | public void setStructureData(List<StructureData> structureData) throws IOException {
dataModel = new StructureDataModel(structureData);
initTable(dataModel);
} | java | {
"resource": ""
} |
q175188 | StructureTable.setPointFeatureData | test | public void setPointFeatureData(List<PointFeature> obsData) throws IOException {
dataModel = new PointFeatureDataModel(obsData);
initTable(dataModel);
} | java | {
"resource": ""
} |
q175189 | GisFeatureRenderer.draw | test | public void draw(java.awt.Graphics2D g, AffineTransform pixelAT) {
g.setColor(color);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g.setStroke(new java.awt.BasicStroke(0.0f));
Rectangle2D clipRect = (Rectangle2D) g.getClip();
Iterator siter = getShapes(g, pixelAT);
while (siter.hasNext()) {
Shape s = (Shape) siter.next();
Rectangle2D shapeBounds = s.getBounds2D();
if (shapeBounds.intersects(clipRect))
g.draw(s);
}
} | java | {
"resource": ""
} |
q175190 | GisFeatureRenderer.getShapes | test | protected Iterator getShapes(java.awt.Graphics2D g, AffineTransform normal2device) {
if (shapeList != null)
return shapeList.iterator();
if(Debug.isSet("projection/LatLonShift"))
System.out.println("projection/LatLonShift GisFeatureRenderer.getShapes called");
ProjectionImpl dataProject = getDataProjection();
// a list of GisFeatureAdapter-s
List featList = getFeatures();
shapeList = new ArrayList(featList.size());
Iterator iter = featList.iterator();
while (iter.hasNext())
{
AbstractGisFeature feature = (AbstractGisFeature) iter.next();
Shape shape;
if (dataProject == null)
shape = feature.getShape();
else if (dataProject.isLatLon()) {
// always got to run it through if its lat/lon
shape = feature.getProjectedShape(displayProject);
//System.out.println("getShapes dataProject.isLatLon() "+displayProject);
} else if (dataProject == displayProject) {
shape = feature.getShape();
//System.out.println("getShapes dataProject == displayProject");
} else {
shape = feature.getProjectedShape(dataProject, displayProject);
//System.out.println("getShapes dataProject != displayProject");
}
shapeList.add(shape);
}
return shapeList.iterator();
} | java | {
"resource": ""
} |
q175191 | BufrSplitter.processStream | test | public void processStream(InputStream is) throws IOException {
int pos = -1;
Buffer b = null;
while (true) {
b = (pos < 0) ? readBuffer(is) : readBuffer(is, b, pos);
pos = processBuffer(b, is);
if (b.done) break;
}
} | java | {
"resource": ""
} |
q175192 | BufrSplitter.readBuffer | test | private boolean readBuffer(InputStream is, byte[] dest, int start, int want) throws IOException {
int done = 0;
while (done < want) {
int got = is.read(dest, start + done, want - done);
if (got < 0)
return false;
done += got;
}
if (showRead) System.out.println("Read buffer at " + bytesRead + " len=" + done);
bytesRead += done;
return true;
} | java | {
"resource": ""
} |
q175193 | HeaderInputStream.getMoreBytes | test | private void getMoreBytes() throws IOException {
currentOffset = 0; // reset current array offset to 0
int bytesRead = 0; // bytes read so far
int lookingFor = 0; // character in endSequence to look for
for (; bytesRead < lineBuf.length; bytesRead++) {
int c = in.read();
if (c == -1)
break; // break on EOL and return what we have so far
lineBuf[bytesRead] = (byte) c;
if (lineBuf[bytesRead] == endSequence[lookingFor]) {
lookingFor++;
if (lookingFor == endSequence.length) {
endFound = true;
break;
}
} else if (lineBuf[bytesRead] == endSequence[0]) { // CHANGED JC
lookingFor = 1;
} else {
lookingFor = 0;
}
}
bytesRemaining = bytesRead; // number of bytes we've read
} | java | {
"resource": ""
} |
q175194 | HeaderInputStream.read | test | public int read(byte b[], int off, int len) throws IOException {
if (len <= 0) {
return 0;
}
int c = read();
if (c == -1)
return -1;
b[off] = (byte) c;
// We've read one byte successfully, let's try for more
int i = 1;
try {
for (; i < len; i++) {
c = read();
if (c == -1) {
break;
}
b[off + i] = (byte) c;
}
} catch (IOException e) {
}
return i;
} | java | {
"resource": ""
} |
q175195 | HeaderInputStream.skip | test | public long skip(long n) {
if (bytesRemaining >= n) {
bytesRemaining -= n;
return n;
} else {
int oldBytesRemaining = bytesRemaining;
bytesRemaining = 0;
return oldBytesRemaining;
}
} | java | {
"resource": ""
} |
q175196 | GridVertCoord.addDimensionsToNetcdfFile | test | void addDimensionsToNetcdfFile(NetcdfFile ncfile, Group g) {
if (!isVertDimensionUsed())
return;
int nlevs = levels.size();
if ( coordValues != null )
nlevs = coordValues.length;
ncfile.addDimension(g, new Dimension(getVariableName(), nlevs, true));
} | java | {
"resource": ""
} |
q175197 | GridVertCoord.coordIndex | test | private int coordIndex(GridRecord record) {
double val = record.getLevel1();
double val2 = record.getLevel2();
if (usesBounds && (val > val2)) {
val = record.getLevel2();
val2 = record.getLevel1();
}
for (int i = 0; i < levels.size(); i++) {
LevelCoord lc = (LevelCoord) levels.get(i);
if (usesBounds) {
if (ucar.nc2.util.Misc.nearlyEquals(lc.value1, val) && ucar.nc2.util.Misc.nearlyEquals(lc.value2, val2)) {
return i;
}
} else {
if (ucar.nc2.util.Misc.nearlyEquals(lc.value1, val)) {
return i;
}
}
}
return -1;
} | java | {
"resource": ""
} |
q175198 | NOWRadiosp.isValidFile | test | public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) {
NOWRadheader localHeader = new NOWRadheader();
return (localHeader.isValidFile(raf));
} | java | {
"resource": ""
} |
q175199 | NOWRadiosp.open | test | public void open(ucar.unidata.io.RandomAccessFile raf, ucar.nc2.NetcdfFile file,
ucar.nc2.util.CancelTask cancelTask)
throws IOException {
super.open(raf, ncfile, cancelTask);
headerParser = new NOWRadheader();
try {
headerParser.read(this.raf, ncfile);
} catch (Exception e) {
}
// myInfo = headerParser.getVarInfo();
pcode = 0;
ncfile.finish();
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.