Revision 432

View differences:

org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<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">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.gpe.app</artifactId>
6
  <description>Adds support for some vector formats (GML, KML)</description>
7
  <packaging>pom</packaging>
8
  
9
  
10
  <parent>
11
      <groupId>org.gvsig</groupId>
12
      <artifactId>org.gvsig.gpe</artifactId>
13
      <version>2.1.7</version>
14
  </parent>
15
    
16
  <modules>
17
    <module>org.gvsig.gpe.app.mainplugin</module>
18
  </modules>
19
</project>
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/buildNumber.properties
1
#Tue May 19 12:31:23 CEST 2015
2
buildNumber=2108
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
gpe_preferences_window=Gml Persistence Engine
2
gpe_preferences_window_other=Otros
3
gpe_preferences_window_xmlschema=XML Schema
4
gpe_preferences_window_xml=XML
5
gpe_preferences_window_coordinates=Coordenadas
6
gpe_xmlVersion=Versi?n de XML
7
gpe_xmlEncoding=Codificaci?n
8
gpe_defaultBlancSpace=Espacio en blanco para la etiquetas
9
gpe_namespacePrefix=Prefijo del Namespace
10
gpe_namespaceURI=Namespace
11
gpe_schemaName=Nombre del esquema por defecto
12
gpe_coordinates=S?mbolo decimal
13
gpe_coordinatesSeparator=Separador entre coordenadas
14
gpe_tuplesSeparator=Separador entre pares de coordenadas
15
gpe_decimalDigits=N?mero de decimales
16
gpe_exporting=Exportando capa
17
gpe_select_version=Selecciona la versi?n 
18
gpe_select_format=Selecciona el formato
19
gpe_select_writer=Selecciona el writer
20
gpe_select_schema=Selecciona el XML schema
21
gpe_create_default_schema=Crear un esquema por defecto
22
gpe_select_file=Seleciona el fichero
23
gpe_select_writer_window=Exportar a fichero
24
gpe_gvsig_dont_support_multilayer=La actual versi?n de gvSIG no soporta multicapa.\ Todas las geometr\u00edas se cargar\u00e1n en la misma capa. 
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
gpe_preferences_window=Gml Persistence Engine
2
gpe_preferences_window_other=Others
3
gpe_preferences_window_xmlschema=XML Schema
4
gpe_preferences_window_xml=XML
5
gpe_preferences_window_coordinates=Coordinates
6
gpe_xmlVersion=XML version
7
gpe_xmlEncoding=XML Encoding
8
gpe_defaultBlancSpace=Blank space for the label names
9
gpe_namespacePrefix=Namespace prefix
10
gpe_namespaceURI=Namespace
11
gpe_schemaName=Default namespace
12
gpe_coordinates=Decimal symbol
13
gpe_coordinatesSeparator=Separator between coordinates
14
gpe_tuplesSeparator=Separator between a pair of coordinates
15
gpe_decimalDigits=Decimal number
16
gpe_exporting=Exporting a layer
17
gpe_select_version=Select the version 
18
gpe_select_format=Select the format
19
gpe_select_writer=Select a writer
20
gpe_select_schema=Select a schema
21
gpe_create_default_schema=Create a default schema
22
gpe_select_file=Select the file
23
gpe_select_writer_window=Export to file
24
gpe_gvsig_dont_support_multilayer=Current gvSIG version doesnt support multilayer.\All the geometries have been loaded on the same layer.
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3

  
4
	<depends plugin-name="org.gvsig.app.mainplugin" />
5
	<depends plugin-name="org.gvsig.exportto.app.mainplugin" />
6
	
7
	<libraries library-dir="lib"/>
8
	<resourceBundle name="text"/>
9
	<extensions>		
10
		<extension class-name="org.gvsig.gpe.GPELibraryExtension"
11
			description=""
12
			active="true"
13
			priority="1">			
14
		</extension>
15
		<!-- 	
16
		<extension class-name="org.gvsig.gpe.GPEWriterExtension"
17
			description="Support for writing"
18
			active="true">
19
			<menu text="Capa/export_to/GML" action-command="GML"/>
20
			<menu text="Capa/export_to/KML" action-command="KML"/>
21
		</extension>
22
		<extension class-name="org.gvsig.gpe.AboutGPEExtension"
23
                description="Extension to add about panel."
24
                active="true"
25
                priority="1">
26
		</extension>
27
		-->    			
28
	</extensions>
29
</plugin-config>
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/resources/org/gvsig/fmap/dal/store/gpe/GPEMetadata.xml
1
<?xml version="1.0"?>
2
<!--
3
Definitions of metadata fields for a gpe file.  
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    
9
    <class name="GPE" namespace="Metadata">
10
      <extends>
11
       <class namespace="Metadata" name="SpatialProvider"/>
12
      </extends>
13
      <description>Metadata of a GPE store</description>
14
      <fields>
15
      </fields>
16
    </class>
17

  
18
  </classes>
19
</definitions>  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/resources/org/gvsig/fmap/dal/store/gpe/GPEParameters.xml
1
<?xml version= "1.0 "?>
2
<definitions>
3
  <version>1.0.0</version>
4
  <classes>
5
    <class name="GPEStoreParameters">
6
       <extends>
7
       <class namespace="dal" name="ProviderParameters"/>
8
      </extends>
9
      <description>Store the parameters need to open a GPE supported file</description>
10
      <fields>
11
        <field name="File" type="file" mandatory="true" group="Basic">
12
          <description>GPE supported file</description>
13
        </field>
14
        <field name="CRS" type="crs" mandatory="true" group="Basic">
15
          <description>The coordinate reference system used in this GPE supported file</description>
16
        </field>
17
        <field name="useAxisOrderYX" label="Use axis order YX" defaultValue="false" type="Boolean" mandatory="false" group="Basic">
18
          <description>If set use axis order XY</description>
19
        </field>
20
      </fields>
21
    </class>
22
  </classes>
23
</definitions>  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.gpe.DALGPELibrary
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-plugin-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>${project.artifactId}</baseDirectory>
32
  <includeBaseDirectory>true</includeBaseDirectory>
33
  <files>
34
    <file>
35
      <source>target/${project.artifactId}-${project.version}.jar</source>
36
      <outputDirectory>lib</outputDirectory>
37
    </file>
38
    <file>
39
      <source>target/package.info</source>
40
    </file>
41
  </files>
42

  
43
  <fileSets>
44
    <fileSet>
45
      <directory>src/main/resources-plugin</directory>
46
      <outputDirectory>.</outputDirectory>
47
    </fileSet>
48
  </fileSets>
49

  
50
  <dependencySets>
51
    <dependencySet>
52
      <useProjectArtifact>false</useProjectArtifact>
53
      <useTransitiveDependencies>false</useTransitiveDependencies>
54
      <outputDirectory>lib</outputDirectory>
55
      <includes>
56
    	<include>org.gvsig:org.gvsig.gpe.lib*</include>
57
        <include>org.gvsig:org.gvsig.gpe.prov*</include>
58
        <include>org.gvsig:org.gvsig.xmlpull*</include>
59
        <include>org.gvsig:org.gvsig.gpe.exportto*</include>
60
        <include>org.gvsig:org.gvsig.xmlschema*</include>
61
        <include>stax:stax</include>
62
      </includes>
63
    </dependencySet>
64
  </dependencySets>
65

  
66
</assembly>
67

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/gpe/handlers/FmapErrorHandler.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import org.gvsig.gpe.lib.impl.parser.GPEErrorHandler;
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$
48
 * $Log$
49
 *
50
 */
51
/**
52
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
53
 */
54
public class FmapErrorHandler extends GPEErrorHandler{
55

  
56
}
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/gpe/handlers/FmapContentHandler.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.ArrayList;
6
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.List;
9
import java.util.Map;
10

  
11
import org.cresques.cts.IProjection;
12
import org.gvsig.fmap.dal.DataTypes;
13
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
14
import org.gvsig.fmap.dal.feature.EditableFeatureType;
15
import org.gvsig.fmap.dal.feature.Feature;
16
import org.gvsig.fmap.dal.feature.FeatureType;
17
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider;
18
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
19
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
20
import org.gvsig.fmap.dal.store.gpe.GPEStoreProvider;
21
import org.gvsig.fmap.dal.store.gpe.model.GPEElement;
22
import org.gvsig.fmap.dal.store.gpe.model.GPEFeature;
23
import org.gvsig.fmap.geom.Geometry;
24
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
25
import org.gvsig.fmap.geom.Geometry.TYPES;
26
import org.gvsig.fmap.geom.GeometryLocator;
27
import org.gvsig.fmap.geom.GeometryManager;
28
import org.gvsig.fmap.geom.aggregate.MultiCurve;
29
import org.gvsig.fmap.geom.aggregate.MultiPoint;
30
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
31
import org.gvsig.fmap.geom.aggregate.MultiSurface;
32
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
33
import org.gvsig.fmap.geom.exception.CreateGeometryException;
34
import org.gvsig.fmap.geom.primitive.Curve;
35
import org.gvsig.fmap.geom.primitive.Envelope;
36
import org.gvsig.fmap.geom.primitive.GeneralPathX;
37
import org.gvsig.fmap.geom.primitive.Point;
38
import org.gvsig.fmap.geom.primitive.Primitive;
39
import org.gvsig.fmap.geom.primitive.Surface;
40
import org.gvsig.gpe.lib.api.parser.IAttributesIterator;
41
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
42
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
43
import org.gvsig.gpe.lib.impl.parser.GPEContentHandler;
44
import org.jfree.util.Log;
45
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
47
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
48
 *
49
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
50
 *
51
 * This program is free software; you can redistribute it and/or
52
 * modify it under the terms of the GNU General Public License
53
 * as published by the Free Software Foundation; either version 2
54
 * of the License, or (at your option) any later version.
55
 *
56
 * This program is distributed in the hope that it will be useful,
57
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
58
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
59
 * GNU General Public License for more details.
60
 *
61
 * You should have received a copy of the GNU General Public License
62
 * along with this program; if not, write to the Free Software
63
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
64
 */
65

  
66
public class FmapContentHandler extends GPEContentHandler {
67
    private static final Logger LOG = LoggerFactory.getLogger(FmapContentHandler.class);
68

  
69
    private HashMap featureSet = null;
70
    private EditableFeatureType featureType = null;
71
    private FeatureStoreProviderServices store = null;
72
    private GPEStoreProvider storeProvider = null;
73
    private GeometryManager geomManager = GeometryLocator.getGeometryManager();
74
    private int featureId = 0;
75
    private Envelope envelope = null;
76
    private File file = null;
77
    private IProjection srs = null;
78
    private int geometryType = 0;
79
    private boolean useAxisOrderYX = false;
80

  
81
    public FmapContentHandler(IGPEErrorHandler errorHandler, FeatureStoreProviderServices store,
82
        GPEStoreProvider storeProvider, File file, IProjection srs, int geometryType) {
83
        super();
84
        setErrorHandler(errorHandler);
85
        this.store = store;
86
        this.storeProvider = storeProvider;
87
        this.file = file;
88
        this.srs = srs;
89
        this.geometryType = geometryType;
90
    }    
91
    
92
    public FmapContentHandler(IGPEErrorHandler errorHandler, FeatureStoreProviderServices store,
93
        GPEStoreProvider storeProvider, File file, IProjection srs, int geometryType,
94
        boolean useAxisOrderYX) {
95
        this(errorHandler, store, storeProvider, file, srs, geometryType);
96
        this.useAxisOrderYX = useAxisOrderYX;
97
    }
98

  
99
    public int getFeaturesCount(){
100
        return featureSet.size();
101
    }
102

  
103
    public Feature getFeatureAt(int index){
104
        return (Feature)featureSet.get(new Integer(index));
105
    }
106

  
107
    public EditableFeatureType getFeatureType(){
108
        return featureType;
109
    }
110

  
111

  
112
    /**
113
     * @return the featureSet
114
     */
115
    public HashMap getFeatureSet() {
116
        return featureSet;
117
    }
118

  
119
    /*
120
     * (non-Javadoc)
121
     * @see org.gvsig.gpe.parser.GPEContentHandler#startLayer(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object, java.lang.Object)
122
     */
123
    public Object startLayer(String id, String namespace, String name,
124
        String description, String srs, IAttributesIterator iterator, Object parentLayer, Object box) {
125
        if (featureSet == null){
126
            featureSet = new HashMap();
127
        }
128
        if (envelope == null){
129
            try {
130
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
131
            } catch (CreateEnvelopeException e) {
132
                Log.error("Error creating the envelope", e);
133
            }
134
        }
135
        return featureSet;
136
    }
137

  
138
    /*
139
     * (non-Javadoc)
140
     * @see org.gvsig.gpe.IGPEContentHandler#endLayer(java.lang.Object)
141
     */
142
    public void endLayer(Object layer) {
143
        if (featureType == null){
144
            createFeatureType(null);
145
        }
146
        storeProvider.setEnvelope(envelope);
147
    }
148

  
149
    /*
150
     * (non-Javadoc)
151
     * @see org.gvsig.gpe.parser.GPEContentHandler#startPoint(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
152
     */
153
    public Object startPoint(String id, ICoordinateIterator coords, String srs) {
154
        return createPoint(coords);
155
    }
156

  
157
    private Point createPoint(ICoordinateIterator coords){
158
        double[] buffer = new double[coords.getDimension()];
159
        try {
160
            coords.hasNext();
161
            coords.next(buffer);
162
            Point point = null;
163
            if (buffer.length == 2){
164
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
165
                if( useAxisOrderYX ) {
166
                    point.setX(buffer[1]);
167
                    point.setY(buffer[0]);
168
                } else {
169
                    point.setX(buffer[0]);
170
                    point.setY(buffer[1]);
171
                }
172
            }else if (buffer.length == 3){
173
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
174
                if( useAxisOrderYX ) {
175
                    point.setX(buffer[1]);
176
                    point.setY(buffer[0]);
177
                } else {
178
                    point.setX(buffer[0]);
179
                    point.setY(buffer[1]);
180
                }
181
                point.setCoordinateAt(2, buffer[2]);
182
            }
183
            return point;
184
        } catch (IOException e) {
185
            getErrorHandler().addError(e);
186
        } catch (CreateGeometryException e) {
187
            getErrorHandler().addError(e);
188
        }
189
        return null;
190
    }
191

  
192
    private Point createPoint(double[] buffer){
193
        try {
194
            Point point = null;
195
            if (buffer.length == 2){
196
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
197
                if( useAxisOrderYX ) {
198
                    point.setX(buffer[1]);
199
                    point.setY(buffer[0]);
200
                } else {
201
                    point.setX(buffer[0]);
202
                    point.setY(buffer[1]);
203
                }
204
            }else if (buffer.length == 3){
205
                point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
206
                if( useAxisOrderYX ) {
207
                    point.setX(buffer[1]);
208
                    point.setY(buffer[0]);
209
                } else {
210
                    point.setX(buffer[0]);
211
                    point.setY(buffer[1]);
212
                }
213
                point.setCoordinateAt(2, buffer[2]);
214
            }
215
            return point;
216
        }catch (CreateGeometryException e) {
217
            getErrorHandler().addError(e);
218
        }
219
        return null;
220
    }
221

  
222

  
223
    /* (non-Javadoc)
224
     * @see org.gvsig.gpe.parser.GPEContentHandler#startLineString(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
225
     */
226
    public Object startLineString(String id, ICoordinateIterator coords,
227
        String srs) {
228
        return createCurve(coords);
229
    }
230

  
231
    private Curve createCurve(ICoordinateIterator coords){
232
        GeneralPathX gp = createGeneralPathX(coords);
233
        try {
234
            Curve curve = null;
235
            if (coords == null || coords.getDimension() == 2){
236
                curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
237
            }else if (coords.getDimension() == 3){
238
                curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM3D);
239
            }
240
            curve.setGeneralPath(gp);
241
            return curve;
242
        } catch (CreateGeometryException e) {
243
            getErrorHandler().addError(e);
244
        }
245
        return null;
246
    }
247

  
248
    private GeneralPathX createGeneralPathX(ICoordinateIterator coords){
249
        GeneralPathX gp = new GeneralPathX();
250
        if (coords == null){
251
            return gp;
252
        }
253
        double[] buffer = new double[coords.getDimension()];
254
        try {
255
            if (coords.hasNext()){
256
                coords.next(buffer);
257
                if( this.useAxisOrderYX ) {
258
                    gp.moveTo(buffer[1], buffer[0]);
259
                } else {
260
                    gp.moveTo(buffer[0], buffer[1]);
261
                }
262
            }
263
            while(coords.hasNext()){
264
                coords.next(buffer);
265
                if( this.useAxisOrderYX ) {
266
                    gp.lineTo(buffer[1], buffer[0]);
267
                } else {
268
                    gp.lineTo(buffer[0], buffer[1]);
269
                }
270
            }
271
        } catch (IOException e) {
272
            getErrorHandler().addError(e);
273
        }
274
        return gp;
275
    }
276

  
277
    /* (non-Javadoc)
278
     * @see org.gvsig.gpe.parser.GPEContentHandler#startPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
279
     */
280

  
281
    public Object startPolygon(String id, ICoordinateIterator coords, String srs) {
282
        return createSurface(coords);
283
    }
284

  
285
    private Surface createSurface(ICoordinateIterator coords){
286
        GeneralPathX gp = createGeneralPathX(coords);
287
        try {
288
            Surface surface = null;
289
            if (coords.getDimension() == 2){
290
                surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
291
            }else if (coords.getDimension() == 3){
292
                surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM3D);
293
            }
294
            surface.setGeneralPath(gp);
295
            return surface;
296
        } catch (CreateGeometryException e) {
297
            getErrorHandler().addError(e);
298
        }
299
        return null;
300
    }
301

  
302

  
303
    /* (non-Javadoc)
304
     * @see org.gvsig.gpe.parser.GPEContentHandler#startInnerPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
305
     */
306
    public Object startInnerPolygon(String id, ICoordinateIterator coords,
307
        String srs) {
308
        return createSurface(coords);
309
    }
310

  
311
    /*
312
     * (non-Javadoc)
313
     * @see org.gvsig.gpe.IGPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object)
314
     */
315
    public void addGeometryToFeature(Object geometry, Object feature) {
316
        
317
        /*
318
         * Two geometries (possibly of different type) in the same feature
319
         * Instead of overwriting we will preserve the first that arrives.
320
         * Alternative: aggregate, but then gvSIG would have issues to
321
         * draw? or export? 
322
         */
323
        GPEFeature gpe_feat = (GPEFeature) feature;
324
        Geometry geom = gpe_feat.getGeometry();
325
        if (geom == null ||
326
            geom.getGeometryType().getType() == Geometry.TYPES.NULL) {
327
            
328
            gpe_feat.setGeometry((Geometry)geometry);
329
        }
330
    }
331

  
332
    /*
333
     * (non-Javadoc)
334
     * @see org.gvsig.gpe.IGPEContentHandler#addBboxToLayer(java.lang.Object, java.lang.Object)
335
     */
336
    public void addBboxToLayer(Object bbox, Object layer) {
337
        //		if (layer != null){
338
        //		GPEBBox gpeBBox = (GPEBBox)bbox;
339
        //		if (gpeBBox.getSrs() != null){
340
        //		IProjection projection = null;
341
        //		try{
342
        //		CRSFactory.getCRS(gpeBBox.getSrs());
343
        //		}catch(Exception e){
344
        //		//If the CRS factory has an error.
345
        //		}
346
        //		if ((projection != null) && (!(projection.equals(((FLayer)layer).getProjection())))){
347
        //		//TODO reproyectar la bbox y asignarsela a la capa
348
        //		}
349
        //		}
350
        //		((IGPEDriver)layer).setExtent(gpeBBox.getBbox2D());
351
        //		}
352
    }
353

  
354
    /*
355
     * (non-Javadoc)
356
     * @see org.gvsig.gpe.IGPEContentHandler#addElementToFeature(java.lang.Object, java.lang.Object)
357
     */
358
    public void addElementToFeature(Object element, Object feature) {
359
        GPEElement gpeElement = (GPEElement)element;
360
        ((GPEFeature)feature).addElement(gpeElement);
361
    }
362

  
363
    /*
364
     * (non-Javadoc)
365
     * @see org.gvsig.gpe.IGPEContentHandler#addFeatureToLayer(java.lang.Object, java.lang.Object)
366
     */
367
    public void addFeatureToLayer(Object feature, Object layer) {
368
        GPEFeature gpefeature = (GPEFeature)feature;
369
        Envelope currentEnvelope = gpefeature.getEnvelope();
370
        if (featureType == null){
371
            createFeatureType(gpefeature);
372

  
373
            //Initialize the envelope
374
            try {
375
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
376
            } catch (CreateEnvelopeException e) {
377
                getErrorHandler().addError(e);
378
            }
379
            //Calculates the envelope
380
            envelope = currentEnvelope;
381
        }else{
382
            //Calculates the envelope
383
            if (currentEnvelope != null){
384
                envelope.add(currentEnvelope);
385
            }
386
        }
387
        //If it is null is a multilayer: not supported yet
388
        if (layer != null){
389
            FeatureProvider data = new DefaultFeatureProvider(featureType.getNotEditableCopy(), storeProvider.createNewOID());
390
            Map elements = gpefeature.getelements();
391
            Iterator keys = elements.keySet().iterator();
392
            String gid = gpefeature.getId();              
393
            data.setOID(gid);              
394
            while (keys.hasNext()){
395
                String elementName = (String)keys.next();
396
                if (featureType.getIndex(elementName) != -1) {
397
                    /*
398
                     * If attribute exists, set its value
399
                     * (if a field description was not properly parsed in the
400
                     * feature type description (previous http request) then
401
                     * perhaps it's not available in featureType) 
402
                     */
403
                    data.set(elementName, ((GPEElement)elements.get(elementName)).getValue());
404
                }
405
            }
406
            data.setDefaultGeometry(gpefeature.getGeometry());
407
            data.set(featureType.getDefaultGeometryAttributeIndex(), gpefeature.getGeometry());
408
            ((HashMap)layer).put(gid, data);
409
        }
410
    }
411

  
412
    private void createFeatureType(GPEFeature gpefeature){
413
        featureType = store.createFeatureType();
414
        
415
        //Adding the Geometry field
416
        EditableFeatureAttributeDescriptor attributeDescriptor = featureType.add("the_geom", DataTypes.GEOMETRY).setGeometryType(geometryType);
417
        attributeDescriptor.setGeometrySubType(SUBTYPES.GEOM2D);
418
        attributeDescriptor.setSRS(srs);
419
        featureType.setDefaultGeometryAttributeName("the_geom");
420
        
421
        //Adding the ID
422
        EditableFeatureAttributeDescriptor ed = featureType.add("gid", DataTypes.LONG);
423
        ed.setSize(10);
424

  
425
        featureType.setHasOID(true);
426

  
427
        if (gpefeature != null){
428
            Map elements = gpefeature.getelements();
429
            Iterator keys = elements.keySet().iterator();
430
            while (keys.hasNext()){
431
                String elementName = (String)keys.next();
432
                if (!elementName.equals("the_geom") && !elementName.equals("gid")){
433
                    ed = featureType.add(elementName, DataTypes.STRING);
434
                    ed.setSize(80);
435
                }
436
            }
437
        }
438

  
439
        FeatureType defaultType = featureType.getNotEditableCopy();
440
        List types = new ArrayList(1);
441
        types.add(defaultType);
442
        this.store.setFeatureTypes(types, defaultType);
443
    }
444

  
445
    /*
446
     * (non-Javadoc)
447
     * @see org.gvsig.gpe.IGPEContentHandler#addInnerPolygonToPolygon(java.lang.Object, java.lang.Object)
448
     */
449
    public void addInnerPolygonToPolygon(Object innerPolygon, Object Polygon) {
450
        //((Geometry)Polygon).addGeometry((GPEGeometry)innerPolygon);
451
    }
452

  
453
    /*
454
     * (non-Javadoc)
455
     * @see org.gvsig.gpe.IGPEContentHandler#addNameToFeature(java.lang.String, java.lang.Object)
456
     */
457
    public void addNameToFeature(String name, Object feature) {
458

  
459
    }
460

  
461
    /*
462
     * (non-Javadoc)
463
     * @see org.gvsig.gpe.IGPEContentHandler#addParentElementToElement(java.lang.Object, java.lang.Object)
464
     */
465
    public void addParentElementToElement(Object parent, Object element) {
466

  
467
    }
468

  
469
    /*
470
     * (non-Javadoc)
471
     * @see org.gvsig.gpe.IGPEContentHandler#addSrsToLayer(java.lang.String, java.lang.Object)
472
     */
473
    public void addSrsToLayer(String srs, Object Layer) {
474
        //		this.srs = srs;
475
    }
476

  
477

  
478
    /* (non-Javadoc)
479
     * @see org.gvsig.gpe.parser.GPEContentHandler#startBbox(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
480
     */
481
    public Object startBbox(String id, ICoordinateIterator coords, String srs) {
482
        Envelope envelope = null;
483
        try {
484
            if (coords.getDimension() == 2){
485
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
486
            }else if (coords.getDimension() == 3){
487
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM3D);
488
            }
489
            double[] buffer = new double[coords.getDimension()];
490

  
491
            if (coords.hasNext()){
492
                coords.next(buffer);
493
                envelope.setLowerCorner(createPoint(buffer));
494
            }
495
            if (coords.hasNext()){
496
                coords.next(buffer);
497
                envelope.setUpperCorner(createPoint(buffer));
498
            }
499
        } catch (IOException e) {
500
            getErrorHandler().addError(e);
501
        } catch (CreateEnvelopeException e) {
502
            getErrorHandler().addError(e);
503
        }
504
        return envelope;
505
    }
506

  
507
    /*
508
     * (non-Javadoc)
509
     * @see org.gvsig.gpe.parser.GPEContentHandler#startElement(java.lang.String, java.lang.String, java.lang.Object, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object)
510
     */
511
    public Object startElement(String namespace, String name, Object value,
512
        IAttributesIterator attributesIterator,	Object parentElement) {
513
        return new GPEElement(name, value, (GPEElement)parentElement);
514
    }
515

  
516
    /*
517
     * (non-Javadoc)
518
     * @see org.gvsig.gpe.parser.GPEContentHandler#startFeature(java.lang.String, java.lang.String, java.lang.String, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object)
519
     */
520
    public Object startFeature(String id, String namespace, String name,
521
        IAttributesIterator attributes, Object layer){
522
        String sId;
523
        if (id == null){
524
            sId = new String(new Long(featureId).toString());			
525
        }else{
526
            sId = id;
527
        }
528
        featureId++;
529
        //Check the xml schema...
530
        //		for (int i=0 ; i<schemas.size() ; i++){
531
        //			IXSSchema schema = schemas.get(i);
532
        //			IXSElementDeclaration element = schema.getElementDeclarationByName(namespace, name);
533
        //			if (element != null){
534
        //				featureType = store.createFeatureType();
535
        //				IXSTypeDefinition type = element.getTypeDefinition();
536
        //				if (type instanceof IXSComplexTypeDefinition){
537
        //					IXSComplexTypeDefinition complexType = (IXSComplexTypeDefinition)type;
538
        //					complexType.getContentType().
539
        //				}
540
        //
541
        //				featureType.add("the_geom", DataTypes.GEOMETRY).setGeometryType(TYPES.GEOMETRY);
542
        //				featureType.setDefaultGeometryAttributeName("the_geom");
543
        //				featureType.setHasOID(true);
544
        //				while (keys.hasNext()){
545
        //					String elementName = (String)keys.next();
546
        //					featureType.add(elementName, DataTypes.STRING);
547
        //				}
548
        //				FeatureType defaultType = featureType.getNotEditableCopy();
549
        //				List types = new ArrayList(1);
550
        //				types.add(defaultType);
551
        //				this.store.setFeatureTypes(types, defaultType);
552
        //
553
        //				//Initialize the envelope
554
        //				try {
555
        //					envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
556
        //				} catch (CreateEnvelopeException e) {
557
        //					getErrorHandler().addError(e);
558
        //				}
559
        //			}
560
        //		}
561
        return new GPEFeature(sId,
562
            name, name);
563
    }
564

  
565
    /* (non-Javadoc)
566
     * @see org.gvsig.gpe.parser.GPEContentHandler#startLinearRing(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
567
     */
568
    public Object startLinearRing(String id, ICoordinateIterator coords,
569
        String srs) {
570
        return createSurface(coords);
571
    }
572

  
573
    /*
574
     * (non-Javadoc)
575
     * @see org.gvsig.gpe.IGPEContentHandler#startMultiPoint(java.lang.String, java.lang.String)
576
     */
577
    public Object startMultiPoint(String id, String srs) {
578
        try {
579
            return geomManager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
580
        } catch (CreateGeometryException e) {
581
            getErrorHandler().addError(e);
582
        }
583
        return null;
584
    }
585

  
586
    /*
587
     * (non-Javadoc)
588
     * @see org.gvsig.gpe.IGPEContentHandler#addPointToMultiPoint(java.lang.Object, java.lang.Object)
589
     */
590
    public void addPointToMultiPoint(Object point, Object multiPoint) {
591
        ((MultiPoint)multiPoint).addPoint((Point)point);
592
    }
593

  
594
    /*
595
     * (non-Javadoc)
596
     * @see org.gvsig.gpe.IGPEContentHandler#startMultiLineString(java.lang.String, java.lang.String)
597
     */
598
    public Object startMultiLineString(String id, String srs) {
599
        super.startMultiLineString(id, srs);
600
        try {
601
            return geomManager.create(TYPES.MULTICURVE, SUBTYPES.GEOM2D);
602
        } catch (CreateGeometryException e) {
603
            getErrorHandler().addError(e);
604
        }
605
        return null;
606
    }
607

  
608
    /*
609
     * (non-Javadoc)
610
     * @see org.gvsig.gpe.IGPEContentHandler#addLineStringToMultiLineString(java.lang.Object, java.lang.Object)
611
     */
612
    public void addLineStringToMultiLineString(Object lineString, Object multiLineString) {
613
        ((MultiCurve)multiLineString).addCurve((Curve)lineString);
614
    }
615

  
616
    /*
617
     * (non-Javadoc)
618
     * @see org.gvsig.gpe.IGPEContentHandler#startMultiPolygon(java.lang.String, java.lang.String)
619
     */
620
    public Object startMultiPolygon(String id, String srs) {
621
        super.startMultiPolygon(id, srs);
622
        try {
623
            return geomManager.create(TYPES.MULTISURFACE, SUBTYPES.GEOM2D);
624
        } catch (CreateGeometryException e) {
625
            getErrorHandler().addError(e);
626
        }
627
        return null;
628
    }
629

  
630
    /*
631
     * (non-Javadoc)
632
     * @see org.gvsig.gpe.IGPEContentHandler#addPolygonToMultiPolygon(java.lang.Object, java.lang.Object)
633
     */
634
    public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) {
635
        ((MultiSurface)multiPolygon).addSurface((Surface)polygon);
636
    }
637

  
638
    /* (non-Javadoc)
639
     * @see org.gvsig.gpe.GPEContentHandler#addCurveToMultiCurve(java.lang.Object, java.lang.Object)
640
     */
641
    public void addCurveToMultiCurve(Object curve, Object multiCurve) {
642
        ((MultiCurve)multiCurve).addCurve((Curve)curve);
643
    }
644

  
645
    /* (non-Javadoc)
646
     * @see org.gvsig.gpe.GPEContentHandler#addSegmentToCurve(java.lang.Object, java.lang.Object)
647
     */
648
    public void addSegmentToCurve(Object segment, Object curve) {
649
        if (segment instanceof Point) {
650
            ((Curve)curve).addVertex((Point) segment);
651
        } else {
652
            if (segment instanceof Curve) {
653
                Curve seg_cur = (Curve) segment;
654
                int n = seg_cur.getNumVertices();
655
                for (int i=0; i<n; i++) {
656
                    ((Curve)curve).addVertex(seg_cur.getVertex(i));
657
                }
658
                
659
            } else {
660
                LOG.info("Discarded unexpected geometry class: "
661
                    + (segment == null ? "NULL" : segment.getClass().getName()));
662
            }
663
        }
664
        
665
    }
666

  
667
    /* (non-Javadoc)
668
     * @see org.gvsig.gpe.parser.GPEContentHandler#startCurve(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
669
     */
670
    public Object startCurve(String id, ICoordinateIterator coords, String srs) {
671
        return createCurve(coords);
672
    }
673

  
674
    /* (non-Javadoc)
675
     * @see org.gvsig.gpe.GPEContentHandler#startCurve(java.lang.String, java.lang.String)
676
     */
677
    public Object startCurve(String id, String srs) {
678
        return createCurve(null);
679
    }
680

  
681
    /* (non-Javadoc)
682
     * @see org.gvsig.gpe.GPEContentHandler#startMultiCurve(java.lang.String, java.lang.String)
683
     */
684
    public Object startMultiCurve(String id, String srs) {
685
        try {
686
            return geomManager.create(TYPES.MULTICURVE, SUBTYPES.GEOM2D);
687
        } catch (CreateGeometryException e) {
688
            getErrorHandler().addError(e);
689
        }
690
        return null;
691
    }
692

  
693
    /* (non-Javadoc)
694
     * @see org.gvsig.gpe.GPEContentHandler#addGeometryToMultiGeometry(java.lang.Object, java.lang.Object)
695
     */
696
    public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) {
697
        ((MultiPrimitive)multiGeometry).addPrimitive((Primitive)geometry);
698
    }
699

  
700
    /* (non-Javadoc)
701
     * @see org.gvsig.gpe.GPEContentHandler#startMultiGeometry(java.lang.String, java.lang.String)
702
     */
703
    public Object startMultiGeometry(String id, String srs) {
704
        try {
705
            return geomManager.create(TYPES.AGGREGATE, SUBTYPES.GEOM2D);
706
        } catch (CreateGeometryException e) {
707
            getErrorHandler().addError(e);
708
        }
709
        return null;
710
    }
711

  
712
    /**
713
     * @return a new OID
714
     */
715
    public Object createNewOID() {
716
        featureId++;
717
        return String.valueOf(featureId);
718
    }	
719

  
720
    /**
721
     * @param envelope the envelope to set
722
     */
723
    public void setEnvelope(Envelope envelope) {
724
        this.envelope = envelope;
725
    }
726

  
727
    /**
728
     * @param featureType the featureType to set
729
     */
730
    public void setFeatureType(EditableFeatureType featureType) {
731
        this.featureType = featureType;
732
    }
733
}
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/gpe/handlers/FmapContentHandlerCreationException.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import java.util.HashMap;
4
import java.util.Map;
5

  
6
import org.gvsig.tools.exception.BaseException;
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id$
51
 * $Log$
52
 *
53
 */
54
/**
55
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
56
 */
57
public class FmapContentHandlerCreationException extends BaseException{
58
	private static final long serialVersionUID = -6021604626521668293L;
59
	
60
	public FmapContentHandlerCreationException(){
61
		initialize();
62
	}
63
	
64
	public FmapContentHandlerCreationException(Throwable e){
65
		initialize();
66
		initCause(e);
67
	}
68
	
69
	protected Map values() {
70
		return new HashMap();
71
	}
72
	
73
	/**
74
	 * Initialize the properties
75
	 */
76
	private void initialize() {
77
		messageKey = "gpe_lgvsig_contentHandler_error";
78
		formatString = "Error creating the contentHandler for" +
79
				"Fmap";
80
		code = serialVersionUID;
81
	}
82

  
83
}
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/gpe/model/GPEElement.java
1
package org.gvsig.fmap.dal.store.gpe.model;
2

  
3
import java.util.HashMap;
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$
48
 * $Log$
49
 *
50
 */
51
/**
52
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
53
 */
54
public class GPEElement {
55
	private String name = null;
56
	private Object value = null;
57
	private HashMap subElements = null;
58
	
59
	public GPEElement(String name, Object value) {
60
		super();
61
		this.name = name;
62
		this.value = value;
63
		subElements = new HashMap();
64
	}
65
	
66
	public GPEElement(String name, Object value, GPEElement parentElement) {
67
		this(name,value);
68
		//If it is a complex value
69
		if (parentElement != null){
70
			parentElement.addChildElement(this);			
71
		}
72
	}	
73
	
74
	/**
75
	 * It adds a new child element
76
	 * @param children
77
	 * The element to add
78
	 */
79
	public void addChildElement(GPEElement children){
80
		subElements.put(children.getName(), children);
81
	}
82
	
83
	/**
84
	 * @return the name
85
	 */
86
	public String getName() {
87
		return name;
88
	}
89
	
90
	/**
91
	 * @return the value
92
	 */
93
	public Object getValue() {
94
		if (subElements.size() > 0){
95
//			ComplexValue cValue = ValueFactory.createComplexValue(name);
96
//			Iterator it = subElements.keySet().iterator();
97
//			while(it.hasNext()){
98
//				GPEElement element = (GPEElement)subElements.get(it.next());
99
//				cValue.put(element.getName(), element.getValue());
100
//			}
101
//			return cValue;
102
		}
103
		return value;		
104
	}
105
}
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/gpe/model/GPEFeature.java
1
package org.gvsig.fmap.dal.store.gpe.model;
2

  
3
import java.util.LinkedHashMap;
4

  
5
import org.gvsig.fmap.geom.Geometry;
6
import org.gvsig.fmap.geom.GeometryLocator;
7
import org.gvsig.fmap.geom.GeometryManager;
8
import org.gvsig.fmap.geom.exception.CreateGeometryException;
9
import org.gvsig.fmap.geom.primitive.Envelope;
10
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
12

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

  
80
	public GPEFeature(){
81
		elements = new LinkedHashMap();		
82
	}
83

  
84
	/**
85
	 * @return the id
86
	 */
87
	public String getId() {
88
		return id;
89
	}
90

  
91
	/**
92
	 * @param id the id to set
93
	 */
94
	public void setId(String id) {
95
		this.id = id;
96
	}
97

  
98
	/**
99
	 * @return the geometry
100
	 */
101
	public Geometry getGeometry() {
102
		if (geometry == null){
103
		    try {
104
	            this.geometry = GEOMETRY_MANAGER.create(Geometry.TYPES.NULL, Geometry.SUBTYPES.GEOM3D);
105
	        } catch (CreateGeometryException e) {
106
	            LOG.error("Not possible to create a geometry", e);
107
	        }
108
		}
109
	    return geometry;
110
	}
111

  
112
	/**
113
	 * @param geometry the geometry to set
114
	 */
115
	public void setGeometry(Geometry geometry) {
116
		this.geometry = geometry;
117
	}
118

  
119
	/**
120
	 * @return the elements
121
	 */
122
	public LinkedHashMap getelements() {
123
		return elements;
124
	}
125

  
126
	/**
127
	 * @param elements the elements to set
128
	 */
129
	public void setElements(LinkedHashMap elements) {
130
		this.elements = elements;
131
	}
132
	
133
	/**
134
	 * It adds a new element
135
	 * @param element
136
	 * The element to add
137
	 */
138
	public void addElement(GPEElement element){
139
		elements.put(element.getName(), element);
140
	}
141

  
142
	/**
143
	 * @return the name
144
	 */
145
	public String getName() {
146
		return name;
147
	}
148

  
149
	/**
150
	 * @return the typeName
151
	 */
152
	public String getTypeName() {
153
		return typeName;
154
	}
155
	
156
	/**
157
	 * Initialize the feature id
158
	 */
159
	public static void initIdFeature(){
160
		idFeature = 0;
161
	}
162

  
163
	public Envelope getEnvelope() {
164
		if (geometry == null){
165
			return null;
166
		}
167
		return geometry.getEnvelope();
168
	}
169
}
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.7/org.gvsig.gpe.app/org.gvsig.gpe.app.mainplugin/src/main/java/org/gvsig/fmap/dal/store/gpe/DALGPELibrary.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
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.fmap.dal.store.gpe;
29

  
30
import java.util.ArrayList;
31
import java.util.List;
32

  
33
import org.gvsig.fmap.dal.DALFileLibrary;
34
import org.gvsig.fmap.dal.DALFileLocator;
35
import org.gvsig.fmap.dal.DALLibrary;
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.DataTypes;
38
import org.gvsig.fmap.dal.FileHelper;
39
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
40
import org.gvsig.fmap.geom.Geometry;
41
import org.gvsig.fmap.geom.GeometryLocator;
42
import org.gvsig.fmap.geom.GeometryManager;
43
import org.gvsig.fmap.geom.operation.writegml2.CurveWriteGml2Operation;
44
import org.gvsig.fmap.geom.operation.writegml2.MultiCurveWriteGml2Operation;
45
import org.gvsig.fmap.geom.operation.writegml2.MultiPointWriteGml2Operation;
46
import org.gvsig.fmap.geom.operation.writegml2.MultiSurfaceWriteGml2Operation;
47
import org.gvsig.fmap.geom.operation.writegml2.PointWriteGml2Operation;
48
import org.gvsig.fmap.geom.operation.writegml2.SurfaceWriteGml2Operation;
49
import org.gvsig.fmap.geom.operation.writegml2.WriteGml2Operation;
50
import org.gvsig.metadata.exceptions.MetadataException;
51
import org.gvsig.tools.library.AbstractLibrary;
52
import org.gvsig.tools.library.LibraryException;
53
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
54
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator;
55
import org.gvsig.xmlschema.lib.api.XMLSchemaManager;
56

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

Also available in: Unified diff