Revision 2770

View differences:

org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/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.lidar</artifactId>
5
    <packaging>pom</packaging>
6
    <version>1.0.68</version>
7
    <name>org.gvsig.lidar</name>
8
    <description>LDAR-support library extension</description>
9
    <parent>
10
        <groupId>org.gvsig</groupId>
11
        <artifactId>org.gvsig.desktop</artifactId>
12
        <version>2.0.305</version>
13
    </parent>
14

  
15
    <url>http://devel.gvsig.org/sites/org.gvsig.lidar/${project.version}</url>
16
    <scm>
17
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68</connection>
18
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68</developerConnection>
19
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68</url>
20
     </scm>
21
    <developers>
22
        <developer>
23
            <id>cmartinez</id>
24
            <name>Cesar Martinez Izquierdo</name>
25
            <email>cmartinez@scolab.es</email>
26
            <roles>
27
                <role>Architect</role>
28
                <role>Developer</role>
29
            </roles>
30
        </developer>
31
    </developers>
32
    <distributionManagement>
33
        <site>
34
            <id>gvsig-repository</id>
35
            <url>dav:https://devel.gvsig.org/sites/org.gvsig.lidar/${project.version}</url>
36
        </site>
37
    </distributionManagement>
38
    <repositories>
39
        <repository>
40
            <id>gvsig-public-http-repository</id>
41
            <name>gvSIG maven public HTTP repository</name>
42
            <url>http://devel.gvsig.org/m2repo/j2se</url>
43
            <releases>
44
                <enabled>true</enabled>
45
                <updatePolicy>daily</updatePolicy>
46
                <checksumPolicy>warn</checksumPolicy>
47
            </releases>
48
            <snapshots>
49
                <enabled>true</enabled>
50
                <updatePolicy>daily</updatePolicy>
51
                <checksumPolicy>warn</checksumPolicy>
52
            </snapshots>
53
        </repository>
54
        <repository>
55
            <id>osgeo</id>
56
            <name>Open Source Geospatial Foundation</name>
57
            <url>http://download.osgeo.org/webdav/geotools</url>
58
            <releases>
59
                <enabled>true</enabled>
60
                <updatePolicy>never</updatePolicy>
61
                <checksumPolicy>warn</checksumPolicy>
62
            </releases>
63
            <snapshots>
64
                <enabled>false</enabled>
65
            </snapshots>
66
        </repository>
67

  
68
    </repositories>
69

  
70
    <properties>
71
        <svn.tags.folder>https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.lidar/tags/</svn.tags.folder>
72
    </properties>
73

  
74
    <dependencyManagement>
75
        <dependencies>
76
            <dependency>
77
            	<groupId>org.gvsig</groupId>
78
            	<artifactId>org.gvsig.gdal.app.lidar.mainplugin</artifactId>
79
                <version>1.0.1-SNAPSHOT</version>
80
            </dependency>
81
            <dependency>
82
            	<groupId>org.gvsig</groupId>
83
            	<artifactId>org.gvsig.lidar.prov.common</artifactId>
84
                <version>1.0.68</version>
85
            </dependency>
86
            <dependency>
87
            	<groupId>org.gvsig</groupId>
88
            	<artifactId>org.gvsig.lidar.prov.jgrass</artifactId>
89
                <version>1.0.68</version>
90
            </dependency>
91
            <dependency>
92
            	<groupId>org.gvsig</groupId>
93
            	<artifactId>org.gvsig.lidar.prov.whitebox</artifactId>
94
                <version>1.0.68</version>
95
            </dependency>
96
            <dependency>
97
                <groupId>whitebox</groupId>
98
                <artifactId>whitebox-api</artifactId>
99
                <version>3.3.0</version>
100
            </dependency>
101

  
102
            <dependency>
103
                <groupId>org.jgrasstools</groupId>
104
                <artifactId>jgt-jgrassgears</artifactId>
105
                <version>0.8.0</version>
106
            </dependency>
107
            <dependency>
108
                <groupId>net.java.dev.jna</groupId>
109
                <artifactId>jna</artifactId>
110
                <version>4.2.2</version>
111
            </dependency>
112
            <dependency>
113
                <!--
114
                GeoAPI dependence is necessary for JGrasstools LAS readers, but
115
                newer or older versions of the API (e.g. 3.0) are also valid,
116
                as it is only used as a fake object
117
                -->
118
                <groupId>org.opengis</groupId>
119
                <artifactId>geoapi</artifactId>
120
                <version>2.0</version>
121
            </dependency>
122

  
123
        </dependencies>
124
    </dependencyManagement>
125

  
126
   <build>
127
        <pluginManagement>
128
            <plugins>
129
                <plugin>
130
                    <groupId>org.apache.maven.plugins</groupId>
131
                    <artifactId>maven-release-plugin</artifactId>
132
                    <configuration>
133
                        <tagBase>https://devel.gvsig.org/svn/gvsig-lidar/tags</tagBase>
134
                    </configuration>
135
                </plugin>
136
                <plugin>
137
                    <groupId>org.apache.maven.plugins</groupId>
138
                    <artifactId>maven-compiler-plugin</artifactId>
139
                    <version>2.3.2</version>
140
                    <executions>
141
                        <execution>
142
                            <id>default-compile</id>
143
                            <configuration combine.self="override">
144
                               <compilerArguments>
145
                                   <source>1.7</source>
146
                                   <target>1.7</target>
147
                               </compilerArguments>
148
                            </configuration>
149
                        </execution>
150
                        <execution>
151
                            <id>default-testCompile</id>
152
                            <configuration combine.self="override">
153
                                <compilerArguments>
154
                                    <source>1.7</source>
155
                                    <target>1.7</target>
156
                                </compilerArguments>
157
                            </configuration>
158
                        </execution>
159
                    </executions>
160
            <configuration combine.self="override">
161
              <source>1.7</source>
162
              <target>1.7</target>
163
              <encoding>ISO-8859-1</encoding>
164
            </configuration>
165

  
166

  
167
                </plugin>
168
                <plugin>
169
                    <groupId>org.codehaus.mojo</groupId>
170
                    <artifactId>animal-sniffer-maven-plugin</artifactId>
171
                    <version>1.9</version>
172
                    <executions>
173
                        <execution>
174
                            <id>check-java-api</id>
175
                            <phase>package</phase>
176
                            <goals>
177
                                <goal>check</goal>
178
                            </goals>
179
                            <configuration combine.self="override">
180
                                <skip>true</skip>
181
                                <signature>
182
                                    <groupId>org.codehaus.mojo.signature</groupId>
183
                                    <artifactId>java18</artifactId>
184
                                    <version>1.0</version>
185
                                </signature>
186
                                <ignores>
187
                                    <ignore>net.sourceforge.cobertura.coveragedata.TouchCollector</ignore>
188
                                </ignores>
189
                            </configuration>
190
                        </execution>
191
                    </executions>
192
                </plugin>
193
            </plugins>
194
        </pluginManagement>
195
        <plugins>
196
                <plugin>
197
                    <groupId>org.codehaus.mojo</groupId>
198
                    <artifactId>animal-sniffer-maven-plugin</artifactId>
199
                    <version>1.9</version>
200
                    <executions>
201
                        <execution>
202
                            <id>check-java-api</id>
203
                            <phase>package</phase>
204
                            <goals>
205
                                <goal>check</goal>
206
                            </goals>
207
                            <configuration combine.self="override">
208
                                <skip>true</skip>
209
                                <signature>
210
                                    <groupId>org.codehaus.mojo.signature</groupId>
211
                                    <artifactId>java18</artifactId>
212
                                    <version>1.0</version>
213
                                </signature>
214
                                <ignores>
215
                                    <ignore>net.sourceforge.cobertura.coveragedata.TouchCollector</ignore>
216
                                </ignores>
217
                            </configuration>
218
                        </execution>
219
                    </executions>
220
                </plugin>
221
        </plugins>
222

  
223
    </build>
224
    <modules>
225
        <module>org.gvsig.lidar.app</module>
226
        <module>org.gvsig.lidar.prov</module>
227
    </modules>
228
</project>
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/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
	
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.lidar.app</artifactId>
6
    <packaging>pom</packaging>
7
    <name>org.gvsig.lidar.app</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.lidar</artifactId>
11
        <version>1.0.68</version>
12
    </parent>
13

  
14
    <modules>
15
      <module>org.gvsig.lidar.app.mainplugin</module>
16
      <!--
17
      <module>org.gvsig.lidar.app.export</module>
18
      -->
19
    </modules>
20
</project>
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/buildNumber.properties
1
#Tue Jul 10 00:21:13 CEST 2018
2
buildNumber=31
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/assembly/gvsig-plugin-package.xml
1
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2016 
2
	gvSIG Association. This program is free software; you can redistribute it 
3
	and/or modify it under the terms of the GNU General Public License as published 
4
	by the Free Software Foundation; either version 3 of the License, or (at 
5
	your option) any later version. This program is distributed in the hope that 
6
	it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
7
	of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
8
	Public License for more details. You should have received a copy of the GNU 
9
	General Public License along with this program; if not, write to the Free 
10
	Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
11
	USA. For any additional information, do not hesitate to contact us at info 
12
	AT gvsig.com, or visit our website www.gvsig.com. -->
13
<assembly>
14
	<id>gvsig-plugin-package</id>
15
	<formats>
16
		<format>zip</format>
17
	</formats>
18
	<baseDirectory>${project.artifactId}</baseDirectory>
19
	<includeBaseDirectory>true</includeBaseDirectory>
20
	<files>
21
		<file>
22
			<source>target/${project.artifactId}-${project.version}.jar</source>
23
			<outputDirectory>lib</outputDirectory>
24
		</file>
25
		<file>
26
			<source>target/package.info</source>
27
		</file>
28
	</files>
29

  
30
	<fileSets>
31
		<fileSet>
32
			<directory>src/main/resources-plugin</directory>
33
			<outputDirectory>.</outputDirectory>
34
		</fileSet>
35
	</fileSets>
36

  
37

  
38
	<dependencySets>
39
		<dependencySet>
40
			<useProjectArtifact>false</useProjectArtifact>
41
			<useTransitiveDependencies>false</useTransitiveDependencies>
42
			<outputDirectory>lib</outputDirectory>
43
			<includes>
44
				<include>org.gvsig:org.gvsig.lidar.prov.common</include>
45
				<include>org.gvsig:org.gvsig.lidar.prov.whitebox</include>
46
				<include>org.gvsig:org.gvsig.lidar.prov.jgrass</include>
47
				<include>whitebox:whitebox-api:jar</include>
48
				<include>org.jgrasstools:jgt-jgrassgears</include>
49
				<include>net.java.dev.jna:jna</include>
50
				<include>org.opengis:geoapi</include>
51
			</includes>
52
		</dependencySet>
53

  
54
	</dependencySets>
55

  
56
</assembly>
57

  
58

  
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/prov/lidar/ExporttoLASProvider.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.exportto.swing.prov.lidar;
24

  
25
import java.io.File;
26
import java.util.ArrayList;
27
import java.util.List;
28

  
29
import org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31
import org.gvsig.exportto.ExporttoService;
32
import org.gvsig.exportto.swing.panel.SelectEnvelopeOptionPanel;
33
import org.gvsig.exportto.swing.prov.file.AbstractExporttoFileProvider;
34
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
38
import org.gvsig.fmap.geom.primitive.Envelope;
39
import org.gvsig.tools.service.spi.ProviderServices;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42
import org.gvsig.exportto.swing.prov.lidar.ExporttoLASService;
43

  
44
/**
45
 * Exporto provider which gets Exporto from a file.
46
 *
47
 * @author <a href="mailto:cmartinez@scolab.es">Cesar Martinez Izquierdo</a>
48
 */
49
public class ExporttoLASProvider extends AbstractExporttoFileProvider
50
        implements ExporttoLASOptions {
51

  
52
    private static Logger logger = LoggerFactory.getLogger(
53
            ExporttoLASProvider.class);
54

  
55
    protected List<ExporttoSwingProviderPanel> panels = new ArrayList<ExporttoSwingProviderPanel>();
56
    
57
    private String storeName = null;
58
    protected SelectEnvelopeOptionPanel envelopePanel;
59
    
60
    public ExporttoLASProvider(ProviderServices providerServices,
61
            FeatureStore sourceStore, IProjection targetProjection) {
62
    	super(providerServices, sourceStore, targetProjection);
63
    	IProjection sourceProjection = getSourceSrs(sourceStore);
64
    	envelopePanel = new SelectEnvelopeOptionPanel(sourceProjection);
65
    }
66
    
67
    protected IProjection getSourceSrs(FeatureStore sourceStore) {
68
    	try {
69
    		return sourceStore.getDefaultFeatureType().getDefaultGeometryAttribute().getSRS();
70
    	} catch (Exception e) {}
71
    	return null;
72
    }
73

  
74
    public int getPanelCount() {
75
    	return super.getPanelCount()+1;
76
        //return this.panels.size();
77
    }
78

  
79
    public ExporttoSwingProviderPanel getPanelAt(int index) {
80
    	if (super.getPanelCount()>index) {
81
    		return super.getPanelAt(index);	
82
    	}
83
    	else {
84
    		return envelopePanel;
85
    	}
86
    }
87

  
88
    public FeatureStore getSource() {
89
        return this.featureStore;
90
    }
91

  
92
    public ExporttoService createExporttoService() {
93
        return new ExporttoLASService(this);
94
    }
95

  
96
    public FilesystemServerExplorerParameters getExplorerParameters() {
97
    	return null;
98
        // CMI return this.connectionPanel.getServerExplorerParameters();
99
    }
100

  
101

  
102

  
103
	public File getOutputFile() {
104
		return this.selectFileOptionPanel.getSelectedFile();
105
	}
106

  
107

  
108

  
109
	public IProjection getTargetProjection() {
110
		return this.projection;
111
	}
112

  
113

  
114
	public Envelope getFilterEnvelope() {
115
		return this.envelopePanel.getEnvelope();
116
	}    
117
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/prov/lidar/ExporttoLASOptions.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23

  
24
package org.gvsig.exportto.swing.prov.lidar;
25

  
26
import java.io.File;
27

  
28
import org.cresques.cts.IProjection;
29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
31
import org.gvsig.fmap.geom.primitive.Envelope;
32

  
33

  
34
/**
35
 *
36
 * @author <a href="mailto:cmartinez@scolab.es">Cesar Martinez Izquierdo</a>
37
 */
38
public interface ExporttoLASOptions  {
39

  
40
    public FilesystemServerExplorerParameters getExplorerParameters();
41
    
42
    public File getOutputFile();
43
    
44
    public FeatureStore getSource();
45
    
46
    public IProjection getTargetProjection();
47
    
48
    public Envelope getFilterEnvelope();
49
    
50
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/prov/lidar/ExporttoLASProviderLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.exportto.swing.prov.lidar;
24

  
25
import org.gvsig.exportto.swing.ExporttoSwingLibrary;
26
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator;
27
import org.gvsig.fmap.dal.DALLibrary;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.i18n.I18nManager;
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.tools.service.spi.ProviderManager;
33

  
34
/**
35
 * @author <a href="mailto:cmartinez@scolab.es">Cesar Martinez Izquierdo</a>
36
 *
37
 */
38
public class ExporttoLASProviderLibrary extends AbstractLibrary {
39

  
40
    @Override
41
    public void doRegistration() {
42
        registerAsServiceOf(ExporttoSwingLibrary.class);
43
        require(DALLibrary.class);
44
        require(ExporttoSwingLibrary.class);
45
    }
46

  
47
    @Override
48
    protected void doInitialize() throws LibraryException {
49
        I18nManager i18nManager = ToolsLocator.getI18nManager();
50
        i18nManager.addResourceFamily(
51
                "org.gvsig.exportto.swing.prov.lidar",
52
                ExporttoLASProviderLibrary.class.getClassLoader(),
53
                ExporttoLASProviderLibrary.class.getClass().getName()
54
        );
55
    }
56

  
57
    @Override
58
    protected void doPostInitialize() throws LibraryException {
59
        ProviderManager providerManager = ExporttoSwingProviderLocator.getManager();
60
        providerManager.addProviderFactory(new ExporttoLASProviderFactory());
61
    }
62

  
63
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/prov/lidar/ExporttoLASService.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.exportto.swing.prov.lidar;
24

  
25
import java.io.File;
26
import java.util.Date;
27
import java.util.List;
28

  
29
import org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31
import org.gvsig.exportto.ExporttoService;
32
import org.gvsig.exportto.ExporttoServiceException;
33
import org.gvsig.exportto.ExporttoServiceFinishAction;
34
import org.gvsig.fmap.dal.DALLocator;
35
import org.gvsig.fmap.dal.DataStoreParameters;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.feature.EditableFeature;
38
import org.gvsig.fmap.dal.feature.Feature;
39
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
40
import org.gvsig.fmap.dal.feature.FeatureReference;
41
import org.gvsig.fmap.dal.feature.FeatureSet;
42
import org.gvsig.fmap.dal.feature.FeatureStore;
43
import org.gvsig.fmap.dal.feature.FeatureType;
44
import org.gvsig.fmap.geom.Geometry;
45
import org.gvsig.fmap.geom.primitive.Envelope;
46
import org.gvsig.lidar.prov.LASOpenStoreParameters;
47

  
48
import org.gvsig.lidar.prov.jgrasstools.JGrassLASDataStoreProvider;
49
import org.gvsig.lidar.prov.jgrasstools.JGrassLASWriter;
50
import org.gvsig.timesupport.Instant;
51
import org.gvsig.timesupport.Interval;
52
import org.gvsig.tools.dispose.DisposableIterator;
53
import org.gvsig.tools.dispose.DisposeUtils;
54
import org.gvsig.tools.dynobject.DynObject;
55
import org.gvsig.tools.evaluator.EvaluatorData;
56
import org.gvsig.tools.task.AbstractMonitorableTask;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59

  
60
/**
61
 * @author <a href="mailto:cmartinez@scolab.es">Cesar Martinez Izquierdo</a>
62
 *
63
 */
64
public class ExporttoLASService extends AbstractMonitorableTask implements
65
        ExporttoService {
66

  
67
    private static final Logger logger = LoggerFactory.getLogger(ExporttoLASService.class);
68

  
69
    public static final int CHECK_NONE = 0;
70
    public static final int CHECK_IF_CORRUPT = 1;
71
    public static final int CHECK_IF_VALID = 2;
72

  
73
    public static final int ACTION_SET_GEOMETRY_TO_NULL = 0;
74
    public static final int ACTION_SKIP_FEATURE = 1;
75
    public static final int ACTION_ABORT = 2;
76

  
77
    private ExporttoServiceFinishAction exporttoServiceFinishAction = null;
78
    private ExporttoLASOptions options;
79

  
80
    public ExporttoLASService(ExporttoLASOptions options) {
81
        this.options = options;
82
    }
83

  
84

  
85
    public void export(FeatureSet featureSet) throws ExporttoServiceException {
86
    	File outFile = this.options.getOutputFile();
87
        DisposableIterator it = null;
88
        try {
89
        	
90
        	
91
            // ======================================
92
            // Reprojection 
93
            FeatureAttributeDescriptor geo_att = this.options.getSource().getDefaultFeatureType().getDefaultGeometryAttribute();
94
            IProjection sourceProjection = null;
95
            ICoordTrans coord_trans = null;
96
            Geometry reproj_geom = null;
97
            Envelope filterEnvelope = this.options.getFilterEnvelope();
98
            
99
            if (geo_att != null) {
100
                sourceProjection = geo_att.getSRS();
101
                // FIXME: we should get the transformation from the options and not from the layer projection.
102
                // If the layer contains a CT, it has been set to convert from layer to view projection,
103
                // which is not necessarily the right one for the target export projection.
104
                // We will be able to improve these corner cases when the new CRS API is fully implemented
105
                if (sourceProjection != null && sourceProjection != this.options.getTargetProjection()) {
106
                    coord_trans = sourceProjection.getCT(this.options.getTargetProjection());
107
                }
108
            }
109
            
110
            // ============================================
111

  
112
            LASOpenStoreParameters openParams = new LASOpenStoreParameters(JGrassLASDataStoreProvider.NAME);
113
            openParams.setFile(outFile);
114
            openParams.setCRS(this.options.getTargetProjection());
115

  
116
            FeatureType sourceFeatureType = featureSet.getDefaultFeatureType();
117
            
118
            Envelope outEnvelope = null;
119
            if (coord_trans!=null) {
120
            	outEnvelope = this.options.getSource().getEnvelope().convert(coord_trans);
121
            }
122
            else {
123
            	outEnvelope = this.options.getSource().getEnvelope();
124
            }
125
            
126
            JGrassLASWriter writer = new JGrassLASWriter(openParams, sourceFeatureType, outEnvelope);            
127
            writer.open();
128
            
129
            int featureCount = 1;
130
            taskStatus.setRangeOfValues(0, featureSet.getSize());
131
            logger.debug("Inserting rows");
132
            taskStatus.message("Inserting rows");
133
            it = featureSet.fastIterator();
134
            while (it.hasNext()) {
135
                Feature feature = (Feature) it.next();
136
                this.taskStatus.setCurValue(featureCount);
137
                Geometry geometry = feature.getDefaultGeometry();
138
                if (filterEnvelope==null
139
                		|| filterEnvelope.intersects(geometry)) {
140
                	// ================================================
141
                	// Reprojection 
142
                	if (geometry != null && 
143
                			geo_att != null && coord_trans != null) {
144
                		CustomFeatureImpl customFeature = new CustomFeatureImpl(feature);
145
                		reproj_geom = geometry.cloneGeometry();
146
                		reproj_geom.reProject(coord_trans);
147
                		customFeature.setDefaultGeometry(reproj_geom);
148
                		feature = customFeature;
149
                	}
150
                	// ================================================
151
                    writer.write(feature);
152
                }
153

  
154
                if (this.taskStatus.isCancellationRequested()) {
155
                    return;
156
                }
157
                featureCount++;
158
            }
159
            writer.close();
160

  
161
            finishAction(this.options.getOutputFile().getName(), this.options.getOutputFile(), this.options.getTargetProjection());
162
            taskStatus.message("Exportation finished");
163

  
164
        } catch (Exception e) {
165
            logger.warn("Can't export data.", e);
166
            taskStatus.message("Problems exporting data");
167
            throw new ExporttoServiceException(e);
168

  
169
        } finally {
170
        	DisposeUtils.disposeQuietly(it);
171
        	DisposeUtils.disposeQuietly(featureSet);
172
            this.taskStatus.terminate();
173
            this.taskStatus.remove();
174
        }
175
    }
176
    
177
    protected void finishAction(String layerName, File out_file, IProjection proj)
178
    throws ExporttoServiceException {
179

  
180
        if (exporttoServiceFinishAction != null) {
181
            /*
182
             * Export is done. We notify with a SHPStoreParameters,
183
             * not with the NewSHPParameters we have used:
184
             */
185
        	DataStoreParameters las_params = null;
186
        	
187
            try {
188
            	las_params = DALLocator.getDataManager().createStoreParameters(JGrassLASDataStoreProvider.NAME);
189
            	las_params.setDynValue("file", out_file);
190
            	las_params.setDynValue("CRS", proj);
191

  
192
            	las_params.validate();
193
            } catch (Exception e) {
194
                throw new ExporttoServiceException(e);
195
            }
196
            exporttoServiceFinishAction.finished(layerName, las_params);
197
        }
198
    }
199

  
200
    public void setFinishAction(
201
            ExporttoServiceFinishAction exporttoServiceFinishAction) {
202
        this.exporttoServiceFinishAction = exporttoServiceFinishAction;
203
    }
204
    
205
    /**
206
     * Incomplete implementation of editable feature, only used to feed
207
     * reprojected features to the LAS Writer
208
     * 
209
     * @author cesar
210
     *
211
     */
212
    protected class CustomFeatureImpl implements Feature {
213
    	private Feature feature;
214
    	private Geometry theGeom;
215
    	private String defaultGeomName;
216
    	private int defaultGeomIndex;
217
    	
218
    	public CustomFeatureImpl(Feature feat) {
219
    		this.feature = feat;
220
    		this.defaultGeomName = feat.getType().getDefaultGeometryAttributeName();
221
    		this.defaultGeomIndex = feat.getType().getDefaultGeometryAttributeIndex();
222
    	}
223

  
224
		public FeatureReference getReference() {
225
			throw new UnsupportedOperationException();
226
		}
227

  
228
		public FeatureType getType() {
229
			return feature.getType();
230
		}
231

  
232
		public Feature getCopy() {
233
			CustomFeatureImpl copy = new CustomFeatureImpl(feature.getCopy());
234
			copy.setDefaultGeometry(theGeom);
235
			return copy;
236
		}
237

  
238
		public void validate(int mode) throws DataException {
239
			feature.validate(mode);
240
		}
241
		public EditableFeature getEditable() {
242
			return feature.getEditable();
243
		}
244
		public Object get(String name) {
245
			if (name.equals(defaultGeomName) && theGeom!=null) {
246
				return theGeom;
247
			}
248
			return feature.get(name);
249
		}
250
		public Object get(int index) {
251
			if (index==defaultGeomIndex && theGeom!=null) {
252
				return theGeom;
253
			}
254
			return feature.get(index);
255
		}
256
		public int getInt(String name) {
257
			return feature.getInt(name);
258
		}
259
		public int getInt(int index) {
260
			return feature.getInt(index);
261
		}
262
		public boolean getBoolean(String name) {
263
			return feature.getBoolean(name);
264
		}
265
		public boolean getBoolean(int index) {
266
			return feature.getBoolean(index);
267
		}
268
		public long getLong(String name) {
269
			return feature.getLong(name);
270
		}
271
		public long getLong(int index) {
272
			return feature.getLong(index);
273
		}
274
		public float getFloat(String name) {
275
			return feature.getFloat(name);
276
		}
277
		public float getFloat(int index) {
278
			return feature.getFloat(index);
279
		}
280
		public double getDouble(String name) {
281
			return feature.getDouble(name);
282
		}
283
		public double getDouble(int index) {
284
			return feature.getDouble(index);
285
		}
286
		public Date getDate(String name) {
287
			return feature.getDate(name);
288
		}
289
		public Date getDate(int index) {
290
			return feature.getDate(index);
291
		}
292
		public String getString(String name) {
293
			return feature.getString(name);
294
		}
295
		public String getString(int index) {
296
			return feature.getString(index);
297
		}
298
		public byte getByte(String name) {
299
			return feature.getByte(name);
300
		}
301
		public byte getByte(int index) {
302
			return feature.getByte(index);
303
		}
304
		public Geometry getGeometry(String name) {
305
			if (name.equals(this.defaultGeomName) && theGeom!=null) {
306
				return theGeom;
307
			}
308
			return feature.getGeometry(name);
309
		}
310
		public Geometry getGeometry(int index) {
311
			if (index==defaultGeomIndex && theGeom!=null) {
312
				return theGeom;
313
			}
314
			return feature.getGeometry(index);
315
		}
316
		public Object[] getArray(String name) {
317
			return feature.getArray(name);
318
		}
319
		public Object[] getArray(int index) {
320
			return feature.getArray(index);
321
		}
322
		public Feature getFeature(String name) {
323
			return feature.getFeature(name);
324
		}
325
		public Feature getFeature(int index) {
326
			return feature.getFeature(index);
327
		}
328
		public Envelope getDefaultEnvelope() {
329
			return feature.getDefaultEnvelope();
330
		}
331
		public Geometry getDefaultGeometry() {
332
			if (theGeom!=null) {
333
				return theGeom;
334
			}
335
			return feature.getDefaultGeometry();
336
		}
337
		public void setDefaultGeometry(Geometry geom) {
338
			this.theGeom = geom;
339
		}
340
		public List getGeometries() {
341
			throw new UnsupportedOperationException();
342
		}
343
		public IProjection getDefaultSRS() {
344
			return feature.getDefaultSRS();
345
		}
346
		public List getSRSs() {
347
			return feature.getSRSs();
348
		}
349
		public Instant getInstant(int index) {
350
			return feature.getInstant(index);
351
		}
352
		public Instant getInstant(String name) {
353
			return feature.getInstant(name);
354
		}
355
		public Interval getInterval(int index) {
356
			return feature.getInterval(index);
357
		}
358
		public Interval getInterval(String name) {
359
			return feature.getInterval(name);
360
		}
361
		public DynObject getAsDynObject() {
362
			return feature.getAsDynObject();
363
		}
364
		public EvaluatorData getEvaluatorData() {
365
			return feature.getEvaluatorData();
366
		}
367
		
368
		public FeatureStore getStore() {
369
			return feature.getStore();
370
		}
371
    }
372

  
373

  
374
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/prov/lidar/ExporttoLASProviderFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.exportto.swing.prov.lidar;
24

  
25
import org.cresques.cts.IProjection;
26
import org.gvsig.exportto.swing.ExporttoSwingManager;
27
import org.gvsig.exportto.swing.spi.AbstractExporttoProviderFactory;
28
import org.gvsig.fmap.dal.feature.FeatureStore;
29
import org.gvsig.i18n.Messages;
30
import org.gvsig.tools.dynobject.DynObject;
31
import org.gvsig.tools.service.ServiceException;
32
import org.gvsig.tools.service.spi.Provider;
33
import org.gvsig.tools.service.spi.ProviderServices;
34

  
35
/**
36
 * Factory of file {@link ExportoProvider} objects.
37
 * 
38
 * @author <a href="mailto:cmartinez@scolab.es">Cesar Martinez Izquierdo</a>
39
 */
40
public class ExporttoLASProviderFactory extends
41
        AbstractExporttoProviderFactory {
42

  
43
    private static final String PROVIDER_NAME = "LAS";
44

  
45
    public ExporttoLASProviderFactory() {
46
        super(new int[]{
47
            ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY,
48
            ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY});
49
    }
50

  
51
    public String getName() {
52
        return PROVIDER_NAME;
53
    }
54

  
55
    public String getDescription() {
56
        return Messages.getText("general_exporter_description",
57
                new String[]{"LAS file"});
58
    }
59

  
60
    public String getLabel() {
61
        return Messages.getText("general_exporter_label",
62
                new String[]{"LAS file"});
63
    }
64

  
65

  
66
    public Provider create(DynObject parameters, ProviderServices services) throws ServiceException {
67
        return new ExporttoLASProvider(services,
68
                (FeatureStore) parameters.getDynValue(PARAMETER_FEATURESTORE),
69
                (IProjection) parameters.getDynValue(PARAMETER_PROJECTION));
70
    }
71

  
72
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/panel/SelectEnvelopeOptionPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.exportto.swing.panel;
24

  
25
import java.awt.BorderLayout;
26
import java.awt.Component;
27
import java.io.File;
28

  
29
import javax.swing.JComponent;
30
import javax.swing.JOptionPane;
31
import javax.swing.JPanel;
32

  
33
import org.cresques.cts.ICoordTrans;
34
import org.cresques.cts.IProjection;
35
import org.gvsig.app.ApplicationLocator;
36
import org.gvsig.app.project.documents.Document;
37
import org.gvsig.app.project.documents.view.BaseViewDocument;
38
import org.gvsig.exportto.swing.ExporttoSwingLocator;
39
import org.gvsig.exportto.swing.ExporttoSwingManager;
40
import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException;
41
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
42
import org.gvsig.fmap.dal.exception.DataException;
43
import org.gvsig.fmap.dal.feature.FeatureStore;
44
import org.gvsig.fmap.geom.Geometry;
45
import org.gvsig.fmap.geom.GeometryLocator;
46
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
47
import org.gvsig.fmap.geom.primitive.Envelope;
48
import org.gvsig.fmap.mapcontext.MapContext;
49
import org.gvsig.gui.beans.coordinatespanel.CoordinatesPanel;
50
import org.gvsig.i18n.Messages;
51
import org.gvsig.tools.locator.LocatorException;
52

  
53
/**
54
 * @author gvSIG Team
55
 * @version $Id$
56
 * 
57
 */
58
public class SelectEnvelopeOptionPanel extends JPanel implements ExporttoSwingProviderPanel {
59
	private static final long serialVersionUID = -729071840887099236L;
60

  
61
	private JPanel optionsPanel;
62

  
63
    private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER =
64
        ExporttoSwingLocator.getSwingManager();
65

  
66
    private SelectEnvelopePanel panel;
67

  
68
    /**
69
     * @param dataSourceSRS Data source SRS, used to transform the View
70
     * envelope to the data source projection, if View and data source
71
     * use different projection
72
     */
73
    public SelectEnvelopeOptionPanel(IProjection dataSourceSRS) {
74
        this(dataSourceSRS, null);
75
    }
76

  
77
    /**
78
     * @param dataSourceSRS Data source SRS, used to transform the View
79
     * envelope to the data source projection, if View and data source
80
     * use different projection
81
     */
82
    public SelectEnvelopeOptionPanel(IProjection dataSourceSRS, JPanel optionsPanel) {
83
        super();
84
        this.setLayout(new BorderLayout());
85
        Document d = ApplicationLocator.getManager().getActiveDocument();
86
        if (d instanceof BaseViewDocument) {
87
        	BaseViewDocument view = (BaseViewDocument) d;
88
        	MapContext mc = view.getMapContext();
89
        	ICoordTrans viewTolayerCT = getViewToSourceCoordTrans(dataSourceSRS, mc.getProjection());
90
        	panel = new SelectEnvelopePanel(view.getMapContext(), viewTolayerCT);
91
        }
92
        else {
93
        	panel = new SelectEnvelopePanel();
94
        }
95
        
96
        add(panel, BorderLayout.NORTH);
97
        if (optionsPanel != null) {
98
            optionsPanel.setBorder(javax.swing.BorderFactory
99
                .createCompoundBorder(javax.swing.BorderFactory
100
                    .createTitledBorder(Messages.getText("options")),
101
                    javax.swing.BorderFactory.createEmptyBorder(10, 5, 5, 5)));
102
            add(optionsPanel, BorderLayout.CENTER);
103
            this.optionsPanel = optionsPanel;
104
        }
105
    }
106
    
107
    protected ICoordTrans getViewToSourceCoordTrans(IProjection sourceSrs,
108
    		IProjection viewSrs) {
109
    	ICoordTrans trans = null;
110
    	try {
111
			/***
112
			 * We get the CT from the sourceSRS and then then inverted because
113
			 * data source to View transform is usually stored in the sourceSrs
114
			 * and not in the view SRS
115
			 */
116
			trans = sourceSrs.getCT(viewSrs).getInverted();
117
		} catch (Exception e) {}
118
    	return trans;
119
    }
120

  
121
    public String getPanelTitle() {
122
        return EXPORTTO_SWING_MANAGER.getTranslation("Filter_by_envelope");
123
    }
124

  
125
    public Envelope getEnvelope() {
126
    	
127
    	return panel.getEnvelope();
128
    }
129

  
130
    public void enterPanel() {
131
        // Default do nothing
132
    }
133
    
134
    public boolean isValidPanel() throws ExporttoPanelValidationException {
135
        return true;
136
    }
137

  
138
    /**
139
     * @return the optionsPanel
140
     */
141
    public JPanel getOptionsPanel() {
142
        return optionsPanel;
143
    }
144

  
145
    public JComponent asJComponent() {
146
        return this;
147
    }
148
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/exportto/swing/panel/SelectEnvelopePanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2016 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23

  
24
package org.gvsig.exportto.swing.panel;
25

  
26
import java.awt.Color;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30

  
31
import javax.swing.BorderFactory;
32
import javax.swing.ButtonGroup;
33
import javax.swing.JPanel;
34
import javax.swing.JRadioButton;
35

  
36
import org.cresques.cts.ICoordTrans;
37
import org.gvsig.fmap.geom.Geometry;
38
import org.gvsig.fmap.geom.GeometryLocator;
39
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
40
import org.gvsig.fmap.geom.primitive.Envelope;
41
import org.gvsig.fmap.mapcontext.MapContext;
42
import org.gvsig.gui.beans.coordinatespanel.CoordinatesPanel;
43
import org.gvsig.tools.ToolsLocator;
44
import org.gvsig.tools.i18n.I18nManager;
45
import org.gvsig.tools.locator.LocatorException;
46

  
47
/**
48
 * A panel to select an envelope from different options:
49
 * - original data source envelope
50
 * - visible extent of the provided View (MapContext)
51
 * - user defined Envelope
52
 */
53
public class SelectEnvelopePanel extends JPanel {
54
	I18nManager trans = ToolsLocator.getI18nManager();
55

  
56
	private JRadioButton btnOriginalEnvelope = null;
57
	private JRadioButton btnViewEnvelope = null;
58
	private JRadioButton btnUserDefinedEnvelope = null;
59
	private ButtonGroup group = null;
60

  
61
	private CoordinatesPanel btnPnlDefinedEnvelope;
62

  
63
	private MapContext mapContext = null;
64
	private ICoordTrans viewTolayerCT = null;
65

  
66
	private static final long serialVersionUID = 4179360502906000062L;
67

  
68
	/**
69
	 * When using this constructor, the View extent will not be
70
	 * available.
71
	 */
72
	public SelectEnvelopePanel() {
73
		initComponents();
74
	}
75

  
76
    /**
77
     * Preferred constructor.
78
     * 
79
     * @param mapcontext The MapContext to get the View envelope
80
     * @param viewTolayerCT A coordinate transform to transform the
81
     * view envelope from view projection coordinates to layer
82
     * projection coordinates. Can be set to null if layer and view
83
     * have the same projection.
84
     */
85
	public SelectEnvelopePanel(MapContext mapContext, ICoordTrans viewTolayerCT) {
86
		this.mapContext = mapContext;
87
		this.viewTolayerCT = viewTolayerCT;
88
		initComponents();
89
	}
90
	
91
	private void initComponents() {
92
		this.setLayout(new GridBagLayout());
93
		group = new ButtonGroup();
94
		GridBagConstraints constraints = new GridBagConstraints();
95
		constraints.gridx = 0;
96
		constraints.gridy = 0;
97
		constraints.anchor = GridBagConstraints.WEST;
98
		constraints.fill = GridBagConstraints.HORIZONTAL;
99
		constraints.insets = new Insets(5, 5, 5, 5);
100
		this.add(getBtnOriginalEnvelope(), constraints);
101
		getBtnOriginalEnvelope().setSelected(true);
102
		if (mapContext!=null) {
103
			constraints.gridy++;
104
			this.add(getBtnViewEnvelope(), constraints);
105
		}
106
		constraints.gridy++;
107
		this.add(getBtnUserDefinedEnvelope(), constraints);
108
		constraints.gridy++;
109
		constraints.ipadx = 30;
110
		this.add(getPnlUserDefinedEnvelope(), constraints);
111
	}
112
	
113
	private JRadioButton getBtnOriginalEnvelope() {
114
		if (btnOriginalEnvelope==null) {
115
			String text = trans.getTranslation("Do_not_filter_by_envelope");
116
			btnOriginalEnvelope  = new JRadioButton(text);
117
			group.add(btnOriginalEnvelope);
118
		}
119
		return btnOriginalEnvelope;
120
	}
121
	
122
	private JRadioButton getBtnViewEnvelope() {
123
		if (btnViewEnvelope==null) {
124
			String text = trans.getTranslation("Use_View_envelope");
125
			btnViewEnvelope  = new JRadioButton(text);
126
			group.add(btnViewEnvelope);
127
		}
128
		return btnViewEnvelope;
129
	}
130
	
131
	private JRadioButton getBtnUserDefinedEnvelope() {
132
		if (btnUserDefinedEnvelope==null) {
133
			String text = trans.getTranslation("Use_custom_envelope_(coordinates_using_data_source_projection)");
134
			btnUserDefinedEnvelope  = new JRadioButton(text);
135
			group.add(btnUserDefinedEnvelope);
136
		}
137
		return btnUserDefinedEnvelope;
138
	}
139
	
140
	private CoordinatesPanel getPnlUserDefinedEnvelope() {
141
		if (btnPnlDefinedEnvelope==null) {
142
			btnPnlDefinedEnvelope = new CoordinatesPanel();
143
		}
144
		return btnPnlDefinedEnvelope;
145
	}
146
	
147
	
148
	public Envelope getEnvelope() {
149
		if (getBtnViewEnvelope().isSelected()) {
150
			if (this.mapContext!=null) {
151
				Envelope envelope = this.mapContext.getViewPort().getEnvelope();
152
				if (viewTolayerCT!=null) {
153
					envelope = envelope.convert(viewTolayerCT);
154
				}
155
				return envelope;
156
			}
157
		}
158
		else if (getBtnUserDefinedEnvelope().isSelected()){
159
	    	double minX = string2double(getPnlUserDefinedEnvelope().getValue11());
160
	    	double minY = string2double(getPnlUserDefinedEnvelope().getValue22());
161
	    	double maxX = string2double(getPnlUserDefinedEnvelope().getValue21());
162
	    	double maxY = string2double(getPnlUserDefinedEnvelope().getValue12());
163
	    	try {
164
				return GeometryLocator.getGeometryManager().createEnvelope(minX, minY, maxX, maxY, Geometry.SUBTYPES.GEOM2D);
165
			} catch (LocatorException e) {
166
				// TODO Auto-generated catch block
167
				e.printStackTrace();
168
			} catch (CreateEnvelopeException e) {
169
				// TODO Auto-generated catch block
170
				e.printStackTrace();
171
			}
172
		}
173
    	return null;
174
    }
175
	
176
    /**
177
     * Tries to parse a string as a double 
178
     * @return
179
     */
180
    public double string2double(String strDouble) {
181
    	try {
182
    		return Double.valueOf(strDouble).doubleValue();
183
    	}
184
    	catch (Exception e) {}
185
    	// assume comma was used as decimal separator
186
    	String replaced = strDouble.replaceAll(".", "");
187
    	replaced = replaced.replaceAll(",", ".");
188
    	try {
189
    		return Double.valueOf(strDouble).doubleValue();
190
    	}
191
    	catch (Exception e) {}
192
    	
193
    	// return 0.0 if no valid number could be decoded
194
    	return 0.0d;
195
    }
196
	
197
	
198

  
199
}
org.gvsig.lidar/tags/org.gvsig.lidar-1.0.68/org.gvsig.lidar.app/org.gvsig.lidar.app.export/src/main/java/org/gvsig/lidar/export/service/ExportLASService.java
1
package org.gvsig.lidar.export.service;
2

  
3
import java.io.File;
4
import org.apache.commons.io.FilenameUtils;
5
import org.gvsig.export.ExportException;
6
import org.gvsig.export.ExportLocator;
7
import org.gvsig.export.ExportParametersGeometry;
8
import org.gvsig.export.spi.AbstractExportService;
9
import org.gvsig.export.spi.ExportService;
10
import org.gvsig.export.spi.ExportServiceFactory;
11
import org.gvsig.export.spi.ExportServiceManager;
12
import org.gvsig.fmap.dal.DALLocator;
13
import org.gvsig.fmap.dal.DataManager;
14
import org.gvsig.fmap.dal.DataServerExplorer;
15
import org.gvsig.fmap.dal.NewDataStoreParameters;
16
import org.gvsig.fmap.dal.OpenDataStoreParameters;
17
import org.gvsig.fmap.dal.exception.DataException;
18
import org.gvsig.fmap.dal.feature.EditableFeature;
19
import org.gvsig.fmap.dal.feature.Feature;
20
import org.gvsig.fmap.dal.feature.FeatureSet;
21
import org.gvsig.fmap.dal.feature.FeatureStore;
22
import org.gvsig.fmap.dal.feature.FeatureType;
23
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
24
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters;
25
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
26
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
27
import org.gvsig.fmap.geom.Geometry;
28
import org.gvsig.fmap.geom.primitive.Envelope;
29
import org.gvsig.lidar.prov.LASNewStoreParameters;
30
import org.gvsig.lidar.prov.LASOpenStoreParameters;
31
import org.gvsig.lidar.prov.jgrasstools.JGrassLASDataStoreProvider;
32
import org.gvsig.lidar.prov.jgrasstools.JGrassLASWriter;
33
import org.gvsig.tools.dispose.DisposableIterator;
34
import org.gvsig.tools.dispose.DisposeUtils;
35
import org.gvsig.tools.util.HasAFile;
36

  
37
/**
38
 *
39
 * @author jjdelcerro
40
 */
41
public class ExportLASService 
42
        extends AbstractExportService 
43
        implements ExportService 
44
    {
45

  
46
    public ExportLASService(ExportServiceFactory factory, ExportLASParameters parameters) {
47
        super(factory, parameters);
48
    }
49

  
50
    @Override
51
    public ExportLASParameters getParameters() {
52
        return (ExportLASParameters) super.getParameters(); 
53
    }
54

  
55
    @Override
56
    protected DataServerExplorer createServerExplorer() throws ExportException{
57
        
58
        DataManager dataManager = DALLocator.getDataManager();
59

  
60
        FilesystemServerExplorerParameters explorerParams;
61
        try {
62
            explorerParams =
63
                (FilesystemServerExplorerParameters) dataManager
64
                    .createServerExplorerParameters(FilesystemServerExplorer.NAME);
65
        } catch (Exception e) {
66
            throw new ExportException(e);
67
        }
68
        explorerParams.setRoot(this.getParameters().getFile().getParent());
69

  
70
        FilesystemServerExplorer explorer;
71
        try {
72
            explorer = (FilesystemServerExplorer) dataManager.openServerExplorer(
73
                    "FilesystemExplorer", explorerParams
74
            );
75
            return explorer;
76
        } catch (Exception e) {
77
            throw new ExportException(e);
78
        }
79
    }
80

  
81
    @Override
82
    protected LASNewStoreParameters createTargetNewStoreParameters() throws ExportException {
83
        LASNewStoreParameters newStoreParameters = new LASNewStoreParameters(JGrassLASDataStoreProvider.NAME);
84
        newStoreParameters.setFile(getParameters().getFile());
85
        newStoreParameters.setCRS(this.getParameters().getTargetProjection());
86
        return newStoreParameters;
87
    }
88

  
89
    @Override
90
    public LASOpenStoreParameters createTargetOpenStoreParameters() throws ExportException {
91
        try {
92
            DataManager dataManager = DALLocator.getDataManager();
93
            LASOpenStoreParameters openStoreParameters = (LASOpenStoreParameters) dataManager.createStoreParameters(JGrassLASDataStoreProvider.NAME);
94
            ((HasAFile)openStoreParameters).setFile(getParameters().getFile());
95
            openStoreParameters.setDynValue("CRS", this.getParameters().getTargetProjection());
96

  
97
            openStoreParameters.validate();
98
            return openStoreParameters;
99
        } catch (Exception ex) {
100
            throw new ExportException(ex);
101
        }
102
    }
103

  
104
    @Override
105
    public void export(FeatureSet featureSet) throws ExportException {
106
        DataServerExplorer explorer = createServerExplorer();
107
        LASNewStoreParameters newStoreParameters = createTargetNewStoreParameters();
108
        LASOpenStoreParameters openStoreParameters = createTargetOpenStoreParameters();
109

  
110
        String providerName = newStoreParameters.getDataStoreName();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff