Revision 2018

View differences:

org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.spi/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.gpe.lib.spi</artifactId>
5
	<packaging>jar</packaging>
6
	<name>org.gvsig.gpe.lib.spi</name>
7
	<description>Generic Persistence Engine library SPI</description>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.gpe.lib</artifactId>
11
		<version>2.1.259</version>				
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>org.gvsig.gpe.lib.api</artifactId>	
17
			<version>2.1.259</version>		
18
		</dependency>
19
	</dependencies>
20
</project>
21

  
0 22

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.spi/src/main/java/org/gvsig/gpe/lib/spi/GPEProviderManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* 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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.gpe.lib.spi;
29

  
30
import java.io.File;
31
import java.io.FileNotFoundException;
32
import java.io.IOException;
33
import java.lang.reflect.InvocationTargetException;
34
import java.net.URI;
35
import java.util.ArrayList;
36

  
37
import org.gvsig.gpe.lib.api.exceptions.ParserCreationException;
38
import org.gvsig.gpe.lib.api.exceptions.ParserNotRegisteredException;
39
import org.gvsig.gpe.lib.api.exceptions.WriterHandlerCreationException;
40
import org.gvsig.gpe.lib.api.exceptions.WriterHandlerNotRegisteredException;
41
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandlerImplementor;
42
import org.gvsig.gpe.lib.spi.parser.IGPEParser;
43

  
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
46
 */
47
public interface GPEProviderManager {
48
	/**
49
	 * Adds a new GPE parser
50
	 * @param name
51
	 * Driver name. It must be written like FORMAT VERSION
52
	 * @param description
53
	 * Driver description. Just a descriptive text
54
	 * @param clazz
55
	 * The parser class	
56
	 * @throws ParserNotRegisteredException 
57
	 * @throws GPEParserRegisterException
58
	 */
59
	public void addGpeParser(String name, String description,Class clazz) throws ParserNotRegisteredException; 
60
			
61
	/**
62
	 * Adds a new GPE parser
63
	 * @param clazz
64
	 * The parser class	
65
	 * @throws ParserNotRegisteredException 
66
	 * @throws GPEParserRegisterException
67
	 */
68
	public void addGpeParser(Class clazz) throws ParserNotRegisteredException; 
69
			
70
	/**
71
	 * It loads the parsers of a parsers file. The file is
72
	 * a properties file. Every line has the structure: 
73
	 * Parser=Parser class
74
	 * @param file
75
	 * File that contains the parsers list
76
	 * @throws IOException 
77
	 * @throws FileNotFoundException 
78
	 * @throws ParserNotRegisteredException 
79
	 */
80
	public void addParsersFile(File file) throws FileNotFoundException, IOException;
81
		
82
	/**
83
	 * It loads the writers of a writers file. The file is
84
	 * a properties file. Every line has the structure: 
85
	 * Writer=Parser class
86
	 * @param file
87
	 * File that contains the writers list
88
	 * @throws IOException 
89
	 * @throws FileNotFoundException 
90
	 */
91
	public void addWritersFile(File file) throws FileNotFoundException, IOException;
92
			
93
	/**
94
	 * @return all the registered parsers
95
	 */
96
	public IGPEParser[] getAllParsers();
97
				
98
	/**
99
	 * Adds a new GPEWriterHandlerImplementor
100
	 * @param name
101
	 * Driver name. It must be written like FORMAT VERSION
102
	 * @param description
103
	 * Driver description. Just a descriptive text
104
	 * @param clazz
105
	 * The parser class	
106
	 * @throws WriterHandlerNotRegisteredException 
107
	 * @throws GPEWriterHandlerRegisterException 
108
	 */
109
	public void addGpeWriterHandlerImplementor(String name, String description,Class clazz) throws WriterHandlerNotRegisteredException;
110
	
111
	/**
112
	 * Adds a new GPEWriterHandlerImplementor
113
	 * @param clazz
114
	 * The parser class	
115
	 * @throws WriterHandlerNotRegisteredException 
116
	 * @throws GPEWriterHandlerRegisterException 
117
	 */
118
	public void addGpeWriterHandlerImplementor(Class clazz) throws WriterHandlerNotRegisteredException;
119
	
120
	/**
121
	 * Create a new parser from a name
122
	 * @param name
123
	 * GPEParser name
124
	 * @param contenHandler
125
	 * Application contenHandler usett to throw the parsing events
126
	 * @param errorHandler
127
	 * Application errror handler used to put errors and warnings
128
	 * @throws ParserCreationException 
129
	 * @throws GPEParserCreationException 
130
	 */
131
	public IGPEParser createParser(String name) throws ParserCreationException;
132
		
133
	/**
134
	 * Create a new parser from a name
135
	 * @param name
136
	 * GPEParser name
137
	 * @param contenHandler
138
	 * Application contenHandler usett to throw the parsing events
139
	 * @param errorHandler
140
	 * Application errror handler used to put errors and warnings
141
	 * @throws ParserCreationException 
142
	 * @throws GPEParserCreationException 
143
	 */
144
	public IGPEParser createParserByClass(String prefferredImplClassName) throws ParserCreationException;
145
		
146
	/**
147
	 * Create a new parser from a mime type. Each parser has a method
148
	 * named {@link GPEParser#getFormat()} that returns the mimetype
149
	 * that the parser can read. One parser only supports one mimetype.
150
	 * <p>
151
	 * This method retrieve all the parsers and returns the first
152
	 * parser that is able to read the mimetype. If there are more
153
	 * parsers that can open the file will not be used.
154
	 * </p>
155
	 * @param mimeType
156
	 * The mimetype of the file to open
157
	 * @return
158
	 * A parser that can parse the mimetype.
159
	 * @throws ParserCreationException
160
	 * If it is not possible to create a parser
161
	 * @see 
162
	 * <a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a>
163
	 */
164
	public IGPEParser createParserByMimeType(String mimeType) throws ParserCreationException;
165
		
166
	/**
167
	 * Gets the parser that can open the file (if it exists)
168
	 * @param uri
169
	 * File to open
170
	 * @return
171
	 * Null if the driver doesn't exist
172
	 * @throws GPEParserCreationException 
173
	 * @throws NoSuchMethodException 
174
	 * @throws InvocationTargetException 
175
	 * @throws IllegalAccessException 
176
	 * @throws InstantiationException 
177
	 * @throws SecurityException 
178
	 * @throws IllegalArgumentException 
179
	 */
180
	public IGPEParser createParser(URI uri) throws ParserCreationException;
181
	
182
	/**
183
	 * Gets the parser that can open the file (if it exists)
184
	 * @param file
185
	 * File to open
186
	 * @return
187
	 * Null if the driver doesn't exist
188
	 * @throws GPEParserCreationException 
189
	 * @throws NoSuchMethodException 
190
	 * @throws InvocationTargetException 
191
	 * @throws IllegalAccessException 
192
	 * @throws InstantiationException 
193
	 * @throws SecurityException 
194
	 * @throws IllegalArgumentException 
195
	 */
196
	public IGPEParser createParser(File file) throws ParserCreationException;
197
			
198
	/**
199
	 * Create a new content writer from a name
200
	 * @param name
201
	 * GPEWriterHandler name
202
	 * GPEParser name
203
	 * @param contenHandler
204
	 * Application contenHandler usett to throw the parsing events
205
	 * @param errorHandler
206
	 * Application errror handler used to put errors and warnings
207
	 * @throws GPEWriterHandlerCreationException 	
208
	 */
209
	public IGPEWriterHandlerImplementor createWriterHandlerImplementor(String name) throws WriterHandlerCreationException;
210
	
211
	/**
212
	 * Create a new writer from a class name. This method can be used 
213
	 * if the class name is known but, the common method to get a writer
214
	 * is using the mime type.     * 
215
	 * @param prefferredImplClassName
216
	 * The name of the class that implements {@link GPEWriterHandler}
217
	 * @return
218
	 * A writer for a concrete format.
219
	 * @throws WriterHandlerCreationException
220
	 * If it is not possible to create a writer
221
	 */
222
	public IGPEWriterHandlerImplementor createWriterHandlerImplementorByClass(String prefferredImplClassName) throws WriterHandlerCreationException; 
223
		
224
	/**
225
	 * Create a new writer from a mime type. Each writer has a method
226
	 * named {@link GPEWriterHandler#getFormat()} that returns the mimetype
227
	 * that the writer can write. One writer only supports one mimetype.
228
	 * <p>
229
	 * This method retrieve all the writers and returns the first
230
	 * one that is able to write the mimetype. If there are more
231
	 * writer that can write the format will not be used.
232
	 * </p>
233
	 * @param mimeType
234
	 * The mimetype of the file to write
235
	 * @return
236
	 * A writer that can write the mimetype.
237
	 * @throws WriterHandlerCreationException
238
	 * If it is not possible to create a writer
239
	 * @see 
240
	 * <a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a>
241
	 */
242
	public IGPEWriterHandlerImplementor createWriterHandlerImplementorByMimeType(String mimeType) throws WriterHandlerCreationException;
243
	
244
	/**
245
	 * Gets all the writers that can write the provided format.
246
	 * The elements are of type IGPEWriterHandler
247
	 * 
248
	 * @param format as a short form (without version). Example: "gml", "kml"
249
	 * @return
250
	 */
251
	public ArrayList getWriterHandlerByFormat(String format);
252
		
253
	/**
254
	 * Return true if exists a driver that can open the file
255
	 * @param uri
256
	 * File to open
257
	 * @return
258
	 * true if the driver exists
259
	 */
260
	public boolean accept(URI uri);	
261
}
262

  
0 263

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.spi/src/main/java/org/gvsig/gpe/lib/spi/GPEProviderLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* 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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.gpe.lib.spi;
29

  
30
import org.gvsig.tools.locator.AbstractLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

  
34
/**
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class GPEProviderLocator extends AbstractLocator {
38
	private static final String LOCATOR_NAME = "GPEProviderLocator";
39
	/**
40
	 * GPEManager name used by the locator to access the instance
41
	 */
42
	public static final String GPE_PROVIDER_MANAGER_NAME = "GPEProviderManager";
43
	private static final String GPE_PROVIDER_MANAGER_DESCRIPTION = "GPEProviderManager of gvSIG";
44
	
45
	/**
46
	 * Unique instance.
47
	 */
48
	private static final GPEProviderLocator instance = new GPEProviderLocator();
49
	
50
	/* (non-Javadoc)
51
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
52
	 */
53
	public String getLocatorName() {
54
		return LOCATOR_NAME;
55
	}
56
	
57
	/**
58
	 * Return a reference to {@link GPEProviderManager}.
59
	 *
60
	 * @return a reference to GPEProviderManager
61
	 * @throws LocatorException
62
	 *             if there is no access to the class or the class cannot be
63
	 *             instantiated
64
	 * @see Locator#get(String)
65
	 */
66
	public static GPEProviderManager getGPEProviderManager() throws LocatorException {
67
		return (GPEProviderManager) getInstance().get(GPE_PROVIDER_MANAGER_NAME);
68
	}
69
	
70
	/**
71
	 * Return the singleton instance.
72
	 *
73
	 * @return the singleton instance
74
	 */
75
	public static GPEProviderLocator getInstance() {
76
		return instance;
77
	}
78
	
79
	/**
80
	 * Registers the Class implementing the {@link GPEProviderManager} interface.
81
	 *
82
	 * @param clazz
83
	 *            implementing the GPEProviderManager interface
84
	 */
85
	public static void registerGPEProviderManager(Class clazz) {
86
		getInstance().register(GPE_PROVIDER_MANAGER_NAME, 
87
				GPE_PROVIDER_MANAGER_DESCRIPTION,
88
				clazz);
89
	}	
90
}
91

  
92

  
93

  
0 94

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.spi/src/main/java/org/gvsig/gpe/lib/spi/parser/IGPEParser.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* 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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27

  
28
package org.gvsig.gpe.lib.spi.parser;
29

  
30
import java.io.InputStream;
31
import java.net.URI;
32

  
33
import org.gvsig.gpe.lib.api.parser.IGPEContentHandler;
34
import org.gvsig.gpe.lib.api.parser.IGPEContentHandlerInmGeom;
35
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
36

  
37
/**
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
39
 */
40
public interface IGPEParser {
41

  
42

  
43
	/**
44
	 * Method to parse a file. It cannot to throw
45
	 * any exception and it cannot to return any value.
46
	 * In a future it could be implemented like a independent
47
	 * thread
48
	 * @param contents
49
	 * Application ContentHandler
50
	 * @param errors
51
	 * Application ErrorsHandler
52
	 * @param uri
53
	 * File to open
54
	 * @throws Exception
55
	 */
56
	public void parse(IGPEContentHandlerInmGeom contents, IGPEErrorHandler errors, URI uri);
57

  
58

  
59
	/**
60
	 * Method to parse an InputStream. It cannot to throw
61
	 * any exception and it cannot to return any value.
62
	 * In a future it could be implemented like a independent
63
	 * thread
64
	 * @param contents
65
	 * Application ContentHandler
66
	 * @param errors
67
	 * Application ErrorsHandler
68
	 * @param is
69
	 * The input stream
70
	 * @throws Exception
71
	 */
72
	public void parse(IGPEContentHandlerInmGeom contents, IGPEErrorHandler errors, InputStream is);
73

  
74
	/**
75
	 * Return if the driver can open the file
76
	 * @param uri
77
	 * File to open
78
	 * @return
79
	 * True if the driver is able to open it
80
	 */
81
	public boolean accept(URI uri);
82

  
83
	/**
84
	 * Return the format that the driver
85
	 * is able to read
86
	 * @return
87
	 */
88
	public String getFormat();
89

  
90
	/**
91
	 * @return the contentHandler
92
	 */
93
	public IGPEContentHandlerInmGeom getContentHandler();
94

  
95

  
96
	/**
97
	 * @return the errorHandler
98
	 */
99
	public IGPEErrorHandler getErrorHandler();
100

  
101
	/**
102
	 * @return the file
103
	 */
104
	public URI getMainFile();
105

  
106
	/**
107
	 * @return the description
108
	 */
109
	public String getDescription();
110

  
111
	/**
112
	 * @return the name
113
	 */
114
	public String getName();
115

  
116
	/**
117
	 * @param errorHandler the errorHandler to set
118
	 */
119
	public void setErrorHandler(IGPEErrorHandler errorHandler);
120

  
121
	/**
122
	 * @param contentHandler the contentHandler to set
123
	 */
124
	public void setContentHandler(IGPEContentHandlerInmGeom contentHandler);
125

  
126
	/**
127
	 * gets the default parser projection
128
	 * @return
129
	 */
130
	public String getProjection();
131

  
132
}
133

  
0 134

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/Bbox.java
1
package org.gvsig.gpe.lib.impl.containers;
2

  
3
import java.util.ArrayList;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id: Bbox.java 54 2007-04-14 16:06:35Z jorpiell $
48
 * $Log$
49
 * Revision 1.1  2007/04/14 16:06:35  jorpiell
50
 * Add the container classes
51
 *
52
 *
53
 */
54
/**
55
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
56
 */
57
public class Bbox {
58
	private String id = null;
59
	private ArrayList coordinates = null;
60
	private int dimension = 0;
61
	private String srs;
62
	
63
	public Bbox(int dimension){
64
		this.dimension = dimension;
65
		coordinates = new ArrayList();
66
	}
67
	
68
	public void addCoordinate(double[] coordinate){
69
		coordinates.add(coordinate);
70
	}
71
	
72
	/**
73
	 * @return the dimension
74
	 */
75
	public int getDimension() {
76
		return dimension;
77
	}
78

  
79
	public double getMinX(){
80
		return ((double[])(coordinates.get(0)))[0];
81
	}
82
	
83
	public double getMaxX(){
84
		return ((double[])(coordinates.get(1)))[0];
85
	}
86
	
87
	public double getMinY(){
88
		return ((double[])(coordinates.get(0)))[1];
89
	}
90
	
91
	public double getMaxY(){
92
		return ((double[])(coordinates.get(1)))[1];
93
	}
94
	
95
	public double getMinZ(){
96
		if (dimension < 3){
97
			return 0.0;
98
		}
99
		return ((double[])(coordinates.get(0)))[2];
100
	}
101
	
102
	public double getMaxZ(){
103
		if (dimension < 3){
104
			return 0.0;
105
		}
106
		return ((double[])(coordinates.get(1)))[2];
107
	}
108
	
109
	public double getMinCoordinate(int dimension){
110
		return ((double[])(coordinates.get(0)))[dimension];
111
	}
112
	
113
	public double getMaxCoordinate(int dimension){
114
		return ((double[])(coordinates.get(1)))[dimension];
115
	}
116
	
117
	/**
118
	 * @return the id
119
	 */
120
	public String getId() {
121
		return id;
122
	}
123
	/**
124
	 * @param id the id to set
125
	 */
126
	public void setId(String id) {
127
		this.id = id;
128
	}
129
	/**
130
	 * @return the srs
131
	 */
132
	public String getSrs() {
133
		return srs;
134
	}
135
	/**
136
	 * @param srs the srs to set
137
	 */
138
	public void setSrs(String srs) {
139
		this.srs = srs;
140
	}
141
}
0 142

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/LinearRing.java
1
package org.gvsig.gpe.lib.impl.containers;
2

  
3
import java.util.ArrayList;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id: LinearRing.java 54 2007-04-14 16:06:35Z jorpiell $
48
 * $Log$
49
 * Revision 1.1  2007/04/14 16:06:35  jorpiell
50
 * Add the container classes
51
 *
52
 *
53
 */
54
/**
55
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
56
 */
57
public class LinearRing extends Geometry {
58
	private ArrayList coordinates = null;
59
		
60
	public LinearRing() {
61
		super();
62
		coordinates = new ArrayList();
63
	}
64

  
65
	public void addCoordinate(double[] coordinate){
66
		coordinates.add(coordinate);
67
	}
68
	
69
	public double geCoordinateAt(int index, int dimension){
70
		return ((double[])(coordinates.get(index)))[dimension];
71
	}
72
	
73
	public int getCoordinatesNumber(){
74
		return coordinates.size();
75
	}	
76
}
0 77

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/Feature.java
1
package org.gvsig.gpe.lib.impl.containers;
2

  
3
import java.util.ArrayList;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id: Feature.java 120 2007-05-15 12:10:01Z jorpiell $
48
 * $Log$
49
 * Revision 1.4  2007/05/15 12:09:41  jorpiell
50
 * The bbox is linked to the feature
51
 *
52
 * Revision 1.3  2007/05/02 11:46:07  jorpiell
53
 * Writing tests updated
54
 *
55
 * Revision 1.2  2007/04/19 07:23:20  jorpiell
56
 * Add the add methods to teh contenhandler and change the register mode
57
 *
58
 * Revision 1.1  2007/04/14 16:06:35  jorpiell
59
 * Add the container classes
60
 *
61
 *
62
 */
63
/**
64
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
65
 */
66
public class Feature {
67
	private String name = null;
68
	private String id = null;
69
	private Geometry geometry = null;
70
	private ArrayList elements = new ArrayList();
71
	private Bbox bbox = null;
72
	private ArrayList metaDataList = new ArrayList();
73
	/**
74
	 * @return the geometry
75
	 */
76
	public Geometry getGeometry() {
77
		return geometry;
78
	}
79
	/**
80
	 * @param geometry the geometry to set
81
	 */
82
	public void setGeometry(Geometry geometry) {
83
		this.geometry = geometry;
84
	}
85
	
86
	/**
87
	 * @param geometry the geometry to set
88
	 */
89
	public void setGeometry(Object geometry) {
90
		if (geometry instanceof Geometry){
91
			this.geometry = (Geometry)geometry;
92
		}
93
	}
94
	
95
	/**
96
	 * @return the id
97
	 */
98
	public String getId() {
99
		return id;
100
	}
101
	/**
102
	 * @param id the id to set
103
	 */
104
	public void setId(String id) {
105
		this.id = id;
106
	}
107
	/**
108
	 * @return the name
109
	 */
110
	public String getName() {
111
		return name;
112
	}
113
	/**
114
	 * @param name the name to set
115
	 */
116
	public void setName(String name) {
117
		this.name = name;
118
	}
119
	/**
120
	 * @return the elements
121
	 */
122
	public ArrayList getElements() {
123
		return elements;
124
	}
125
		
126
	/**
127
	 * @return the element at position i
128
	 * @param i
129
	 * Element position
130
	 */
131
	public Element getElementAt(int i) {
132
		return (Element)elements.get(i);
133
	}
134
	
135
	/**
136
	 * Adds a new element
137
	 * @param layer
138
	 */
139
	public void addElement(Element element){
140
		elements.add(element);
141
	}
142
	
143
	/**
144
	 * Adds a new element
145
	 * @param layer
146
	 */
147
	public void addElement(Object element){
148
		if (element instanceof Element){
149
			elements.add(element);
150
		}
151
	}
152
	
153
	/**
154
	 * @return the bbox
155
	 */
156
	public Bbox getBbox() {
157
		return bbox;
158
	}
159

  
160
	/**
161
	 * @param bbox the bbox to set
162
	 */
163
	public void setBbox(Bbox bbox) {
164
		this.bbox = bbox;
165
	}
166
	
167
	/**
168
	 * @param bbox the bbox to set
169
	 */
170
	public void setBbox(Object bbox) {
171
		if (bbox instanceof Bbox){
172
			this.bbox = (Bbox)bbox;
173
		}
174
	}
175
	
176
	public void addMetadata(Object metadata) {
177
		if (metadata instanceof MetaData){
178
			metaDataList.add(metadata);
179
		}
180
	}
181
	
182
	public void addTime(Object time) {
183
		if (time instanceof Time){
184
		}
185
	}
186
}
0 187

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/Geometry.java
1
package org.gvsig.gpe.lib.impl.containers;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
/* CVS MESSAGES:
43
 *
44
 * $Id: Geometry.java 180 2007-11-21 11:19:46Z csanchez $
45
 * $Log$
46
 * Revision 1.3  2007/05/09 10:25:45  jorpiell
47
 * Add the multiGeometries
48
 *
49
 * Revision 1.2  2007/04/19 07:23:20  jorpiell
50
 * Add the add methods to teh contenhandler and change the register mode
51
 *
52
 * Revision 1.1  2007/04/14 16:06:35  jorpiell
53
 * Add the container classes
54
 *
55
 *
56
 */
57
/**
58
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
59
 */
60
public class Geometry {
61
	private String id = null;
62
	private Bbox bbox = null;
63
	private String srs = null;
64
	private int dimension = 0;
65

  
66

  
67
	/**
68
	 * Constructor
69
	 */
70
	public Geometry(String id, String srs, int dimension) {
71
		super();
72
		this.id = id;
73
		this.srs = srs;
74
		this.dimension = dimension;
75
	}
76

  
77
	/**
78
	 * @return the srs
79
	 */
80
	public String getSrs() {
81
		return srs;
82
	}
83

  
84
	/**
85
	 * @param srs the srs to set
86
	 */
87
	public void setSrs(String srs) {
88
		this.srs = srs;
89
	}
90

  
91
	/**
92
	 * @return the bbox
93
	 */
94
	public Bbox getBbox() {
95
		return bbox;
96
	}
97

  
98
	/**
99
	 * @param bbox the bbox to set
100
	 */
101
	public void setBbox(Bbox bbox) {
102
		this.bbox = bbox;
103
	}
104
	
105
	/**
106
	 * @param bbox the bbox to set
107
	 */
108
	public void setBbox(Object bbox) {
109
		if (bbox instanceof Bbox){
110
			this.bbox = (Bbox)bbox;
111
		}
112
	}
113

  
114
	/**
115
	 * @return the id
116
	 */
117
	public String getId() {
118
		return id;
119
	}
120

  
121
	/**
122
	 * @param id the id to set
123
	 */
124
	public void setId(String id) {
125
		this.id = id;
126
	}
127

  
128
	public Geometry() {
129
		super();
130
	}
131

  
132
	/**
133
	 * @return the dimension
134
	 */
135
	public int getDimension() {
136
		return dimension;
137
	}
138

  
139
	/**
140
	 * @param dimension the dimension to set
141
	 */
142
	public void setDimension(int dimension) {
143
		this.dimension = dimension;
144
	}
145
	
146
}
0 147

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/Time.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* 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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 PRODEVELOP S.L.
26
*/
27
 
28
package org.gvsig.gpe.lib.impl.containers;
29

  
30
import java.util.Date;
31

  
32
/**
33
 * @author Carlos S?nchez Peri??n
34
 * 		   PRODEVELOP S.L.
35
 * 08/01/2009
36
 */
37
public class Time {
38
	Date date=null;
39
	Time hour=null;
40
	String UTCoffset=null;
41
	Double duration=null;
42
	String unit=null;
43
	Time next=null, previous=null;
44
	String type=null,description=null,name=null,value=null;
45
	
46
	public Time getNext() {
47
		return next;
48
	}
49
	public void setNext(Time next) {
50
		this.next = next;
51
	}
52
	public Time getPrevious() {
53
		return previous;
54
	}
55
	public void setPrevious(Time previous) {
56
		this.previous = previous;
57
	}
58
	public Date getDate() {
59
		return date;
60
	}
61
	public void setDate(Date date) {
62
		this.date = date;
63
	}
64
	public Time getHour() {
65
		return hour;
66
	}
67
	public void setHour(Time hour) {
68
		this.hour = hour;
69
	}
70
	public String getUTCoffset() {
71
		return UTCoffset;
72
	}
73
	public void setUTCoffset(String coffset) {
74
		UTCoffset = coffset;
75
	}
76
	public Double getDuration() {
77
		return duration;
78
	}
79
	public void setDuration(Double duration) {
80
		this.duration = duration;
81
	}
82
	public String getUnit() {
83
		return unit;
84
	}
85
	public void setUnit(String unit) {
86
		this.unit = unit;
87
	}
88
	
89
	public String getType() {
90
		return type;
91
	}
92
	public void setType(String type) {
93
		this.type = type;
94
	}
95
	
96
	public String getName() {
97
		return name;
98
	}
99
	public void setName(String name) {
100
		this.name = name;
101
	}
102
	
103
	public String getDescription() {
104
		return description;
105
	}
106
	public void setDescription(String description) {
107
		this.description = description;
108
	}
109
	
110
	public String getValue() {
111
		return value;
112
	}
113
	public void setValue(String value) {
114
		this.value = value;
115
	}
116
}
0 117

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/MultiCurve.java
1
package org.gvsig.gpe.lib.impl.containers;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
/* CVS MESSAGES:
43
 *
44
 * $Id$
45
 * $Log$
46
 *
47
 */
48
/**
49
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
50
 */
51
public class MultiCurve extends MultiGeometry{
52
	
53
	/**
54
	 * Adds a new Curve
55
	 * @param curve
56
	 * The curve to add
57
	 */
58
	public void addCurve(Curve curve) {
59
		addGeometry(curve);
60
	}
61
	
62
	/**
63
	 * Gets a Curve at position i
64
	 * @param i
65
	 * position
66
	 */
67
	public Curve getCurvePointAt(int i) {
68
		return (Curve)getGeometryAt(i);
69
	}
70
}
0 71

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.259/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/containers/AttributesIterator.java
1
package org.gvsig.gpe.lib.impl.containers;
2

  
3
import java.io.IOException;
4
import java.util.HashMap;
5
import java.util.Iterator;
6

  
7
import org.gvsig.gpe.lib.api.parser.IAttributesIterator;
8
import org.gvsig.xmlpull.lib.api.stream.IQName;
9
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
10
*
11
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
12
*
13
* This program is free software; you can redistribute it and/or
14
* modify it under the terms of the GNU General Public License
15
* as published by the Free Software Foundation; either version 2
16
* of the License, or (at your option) any later version.
17
*
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with this program; if not, write to the Free Software
25
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
26
*
27
* For more information, contact:
28
*
29
*  Generalitat Valenciana
30
*   Conselleria d'Infraestructures i Transport
31
*   Av. Blasco Ib??ez, 50
32
*   46010 VALENCIA
33
*   SPAIN
34
*
35
*      +34 963862235
36
*   gvsig@gva.es
37
*      www.gvsig.gva.es
38
*
39
*    or
40
*
41
*   IVER T.I. S.A
42
*   Salamanca 50
43
*   46005 Valencia
44
*   Spain
45
*
46
*   +34 963163400
47
*   dac@iver.es
48
*/
49
/* CVS MESSAGES:
50
*
51
* $Id$
52
* $Log$
53
*
54
*/
55
/**
56
* @author Carlos S?nchez Peri??n
57
*/
58
public class AttributesIterator implements IAttributesIterator{
59
	private HashMap attributes;
60
	private Iterator keys = null;
61
	private IQName currentAttibuteName = null;
62
	
63
	public AttributesIterator(IQName name, Object value){
64
		attributes = new HashMap();
65
		attributes.put(name, value);
66
		initialize();
67
	}
68
	
69
	public AttributesIterator(IQName[] names, String[] values){
70
		attributes = new HashMap();
71
		for (int i=0 ; i<names.length ; i++){
72
			attributes.put(names[i], values[i]);
73
		}
74
		initialize();
75
	}	
76
	
77
	/*
78
	 * (non-Javadoc)
79
	 * @see org.gvsig.gpe.parser.IAttributesIterator#hasNext()
80
	 */
81
	public boolean hasNext() throws IOException {
82
		currentAttibuteName = null;
83
		return (keys.hasNext());
84
	}
85

  
86
	/*
87
	 * (non-Javadoc)
88
	 * @see org.gvsig.gpe.parser.IAttributesIterator#getNumAttributes()
89
	 */
90
	public int getNumAttributes() {
91
		return attributes.size();
92
	}
93

  
94
	/* (non-Javadoc)
95
	 * @see org.gvsig.gpe.parser.IAttributesIterator#nextAttribute()
96
	 */
97
	public Object nextAttribute() throws IOException {
98
		setAttributeName();
99
		return attributes.get(currentAttibuteName);	
100
	}
101

  
102
	/* (non-Javadoc)
103
	 * @see org.gvsig.gpe.parser.IAttributesIterator#nextAttributeName()
104
	 */
105
	public IQName nextAttributeName() {
106
		setAttributeName();
107
		return currentAttibuteName;
108
	}
109
	
110
	private void setAttributeName(){
111
		if (currentAttibuteName == null){
112
			currentAttibuteName = (IQName)keys.next();
113
		}
114
	}
115

  
116
	/* (non-Javadoc)
117
	 * @see org.gvsig.gpe.parser.IAttributesIterator#initialize()
118
	 */
119
	public void initialize() {
120
		keys = attributes.keySet().iterator();		
121
	}
122

  
123
}
0 124

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff