org.geotools.xsd.Node.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中org.geotools.xsd.Node.getParent()方法的一些代码示例,展示了Node.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getParent()方法的具体详情如下:
包路径:org.geotools.xsd.Node
类名称:Node
方法名:getParent

Node.getParent介绍

[英]Returns the parent node for this node
[中]返回此节点的父节点

代码示例

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
  3. Node parent = node.getParent();
  4. if (parent != null) {
  5. String parentElementName = parent.getComponent().getName();
  6. if (FOLDER.equals(parentElementName)) {
  7. Folder folder = folderStack.peek();
  8. if (folder != null) {
  9. folder.setName(value.toString());
  10. }
  11. }
  12. }
  13. return super.parse(instance, node, value);
  14. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Returns the number of dimensions for the specified node, eventually recursing up to find the
  3. * parent node that has the indication of the dimensions (normally the top-most geometry element
  4. * has it, not the posList). If no srsDimension can be found, check the srsName the same way and
  5. * return the srsDimensions instead. Returns 2 if no srsDimension or srsName attribute could be
  6. * found.
  7. *
  8. * @param node
  9. * @return
  10. */
  11. public static int dimensions(Node node) {
  12. Node current = node;
  13. while (current != null) {
  14. Node dimensions = current.getAttribute("srsDimension");
  15. if (dimensions != null) {
  16. return ((Number) dimensions.getValue()).intValue();
  17. }
  18. current = current.getParent();
  19. }
  20. current = node;
  21. while (current != null) {
  22. CoordinateReferenceSystem crs = crs(current);
  23. if (crs != null) {
  24. return crs.getCoordinateSystem().getDimension();
  25. }
  26. current = current.getParent();
  27. }
  28. return 2;
  29. }

相关文章