Source Code Cross Referenced for ExtentImpl.java in  » GIS » GeoTools-2.4.1 » org » geotools » metadata » iso » extent » 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.metadata.iso.extent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005:         *    (C) 2004, 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.metadata.iso.extent;
021:
022:        // J2SE dependencies
023:        import java.util.Iterator;
024:        import java.util.Collection;
025:
026:        // OpenGIS dependencies
027:        import org.opengis.metadata.extent.Extent;
028:        import org.opengis.metadata.extent.BoundingPolygon;
029:        import org.opengis.metadata.extent.GeographicExtent;
030:        import org.opengis.metadata.extent.GeographicBoundingBox;
031:        import org.opengis.metadata.extent.TemporalExtent;
032:        import org.opengis.metadata.extent.VerticalExtent;
033:        import org.opengis.util.InternationalString;
034:
035:        // Geotools dependencies
036:        import org.geotools.metadata.iso.MetadataEntity;
037:
038:        /**
039:         * Information about spatial, vertical, and temporal extent.
040:         * This interface has four optional attributes
041:         * ({@linkplain #getGeographicElements geographic elements},
042:         *  {@linkplain #getTemporalElements temporal elements}, and
043:         *  {@linkplain #getVerticalElements vertical elements}) and an element called
044:         *  {@linkplain #getDescription description}.
045:         *  At least one of the four shall be used.
046:         *
047:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/extent/ExtentImpl.java $
048:         * @version $Id: ExtentImpl.java 25189 2007-04-17 13:23:47Z desruisseaux $
049:         * @author Martin Desruisseaux
050:         * @author Touraïvane
051:         *
052:         * @since 2.1
053:         */
054:        public class ExtentImpl extends MetadataEntity implements  Extent {
055:            /**
056:             * Serial number for interoperability with different versions.
057:             */
058:            private static final long serialVersionUID = 7812213837337326257L;
059:
060:            /**
061:             * A geographic extent ranging from 180°W to 180°E and 90°S to 90°N.
062:             *
063:             * @since 2.2
064:             */
065:            public static final Extent WORLD;
066:            static {
067:                final ExtentImpl world = new ExtentImpl();
068:                world.getGeographicElements().add(
069:                        GeographicBoundingBoxImpl.WORLD);
070:                world.freeze();
071:                WORLD = world;
072:            }
073:
074:            /**
075:             * Returns the spatial and temporal extent for the referring object.
076:             */
077:            private InternationalString description;
078:
079:            /**
080:             * Provides geographic component of the extent of the referring object
081:             */
082:            private Collection/*<GeographicExtent>*/geographicElements;
083:
084:            /**
085:             * Provides temporal component of the extent of the referring object
086:             */
087:            private Collection/*<TemporalExtent>*/temporalElements;
088:
089:            /**
090:             * Provides vertical component of the extent of the referring object
091:             */
092:            private Collection/*<VerticalExtent>*/verticalElements;
093:
094:            /**
095:             * Constructs an initially empty extent.
096:             */
097:            public ExtentImpl() {
098:            }
099:
100:            /**
101:             * Constructs a metadata entity initialized with the values from the specified metadata.
102:             *
103:             * @since 2.4
104:             */
105:            public ExtentImpl(final Extent source) {
106:                super (source);
107:            }
108:
109:            /**
110:             * Returns the spatial and temporal extent for the referring object.
111:             */
112:            public InternationalString getDescription() {
113:                return description;
114:            }
115:
116:            /**
117:             * Set the spatial and temporal extent for the referring object.
118:             */
119:            public synchronized void setDescription(
120:                    final InternationalString newValue) {
121:                checkWritePermission();
122:                description = newValue;
123:            }
124:
125:            /**
126:             * Provides geographic component of the extent of the referring object
127:             */
128:            public synchronized Collection/*<GeographicExtent>*/getGeographicElements() {
129:                return geographicElements = nonNullCollection(
130:                        geographicElements, GeographicExtent.class);
131:            }
132:
133:            /**
134:             * Set geographic component of the extent of the referring object
135:             */
136:            public synchronized void setGeographicElements(
137:                    final Collection/*<GeographicExtent>*/newValues) {
138:                geographicElements = copyCollection(newValues,
139:                        geographicElements, GeographicExtent.class);
140:            }
141:
142:            /**
143:             * Provides temporal component of the extent of the referring object
144:             */
145:            public synchronized Collection/*<TemporalExtent>*/getTemporalElements() {
146:                return temporalElements = nonNullCollection(temporalElements,
147:                        TemporalExtent.class);
148:            }
149:
150:            /**
151:             * Set temporal component of the extent of the referring object
152:             */
153:            public synchronized void setTemporalElements(
154:                    final Collection/*<TemporalExtent>*/newValues) {
155:                temporalElements = copyCollection(newValues, temporalElements,
156:                        TemporalExtent.class);
157:            }
158:
159:            /**
160:             * Provides vertical component of the extent of the referring object
161:             */
162:            public synchronized Collection/*<VerticalExtent>*/getVerticalElements() {
163:                return verticalElements = nonNullCollection(verticalElements,
164:                        VerticalExtent.class);
165:            }
166:
167:            /**
168:             * Set vertical component of the extent of the referring object
169:             */
170:            public synchronized void setVerticalElements(
171:                    final Collection/*<VerticalExtent>*/newValues) {
172:                verticalElements = copyCollection(newValues, verticalElements,
173:                        VerticalExtent.class);
174:            }
175:
176:            /**
177:             * Convenience method returning a single geographic bounding box from the specified extent.
178:             * If no bounding box was found, then this method returns {@code null}. If more than one box
179:             * is found, then boxes are {@linkplain GeographicBoundingBoxImpl#add added} together.
180:             *
181:             * @since 2.2
182:             */
183:            public static GeographicBoundingBox getGeographicBoundingBox(
184:                    final Extent extent) {
185:                GeographicBoundingBox candidate = null;
186:                if (extent != null) {
187:                    GeographicBoundingBoxImpl modifiable = null;
188:                    for (final Iterator it = extent.getGeographicElements()
189:                            .iterator(); it.hasNext();) {
190:                        final GeographicExtent element = (GeographicExtent) it
191:                                .next();
192:                        final GeographicBoundingBox bounds;
193:                        if (element instanceof  GeographicBoundingBox) {
194:                            bounds = (GeographicBoundingBox) element;
195:                        } else if (element instanceof  BoundingPolygon) {
196:                            // TODO: iterates through all polygons and invoke Polygon.getEnvelope();
197:                            continue;
198:                        } else {
199:                            continue;
200:                        }
201:                        /*
202:                         * A single geographic bounding box has been extracted. Now add it to previous
203:                         * ones (if any). All exclusion boxes before the first inclusion box are ignored.
204:                         */
205:                        if (candidate == null) {
206:                            /*
207:                             * Reminder: 'inclusion' is a mandatory attribute, so it should never be
208:                             * null for a valid metadata object.  If the metadata object is invalid,
209:                             * it is better to get an exception than having a code doing silently
210:                             * some probably inappropriate work.
211:                             */
212:                            final Boolean inclusion = bounds.getInclusion();
213:                            ensureNonNull("inclusion", inclusion);
214:                            if (inclusion.booleanValue()) {
215:                                candidate = bounds;
216:                            }
217:                        } else {
218:                            if (modifiable == null) {
219:                                modifiable = new GeographicBoundingBoxImpl(
220:                                        candidate);
221:                                candidate = modifiable;
222:                            }
223:                            modifiable.add(bounds);
224:                        }
225:                    }
226:                    if (modifiable != null) {
227:                        modifiable.freeze();
228:                    }
229:                }
230:                return candidate;
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.