LinearRingDecoder.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 LinearRingDecoder implements GmlDecoder<LinearRing> {

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

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

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

  32.         return returnElement;
  33.     }
  34. }