Source Code Cross Referenced for AbstractDatum.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » datum » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.referencing.datum 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, GeoTools Project Managment Committee (PMC)
005:         *    (C) 2001, Institut de Recherche pour le Développement
006:         *   
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation;
010:         *    version 2.1 of the License.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         *
017:         *    This package contains documentation from OpenGIS specifications.
018:         *    OpenGIS consortium's work is fully acknowledged here.
019:         */
020:        package org.geotools.referencing.datum;
021:
022:        // J2SE dependencies
023:        import java.util.Date;
024:        import java.util.HashMap;
025:        import java.util.Map;
026:
027:        // OpenGIS dependencies
028:        import org.opengis.metadata.extent.Extent;
029:        import org.opengis.referencing.datum.Datum;
030:        import org.opengis.util.InternationalString;
031:
032:        // Geotools dependencies
033:        import org.geotools.referencing.AbstractIdentifiedObject;
034:        import org.geotools.referencing.wkt.Formatter;
035:        import org.geotools.resources.Utilities;
036:
037:        /**
038:         * Specifies the relationship of a coordinate system to the earth, thus creating a {@linkplain
039:         * org.opengis.referencing.crs.CoordinateReferenceSystem coordinate reference system}. A datum
040:         * uses a parameter or set of parameters that determine the location of the origin of the coordinate
041:         * reference system. Each datum subtype can be associated with only specific types of
042:         * {@linkplain org.opengis.referencing.cs.AbstractCS coordinate systems}.
043:         * <p>
044:         * A datum can be defined as a set of real points on the earth that have coordinates.
045:         * The definition of the datum may also include the temporal behavior (such as the
046:         * rate of change of the orientation of the coordinate axes).
047:         * <p>
048:         * This class is conceptually <cite>abstract</cite>, even if it is technically possible to
049:         * instantiate it. Typical applications should create instances of the most specific subclass with
050:         * {@code Default} prefix instead. An exception to this rule may occurs when it is not possible to
051:         * identify the exact type.
052:         *
053:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/datum/AbstractDatum.java $
054:         * @version $Id: AbstractDatum.java 28264 2007-12-05 21:53:08Z desruisseaux $
055:         * @author Martin Desruisseaux
056:         *
057:         * @since 2.1
058:         *
059:         * @see org.geotools.referencing.cs.AbstractCS
060:         * @see org.geotools.referencing.crs.AbstractCRS
061:         */
062:        public class AbstractDatum extends AbstractIdentifiedObject implements 
063:                Datum {
064:            /**
065:             * Serial number for interoperability with different versions.
066:             */
067:            private static final long serialVersionUID = -4894180465652474930L;
068:
069:            /**
070:             * List of localizable properties. To be given to
071:             * {@link AbstractIdentifiedObject} constructor.
072:             */
073:            private static final String[] LOCALIZABLES = { ANCHOR_POINT_KEY,
074:                    SCOPE_KEY };
075:
076:            /**
077:             * Description, possibly including coordinates, of the point or points used to anchor the datum
078:             * to the Earth. Also known as the "origin", especially for Engineering and Image Datums.
079:             */
080:            private final InternationalString anchorPoint;
081:
082:            /**
083:             * The time after which this datum definition is valid. This time may be precise
084:             * (e.g. 1997 for IRTF97) or merely a year (e.g. 1983 for NAD83). If the time is
085:             * not defined, then the value is {@link Long#MIN_VALUE}.
086:             */
087:            private final long realizationEpoch;
088:
089:            /**
090:             * Area or region in which this datum object is valid.
091:             */
092:            private final Extent domainOfValidity;
093:
094:            /**
095:             * Description of domain of usage, or limitations of usage, for which this
096:             * datum object is valid.
097:             */
098:            private final InternationalString scope;
099:
100:            /**
101:             * Constructs a new datum with the same values than the specified one.
102:             * This copy constructor provides a way to wrap an arbitrary implementation into a
103:             * Geotools one or a user-defined one (as a subclass), usually in order to leverage
104:             * some implementation-specific API. This constructor performs a shallow copy,
105:             * i.e. the properties are not cloned.
106:             *
107:             * @since 2.2
108:             */
109:            public AbstractDatum(final Datum datum) {
110:                super (datum);
111:                final Date epoch = datum.getRealizationEpoch();
112:                realizationEpoch = (epoch != null) ? epoch.getTime()
113:                        : Long.MIN_VALUE;
114:                domainOfValidity = datum.getDomainOfValidity();
115:                scope = datum.getScope();
116:                anchorPoint = datum.getAnchorPoint();
117:            }
118:
119:            /**
120:             * Constructs a datum from a set of properties. The properties given in argument follow
121:             * the same rules than for the {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map)
122:             * super-class constructor}. Additionally, the following properties are understood by this
123:             * construtor:
124:             * <br><br>
125:             * <table border='1'>
126:             *   <tr bgcolor="#CCCCFF" class="TableHeadingColor">
127:             *     <th nowrap>Property name</th>
128:             *     <th nowrap>Value type</th>
129:             *     <th nowrap>Value given to</th>
130:             *   </tr>
131:             *   <tr>
132:             *     <td nowrap>&nbsp;{@link #ANCHOR_POINT_KEY "anchorPoint"}&nbsp;</td>
133:             *     <td nowrap>&nbsp;{@link InternationalString} or {@link String}&nbsp;</td>
134:             *     <td nowrap>&nbsp;{@link #getAnchorPoint}</td>
135:             *   </tr>
136:             *   <tr>
137:             *     <td nowrap>&nbsp;{@link #REALIZATION_EPOCH_KEY "realizationEpoch"}&nbsp;</td>
138:             *     <td nowrap>&nbsp;{@link Date}&nbsp;</td>
139:             *     <td nowrap>&nbsp;{@link #getRealizationEpoch}</td>
140:             *   </tr>
141:             *   <tr>
142:             *     <td nowrap>&nbsp;{@link #DOMAIN_OF_VALIDITY_KEY "domainOfValidity"}&nbsp;</td>
143:             *     <td nowrap>&nbsp;{@link Extent}&nbsp;</td>
144:             *     <td nowrap>&nbsp;{@link #getDomainOfValidity}</td>
145:             *   </tr>
146:             *   <tr>
147:             *     <td nowrap>&nbsp;{@link #SCOPE_KEY "scope"}&nbsp;</td>
148:             *     <td nowrap>&nbsp;{@link InternationalString} or {@link String}&nbsp;</td>
149:             *     <td nowrap>&nbsp;{@link #getScope}</td>
150:             *   </tr>
151:             * </table>
152:             */
153:            public AbstractDatum(final Map properties) {
154:                this (properties, new HashMap());
155:            }
156:
157:            /**
158:             * Work around for RFE #4093999 in Sun's bug database
159:             * ("Relax constraint on placement of this()/super() call in constructors").
160:             */
161:            private AbstractDatum(final Map properties, final Map subProperties) {
162:                super (properties, subProperties, LOCALIZABLES);
163:                final Date realizationEpoch;
164:                anchorPoint = (InternationalString) subProperties
165:                        .get(ANCHOR_POINT_KEY);
166:                realizationEpoch = (Date) subProperties
167:                        .get(REALIZATION_EPOCH_KEY);
168:                domainOfValidity = (Extent) subProperties
169:                        .get(DOMAIN_OF_VALIDITY_KEY);
170:                scope = (InternationalString) subProperties.get(SCOPE_KEY);
171:                this .realizationEpoch = (realizationEpoch != null) ? realizationEpoch
172:                        .getTime()
173:                        : Long.MIN_VALUE;
174:            }
175:
176:            /**
177:             * Description, possibly including coordinates, of the point or points used to anchor the datum
178:             * to the Earth. Also known as the "origin", especially for Engineering and Image Datums.
179:             *
180:             * <ul>
181:             *   <li>For a geodetic datum, this point is also known as the fundamental point, which is
182:             *       traditionally the point where the relationship between geoid and ellipsoid is defined.
183:             *       In some cases, the "fundamental point" may consist of a number of points. In those
184:             *       cases, the parameters defining the geoid/ellipsoid relationship have then been averaged
185:             *       for these points, and the averages adopted as the datum definition.</li>
186:             *
187:             *   <li>For an engineering datum, the anchor point may be a physical point, or it may be a
188:             *       point with defined coordinates in another CRS.</li>
189:             *
190:             *   <li>For an image datum, the anchor point is usually either the centre of the image or the
191:             *       corner of the image.</li>
192:             *
193:             *   <li>For a temporal datum, this attribute is not defined. Instead of the anchor point,
194:             *       a temporal datum carries a separate time origin of type {@link Date}.</li>
195:             * </ul>
196:             */
197:            public InternationalString getAnchorPoint() {
198:                return anchorPoint;
199:            }
200:
201:            /**
202:             * The time after which this datum definition is valid. This time may be precise (e.g. 1997
203:             * for IRTF97) or merely a year (e.g. 1983 for NAD83). In the latter case, the epoch usually
204:             * refers to the year in which a major recalculation of the geodetic control network, underlying
205:             * the datum, was executed or initiated. An old datum can remain valid after a new datum is
206:             * defined. Alternatively, a datum may be superseded by a later datum, in which case the
207:             * realization epoch for the new datum defines the upper limit for the validity of the
208:             * superseded datum.
209:             */
210:            public Date getRealizationEpoch() {
211:                return (realizationEpoch != Long.MIN_VALUE) ? new Date(
212:                        realizationEpoch) : null;
213:            }
214:
215:            /**
216:             * Area or region or timeframe in which this datum is valid.
217:             *
218:             * @since 2.4
219:             */
220:            public Extent getDomainOfValidity() {
221:                return domainOfValidity;
222:            }
223:
224:            /**
225:             * Area or region in which this datum object is valid.
226:             *
227:             * @deprecated Renamed {@link #getDomainOfValidity}.
228:             */
229:            public Extent getValidArea() {
230:                return domainOfValidity;
231:            }
232:
233:            /**
234:             * Description of domain of usage, or limitations of usage, for which this
235:             * datum object is valid.
236:             */
237:            public InternationalString getScope() {
238:                return scope;
239:            }
240:
241:            /**
242:             * Gets the type of the datum as an enumerated code. Datum type was provided
243:             * for all kind of datum in the legacy OGC 01-009 specification. In the new
244:             * OGC 03-73 (ISO 19111) specification, datum type is provided only for
245:             * vertical datum. Nevertheless, we keep this method around since it is
246:             * needed for WKT formatting. Note that we returns the datum type ordinal
247:             * value, not the code list object.
248:             */
249:            int getLegacyDatumType() {
250:                return 0;
251:            }
252:
253:            /**
254:             * Compares the specified object with this datum for equality.
255:             *
256:             * @param  object The object to compare to {@code this}.
257:             * @param  compareMetadata {@code true} for performing a strict comparaison, or
258:             *         {@code false} for comparing only properties relevant to transformations.
259:             * @return {@code true} if both objects are equal.
260:             */
261:            public boolean equals(final AbstractIdentifiedObject object,
262:                    final boolean compareMetadata) {
263:                if (super .equals(object, compareMetadata)) {
264:                    if (!compareMetadata) {
265:                        /*
266:                         * Tests for name, since datum with different name have completly
267:                         * different meaning. We don't perform this comparaison if the user
268:                         * asked for metadata comparaison, because in such case the names
269:                         * have already been compared by the subclass.
270:                         */
271:                        return nameMatches(object.getName().getCode())
272:                                || object.nameMatches(getName().getCode());
273:                    }
274:                    final AbstractDatum that = (AbstractDatum) object;
275:                    return this .realizationEpoch == that.realizationEpoch
276:                            && Utilities.equals(this .domainOfValidity,
277:                                    that.domainOfValidity)
278:                            && Utilities.equals(this .anchorPoint,
279:                                    that.anchorPoint)
280:                            && Utilities.equals(this .scope, that.scope);
281:                }
282:                return false;
283:            }
284:
285:            /**
286:             * Format the inner part of a
287:             * <A HREF="http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html"><cite>Well
288:             * Known Text</cite> (WKT)</A> element.
289:             *
290:             * Note: All subclasses will override this method, but only {@link DefaultGeodeticDatum} will
291:             *       <strong>not</strong> invokes this parent method, because horizontal datum do not write
292:             *       the datum type.
293:             *
294:             * @param  formatter The formatter to use.
295:             * @return The WKT element name.
296:             */
297:            protected String formatWKT(final Formatter formatter) {
298:                formatter.append(getLegacyDatumType());
299:                return Utilities.getShortClassName(this);
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.