Source Code Cross Referenced for AutoCRSFactory.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » factory » wms » 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.factory.wms 
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:         *   
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.referencing.factory.wms;
017:
018:        // J2SE dependencies
019:        import java.util.Map;
020:        import java.util.TreeMap;
021:        import java.util.Iterator;
022:        import java.util.Collections;
023:        import java.util.Set;
024:        import java.util.LinkedHashSet;
025:
026:        // OpenGIS dependencies
027:        import org.opengis.util.InternationalString;
028:        import org.opengis.metadata.citation.Citation;
029:        import org.opengis.referencing.FactoryException;
030:        import org.opengis.referencing.IdentifiedObject;
031:        import org.opengis.referencing.NoSuchAuthorityCodeException;
032:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
033:        import org.opengis.referencing.crs.CRSAuthorityFactory;
034:        import org.opengis.referencing.crs.ProjectedCRS;
035:
036:        // Geotools dependencies
037:        import org.geotools.factory.Hints;
038:        import org.geotools.util.SimpleInternationalString;
039:        import org.geotools.metadata.iso.citation.Citations;
040:        import org.geotools.metadata.iso.citation.CitationImpl;
041:        import org.geotools.referencing.factory.DirectAuthorityFactory;
042:
043:        /**
044:         * The factory for {@linkplain ProjectedCRS projected CRS} in the {@code AUTO} and {@code AUTO2}
045:         * space.
046:         *
047:         * @since 2.2
048:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/factory/wms/AutoCRSFactory.java $
049:         * @version $Id: AutoCRSFactory.java 27544 2007-10-18 19:16:40Z desruisseaux $
050:         * @author Jody Garnett
051:         * @author Rueben Schulz
052:         * @author Martin Desruisseaux
053:         *
054:         * @deprecated This class will move in a <code>org.geotools.referencing.factory.<strong>web</strong></code>
055:         *             package in Geotools 2.5, in order to put together other web-related factories defined
056:         *             outside the WMS specification. Don't use this class directly. You should not need to
057:         *             anyway - use {@link org.geotools.referencing.ReferencingFactoryFinder} instead, which
058:         *             will continue to work no matter where this class is located.
059:         */
060:        public class AutoCRSFactory extends DirectAuthorityFactory implements 
061:                CRSAuthorityFactory {
062:            /**
063:             * The authority code. We use {@code AUTO2} citation, but merge {@code AUTO} and
064:             * {@code AUTO2} identifiers in order to use the same factory for both authorities.
065:             */
066:            private static final Citation AUTHORITY;
067:            static {
068:                final CitationImpl c = new CitationImpl(Citations.AUTO2);
069:                c.getIdentifiers().addAll(Citations.AUTO.getIdentifiers());
070:                AUTHORITY = (Citation) c.unmodifiable();
071:            }
072:
073:            /**
074:             * Map of Factlets by integer code (from {@code AUTO:code}).
075:             *
076:             * @todo Replace this with full FactorySPI system.
077:             */
078:            private final Map factlets = new TreeMap();
079:
080:            /**
081:             * Constructs a default factory for the {@code AUTO} authority.
082:             */
083:            public AutoCRSFactory() {
084:                this (null);
085:            }
086:
087:            /**
088:             * Constructs a factory for the {@code AUTO} authority using the specified hints.
089:             */
090:            public AutoCRSFactory(final Hints hints) {
091:                super (hints, NORMAL_PRIORITY);
092:                add(Auto42001.DEFAULT);
093:                add(Auto42002.DEFAULT);
094:                add(Auto42003.DEFAULT);
095:                add(Auto42004.DEFAULT);
096:                add(Auto42005.DEFAULT);
097:            }
098:
099:            /**
100:             * Add the specified factlet.
101:             */
102:            private void add(final Factlet f) {
103:                final int code = f.code();
104:                if (factlets.put(new Integer(code), f) != null) {
105:                    throw new IllegalArgumentException(String.valueOf(code));
106:                }
107:            }
108:
109:            /**
110:             * Returns the {@link Factlet} for the given code.
111:             *
112:             * @param  code The code.
113:             * @return The fatclet for the specified code.
114:             * @throws NoSuchAuthorityCodeException if no factlet has been found for the specified code.
115:             */
116:            private Factlet findFactlet(final Code code)
117:                    throws NoSuchAuthorityCodeException {
118:                if (code.authority.equalsIgnoreCase("AUTO")
119:                        || code.authority.equalsIgnoreCase("AUTO2")) {
120:                    final Integer key = new Integer(code.code);
121:                    final Factlet fac = (Factlet) factlets.get(key);
122:                    if (fac != null) {
123:                        return fac;
124:                    }
125:                }
126:                throw noSuchAuthorityCode(code.type, code.toString());
127:            }
128:
129:            /**
130:             * Returns the authority for this factory.
131:             */
132:            public Citation getAuthority() {
133:                return AUTHORITY;
134:            }
135:
136:            /**
137:             * Provides a complete set of the known codes provided by this authority.
138:             * The returned set contains only numeric identifiers like {@code "42001"},
139:             * {@code "42002"}, <cite>etc</cite>. The authority name ({@code "AUTO"})
140:             * and the {@code lon0,lat0} part are not included. This is consistent with the
141:             * {@linkplain org.geotools.referencing.factory.epsg.DirectEpsgFactory#getAuthorityCodes
142:             * codes returned by the EPSG factory} and avoid duplication, since the authority is the
143:             * same for every codes returned by this factory. It also make it easier for clients to
144:             * prepend whatever authority name they wish, as for example in the
145:             * {@linkplain org.geotools.referencing.factory.AllAuthoritiesFactory#getAuthorityCodes
146:             * all authorities factory}.
147:             */
148:            public Set getAuthorityCodes(final Class type)
149:                    throws FactoryException {
150:                if (type.isAssignableFrom(ProjectedCRS.class)) {
151:                    final Set set = new LinkedHashSet();
152:                    for (final Iterator it = factlets.keySet().iterator(); it
153:                            .hasNext();) {
154:                        Integer code = (Integer) it.next();
155:                        set.add(String.valueOf(code));
156:                    }
157:                    return set;
158:                } else {
159:                    return Collections.EMPTY_SET;
160:                }
161:            }
162:
163:            /**
164:             * Returns the CRS name for the given code.
165:             */
166:            public InternationalString getDescriptionText(final String code)
167:                    throws FactoryException {
168:                final Code c = new Code(code, ProjectedCRS.class);
169:                return new SimpleInternationalString(findFactlet(c).getName());
170:            }
171:
172:            /**
173:             * Creates an object from the specified code. The default implementation delegates to
174:             * <code>{@linkplain #createCoordinateReferenceSystem createCoordinateReferenceSystem}(code)</code>.
175:             */
176:            public IdentifiedObject createObject(final String code)
177:                    throws FactoryException {
178:                return createCoordinateReferenceSystem(code);
179:            }
180:
181:            /**
182:             * Creates a coordinate reference system from the specified code. The default implementation
183:             * delegates to <code>{@linkplain #createProjectedCRS createProjectedCRS}(code)</code>.
184:             */
185:            public CoordinateReferenceSystem createCoordinateReferenceSystem(
186:                    final String code) throws FactoryException {
187:                return createProjectedCRS(code);
188:            }
189:
190:            /**
191:             * Creates a projected coordinate reference system from the specified code.
192:             */
193:            public ProjectedCRS createProjectedCRS(final String code)
194:                    throws FactoryException {
195:                final Code c = new Code(code, ProjectedCRS.class);
196:                return findFactlet(c).create(c, factories);
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.