Revision 1301
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.main/src/main/resources/README.txt | ||
---|---|---|
1 |
==== |
|
2 |
gvSIG. Desktop Geographic Information System. |
|
3 |
|
|
4 |
Copyright (C) 2007-2012 gvSIG 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 |
|
|
25 |
Put into this folder the resources needed by your classes. |
|
26 |
|
|
27 |
This folder is added to the classpath, so you can load any resources |
|
28 |
through the ClassLoader. |
|
29 |
|
|
30 |
By default, in this folder you can find an example of log4j configuration, |
|
31 |
prepared to log messages through the console, so logging works when you |
|
32 |
run your classes. |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.main/src/main/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
28 |
|
|
29 |
<!-- |
|
30 |
Log4J configuration file for unit tests execution. |
|
31 |
--> |
|
32 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
33 |
|
|
34 |
<!-- Appender configuration to show logging messages through the console --> |
|
35 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
36 |
<layout class="org.apache.log4j.PatternLayout"> |
|
37 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
38 |
</layout> |
|
39 |
</appender> |
|
40 |
|
|
41 |
<!-- |
|
42 |
Activate logging messages of DEBUG level of higher only for the |
|
43 |
org.gvsig.tools packages. |
|
44 |
You can put full classes names or packages instead, to configure |
|
45 |
logging for all the classes and subpackages of the package. |
|
46 |
--> |
|
47 |
<category name="org.gvsig.tools"> |
|
48 |
<priority value="DEBUG" /> |
|
49 |
</category> |
|
50 |
<category name="org.gvsig.proj"> |
|
51 |
<priority value="DEBUG" /> |
|
52 |
</category> |
|
53 |
|
|
54 |
<!-- |
|
55 |
By default, show only logging messages of INFO level or higher, |
|
56 |
through the previously configured CONSOLE appender. |
|
57 |
--> |
|
58 |
<root> |
|
59 |
<priority value="INFO" /> |
|
60 |
<appender-ref ref="CONSOLE" /> |
|
61 |
</root> |
|
62 |
</log4j:configuration> |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.main/src/main/java/org/gvsig/proj/main/Main.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG 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.proj.main; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.event.ActionEvent; |
|
29 |
|
|
30 |
import javax.swing.AbstractAction; |
|
31 |
import javax.swing.Action; |
|
32 |
import javax.swing.JButton; |
|
33 |
import javax.swing.JFrame; |
|
34 |
import javax.swing.JMenu; |
|
35 |
import javax.swing.JMenuBar; |
|
36 |
import javax.swing.JMenuItem; |
|
37 |
import javax.swing.JToolBar; |
|
38 |
import javax.swing.WindowConstants; |
|
39 |
|
|
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
42 |
|
|
43 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
44 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
|
45 |
import org.gvsig.proj.CoordinateReferenceSystemManager; |
|
46 |
import org.gvsig.proj.CoordinateReferenceSystemNotFoundException; |
|
47 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSelectorComponent; |
|
48 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingLocator; |
|
49 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingManager; |
|
50 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
51 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
52 |
|
|
53 |
/** |
|
54 |
* Main executable class for testing the CRS library. |
|
55 |
* |
|
56 |
* @author gvSIG Team |
|
57 |
* @version $Id$ |
|
58 |
*/ |
|
59 |
public class Main { |
|
60 |
|
|
61 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
|
62 |
|
|
63 |
private CoordinateReferenceSystemManager manager; |
|
64 |
private CoordinateReferenceSystemSwingManager swingManager; |
|
65 |
|
|
66 |
public static void main(String args[]) { |
|
67 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
68 |
Main main = new Main(); |
|
69 |
main.show(); |
|
70 |
} |
|
71 |
|
|
72 |
@SuppressWarnings("serial") |
|
73 |
public void show() { |
|
74 |
manager = CoordinateReferenceSystemLocator.getManager(); |
|
75 |
swingManager = CoordinateReferenceSystemSwingLocator.getSwingManager(); |
|
76 |
|
|
77 |
Action showCRSSelector = new AbstractAction("Select a CRS") { |
|
78 |
|
|
79 |
public void actionPerformed(ActionEvent e) { |
|
80 |
showCRSSelector(manager); |
|
81 |
} |
|
82 |
}; |
|
83 |
|
|
84 |
Action exit = new AbstractAction("Exit") { |
|
85 |
|
|
86 |
public void actionPerformed(ActionEvent e) { |
|
87 |
System.exit(0); |
|
88 |
} |
|
89 |
}; |
|
90 |
|
|
91 |
JFrame frame = new JFrame("CRS example app"); |
|
92 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
93 |
|
|
94 |
// Create the menu bar. |
|
95 |
JMenuBar menuBar = new JMenuBar(); |
|
96 |
|
|
97 |
// Build the menu. |
|
98 |
JMenu menuFile = new JMenu("File"); |
|
99 |
menuFile.add(new JMenuItem(showCRSSelector)); |
|
100 |
menuFile.add(new JMenuItem(exit)); |
|
101 |
|
|
102 |
menuBar.add(menuFile); |
|
103 |
|
|
104 |
JToolBar toolBar = new JToolBar(); |
|
105 |
toolBar.add(new JButton(showCRSSelector)); |
|
106 |
toolBar.add(new JButton(exit)); |
|
107 |
|
|
108 |
frame.setPreferredSize(new Dimension(200, 100)); |
|
109 |
frame.setJMenuBar(menuBar); |
|
110 |
frame.add(toolBar, BorderLayout.PAGE_START); |
|
111 |
|
|
112 |
// Display the window. |
|
113 |
frame.pack(); |
|
114 |
frame.setVisible(true); |
|
115 |
} |
|
116 |
|
|
117 |
public void showCRSSelector(CoordinateReferenceSystemManager manager) { |
|
118 |
|
|
119 |
CoordinateReferenceSystemSelectorComponent crsSelectionComponent = |
|
120 |
swingManager.createCoordinateReferenceSystemSelectionComponent(); |
|
121 |
|
|
122 |
try { |
|
123 |
CoordinateReferenceSystem currentCRS = |
|
124 |
manager.getCoordinateReferenceSystem("EPSG", "23030"); |
|
125 |
crsSelectionComponent.setCoordinateReferenceSystem(currentCRS); |
|
126 |
} catch (CoordinateReferenceSystemNotFoundException e) { |
|
127 |
LOG.error("Error getting crs EPSG:23030", e); |
|
128 |
} |
|
129 |
|
|
130 |
swingManager.getWindowManager().showWindow( |
|
131 |
crsSelectionComponent.asJComponent(), "Proj", |
|
132 |
WindowManager.MODE.WINDOW); |
|
133 |
} |
|
134 |
|
|
135 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.main/src/main/java/org/gvsig/proj/main/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
28 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
29 |
<head> |
|
30 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
31 |
<title>org.gvsig.proj package documentation</title> |
|
32 |
</head> |
|
33 |
<body> |
|
34 |
|
|
35 |
<p>Proj library testing and demo application.</p> |
|
36 |
|
|
37 |
</body> |
|
38 |
</html> |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.main/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" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.proj.main</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.proj</artifactId> |
|
11 |
<version>1.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencyManagement> |
|
15 |
<dependencies> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
19 |
<version>${gvsig.desktop.version}</version> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
24 |
<version>${gvsig.desktop.version}</version> |
|
25 |
</dependency> |
|
26 |
</dependencies> |
|
27 |
</dependencyManagement> |
|
28 |
|
|
29 |
<dependencies> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
33 |
<scope>compile</scope> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
38 |
<type>test-jar</type> |
|
39 |
<scope>test</scope> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.gvsig</groupId> |
|
43 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
44 |
<scope>compile</scope> |
|
45 |
</dependency> |
|
46 |
<!-- |
|
47 |
<dependency> |
|
48 |
<groupId>org.gvsig</groupId> |
|
49 |
<artifactId>org.gvsig.i18n</artifactId> |
|
50 |
<scope>compile</scope> |
|
51 |
</dependency> |
|
52 |
--> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
56 |
<scope>compile</scope> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>org.gvsig</groupId> |
|
60 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
61 |
<scope>compile</scope> |
|
62 |
</dependency> |
|
63 |
<dependency> |
|
64 |
<groupId>org.gvsig</groupId> |
|
65 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
66 |
<scope>compile</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.gvsig</groupId> |
|
70 |
<artifactId>org.gvsig.proj.lib.api</artifactId> |
|
71 |
<scope>compile</scope> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.proj.lib.proj4j</artifactId> |
|
76 |
<scope>runtime</scope> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.proj.swing.api</artifactId> |
|
81 |
<scope>compile</scope> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<groupId>org.gvsig</groupId> |
|
85 |
<artifactId>org.gvsig.proj.swing.impl</artifactId> |
|
86 |
<scope>runtime</scope> |
|
87 |
</dependency> |
|
88 |
</dependencies> |
|
89 |
|
|
90 |
<properties> |
|
91 |
<gvsig.desktop.version>2.0.10-SNAPSHOT</gvsig.desktop.version> |
|
92 |
</properties> |
|
93 |
</project> |
|
0 | 94 |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/test/resources/README.txt | ||
---|---|---|
1 |
==== |
|
2 |
gvSIG. Desktop Geographic Information System. |
|
3 |
|
|
4 |
Copyright (C) 2007-2012 gvSIG 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 |
|
|
25 |
Put into this folder the resources needed by your test classes. |
|
26 |
|
|
27 |
This folder is added to the Tests classpath, so you can load any resources |
|
28 |
through the ClassLoader. |
|
29 |
|
|
30 |
By default, in this folder you can find an example of log4j configuration, |
|
31 |
prepared to log messages through the console, so logging works when you |
|
32 |
run your tests classes. |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
28 |
|
|
29 |
<!-- |
|
30 |
Log4J configuration file for unit tests execution. |
|
31 |
--> |
|
32 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
33 |
|
|
34 |
<!-- Appender configuration to show logging messages through the console --> |
|
35 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
36 |
<layout class="org.apache.log4j.PatternLayout"> |
|
37 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
38 |
</layout> |
|
39 |
</appender> |
|
40 |
|
|
41 |
<!-- |
|
42 |
Activate logging messages of DEBUG level of higher only for the |
|
43 |
org.gvsig.tools packages. |
|
44 |
You can put full classes names or packages instead, to configure |
|
45 |
logging for all the classes and subpackages of the package. |
|
46 |
--> |
|
47 |
<category name="org.gvsig.tools"> |
|
48 |
<priority value="DEBUG" /> |
|
49 |
</category> |
|
50 |
<category name="org.gvsig.proj"> |
|
51 |
<priority value="DEBUG" /> |
|
52 |
</category> |
|
53 |
|
|
54 |
<!-- |
|
55 |
By default, show only logging messages of INFO level or higher, |
|
56 |
through the previously configured CONSOLE appender. |
|
57 |
--> |
|
58 |
<root> |
|
59 |
<priority value="INFO" /> |
|
60 |
<appender-ref ref="CONSOLE" /> |
|
61 |
</root> |
|
62 |
</log4j:configuration> |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/test/java/org/gvsig/proj/proj4j/DefaultCoordinateReferenceSystemManagerIT.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.proj4j; |
|
24 |
|
|
25 |
import org.gvsig.proj.CoordinateReferenceSystemManager; |
|
26 |
import org.gvsig.proj.CoordinateReferenceSystemManagerIT; |
|
27 |
import org.gvsig.proj.proj4j.DefaultCoordinateReferenceSystemManager; |
|
28 |
|
|
29 |
/** |
|
30 |
* API acceptance tests for the {@link DefaultCoordinateReferenceSystemManager} implementation. |
|
31 |
* |
|
32 |
* @author gvSIG Team |
|
33 |
*/ |
|
34 |
public class DefaultCoordinateReferenceSystemManagerIT extends CoordinateReferenceSystemManagerIT { |
|
35 |
|
|
36 |
protected CoordinateReferenceSystemManager createProjectionManager() { |
|
37 |
return new DefaultCoordinateReferenceSystemManager(); |
|
38 |
} |
|
39 |
|
|
40 |
protected String getAuthorityName() { |
|
41 |
return "EPSG"; |
|
42 |
} |
|
43 |
|
|
44 |
protected String getCode() { |
|
45 |
return "23030"; |
|
46 |
} |
|
47 |
|
|
48 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/test/java/org/gvsig/proj/proj4j/DefaultCoordinateReferenceSystemIT.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.proj4j; |
|
24 |
|
|
25 |
import org.gvsig.proj.CoordinateReferenceSystemIT; |
|
26 |
|
|
27 |
/** |
|
28 |
* API acceptance tests for the {@link DefaultCoordinateReferenceSystem} implementation. |
|
29 |
* |
|
30 |
* @author gvSIG Team |
|
31 |
*/ |
|
32 |
public class DefaultCoordinateReferenceSystemIT extends CoordinateReferenceSystemIT { |
|
33 |
|
|
34 |
protected String getAuthorityName() { |
|
35 |
return "EPSG"; |
|
36 |
} |
|
37 |
|
|
38 |
protected String getCode() { |
|
39 |
return "23030"; |
|
40 |
} |
|
41 |
|
|
42 |
protected String getCode2() { |
|
43 |
return "23031"; |
|
44 |
} |
|
45 |
|
|
46 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/test/java/org/gvsig/proj/proj4j/DefaultCoordinateTransformationIT.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.proj4j; |
|
24 |
|
|
25 |
import org.gvsig.proj.CoordinateTransformationIT; |
|
26 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
27 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
|
28 |
import org.gvsig.proj.proj4j.DefaultCoordinateTransformation; |
|
29 |
|
|
30 |
/** |
|
31 |
* API acceptance tests for the {@link DefaultCoordinateTransformation} |
|
32 |
* implementation. |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
*/ |
|
36 |
public class DefaultCoordinateTransformationIT extends |
|
37 |
CoordinateTransformationIT { |
|
38 |
|
|
39 |
protected CoordinateReferenceSystem createSourceProjection() throws Exception { |
|
40 |
return CoordinateReferenceSystemLocator.getManager().getCoordinateReferenceSystem("EPSG", "23030"); |
|
41 |
} |
|
42 |
|
|
43 |
protected CoordinateReferenceSystem createTargetProjection() throws Exception { |
|
44 |
return CoordinateReferenceSystemLocator.getManager().getCoordinateReferenceSystem("EPSG", "23031"); |
|
45 |
} |
|
46 |
|
|
47 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/test/java/org/gvsig/proj/proj4j/ShowAllWorkingAuthorityCodes.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.proj4j; |
|
24 |
|
|
25 |
import java.io.IOException; |
|
26 |
|
|
27 |
/** |
|
28 |
* Shows all working authority codes in the console in properties format. |
|
29 |
* May be used to update the |
|
30 |
* src/main/resources/org/gvsig/proj/proj4j/supportedcrs.properties file. |
|
31 |
* |
|
32 |
* @author gvSIG Team |
|
33 |
*/ |
|
34 |
public class ShowAllWorkingAuthorityCodes { |
|
35 |
|
|
36 |
/** |
|
37 |
* Run the app. |
|
38 |
* |
|
39 |
* @param args |
|
40 |
* ignored parameters |
|
41 |
*/ |
|
42 |
public static void main(String[] args) throws IOException { |
|
43 |
new DefaultCoordinateReferenceSystemManager().showAllWorkingCodes(); |
|
44 |
} |
|
45 |
|
|
46 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/DefaultEllipsoid.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.proj4j; |
|
24 |
|
|
25 |
import java.util.HashMap; |
|
26 |
import java.util.Map; |
|
27 |
|
|
28 |
import org.gvsig.proj.Ellipsoid; |
|
29 |
|
|
30 |
/** |
|
31 |
* {@link Ellipsoid} implementation based on the Proj4J library. |
|
32 |
* |
|
33 |
* @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a> |
|
34 |
* @version $Rev$ |
|
35 |
* @since 0.1.0 |
|
36 |
*/ |
|
37 |
public class DefaultEllipsoid implements Ellipsoid { |
|
38 |
|
|
39 |
private org.osgeo.proj4j.datum.Ellipsoid ellipsoid; |
|
40 |
|
|
41 |
private static final String[] SHORT_NAMES = new String[] { "intl", |
|
42 |
"bessel", "clrk66", "clrk80", "airy", "WGS60", "WGS66", "WGS72", |
|
43 |
"WGS84", "krass", "evrst30", "new_intl", "GRS80", "australian", |
|
44 |
"MERIT", "SGS85", "IAU76", "APL4.9", "NWL9D", "mod_airy", "andrae", |
|
45 |
"aust_SA", "GRS67", "bess_nam", "CPM", "delmbr", "engelis", "evrst48", |
|
46 |
"evrst56", "evrst69", "evrstSS", "fschr60", "fschr60m", "fschr68", |
|
47 |
"helmert", "hough", "intl", "kaula", "lerch", "mprts", "plessis", |
|
48 |
"SEasia", "walbeck", "NAD27", "NAD83", "sphere" }; |
|
49 |
|
|
50 |
private static final double[] FLATTENINGS = new double[] { 297.0, |
|
51 |
299.1528128, 0.0, 293.4663, 0.0, 298.3, 298.25, 298.26, 298.257223563, |
|
52 |
298.3, 300.8017, 0.0, 298.257222101, 298.25, 298.257, 298.257, 298.257, |
|
53 |
298.25, 298.25, 0.0, 300.0, 298.25, 298.2471674270, 299.1528128, |
|
54 |
334.29, 311.5, 298.2566, 300.8017, 300.8017, 300.8017, 300.8017, 298.3, |
|
55 |
298.3, 298.3, 298.3, 297.0, 297.0, 298.24, 298.257, 191.0, 0.0, 0.0, |
|
56 |
0.0, 293.4663, 298.257222101, 0.0 }; |
|
57 |
|
|
58 |
private static final Map ellipsoidFlattenings = new HashMap(); |
|
59 |
|
|
60 |
static { |
|
61 |
for (int i = 0; i < SHORT_NAMES.length; i++) { |
|
62 |
ellipsoidFlattenings |
|
63 |
.put(SHORT_NAMES[i], new Double(FLATTENINGS[i])); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Creates a new ellipsoid based on a Proj4J one. |
|
69 |
* |
|
70 |
* @param ellipsoid |
|
71 |
* the Proj4J ellipsoid |
|
72 |
*/ |
|
73 |
public DefaultEllipsoid(org.osgeo.proj4j.datum.Ellipsoid ellipsoid) { |
|
74 |
this.ellipsoid = ellipsoid; |
|
75 |
} |
|
76 |
|
|
77 |
public String getShortName() { |
|
78 |
return ellipsoid.getShortName(); |
|
79 |
} |
|
80 |
|
|
81 |
public String getName() { |
|
82 |
return ellipsoid.getName(); |
|
83 |
} |
|
84 |
|
|
85 |
public double getSemiMajorAxis() { |
|
86 |
return ellipsoid.getEquatorRadius(); |
|
87 |
} |
|
88 |
|
|
89 |
public double getSemiMinorAxis() { |
|
90 |
return ellipsoid.poleRadius; |
|
91 |
} |
|
92 |
|
|
93 |
public double getReciprocalFlattening() { |
|
94 |
Double flattening = (Double) ellipsoidFlattenings.get(getShortName()); |
|
95 |
return flattening == null ? 0.0d : flattening.doubleValue(); |
|
96 |
} |
|
97 |
|
|
98 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/Proj4jCoordinateReferenceSystemLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG 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.proj.proj4j; |
|
25 |
|
|
26 |
import org.gvsig.proj.CoordinateReferenceSystemLibrary; |
|
27 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
|
|
31 |
/** |
|
32 |
* Library to register the Proj4J based implementation of the org.gvsig.proj |
|
33 |
* API. |
|
34 |
* |
|
35 |
* @author gvSIG team |
|
36 |
* @version $Id$ |
|
37 |
*/ |
|
38 |
public class Proj4jCoordinateReferenceSystemLibrary extends AbstractLibrary { |
|
39 |
|
|
40 |
public void doRegistration() { |
|
41 |
registerAsImplementationOf(CoordinateReferenceSystemLibrary.class); |
|
42 |
} |
|
43 |
|
|
44 |
protected void doInitialize() throws LibraryException { |
|
45 |
CoordinateReferenceSystemLocator |
|
46 |
.registerManager(DefaultCoordinateReferenceSystemManager.class); |
|
47 |
} |
|
48 |
|
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
// Do nothing |
|
51 |
} |
|
52 |
|
|
53 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/DefaultCoordinateReferenceSystemManager.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.proj4j; |
|
24 |
|
|
25 |
import java.io.BufferedReader; |
|
26 |
import java.io.IOException; |
|
27 |
import java.io.InputStream; |
|
28 |
import java.io.InputStreamReader; |
|
29 |
import java.io.OutputStream; |
|
30 |
import java.io.PrintStream; |
|
31 |
import java.io.StreamTokenizer; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Arrays; |
|
34 |
import java.util.Collections; |
|
35 |
import java.util.HashMap; |
|
36 |
import java.util.Iterator; |
|
37 |
import java.util.List; |
|
38 |
import java.util.Map; |
|
39 |
import java.util.Map.Entry; |
|
40 |
import java.util.Properties; |
|
41 |
import java.util.Set; |
|
42 |
|
|
43 |
import org.osgeo.proj4j.CRSFactory; |
|
44 |
import org.osgeo.proj4j.io.Proj4FileReader; |
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
49 |
import org.gvsig.proj.CoordinateReferenceSystemManager; |
|
50 |
import org.gvsig.proj.CoordinateReferenceSystemNotFoundException; |
|
51 |
import org.gvsig.tools.dynobject.DynObject; |
|
52 |
|
|
53 |
/** |
|
54 |
* Proj4J based {@link CoordinateReferenceSystemManager} implementation. |
|
55 |
* |
|
56 |
* @author gvSIG Team |
|
57 |
*/ |
|
58 |
public class DefaultCoordinateReferenceSystemManager implements |
|
59 |
CoordinateReferenceSystemManager { |
|
60 |
|
|
61 |
private static final Logger LOG = LoggerFactory |
|
62 |
.getLogger(DefaultCoordinateReferenceSystemManager.class); |
|
63 |
|
|
64 |
private final Map authorityCodes; |
|
65 |
|
|
66 |
private CRSFactory factory = new CRSFactory(); |
|
67 |
|
|
68 |
/** |
|
69 |
* Default constructor. |
|
70 |
*/ |
|
71 |
public DefaultCoordinateReferenceSystemManager() { |
|
72 |
authorityCodes = loadSupportedCRS(); |
|
73 |
} |
|
74 |
|
|
75 |
public List getAuthorityNames() { |
|
76 |
Set authCodeSet = authorityCodes.keySet(); |
|
77 |
Object[] codes = authCodeSet.toArray(); |
|
78 |
Arrays.sort(codes); |
|
79 |
return Collections.unmodifiableList(Arrays.asList(codes)); |
|
80 |
} |
|
81 |
|
|
82 |
public List getCodes(String authorityName) { |
|
83 |
return (List) authorityCodes.get(authorityName); |
|
84 |
} |
|
85 |
|
|
86 |
public void updateAllWorkingCodes() { |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Shows the list of working codes for each authority in the console. |
|
92 |
* |
|
93 |
* @throws IOException |
|
94 |
* if there is an error writing in the console output stream |
|
95 |
*/ |
|
96 |
public void showAllWorkingCodes() throws IOException { |
|
97 |
storeAllWorkingCodes(System.out); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Stores the list of working codes for each authority in the |
|
102 |
* {@link OutputStream} in properties format. |
|
103 |
* |
|
104 |
* @param os |
|
105 |
* to show the list of working codes into. |
|
106 |
* @throws IOException |
|
107 |
* if there is an error writing in the stream |
|
108 |
*/ |
|
109 |
public void storeAllWorkingCodes(OutputStream os) throws IOException { |
|
110 |
String[] auths = |
|
111 |
new String[] { "EPSG", "ESRI", "WORLD", "NAD83", "NAD27" }; |
|
112 |
Properties properties = new Properties(); |
|
113 |
for (int i = 0; i < auths.length; i++) { |
|
114 |
List workingCodes = findWorkingCodes(auths[i]); |
|
115 |
StringBuffer buffer = new StringBuffer(); |
|
116 |
for (int j = 0; workingCodes != null && j < workingCodes.size(); j++) { |
|
117 |
buffer.append(workingCodes.get(j)); |
|
118 |
if (j < workingCodes.size() - 1) { |
|
119 |
buffer.append(","); |
|
120 |
} |
|
121 |
} |
|
122 |
properties.setProperty(auths[i], buffer.toString()); |
|
123 |
} |
|
124 |
properties.store(new PrintStream(os), "Created by calling " |
|
125 |
+ "DefaultCoordinateReferenceSystemManager.storeAllWorkingCodes()"); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Looks for the list of codes currently working for an authority, |
|
130 |
* as the pro4j library CRS definition files usually provides more |
|
131 |
* than really supports. |
|
132 |
* |
|
133 |
* @param authority |
|
134 |
* to find the working codes from |
|
135 |
* @return the list of codes of the authority which might be used to get a |
|
136 |
* CRS |
|
137 |
*/ |
|
138 |
public List findWorkingCodes(String authority) { |
|
139 |
List codes; |
|
140 |
|
|
141 |
String filename = "/nad/" + authority.toLowerCase(); |
|
142 |
InputStream inStr = Proj4FileReader.class.getResourceAsStream(filename); |
|
143 |
if (inStr == null) { |
|
144 |
throw new IllegalStateException("Unable to access CRS file: " |
|
145 |
+ filename); |
|
146 |
} |
|
147 |
BufferedReader reader = |
|
148 |
new BufferedReader(new InputStreamReader(inStr)); |
|
149 |
try { |
|
150 |
codes = readAuthorityCodes(reader); |
|
151 |
} catch (IOException e) { |
|
152 |
throw new RuntimeException("Error reading the codes of authority: " |
|
153 |
+ authority, e); |
|
154 |
} finally { |
|
155 |
try { |
|
156 |
reader.close(); |
|
157 |
} catch (IOException e) { |
|
158 |
LOG.warn("Error closing BufferedReader on file " + filename, e); |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
// Check if a projection might be really created with a given code |
|
163 |
// and remove from the list otherwise |
|
164 |
for (Iterator iterator = codes.iterator(); iterator.hasNext();) { |
|
165 |
String code = (String) iterator.next(); |
|
166 |
try { |
|
167 |
factory.createFromName(getCRSName(authority, code)); |
|
168 |
} catch (Throwable e) { |
|
169 |
iterator.remove(); |
|
170 |
LOG.debug("CRS with authority '" + authority + "' and code '" |
|
171 |
+ code + "' could not be loaded, removing from the list " |
|
172 |
+ "of codes of the authority", e); |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
return codes; |
|
177 |
} |
|
178 |
|
|
179 |
private StreamTokenizer createTokenizer(BufferedReader reader) { |
|
180 |
StreamTokenizer t = new StreamTokenizer(reader); |
|
181 |
t.commentChar('#'); |
|
182 |
t.ordinaryChars('0', '9'); |
|
183 |
t.ordinaryChars('.', '.'); |
|
184 |
t.ordinaryChars('-', '-'); |
|
185 |
t.ordinaryChars('+', '+'); |
|
186 |
t.wordChars('0', '9'); |
|
187 |
t.wordChars('\'', '\''); |
|
188 |
t.wordChars('"', '"'); |
|
189 |
t.wordChars('_', '_'); |
|
190 |
t.wordChars('.', '.'); |
|
191 |
t.wordChars('-', '-'); |
|
192 |
t.wordChars('+', '+'); |
|
193 |
t.wordChars(',', ','); |
|
194 |
t.wordChars('@', '@'); |
|
195 |
return t; |
|
196 |
} |
|
197 |
|
|
198 |
private List readAuthorityCodes(BufferedReader reader) throws IOException { |
|
199 |
List codes = new ArrayList(); |
|
200 |
StreamTokenizer t = createTokenizer(reader); |
|
201 |
|
|
202 |
t.nextToken(); |
|
203 |
while (t.ttype == '<') { |
|
204 |
t.nextToken(); |
|
205 |
if (t.ttype != StreamTokenizer.TT_WORD) { |
|
206 |
throw new IOException(t.lineno() + ": Word expected after '<'"); |
|
207 |
} |
|
208 |
codes.add(t.sval); |
|
209 |
t.nextToken(); |
|
210 |
if (t.ttype != '>') |
|
211 |
throw new IOException(t.lineno() + ": '>' expected"); |
|
212 |
t.nextToken(); |
|
213 |
|
|
214 |
while (t.ttype != '<') { |
|
215 |
t.nextToken(); |
|
216 |
} |
|
217 |
t.nextToken(); |
|
218 |
if (t.ttype != '>') |
|
219 |
throw new IOException(t.lineno() + ": '<>' expected"); |
|
220 |
t.nextToken(); |
|
221 |
} |
|
222 |
return codes; |
|
223 |
} |
|
224 |
|
|
225 |
public CoordinateReferenceSystem getCoordinateReferenceSystem( |
|
226 |
String authority, String code) |
|
227 |
throws CoordinateReferenceSystemNotFoundException { |
|
228 |
int n = code.indexOf("("); |
|
229 |
if( n>0 ) { |
|
230 |
code = code.substring(0, n); |
|
231 |
} |
|
232 |
org.osgeo.proj4j.CoordinateReferenceSystem proj4jcrs = |
|
233 |
factory.createFromName(getCRSName(authority, code)); |
|
234 |
return new DefaultCoordinateReferenceSystem(authority, code, proj4jcrs); |
|
235 |
} |
|
236 |
|
|
237 |
private String getCRSName(String authority, String code) { |
|
238 |
String name = authority.concat(":").concat(code); |
|
239 |
return name; |
|
240 |
} |
|
241 |
|
|
242 |
public DynObject createParameters() { |
|
243 |
// Nothing to do, no parameters needed. |
|
244 |
return null; |
|
245 |
} |
|
246 |
|
|
247 |
public void initialize(DynObject parameters) { |
|
248 |
// Nothing to do |
|
249 |
} |
|
250 |
|
|
251 |
private Map loadSupportedCRS() { |
|
252 |
Properties supported = new Properties(); |
|
253 |
InputStream is = |
|
254 |
getClass().getResourceAsStream("supportedcrs.properties"); |
|
255 |
try { |
|
256 |
if (is == null) { |
|
257 |
throw new RuntimeException( |
|
258 |
"Supported crs property file not found in " |
|
259 |
+ getClass().getResource("supportedcrs.properties")); |
|
260 |
} else { |
|
261 |
supported.load(is); |
|
262 |
} |
|
263 |
} catch (IOException e) { |
|
264 |
throw new RuntimeException( |
|
265 |
"Error loading the supported crs property file from " |
|
266 |
+ getClass().getResource("supportedcrs.properties"), e); |
|
267 |
} |
|
268 |
|
|
269 |
Map authorityCodes = new HashMap(supported.size()); |
|
270 |
for (Iterator iterator = supported.entrySet().iterator(); iterator |
|
271 |
.hasNext();) { |
|
272 |
Entry entry = (Entry) iterator.next(); |
|
273 |
String authority = (String) entry.getKey(); |
|
274 |
String codesAsString = (String) entry.getValue(); |
|
275 |
List codes = |
|
276 |
Collections.unmodifiableList(Arrays.asList(codesAsString |
|
277 |
.split(","))); |
|
278 |
authorityCodes.put(authority, Collections.unmodifiableList(codes)); |
|
279 |
} |
|
280 |
return authorityCodes; |
|
281 |
} |
|
282 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
28 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
29 |
<head> |
|
30 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
31 |
<title>org.gvsig.proj package documentation</title> |
|
32 |
</head> |
|
33 |
<body> |
|
34 |
|
|
35 |
<p>Projection library API implementation based on the |
|
36 |
<a href="http://sourceforge.net/projects/jmapprojlib/">Java Map Projection Library</a>.</p> |
|
37 |
|
|
38 |
</body> |
|
39 |
</html> |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/DefaultDatum.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.proj4j; |
|
24 |
|
|
25 |
import org.gvsig.proj.Datum; |
|
26 |
import org.gvsig.proj.Ellipsoid; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* {@link Datum} implementation based on the Proj4J library. |
|
31 |
* |
|
32 |
* @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a> |
|
33 |
* @version $Rev$ |
|
34 |
* @since 0.1.0 |
|
35 |
*/ |
|
36 |
public class DefaultDatum implements Datum { |
|
37 |
|
|
38 |
private org.osgeo.proj4j.datum.Datum datum; |
|
39 |
private Ellipsoid ellipsoid; |
|
40 |
|
|
41 |
/** |
|
42 |
* Creates a new datum based on a Proj4J datum. |
|
43 |
* |
|
44 |
* @param datum |
|
45 |
* the Proj4J Datum. |
|
46 |
*/ |
|
47 |
public DefaultDatum(org.osgeo.proj4j.datum.Datum datum) { |
|
48 |
this.datum = datum; |
|
49 |
this.ellipsoid = new DefaultEllipsoid(datum.getEllipsoid()); |
|
50 |
} |
|
51 |
|
|
52 |
public String getShortName() { |
|
53 |
return datum.getCode(); |
|
54 |
} |
|
55 |
|
|
56 |
public String getName() { |
|
57 |
return datum.getName(); |
|
58 |
} |
|
59 |
|
|
60 |
public Ellipsoid getEllipsoid() { |
|
61 |
return ellipsoid; |
|
62 |
} |
|
63 |
|
|
64 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/DefaultCoordinateReferenceSystem.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.proj4j; |
|
24 |
|
|
25 |
import org.osgeo.proj4j.proj.LongLatProjection; |
|
26 |
|
|
27 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
28 |
import org.gvsig.proj.CoordinateTransformation; |
|
29 |
import org.gvsig.proj.Datum; |
|
30 |
|
|
31 |
/** |
|
32 |
* Proj4J based {@link CoordinateReferenceSystem} implementation. |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
*/ |
|
36 |
public class DefaultCoordinateReferenceSystem implements |
|
37 |
CoordinateReferenceSystem { |
|
38 |
|
|
39 |
private final org.osgeo.proj4j.CoordinateReferenceSystem crs; |
|
40 |
private final String authorityName; |
|
41 |
private final String code; |
|
42 |
private final Datum datum; |
|
43 |
|
|
44 |
/** |
|
45 |
* Constructor |
|
46 |
*/ |
|
47 |
public DefaultCoordinateReferenceSystem(String authorityName, String code, |
|
48 |
org.osgeo.proj4j.CoordinateReferenceSystem crs) { |
|
49 |
this.authorityName = authorityName; |
|
50 |
this.code = code; |
|
51 |
this.crs = crs; |
|
52 |
this.datum = new DefaultDatum(crs.getDatum()); |
|
53 |
} |
|
54 |
|
|
55 |
public String getAuthorityName() { |
|
56 |
return authorityName; |
|
57 |
} |
|
58 |
|
|
59 |
public String getCode() { |
|
60 |
return code; |
|
61 |
} |
|
62 |
|
|
63 |
public String getReference() { |
|
64 |
return authorityName.concat(":").concat(code); |
|
65 |
} |
|
66 |
|
|
67 |
public String getDefinition() { |
|
68 |
return crs.getParameterString(); |
|
69 |
} |
|
70 |
|
|
71 |
public String getDescription() { |
|
72 |
return crs.getProjection().getPROJ4Description(); |
|
73 |
} |
|
74 |
|
|
75 |
public boolean isProjected() { |
|
76 |
return !(crs.getProjection() instanceof LongLatProjection); |
|
77 |
} |
|
78 |
|
|
79 |
public Object clone() throws CloneNotSupportedException { |
|
80 |
DefaultCoordinateReferenceSystem cloned = |
|
81 |
(DefaultCoordinateReferenceSystem) super.clone(); |
|
82 |
return cloned; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* @return the crs |
|
87 |
*/ |
|
88 |
public org.osgeo.proj4j.CoordinateReferenceSystem getCRS() { |
|
89 |
return crs; |
|
90 |
} |
|
91 |
|
|
92 |
public org.osgeo.proj4j.CoordinateReferenceSystem getGeographicCRS() { |
|
93 |
return crs.createGeographic(); |
|
94 |
} |
|
95 |
|
|
96 |
public CoordinateTransformation getTransformation( |
|
97 |
CoordinateReferenceSystem target) { |
|
98 |
return new DefaultCoordinateTransformation(this, |
|
99 |
(DefaultCoordinateReferenceSystem) target); |
|
100 |
} |
|
101 |
|
|
102 |
public String toString() { |
|
103 |
return getReference() + "(" + getDefinition() + ")"; |
|
104 |
} |
|
105 |
|
|
106 |
public CoordinateReferenceSystem createGeographic() { |
|
107 |
org.osgeo.proj4j.CoordinateReferenceSystem geographic = |
|
108 |
crs.createGeographic(); |
|
109 |
return new DefaultCoordinateReferenceSystem(getAuthorityName(), "GEO-" |
|
110 |
+ geographic.getDatum().getCode(), geographic); |
|
111 |
} |
|
112 |
|
|
113 |
public Datum getDatum() { |
|
114 |
return datum; |
|
115 |
} |
|
116 |
|
|
117 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/DefaultCoordinateTransformation.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.proj4j; |
|
24 |
|
|
25 |
import org.osgeo.proj4j.CoordinateTransform; |
|
26 |
import org.osgeo.proj4j.CoordinateTransformFactory; |
|
27 |
import org.osgeo.proj4j.ProjCoordinate; |
|
28 |
|
|
29 |
import org.gvsig.proj.CoordinateReferenceSystem; |
|
30 |
import org.gvsig.proj.CoordinateTransformation; |
|
31 |
|
|
32 |
/** |
|
33 |
* Proj4J based {@link CoordinateTransformation} implementation. |
|
34 |
* |
|
35 |
* @author gvSIG Team |
|
36 |
*/ |
|
37 |
public class DefaultCoordinateTransformation implements |
|
38 |
CoordinateTransformation { |
|
39 |
|
|
40 |
private final DefaultCoordinateReferenceSystem source; |
|
41 |
private final DefaultCoordinateReferenceSystem target; |
|
42 |
private final CoordinateTransform transform; |
|
43 |
|
|
44 |
/** |
|
45 |
* Creates a new {@link CoordinateTransformation} with the the source and |
|
46 |
* target projections. |
|
47 |
* |
|
48 |
* @param source |
|
49 |
* the projection to transform coordinates from |
|
50 |
* @param target |
|
51 |
* the projection to transform coordinates to |
|
52 |
*/ |
|
53 |
public DefaultCoordinateTransformation(DefaultCoordinateReferenceSystem source, |
|
54 |
DefaultCoordinateReferenceSystem target) { |
|
55 |
this.source = source; |
|
56 |
this.target = target; |
|
57 |
CoordinateTransformFactory factory = new CoordinateTransformFactory(); |
|
58 |
this.transform = |
|
59 |
factory.createTransform(source.getCRS(), target.getCRS()); |
|
60 |
} |
|
61 |
|
|
62 |
public CoordinateReferenceSystem getSourceProjection() { |
|
63 |
return source; |
|
64 |
} |
|
65 |
|
|
66 |
public CoordinateReferenceSystem getTargetProjection() { |
|
67 |
return target; |
|
68 |
} |
|
69 |
|
|
70 |
public void convert(double[] pointxy) { |
|
71 |
ProjCoordinate source = new ProjCoordinate(pointxy[0], pointxy[1]); |
|
72 |
ProjCoordinate result = new ProjCoordinate(); |
|
73 |
|
|
74 |
transform.transform(source, result); |
|
75 |
|
|
76 |
pointxy[0] = result.x; |
|
77 |
pointxy[1] = result.y; |
|
78 |
} |
|
79 |
|
|
80 |
public CoordinateTransformation getReverse() { |
|
81 |
return new DefaultCoordinateTransformation(target, source); |
|
82 |
} |
|
83 |
|
|
84 |
public Object clone() throws CloneNotSupportedException { |
|
85 |
return super.clone(); |
|
86 |
} |
|
87 |
|
|
88 |
} |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.proj.proj4j.Proj4jCoordinateReferenceSystemLibrary |
org.gvsig.proj/tags/org.gvsig.proj-1.0.28/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/resources/org/gvsig/proj/proj4j/supportedcrs.properties | ||
---|---|---|
1 |
#Created by calling DefaultCoordinateReferenceSystemManager.storeAllWorkingCodes() |
Also available in: Unified diff