Revision 25759

View differences:

tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/build.xml
1
<project name="jlidarlib" default="clean-orig" basedir=".">
2
    <description>
3
        Genera jDielmoOpenLiDARlib.jar en /lib y una distribuciĆ³n
4
    </description>
5
	<!-- set global properties for this build -->
6
	<property name="src" location="src"/>
7
	<property name="build" location="bin"/>
8
	<property name="lib"  location="lib"/>
9
	<property name="doc"  location="doc"/>
10
	<property name="jarName" value="jDielmoOpenLiDARlib"/>
11
	<property name="sig_lidar_driver" location="../extDielmoOpenLidar/lib"/>
12
	<property name="dist"  location="dist"/>
13
	<property name="libDir" location="../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/lib" />
14
	<property name="andamiLibs" location="../_fwAndami/lib" />
15
	<property name="compile-classpath" value="${libDir}/fmap.jar:${andamiLibs}/log4j-1.2.8.jar"/>
16
	
17
	<property name="JavaSourceVersion" value="1.4"/>
18
	<property name="JavaTargetVersion" value="1.4"/>
19
	<property name="encoding" value="ISO_8859_1"/>
20

  
21
  <target name="init">
22
    <!-- Create the time stamp -->
23
    <tstamp/>
24
	<echo>
25
		Compiling ${ant.project.name}...</echo>
26
  </target>
27

  
28
  <target name="make1" depends="init"
29
        description="generate jDielmoOpenLiDARlib.jar in /lib and in the gvSIG Driver" >
30
    <jar jarfile="${sig_lidar_driver}/${jarName}.jar">
31
      <fileset dir="${build}" />
32
    </jar>
33
  	
34
  	<jar jarfile="${lib}/${jarName}.jar" basedir="${build}" includes="**/**"/>
35
  </target>
36
	
37
	<target name="clean-orig" depends="dist"
38
			description="clean dist directory" >
39
		<!-- Clean the distribution directory -->
40
		<delete dir="${dist}/src"/>
41
		<delete dir="${dist}/doc"/>
42
		<delete dir="${dist}/lib"/>
43
	</target>
44

  
45
  <target name="dist" depends="make1"
46
	description="generate the distribution" >
47
    <!-- Remove previous distribution directory -->
48
    <delete dir="${dist}"/>
49
    <!-- Create the distribution directory structure -->
50
    <mkdir dir="${dist}"/>
51
    <mkdir dir="${dist}/src"/>
52
    <mkdir dir="${dist}/doc"/>
53
    <mkdir dir="${dist}/lib"/>
54
    <!-- Copy necessary distribution files to dist dir -->
55
    <copy todir="${dist}/src">
56
      <fileset dir="${src}"/>
57
    </copy>
58
  	
59
    <copy todir="${dist}/doc">
60
      <fileset dir="${doc}">
61
      </fileset>
62
    </copy>
63
  	
64
  	<copy todir="${dist}/lib">
65
      <fileset dir="${lib}"/>
66
    </copy>
67
  	
68
    <!-- Zip distribution -->
69
    <zip destfile="${dist}/jDielmoOpenLiDARlib.zip"
70
         basedir="${dist}"
71
         update="true"
72
    />
73
  </target>
74
	
75
	<target name="batch-build"
76
			description="compile the sources, create the jar file"
77
			depends="init,compile,create-jar,move-to-extDielmoOpenLidar">
78
	</target>
79

  
80
	<target name="compile" description="compile the source" >
81
		<!-- Compile the Java code from ${src} to ${build} -->
82
		<mkdir dir="${build}" />
83
		<javac  srcdir="${src}"
84
			destdir="${build}"
85
			classpath="${compile-classpath}"
86
			source="${JavaSourceVersion}"
87
			target="${JavaTargetVersion}"			
88
			debug="${debug}"
89
			debuglevel="${debuglevel}"
90
			excludes="com/iver/cit/gvsig/fmap/**"
91
			encoding="${encoding}"/>
92
	</target>
93
	
94
	<target name="create-jar"
95
			description="Creates the plugin jar">
96
		<mkdir dir="${dist}"/>
97
	    <jar 	jarfile="${dist}/${jarName}.jar"
98
	    		basedir="${build}"/>
99
	</target>
100
	
101
	<target name="move-to-extDielmoOpenLidar">
102
	  	<!-- jar file must be in gvSIG/lib directory -->
103
	  	<!--<copy file="${without_src}/${plugin}.jar" todir="${lib-dir}"/>-->
104
	    <move todir="${sig_lidar_driver}" file="${dist}/${jarName}.jar"/>
105
	</target>
106
	
107
	<target name="clean"
108
			description="clean up">
109
		<!-- Delete the ${build} and ${dist} directory trees -->
110
		<delete dir="${build}" />
111
		<delete dir="${dist}" />
112
	</target>
113

  
114
</project>
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry combineaccessrules="false" kind="src" path="/libIverUtiles"/>
6
	<classpathentry combineaccessrules="false" kind="src" path="/libGDBMS"/>
7
	<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/>
8
	<classpathentry kind="output" path="bin"/>
9
</classpath>
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>libDielmoOpenLiDAR</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/config/text.properties
1
outOFIndex=Punto inexperado: fuera del indice
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/config/text_en.properties
1
outOFIndex=unexpected point: out of bounds
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/src/com/dielmo/lidar/InicializeLidar.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
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 more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.lidar;
51

  
52
import java.io.File;
53
import java.io.FileInputStream;
54
import java.io.FileNotFoundException;
55
import java.io.IOException;
56
import java.io.InputStream;
57

  
58
import javax.swing.JOptionPane;
59

  
60

  
61
/**
62
 * Inicizliza Lidar points and header
63
 *
64
 * @author Oscar Garcia
65
 */
66
public class InicializeLidar {
67

  
68
	public static int testLASFormat(File name) {
69

  
70
		File f = name;
71
		InputStream input;
72
		int offset = 0,numRead = 0;
73
		char[] FileSignatureLASF = new char[4];
74
		char  versionMajor, versionMinor, format;
75
		byte[] cabecera = new byte[105]; // lleemos hasta el byte que nos indica la version de LAS en la que estamos
76
		
77
		try {
78
	    	  
79
	    	input = new FileInputStream(f);
80
			while (offset < cabecera.length && (numRead = input.read(cabecera, offset, cabecera.length-offset) ) >= 0) {
81
			     offset += numRead;
82
			}	
83
		   
84
		    FileSignatureLASF[0] = (char)(cabecera[0] & 0xFF);
85
		    FileSignatureLASF[1] = (char)(cabecera[1] & 0xFF);
86
		    FileSignatureLASF[2] = (char)(cabecera[2] & 0xFF);
87
		    FileSignatureLASF[3] = (char)(cabecera[3] & 0xFF);
88
		    
89
		    if(FileSignatureLASF[0] == 'L'&& FileSignatureLASF[1] == 'A'&& FileSignatureLASF[2] == 'S' && FileSignatureLASF[3] == 'F') {
90
		    	
91
			    if (offset < cabecera.length) {
92
			    	JOptionPane.showMessageDialog(null, "Bad input format");
93
				}
94
			    
95
			    versionMajor = (char)(cabecera[24] & 0xFF);
96
			    versionMinor = (char)(cabecera[25] & 0xFF);
97
			    format = (char)(cabecera[104] & 0xFF);
98
			
99
		    	if(versionMajor == 1 && versionMinor == 0) {
100
		    		
101
		    		if(format == 0)
102
		    			return LidarHeader.LAS10F0;
103
		    		else if(format == 1)
104
		    			return LidarHeader.LAS10F1;
105
		    	} else if(versionMajor == 1 && versionMinor == 1) {
106
		    		
107
		    		if(format == 0)
108
		    			return LidarHeader.LAS11F0;
109
		    		else if(format == 1)
110
		    			return LidarHeader.LAS11F1;
111
		    	} else if (versionMajor == 1 && versionMinor == 2){
112
		    		
113
		    		if(format == 0)
114
		    			return LidarHeader.LAS12F0;
115
		    		else if(format == 1)
116
		    			return LidarHeader.LAS12F1;
117
		    		else if(format == 2)
118
		    			return LidarHeader.LAS12F2;
119
		    		else if(format == 3)
120
		    			return LidarHeader.LAS12F3;
121
		    		
122
		    	} else {
123
		    		throw new UnexpectedLidarHeaderException("Header not expected");
124
		    	}
125
		    }
126
		    
127
		} catch(UnexpectedLidarHeaderException e) {
128
			e.printStackTrace();			
129
		} catch (FileNotFoundException e) {
130
			// TODO Auto-generated catch block
131
			e.printStackTrace();
132
		} catch (IOException e) {
133
			// TODO Auto-generated catch block
134
			e.printStackTrace();
135
		}
136
		
137
		return LidarHeader.UNEXPECTED;
138
	}
139
	
140
	public static int testBINFormat(File name) {
141
		
142
		File f = name;
143
		InputStream input;
144
		int offset = 0,numRead = 0;
145
		byte[] cabecera = new byte[8];
146
		
147
		try {
148
	    	  
149
	    	input = new FileInputStream(f);
150
			while (offset < cabecera.length && (numRead = input.read(cabecera, offset, cabecera.length-offset) ) >= 0) {
151
			     offset += numRead;
152
			}
153
		    
154
		    int HdrVersionBin; 
155
	    	HdrVersionBin = ByteUtilities.arr2Int(cabecera, 4);
156
	    	if(HdrVersionBin == 20020715) {
157
	    		
158
	    		return LidarHeader.BIN20020715;
159
	    	}
160
	    	else if( HdrVersionBin == 20010712) {
161
	    		
162
	    		return LidarHeader.BIN20010712;
163
	    	} //  ( HdrVersionBin == 20010129 || HdrVersionBin == 970404)	
164
		
165
		} catch (FileNotFoundException e) {
166
			// TODO Auto-generated catch block
167
			e.printStackTrace();
168
		} catch (IOException e) {
169
			// TODO Auto-generated catch block
170
			e.printStackTrace();
171
		}
172
		
173
		return LidarHeader.UNEXPECTED;
174
	}
175
	
176
	public static int testFormat(File name) {
177
		
178
		int f = testLASFormat(name);
179
		if(f != LidarHeader.UNEXPECTED) {
180
			return f;
181
		}
182
		
183
		f = testBINFormat(name);
184
		if(f != LidarHeader.UNEXPECTED) {
185
			return f;
186
		}
187
		
188
		if (f == LidarHeader.UNEXPECTED) {
189
	    	JOptionPane.showMessageDialog(null, "Unsupported format");
190
		}
191
	
192
		return LidarHeader.UNEXPECTED;
193
		
194
	}
195
	
196
	public static LidarPoint InizializeLidarPoint(File file) {
197
		boolean binColor, binTime;
198
		
199
		int type = testFormat(file);
200
		switch(type) {
201
		
202
			case LidarHeader.LAS10F0:
203
				return new LASPoint10F0();
204
				
205
			case LidarHeader.LAS10F1:
206
				return new LASPoint10F1();
207
				
208
			case LidarHeader.LAS11F0:
209
				return new LASPoint11F0();
210
				
211
			case LidarHeader.LAS11F1:
212
				return new LASPoint11F1();
213
				
214
			case LidarHeader.LAS12F0:
215
				return new LASPoint12F0();
216
				
217
			case LidarHeader.LAS12F1:
218
				return new LASPoint12F1();
219
				
220
			case LidarHeader.LAS12F2:
221
				return new LASPoint12F2();
222
			
223
			case LidarHeader.LAS12F3:
224
				return new LASPoint12F3();
225
				
226
			case LidarHeader.BIN20010712:
227
				
228
				BINHeader headerBin2001 = new BINHeader(file);
229
				headerBin2001.readLidarHeader();
230
				
231
				binColor = false;
232
				binTime = false;
233

  
234
				
235
				if(headerBin2001.getColor()>0)
236
					binColor = true;
237
					
238
				if(headerBin2001.getTime()>0)
239
					binTime = true;
240
				
241
				return new BINPoint2001(binColor, binTime);
242
				
243
			case LidarHeader.BIN20020715:
244
				BINHeader headerBin2002 = new BINHeader(file);
245
				headerBin2002.readLidarHeader();
246
				
247
				binColor = false;
248
				binTime = false;
249

  
250
				
251
				if(headerBin2002.getColor()>0)
252
					binColor = true;
253
					
254
				if(headerBin2002.getTime()>0)
255
					binTime = true;
256
				
257
				return new BINPoint2002(binColor, binTime);
258
		}
259
		
260
		return null;
261
	}
262
	
263
	
264
	public static LidarHeader InizializeLidarHeader(File file) {
265
		int type = testFormat(file);
266
		switch(type) {
267
		
268
			case LidarHeader.LAS10F0:
269
			case LidarHeader.LAS10F1:
270
				LASHeader_V10 header10 = new LASHeader_V10(file);
271
				header10.readLidarHeader();
272
				return header10;
273
				
274
			case LidarHeader.LAS11F0:
275
			case LidarHeader.LAS11F1:
276
				LASHeader_V11 header11 = new LASHeader_V11(file);
277
				header11.readLidarHeader();
278
				return header11;
279
				
280
			case LidarHeader.LAS12F0:
281
			case LidarHeader.LAS12F1:
282
			case LidarHeader.LAS12F2:
283
			case LidarHeader.LAS12F3:
284
				LASHeader_V12 header12 = new LASHeader_V12(file);
285
				header12.readLidarHeader();
286
				return header12;
287
				
288
			case LidarHeader.BIN20010712:
289
				
290
				BINHeader headerBin2001 = new BINHeader(file);
291
				headerBin2001.readLidarHeader();
292
				return headerBin2001;
293
				
294
			case LidarHeader.BIN20020715:
295
				BINHeader headerBin2002 = new BINHeader(file);
296
				headerBin2002.readLidarHeader();	
297
				return headerBin2002;
298
		}
299
		
300
		return null;
301
	}
302
}
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/src/com/dielmo/lidar/UnexpectedPointException.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
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 more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.lidar;
51

  
52
public class UnexpectedPointException extends Exception {
53

  
54
	/**
55
	 * serial ID
56
	 */
57
	private static final long serialVersionUID = 207114730916728752L;
58

  
59
	/**
60
	 * Crea un nuevo unExpected Point.
61
	 *
62
	 * @param s string that identify the cause
63
	 */
64
	public UnexpectedPointException(String string){
65
		super(string);
66
	}
67
	
68
}
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/src/com/dielmo/lidar/LASVariableLengthRecord_1X.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
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 more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.lidar;
51

  
52
import java.io.InputStream;
53
import java.nio.ByteBuffer;
54

  
55

  
56
public abstract class LASVariableLengthRecord_1X {	
57
	
58
	
59
	/**
60
	 * data after the variable length record.
61
	 * 
62
	 * Make sure that maximum size is 65536 bytes
63
	 */
64
	protected byte[] data;
65
	
66
	/**
67
	 * The userID field is ASCII character data that identifies the
68
	 * user which created the variable length record.
69
	 */
70
	protected char[] userID = new char[16];
71
	
72
	/**
73
	 * Record ID is dependent upon the User ID. There can be 0 to 65535
74
	 * record Ids for every UserID. The ASPRS standard will manage its own record Ids (User Ids owned by the
75
	 * specification), otherwise record Ids will be managed by the owner of the given User ID. So each	 
76
	 * User ID is allowed to assign 0 to 65535 record Ids as they wish. Publicizing the meaning of a
77
	 * given record ID will be left to the owner of the given User ID. Unknown User ID/Record ID
78
	 * combinations should be ignored.
79
	 */
80
	protected int recordID; 
81
	
82
	/**
83
	 * The record length is the number of bytes for the record after the
84
	 * end of the standard part of the header.
85
	 */
86
	protected int RecordLengthAfterHeader;
87
	
88
	/**
89
	 * Optional null terminated text description of the data.
90
	 */
91
	protected char[] description = new char[32]; 
92

  
93
	
94
	/**
95
	 * Default constructor, without arguments.
96
	 * Initializes all components to zero.
97
	 */ 
98
	public LASVariableLengthRecord_1X() {
99
		int i;
100
		
101
		for(i=0;i<16;i++)
102
			userID[i] = 0;
103
		
104
		recordID = 0;
105
		RecordLengthAfterHeader=0;
106
		
107
		for(i=0;i<32;i++)
108
			description[i] = 0;
109
	}
110
	
111

  
112
	/**
113
	 * Return the userID field as string that identifies the
114
	 * user which created the variable length record.
115
	 * 
116
	 * @return user ID
117
	 */
118
	public String getUserID() {	
119
		String s;
120
		char[] G = new char[16];
121
		int i;
122
		for(i=0;i<16;i++)
123
		{
124
			if(userID[i]!=0)
125
				G[i] = userID[i];
126
			else
127
				G[i] = ' ';
128
		}
129
				
130
		s = new String(G);
131
		return s;
132
	}
133
	
134
	/**
135
	 * set the userID field as string that identifies the
136
	 * user which created the variable length record.
137
	 * 
138
	 * Only accept 16 characters
139
	 * 
140
	 * @param u new userID
141
	 */
142
	public void setUserID(String u) {	
143

  
144
		int i;
145
		for(i=0;i<16 && i<u.length() ;i++){
146
			
147
			userID[i] = u.charAt(i);
148
		}
149
	
150
		// put to zero.
151
		while(i<16){
152
			
153
			userID[i] = 0;
154
			i++;
155
		}
156
	}
157
	
158
	/**
159
	 * Return record ID.
160
	 * 
161
	 * Record ID is dependent upon the User ID. There can be 0 to 65535 
162
	 * record Ids for every UserID. The ASPRS standard will manage its own
163
	 * record Ids (User Ids owned by the specification), otherwise record
164
	 * Ids will be managed by the owner of the given User ID. So each User
165
	 * ID is allowed to assign 0 to 65535 record Ids as they wish. 
166
	 * Publicizing the meaning of a given record ID will be left to the
167
	 * owner of the given User ID. Unknown User ID/Record ID combinations
168
	 * should be ignored. 
169
	 *  
170
	 * @return record ID
171
	 */
172
	public int getRecordID() {	
173
		return recordID;
174
	}
175
	
176
	/**
177
	 * set record ID.
178
	 * 
179
	 * Record ID is dependent upon the User ID. There can be 0 to 65535 
180
	 * record Ids for every UserID. The ASPRS standard will manage its own
181
	 * record Ids (User Ids owned by the specification), otherwise record
182
	 * Ids will be managed by the owner of the given User ID. So each User
183
	 * ID is allowed to assign 0 to 65535 record Ids as they wish. 
184
	 * Publicizing the meaning of a given record ID will be left to the
185
	 * owner of the given User ID. Unknown User ID/Record ID combinations
186
	 * should be ignored. 
187
	 *  
188
	 * @param r new record ID
189
	 */
190
	public void setRecordID( int r) {	
191

  
192
		try{
193
			if(r>=0 && r<=LidarHeader.UNSIGNED_SHORT_MAX)
194
				recordID=r;
195
			else
196
				throw new OutOfRangeLidarException("Out of range of record ID (Variable Length Record)");
197
			
198
		} catch(OutOfRangeLidarException e) {
199
			
200
			e.printStackTrace();
201
		}
202
		
203
	}
204
	
205
	/**
206
	 * Return record length after header. This is the number of bytes
207
	 * for the record after the end of the standard part of the header.
208
	 *  
209
	 * @return record length after header
210
	 */
211
	public int getRecordLengthAfterHeader() {	
212
		return RecordLengthAfterHeader;
213
	}
214
	
215
	/**
216
	 * set record length after header. This is the number of bytes
217
	 * for the record after the end of the standard part of the header.
218
	 *  
219
	 * @param r new record length after header
220
	 */
221
	public void setRecordLengthAfterHeader(int r) {	
222
		
223
		try{
224
			if(r>=0 && r<=LidarHeader.UNSIGNED_SHORT_MAX)
225
				RecordLengthAfterHeader = r;
226
			else
227
				throw new OutOfRangeLidarException("Out of range of record length after header (Variable Length Record)");
228
			
229
		} catch(OutOfRangeLidarException e) {
230
			
231
			e.printStackTrace();
232
		}
233
	}
234
	
235
	/**
236
	 * Return the text description of the data.
237
	 * 
238
	 * @return description
239
	 */
240
	public String getDescription() {	
241
		String s;
242
		char[] D = new char[32];
243
		int i;
244
		for(i=0;i<32;i++) {
245
			if(description[i]!=0)
246
				D[i] = description[i];
247
			else
248
				D[i] = ' ';
249
		}
250
				
251
		s = new String(D);
252
		return s;
253
	}
254
	
255
	/**
256
	 * set the text description of the data.
257
	 * Only accept 32 characters
258
	 * 
259
	 * @param d new description
260
	 */
261
	public void setDescription(String d) {	
262
		int i;
263
		for(i=0;i<32 && i<d.length();i++) {
264
		
265
			description[i] = d.charAt(i);
266
		}
267
	
268
		// put to zero.
269
		while(i<32){
270
			
271
			description[i] = 0;
272
			i++;
273
		}
274
	}
275

  
276
	/**
277
	 * Read the collection of bytes of variable length record 
278
	 * 
279
	 * @param input input file to read
280
	 * @param VarLengthRecord buffer into which the data is read 
281
	 * @return true if success else return false 
282
	 */
283
	protected abstract boolean readVarLegthRecordData(InputStream input);
284
	
285
	/**
286
	 * Read the Variable length record header of LAS file
287
	 * 
288
	 * @param input input file to read
289
	 * @return true if success else return false 
290
	 */
291
	public abstract boolean readVarLegthRecord(InputStream input);
292
	
293
	/**
294
	 * Write the Variable length record header of LAS file
295
	 * 
296
	 * @param bb byte buffer to write
297
	 * @return true if success else return false 
298
	 */
299
	public abstract boolean writeVarLegthRecord(ByteBuffer bb);
300

  
301
	
302
	/**
303
	 * return data after the variable length record.
304
	 * 
305
	 * maximum size is 65536 bytes
306
	 * 
307
	 * @return data after variable length record.
308
	 */
309
	public byte[] getData() {
310
		return data;
311
	}
312

  
313

  
314
	/**
315
	 * set data after the variable length record.
316
	 * 
317
	 * Make sure that maximum size is 65536 bytes
318
	 * 
319
	 * @return data after variable length record.
320
	 */
321
	public void setData(byte[] data) {
322
		this.data = data;
323
	}
324
}
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/src/com/dielmo/lidar/ByteUtilities.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
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 more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.lidar;
51

  
52
/**
53
 * Static class to work with a given vector of bytes.
54
 *
55
 * @author Oscar Garcia
56
 */
57
public class ByteUtilities {
58

  
59
	// operaciones de vectores de bytes a tipos de java
60
	/**
61
	 * From an array of bytes (byte[]), takes over from the position given as start
62
	 * and gives value to int variable using the following 4 bytes.
63
	 * 
64
	 * @param arr array of bytes
65
	 * @param start initial position
66
	 */
67
	public static int arr2Int (byte[] arr, int start) {
68
		int i = 0;
69
		int length = 4;
70
		int cnt = 0;
71
		byte[] tmp = new byte[length];
72
		for (i = start; i < (start + length); i++) {
73
			tmp[cnt] = arr[i];
74
			//System.out.println(java.lang.Byte.toString(arr[i]) + " " + i);
75
			cnt++;
76
		}
77
		int accum = 0;
78
		i = 0;
79
		for ( int shiftBy = 0; shiftBy < 32; shiftBy += 8 ) {
80
			accum |= ( (int)( tmp[i] & 0xff ) ) << shiftBy;
81
			i++;
82
		}
83
		return accum;
84
	}
85

  
86
	/**
87
	 * From an array of bytes (byte[]), takes over from the position given as start
88
	 * and gives value to double variable using the following 8 bytes.
89
	 * 
90
	 * @param arr array of bytes
91
	 * @param start initial position
92
	 */
93
	public static double arr2Double (byte[] arr, int start) {
94
		int i = 0;
95
		int length = 8;
96
		int cnt = 0;
97
		byte[] tmp = new byte[length];
98
		for (i = start; i < (start + length); i++) {
99
			tmp[cnt] = arr[i];
100
			//System.out.println(java.lang.Byte.toString(arr[i]) + " " + i);
101
			cnt++;
102
		}
103
		long accum = 0;
104
		i = 0;
105
		for ( int shiftBy = 0; shiftBy < 64; shiftBy += 8 ) {
106
			accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
107
			i++;
108
		}
109
		return Double.longBitsToDouble(accum);
110
	}
111

  
112
	/**
113
	 * From an array of bytes (byte[]), takes over from the position given as start
114
	 * and gives value to long variable using the following 4 bytes.
115
	 * 
116
	 * @param arr array of bytes
117
	 * @param start initial position
118
	 */
119
	public static long arr2UnsignedInt (byte[] arr, int start) {
120
		int i = 0;
121
		int length = 4;
122
		int cnt = 0;
123
		byte[] tmp = new byte[length];
124
		for (i = start; i < (start + length); i++) {
125
			tmp[cnt] = arr[i];
126
			//System.out.println(java.lang.Byte.toString(arr[i]) + " " + i);
127
			cnt++;
128
		}
129
		long accum = 0;
130
		i = 0;
131
		for ( int shiftBy = 0; shiftBy < 32; shiftBy += 8 ) {
132
			accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
133
			i++;
134
		}
135
		return accum;
136
	}
137
	
138
	/**
139
	 * From an array of bytes (byte[]), takes over from the position given as start
140
	 * and gives value to long variable using the following 8 bytes.
141
	 * 
142
	 * @param arr array of bytes
143
	 * @param start initial position
144
	 */
145
	public static long arr2Long(byte[] arr, int start) {
146
		int i = 0;
147
		int length = 8;
148
		int cnt = 0;
149
		byte[] tmp = new byte[length];
150
		for (i = start; i < (start + length); i++) {
151
			tmp[cnt] = arr[i];
152
			//System.out.println(java.lang.Byte.toString(arr[i]) + " " + i);
153
			cnt++;
154
		}
155
		long accum = 0;
156
		i = 0;
157
		for ( int shiftBy = 0; shiftBy < 64; shiftBy += 8 ) {
158
			accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
159
			i++;
160
		}
161
		return accum;
162
	}
163
	
164
	/**
165
	 * From an array of bytes (byte[]), takes over from the position given as start
166
	 * and gives value to int variable using the following 2 bytes.
167
	 * 
168
	 * @param arr array of bytes
169
	 * @param start initial position
170
	 */
171
	public static int arr2Unsignedshort (byte[] arr, int start) {
172
		
173
		int i = 0;
174
		int length = 2;
175
		int cnt = 0;
176
		byte[] tmp = new byte[length];
177
		for (i = start; i < (start + length); i++) {
178
			tmp[cnt] = arr[i];
179
			//System.out.println(java.lang.Byte.toString(arr[i]) + " " + i);
180
			cnt++;
181
		}
182
		int accum = 0;
183
		i = 0;
184
		for ( int shiftBy = 0; shiftBy < 16; shiftBy += 8 ) {
185
			accum |= ( (int)( tmp[i] & 0xff ) ) << shiftBy;
186
			i++;
187
		}
188
		return accum;
189
	}	
190

  
191
	/**
192
	 * Write the bytes of "var" into new byte array.
193
	 *
194
	 * @param var the int to encode
195
	 * @param arrayBytes The byte array to store into.
196
	 * @param startIndex index data to begin write.
197
	 */
198
	public static void int2Arr(int var, byte[] arrayBytes, int startIndex) {
199

  
200
		int length = 4;
201
	
202
		if (arrayBytes != null && startIndex+length <= arrayBytes.length) {
203
			for (int j = startIndex; j < startIndex+length; j++) {
204
				arrayBytes[j] = (byte) var; // se copian los 8 primeros bits de la variable
205
				var >>= 8;
206
			}
207
		}
208
	}
209
	
210
	/**
211
	 * Write the bytes of "var" into new byte array.
212
	 *
213
	 * @param var the int that represents a unsigned short of 2 bytes to encode
214
	 * @param arrayBytes The byte array to store into.
215
	 * @param startIndex index data to begin write.
216
	 */
217
	public static void unsignedShort2Arr(int var, byte[] arrayBytes, int startIndex) {
218

  
219
		int length = 2;
220
	
221
		if (arrayBytes != null && startIndex+length <= arrayBytes.length) {
222
			for (int j = startIndex; j < startIndex+length; j++) {
223
				arrayBytes[j] = (byte) var; // se copian los 8 primeros bits de la variable
224
				var >>= 8;
225
			}
226
		}
227
	}
228
	
229
	/**
230
	 * Write the bytes of "var" into new byte array.
231
	 *
232
	 * @param var the long that represents a unsigned int of 4 bytes to encode
233
	 * @param arrayBytes The byte array to store into.
234
	 * @param startIndex index data to begin write.
235
	 */
236
	public static void unsignedInt2Arr(long var, byte[] arrayBytes, int startIndex) {
237

  
238
		int length = 4;
239
	
240
		if (arrayBytes != null && startIndex+length <= arrayBytes.length) {
241
			for (int j = startIndex; j < startIndex+length; j++) {
242
				arrayBytes[j] = (byte) var; // se copian los 8 primeros bits de la variable
243
				var >>= 8;
244
			}
245
		}
246
	}
247
	
248
	/**
249
	 * Write the bytes of "var" into new byte array.
250
	 *
251
	 * @param var the long of 8 bytes to encode
252
	 * return tmp The byte array to store into.
253
	 */
254
	public static void long2Arr(long var, byte[] arrayBytes, int startIndex) {
255
		
256
		int length = 8;
257
		
258
		if (arrayBytes != null && startIndex+length <= arrayBytes.length) {
259
			for (int j = startIndex; j < startIndex+length; j++) {
260
				arrayBytes[j] = (byte) var; // se copian los 8 primeros bits de la variable
261
				var >>= 8;
262
			}
263
		}
264
	}
265
	
266
	/**
267
	 * Write the bytes of "var" into new byte array.
268
	 *
269
	 * @param var the double of 8 bytes to encode
270
	 * return tmp The byte array.
271
	 */
272
	public static void double2Arr(double var, byte[] arrayBytes, int startIndex) {
273
	
274
		long bits = Double.doubleToLongBits(var);
275
		long2Arr(bits, arrayBytes, startIndex);
276
	}
277
}
tags/DielmoOpenLiDAR-0.1.0-1015_5/libDielmoOpenLidar/src/com/dielmo/lidar/LASHeader_1X.java
1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department of the Valencian Government (CIT)
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 more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

  
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

  
50
package com.dielmo.lidar;
51

  
52
import java.io.File;
53

  
54
public abstract class LASHeader_1X implements LidarHeader{
55
	
56
	/**
57
	 * path of LAS file 
58
	 */
59
	protected File m_Fich;
60
	
61
	/**
62
	 * file Signature, must contain LASF
63
	 */
64
	protected char[] fileSignature = new char[4];
65

  
66
	/** 
67
	 * Global Unique IDentifier 1; unsigned int
68
	 */
69
	protected long GUID1 ; 
70
	
71
	/**
72
	 * Global Unique IDentifier 2; unsigned short
73
	 */
74
	protected int GUID2 ;
75
	
76
	/**
77
	 * Global Unique IDentifier 3; unsigned short
78
	 */
79
	protected int GUID3 ; 
80
	
81
	/**
82
	 * Global Unique IDentifier 4
83
	 */
84
	protected char[]GUID4 = new char[8];
85
	
86
	/**
87
	 * version format number mayor
88
	 */
89
	protected char versionMayor; 
90
	
91
	/**
92
	 * version format number minor
93
	 */
94
	protected char versionMinor;
95
	
96
	/**
97
	 * software generated by: Original Data, Merge, Modification, Extraction, Transformation or Other
98
	 */
99
	protected char[] systemIDentifier = new char[32]; 
100

  
101
	/**
102
	 * Who generate software
103
	 */
104
	protected char[] generatingSoftware = new char[32];
105
	
106
	/**
107
	 * LAS 1.0 Julian day
108
	 * LAS 1.1 day of year 1-365
109
	 */
110
	protected int day; 
111
	
112
	/**
113
	 * In LAS 1.0 year that the data was collected.
114
	 * In LAS 1.1 year on which this file was created.
115
	 */
116
	protected int year;
117
	
118
	/**
119
	 * Size, in bytes, of the header file 
120
	 */
121
	protected int hdrSize;
122
	
123
	/**
124
	 * Number of bytes from the beginning of the file
125
	 * to the first point record data (including the two 
126
	 * bytes for data start signature in case of LAS1.0).
127
	 */
128
	protected long offsetData;
129
	
130
	/**
131
	 * number of variable length records
132
	 */
133
	protected long numVarLengthRecord;
134
	
135
	/**
136
	 * point data record format type (0-1)
137
	 */
138
	protected char pointDataFormatID;
139
	
140
	/**
141
	 * size of the point data record
142
	 */
143
	protected int pointDataRecordLength;
144
	
145
	/**
146
	 * total number of points records within the file
147
	 */
148
	protected long numPointsRecord;
149
	
150
	/**
151
	 * array of the total point records per return
152
	 */
153
	protected long[] numPointsByReturn = new long[5];
154
	                                            
155
	/**
156
	 * X Scale factor for scale corresponding X values within the point
157
	 * record. 
158
	 */
159
	protected double xScale;
160
	
161
	/**
162
	 * Y Scale factor for scale corresponding Y values within the point
163
	 * record. 
164
	 */
165
	protected double yScale;
166
	
167
	/**
168
	 * Z Scale factor for scale corresponding Z values within the point
169
	 * record. 
170
	 */
171
	protected double zScale;
172
	
173
	/**
174
	 * X Offset used to set the overall offset for the point records.
175
	 */
176
	protected double xOffset;
177
	
178
	/**
179
	 * Y Offset used to set the overall offset for the point records.
180
	 */
181
	protected double yOffset;
182
	
183
	/**
184
	 * Z Offset used to set the overall offset for the point records.
185
	 */
186
	protected double zOffset;
187
	
188
	/**
189
	 * The actual maximum X of coordinate extents of the file
190
	 */
191
	protected double maxX;
192
	
193
	/**
194
	 * The actual minimum X of coordinate extents of the file
195
	 */
196
	protected double minX;
197
	
198
	/**
199
	 * The actual maximum Y of coordinate extents of the file
200
	 */
201
	protected double maxY;
202
	
203
	/**
204
	 * The actual minimum Y of coordinate extents of the file
205
	 */
206
	protected double minY;
207
	
208
	/**
209
	 * The actual maximum Z of coordinate extents of the file
210
	 */
211
	protected double maxZ;
212
	
213
	/**
214
	 * The actual minimum Z of coordinate extents of the file
215
	 */
216
	protected double minZ;
217
	
218
	/**
219
	 * Default constructor, without arguments.
220
	 * Initializes all components to zero.
221
	 */ 
222
	public LASHeader_1X(File file) {
223
		m_Fich = file;
224
		int i;
225
		
226
		fileSignature[0] = 'L';
227
		fileSignature[1] = 'A';
228
		fileSignature[2] = 'S';
229
		fileSignature[3] = 'F';
230
		
231
		GUID1 = 0;
232
		GUID2 = 0;
233
		GUID3 = 0;
234
		
235
		for(i=0;i<8;i++)
236
			GUID4[i] = 0;
237
		
238
		versionMayor = 0;
239
		versionMinor = 0;
240
		
241
		for(i=0;i<32;i++)
242
			systemIDentifier[i] = 0;
243
		
244
		for(i=0;i<32;i++)
245
			generatingSoftware[i] = 0;
246
		
247
		generatingSoftware[0] = 'D';
248
		generatingSoftware[1] = 'I';
249
		generatingSoftware[2] = 'E';
250
		generatingSoftware[3] = 'L';
251
		generatingSoftware[4] = 'M';
252
		generatingSoftware[5] = '0';
253
		generatingSoftware[6] = ' ';
254
		generatingSoftware[7] = '3';
255
		generatingSoftware[8] = 'D';
256
		generatingSoftware[9] = ' ';
257
		generatingSoftware[10] = 'S';
258
		generatingSoftware[11] = '.';
259
		generatingSoftware[12] = 'L';
260
		generatingSoftware[13] = '.';
261
		
262
		day = 0;
263
		year = 0;
264
		hdrSize=227;
265
		offsetData=0;
266
		numVarLengthRecord=0;
267
		pointDataFormatID=0;
268
		pointDataRecordLength=0;
269
		numPointsRecord=0;
270
		
271
		for(i=0;i<5;i++)
272
			numPointsByReturn[i] = 0;
273
		
274
		xScale=0;
275
		yScale=0;
276
		zScale=0;
277
		xOffset=0;
278
		yOffset=0;
279
		zOffset=0;
280
		maxX=0;
281
		minX=0;
282
		maxY=0;
283
		minY=0;
284
		maxZ=0;
285
		minZ=0;
286
	}
287
	
288
	// GET MEHODS
289
	/**
290
	 * Return file signature. This must be always "LASF"
291
	 * 
292
	 * @return String with file signature
293
	 */
294
	public String getFileSignature() {
295
		
296
		String f = new String(fileSignature);
297
		// comprobamos los datos y si son nulos se ponen a cero 		
298
		return f;
299
	}
300
	
301
	/**
302
	 * Return Global unique identifier 1 (GUID1)
303
	 * 
304
	 * @return GUID1
305
	 */
306
	public long getGUID1() {
307
		return GUID1;
308
	}
309
	
310
	/**
311
	 * Return Global unique identifier 2 (GUID2)
312
	 * 
313
	 * @return GUID2
314
	 */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff