Revision 813
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.lib.impl/src/main/java/org/gvsig/sis/proj/lib/SisCrsLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2018gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.sis.proj.lib; |
|
25 |
|
|
26 |
import org.gvsig.proj.catalog.CRSCatalogLocator; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
|
|
30 |
/** |
|
31 |
* Library to register the Apache SIS-based implementation of the |
|
32 |
* org.gvsig.proj.catalog API. |
|
33 |
* |
|
34 |
* @author Cesar Martinez Izquierdo |
|
35 |
*/ |
|
36 |
public class SisCrsLibrary extends AbstractLibrary { |
|
37 |
|
|
38 |
public SisCrsLibrary() { |
|
39 |
//registerAsImplementationOf(CoordinateReferenceSystemLibrary.class); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doInitialize() throws LibraryException { |
|
44 |
CRSCatalogLocator.registerManager(SisCoordinateReferenceSystemManager.class); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
protected void doPostInitialize() throws LibraryException { |
|
49 |
// TODO Auto-generated method stub |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.lib.impl/src/main/java/org/gvsig/sis/proj/lib/DefaultCoordinateReferenceSystem.java | ||
---|---|---|
1 |
package org.gvsig.sis.proj.lib; |
|
2 |
|
|
3 |
import org.apache.sis.referencing.CRS; |
|
4 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
5 |
import org.gvsig.proj.CoordinateReferenceSystemException; |
|
6 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
|
7 |
import org.gvsig.proj.catalog.CRSCatalogManager; |
|
8 |
import org.gvsig.proj.catalog.CRSDefinition; |
|
9 |
import org.gvsig.proj.catalog.exception.CoordinateReferenceSystemNotFoundException; |
|
10 |
import org.gvsig.sis.proj.catalog.DefaultCRSDefinition; |
|
11 |
import org.gvsig.sis.proj.catalog.SisCRSCatalogManager; |
|
12 |
import org.opengis.util.FactoryException; |
|
13 |
|
|
14 |
public class DefaultCoordinateReferenceSystem implements CoordinateReferenceSystem { |
|
15 |
private org.opengis.referencing.crs.CoordinateReferenceSystem crs = null; |
|
16 |
private CRSDefinition definition = null; |
|
17 |
|
|
18 |
public DefaultCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs) { |
|
19 |
this.crs = crs; |
|
20 |
} |
|
21 |
|
|
22 |
public DefaultCoordinateReferenceSystem(CRSDefinition definition) throws CoordinateReferenceSystemException { |
|
23 |
if (definition instanceof DefaultCRSDefinition) { |
|
24 |
DefaultCRSDefinition def = (DefaultCRSDefinition) definition; |
|
25 |
this.definition = def; |
|
26 |
this.crs = def.getInternalCRS(); |
|
27 |
} |
|
28 |
else { |
|
29 |
this.definition = definition; |
|
30 |
try { |
|
31 |
this.crs = CRS.fromWKT(definition.toWKT()); |
|
32 |
} catch (UnsupportedOperationException | FactoryException e) { |
|
33 |
throw new CoordinateReferenceSystemException(e); |
|
34 |
} |
|
35 |
} |
|
36 |
} |
|
37 |
|
|
38 |
public DefaultCoordinateReferenceSystem(String wktDefinition) throws CoordinateReferenceSystemException { |
|
39 |
try { |
|
40 |
this.crs = CRS.fromWKT(wktDefinition); |
|
41 |
} catch (FactoryException e) { |
|
42 |
throw new CoordinateReferenceSystemException(e); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public CRSDefinition getDefinition() throws CoordinateReferenceSystemNotFoundException, UnsupportedOperationException { |
|
48 |
if (definition==null) { |
|
49 |
SisCoordinateReferenceSystemManager manager = (SisCoordinateReferenceSystemManager) CoordinateReferenceSystemLocator.getManager(); |
|
50 |
CRSCatalogManager catManager = manager.getCatalogManager(); |
|
51 |
if (catManager instanceof SisCRSCatalogManager) { |
|
52 |
SisCRSCatalogManager sisCatManager = (SisCRSCatalogManager) catManager; |
|
53 |
definition = sisCatManager.getCRSDefinition(crs); |
|
54 |
} |
|
55 |
else { |
|
56 |
definition = catManager.getCRSDefinitionFromWKT(crs.toWKT()); |
|
57 |
} |
|
58 |
} |
|
59 |
return definition; |
|
60 |
} |
|
61 |
|
|
62 |
public Object clone() { // FIXME: do we need clone?? |
|
63 |
return new DefaultCoordinateReferenceSystem(this.crs); |
|
64 |
} |
|
65 |
|
|
66 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.lib.impl/src/main/java/org/gvsig/sis/proj/lib/DefaultCoordinateTransformation.java | ||
---|---|---|
1 |
package org.gvsig.sis.proj.lib; |
|
2 |
|
|
3 |
import java.text.ParseException; |
|
4 |
|
|
5 |
import org.apache.sis.io.wkt.WKTFormat; |
|
6 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
7 |
import org.gvsig.proj.CoordinateReferenceSystemException; |
|
8 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
|
9 |
import org.gvsig.proj.CoordinateTransformation; |
|
10 |
import org.gvsig.proj.catalog.CRSCatalogManager; |
|
11 |
import org.gvsig.proj.catalog.TransformationDefinition; |
|
12 |
import org.gvsig.sis.proj.catalog.DefaultTransformationDefinition; |
|
13 |
import org.gvsig.sis.proj.catalog.SisCRSCatalogManager; |
|
14 |
import org.opengis.referencing.operation.CoordinateOperation; |
|
15 |
import org.opengis.referencing.operation.MathTransform; |
|
16 |
import org.opengis.referencing.operation.NoninvertibleTransformException; |
|
17 |
import org.opengis.referencing.operation.TransformException; |
|
18 |
|
|
19 |
public class DefaultCoordinateTransformation implements CoordinateTransformation { |
|
20 |
private CoordinateOperation operation; |
|
21 |
private boolean inverse = false; |
|
22 |
private MathTransform mathTransform = null; |
|
23 |
private TransformationDefinition definition = null; |
|
24 |
private CoordinateReferenceSystem source = null; |
|
25 |
private CoordinateReferenceSystem target = null; |
|
26 |
|
|
27 |
public DefaultCoordinateTransformation(CoordinateOperation operation) { |
|
28 |
this.operation = operation; |
|
29 |
} |
|
30 |
|
|
31 |
public DefaultCoordinateTransformation(CoordinateOperation operation, boolean inverse) throws org.gvsig.proj.catalog.exception.NoninvertibleTransformException { |
|
32 |
this.operation = operation; |
|
33 |
if (inverse) { |
|
34 |
try { |
|
35 |
this.mathTransform = operation.getMathTransform().inverse(); |
|
36 |
} catch (NoninvertibleTransformException e) { |
|
37 |
String name = operation.getName().toString(); |
|
38 |
throw new org.gvsig.proj.catalog.exception.NoninvertibleTransformException(name, e); |
|
39 |
} |
|
40 |
} |
|
41 |
this.inverse = inverse; |
|
42 |
} |
|
43 |
|
|
44 |
|
|
45 |
public DefaultCoordinateTransformation(TransformationDefinition definition) throws ParseException, CoordinateReferenceSystemException { |
|
46 |
if (definition instanceof DefaultTransformationDefinition) { |
|
47 |
DefaultTransformationDefinition def = (DefaultTransformationDefinition) definition; |
|
48 |
this.definition = def; |
|
49 |
this.operation = def.getInternalOperation(); |
|
50 |
this.inverse = def.isInverse(); |
|
51 |
} |
|
52 |
else { |
|
53 |
this.definition = definition; |
|
54 |
try { |
|
55 |
WKTFormat format = new WKTFormat(null, null); |
|
56 |
Object obj = format.parseObject(definition.toWKT()); |
|
57 |
this.operation = (CoordinateOperation) obj; |
|
58 |
} catch (UnsupportedOperationException e) { |
|
59 |
throw new CoordinateReferenceSystemException(e); |
|
60 |
} |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public CoordinateReferenceSystem getSource() { |
|
66 |
if (source==null) { |
|
67 |
if (inverse) { |
|
68 |
source = new DefaultCoordinateReferenceSystem(operation.getTargetCRS()); |
|
69 |
} |
|
70 |
else { |
|
71 |
source = new DefaultCoordinateReferenceSystem(operation.getSourceCRS()); |
|
72 |
} |
|
73 |
} |
|
74 |
return source; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public CoordinateReferenceSystem getTarget() { |
|
79 |
if (target==null) { |
|
80 |
if (inverse) { |
|
81 |
source = new DefaultCoordinateReferenceSystem(operation.getSourceCRS()); |
|
82 |
} |
|
83 |
else { |
|
84 |
target = new DefaultCoordinateReferenceSystem(operation.getTargetCRS()); |
|
85 |
} |
|
86 |
} |
|
87 |
return target; |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void apply(double[] point) { |
|
92 |
try { |
|
93 |
if (mathTransform==null) { |
|
94 |
if (inverse) { |
|
95 |
mathTransform = operation.getMathTransform().inverse(); |
|
96 |
} |
|
97 |
else { |
|
98 |
mathTransform = operation.getMathTransform(); |
|
99 |
} |
|
100 |
} |
|
101 |
mathTransform.transform(point, 0, point, 0, 1); |
|
102 |
} catch (TransformException e) { |
|
103 |
// TODO Auto-generated catch block |
|
104 |
e.printStackTrace(); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public void apply(double[] srcPoint, double[] dstPoint) { |
|
110 |
try { |
|
111 |
if (mathTransform==null) { |
|
112 |
if (inverse) { |
|
113 |
mathTransform = operation.getMathTransform().inverse(); |
|
114 |
} |
|
115 |
else { |
|
116 |
mathTransform = operation.getMathTransform(); |
|
117 |
} |
|
118 |
} |
|
119 |
mathTransform.transform(srcPoint, 0, dstPoint, 0, 1); |
|
120 |
} catch (TransformException e) { |
|
121 |
// TODO Auto-generated catch block |
|
122 |
e.printStackTrace(); |
|
123 |
} |
|
124 |
|
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public CoordinateTransformation getInverse() throws org.gvsig.proj.catalog.exception.NoninvertibleTransformException { |
|
129 |
return new DefaultCoordinateTransformation(this.operation, (!this.inverse)); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public TransformationDefinition getDefinition() { |
|
134 |
if (definition==null) { |
|
135 |
SisCoordinateReferenceSystemManager manager = (SisCoordinateReferenceSystemManager) CoordinateReferenceSystemLocator.getManager(); |
|
136 |
CRSCatalogManager catManager = manager.getCatalogManager(); |
|
137 |
if (catManager instanceof SisCRSCatalogManager) { |
|
138 |
SisCRSCatalogManager sisCatManager = (SisCRSCatalogManager) catManager; |
|
139 |
definition = sisCatManager.getTransformationDefinition(operation, inverse); |
|
140 |
} |
|
141 |
else { |
|
142 |
definition = catManager.getTransformationDefinitionFromWKT(operation.toWKT()); |
|
143 |
} |
|
144 |
} |
|
145 |
return definition; |
|
146 |
} |
|
147 |
|
|
148 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.lib.impl/src/main/java/org/gvsig/sis/proj/lib/SisCoordinateReferenceSystemManager.java | ||
---|---|---|
1 |
package org.gvsig.sis.proj.lib; |
|
2 |
|
|
3 |
import java.text.ParseException; |
|
4 |
|
|
5 |
import org.apache.sis.io.wkt.WKTFormat; |
|
6 |
import org.gvsig.proj.CoordinateOperationNotFoundException; |
|
7 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
8 |
import org.gvsig.proj.CoordinateReferenceSystemException; |
|
9 |
import org.gvsig.proj.CoordinateReferenceSystemManager; |
|
10 |
import org.gvsig.proj.CoordinateTransformation; |
|
11 |
import org.gvsig.proj.catalog.CRSCatalogLocator; |
|
12 |
import org.gvsig.proj.catalog.CRSCatalogManager; |
|
13 |
import org.gvsig.proj.catalog.CRSDefinition; |
|
14 |
import org.gvsig.proj.catalog.TransformationDefinition; |
|
15 |
import org.opengis.referencing.operation.CoordinateOperation; |
|
16 |
|
|
17 |
public class SisCoordinateReferenceSystemManager implements CoordinateReferenceSystemManager { |
|
18 |
private CRSCatalogManager catalogManager = null; |
|
19 |
|
|
20 |
public SisCoordinateReferenceSystemManager() { |
|
21 |
} |
|
22 |
|
|
23 |
@Override |
|
24 |
public CoordinateReferenceSystem getCoordinateReferenceSystem(String wkt) |
|
25 |
throws CoordinateReferenceSystemException { |
|
26 |
return new DefaultCoordinateReferenceSystem(wkt); |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
public CoordinateReferenceSystem getCoordinateReferenceSystem(CRSDefinition definition) |
|
31 |
throws CoordinateReferenceSystemException { |
|
32 |
return new DefaultCoordinateReferenceSystem(definition); |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public CoordinateTransformation getCoordinateTransformation(String wkt) |
|
38 |
throws CoordinateOperationNotFoundException, ParseException { |
|
39 |
WKTFormat format = new WKTFormat(null, null); |
|
40 |
Object obj = format.parseObject(wkt); |
|
41 |
CoordinateOperation operation = (CoordinateOperation) obj; |
|
42 |
return new DefaultCoordinateTransformation(operation); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public CoordinateTransformation getCoordinateTransformation(TransformationDefinition definition) |
|
47 |
throws CoordinateReferenceSystemException, ParseException { |
|
48 |
return new DefaultCoordinateTransformation(definition); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public void setCatalogManager(CRSCatalogManager manager) { |
|
53 |
this.catalogManager = manager; |
|
54 |
} |
|
55 |
|
|
56 |
public CRSCatalogManager getCatalogManager() { |
|
57 |
if( this.catalogManager == null ) { |
|
58 |
this.catalogManager = CRSCatalogLocator.getManager(); |
|
59 |
} |
|
60 |
return this.catalogManager; |
|
61 |
} |
|
62 |
|
|
63 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.lib.impl/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.sis.proj.lib.impl</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<description>Implementation of the catalog of coordinate reference systems (CRSs) based on Apache SIS library.</description> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.sis.proj</artifactId> |
|
11 |
<version>1.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
<!-- gvsig --> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.tools</artifactId> |
|
19 |
<version>${gvsig.tools.version}</version> |
|
20 |
<type>pom</type> |
|
21 |
<scope>import</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.proj.lib.api</artifactId> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.proj.catalog.api</artifactId> |
|
30 |
</dependency> |
|
31 |
|
|
32 |
<!-- external --> |
|
33 |
<dependency> |
|
34 |
<groupId>org.apache.sis.core</groupId> |
|
35 |
<artifactId>sis-referencing</artifactId> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.apache.sis.non-free</groupId> |
|
39 |
<artifactId>sis-epsg</artifactId> |
|
40 |
<scope>runtime</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.apache.derby</groupId> |
|
44 |
<artifactId>derby</artifactId> |
|
45 |
<scope>runtime</scope> |
|
46 |
</dependency> |
|
47 |
|
|
48 |
<!-- internal --> |
|
49 |
<dependency> |
|
50 |
<groupId>org.gvsig</groupId> |
|
51 |
<artifactId>org.gvsig.sis.proj.catalog.impl</artifactId> |
|
52 |
<type>test-jar</type> |
|
53 |
<scope>test</scope> |
|
54 |
</dependency> |
|
55 |
</dependencies> |
|
56 |
</project> |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.catalog.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.sis.proj.catalog.app</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
|
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.sis.proj</artifactId> |
|
10 |
<version>1.0.0-SNAPSHOT</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.proj.lib.api</artifactId> |
|
16 |
</dependency> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.proj.catalog.api</artifactId> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.sis.proj.catalog.impl</artifactId> |
|
24 |
</dependency> |
|
25 |
</dependencies> |
|
26 |
|
|
27 |
<properties> |
|
28 |
<!-- Package info property values --> |
|
29 |
<!-- Default values in org.gvsig.desktop --> |
|
30 |
<gvsig.package.info.name>CRS Catalog support: Apache SIS-based implementation</gvsig.package.info.name> |
|
31 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
32 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
33 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.1</gvsig.package.info.dependencies> |
|
34 |
<gvsig.package.info.categories>Base</gvsig.package.info.categories> |
|
35 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-jcrs/pool/</gvsig.package.info.poolURL> |
|
36 |
</properties></project> |
|
37 |
|
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.catalog.impl/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.sis.proj.catalog.impl</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<description>Implementation of the catalog of coordinate reference systems (CRSs) based on Apache SIS library.</description> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.sis.proj</artifactId> |
|
11 |
<version>1.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
<!-- gvsig --> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.tools</artifactId> |
|
19 |
<version>${gvsig.tools.version}</version> |
|
20 |
<type>pom</type> |
|
21 |
<scope>import</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.proj.lib.api</artifactId> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.proj.catalog.api</artifactId> |
|
30 |
</dependency> |
|
31 |
|
|
32 |
<!-- external --> |
|
33 |
<dependency> |
|
34 |
<groupId>org.apache.sis.core</groupId> |
|
35 |
<artifactId>sis-referencing</artifactId> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.apache.sis.non-free</groupId> |
|
39 |
<artifactId>sis-epsg</artifactId> |
|
40 |
<scope>runtime</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.apache.derby</groupId> |
|
44 |
<artifactId>derby</artifactId> |
|
45 |
<scope>runtime</scope> |
|
46 |
</dependency> |
|
47 |
</dependencies> |
|
48 |
</project> |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.catalog.impl/src/main/java/org/gvsig/sis/proj/catalog/SisCRSCatalogManager.java | ||
---|---|---|
1 |
package org.gvsig.sis.proj.catalog; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
7 |
import java.util.ServiceLoader; |
|
8 |
import java.util.Set; |
|
9 |
|
|
10 |
import org.apache.sis.referencing.CRS; |
|
11 |
import org.gvsig.proj.catalog.CRSCatalogManager; |
|
12 |
import org.gvsig.proj.catalog.CRSDefinition; |
|
13 |
import org.gvsig.proj.catalog.TransformationDefinition; |
|
14 |
import org.gvsig.proj.catalog.exception.CRSCatalogException; |
|
15 |
import org.gvsig.proj.catalog.exception.CoordinateReferenceSystemNotFoundException; |
|
16 |
import org.gvsig.proj.catalog.exception.IncompatibleDefinitionException; |
|
17 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
18 |
import org.opengis.referencing.crs.CRSAuthorityFactory; |
|
19 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
20 |
import org.opengis.referencing.operation.CoordinateOperation; |
|
21 |
import org.opengis.util.FactoryException; |
|
22 |
|
|
23 |
public class SisCRSCatalogManager implements CRSCatalogManager { |
|
24 |
|
|
25 |
public SisCRSCatalogManager() { |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
public List<String> getAuthorityNames() { |
|
30 |
ArrayList<String> authNames = new ArrayList<String>(); |
|
31 |
ServiceLoader<CRSAuthorityFactory> loader = (ServiceLoader<CRSAuthorityFactory>) ServiceLoader.load(CRSAuthorityFactory.class); |
|
32 |
Iterator<CRSAuthorityFactory> iterator = loader.iterator(); |
|
33 |
CRSAuthorityFactory factory; |
|
34 |
while (iterator.hasNext()) { |
|
35 |
factory = iterator.next(); |
|
36 |
authNames.add(factory.getAuthority().getTitle().toString()); |
|
37 |
} |
|
38 |
return authNames; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public List<String> getCodes() { |
|
43 |
ArrayList<String> codes = new ArrayList<String>(); |
|
44 |
ServiceLoader<CRSAuthorityFactory> loader = (ServiceLoader<CRSAuthorityFactory>) ServiceLoader.load(CRSAuthorityFactory.class); |
|
45 |
Iterator<CRSAuthorityFactory> iterator = loader.iterator(); |
|
46 |
CRSAuthorityFactory factory; |
|
47 |
while (iterator.hasNext()) { |
|
48 |
factory = iterator.next(); |
|
49 |
Set<String> authCodes; |
|
50 |
try { |
|
51 |
authCodes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); |
|
52 |
for (String code: authCodes) { |
|
53 |
codes.add(code); |
|
54 |
} |
|
55 |
} catch (FactoryException e) { |
|
56 |
// TODO Auto-generated catch block |
|
57 |
e.printStackTrace(); |
|
58 |
} |
|
59 |
|
|
60 |
} |
|
61 |
return codes; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public List<String> getCodes(String authorityName) { |
|
66 |
ArrayList<String> codes = new ArrayList<String>(); |
|
67 |
try { |
|
68 |
CRSAuthorityFactory factory = CRS.getAuthorityFactory(authorityName); |
|
69 |
Set<String> authCodes; |
|
70 |
authCodes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); |
|
71 |
for (String code: authCodes) { |
|
72 |
codes.add(code); |
|
73 |
} |
|
74 |
} catch (FactoryException e) { |
|
75 |
// TODO Auto-generated catch block |
|
76 |
e.printStackTrace(); |
|
77 |
} |
|
78 |
|
|
79 |
return codes; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public List<String> search(String searchString) { |
|
84 |
// TODO Auto-generated method stub |
|
85 |
return null; |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public List<String> search(String authority, String searchString) { |
|
90 |
// TODO Auto-generated method stub |
|
91 |
return null; |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public CRSDefinition getCRSDefinition(String code) throws CoordinateReferenceSystemNotFoundException { |
|
96 |
CoordinateReferenceSystem crs; |
|
97 |
try { |
|
98 |
crs = CRS.forCode(code); |
|
99 |
} catch (NoSuchAuthorityCodeException e) { |
|
100 |
throw new CoordinateReferenceSystemNotFoundException(code, e); |
|
101 |
} catch (FactoryException e) { |
|
102 |
// FIXME: authoritynotfoundexception; |
|
103 |
throw new CoordinateReferenceSystemNotFoundException(code, e); |
|
104 |
} |
|
105 |
return new DefaultCRSDefinition(crs); |
|
106 |
} |
|
107 |
|
|
108 |
public CRSDefinition getCRSDefinition(CoordinateReferenceSystem crs) throws CoordinateReferenceSystemNotFoundException { |
|
109 |
return new DefaultCRSDefinition(crs); |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public CRSDefinition getCRSDefinitionFromWKT(String wkt) throws CoordinateReferenceSystemNotFoundException { |
|
114 |
CoordinateReferenceSystem crs; |
|
115 |
try { |
|
116 |
crs = CRS.fromWKT(wkt); |
|
117 |
} catch (NoSuchAuthorityCodeException e) { |
|
118 |
// FIXME: unsupported crs type; // FIXME: failed parsing?? |
|
119 |
throw new CoordinateReferenceSystemNotFoundException(wkt, e); |
|
120 |
} catch (FactoryException e) { |
|
121 |
// FIXME: authoritynotfoundexception; |
|
122 |
throw new CoordinateReferenceSystemNotFoundException(wkt, e); |
|
123 |
} |
|
124 |
return new DefaultCRSDefinition(crs); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public CRSDefinition getCompoundCRS(CRSDefinition... crsList) throws IncompatibleDefinitionException { |
|
129 |
DefaultCRSDefinition[] defs = (DefaultCRSDefinition[]) crsList; |
|
130 |
ArrayList<CoordinateReferenceSystem> components = new ArrayList<CoordinateReferenceSystem>(); |
|
131 |
for (CRSDefinition def: defs) { |
|
132 |
if (def instanceof DefaultCRSDefinition) { |
|
133 |
components.add(((DefaultCRSDefinition)def).getInternalCRS()); |
|
134 |
} |
|
135 |
else { |
|
136 |
throw new IncompatibleDefinitionException(); |
|
137 |
} |
|
138 |
|
|
139 |
} |
|
140 |
CoordinateReferenceSystem compoundCRS; |
|
141 |
try { |
|
142 |
compoundCRS = CRS.compound(components.toArray(new CoordinateReferenceSystem[components.size()])); |
|
143 |
return new DefaultCRSDefinition(compoundCRS); |
|
144 |
} catch (FactoryException e) { |
|
145 |
// FIXME: which kind of exception |
|
146 |
throw new IncompatibleDefinitionException(e); |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public TransformationDefinition getTransformationDefinition(String code) { |
|
152 |
// TODO Auto-generated method stub |
|
153 |
return null; |
|
154 |
} |
|
155 |
|
|
156 |
public TransformationDefinition getTransformationDefinition(CoordinateOperation operation, boolean inverse) { |
|
157 |
// TODO Auto-generated method stub |
|
158 |
return null; |
|
159 |
} |
|
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 registerCoordinateReferenceSystem(String wktDefinition, String description) { |
|
169 |
// TODO Auto-generated method stub |
|
170 |
return null; |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public String registerTransformation(String wktDefinition, String description) { |
|
175 |
// TODO Auto-generated method stub |
|
176 |
return null; |
|
177 |
} |
|
178 |
|
|
179 |
@Override |
|
180 |
public String registerCoordinateTransformationPVT(String sourceCRS, String targetCRS, String description, |
|
181 |
float xTraslation, float yTraslation, float zTraslation, float xRotation, float yRotation, float zRotation, |
|
182 |
float scaleDifference) { |
|
183 |
// TODO Auto-generated method stub |
|
184 |
return null; |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public String registerCoordinateTransformationCFR(String sourceCRS, String targetCRS, String description, |
|
189 |
float xTraslation, float yTraslation, float zTraslation, float xRotation, float yRotation, float zRotation, |
|
190 |
float scaleDifference) { |
|
191 |
// TODO Auto-generated method stub |
|
192 |
return null; |
|
193 |
} |
|
194 |
|
|
195 |
@Override |
|
196 |
public String registerCoordinateTransformation(String sourceCRS, String targetCRS, String description, |
|
197 |
File ntv2Grid) { |
|
198 |
// TODO Auto-generated method stub |
|
199 |
return null; |
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
public List<TransformationDefinition> getCoordinateTransformations(CRSDefinition source, CRSDefinition target) throws CRSCatalogException { |
|
204 |
ArrayList<TransformationDefinition> transforms = new ArrayList<TransformationDefinition>(); |
|
205 |
try { |
|
206 |
CoordinateReferenceSystem sourceCRS = ((DefaultCRSDefinition)source).getInternalCRS(); |
|
207 |
CoordinateReferenceSystem targetCRS = ((DefaultCRSDefinition)target).getInternalCRS(); |
|
208 |
DefaultTransformationDefinition def = new DefaultTransformationDefinition(CRS.findOperation(sourceCRS, targetCRS, null)); |
|
209 |
transforms.add(def); |
|
210 |
} catch (NoSuchAuthorityCodeException e) { |
|
211 |
// TODO Auto-generated catch block |
|
212 |
e.printStackTrace(); |
|
213 |
} catch (FactoryException e) { |
|
214 |
// TODO Auto-generated catch block |
|
215 |
e.printStackTrace(); |
|
216 |
} catch (ClassCastException e) { |
|
217 |
throw new IncompatibleDefinitionException(e); |
|
218 |
} |
|
219 |
return transforms; |
|
220 |
} |
|
221 |
|
|
222 |
@Override |
|
223 |
public List<TransformationDefinition> getCoordinateTransformations(String source, String target) { |
|
224 |
ArrayList<TransformationDefinition> transforms = new ArrayList<TransformationDefinition>(); |
|
225 |
try { |
|
226 |
CoordinateReferenceSystem sourceCRS = CRS.forCode(source); |
|
227 |
CoordinateReferenceSystem targetCRS = CRS.forCode(target); |
|
228 |
DefaultTransformationDefinition def = new DefaultTransformationDefinition(CRS.findOperation(sourceCRS, targetCRS, null)); |
|
229 |
transforms.add(def); |
|
230 |
} catch (NoSuchAuthorityCodeException e) { |
|
231 |
// TODO Auto-generated catch block |
|
232 |
e.printStackTrace(); |
|
233 |
} catch (FactoryException e) { |
|
234 |
// TODO Auto-generated catch block |
|
235 |
e.printStackTrace(); |
|
236 |
} |
|
237 |
return transforms; |
|
238 |
} |
|
239 |
|
|
240 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.catalog.impl/src/main/java/org/gvsig/sis/proj/catalog/DefaultTransformationDefinition.java | ||
---|---|---|
1 |
package org.gvsig.sis.proj.catalog; |
|
2 |
|
|
3 |
import java.text.ParseException; |
|
4 |
import java.util.HashSet; |
|
5 |
import java.util.Set; |
|
6 |
|
|
7 |
import org.apache.sis.io.wkt.WKTFormat; |
|
8 |
import org.gvsig.proj.catalog.CRSDefinition; |
|
9 |
import org.gvsig.proj.catalog.TransformationDefinition; |
|
10 |
import org.gvsig.proj.catalog.exception.NoninvertibleTransformException; |
|
11 |
import org.gvsig.proj.catalog.ref.Extent; |
|
12 |
import org.opengis.referencing.ReferenceIdentifier; |
|
13 |
import org.opengis.referencing.operation.CoordinateOperation; |
|
14 |
import org.opengis.referencing.operation.Transformation; |
|
15 |
|
|
16 |
public class DefaultTransformationDefinition implements TransformationDefinition { |
|
17 |
CoordinateOperation operation = null; |
|
18 |
String wkt = null; |
|
19 |
private DefaultCRSDefinition source = null; |
|
20 |
private DefaultCRSDefinition target = null; |
|
21 |
boolean inverse = false; |
|
22 |
|
|
23 |
public DefaultTransformationDefinition(CoordinateOperation operation) { |
|
24 |
this.operation = operation; |
|
25 |
} |
|
26 |
|
|
27 |
public DefaultTransformationDefinition(CoordinateOperation operation, boolean inverse) throws NoninvertibleTransformException { |
|
28 |
this.operation = operation; |
|
29 |
try { |
|
30 |
operation.getMathTransform().inverse(); |
|
31 |
} |
|
32 |
catch (org.opengis.referencing.operation.NoninvertibleTransformException e) { |
|
33 |
throw new NoninvertibleTransformException(operation.getName().getCode()); |
|
34 |
} |
|
35 |
this.inverse = inverse; |
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
public DefaultTransformationDefinition(String wkt) throws ParseException { |
|
40 |
this.wkt = wkt; |
|
41 |
WKTFormat format = new WKTFormat(null, null); |
|
42 |
Object obj = format.parseObject(wkt); |
|
43 |
this.operation = (CoordinateOperation) obj; |
|
44 |
} |
|
45 |
|
|
46 |
public CoordinateOperation getInternalOperation() { |
|
47 |
return operation; |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
public CRSDefinition getSourceCRS() { |
|
52 |
if (source==null) { |
|
53 |
if (inverse) { |
|
54 |
source = new DefaultCRSDefinition(operation.getTargetCRS()); |
|
55 |
} |
|
56 |
else { |
|
57 |
source = new DefaultCRSDefinition(operation.getSourceCRS()); |
|
58 |
} |
|
59 |
} |
|
60 |
return source; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public CRSDefinition getTargetCRS() { |
|
65 |
if (target==null) { |
|
66 |
if (inverse) { |
|
67 |
target = new DefaultCRSDefinition(operation.getSourceCRS()); |
|
68 |
} |
|
69 |
else { |
|
70 |
target = new DefaultCRSDefinition(operation.getTargetCRS()); |
|
71 |
} |
|
72 |
} |
|
73 |
return target; |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public String getName() { |
|
78 |
// FIXME: compare with identifier |
|
79 |
return operation.getName().toString(); |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public String getIdentifier() { |
|
84 |
// FIXME: compare with name |
|
85 |
return operation.getName().toString(); |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public Set<String> getIdentifiers() { |
|
90 |
HashSet<String> ids = new HashSet<String>(); |
|
91 |
for (ReferenceIdentifier id: operation.getIdentifiers()) { |
|
92 |
ids.add(id.toString()); |
|
93 |
} |
|
94 |
return ids; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public String getAuthorityName() { |
|
99 |
return operation.getName().getAuthority().getTitle().toString(); |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public String getOperationVersion() { |
|
104 |
return operation.getOperationVersion(); |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public Extent getDomainOfValidity() { |
|
109 |
// TODO Auto-generated method stub |
|
110 |
return null; |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public String getDescription() { |
|
115 |
return operation.getScope() + "\nRemarks: " + operation.getRemarks(); |
|
116 |
} |
|
117 |
|
|
118 |
@Override |
|
119 |
public boolean isTransformation() { |
|
120 |
return (operation instanceof Transformation); |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public TransformationDefinition getInverse() throws NoninvertibleTransformException { |
|
125 |
return new DefaultTransformationDefinition(this.operation, true); |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public String toWKT() throws UnsupportedOperationException { |
|
130 |
// TODO Auto-generated method stub |
|
131 |
// FIXME: how to store the inverse transformation as wkt?? |
|
132 |
return null; |
|
133 |
} |
|
134 |
|
|
135 |
public boolean isInverse() { |
|
136 |
return inverse; |
|
137 |
} |
|
138 |
|
|
139 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.catalog.impl/src/main/java/org/gvsig/sis/proj/catalog/DefaultCRSDefinition.java | ||
---|---|---|
1 |
package org.gvsig.sis.proj.catalog; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashSet; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Set; |
|
7 |
|
|
8 |
import javax.measure.Unit; |
|
9 |
import javax.measure.quantity.Length; |
|
10 |
|
|
11 |
import org.apache.sis.referencing.CRS; |
|
12 |
import org.gvsig.proj.catalog.CRSDefinition; |
|
13 |
import org.gvsig.proj.catalog.CRSType; |
|
14 |
import org.gvsig.proj.catalog.CoordinateSystemAxis; |
|
15 |
import org.gvsig.proj.catalog.TransformationDefinition; |
|
16 |
import org.gvsig.proj.catalog.datum.Datum; |
|
17 |
import org.gvsig.proj.catalog.ref.Extent; |
|
18 |
import org.opengis.referencing.ReferenceIdentifier; |
|
19 |
import org.opengis.referencing.crs.CompoundCRS; |
|
20 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
21 |
import org.opengis.referencing.crs.GeneralDerivedCRS; |
|
22 |
import org.opengis.referencing.crs.GeocentricCRS; |
|
23 |
import org.opengis.referencing.crs.GeographicCRS; |
|
24 |
import org.opengis.referencing.crs.ProjectedCRS; |
|
25 |
import org.opengis.referencing.crs.TemporalCRS; |
|
26 |
import org.opengis.referencing.crs.VerticalCRS; |
|
27 |
import org.opengis.referencing.operation.Conversion; |
|
28 |
import org.opengis.util.FactoryException; |
|
29 |
|
|
30 |
public class DefaultCRSDefinition implements CRSDefinition { |
|
31 |
private CoordinateReferenceSystem crs = null; |
|
32 |
private String wkt = null; |
|
33 |
|
|
34 |
public DefaultCRSDefinition(String wktDefinition) { |
|
35 |
this.wkt = wktDefinition; |
|
36 |
try { |
|
37 |
this.crs = CRS.fromWKT(wktDefinition); |
|
38 |
} catch (FactoryException e) { |
|
39 |
// TODO Auto-generated catch block |
|
40 |
e.printStackTrace(); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
public DefaultCRSDefinition(CoordinateReferenceSystem crs) { |
|
45 |
this.crs = crs; |
|
46 |
} |
|
47 |
|
|
48 |
public CoordinateReferenceSystem getInternalCRS() { |
|
49 |
return crs; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getName() { |
|
54 |
// TODO Auto-generated method stub |
|
55 |
return null; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public String getIdentifier() { |
|
60 |
return crs.getName().toString(); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public Set<String> getIdentifiers() { |
|
65 |
HashSet<String> ids = new HashSet<String>(); |
|
66 |
for (ReferenceIdentifier id: crs.getIdentifiers()) { |
|
67 |
ids.add(id.toString()); |
|
68 |
} |
|
69 |
return ids; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String getAuthorityName() { |
|
74 |
return crs.getName().getAuthority().getTitle().toString(); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public Extent getDomainOfValidity() { |
|
79 |
// TODO Auto-generated method stub |
|
80 |
return null; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public String getDescription() { |
|
85 |
return crs.getScope() + "\nRemarks: " + crs.getRemarks(); |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public boolean isProjected() { |
|
90 |
return (crs instanceof ProjectedCRS); |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public CRSType getType() { |
|
95 |
if (crs instanceof ProjectedCRS) { |
|
96 |
return CRSType.ProjectedCRSType; |
|
97 |
} |
|
98 |
if (crs instanceof GeographicCRS) { |
|
99 |
return CRSType.GeographicCRSType; |
|
100 |
} |
|
101 |
if (crs instanceof GeocentricCRS) { |
|
102 |
return CRSType.GeocentricCRSType; |
|
103 |
} |
|
104 |
if (crs instanceof GeneralDerivedCRS) { |
|
105 |
return CRSType.OtherDerivedCRSType; |
|
106 |
} |
|
107 |
if (crs instanceof CompoundCRS) { |
|
108 |
return CRSType.CompoundCRSType; |
|
109 |
} |
|
110 |
if (crs instanceof VerticalCRS) { |
|
111 |
return CRSType.VerticalCRSType; |
|
112 |
} |
|
113 |
if (crs instanceof TemporalCRS) { |
|
114 |
return CRSType.TemporalCRSType; |
|
115 |
} |
|
116 |
return CRSType.OtherCRSType; |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public String toWKT() throws UnsupportedOperationException { |
|
121 |
if (wkt!=null) { |
|
122 |
return wkt; |
|
123 |
} |
|
124 |
return crs.toWKT(); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public List<CRSDefinition> getComponents() { |
|
129 |
if (crs instanceof CompoundCRS) { |
|
130 |
ArrayList<CRSDefinition> list = new ArrayList<CRSDefinition>(); |
|
131 |
for (CoordinateReferenceSystem component: ((CompoundCRS) crs).getComponents()) { |
|
132 |
list.add(new DefaultCRSDefinition(component)); |
|
133 |
} |
|
134 |
return list; |
|
135 |
} |
|
136 |
return null; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public int getAxisCount() { |
|
141 |
return crs.getCoordinateSystem().getDimension(); |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public CoordinateSystemAxis getAxis(int dimension) throws IndexOutOfBoundsException { |
|
146 |
// TODO Auto-generated method stub |
|
147 |
return null; |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public CoordinateSystemAxis getAxisInternal(int dimension) throws IndexOutOfBoundsException { |
|
152 |
// TODO Auto-generated method stub |
|
153 |
return null; |
|
154 |
} |
|
155 |
|
|
156 |
@Override |
|
157 |
public CRSDefinition getBaseCRS() { |
|
158 |
if (crs instanceof GeneralDerivedCRS) { |
|
159 |
CoordinateReferenceSystem base = ((GeneralDerivedCRS)crs).getBaseCRS(); |
|
160 |
return new DefaultCRSDefinition(base); |
|
161 |
} |
|
162 |
return null; |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public TransformationDefinition getConversionFromBase() { |
|
167 |
if (crs instanceof GeneralDerivedCRS) { |
|
168 |
Conversion conversion = ((GeneralDerivedCRS)crs).getConversionFromBase(); |
|
169 |
return new DefaultTransformationDefinition(conversion); |
|
170 |
} |
|
171 |
return null; |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public Datum getDatum() { |
|
176 |
// TODO Auto-generated method stub |
|
177 |
return null; |
|
178 |
} |
|
179 |
|
|
180 |
@Override |
|
181 |
public double getDistance(double[] point1, double[] point2, Unit<Length> unit) { |
|
182 |
// TODO Auto-generated method stub |
|
183 |
return 0; |
|
184 |
} |
|
185 |
|
|
186 |
@Override |
|
187 |
public double getDistance(double[] point1, double[] point2, boolean useBaseCRS, Unit<Length> unit) { |
|
188 |
// TODO Auto-generated method stub |
|
189 |
return 0; |
|
190 |
} |
|
191 |
|
|
192 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.catalog.impl/src/main/java/org/gvsig/sis/proj/catalog/SisCrsCatalogLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2018gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.sis.proj.catalog; |
|
25 |
|
|
26 |
import org.gvsig.proj.CoordinateReferenceSystemLibrary; |
|
27 |
import org.gvsig.proj.catalog.CRSCatalogLocator; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
|
|
31 |
/** |
|
32 |
* Library to register the Apache SIS-based implementation of the |
|
33 |
* org.gvsig.proj.catalog API. |
|
34 |
* |
|
35 |
* @author Cesar Martinez Izquierdo |
|
36 |
*/ |
|
37 |
public class SisCrsCatalogLibrary extends AbstractLibrary { |
|
38 |
|
|
39 |
public SisCrsCatalogLibrary() { |
|
40 |
registerAsImplementationOf(CoordinateReferenceSystemLibrary.class); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void doInitialize() throws LibraryException { |
|
45 |
CRSCatalogLocator.registerManager(SisCRSCatalogManager.class); |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doPostInitialize() throws LibraryException { |
|
51 |
// TODO Auto-generated method stub |
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
} |
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/org.gvsig.sis.proj.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.sis.proj.app</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
|
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.sis.proj</artifactId> |
|
10 |
<version>1.0.0-SNAPSHOT</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.proj.lib.api</artifactId> |
|
16 |
</dependency> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.proj.catalog.api</artifactId> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.sis.proj.catalog.impl</artifactId> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.sis.proj.lib.impl</artifactId> |
|
28 |
</dependency> |
|
29 |
</dependencies> |
|
30 |
|
|
31 |
<properties> |
|
32 |
<!-- Package info property values --> |
|
33 |
<!-- Default values in org.gvsig.desktop --> |
|
34 |
<gvsig.package.info.name>CRS support: Apache SIS-based implementation</gvsig.package.info.name> |
|
35 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
36 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
37 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.1</gvsig.package.info.dependencies> |
|
38 |
<gvsig.package.info.categories>Base</gvsig.package.info.categories> |
|
39 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-jcrs/pool/</gvsig.package.info.poolURL> |
|
40 |
</properties> |
|
41 |
|
|
42 |
</project> |
|
43 |
|
org.gvsig.sis.proj/trunk/org.gvsig.sis.proj/pom.xml | ||
---|---|---|
136 | 136 |
</developers> |
137 | 137 |
|
138 | 138 |
<properties> |
139 |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
139 |
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> -->
|
|
140 | 140 |
<sis.version>0.8</sis.version> |
141 |
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding> |
|
142 |
<localRepository>${user.home}/.m2/repository</localRepository> |
|
143 |
<site-repository>dav:https://devel.gvsig.org/sites/${project.artifactId}/${project.version}</site-repository> |
|
144 |
<gvsig.tools.version>3.0.87</gvsig.tools.version> |
|
145 |
<gvsig.metadata.version>1.0.0</gvsig.metadata.version> |
|
146 |
<!-- <gvsig.projection.version>2.0.21</gvsig.projection.version> --> |
|
141 | 147 |
</properties> |
142 | 148 |
<dependencyManagement> |
143 | 149 |
<dependencies> |
... | ... | |
188 | 194 |
<dependency> |
189 | 195 |
<groupId>org.gvsig</groupId> |
190 | 196 |
<artifactId>org.gvsig.sis.proj.lib.impl</artifactId> |
191 |
<version>1.0.5-SNAPSHOT</version> |
|
197 |
<version>1.0.0-SNAPSHOT</version> |
|
198 |
</dependency> |
|
199 |
<dependency> |
|
200 |
<groupId>org.gvsig</groupId> |
|
201 |
<artifactId>org.gvsig.sis.proj.catalog.impl</artifactId> |
|
202 |
<version>1.0.0-SNAPSHOT</version> |
|
203 |
</dependency> |
|
204 |
<dependency> |
|
205 |
<groupId>org.gvsig</groupId> |
|
206 |
<artifactId>org.gvsig.sis.proj.lib.impl</artifactId> |
|
207 |
<version>1.0.0-SNAPSHOT</version> |
|
192 | 208 |
<type>test-jar</type> |
193 | 209 |
<scope>test</scope> |
194 | 210 |
</dependency> |
195 | 211 |
<dependency> |
196 | 212 |
<groupId>org.gvsig</groupId> |
197 | 213 |
<artifactId>org.gvsig.sis.proj.catalog.impl</artifactId> |
198 |
<version>1.0.5-SNAPSHOT</version>
|
|
214 |
<version>1.0.0-SNAPSHOT</version>
|
|
199 | 215 |
<type>test-jar</type> |
200 | 216 |
<scope>test</scope> |
201 | 217 |
</dependency> |
202 | 218 |
<dependency> |
203 | 219 |
<groupId>org.gvsig</groupId> |
204 |
<artifactId>org.gvsig.sis.app.proj</artifactId>
|
|
205 |
<version>1.0.5-SNAPSHOT</version>
|
|
220 |
<artifactId>org.gvsig.sis.proj.app</artifactId>
|
|
221 |
<version>1.0.0-SNAPSHOT</version>
|
|
206 | 222 |
</dependency> |
207 | 223 |
<dependency> |
208 | 224 |
<groupId>org.gvsig</groupId> |
209 |
<artifactId>org.gvsig.sis.app.projcatalog<</artifactId>
|
|
210 |
<version>1.0.5-SNAPSHOT</version>
|
|
225 |
<artifactId>org.gvsig.sis.proj.catalog.app</artifactId>
|
|
226 |
<version>1.0.0-SNAPSHOT</version>
|
|
211 | 227 |
</dependency> |
212 | 228 |
</dependencies> |
213 | 229 |
</dependencyManagement> |
... | ... | |
430 | 446 |
</plugin> |
431 | 447 |
</plugins> |
432 | 448 |
</reporting> |
433 |
|
|
434 |
|
|
435 |
<properties> |
|
436 |
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding> |
|
437 |
<localRepository>${user.home}/.m2/repository</localRepository> |
|
438 |
<site-repository>dav:https://devel.gvsig.org/sites/${project.artifactId}/${project.version}</site-repository> |
|
439 |
|
|
440 | 449 |
|
441 |
<gvsig.tools.version>3.0.87</gvsig.tools.version> |
|
442 |
<gvsig.metadata.version>1.0.0</gvsig.metadata.version> |
|
443 |
<!-- <gvsig.projection.version>2.0.21</gvsig.projection.version> --> |
|
444 |
</properties> |
|
445 |
|
|
446 | 450 |
<modules> |
447 | 451 |
<module>org.gvsig.sis.proj.lib.impl</module> |
448 | 452 |
<module>org.gvsig.sis.proj.catalog.impl</module> |
449 |
<module>org.gvsig.sis.app.proj</module>
|
|
450 |
<module>org.gvsig.sis.app.projcatalog</module>
|
|
453 |
<module>org.gvsig.sis.proj.app</module>
|
|
454 |
<module>org.gvsig.sis.proj.catalog.app</module>
|
|
451 | 455 |
</modules> |
452 | 456 |
<groupId>org.gvsig</groupId> |
453 | 457 |
</project> |
454 | 458 |
Also available in: Unified diff