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.crs;
017:
018: // J2SE dependencies
019: import java.util.Arrays;
020: import java.util.Iterator;
021: import java.util.Set;
022:
023: // OpenGIS dependencies
024: import org.opengis.metadata.citation.Citation;
025: import org.opengis.referencing.crs.CoordinateReferenceSystem;
026:
027: // Geotools dependencies
028: import org.geotools.referencing.CRS;
029: import org.geotools.referencing.NamedIdentifier;
030: import org.geotools.metadata.iso.citation.Citations;
031:
032: // JUnit dependencies
033: import junit.framework.TestCase;
034:
035: /**
036: * These EPSG support.
037: *
038: * @author Jody Garnett
039: * @since 2.1.M3
040: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/epsg-wkt/src/test/java/org/geotools/referencing/crs/EPSGTest.java $
041: * @version 2.1.M3
042: */
043: public class EPSGTest extends TestCase {
044: EPSGCRSAuthorityFactory factory;
045:
046: /*
047: * @see junit.framework.TestCase#setUp()
048: */
049: protected void setUp() throws Exception {
050: super .setUp();
051: factory = new EPSGCRSAuthorityFactory();
052: }
053:
054: public void testAuthority() {
055: Citation authority = factory.getAuthority();
056:
057: assertNotNull(authority);
058: assertEquals("European Petroleum Survey Group", authority
059: .getTitle().toString());
060: assertTrue(authority.getIdentifiers().contains("EPSG"));
061: }
062:
063: public void testVendor() {
064: Citation vendor = factory.getVendor();
065: assertNotNull(vendor);
066: assertEquals("Geotools", vendor.getTitle().toString());
067: }
068:
069: public void testCodes() throws Exception {
070: Set codes = factory
071: .getAuthorityCodes(CoordinateReferenceSystem.class);
072:
073: assertNotNull(codes);
074: assertEquals(2798, codes.size());
075: }
076:
077: /**
078: * A random CRS for fun.
079: */
080: public void test26910() throws Exception {
081: CoordinateReferenceSystem crs = (CoordinateReferenceSystem) factory
082: .createObject("EPSG:26910");
083: assertNotNull(crs);
084: }
085:
086: /** UDIG requires this to work */
087: public void test4326() throws Exception {
088: CoordinateReferenceSystem crs = (CoordinateReferenceSystem) factory
089: .createObject("EPSG:4326");
090: assertNotNull(crs);
091: }
092:
093: /** UDIG requires this to work */
094: public void test4269() throws Exception {
095: CoordinateReferenceSystem crs = (CoordinateReferenceSystem) factory
096: .createObject("EPSG:4269");
097: assertNotNull(crs);
098: }
099:
100: /** UDIG requires this to work */
101: public void test42102() throws Exception {
102: CoordinateReferenceSystem crs = (CoordinateReferenceSystem) factory
103: .createObject("EPSG:42102");
104: assertNotNull(crs);
105: assertNotNull(crs.getIdentifiers());
106: assertTrue(crs.getIdentifiers().size() > 0);
107: NamedIdentifier expected = new NamedIdentifier(Citations.EPSG,
108: "42102");
109: assertTrue(crs.getIdentifiers().contains(expected));
110: }
111:
112: public void testSuccess() throws Exception {
113: Set codes = factory
114: .getAuthorityCodes(CoordinateReferenceSystem.class);
115: int total = codes.size();
116: int count = 0;
117:
118: for (Iterator i = codes.iterator(); i.hasNext();) {
119: CoordinateReferenceSystem crs;
120: String code = (String) i.next();
121: try {
122: crs = (CoordinateReferenceSystem) factory
123: .createObject(code);
124: if (crs != null)
125: count++;
126: } catch (Throwable e) {
127: System.err.println("WARNING (CRS: " + code + " ):" + e);
128: }
129: }
130: System.out.println("success:" + count + "/" + total);
131: }
132:
133: /**
134: * A random CRS for fun.
135: */
136: public void test26910Lower() throws Exception {
137: CoordinateReferenceSystem crs = CRS.decode("epsg:26910");
138: assertNotNull(crs);
139: }
140:
141: /**
142: * A random CRS for fun.
143: */
144: public void test26986Lower() throws Exception {
145: CoordinateReferenceSystem crs = CRS.decode("epsg:26986");
146: assertNotNull(crs);
147: }
148:
149: /** wfs requires this to work */
150: public void test4326Lower() throws Exception {
151: CoordinateReferenceSystem crs = CRS.decode("epsg:4326");
152: assertNotNull(crs);
153: }
154:
155: /** wfs requires this to work */
156: public void test26742Lower() throws Exception {
157: CoordinateReferenceSystem crs = CRS.decode("epsg:26742");
158: assertNotNull(crs);
159: }
160:
161: /** wfs requires this to work */
162: public void test4269Lower() throws Exception {
163: CoordinateReferenceSystem crs = CRS.decode("epsg:4269");
164: assertNotNull(crs);
165: }
166:
167: /** wfs requires this to work */
168: public void test42304Lower() throws Exception {
169: CoordinateReferenceSystem crs = CRS.decode("epsg:42304");
170: assertNotNull(crs);
171: }
172:
173: /** wfs requires this to work */
174: public void test42102Lower() throws Exception {
175: CoordinateReferenceSystem crs = CRS.decode("epsg:42102");
176: assertNotNull(crs);
177: assertNotNull(crs.getIdentifiers());
178: assertTrue(crs.getIdentifiers().size() > 0);
179: NamedIdentifier expected = new NamedIdentifier(Citations.EPSG,
180: "42102");
181: assertTrue(crs.getIdentifiers().contains(expected));
182: }
183: }
|