Revision 828 org.gvsig.geotools.proj/trunk/org.gvsig.geotools.proj/org.gvsig.geotools.proj.catalog.impl/src/main/java/org/gvsig/geotools/proj/catalog/GtCRSCatalogManager.java

View differences:

GtCRSCatalogManager.java
32 32
import org.gvsig.proj.catalog.TransformationDefinition;
33 33
import org.gvsig.proj.catalog.exception.CoordinateReferenceSystemException;
34 34
import org.gvsig.proj.catalog.exception.UnsupportedCoordinateReferenceSystemException;
35
import org.gvsig.proj.catalog.exception.UnsupportedFormatException;
35 36
import org.gvsig.proj.catalog.exception.UnsupportedTransformationException;
36 37
import org.opengis.referencing.FactoryException;
37 38
import org.opengis.referencing.NoSuchAuthorityCodeException;
......
197 198
            throw exception;
198 199
        }
199 200
        conn.close();
200
        System.out.println(codes.size());
201 201
        return codes;
202 202
    }
203 203

  
......
211 211
		} catch (FactoryException e) {
212 212
			throw new UnsupportedCoordinateReferenceSystemException(code, e);
213 213
		}
214
		return new DefaultCRS(crs);
214
		return new DefaultCRSDefinition(crs);
215 215
	}
216 216
	
217 217
	public CRSDefinition getCRSDefinition(CoordinateReferenceSystem crs) throws UnsupportedCoordinateReferenceSystemException {
218
		return new DefaultCRS(crs);
218
		return new DefaultCRSDefinition(crs);
219 219
	}
220 220

  
221 221

  
222 222
	@Override
223 223
	public CRSDefinition getCompoundCRS(CRSDefinition... crsList) throws UnsupportedCoordinateReferenceSystemException {
224
		DefaultCRS[] defs = (DefaultCRS[]) crsList;
225 224
		ArrayList<CoordinateReferenceSystem> components = new ArrayList<CoordinateReferenceSystem>();
226
		for (CRSDefinition def: defs) {
227
			if (def instanceof DefaultCRS) {
228
				components.add(((DefaultCRS)def).getInternalCRS());	
225
		for (CRSDefinition def: crsList) {
226
			if (def instanceof DefaultCRSDefinition) {
227
				components.add(((DefaultCRSDefinition)def).getInternalCRS());	
229 228
			}
230 229
			else {
231
				def = new DefaultCRS(def.toWKT());
230
				def = new DefaultCRSDefinition(def.toWKT());
232 231
			}
233 232
		}
234 233
	    CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
......
237 236
		    Map<String, String> properties = new HashMap<String, String>();
238 237
		    crsFactory.createCompoundCRS(properties, components.toArray(new CoordinateReferenceSystem[components.size()]));
239 238
			compoundCRS = crsFactory.createCompoundCRS(properties, components.toArray(new CoordinateReferenceSystem[components.size()]));;
240
			return new DefaultCRS(compoundCRS);
239
			return new DefaultCRSDefinition(compoundCRS);
241 240
		} catch (FactoryException e) {
242 241
			throw new UnsupportedCoordinateReferenceSystemException(e);
243 242
		}
......
253 252
		} catch (FactoryException e) {
254 253
			throw new UnsupportedCoordinateReferenceSystemException(def, e);
255 254
		}
256
		return new DefaultCRS(crs);
255
		return new DefaultCRSDefinition(crs);
257 256
	}
258 257
	
259 258

  
260 259
	@Override
261 260
	public CRSDefinition parseCRSDefinition(String def, Format format)
262
			throws UnsupportedCoordinateReferenceSystemException {
261
			throws UnsupportedCoordinateReferenceSystemException, UnsupportedFormatException {
263 262
		if (SUPPORTED_FORMATS.contains(format)) {
264 263
			parseCRSDefinition(def);
265 264
		}
266
		throw new UnsupportedOperationException("Format not supported");
265
		throw new UnsupportedFormatException(format);
267 266
	}
268
	
269 267

  
270 268
	@Override
271
	public DefaultTransformation parseTransformationDefinition(String def) throws ParseException {
272
		return new DefaultTransformation(def);
269
	public DefaultTransformationDefinition parseTransformationDefinition(String def) throws ParseException {
270
		return new DefaultTransformationDefinition(def);
273 271
	}
274 272

  
275 273
	@Override
276
	public DefaultTransformation parseTransformationDefinition(String def, Format format)
277
			throws UnsupportedCoordinateReferenceSystemException, ParseException {
274
	public DefaultTransformationDefinition parseTransformationDefinition(String def, Format format)
275
			throws ParseException, UnsupportedFormatException {
278 276
		if (SUPPORTED_FORMATS.contains(format)) {
279
			return new DefaultTransformation(def);
277
			return new DefaultTransformationDefinition(def);
280 278
		}
281
		throw new UnsupportedOperationException("Format not supported");
279
		throw new UnsupportedFormatException(format);
282 280
	}
283 281

  
284 282
	@Override
......
331 329
	public List<TransformationDefinition> getCoordinateTransformations(CRSDefinition source, CRSDefinition target) throws CoordinateReferenceSystemException {
332 330
		ArrayList<TransformationDefinition> transforms = new ArrayList<TransformationDefinition>();
333 331
		try {
334
			CoordinateReferenceSystem sourceCRS = ((DefaultCRS)source).getInternalCRS();
335
			CoordinateReferenceSystem targetCRS = ((DefaultCRS)target).getInternalCRS();
332
			CoordinateReferenceSystem sourceCRS = ((DefaultCRSDefinition)source).getInternalCRS();
333
			CoordinateReferenceSystem targetCRS = ((DefaultCRSDefinition)target).getInternalCRS();
336 334
	        CoordinateOperationFactory operationFactory = CRS.getCoordinateOperationFactory(false);
337 335
	        Set<CoordinateOperation> ops = operationFactory.findOperations(sourceCRS, targetCRS);
338 336
	        for (CoordinateOperation op: ops) {
339
	        	DefaultTransformation def = new DefaultTransformation(op);
337
	        	DefaultTransformationDefinition def = new DefaultTransformationDefinition(op);
340 338
	        	transforms.add(def);
341 339
	        }
342 340
		} catch (FactoryException | ClassCastException e) {
......
354 352
	        CoordinateOperationFactory operationFactory = CRS.getCoordinateOperationFactory(false);
355 353
	        Set<CoordinateOperation> ops = operationFactory.findOperations(sourceCRS, targetCRS);
356 354
	        for (CoordinateOperation op: ops) {
357
	        	DefaultTransformation def = new DefaultTransformation(op);
355
	        	DefaultTransformationDefinition def = new DefaultTransformationDefinition(op);
358 356
	        	transforms.add(def);
359 357
	        }
360 358
		} catch (FactoryException e) {

Also available in: Unified diff