View Javadoc
1   /*
2    * Copyright (c) 2012-2014, Dienst Landelijk Gebied - Ministerie van Economische Zaken
3    * 
4    * Gepubliceerd onder de BSD 2-clause licentie, 
5    * zie https://github.com/MinELenI/CBSviewer/blob/master/LICENSE.md voor de volledige licentie.
6    */
7   package nl.mineleni.openls.databinding.gml;
8   
9   import java.util.Vector;
10  
11  import nl.mineleni.openls.XmlNamespaceConstants;
12  
13  /**
14   * GML Point. Beschrijft het Point element uit GML 3.2.1.
15   * 
16   * http://schemas.opengis.net/gml/3.2.1/geometryBasic0d1d.xsd
17   * 
18   * <pre>
19   * 
20   * &lt;complexType name="PointType"&gt;
21   *   &lt;complexContent&gt;
22   *     &lt;extension base="gml:AbstractGeometricPrimitiveType"&gt;
23   *       &lt;sequence&gt;
24   *         &lt;choice&gt;
25   *           &lt;element ref="gml:pos" /&gt;
26   *           &lt;element ref="gml:coordinates" /&gt;
27   *         &lt;/choice&gt;
28   *       &lt;/sequence&gt;
29   *     &lt;/extension&gt;
30   *   &lt;/complexContent&gt;
31   * &lt;/complexType&gt;
32   * 
33   * </pre>
34   * 
35   * @author mprins
36   * @since 1.7
37   * @composed 1 - 0..* Pos
38   */
39  public class Point implements XmlNamespaceConstants {
40  
41  	/**
42  	 * serialisation id.
43  	 */
44  	private static final long serialVersionUID = -163863783181316506L;
45  
46  	/** position list. */
47  	private final Vector<Pos> pos = new Vector<>();;
48  
49  	/** The srs name. */
50  	private String srsName;
51  
52  	/** The has srs name. */
53  	private boolean hasSrsName;
54  
55  	/**
56  	 * Instantiates a new point.
57  	 */
58  	public Point() {
59  		this.hasSrsName = false;
60  	}
61  
62  	/**
63  	 * Adds the pos.
64  	 * 
65  	 * @param p
66  	 *            the p
67  	 */
68  	public void addPos(final Pos p) {
69  		this.pos.add(p);
70  	}
71  
72  	/**
73  	 * Gets the pos at.
74  	 * 
75  	 * @param i
76  	 *            the i
77  	 * @return the pos at
78  	 */
79  	public Pos getPosAt(final int i) {
80  		return this.pos.get(i);
81  	}
82  
83  	/**
84  	 * Gets the pos size.
85  	 * 
86  	 * @return the pos size
87  	 */
88  	public int getPosSize() {
89  		return this.pos.size();
90  	}
91  
92  	/**
93  	 * Sets the srs name.
94  	 * 
95  	 * @param srsName
96  	 *            the new srs name
97  	 */
98  	public void setSrsName(final String srsName) {
99  		this.hasSrsName = true;
100 		this.srsName = srsName;
101 	}
102 
103 	/**
104 	 * Gets the srs name.
105 	 * 
106 	 * @return the srs name
107 	 */
108 	public String getSrsName() {
109 		return this.srsName;
110 	}
111 
112 	/**
113 	 * Checks for srs name.
114 	 * 
115 	 * @return true, if successful
116 	 */
117 	public boolean hasSrsName() {
118 		return this.hasSrsName;
119 	}
120 
121 	/*
122 	 * (non-Javadoc)
123 	 * 
124 	 * @see nl.mineleni.openls.XmlNamespaceConstants#toXML()
125 	 */
126 	@Override
127 	public String toXML() {
128 		final StringBuilder sb = new StringBuilder("<"
129 				+ XmlNamespaceConstants.OGC_GML_NAMESPACE_PREFIX + ":Point");
130 
131 		if (this.hasSrsName()) {
132 			sb.append(" srsName=\"").append(this.getSrsName()).append("\"");
133 		}
134 		sb.append(">");
135 		for (final Pos p : this.pos) {
136 			sb.append(p.toXML());
137 		}
138 		sb.append("</" + XmlNamespaceConstants.OGC_GML_NAMESPACE_PREFIX
139 				+ ":Point>");
140 		return sb.toString();
141 	}
142 }