Revision 867 org.gvsig.geotools.proj/trunk/org.gvsig.geotools.proj/org.gvsig.geotools.proj.catalog.impl/src/main/java/org/gvsig/geotools/proj/catalog/DefaultTransformationDefinition.java

View differences:

DefaultTransformationDefinition.java
1 1
package org.gvsig.geotools.proj.catalog;
2 2

  
3
import java.util.ArrayList;
3 4
import java.util.HashSet;
4 5
import java.util.List;
5 6
import java.util.Set;
......
8 9
import org.geotools.referencing.operation.transform.ConcatenatedTransform;
9 10
import org.geotools.referencing.wkt.Formatter;
10 11
import org.geotools.referencing.wkt.Symbols;
11
import org.gvsig.geotools.proj.catalog.utils.IdentifiedObjectUtils;
12
import org.gvsig.geotools.proj.catalog.extent.DefaultExtent;
13
import org.gvsig.geotools.proj.catalog.extent.DefaultGeographicBoundingBox;
14
import org.gvsig.geotools.proj.catalog.extent.DefaultVerticalExtent;
15
import org.gvsig.geotools.proj.catalog.utils.GtUtils;
12 16
import org.gvsig.proj.catalog.CRSDefinition;
13 17
import org.gvsig.proj.catalog.TextSerialization.Format;
14 18
import org.gvsig.proj.catalog.TextSerialization.WKTConvention;
......
19 23
import org.gvsig.proj.catalog.exception.UnsupportedFormatException;
20 24
import org.gvsig.proj.catalog.exception.UnsupportedTransformationException;
21 25
import org.gvsig.proj.catalog.extent.Extent;
26
import org.gvsig.proj.catalog.extent.GeographicBoundingBox;
27
import org.gvsig.proj.catalog.extent.VerticalExtent;
22 28
import org.opengis.referencing.ReferenceIdentifier;
23 29
import org.opengis.referencing.operation.ConcatenatedOperation;
24 30
import org.opengis.referencing.operation.CoordinateOperation;
25 31
import org.opengis.referencing.operation.MathTransform;
26 32
import org.opengis.referencing.operation.PassThroughOperation;
33
import org.opengis.referencing.operation.Projection;
27 34
import org.opengis.referencing.operation.SingleOperation;
28 35
import org.opengis.referencing.operation.Transformation;
29 36

  
......
106 113

  
107 114
	@Override
108 115
	public String getName() {
109
		// FIXME: define in API whether null or blank ""  is allowed
110 116
		if (operation != null) {
111 117
			return nameFromOperation(operation);
112 118
		}
......
133 139
			List<SingleOperation> opList = ((ConcatenatedOperation) op).getOperations();
134 140
			for (SingleOperation singleOp: opList) {
135 141
				if (singleOp instanceof Transformation) {
136
					meaningfulName.append("Concat operation using ");
142
					String id = GtUtils.getIdentifier(singleOp);
143
					if (id!=null) {
144
						meaningfulName.append(id).append("-based concat operation").append(" - ");
145
					}
137 146
					if (singleOp.getName() != null) {
138 147
						meaningfulName.append(singleOp.getName());
139 148
					}
140
					String id = IdentifiedObjectUtils.getIdentifier(singleOp);
141
					if (id!=null) {
142
						meaningfulName.append("[").append(id).append("]");
143
					}
144 149
				}
145 150
			}
146 151
			if (op.getName() != null) {
147
				if (meaningfulName.length()>0) {
148
					meaningfulName.append(" transforming ");
152
				if (meaningfulName.length()==0) {
153
					meaningfulName.append("Concat operation");
149 154
				}
150
				meaningfulName.append(op.getName().toString().replace("\u21e8", "=>"));	
151 155
			}
152 156
			if (meaningfulName.length()>0) {
153 157
				return meaningfulName.toString();
......
167 171
		if (operation==null) {
168 172
			return null;
169 173
		}
170
		return IdentifiedObjectUtils.getIdentifier(operation);
174
		return GtUtils.getIdentifier(operation);
171 175
	}
172 176

  
173 177
	@Override
......
186 190
						operation.getName().getAuthority()==null) {
187 191
			return null;
188 192
		}
189
		return IdentifiedObjectUtils.getIdentifier(operation.getName().getAuthority().getIdentifiers());
193
		return GtUtils.getIdentifier(operation.getName().getAuthority().getIdentifiers());
190 194
	}
191 195

  
192 196
	@Override
......
199 203

  
200 204
	@Override
201 205
	public Extent getDomainOfValidity() {
202
		// TODO Auto-generated method stub
206
		org.opengis.metadata.extent.Extent extent = operation.getDomainOfValidity();
207
		if (extent != null) {
208
			String desc;
209
			if (operation.getDomainOfValidity().getDescription() != null) {
210
				desc = operation.getDomainOfValidity().getDescription().toString();
211
			}
212
			else {
213
				desc = null;
214
			}
215
			ArrayList<GeographicBoundingBox> horizontalExtentList = new ArrayList<GeographicBoundingBox>();
216
			for (org.opengis.metadata.extent.GeographicExtent horizExtent: operation.getDomainOfValidity().getGeographicElements()) {
217
				if (horizExtent instanceof org.opengis.metadata.extent.GeographicBoundingBox) {
218
					DefaultGeographicBoundingBox bb = new DefaultGeographicBoundingBox(
219
							((org.opengis.metadata.extent.GeographicBoundingBox) horizExtent).getWestBoundLongitude(),
220
							((org.opengis.metadata.extent.GeographicBoundingBox) horizExtent).getEastBoundLongitude(),
221
							((org.opengis.metadata.extent.GeographicBoundingBox) horizExtent).getNorthBoundLatitude(),
222
							((org.opengis.metadata.extent.GeographicBoundingBox) horizExtent).getSouthBoundLatitude()); 
223
					horizontalExtentList.add(bb);
224
				}				
225
			}
226
			
227
			ArrayList<VerticalExtent> vertExtentList = new ArrayList<VerticalExtent>();
228
			for (org.opengis.metadata.extent.VerticalExtent verticalExtent: operation.getDomainOfValidity().getVerticalElements()) {
229
				DefaultVerticalExtent ve = new DefaultVerticalExtent(
230
						new DefaultCRSDefinition(verticalExtent.getVerticalCRS()),
231
						verticalExtent.getMinimumValue(),
232
						verticalExtent.getMaximumValue()
233
						);
234
				vertExtentList.add(ve);
235
			}
236
			return new DefaultExtent(desc, horizontalExtentList, vertExtentList);
237
		}
203 238
		return null;
204 239
	}
205 240

  
......
208 243
		if (operation==null) {
209 244
			return null;
210 245
		}
211
		return operation.getScope() + "\nRemarks: " + operation.getRemarks();
246
		StringBuilder desc = new StringBuilder();
247
		CoordinateOperation op = GtUtils.getDefiningOperation(operation);
248
		if (op!=null) {
249
			fillDescription(op, desc);
250
			if (desc.length()>0) {
251
				return desc.toString();
252
			}
253
		}
254
		fillDescription(operation, desc);
255
		return desc.toString();
212 256
	}
257
	
258
	protected StringBuilder fillDescription(CoordinateOperation op, StringBuilder desc) {
259
		if (op.getName() != null) {
260
			desc.append("Summary: Concatenated operation");
261
			String id = GtUtils.getIdentifier(op);
262
			if (id!=null) {
263
				desc.append(" based on ").append(id).append(",");
264
			}
265
			desc.append(" transforming ");
266
			desc.append(op.getName().toString().replace("\u21e8", "=>")).append("\n");
267
		}
268
		if (op.getScope() != null) {
269
			desc.append("Scope: ").append(op.getScope());
270
		}
271
		if (op.getRemarks() != null) {
272
			if (desc.length()>0) {
273
				desc.append("\nRemarks: ");
274
			}
275
			else {
276
				desc.append("Remarks: ");
277
			}
278
			desc.append(op.getRemarks());
279
		}
280
		if (op.getDomainOfValidity() != null &&
281
				op.getDomainOfValidity().getDescription() != null) {
282
			if (desc.length()>0) {
283
				desc.append("\nDomain: ");
284
			}
285
			else {
286
				desc.append("Domain: ");
287
			}
288
			desc.append(op.getDomainOfValidity().getDescription());
289
		}
290
		return desc;
291
	}
213 292

  
214 293
	@Override
215 294
	public TransformationDefinition getInverseDefinition()
......
231 310
	}
232 311

  
233 312
	@Override
234
	public String toString(Format format) throws UnsupportedFormatException {
313
	public String export(Format format) throws UnsupportedFormatException {
235 314
		if (format==Format.WKT1) {
236 315
			return toWKT();
237 316
		}
......
239 318
	}
240 319

  
241 320
	@Override
242
	public String toString(Format format, WKTConvention convention, int indentation) throws UnsupportedFormatException {
321
	public String export(Format format, WKTConvention convention, int indentation) throws UnsupportedFormatException {
243 322
		if (format==Format.WKT1) {
244 323
			Formatter formatter = new Formatter(Symbols.DEFAULT, indentation);
245 324
			if (convention==WKTConvention.EPSG) {
......
257 336
	public MathTransform getMathTransform() {
258 337
		return mathTransform;
259 338
	}
260

  
261
	/*
339
	
262 340
	@Override
263
	public boolean isIdentity() throws TransformationException {
264
		return mathTransform.isIdentity();
265
	}*/
341
	public String toString() {
342
		return getName();
343
	}
266 344
	
267 345
	@Override
268 346
	public boolean equals(Object obj) {

Also available in: Unified diff