private BxBounds parseElementContainingVertexes(Element el) { ArrayList<Element> vs = getChildren("Vertex", el); if (vs.isEmpty()) { return null; } ArrayList<ComparablePair<Integer, Integer>> list = new ArrayList<ComparablePair<Integer, Integer>>(); int minx = Integer.MAX_VALUE; int maxx = Integer.MIN_VALUE; int miny = Integer.MAX_VALUE; int maxy = Integer.MIN_VALUE; for (Element v : vs) { int x = Integer.parseInt(v.getAttribute("x")); if (x < minx) minx = x; if (x > maxx) maxx = x; int y = Integer.parseInt(v.getAttribute("y")); if (y < miny) miny = y; if (y > maxy) maxy = y; list.add(new ComparablePair<Integer, Integer>(x, y)); } Collections.sort(list); ComparablePair<Integer, Integer> mine = list.get(0); ComparablePair<Integer, Integer> maxe = list.get(list.size() - 1); BxBounds ret = new BxBounds(minx, miny, maxx - minx, maxy - miny); if (ret.getHeight() == 0 || ret.getWidth() == 0) { log.warn("problems with height or width points are:"); for (ComparablePair<Integer, Integer> pa : list) { log.warn("\t" + pa.o1 + " , " + pa.o2); } } return ret; }
private ArrayList<Element> getChildren(String name, Element el) { ArrayList<Element> list = new ArrayList<Element>(); NodeList nl = el.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n instanceof Element) { Element e = (Element) n; if (e.getTagName().equalsIgnoreCase(name)) { list.add(e); } } } return list; }
private BxZoneLabel parseClassification(Element elClassicfication) { ArrayList<Element> eli = getChildren("Category", elClassicfication); Element catEl = eli.isEmpty() ? null : eli.get(0); if (catEl == null) { eli = getChildren("Type", elClassicfication); catEl = eli.isEmpty() ? null : eli.get(0); } if (catEl == null) { return null; } String val = catEl.getAttribute("Value"); if (val == null) { return null; } if (zoneLabelMap.containsKey(val.toLowerCase())) { return zoneLabelMap.get(val.toLowerCase()); } return BxZoneLabel.OTH_UNKNOWN; }