root / org.gvsig.geotools.proj / trunk / org.gvsig.geotools.proj / org.gvsig.geotools.proj.catalog.impl / src / main / java / org / gvsig / geotools / proj / catalog / utils / GtUtils.java @ 867
History | View | Annotate | Download (1.86 KB)
1 |
package org.gvsig.geotools.proj.catalog.utils; |
---|---|
2 |
|
3 |
import java.util.Collection; |
4 |
import java.util.List; |
5 |
|
6 |
import org.opengis.metadata.Identifier; |
7 |
import org.opengis.referencing.IdentifiedObject; |
8 |
import org.opengis.referencing.ReferenceIdentifier; |
9 |
import org.opengis.referencing.operation.ConcatenatedOperation; |
10 |
import org.opengis.referencing.operation.CoordinateOperation; |
11 |
import org.opengis.referencing.operation.PassThroughOperation; |
12 |
import org.opengis.referencing.operation.Projection; |
13 |
import org.opengis.referencing.operation.SingleOperation; |
14 |
import org.opengis.referencing.operation.Transformation; |
15 |
|
16 |
public class GtUtils { |
17 |
|
18 |
public static String getIdentifier(IdentifiedObject object) { |
19 |
if (object==null) { |
20 |
return null; |
21 |
} |
22 |
for (ReferenceIdentifier id: object.getIdentifiers()) {
|
23 |
// return the first one we find
|
24 |
return id.toString();
|
25 |
} |
26 |
return null; |
27 |
} |
28 |
|
29 |
public static String getIdentifier(Collection<? extends Identifier> identifiers) { |
30 |
if (identifiers != null) { |
31 |
for (Identifier id: identifiers) {
|
32 |
// return the first one we find
|
33 |
return id.getCode();
|
34 |
} |
35 |
} |
36 |
return null; |
37 |
} |
38 |
|
39 |
public static CoordinateOperation getDefiningOperation(CoordinateOperation operation) { |
40 |
if (operation instanceof ConcatenatedOperation) { |
41 |
List<SingleOperation> opList = ((ConcatenatedOperation) operation).getOperations();
|
42 |
for (SingleOperation singleOp: opList) {
|
43 |
if (singleOp instanceof Transformation) { |
44 |
return singleOp;
|
45 |
} |
46 |
} |
47 |
for (SingleOperation singleOp: opList) {
|
48 |
if (singleOp instanceof PassThroughOperation) { |
49 |
return getDefiningOperation(singleOp);
|
50 |
} |
51 |
} |
52 |
for (SingleOperation singleOp: opList) {
|
53 |
if (singleOp instanceof Projection) { |
54 |
return singleOp;
|
55 |
} |
56 |
} |
57 |
} |
58 |
else if (operation instanceof PassThroughOperation) { |
59 |
return getDefiningOperation(((PassThroughOperation)operation).getOperation());
|
60 |
} |
61 |
return operation;
|
62 |
} |
63 |
} |