Revision 38328
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/config/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. |
|
0 | 25 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/config/about.htm | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<title>libGPE Extension.</title> |
|
4 |
<meta content=""> |
|
5 |
<style></style> |
|
6 |
</head> |
|
7 |
<body> |
|
8 |
<table width="60%" border="0"> |
|
9 |
<tr> |
|
10 |
<td width="64%"><img src="images/logo_horiz_bicolor_gva.png" width="329" height="50"></td> |
|
11 |
<td width="36%"><div align="right"><img src="images/logoIver.png" width="87" height="50"></div></td> |
|
12 |
</tr> |
|
13 |
<tr> |
|
14 |
<td colspan="2"><font face="Arial, Helvetica, sans-serif">© Copyright |
|
15 |
Generalitat Valenciana, IVER T.I. 2008.</font></td> |
|
16 |
</tr> |
|
17 |
</table> |
|
18 |
<h3>libGPE Extension.</h3> |
|
19 |
<p><br><br><b> Build Number: #build.number#</b></p> |
|
20 |
</body> |
|
21 |
</html> |
|
0 | 22 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/config/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. |
|
0 | 25 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/config/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.app" /> |
|
4 |
<libraries library-dir="lib"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.gpe.GPELibraryExtension" |
|
8 |
description="" |
|
9 |
active="true" |
|
10 |
priority="1"> |
|
11 |
</extension> |
|
12 |
<!-- |
|
13 |
<extension class-name="org.gvsig.gpe.GPEWriterExtension" |
|
14 |
description="Support for writing" |
|
15 |
active="true"> |
|
16 |
<menu text="Capa/export_to/GML" action-command="GML"/> |
|
17 |
<menu text="Capa/export_to/KML" action-command="KML"/> |
|
18 |
</extension> |
|
19 |
<extension class-name="org.gvsig.gpe.AboutGPEExtension" |
|
20 |
description="Extension to add about panel." |
|
21 |
active="true" |
|
22 |
priority="1"> |
|
23 |
</extension> |
|
24 |
--> |
|
25 |
</extensions> |
|
26 |
</plugin-config> |
|
0 | 27 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEFileSystemServerProvider.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.io.File; |
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.DALLocator; |
|
33 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.exception.CreateException; |
|
37 |
import org.gvsig.fmap.dal.exception.DataException; |
|
38 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
39 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
40 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
41 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
42 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
|
43 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
44 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
45 |
import org.gvsig.gpe.lib.api.GPELocator; |
|
46 |
import org.gvsig.gpe.lib.api.GPEManager; |
|
47 |
|
|
48 |
/** |
|
49 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
50 |
*/ |
|
51 |
public class GPEFileSystemServerProvider extends AbstractFilesystemServerExplorerProvider |
|
52 |
implements FilesystemServerExplorerProvider, ResourceConsumer { |
|
53 |
protected FilesystemServerExplorerProviderServices serverExplorer; |
|
54 |
|
|
55 |
private static final GPEManager GPE_MANAGER = GPELocator.getGPEManager(); |
|
56 |
|
|
57 |
public boolean canCreate() { |
|
58 |
// TODO Auto-generated method stub |
|
59 |
return false; |
|
60 |
} |
|
61 |
|
|
62 |
public int getMode() { |
|
63 |
return DataServerExplorer.MODE_FEATURE | DataServerExplorer.MODE_GEOMETRY; |
|
64 |
} |
|
65 |
|
|
66 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
70 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
|
71 |
throws CreateException { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
77 |
return (NewFeatureStoreParameters) DALLocator.getDataManager() |
|
78 |
.createStoreParameters(this.getDataStoreProviderName()); |
|
79 |
} |
|
80 |
|
|
81 |
public void initialize( |
|
82 |
FilesystemServerExplorerProviderServices serverExplorer) { |
|
83 |
this.serverExplorer = serverExplorer; |
|
84 |
} |
|
85 |
|
|
86 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
87 |
// TODO Auto-generated method stub |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
public String getDataStoreProviderName() { |
|
92 |
return GPEStoreProvider.NAME; |
|
93 |
} |
|
94 |
|
|
95 |
public String getDescription() { |
|
96 |
return GPEStoreProvider.DESCRIPTION; |
|
97 |
} |
|
98 |
|
|
99 |
public boolean accept(File pathName) { |
|
100 |
return GPE_MANAGER.accept(pathName.toURI()); |
|
101 |
} |
|
102 |
|
|
103 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
104 |
// TODO Auto-generated method stub |
|
105 |
return false; |
|
106 |
} |
|
107 |
|
|
108 |
public void resourceChanged(ResourceProvider resource) { |
|
109 |
// TODO Auto-generated method stub |
|
110 |
|
|
111 |
} |
|
112 |
|
|
113 |
} |
|
114 |
|
|
0 | 115 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPESetProvider.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.HashMap; |
|
31 |
import java.util.Iterator; |
|
32 |
|
|
33 |
import org.gvsig.fmap.dal.exception.DataException; |
|
34 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
36 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureProviderIterator; |
|
37 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureSetProvider; |
|
38 |
import org.gvsig.tools.exception.BaseException; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
42 |
*/ |
|
43 |
public class GPESetProvider extends AbstractFeatureSetProvider { |
|
44 |
|
|
45 |
public GPESetProvider(GPEStoreProvider store, |
|
46 |
FeatureQuery query) { |
|
47 |
super(store, query, null); |
|
48 |
} |
|
49 |
|
|
50 |
public GPESetProvider(GPEStoreProvider store, |
|
51 |
FeatureQuery query, FeatureType featureType) { |
|
52 |
super(store, query, featureType); |
|
53 |
} |
|
54 |
|
|
55 |
/* (non-Javadoc) |
|
56 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter() |
|
57 |
*/ |
|
58 |
public boolean canFilter() { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
return false; |
|
61 |
} |
|
62 |
|
|
63 |
/* (non-Javadoc) |
|
64 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canIterateFromIndex() |
|
65 |
*/ |
|
66 |
public boolean canIterateFromIndex() { |
|
67 |
// TODO Auto-generated method stub |
|
68 |
return false; |
|
69 |
} |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
72 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canOrder() |
|
73 |
*/ |
|
74 |
public boolean canOrder() { |
|
75 |
// TODO Auto-generated method stub |
|
76 |
return false; |
|
77 |
} |
|
78 |
|
|
79 |
/* (non-Javadoc) |
|
80 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#getSize() |
|
81 |
*/ |
|
82 |
public long getSize() throws DataException { |
|
83 |
return getStore().getFeatureCount(); |
|
84 |
} |
|
85 |
|
|
86 |
/* (non-Javadoc) |
|
87 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#isEmpty() |
|
88 |
*/ |
|
89 |
public boolean isEmpty() throws DataException { |
|
90 |
// TODO Auto-generated method stub |
|
91 |
return false; |
|
92 |
} |
|
93 |
|
|
94 |
protected AbstractFeatureProviderIterator createFastIterator(long index) |
|
95 |
throws DataException { |
|
96 |
return new GPEFastIterator((GPEStoreProvider) getStore(), |
|
97 |
getFeatureType()); |
|
98 |
} |
|
99 |
|
|
100 |
protected AbstractFeatureProviderIterator createIterator(long index) |
|
101 |
throws DataException { |
|
102 |
return new GPEIterator((GPEStoreProvider) getStore(), getFeatureType()); |
|
103 |
} |
|
104 |
|
|
105 |
protected class GPEIterator extends AbstractFeatureProviderIterator { |
|
106 |
protected FeatureType type; |
|
107 |
Iterator keys = null; |
|
108 |
HashMap features = null; |
|
109 |
|
|
110 |
public GPEIterator(GPEStoreProvider store, FeatureType type) |
|
111 |
throws DataException { |
|
112 |
super(store); |
|
113 |
this.type = type; |
|
114 |
features = store.getContentHandler().getFeatureSet(); |
|
115 |
keys = features.keySet().iterator(); |
|
116 |
} |
|
117 |
|
|
118 |
protected boolean internalHasNext() { |
|
119 |
return keys.hasNext(); |
|
120 |
} |
|
121 |
|
|
122 |
protected Object internalNext() { |
|
123 |
return features.get(keys.next()); |
|
124 |
} |
|
125 |
|
|
126 |
/* |
|
127 |
* (non-Javadoc) |
|
128 |
* @see java.util.Iterator#remove() |
|
129 |
*/ |
|
130 |
public void remove() { |
|
131 |
throw new UnsupportedOperationException(); |
|
132 |
} |
|
133 |
|
|
134 |
protected void doDispose() throws BaseException { |
|
135 |
|
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
protected class GPEFastIterator extends GPEIterator { |
|
140 |
|
|
141 |
public GPEFastIterator(GPEStoreProvider store, FeatureType type) throws DataException { |
|
142 |
super(store, type); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
protected void doDispose() throws BaseException { |
|
147 |
// Nothing to do |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
0 | 151 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEStoreProvider.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.io.File; |
|
31 |
import java.util.Map; |
|
32 |
|
|
33 |
import org.cresques.cts.IProjection; |
|
34 |
|
|
35 |
import org.gvsig.fmap.dal.DALLocator; |
|
36 |
import org.gvsig.fmap.dal.DataManager; |
|
37 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
38 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
39 |
import org.gvsig.fmap.dal.DataTypes; |
|
40 |
import org.gvsig.fmap.dal.FileHelper; |
|
41 |
import org.gvsig.fmap.dal.exception.DataException; |
|
42 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
43 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
44 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
45 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
46 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
47 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
48 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider; |
|
49 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
50 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
|
51 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
|
52 |
import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException; |
|
53 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
|
54 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
55 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
56 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
57 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
58 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
59 |
import org.gvsig.fmap.dal.store.gpe.handlers.FmapContentHandler; |
|
60 |
import org.gvsig.fmap.dal.store.gpe.handlers.FmapErrorHandler; |
|
61 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
62 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
63 |
import org.gvsig.gpe.lib.api.GPELocator; |
|
64 |
import org.gvsig.gpe.lib.api.GPEManager; |
|
65 |
import org.gvsig.tools.dynobject.DynObject; |
|
66 |
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator; |
|
67 |
import org.gvsig.xmlschema.lib.api.XMLSchemaManager; |
|
68 |
|
|
69 |
/** |
|
70 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
71 |
*/ |
|
72 |
public class GPEStoreProvider extends AbstractFeatureStoreProvider implements |
|
73 |
ResourceConsumer { |
|
74 |
public static final String NAME = "GPE"; |
|
75 |
public static final String DESCRIPTION = "GPE file"; |
|
76 |
public static final String METADATA_DEFINITION_NAME = NAME; |
|
77 |
|
|
78 |
protected File m_Fich; |
|
79 |
protected boolean isOpen = false; |
|
80 |
//private GPEStoreParameters gpeParams; |
|
81 |
private ResourceProvider gpeResource; |
|
82 |
|
|
83 |
//Managers to manage the parsing process |
|
84 |
protected GPEManager gpeManager = null; |
|
85 |
protected XMLSchemaManager xmlSchemaManager = null; |
|
86 |
|
|
87 |
//The content handler and the error handler |
|
88 |
protected FmapContentHandler contentHandler; |
|
89 |
protected FmapErrorHandler errorHandler; |
|
90 |
|
|
91 |
public GPEStoreProvider(DataStoreParameters params, |
|
92 |
DataStoreProviderServices storeServices) |
|
93 |
throws InitializeException { |
|
94 |
this(params, storeServices, FileHelper |
|
95 |
.newMetadataContainer(METADATA_DEFINITION_NAME)); |
|
96 |
} |
|
97 |
|
|
98 |
protected GPEStoreProvider(DataStoreParameters params, |
|
99 |
DataStoreProviderServices storeServices, DynObject metadata) |
|
100 |
throws InitializeException { |
|
101 |
|
|
102 |
super(params, storeServices, metadata); |
|
103 |
|
|
104 |
this.setDynValue("Envelope", params.getDynValue("Envelope")); |
|
105 |
|
|
106 |
gpeManager = GPELocator.getGPEManager(); |
|
107 |
xmlSchemaManager = XMLSchemaLocator.getXMLSchemaManager(); |
|
108 |
|
|
109 |
retrieveFile(); |
|
110 |
gpeResource = this.createResource(FileResource.NAME, |
|
111 |
new Object[] { m_Fich.getAbsolutePath() }); |
|
112 |
gpeResource.addConsumer(this); |
|
113 |
this.initFeatureType(); |
|
114 |
} |
|
115 |
|
|
116 |
protected void retrieveFile() throws InitializeException{ |
|
117 |
m_Fich = getGPEParameters().getFile(); |
|
118 |
} |
|
119 |
|
|
120 |
protected void initFeatureType() throws InitializeException { |
|
121 |
try { |
|
122 |
|
|
123 |
this.open(); |
|
124 |
} catch (DataException e) { |
|
125 |
throw new InitializeException(this.getProviderName(), e); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
private GPEStoreParameters getGPEParameters() { |
|
130 |
return (GPEStoreParameters) this.getParameters(); |
|
131 |
} |
|
132 |
|
|
133 |
/* (non-Javadoc) |
|
134 |
* @see org.gvsig.fmap.dal.resource.spi.ResourceConsumer#closeResourceRequested(org.gvsig.fmap.dal.resource.spi.ResourceProvider) |
|
135 |
*/ |
|
136 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
137 |
// TODO Auto-generated method stub |
|
138 |
return false; |
|
139 |
} |
|
140 |
|
|
141 |
/* (non-Javadoc) |
|
142 |
* @see org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.gvsig.fmap.dal.resource.spi.ResourceProvider) |
|
143 |
*/ |
|
144 |
public void resourceChanged(ResourceProvider resource) { |
|
145 |
// TODO Auto-generated method stub |
|
146 |
|
|
147 |
} |
|
148 |
|
|
149 |
/* (non-Javadoc) |
|
150 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#canWriteGeometry(int) |
|
151 |
*/ |
|
152 |
public boolean canWriteGeometry(int geometryType, int geometrySubtype) |
|
153 |
throws DataException { |
|
154 |
// TODO Auto-generated method stub |
|
155 |
return false; |
|
156 |
} |
|
157 |
|
|
158 |
/* (non-Javadoc) |
|
159 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createNewOID() |
|
160 |
*/ |
|
161 |
public Object createNewOID() { |
|
162 |
return contentHandler.createNewOID(); |
|
163 |
} |
|
164 |
|
|
165 |
/* (non-Javadoc) |
|
166 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createSet(org.gvsig.fmap.dal.feature.FeatureQuery) |
|
167 |
*/ |
|
168 |
public FeatureSetProvider createSet(FeatureQuery query) |
|
169 |
throws DataException { |
|
170 |
return new GPESetProvider(this, query); |
|
171 |
} |
|
172 |
|
|
173 |
protected FeatureProvider internalGetFeatureProviderByReference( |
|
174 |
FeatureReferenceProviderServices reference) throws DataException { |
|
175 |
return internalGetFeatureProviderByReference(reference, |
|
176 |
this |
|
177 |
.getFeatureStore() |
|
178 |
.getDefaultFeatureType()); |
|
179 |
} |
|
180 |
|
|
181 |
public FeatureProvider internalGetFeatureProviderByReference( |
|
182 |
FeatureReferenceProviderServices reference, FeatureType featureType) |
|
183 |
throws DataException { |
|
184 |
Map featureSet = contentHandler.getFeatureSet(); |
|
185 |
if (featureSet.containsKey(reference.getOID())){ |
|
186 |
return (FeatureProvider)featureSet.get(reference.getOID()); |
|
187 |
} |
|
188 |
return null; |
|
189 |
} |
|
190 |
|
|
191 |
FeatureProvider getFeatureProviderByIndex(Long index, FeatureType fType) |
|
192 |
throws DataException { |
|
193 |
Map featureSet = contentHandler.getFeatureSet(); |
|
194 |
if (featureSet.containsKey(index)){ |
|
195 |
return (FeatureProvider)featureSet.get(index); |
|
196 |
} |
|
197 |
return null; |
|
198 |
} |
|
199 |
|
|
200 |
public void resourcesBegin() throws ResourceExecuteException { |
|
201 |
// Nothing to do |
|
202 |
} |
|
203 |
|
|
204 |
public void resourcesEnd() { |
|
205 |
// Nothing to do |
|
206 |
} |
|
207 |
|
|
208 |
/* (non-Javadoc) |
|
209 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getFeatureReferenceOIDType() |
|
210 |
*/ |
|
211 |
public int getOIDType() { |
|
212 |
return DataTypes.STRING; |
|
213 |
} |
|
214 |
|
|
215 |
/* (non-Javadoc) |
|
216 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getName() |
|
217 |
*/ |
|
218 |
public String getProviderName() { |
|
219 |
return NAME; |
|
220 |
} |
|
221 |
|
|
222 |
/* (non-Javadoc) |
|
223 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getSourceId() |
|
224 |
*/ |
|
225 |
public Object getSourceId() { |
|
226 |
return getGPEParameters().getFile(); |
|
227 |
} |
|
228 |
|
|
229 |
public String getName() { |
|
230 |
String name = this.getGPEParameters().getFile().getName(); |
|
231 |
int n = name.lastIndexOf("."); |
|
232 |
if( n<1 ) { |
|
233 |
return name; |
|
234 |
} |
|
235 |
return name.substring(0, n); |
|
236 |
} |
|
237 |
|
|
238 |
public String getFullName() { |
|
239 |
return this.getGPEParameters().getFile().getAbsolutePath(); |
|
240 |
} |
|
241 |
|
|
242 |
/* (non-Javadoc) |
|
243 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#open() |
|
244 |
*/ |
|
245 |
public void open() throws OpenException { |
|
246 |
if (isOpen) { |
|
247 |
return; |
|
248 |
} |
|
249 |
try { |
|
250 |
errorHandler = new FmapErrorHandler(); |
|
251 |
contentHandler = new FmapContentHandler(errorHandler, |
|
252 |
getStoreServices(), this, m_Fich, |
|
253 |
getSRS(), |
|
254 |
getGeometryType()); |
|
255 |
if (getStoreServices().getDefaultFeatureType() != null){ |
|
256 |
contentHandler.setFeatureType(getStoreServices().getDefaultFeatureType().getEditable()); |
|
257 |
} |
|
258 |
contentHandler.setEnvelope((Envelope)getDynValue("Envelope")); |
|
259 |
isOpen = true; |
|
260 |
gpeManager.parse(contentHandler, errorHandler, m_Fich.toURI()); |
|
261 |
} catch (Exception e) { |
|
262 |
throw new OpenException("Imposible create a parser",e); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
protected IProjection getSRS(){ |
|
267 |
return getGPEParameters().getCRS(); |
|
268 |
} |
|
269 |
|
|
270 |
protected int getGeometryType() { |
|
271 |
return TYPES.GEOMETRY; |
|
272 |
} |
|
273 |
|
|
274 |
/* (non-Javadoc) |
|
275 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createSet(org.gvsig.fmap.dal.feature.FeatureQuery, org.gvsig.fmap.dal.feature.FeatureType) |
|
276 |
*/ |
|
277 |
public FeatureSetProvider createSet(FeatureQuery query, |
|
278 |
FeatureType featureType) throws DataException { |
|
279 |
return new GPESetProvider(this, query, featureType); |
|
280 |
} |
|
281 |
|
|
282 |
public long getFeatureCount() throws DataException { |
|
283 |
return contentHandler.getFeaturesCount(); |
|
284 |
} |
|
285 |
|
|
286 |
/* (non-Javadoc) |
|
287 |
* @see org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider#getEnvelope() |
|
288 |
*/ |
|
289 |
public Envelope getEnvelope() throws DataException { |
|
290 |
this.open(); |
|
291 |
return (Envelope) this.getDynValue("Envelope"); |
|
292 |
} |
|
293 |
|
|
294 |
public void setEnvelope(Envelope envelope) { |
|
295 |
this.setDynValue("Envelope", envelope); |
|
296 |
} |
|
297 |
|
|
298 |
public ResourceProvider getResource() { |
|
299 |
return gpeResource; |
|
300 |
} |
|
301 |
|
|
302 |
public DataServerExplorer getExplorer() throws ReadException, |
|
303 |
ValidateDataParametersException { |
|
304 |
DataManager manager = DALLocator.getDataManager(); |
|
305 |
FilesystemServerExplorerParameters params; |
|
306 |
try { |
|
307 |
params = (FilesystemServerExplorerParameters) manager |
|
308 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
309 |
params.setRoot(this.getGPEParameters().getFile().getParent()); |
|
310 |
return manager.createServerExplorer(params); |
|
311 |
} catch (DataException e) { |
|
312 |
throw new ReadException(this.getProviderName(), e); |
|
313 |
} catch (ValidateDataParametersException e) { |
|
314 |
// TODO Auto-generated catch block |
|
315 |
throw new ReadException(this.getProviderName(), e); |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* @return the contentHandler |
|
321 |
*/ |
|
322 |
public FmapContentHandler getContentHandler() { |
|
323 |
return contentHandler; |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* @return the errorHandler |
|
328 |
*/ |
|
329 |
public FmapErrorHandler getErrorHandler() { |
|
330 |
return errorHandler; |
|
331 |
} |
|
332 |
|
|
333 |
} |
|
0 | 334 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEStoreParameters.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.io.File; |
|
31 |
|
|
32 |
import org.cresques.cts.IProjection; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.FileHelper; |
|
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
38 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
39 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
40 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
45 |
*/ |
|
46 |
public class GPEStoreParameters extends AbstractDataParameters implements |
|
47 |
DataStoreParameters, FilesystemStoreParameters { |
|
48 |
|
|
49 |
public static final String PARAMETERS_DEFINITION_NAME = "GPEStoreParameters"; |
|
50 |
|
|
51 |
private static final String FILE_PARAMETER_NAME = "File"; |
|
52 |
private static final String CRS_PARAMETER_NAME = "CRS"; |
|
53 |
private static final String ENVELOPE_PARAMETER_NAME = "Envelope"; |
|
54 |
|
|
55 |
private DelegatedDynObject parameters; |
|
56 |
|
|
57 |
public GPEStoreParameters() { |
|
58 |
this(PARAMETERS_DEFINITION_NAME); |
|
59 |
} |
|
60 |
|
|
61 |
protected GPEStoreParameters(String parametersDefinitionName) { |
|
62 |
this(parametersDefinitionName, GPEStoreProvider.NAME); |
|
63 |
} |
|
64 |
|
|
65 |
public GPEStoreParameters(String parametersDefinitionName, String name) { |
|
66 |
super(); |
|
67 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
|
68 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name); |
|
69 |
} |
|
70 |
|
|
71 |
protected static void registerParametersDefinition(){ |
|
72 |
DynStruct dynStruct = FileHelper.registerParametersDefinition( |
|
73 |
GPEStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
74 |
GPEStoreParameters.class, "GPEParameters.xml"); |
|
75 |
dynStruct.addDynFieldObject("Envelope").setClassOfValue(Envelope.class).setMandatory(false); |
|
76 |
} |
|
77 |
|
|
78 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
79 |
return parameters; |
|
80 |
} |
|
81 |
|
|
82 |
public String getDataStoreName() { |
|
83 |
return GPEStoreProvider.NAME; |
|
84 |
} |
|
85 |
|
|
86 |
public String getDescription() { |
|
87 |
return GPEStoreProvider.DESCRIPTION; |
|
88 |
} |
|
89 |
|
|
90 |
public boolean isValid() { |
|
91 |
return (this.getFile() != null); |
|
92 |
} |
|
93 |
|
|
94 |
public File getFile() { |
|
95 |
return (File) this.getDynValue(FILE_PARAMETER_NAME); |
|
96 |
} |
|
97 |
|
|
98 |
public void setFile(File file) { |
|
99 |
this.setDynValue(FILE_PARAMETER_NAME, file); |
|
100 |
} |
|
101 |
|
|
102 |
public String getFileName() { |
|
103 |
return this.getFile().getAbsolutePath(); |
|
104 |
} |
|
105 |
|
|
106 |
public void setFileName(String fileName) { |
|
107 |
this.setDynValue(FILE_PARAMETER_NAME, fileName); |
|
108 |
} |
|
109 |
|
|
110 |
public IProjection getCRS() { |
|
111 |
return (IProjection) this.getDynValue(CRS_PARAMETER_NAME); |
|
112 |
} |
|
113 |
|
|
114 |
public void setCRS(IProjection srs) { |
|
115 |
this.setDynValue(CRS_PARAMETER_NAME, srs); |
|
116 |
} |
|
117 |
|
|
118 |
public void setCRS(String srs) { |
|
119 |
this.setDynValue(CRS_PARAMETER_NAME, srs); |
|
120 |
} |
|
121 |
|
|
122 |
public Envelope getEnvelope() { |
|
123 |
return (Envelope) this.getDynValue(ENVELOPE_PARAMETER_NAME); |
|
124 |
} |
|
125 |
|
|
126 |
public void setEnvelope(Envelope envelope) { |
|
127 |
this.setDynValue(ENVELOPE_PARAMETER_NAME, envelope); |
|
128 |
} |
|
129 |
} |
|
0 | 130 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/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 |
} |
|
0 | 84 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/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 |
} |
|
0 | 57 |
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/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.jfree.util.Log; |
|
13 |
import org.slf4j.Logger; |
|
14 |
import org.slf4j.LoggerFactory; |
|
15 |
|
|
16 |
import org.gvsig.fmap.dal.DataTypes; |
|
17 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
18 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
19 |
import org.gvsig.fmap.dal.feature.Feature; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
21 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
|
22 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
23 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
|
24 |
import org.gvsig.fmap.dal.store.gpe.GPEStoreProvider; |
|
25 |
import org.gvsig.fmap.dal.store.gpe.model.GPEElement; |
|
26 |
import org.gvsig.fmap.dal.store.gpe.model.GPEFeature; |
|
27 |
import org.gvsig.fmap.geom.Geometry; |
|
28 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
29 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
30 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
31 |
import org.gvsig.fmap.geom.GeometryManager; |
|
32 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
33 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
34 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
|
35 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
36 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
37 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
38 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
39 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
40 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
41 |
import org.gvsig.fmap.geom.primitive.Point; |
|
42 |
import org.gvsig.fmap.geom.primitive.Primitive; |
|
43 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
44 |
import org.gvsig.gpe.lib.api.parser.IAttributesIterator; |
|
45 |
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator; |
|
46 |
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler; |
|
47 |
import org.gvsig.gpe.lib.impl.parser.GPEContentHandler; |
|
48 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
49 |
* |
|
50 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
51 |
* |
|
52 |
* This program is free software; you can redistribute it and/or |
|
53 |
* modify it under the terms of the GNU General Public License |
|
54 |
* as published by the Free Software Foundation; either version 2 |
|
55 |
* of the License, or (at your option) any later version. |
|
56 |
* |
|
57 |
* This program is distributed in the hope that it will be useful, |
|
58 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
59 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
60 |
* GNU General Public License for more details. |
|
61 |
* |
|
62 |
* You should have received a copy of the GNU General Public License |
|
63 |
* along with this program; if not, write to the Free Software |
|
64 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
65 |
* |
|
66 |
* For more information, contact: |
|
67 |
* |
|
68 |
* Generalitat Valenciana |
|
69 |
* Conselleria d'Infraestructures i Transport |
|
70 |
* Av. Blasco Ib??ez, 50 |
|
71 |
* 46010 VALENCIA |
|
72 |
* SPAIN |
|
73 |
* |
|
74 |
* +34 963862235 |
|
75 |
* gvsig@gva.es |
|
76 |
* www.gvsig.gva.es |
|
77 |
* |
|
78 |
* or |
|
79 |
* |
|
80 |
* IVER T.I. S.A |
|
81 |
* Salamanca 50 |
|
82 |
* 46005 Valencia |
|
83 |
* Spain |
|
84 |
* |
|
85 |
* +34 963163400 |
|
86 |
* dac@iver.es |
|
87 |
*/ |
|
88 |
/* CVS MESSAGES: |
|
89 |
* |
|
90 |
* $Id$ |
|
91 |
* $Log$ |
|
92 |
* |
|
93 |
*/ |
|
94 |
/** |
|
95 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
96 |
*/ |
|
97 |
public class FmapContentHandler extends GPEContentHandler { |
|
98 |
private static final Logger LOG = LoggerFactory.getLogger(FmapContentHandler.class); |
|
99 |
|
|
100 |
private HashMap featureSet = null; |
|
101 |
private EditableFeatureType featureType = null; |
|
102 |
private FeatureStoreProviderServices store = null; |
|
103 |
private GPEStoreProvider storeProvider = null; |
|
104 |
private GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
105 |
private int featureId = 0; |
|
106 |
private Envelope envelope = null; |
|
107 |
private File file = null; |
|
108 |
private IProjection srs = null; |
|
109 |
private int geometryType = 0; |
|
110 |
|
|
111 |
public FmapContentHandler(IGPEErrorHandler errorHandler, FeatureStoreProviderServices store, |
|
112 |
GPEStoreProvider storeProvider, File file, IProjection srs, int geometryType) { |
|
113 |
super(); |
|
114 |
setErrorHandler(errorHandler); |
|
115 |
this.store = store; |
|
116 |
this.storeProvider = storeProvider; |
|
117 |
this.file = file; |
|
118 |
this.srs = srs; |
|
119 |
this.geometryType = geometryType; |
|
120 |
} |
|
121 |
|
|
122 |
public int getFeaturesCount(){ |
|
123 |
return featureSet.size(); |
|
124 |
} |
|
125 |
|
|
126 |
public Feature getFeatureAt(int index){ |
|
127 |
return (Feature)featureSet.get(new Integer(index)); |
|
128 |
} |
|
129 |
|
|
130 |
public EditableFeatureType getFeatureType(){ |
|
131 |
return featureType; |
|
132 |
} |
|
133 |
|
|
134 |
|
|
135 |
/** |
|
136 |
* @return the featureSet |
|
137 |
*/ |
|
138 |
public HashMap getFeatureSet() { |
|
139 |
return featureSet; |
|
140 |
} |
|
141 |
|
|
142 |
/* |
|
143 |
* (non-Javadoc) |
|
144 |
* @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) |
|
145 |
*/ |
|
146 |
public Object startLayer(String id, String namespace, String name, |
|
147 |
String description, String srs, IAttributesIterator iterator, Object parentLayer, Object box) { |
|
148 |
if (featureSet == null){ |
|
149 |
featureSet = new HashMap(); |
|
150 |
} |
|
151 |
if (envelope == null){ |
|
152 |
try { |
|
153 |
envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D); |
|
154 |
} catch (CreateEnvelopeException e) { |
|
155 |
Log.error("Error creating the envelope", e); |
|
156 |
} |
|
157 |
} |
|
158 |
return featureSet; |
|
159 |
} |
|
160 |
|
|
161 |
/* |
|
162 |
* (non-Javadoc) |
|
163 |
* @see org.gvsig.gpe.IGPEContentHandler#endLayer(java.lang.Object) |
|
164 |
*/ |
|
165 |
public void endLayer(Object layer) { |
|
166 |
if (featureType == null){ |
|
167 |
createFeatureType(null); |
|
168 |
} |
|
169 |
storeProvider.setEnvelope(envelope); |
|
170 |
} |
|
171 |
|
|
172 |
/* |
|
173 |
* (non-Javadoc) |
|
174 |
* @see org.gvsig.gpe.parser.GPEContentHandler#startPoint(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String) |
|
175 |
*/ |
|
176 |
public Object startPoint(String id, ICoordinateIterator coords, String srs) { |
|
177 |
return createPoint(coords); |
|
178 |
} |
|
179 |
|
|
180 |
private Point createPoint(ICoordinateIterator coords){ |
|
181 |
double[] buffer = new double[coords.getDimension()]; |
|
182 |
try { |
|
183 |
coords.hasNext(); |
|
184 |
coords.next(buffer); |
|
185 |
Point point = null; |
|
186 |
if (coords.getDimension() == 2){ |
|
187 |
point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
188 |
}else if (coords.getDimension() == 3){ |
|
189 |
point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D); |
|
190 |
} |
|
191 |
for (int i=0 ; i<buffer.length ; i++){ |
|
192 |
point.setCoordinateAt(i, buffer[i]); |
|
193 |
} |
|
194 |
return point; |
|
195 |
} catch (IOException e) { |
|
196 |
getErrorHandler().addError(e); |
|
197 |
} catch (CreateGeometryException e) { |
|
198 |
getErrorHandler().addError(e); |
|
199 |
} |
|
200 |
return null; |
|
201 |
} |
|
202 |
|
|
203 |
private Point createPoint(double[] buffer){ |
|
204 |
try { |
|
205 |
Point point = null; |
|
206 |
if (buffer.length == 2){ |
|
207 |
point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
208 |
}else if (buffer.length == 3){ |
|
209 |
point = (Point) geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D); |
|
210 |
} |
|
211 |
for (int i=0 ; i<buffer.length ; i++){ |
|
212 |
point.setCoordinateAt(i, buffer[i]); |
|
213 |
} |
|
214 |
return point; |
|
215 |
}catch (CreateGeometryException e) { |
|
216 |
getErrorHandler().addError(e); |
|
217 |
} |
|
218 |
return null; |
|
219 |
} |
|
220 |
|
|
221 |
|
|
222 |
/* (non-Javadoc) |
|
223 |
* @see org.gvsig.gpe.parser.GPEContentHandler#startLineString(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String) |
|
224 |
*/ |
|
225 |
public Object startLineString(String id, ICoordinateIterator coords, |
|
226 |
String srs) { |
|
227 |
return createCurve(coords); |
|
228 |
} |
|
229 |
|
|
230 |
private Curve createCurve(ICoordinateIterator coords){ |
|
231 |
GeneralPathX gp = createGeneralPathX(coords); |
|
232 |
try { |
|
233 |
Curve curve = null; |
|
234 |
if (coords.getDimension() == 2){ |
|
235 |
curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
236 |
}else if (coords.getDimension() == 3){ |
|
237 |
curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM3D); |
|
238 |
} |
|
239 |
curve.setGeneralPath(gp); |
|
240 |
return curve; |
|
241 |
} catch (CreateGeometryException e) { |
|
242 |
getErrorHandler().addError(e); |
|
243 |
} |
|
244 |
return null; |
|
245 |
} |
|
246 |
|
|
247 |
private GeneralPathX createGeneralPathX(ICoordinateIterator coords){ |
|
248 |
GeneralPathX gp = new GeneralPathX(); |
|
249 |
if (coords == null){ |
|
250 |
return gp; |
|
251 |
} |
|
252 |
double[] buffer = new double[coords.getDimension()]; |
|
253 |
try { |
|
254 |
if (coords.hasNext()){ |
|
255 |
coords.next(buffer); |
|
256 |
gp.moveTo(buffer[0], buffer[1]); |
|
257 |
} |
|
258 |
while(coords.hasNext()){ |
|
259 |
coords.next(buffer); |
|
260 |
gp.lineTo(buffer[0], buffer[1]); |
|
261 |
} |
|
262 |
} catch (IOException e) { |
|
263 |
getErrorHandler().addError(e); |
|
264 |
} |
|
265 |
return gp; |
|
266 |
} |
|
267 |
|
|
268 |
/* (non-Javadoc) |
|
269 |
* @see org.gvsig.gpe.parser.GPEContentHandler#startPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String) |
|
270 |
*/ |
|
271 |
|
|
272 |
public Object startPolygon(String id, ICoordinateIterator coords, String srs) { |
|
273 |
return createSurface(coords); |
|
274 |
} |
|
275 |
|
|
276 |
private Surface createSurface(ICoordinateIterator coords){ |
|
277 |
GeneralPathX gp = createGeneralPathX(coords); |
|
278 |
try { |
|
279 |
Surface surface = null; |
|
280 |
if (coords.getDimension() == 2){ |
|
281 |
surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
282 |
}else if (coords.getDimension() == 3){ |
|
283 |
surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM3D); |
|
284 |
} |
|
285 |
surface.setGeneralPath(gp); |
|
286 |
return surface; |
|
287 |
} catch (CreateGeometryException e) { |
|
288 |
getErrorHandler().addError(e); |
|
289 |
} |
|
290 |
return null; |
|
291 |
} |
|
292 |
|
|
293 |
|
|
294 |
/* (non-Javadoc) |
|
295 |
* @see org.gvsig.gpe.parser.GPEContentHandler#startInnerPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String) |
|
296 |
*/ |
|
297 |
public Object startInnerPolygon(String id, ICoordinateIterator coords, |
|
298 |
String srs) { |
|
299 |
return createSurface(coords); |
|
300 |
} |
|
301 |
|
|
302 |
/* |
|
303 |
* (non-Javadoc) |
|
304 |
* @see org.gvsig.gpe.IGPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object) |
|
305 |
*/ |
|
306 |
public void addGeometryToFeature(Object geometry, Object feature) { |
|
307 |
((GPEFeature)feature).setGeometry((Geometry)geometry); |
|
308 |
} |
|
309 |
|
|
310 |
/* |
|
311 |
* (non-Javadoc) |
|
312 |
* @see org.gvsig.gpe.IGPEContentHandler#addBboxToLayer(java.lang.Object, java.lang.Object) |
|
313 |
*/ |
|
314 |
public void addBboxToLayer(Object bbox, Object layer) { |
|
315 |
// if (layer != null){ |
|
316 |
// GPEBBox gpeBBox = (GPEBBox)bbox; |
|
317 |
// if (gpeBBox.getSrs() != null){ |
|
318 |
// IProjection projection = null; |
|
319 |
// try{ |
|
320 |
// CRSFactory.getCRS(gpeBBox.getSrs()); |
|
321 |
// }catch(Exception e){ |
|
322 |
// //If the CRS factory has an error. |
|
323 |
// } |
|
324 |
// if ((projection != null) && (!(projection.equals(((FLayer)layer).getProjection())))){ |
|
325 |
// //TODO reproyectar la bbox y asignarsela a la capa |
|
326 |
// } |
|
327 |
// } |
|
328 |
// ((IGPEDriver)layer).setExtent(gpeBBox.getBbox2D()); |
|
329 |
// } |
|
330 |
} |
|
331 |
|
|
332 |
/* |
|
333 |
* (non-Javadoc) |
|
334 |
* @see org.gvsig.gpe.IGPEContentHandler#addElementToFeature(java.lang.Object, java.lang.Object) |
|
335 |
*/ |
|
336 |
public void addElementToFeature(Object element, Object feature) { |
|
337 |
GPEElement gpeElement = (GPEElement)element; |
|
338 |
((GPEFeature)feature).addElement(gpeElement); |
|
339 |
} |
|
340 |
|
|
341 |
/* |
|
342 |
* (non-Javadoc) |
|
343 |
* @see org.gvsig.gpe.IGPEContentHandler#addFeatureToLayer(java.lang.Object, java.lang.Object) |
|
344 |
*/ |
|
345 |
public void addFeatureToLayer(Object feature, Object layer) { |
|
346 |
GPEFeature gpefeature = (GPEFeature)feature; |
|
347 |
Envelope currentEnvelope = gpefeature.getEnvelope(); |
|
348 |
if (featureType == null){ |
|
349 |
createFeatureType(gpefeature); |
|
350 |
|
|
351 |
//Initialize the envelope |
|
352 |
try { |
|
353 |
envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D); |
|
354 |
} catch (CreateEnvelopeException e) { |
|
355 |
getErrorHandler().addError(e); |
|
356 |
} |
|
357 |
//Calculates the envelope |
|
358 |
envelope = currentEnvelope; |
|
359 |
}else{ |
|
360 |
//Calculates the envelope |
|
361 |
if (currentEnvelope != null){ |
|
362 |
envelope.add(currentEnvelope); |
|
363 |
} |
|
364 |
} |
|
365 |
//If it is null is a multilayer: not supported yet |
|
366 |
if (layer != null){ |
|
367 |
FeatureProvider data = new DefaultFeatureProvider(featureType.getNotEditableCopy(), storeProvider.createNewOID()); |
|
368 |
Map elements = gpefeature.getelements(); |
|
369 |
Iterator keys = elements.keySet().iterator(); |
|
370 |
String gid = gpefeature.getId(); |
|
371 |
data.setOID(gid); |
|
372 |
while (keys.hasNext()){ |
|
373 |
String elementName = (String)keys.next(); |
|
374 |
data.set(elementName, ((GPEElement)elements.get(elementName)).getValue()); |
|
375 |
} |
Also available in: Unified diff