Source Code Cross Referenced for Altitude.java in  » Science » jscience-4.3.1 » org » jscience » geography » coordinates » 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 » Science » jscience 4.3.1 » org.jscience.geography.coordinates 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
003:         * Copyright (C) 2006 - JScience (http://jscience.org/)
004:         * All rights reserved.
005:         * 
006:         * Permission to use, copy, modify, and distribute this software is
007:         * freely granted, provided that this notice is preserved.
008:         */
009:        package org.jscience.geography.coordinates;
010:
011:        import javax.measure.quantity.Length;
012:        import javax.measure.Measurable;
013:        import static javax.measure.unit.SI.METRE;
014:        import javax.measure.unit.Unit;
015:
016:        import javolution.context.ObjectFactory;
017:        import javolution.xml.XMLFormat;
018:        import javolution.xml.stream.XMLStreamException;
019:
020:        import org.jscience.geography.coordinates.crs.VerticalCRS;
021:        import org.opengis.referencing.cs.CoordinateSystem;
022:
023:        /**
024:         * This class represents the Mean-Sea-Level {@link VerticalCRS vertical} 
025:         * altitude (MSL).
026:         *  
027:         * <p> Note: The current implementation approximates the MSL altitude to 
028:         *           the WGS-86 Ellipsoid Height. Future implementations will use 
029:         *           lookup tables in order to correct for regional discrepencies.</p> 
030:         * 
031:         * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
032:         * @version 3.0, February 26, 2006
033:         */
034:        public final class Altitude extends Coordinates<VerticalCRS<?>>
035:                implements  Measurable<Length> {
036:
037:            /**
038:             * Holds the coordinate reference system for all instances of this class. 
039:             */
040:            public static final VerticalCRS<Altitude> CRS = new VerticalCRS<Altitude>() {
041:
042:                @Override
043:                protected Altitude coordinatesOf(AbsolutePosition position) {
044:                    return Altitude.valueOf(position.heightWGS84
045:                            .doubleValue(METRE), METRE);
046:                }
047:
048:                @Override
049:                protected AbsolutePosition positionOf(Altitude coordinates,
050:                        AbsolutePosition position) {
051:                    position.heightWGS84 = coordinates;
052:                    return position;
053:                }
054:
055:                @Override
056:                public CoordinateSystem getCoordinateSystem() {
057:                    return VerticalCRS.HEIGHT_CS;
058:                }
059:            };
060:
061:            /**
062:             * Holds the altitude value in meters. 
063:             */
064:            private double _meters;
065:
066:            /**
067:             * Returns the vertical position corresponding to the specified coordinates.
068:             * 
069:             * @param value the mean sea level altitude stated in the specified unit.
070:             * @param unit the length unit in which the altitude is stated.
071:             * @return the corresponding vertical position.
072:             */
073:            public static Altitude valueOf(double value, Unit<Length> unit) {
074:                Altitude altitude = FACTORY.object();
075:                altitude._meters = (unit == METRE) ? value : unit
076:                        .getConverterTo(METRE).convert(value);
077:                return altitude;
078:            }
079:
080:            private static final ObjectFactory<Altitude> FACTORY = new ObjectFactory<Altitude>() {
081:
082:                @Override
083:                protected Altitude create() {
084:                    return new Altitude();
085:                }
086:            };
087:
088:            private Altitude() {
089:            }
090:
091:            @Override
092:            public VerticalCRS<?> getCoordinateReferenceSystem() {
093:                return Altitude.CRS;
094:            }
095:
096:            // OpenGIS Interface.
097:            public int getDimension() {
098:                return 1;
099:            }
100:
101:            // OpenGIS Interface.
102:            public double getOrdinate(int dimension)
103:                    throws IndexOutOfBoundsException {
104:                if (dimension == 0) {
105:                    Unit<?> u = VerticalCRS.HEIGHT_CS.getAxis(0).getUnit();
106:                    return METRE.getConverterTo(u).convert(_meters);
107:                } else {
108:                    throw new IndexOutOfBoundsException();
109:                }
110:            }
111:
112:            // Implements Scalar<Length>
113:            public final double doubleValue(Unit<Length> unit) {
114:                return (unit == METRE) ? _meters : METRE.getConverterTo(unit)
115:                        .convert(_meters);
116:            }
117:
118:            // Implements Scalar<Length>
119:            public final long longValue(Unit<Length> unit) {
120:                return Math.round(doubleValue(unit));
121:            }
122:
123:            // Implements Scalar<Length>
124:            public int compareTo(Measurable<Length> measure) {
125:                double meters = measure.doubleValue(METRE);
126:                return (_meters > meters) ? 1 : (_meters < meters) ? -1 : 0;
127:            }
128:
129:            @Override
130:            public Altitude copy() {
131:                return Altitude.valueOf(_meters, METRE);
132:            }
133:
134:            // Default serialization.
135:            //
136:
137:            static final XMLFormat<Altitude> XML = new XMLFormat<Altitude>(
138:                    Altitude.class) {
139:
140:                @Override
141:                public Altitude newInstance(Class<Altitude> cls,
142:                        InputElement xml) throws XMLStreamException {
143:                    return FACTORY.object();
144:                }
145:
146:                public void write(Altitude altitude, OutputElement xml)
147:                        throws XMLStreamException {
148:                    xml.setAttribute("meters", altitude._meters);
149:                }
150:
151:                public void read(InputElement xml, Altitude altitude)
152:                        throws XMLStreamException {
153:                    altitude._meters = xml.getAttribute("meters", 0.0);
154:                }
155:            };
156:
157:            private static final long serialVersionUID = 1L;
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.