Revision 805
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/pom.xml | ||
---|---|---|
23 | 23 |
<scope>test</scope> |
24 | 24 |
</dependency> |
25 | 25 |
<dependency> |
26 |
<groupId>org.jscience</groupId>
|
|
27 |
<artifactId>jscience</artifactId>
|
|
28 |
<version>4.3.1</version>
|
|
26 |
<groupId>javax.measure</groupId>
|
|
27 |
<artifactId>unit-api</artifactId>
|
|
28 |
<version>1.0</version>
|
|
29 | 29 |
</dependency> |
30 | 30 |
<dependency> |
31 | 31 |
<groupId>org.gvsig</groupId> |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/test/java/org/gvsig/proj/CRSCatalogueManagerIT.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.proj.catalogue.CRSCatalogManager; |
|
28 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
29 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
30 |
|
|
31 |
/** |
|
32 |
* {@link CoordinateReferenceSystemManager} API acceptance tests. |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
*/ |
|
36 |
public abstract class CRSCatalogueManagerIT extends |
|
37 |
AbstractLibraryAutoInitTestCase { |
|
38 |
|
|
39 |
protected CRSCatalogManager manager; |
|
40 |
|
|
41 |
protected void doSetUp() throws Exception { |
|
42 |
manager = createProjectionManager(); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* Creates a {@link CoordinateReferenceSystemManager} instance. |
|
47 |
* |
|
48 |
* @return the {@link CoordinateReferenceSystemManager} instance |
|
49 |
*/ |
|
50 |
protected abstract CRSCatalogManager createProjectionManager(); |
|
51 |
|
|
52 |
/** |
|
53 |
* Returns the authority name to use to create the projections to test. |
|
54 |
* |
|
55 |
* @return the authority name |
|
56 |
*/ |
|
57 |
protected abstract String getAuthorityName(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Returns the code to use to create the projections to test. |
|
61 |
* |
|
62 |
* @return the code |
|
63 |
*/ |
|
64 |
protected abstract String getCode(); |
|
65 |
|
|
66 |
/** |
|
67 |
* Test method for |
|
68 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getAuthorityNames()} |
|
69 |
* . |
|
70 |
*/ |
|
71 |
public void testGetAuthorityNames() { |
|
72 |
List names = manager.getAuthorityNames(); |
|
73 |
assertNotNull(names); |
|
74 |
assertTrue("Authority names list is empty", names.size() > 0); |
|
75 |
for (int i = 0; i < names.size(); i++) { |
|
76 |
if (!(names.get(i) instanceof String)) { |
|
77 |
fail("At least one authority name is not a String"); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Test method for |
|
84 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCodes(java.lang.String)} |
|
85 |
* . |
|
86 |
*/ |
|
87 |
public void testGetCodes() { |
|
88 |
List names = manager.getAuthorityNames(); |
|
89 |
for (int i = 0; i < names.size(); i++) { |
|
90 |
List codes = manager.getCodes((String) names.get(i)); |
|
91 |
for (int j = 0; j < codes.size(); j++) { |
|
92 |
if (!(codes.get(i) instanceof String)) { |
|
93 |
fail("At least one code of the authority " + names.get(i) |
|
94 |
+ " is not a String"); |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Test method for |
|
102 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateReferenceSystem(java.lang.String, java.lang.String)} |
|
103 |
*/ |
|
104 |
public void testGetDefinition() throws Exception { |
|
105 |
String code = getAuthorityName() + ":" + getCode(); |
|
106 |
CRSDefinition projection = |
|
107 |
manager.getCRSDefinition(code); |
|
108 |
//FIXME: assertEquals(getAuthorityName(), projection.getAuthorityName()); |
|
109 |
//FIXME: assertEquals(getCode(), projection.getCode()); |
|
110 |
} |
|
111 |
|
|
112 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/test/java/org/gvsig/proj/CRSCatalogLocatorTest.java | ||
---|---|---|
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
@Override |
127 |
public String registerCoordinateOperation(String wktDefinition, String description) { |
|
128 |
// TODO Auto-generated method stub |
|
129 |
return null; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 | 127 |
public String registerCoordinateTransformationPVT(String sourceCRS, String targetCRS, String description, |
134 | 128 |
float xTraslation, float yTraslation, float zTraslation, float xRotation, float yRotation, |
135 | 129 |
float zRotation, float scaleDifference) { |
... | ... | |
164 | 158 |
return null; |
165 | 159 |
} |
166 | 160 |
|
161 |
@Override |
|
162 |
public TransformationDefinition getTransformationDefinitionFromWKT(String wkt) { |
|
163 |
// TODO Auto-generated method stub |
|
164 |
return null; |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
public String registerTransformation(String wktDefinition, String description) { |
|
169 |
// TODO Auto-generated method stub |
|
170 |
return null; |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public CRSDefinition getCompoundCRS(CRSDefinition... crsList) { |
|
175 |
// TODO Auto-generated method stub |
|
176 |
return null; |
|
177 |
} |
|
178 |
|
|
167 | 179 |
} |
168 | 180 |
|
169 | 181 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/test/java/org/gvsig/proj/CRSCatalogManagerIT.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.proj.catalogue.CRSCatalogManager; |
|
28 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
29 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
30 |
|
|
31 |
/** |
|
32 |
* {@link CoordinateReferenceSystemManager} API acceptance tests. |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
*/ |
|
36 |
public abstract class CRSCatalogManagerIT extends |
|
37 |
AbstractLibraryAutoInitTestCase { |
|
38 |
|
|
39 |
protected CRSCatalogManager manager; |
|
40 |
|
|
41 |
protected void doSetUp() throws Exception { |
|
42 |
manager = createProjectionManager(); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* Creates a {@link CoordinateReferenceSystemManager} instance. |
|
47 |
* |
|
48 |
* @return the {@link CoordinateReferenceSystemManager} instance |
|
49 |
*/ |
|
50 |
protected abstract CRSCatalogManager createProjectionManager(); |
|
51 |
|
|
52 |
/** |
|
53 |
* Returns the authority name to use to create the projections to test. |
|
54 |
* |
|
55 |
* @return the authority name |
|
56 |
*/ |
|
57 |
protected abstract String getAuthorityName(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Returns the code to use to create the projections to test. |
|
61 |
* |
|
62 |
* @return the code |
|
63 |
*/ |
|
64 |
protected abstract String getCode(); |
|
65 |
|
|
66 |
/** |
|
67 |
* Test method for |
|
68 |
* {@link org.gvsig.proj.catalogue.CRSCatalogManager#getAuthorityNames()} |
|
69 |
* . |
|
70 |
*/ |
|
71 |
public void testGetAuthorityNames() { |
|
72 |
List names = manager.getAuthorityNames(); |
|
73 |
assertNotNull(names); |
|
74 |
assertTrue("Authority names list is empty", names.size() > 0); |
|
75 |
for (int i = 0; i < names.size(); i++) { |
|
76 |
if (!(names.get(i) instanceof String)) { |
|
77 |
fail("At least one authority name is not a String"); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Test method for |
|
84 |
* {@link org.gvsig.proj.catalogue.CRSCatalogManager#getCodes(java.lang.String)} |
|
85 |
* . |
|
86 |
*/ |
|
87 |
public void testGetCodes() { |
|
88 |
List names = manager.getAuthorityNames(); |
|
89 |
for (int i = 0; i < names.size(); i++) { |
|
90 |
List codes = manager.getCodes((String) names.get(i)); |
|
91 |
for (int j = 0; j < codes.size(); j++) { |
|
92 |
if (!(codes.get(i) instanceof String)) { |
|
93 |
fail("At least one code of the authority " + names.get(i) |
|
94 |
+ " is not a String"); |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Test method for |
|
102 |
* {@linkorg.gvsig.proj.catalogue.CRSCatalogManager#getCoordinateReferenceSystem(java.lang.String)} |
|
103 |
*/ |
|
104 |
public void testGetDefinition() throws Exception { |
|
105 |
String code = getAuthorityName() + ":" + getCode(); |
|
106 |
CRSDefinition crs = |
|
107 |
manager.getCRSDefinition(code); |
|
108 |
assertNotNull(crs); |
|
109 |
assertEquals(code, crs.getIdentifier()); |
|
110 |
//FIXME: assertEquals(getAuthorityName(), projection.getAuthorityName()); |
|
111 |
//FIXME: assertEquals(getCode(), projection.getCode()); |
|
112 |
} |
|
113 |
|
|
114 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/test/java/org/gvsig/proj/CoordinateTransformationIT.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
26 |
import org.gvsig.proj.catalogue.TransformationDefinition; |
|
27 |
import org.gvsig.proj.catalogue.exception.NoninvertibleTransformException; |
|
28 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
29 |
|
|
30 |
/** |
|
31 |
* {@link CoordinateTransformation} API acceptance tests. |
|
32 |
* |
|
33 |
* @author gvSIG Team |
|
34 |
*/ |
|
35 |
public abstract class CoordinateTransformationIT extends |
|
36 |
AbstractLibraryAutoInitTestCase { |
|
37 |
|
|
38 |
protected CRSDefinition source; |
|
39 |
protected CRSDefinition target; |
|
40 |
protected TransformationDefinition transformation; |
|
41 |
|
|
42 |
protected void doSetUp() throws Exception { |
|
43 |
source = createSourceProjection(); |
|
44 |
target = createTargetProjection(); |
|
45 |
transformation = createTransformation(); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Creates the transformation to test |
|
50 |
* |
|
51 |
* @return |
|
52 |
* @throws Exception |
|
53 |
*/ |
|
54 |
protected abstract TransformationDefinition createTransformation() |
|
55 |
throws Exception; |
|
56 |
|
|
57 |
/** |
|
58 |
* Creates the source CRSDefinition, which must match the |
|
59 |
* source CRS of the transformation to test |
|
60 |
* @return |
|
61 |
* @throws Exception |
|
62 |
*/ |
|
63 |
protected abstract CRSDefinition createSourceProjection() |
|
64 |
throws Exception; |
|
65 |
|
|
66 |
/** |
|
67 |
* Returns the name of the authority which defines the |
|
68 |
* transformation to be tested |
|
69 |
* |
|
70 |
* @return |
|
71 |
*/ |
|
72 |
protected abstract String getAuthorityName(); |
|
73 |
|
|
74 |
/** |
|
75 |
* Creates the target CRSDefinition, which must match the |
|
76 |
* target CRS of the transformation to test |
|
77 |
* @return |
|
78 |
* @throws Exception |
|
79 |
*/ |
|
80 |
protected abstract CRSDefinition createTargetProjection() |
|
81 |
throws Exception; |
|
82 |
|
|
83 |
/** |
|
84 |
* Test method for |
|
85 |
* {@link org.gvsig.proj.catalogue.TransformationDefinition#getAuthorityName()}. |
|
86 |
*/ |
|
87 |
public void testGetAuthorityName() { |
|
88 |
assertEquals(getAuthorityName(), transformation.getAuthorityName()); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Test method for |
|
93 |
* {@link org.gvsig.proj.catalogue.TransformationDefinition#getIdentifier()}. |
|
94 |
*/ |
|
95 |
// public void testGetIdentifier() { |
|
96 |
// assertEquals(getProjectedCode(), projCrsDef.getIdentifier()); |
|
97 |
// } |
|
98 |
|
|
99 |
/** |
|
100 |
* Test method for |
|
101 |
* {@link org.gvsig.proj.catalogue.TransformationDefinition#getSourceCRS()}. |
|
102 |
*/ |
|
103 |
public void testGetSourceProjection() { |
|
104 |
assertEquals(source, transformation.getSourceCRS()); |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Test method for |
|
109 |
* {@link org.gvsig.proj.catalogue.TransformationDefinition#getTargetCRS()}. |
|
110 |
*/ |
|
111 |
public void testGetTargetProjection() { |
|
112 |
assertEquals(target, transformation.getTargetCRS()); |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Test method for |
|
117 |
* {@link org.gvsig.proj.catalogue.TransformationDefinition#getInverse()}. |
|
118 |
* @throws NoninvertibleTransformException |
|
119 |
*/ |
|
120 |
public void testGetReverse() throws NoninvertibleTransformException { |
|
121 |
TransformationDefinition inverseTransformation = |
|
122 |
transformation.getInverse(); |
|
123 |
assertEquals(target, inverseTransformation.getSourceCRS()); |
|
124 |
assertEquals(source, inverseTransformation.getTargetCRS()); |
|
125 |
} |
|
126 |
|
|
127 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/test/java/org/gvsig/proj/CRSDefinitionIT.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
import org.gvsig.proj.catalogue.CRSCatalogLocator; |
|
26 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
27 |
import org.gvsig.proj.catalogue.exception.CoordinateReferenceSystemNotFoundException; |
|
28 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
29 |
|
|
30 |
/** |
|
31 |
* {@link CoordinateReferenceSystem} API acceptance tests. |
|
32 |
* |
|
33 |
* @author gvSIG Team |
|
34 |
*/ |
|
35 |
public abstract class CRSDefinitionIT extends |
|
36 |
AbstractLibraryAutoInitTestCase { |
|
37 |
|
|
38 |
protected CRSDefinition projCrsDef; |
|
39 |
protected CRSDefinition geog2dCrsDef; |
|
40 |
|
|
41 |
protected void doSetUp() throws Exception { |
|
42 |
projCrsDef = createProjection(getProjectedCode()); |
|
43 |
geog2dCrsDef = createProjection(getGeographic2DCode()); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* Creates a new {@link CoordinateReferenceSystem}. |
|
48 |
* |
|
49 |
* @param authorityName |
|
50 |
* @param code |
|
51 |
* @return the created projection |
|
52 |
* @throws CoordinateReferenceSystemNotFoundException |
|
53 |
*/ |
|
54 |
protected CRSDefinition createProjection( |
|
55 |
String code) throws CoordinateReferenceSystemNotFoundException, |
|
56 |
Exception { |
|
57 |
return CRSCatalogLocator.getManager().getCRSDefinition(code); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Returns the code to use to create the projection to test, which |
|
62 |
* should be a projected CRS |
|
63 |
* |
|
64 |
* @return the code |
|
65 |
*/ |
|
66 |
protected abstract String getProjectedCode(); |
|
67 |
|
|
68 |
/** |
|
69 |
* Returns the code to use to create the projection to test, which |
|
70 |
* should be a geographic 2D CRS |
|
71 |
* |
|
72 |
* @return the code |
|
73 |
*/ |
|
74 |
protected abstract String getGeographic2DCode(); |
|
75 |
|
|
76 |
/** |
|
77 |
* Returns the name of the authority which defines the CRS to be |
|
78 |
* tested |
|
79 |
* |
|
80 |
* @return |
|
81 |
*/ |
|
82 |
protected abstract String getAuthorityName(); |
|
83 |
|
|
84 |
/** |
|
85 |
* Test method for |
|
86 |
* {@link org.gvsig.proj.catalogue.CRSDefinition#getAuthorityName()}. |
|
87 |
*/ |
|
88 |
public void testGetAuthorityName() { |
|
89 |
assertEquals(getAuthorityName(), projCrsDef.getAuthorityName()); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* Test method for |
|
94 |
* {@link org.gvsig.proj.catalogue.CRSDefinition#getIdentifier()}. |
|
95 |
*/ |
|
96 |
public void testGetIdentifier() { |
|
97 |
assertEquals(getProjectedCode(), projCrsDef.getIdentifier()); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Test method for |
|
102 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#isProjected()}. |
|
103 |
*/ |
|
104 |
public void testIsProjected() { |
|
105 |
assertTrue(projCrsDef.isProjected()); |
|
106 |
assertFalse(projCrsDef.isProjected()); |
|
107 |
} |
|
108 |
|
|
109 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/TransformationDefinition.java | ||
---|---|---|
79 | 79 |
* @return the list of object identifiers, or an empty collection if there is none. |
80 | 80 |
*/ |
81 | 81 |
Set<String> getIdentifiers(); |
82 |
|
|
83 |
/** |
|
84 |
* Gets the authority which defines this coordinate operation |
|
85 |
* (e.g. "EPSG", "ESRI", "USER"...). |
|
86 |
* |
|
87 |
* If this transformation is defined by several |
|
88 |
* authorities, it returns the authority which was used to instantiate |
|
89 |
* the object, or the authority that more closely matches the information |
|
90 |
* used to instantiate the object (e.g. if derived from an WKT definition) |
|
91 |
* |
|
92 |
* @return The authority name |
|
93 |
*/ |
|
94 |
String getAuthorityName(); |
|
82 | 95 |
|
83 | 96 |
/** |
84 | 97 |
* Version of the coordinate transformation (i.e., instantiation due to the stochastic |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/CRSDefinition.java | ||
---|---|---|
26 | 26 |
import java.util.List; |
27 | 27 |
import java.util.Set; |
28 | 28 |
|
29 |
import javax.measure.Unit; |
|
30 |
import javax.measure.quantity.Length; |
|
31 |
|
|
29 | 32 |
import org.gvsig.proj.catalogue.datum.Datum; |
30 | 33 |
import org.gvsig.proj.catalogue.ref.Extent; |
31 | 34 |
|
... | ... | |
59 | 62 |
* Gets a code that references an unambiguous definition of the coordinate reference |
60 | 63 |
* system for some authority. Examples: "EPSG:4326", "EPSG:25830". |
61 | 64 |
* |
65 |
* Note that identifiers in the "USER:" namespace are an special case, as their |
|
66 |
* definition will be different for each user, so they don't reference an |
|
67 |
* unambiguous definition. |
|
68 |
* |
|
62 | 69 |
* @return the identifier which was used to instantiate the object, or the |
63 | 70 |
* identifier that more closely matches the information used to instantiate |
64 | 71 |
* the object (e.g. if derived from an WKT definition) |
... | ... | |
72 | 79 |
* @return the list of object identifiers, or an empty collection if there is none. |
73 | 80 |
*/ |
74 | 81 |
Set<String> getIdentifiers(); |
82 |
|
|
83 |
/** |
|
84 |
* Gets the authority which defines this coordinate references system |
|
85 |
* (e.g. "EPSG", "ESRI", "USER"...). |
|
86 |
* |
|
87 |
* If the CRS is defined by several |
|
88 |
* authorities, it returns the authority which was used to instantiate |
|
89 |
* the object, or the authority that more closely matches the information |
|
90 |
* used to instantiate the object (e.g. if derived from an WKT definition) |
|
91 |
* |
|
92 |
* @return The authority name |
|
93 |
*/ |
|
94 |
String getAuthorityName(); |
|
75 | 95 |
|
76 | 96 |
/** |
77 | 97 |
* FIXME: GeoAPI |
... | ... | |
216 | 236 |
* The provided points are considered to be 2D points |
217 | 237 |
* (additional dimensions are ignored). |
218 | 238 |
* |
219 |
* @return The distance between point1 and point2 in the same units as the |
|
220 |
* ellipsoid axis (for geodetic CRSs) or in the same units as defined by the |
|
221 |
* first axis dimension (for non-geodetic CRSs). |
|
239 |
* @param point1 |
|
240 |
* @param point2 |
|
241 |
* @param the unit in which the distance should be measure |
|
242 |
* |
|
243 |
* @return The distance between point1 and point2 measured in the units |
|
244 |
* provided by the unit parameter. |
|
222 | 245 |
*/ |
223 |
double getDistance(double[] point1, double[] point2); |
|
246 |
double getDistance(double[] point1, double[] point2, Unit<Length> unit);
|
|
224 | 247 |
|
225 | 248 |
/** |
226 | 249 |
* Calculates the distance between 2 points on the surface of the Earth. |
... | ... | |
240 | 263 |
* The provided points are considered to be 2D points |
241 | 264 |
* (additional dimensions are ignored). |
242 | 265 |
* |
243 |
* @return The distance between point1 and point2 in the same units as the |
|
244 |
* ellipsoid axis (for geodetic CRSs) or in the same units as defined by the |
|
245 |
* first axis dimension (for non-geodetic CRSs). |
|
266 |
* @param point1 |
|
267 |
* @param point2 |
|
268 |
* @param the unit in which the distance should be measure |
|
269 |
* |
|
270 |
* @return The distance between point1 and point2 measured in the units |
|
271 |
* provided by the unit parameter. |
|
246 | 272 |
*/ |
247 |
double getDistance(double[] point1, double[] point2, boolean useBaseCRS); |
|
273 |
double getDistance(double[] point1, double[] point2, boolean useBaseCRS, Unit<Length> unit);
|
|
248 | 274 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/CoordinateSystemAxis.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
package org.gvsig.proj.catalogue; |
60 | 60 |
|
61 |
import javax.measure.unit.Unit;
|
|
61 |
import javax.measure.Unit; |
|
62 | 62 |
|
63 | 63 |
/** |
64 | 64 |
* Definition of a coordinate system axis |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/CRSType.java | ||
---|---|---|
24 | 24 |
package org.gvsig.proj.catalogue; |
25 | 25 |
|
26 | 26 |
/** |
27 |
* Defines the type of CRS |
|
27 |
* Defines the type of CRS.
|
|
28 | 28 |
* |
29 | 29 |
* @author Cesar Martinez Izquierdo |
30 | 30 |
*/ |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/datum/Ellipsoid.java | ||
---|---|---|
59 | 59 |
|
60 | 60 |
package org.gvsig.proj.catalogue.datum; |
61 | 61 |
|
62 |
import javax.measure.Unit; |
|
62 | 63 |
import javax.measure.quantity.Length; |
63 |
import javax.measure.unit.Unit; |
|
64 | 64 |
|
65 | 65 |
|
66 | 66 |
/** |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/datum/PrimeMeridian.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
package org.gvsig.proj.catalogue.datum; |
60 | 60 |
|
61 |
import javax.measure.Unit; |
|
61 | 62 |
import javax.measure.quantity.Angle; |
62 |
import javax.measure.unit.Unit; |
|
63 | 63 |
|
64 | 64 |
/** |
65 | 65 |
* A prime meridian defines the origin from which longitude values are determined. |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.catalog/org.gvsig.proj.catalog.api/src/main/java/org/gvsig/proj/catalogue/CRSCatalogManager.java | ||
---|---|---|
105 | 105 |
*/ |
106 | 106 |
CRSDefinition getCRSDefinitionFromWKT(String wkt); // anyadir formato |
107 | 107 |
|
108 |
|
|
108 | 109 |
/** |
110 |
* Creates a compound CRS by combining the provided individual |
|
111 |
* CRSDefinitions. |
|
112 |
* |
|
113 |
* @param crsList The list of CRSDefinitions to compound |
|
114 |
* @return The definition of the compound CRS |
|
115 |
* |
|
116 |
* @see CRSType#CompoundCRSType |
|
117 |
* @see CRSDefinition#getComponents() |
|
118 |
* @see CRSDefinition#getType() |
|
119 |
*/ |
|
120 |
CRSDefinition getCompoundCRS(CRSDefinition... crsList); |
|
121 |
|
|
122 |
/** |
|
109 | 123 |
* Gets the TransformationDefinition for the provided code |
110 | 124 |
* @param code The operation code (e.g. "EPSG:1633", "EPSG:1632") |
111 | 125 |
* |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/test/java/org/gvsig/proj/CoordinateReferenceSystemManagerIT.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.util.List; |
26 | 26 |
|
27 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
28 |
import org.gvsig.proj.catalogue.TransformationDefinition; |
|
27 | 29 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
28 | 30 |
|
29 | 31 |
/** |
... | ... | |
48 | 50 |
protected abstract CoordinateReferenceSystemManager createProjectionManager(); |
49 | 51 |
|
50 | 52 |
/** |
51 |
* Returns the authority name to use to create the projections to test.
|
|
53 |
* Returns the WKT string to create the CRSs to test.
|
|
52 | 54 |
* |
53 | 55 |
* @return the authority name |
54 | 56 |
*/ |
55 |
protected abstract String getAuthorityName();
|
|
57 |
protected abstract String getCoordinateReferenceSystemWKT();
|
|
56 | 58 |
|
57 | 59 |
/** |
58 |
* Returns the code to use to create the projections to test. |
|
60 |
* Test method for |
|
61 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateReferenceSystem(java.lang.String)} |
|
62 |
*/ |
|
63 |
public void testGetCoordinateReferenceSystemFromWKT() throws Exception { |
|
64 |
CoordinateReferenceSystem crs = |
|
65 |
manager.getCoordinateReferenceSystem(getCoordinateReferenceSystemWKT()); |
|
66 |
assertNotNull(crs); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Returns the WKT string to create the CoordinateTransformation to test. |
|
59 | 71 |
* |
60 |
* @return the code
|
|
72 |
* @return the authority name
|
|
61 | 73 |
*/ |
62 |
protected abstract String getCode();
|
|
63 |
|
|
74 |
protected abstract String getCoordinateTransformationWKT();
|
|
75 |
|
|
64 | 76 |
/** |
65 | 77 |
* Test method for |
66 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getAuthorityNames()} |
|
67 |
* . |
|
78 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateTransformation(java.lang.String)} |
|
68 | 79 |
*/ |
69 |
public void testGetAuthorityNames() { |
|
70 |
List names = manager.getAuthorityNames(); |
|
71 |
assertNotNull(names); |
|
72 |
assertTrue("Authority names list is empty", names.size() > 0); |
|
73 |
for (int i = 0; i < names.size(); i++) { |
|
74 |
if (!(names.get(i) instanceof String)) { |
|
75 |
fail("At least one authority name is not a String"); |
|
76 |
} |
|
77 |
} |
|
80 |
public void testGetTransformationFromWKT() throws Exception { |
|
81 |
CoordinateTransformation ct = |
|
82 |
manager.getCoordinateTransformation(getCoordinateTransformationWKT()); |
|
83 |
assertNotNull(ct); |
|
78 | 84 |
} |
85 |
|
|
86 |
/** |
|
87 |
* Returns the CRS definition to create the CRSs to test. |
|
88 |
* |
|
89 |
* @return the authority name |
|
90 |
*/ |
|
91 |
protected abstract CRSDefinition getCoordinateReferenceSystemDefinition(); |
|
92 |
|
|
93 |
/** |
|
94 |
* Returns the transformation definition to create the CoordinateTransformation |
|
95 |
* to test. |
|
96 |
* |
|
97 |
* @return the authority name |
|
98 |
*/ |
|
99 |
protected abstract TransformationDefinition getTransformationDefinition(); |
|
79 | 100 |
|
80 | 101 |
/** |
81 | 102 |
* Test method for |
82 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCodes(java.lang.String)} |
|
83 |
* . |
|
103 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateReferenceSystem(CRSDefinition)} |
|
84 | 104 |
*/ |
85 |
public void testGetCodes() { |
|
86 |
List names = manager.getAuthorityNames(); |
|
87 |
for (int i = 0; i < names.size(); i++) { |
|
88 |
List codes = manager.getCodes((String) names.get(i)); |
|
89 |
for (int j = 0; j < codes.size(); j++) { |
|
90 |
if (!(codes.get(i) instanceof String)) { |
|
91 |
fail("At least one code of the authority " + names.get(i) |
|
92 |
+ " is not a String"); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
105 |
public void testGetProjectionFromDefinition() throws Exception { |
|
106 |
CRSDefinition definition = getCoordinateReferenceSystemDefinition(); |
|
107 |
CoordinateReferenceSystem crs = |
|
108 |
manager.getCoordinateReferenceSystem(definition); |
|
109 |
assertNotNull(crs); |
|
110 |
assertEquals(definition, crs.getDefinition()); |
|
96 | 111 |
} |
97 |
|
|
112 |
|
|
98 | 113 |
/** |
99 | 114 |
* Test method for |
100 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateReferenceSystem(java.lang.String, java.lang.String)}
|
|
115 |
* {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateTransformation(TransformationDefinition)}
|
|
101 | 116 |
*/ |
102 |
public void testGetProjection() throws Exception { |
|
103 |
CoordinateReferenceSystem projection = |
|
104 |
manager.getCoordinateReferenceSystem(getAuthorityName(), getCode()); |
|
105 |
assertEquals(getAuthorityName(), projection.getAuthorityName()); |
|
106 |
assertEquals(getCode(), projection.getCode()); |
|
117 |
public void testGetTransformationFromDefinition() throws Exception { |
|
118 |
TransformationDefinition definition = getTransformationDefinition(); |
|
119 |
CoordinateTransformation ct = |
|
120 |
manager.getCoordinateTransformation(definition); |
|
121 |
assertNotNull(ct); |
|
122 |
assertEquals(definition, ct.getDefinition()); |
|
123 |
|
|
107 | 124 |
} |
108 |
|
|
125 |
|
|
109 | 126 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/test/java/org/gvsig/proj/CoordinateReferenceSystemIT.java | ||
---|---|---|
35 | 35 |
protected CoordinateReferenceSystem projection; |
36 | 36 |
|
37 | 37 |
protected void doSetUp() throws Exception { |
38 |
projection = createProjection(getAuthorityName(), getCode());
|
|
38 |
projection = createProjection(getWKT());
|
|
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
/** |
42 | 42 |
* Creates a new {@link CoordinateReferenceSystem}. |
43 | 43 |
* |
44 |
* @param authorityName |
|
45 | 44 |
* @param code |
46 | 45 |
* @return the created projection |
47 | 46 |
* @throws CoordinateReferenceSystemNotFoundException |
48 | 47 |
*/ |
49 |
protected CoordinateReferenceSystem createProjection(String authorityName,
|
|
50 |
String code) throws CoordinateReferenceSystemNotFoundException,
|
|
48 |
protected CoordinateReferenceSystem createProjection( |
|
49 |
String wkt) throws CoordinateReferenceSystemNotFoundException,
|
|
51 | 50 |
Exception { |
52 | 51 |
return CoordinateReferenceSystemLocator.getManager().getCoordinateReferenceSystem( |
53 |
getAuthorityName(), getCode());
|
|
52 |
wkt);
|
|
54 | 53 |
} |
55 | 54 |
|
56 | 55 |
/** |
57 |
* Returns the authority name to use to create the projections to test.
|
|
56 |
* Returns the code to use to create the projection to test.
|
|
58 | 57 |
* |
59 |
* @return the authority name |
|
60 |
*/ |
|
61 |
protected abstract String getAuthorityName(); |
|
62 |
|
|
63 |
/** |
|
64 |
* Returns the code to use to create the projections to test. |
|
65 |
* |
|
66 | 58 |
* @return the code |
67 | 59 |
*/ |
68 |
protected abstract String getCode();
|
|
60 |
protected abstract String getWKT();
|
|
69 | 61 |
|
70 | 62 |
/** |
71 |
* Returns as second code to use to create the projections to test |
|
72 |
* transformation creation. |
|
73 |
* |
|
74 |
* @return the code |
|
75 |
*/ |
|
76 |
protected abstract String getCode2(); |
|
77 |
|
|
78 |
/** |
|
79 | 63 |
* Test method for |
80 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#getAuthorityName()}. |
|
64 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#getProjectedCode()}. |
|
65 |
* @throws Exception |
|
66 |
* @throws UnsupportedOperationException |
|
67 |
* @throws CoordinateReferenceSystemNotFoundException |
|
81 | 68 |
*/ |
82 |
public void testGetAuthorityName() {
|
|
83 |
assertEquals(getAuthorityName(), projection.getAuthorityName());
|
|
69 |
public void testCRSDeserialization() throws CoordinateReferenceSystemNotFoundException, UnsupportedOperationException, Exception {
|
|
70 |
assertEquals(projection, createProjection(projection.getDefinition().toWKT()));
|
|
84 | 71 |
} |
85 | 72 |
|
86 | 73 |
/** |
87 | 74 |
* Test method for |
88 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#getCode()}. |
|
89 |
*/ |
|
90 |
public void testGetCode() { |
|
91 |
assertEquals(getCode(), projection.getCode()); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Test method for |
|
96 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#getReference()}. |
|
97 |
*/ |
|
98 |
public void testGetReference() { |
|
99 |
assertEquals(getAuthorityName() + ":" + getCode(), |
|
100 |
projection.getReference()); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Test method for |
|
105 | 75 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#getDefinition()}. |
106 | 76 |
*/ |
107 | 77 |
public void testGetDefinition() { |
108 | 78 |
assertNotNull(projection.getDefinition()); |
109 | 79 |
} |
110 | 80 |
|
111 |
/** |
|
112 |
* Test method for |
|
113 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#getTransformation(org.gvsig.proj.CoordinateReferenceSystem)} |
|
114 |
* . |
|
115 |
*/ |
|
116 |
public void testGetTransformation() throws Exception { |
|
117 |
CoordinateReferenceSystem targetProjection = |
|
118 |
createProjection(getAuthorityName(), getCode2()); |
|
119 |
CoordinateTransformation transformation = |
|
120 |
projection.getTransformation(targetProjection); |
|
121 |
|
|
122 |
if (transformation == null) { |
|
123 |
fail("Transformation from source projection " + projection + " to " |
|
124 |
+ targetProjection + " is null"); |
|
125 |
} |
|
126 |
assertEquals(projection, transformation.getSourceProjection()); |
|
127 |
assertEquals(targetProjection, transformation.getTargetProjection()); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Test method for |
|
132 |
* {@link org.gvsig.proj.CoordinateReferenceSystem#isProjected()}. |
|
133 |
*/ |
|
134 |
public void testIsProjected() { |
|
135 |
assertTrue(projection.isProjected()); |
|
136 |
} |
|
137 |
|
|
138 | 81 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/test/java/org/gvsig/proj/CoordinateTransformationIT.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.proj; |
24 | 24 |
|
25 |
import java.util.Arrays; |
|
26 |
|
|
27 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
28 |
import org.gvsig.proj.catalogue.TransformationDefinition; |
|
25 | 29 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
26 | 30 |
|
27 | 31 |
/** |
... | ... | |
35 | 39 |
protected CoordinateReferenceSystem source; |
36 | 40 |
protected CoordinateReferenceSystem target; |
37 | 41 |
protected CoordinateTransformation transformation; |
42 |
protected CoordinateReferenceSystemManager manager; |
|
38 | 43 |
|
39 | 44 |
protected void doSetUp() throws Exception { |
45 |
manager = createProjectionManager(); |
|
40 | 46 |
source = createSourceProjection(); |
41 | 47 |
target = createTargetProjection(); |
42 |
transformation = source.getTransformation(target);
|
|
48 |
transformation = createTransformationFromDefinition();
|
|
43 | 49 |
} |
50 |
|
|
51 |
/** |
|
52 |
* Creates a {@link CoordinateReferenceSystemManager} instance. |
|
53 |
* |
|
54 |
* @return the {@link CoordinateReferenceSystemManager} instance |
|
55 |
*/ |
|
56 |
protected abstract CoordinateReferenceSystemManager createProjectionManager(); |
|
57 |
|
|
58 |
/** |
|
59 |
* Returns the transformation definition to create the CoordinateTransformation |
|
60 |
* to test. |
|
61 |
* |
|
62 |
* @return the authority name |
|
63 |
*/ |
|
64 |
protected abstract TransformationDefinition getTransformationDefinition(); |
|
44 | 65 |
|
66 |
/** |
|
67 |
* Creates the transformation to be tested |
|
68 |
*/ |
|
69 |
public CoordinateTransformation createTransformationFromDefinition() throws Exception { |
|
70 |
TransformationDefinition definition = getTransformationDefinition(); |
|
71 |
return manager.getCoordinateTransformation(definition); |
|
72 |
} |
|
73 |
|
|
45 | 74 |
protected abstract CoordinateReferenceSystem createSourceProjection() |
46 | 75 |
throws Exception; |
47 | 76 |
|
... | ... | |
50 | 79 |
|
51 | 80 |
/** |
52 | 81 |
* Test method for |
53 |
* {@link org.gvsig.proj.CoordinateTransformation#getSourceProjection()}.
|
|
82 |
* {@link org.gvsig.proj.CoordinateTransformation#getSource()}. |
|
54 | 83 |
*/ |
55 | 84 |
public void testGetSourceProjection() { |
56 |
assertEquals(source, transformation.getSourceProjection());
|
|
85 |
assertEquals(source, transformation.getSource()); |
|
57 | 86 |
} |
58 | 87 |
|
59 | 88 |
/** |
60 | 89 |
* Test method for |
61 |
* {@link org.gvsig.proj.CoordinateTransformation#getTargetProjection()}.
|
|
90 |
* {@link org.gvsig.proj.CoordinateTransformation#getTarget()}. |
|
62 | 91 |
*/ |
63 | 92 |
public void testGetTargetProjection() { |
64 |
assertEquals(target, transformation.getTargetProjection());
|
|
93 |
assertEquals(target, transformation.getTarget()); |
|
65 | 94 |
} |
66 | 95 |
|
67 | 96 |
/** |
68 | 97 |
* Test method for |
69 |
* {@link org.gvsig.proj.CoordinateTransformation#getReverse()}.
|
|
98 |
* {@link org.gvsig.proj.CoordinateTransformation#getInverse()}.
|
|
70 | 99 |
*/ |
71 | 100 |
public void testGetReverse() { |
72 | 101 |
CoordinateTransformation reverseTransformation = |
73 |
transformation.getReverse();
|
|
74 |
assertEquals(target, reverseTransformation.getSourceProjection());
|
|
75 |
assertEquals(source, reverseTransformation.getTargetProjection());
|
|
102 |
transformation.getInverse();
|
|
103 |
assertEquals(target, reverseTransformation.getSource()); |
|
104 |
assertEquals(source, reverseTransformation.getTarget()); |
|
76 | 105 |
} |
77 | 106 |
|
107 |
/** |
|
108 |
* The input point to test the transformation |
|
109 |
* |
|
110 |
* @return |
|
111 |
*/ |
|
112 |
public abstract double[] getInputPoint(); |
|
113 |
/** |
|
114 |
* The output point to thest the transformation. This point |
|
115 |
* should be a known result of applying the transformation on |
|
116 |
* getInputPoint() |
|
117 |
* @return |
|
118 |
*/ |
|
119 |
public abstract double[] getResultPoint(); |
|
120 |
/** |
|
121 |
* Gets the maximum numeric tolerance to accept the result of |
|
122 |
* the transformation as valid |
|
123 |
* |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
public abstract double getResultTolerance(); |
|
127 |
|
|
128 |
/** |
|
129 |
* Test method for |
|
130 |
* {@link org.gvsig.proj.CoordinateTransformation#apply(double[])}. |
|
131 |
*/ |
|
132 |
public void testApplyTransformationInline() { |
|
133 |
double[] input = getInputPoint(); |
|
134 |
transformation.apply(input); |
|
135 |
assertTrue(pointsEquals(getResultPoint(), input, getResultTolerance())); |
|
136 |
} |
|
137 |
|
|
138 |
public boolean pointsEquals(double[] point1, double[] point2, double tolerance) { |
|
139 |
for (int i=0; i<point1.length; i++) { |
|
140 |
if (Math.abs(point1[i]-point2[i])>tolerance) { |
|
141 |
return false; |
|
142 |
} |
|
143 |
} |
|
144 |
return true; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Test method for |
|
149 |
* {@link org.gvsig.proj.CoordinateTransformation#apply(double[])}. |
|
150 |
*/ |
|
151 |
public void testApplyTransformation() { |
|
152 |
double[] input = getInputPoint(); |
|
153 |
double[] transformed = new double[input.length]; |
|
154 |
transformation.apply(input, transformed); |
|
155 |
assertTrue(pointsEquals(getResultPoint(), transformed, getResultTolerance())); |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* Test method for |
|
160 |
* {@link org.gvsig.proj.CoordinateTransformation#getInverse()} |
|
161 |
* and |
|
162 |
* {@link org.gvsig.proj.CoordinateTransformation#apply(double[])}. |
|
163 |
*/ |
|
164 |
public void testApplyInverseTransformation() { |
|
165 |
double[] input = getInputPoint(); |
|
166 |
double[] transformed = new double[input.length]; |
|
167 |
transformation.apply(input, transformed); |
|
168 |
CoordinateTransformation reverseTransformation = |
|
169 |
transformation.getInverse(); |
|
170 |
reverseTransformation.apply(transformed); |
|
171 |
assertTrue(pointsEquals(input, transformed, getResultTolerance())); |
|
172 |
} |
|
78 | 173 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/test/java/org/gvsig/proj/CoordinateReferenceSystemLocatorTest.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import junit.framework.TestCase; |
28 | 28 |
|
29 |
import org.gvsig.proj.catalogue.CRSDefinition; |
|
30 |
import org.gvsig.proj.catalogue.TransformationDefinition; |
|
29 | 31 |
import org.gvsig.tools.dynobject.DynObject; |
30 | 32 |
|
31 | 33 |
/** |
... | ... | |
51 | 53 |
public static class DummyProjectionManager implements |
52 | 54 |
CoordinateReferenceSystemManager { |
53 | 55 |
|
54 |
public List getAuthorityNames() { |
|
55 |
// Nothing to do |
|
56 |
return null; |
|
57 |
} |
|
56 |
@Override |
|
57 |
public CoordinateReferenceSystem getCoordinateReferenceSystem(String wkt) |
|
58 |
throws CoordinateReferenceSystemNotFoundException { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
return null; |
|
61 |
} |
|
58 | 62 |
|
59 |
public List getCodes(String authorityName) { |
|
60 |
// Nothing to do |
|
61 |
return null; |
|
62 |
} |
|
63 |
@Override |
|
64 |
public CoordinateReferenceSystem getCoordinateReferenceSystem(CRSDefinition definition) |
|
65 |
throws CoordinateReferenceSystemNotFoundException { |
|
66 |
// TODO Auto-generated method stub |
|
67 |
return null; |
|
68 |
} |
|
63 | 69 |
|
64 |
public CoordinateReferenceSystem getCoordinateReferenceSystem(String authorityName, |
|
65 |
String code) { |
|
66 |
// Nothing to do |
|
67 |
return null; |
|
68 |
} |
|
70 |
@Override |
|
71 |
public CoordinateTransformation getCoordinateTransformation(String wkt) |
|
72 |
throws CoordinateOperationNotFoundException { |
|
73 |
// TODO Auto-generated method stub |
|
74 |
return null; |
|
75 |
} |
|
69 | 76 |
|
70 |
public DynObject createParameters() { |
|
71 |
// Nothing to do |
|
72 |
return null; |
|
73 |
} |
|
77 |
@Override |
|
78 |
public CoordinateTransformation getCoordinateTransformation(TransformationDefinition definition) |
|
79 |
throws CoordinateOperationNotFoundException { |
|
80 |
// TODO Auto-generated method stub |
|
81 |
return null; |
|
82 |
} |
|
74 | 83 |
|
75 |
public void initialize(DynObject parameters) { |
|
76 |
// Nothing to do |
|
77 |
} |
|
78 |
|
|
79 | 84 |
} |
80 | 85 |
|
81 | 86 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/CoordinateOperation.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2018 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
import org.gvsig.proj.catalogue.TransformationDefinition; |
|
26 |
|
|
27 |
/** |
|
28 |
* Representation of a conversion or transformation between map |
|
29 |
* {@link CoordinateReferenceSystem}s. |
|
30 |
* |
|
31 |
* @see http://en.wikipedia.org/wiki/Map_projection |
|
32 |
* @see http://en.wikipedia.org/wiki/Coordinate_reference_system |
|
33 |
* @author gvSIG Team |
|
34 |
*/ |
|
35 |
public interface CoordinateOperation { |
|
36 |
|
|
37 |
/** |
|
38 |
* Returns the {@link CoordinateReferenceSystem} of the coordinates to be |
|
39 |
* converted from. |
|
40 |
* |
|
41 |
* @return the coordinates original {@link CoordinateReferenceSystem} |
|
42 |
*/ |
|
43 |
CoordinateReferenceSystem getSource(); |
|
44 |
|
|
45 |
/** |
|
46 |
* Returns the {@link CoordinateReferenceSystem} of the coordinates to be |
|
47 |
* converted to. |
|
48 |
* |
|
49 |
* @return the coordinates target {@link CoordinateReferenceSystem} |
|
50 |
*/ |
|
51 |
CoordinateReferenceSystem getTarget(); |
|
52 |
|
|
53 |
/** |
|
54 |
* Converts coordinates from their source projection to the target one. |
|
55 |
* |
|
56 |
* @param point |
|
57 |
* values of the coordinates to convert. |
|
58 |
* The converted values will be written over the same array given |
|
59 |
* as parameter |
|
60 |
*/ |
|
61 |
void apply(double[] point); |
|
62 |
|
|
63 |
/** |
|
64 |
* Converts coordinates from their source projection to the target one. |
|
65 |
* |
|
66 |
* @param srcPoint |
|
67 |
* values of the coordinates to convert. |
|
68 |
* @param srcPoint |
|
69 |
* a target array to hold the converted coordinates |
|
70 |
*/ |
|
71 |
void apply(double[] srcPoint, double[] dstPoint); |
|
72 |
|
|
73 |
/** |
|
74 |
* Returns a {@link CoordinateTransformation} object which is able to |
|
75 |
* convert coordinates, but performing the opposite conversion, using this |
|
76 |
* transformation source projection as the target one, and using the |
|
77 |
* target projection as the source one. |
|
78 |
* |
|
79 |
* @return a {@link CoordinateTransformation} for the opposite conversion |
|
80 |
*/ |
|
81 |
CoordinateOperation getInverse(); |
|
82 |
|
|
83 |
/** |
|
84 |
* Gets the definition of the coordinate operation. The CoordinateOperationDefinition |
|
85 |
* fully defines the operation |
|
86 |
* |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
TransformationDefinition getDefinition(); |
|
90 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/Datum.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
|
|
26 |
/** |
|
27 |
* A geodetic datum (plural datums, not data) is a reference from which |
|
28 |
* measurements are made. In surveying and geodesy, a datum is a set of |
|
29 |
* reference points on the Earth's surface against which position measurements |
|
30 |
* are made and (often) an associated model of the shape of the Earth (reference |
|
31 |
* ellipsoid) to define a geographic coordinate system. |
|
32 |
* |
|
33 |
* @see http://en.wikipedia.org/wiki/Datum_%28geodesy%29 |
|
34 |
* @see http://en.wikipedia.org/wiki/Geodetic_system |
|
35 |
* |
|
36 |
* @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a> |
|
37 |
* @version $Rev$ |
|
38 |
* @since 0.1.0 |
|
39 |
*/ |
|
40 |
public interface Datum { |
|
41 |
|
|
42 |
/** |
|
43 |
* Returns the Datum short name, like the one used in ProJ4 definitions. |
|
44 |
* |
|
45 |
* @return the short name. |
|
46 |
*/ |
|
47 |
public String getShortName(); |
|
48 |
|
|
49 |
/** |
|
50 |
* Returns the Datum name. |
|
51 |
* |
|
52 |
* @return the Datum name |
|
53 |
*/ |
|
54 |
public String getName(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Returns the {@link Ellipsoid} used in this Datum. |
|
58 |
* |
|
59 |
* @return the related {@link Ellipsoid} |
|
60 |
*/ |
|
61 |
public Ellipsoid getEllipsoid(); |
|
62 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/Ellipsoid.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.proj; |
|
24 |
|
|
25 |
|
|
26 |
/** |
|
27 |
* In geodesy, a reference ellipsoid is a mathematically-defined surface that |
|
28 |
* approximates the geoid, the truer figure of the Earth, or other planetary |
|
29 |
* body. Because of their relative simplicity, reference ellipsoids are used as |
|
30 |
* a preferred surface on which geodetic network computations are performed and |
|
31 |
* point coordinates such as latitude, longitude, and elevation are defined. |
|
32 |
* |
|
33 |
* @see http://en.wikipedia.org/wiki/Reference_ellipsoid |
|
34 |
* |
|
35 |
* @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a> |
|
36 |
* @version $Rev$ |
|
37 |
* @since 0.1.0 |
|
38 |
*/ |
|
39 |
public interface Ellipsoid { |
|
40 |
|
|
41 |
/** |
|
42 |
* Returns the Ellipsoid short name, like the one used in ProJ4 definitions. |
|
43 |
* |
|
44 |
* @return the Ellipsoid short name. |
|
45 |
*/ |
|
46 |
public String getShortName(); |
|
47 |
|
|
48 |
/** |
|
49 |
* Return the name of the Ellipsoid. |
|
50 |
* |
|
51 |
* @return the name of the Ellipsoid |
|
52 |
*/ |
|
53 |
public String getName(); |
|
54 |
|
|
55 |
/** |
|
56 |
* Returns the the equatorial radius or semi-major axis value. |
|
57 |
* |
|
58 |
* @return the equatorial radius or semi-major axis. |
|
59 |
*/ |
|
60 |
public double getSemiMajorAxis(); |
|
61 |
|
|
62 |
/** |
|
63 |
* Returns the polar radius or semi-minor axis value. |
|
64 |
* |
|
65 |
* @return the polar radius or semi-minor axis. |
|
66 |
*/ |
|
67 |
public double getSemiMinorAxis(); |
|
68 |
|
|
69 |
/** |
|
70 |
* Returns the reciprocal flattening. |
|
71 |
* |
|
72 |
* @return the reciprocal flattening. |
|
73 |
*/ |
|
74 |
public double getReciprocalFlattening(); |
|
75 |
|
|
76 |
} |
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/CoordinateReferenceSystemManager.java | ||
---|---|---|
51 | 51 |
/** |
52 | 52 |
* Returns a Coordinate Reference System. |
53 | 53 |
* |
54 |
* @param authorityName |
|
55 |
* name of the Authority who defines de Coordinate Reference |
|
56 |
* System |
|
57 |
* @param code |
|
58 |
* the code used by the Authority to identify the Coordinate |
|
59 |
* Reference System |
|
60 |
* @return the projection |
|
54 |
* @param definition |
|
61 | 55 |
* @throws CoordinateReferenceSystemNotFoundException |
62 |
* if there is not any Coordinate Reference System available in |
|
63 |
* the library with the given reference |
|
64 | 56 |
*/ |
65 | 57 |
CoordinateReferenceSystem getCoordinateReferenceSystem( |
66 |
String authorityName, String code) |
|
67 |
throws CoordinateReferenceSystemNotFoundException; |
|
68 |
|
|
69 |
/** |
|
70 |
* Returns a Coordinate Reference System. |
|
71 |
* |
|
72 |
* @param definition |
|
73 |
*/ |
|
74 |
CoordinateReferenceSystem getCoordinateReferenceSystem( |
|
75 | 58 |
CRSDefinition definition) |
76 | 59 |
throws CoordinateReferenceSystemNotFoundException; |
77 | 60 |
|
78 | 61 |
/** |
79 |
* Returns a Coordinate Operation |
|
80 |
* @param authorityName |
|
81 |
* @param code |
|
62 |
* Returns a Coordinate Transformation |
|
63 |
* @param wkt Well Known Text representation of the transformation |
|
82 | 64 |
* @return |
83 | 65 |
* @throws CoordinateReferenceSystemNotFoundException |
84 | 66 |
*/ |
85 |
CoordinateOperation getCoordinateOperation(
|
|
86 |
String authorityName, String code)
|
|
67 |
CoordinateTransformation getCoordinateTransformation(
|
|
68 |
String wkt)
|
|
87 | 69 |
throws CoordinateOperationNotFoundException; |
88 | 70 |
|
89 | 71 |
/** |
90 |
* Returns a Coordinate Operation
|
|
72 |
* Returns a Coordinate Transformation
|
|
91 | 73 |
* |
92 | 74 |
* @param definition |
93 | 75 |
*/ |
Also available in: Unified diff