PointDecoder.java

  1. package de.turnertech.ows.gml;

  2. import org.w3c.dom.Node;
  3. import org.w3c.dom.NodeList;

  4. import de.turnertech.ows.srs.SpatialReferenceSystem;

  5. public class PointDecoder implements GmlDecoder<Point> {
  6.    
  7.     @Override
  8.     public Point decode(Node root, GmlDecoderContext context) {
  9.         Point returnElement = new Point();
  10.        
  11.         Node srsNode = root.getAttributes().getNamedItem("srsName");
  12.         SpatialReferenceSystem srs = null;
  13.         if(srsNode != null) {
  14.             srs = SpatialReferenceSystem.from(srsNode.getNodeValue());
  15.             if(srs != null) {
  16.                 context.getSrsDeque().push(srs);
  17.             }
  18.         }

  19.         NodeList children = root.getChildNodes();
  20.         for(int i = 0; i < children.getLength(); ++i) {
  21.             Node child = children.item(i);
  22.             if(child.getNodeType() != Node.ELEMENT_NODE) {
  23.                 continue;
  24.             }
  25.             if("pos".equals(child.getNodeName())) {
  26.                 DirectPosition pos = new DirectPositionDecoder().decode(child, context);
  27.                 returnElement.setPos(pos);
  28.             }
  29.         }

  30.         if(srs != null) {
  31.             context.getSrsDeque().pop();
  32.         }

  33.         return returnElement;
  34.     }

  35. }