manually deproxied NamedAreas
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / location / Point.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.model.location;
11 import java.io.Serializable;
12
13 import javax.persistence.Embeddable;
14 import javax.persistence.FetchType;
15 import javax.persistence.ManyToOne;
16 import javax.xml.bind.annotation.XmlAccessType;
17 import javax.xml.bind.annotation.XmlAccessorType;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlIDREF;
20 import javax.xml.bind.annotation.XmlRootElement;
21 import javax.xml.bind.annotation.XmlRootElement;
22 import javax.xml.bind.annotation.XmlSchemaType;
23 import javax.xml.bind.annotation.XmlType;
24
25 import org.apache.log4j.Logger;
26
27 import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
28
29 /**
30 * @author m.doering
31 * @version 1.0
32 * @created 08-Nov-2007 13:06:44
33 */
34 @XmlAccessorType(XmlAccessType.FIELD)
35 @XmlType(name = "Point", propOrder = {
36 "longitude",
37 "latitude",
38 "errorRadius",
39 "referenceSystem"
40 })
41 @XmlRootElement(name = "Point")
42 @Embeddable
43 public class Point implements Cloneable, Serializable {
44 private static final Logger logger = Logger.getLogger(Point.class);
45
46 //TODO was Float but H2 threw errors
47 @XmlElement(name = "Longitude")
48 private Double longitude;
49
50 @XmlElement(name = "Latitude")
51 private Double latitude;
52
53 //in Meters
54 @XmlElement(name = "ErrorRadius")
55 private Integer errorRadius = 0;
56
57 @XmlElement(name = "ReferenceSystem")
58 @XmlIDREF
59 @XmlSchemaType(name = "IDREF")
60 @ManyToOne(fetch = FetchType.LAZY)
61 private ReferenceSystem referenceSystem;
62
63 /**
64 * Factory method
65 * @return
66 */
67 public static Point NewInstance(){
68 return new Point();
69 }
70
71 /**
72 * Constructor
73 */
74 public Point() {
75 }
76
77 public ReferenceSystem getReferenceSystem(){
78 return this.referenceSystem;
79 }
80
81 /**
82 *
83 * @param referenceSystem referenceSystem
84 */
85 public void setReferenceSystem(ReferenceSystem referenceSystem){
86 this.referenceSystem = referenceSystem;
87 }
88
89 public Double getLongitude(){
90 return this.longitude;
91 }
92
93 /**
94 *
95 * @param longitude longitude
96 */
97 public void setLongitude(Double longitude){
98 this.longitude = longitude;
99 }
100
101 public Double getLatitude(){
102 return this.latitude;
103 }
104
105 /**
106 *
107 * @param latitude latitude
108 */
109 public void setLatitude(Double latitude){
110 this.latitude = latitude;
111 }
112
113 public Integer getErrorRadius(){
114 return this.errorRadius;
115 }
116
117 /**
118 *
119 * @param errorRadius errorRadius
120 */
121 public void setErrorRadius(Integer errorRadius){
122 this.errorRadius = errorRadius;
123 }
124
125
126 //*********** CLONE **********************************/
127
128 /**
129 * Clones <i>this</i> point. This is a shortcut that enables to
130 * create a new instance that differs only slightly from <i>this</i> point
131 * by modifying only some of the attributes.<BR>
132 * This method overrides the clone method from {@link DerivedUnitBase DerivedUnitBase}.
133 *
134 * @see java.lang.Object#clone()
135 */
136 @Override
137 public Point clone(){
138 try{
139 Point result = (Point)super.clone();
140 result.setReferenceSystem(this.referenceSystem);
141 //no changes to: errorRadius, latitude, longitude
142 return result;
143 } catch (CloneNotSupportedException e) {
144 logger.warn("Object does not implement cloneable");
145 e.printStackTrace();
146 return null;
147 }
148 }
149
150
151 }