Revision 122
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNGetLabeling.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dgn.legend; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
31 |
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider; |
|
32 |
import org.gvsig.fmap.dal.store.dgn.LegendBuilder; |
|
33 |
import org.gvsig.tools.ToolsLocator; |
|
34 |
import org.gvsig.tools.dynobject.DynClass; |
|
35 |
import org.gvsig.tools.dynobject.DynMethod; |
|
36 |
import org.gvsig.tools.dynobject.DynObject; |
|
37 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
38 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
39 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
40 |
|
|
41 |
public class DGNGetLabeling implements DynMethod { |
|
42 |
private static int code = DynObjectManager.NULLCODE; |
|
43 |
|
|
44 |
static void register(DynClass DGNDynClass) { |
|
45 |
if (code != DynObjectManager.NULLCODE) { |
|
46 |
return; |
|
47 |
} |
|
48 |
code = ToolsLocator.getDynObjectManager().registerDynMethod( |
|
49 |
DGNDynClass, |
|
50 |
new DGNGetLabeling() |
|
51 |
); |
|
52 |
|
|
53 |
} |
|
54 |
public int getCode() throws DynMethodNotSupportedException { |
|
55 |
return code; |
|
56 |
} |
|
57 |
|
|
58 |
public String getDescription() { |
|
59 |
return "DGN Labeling"; |
|
60 |
} |
|
61 |
|
|
62 |
public String getName() { |
|
63 |
return LegendBuilder.DYNMETHOD_GETLABELING_NAME; |
|
64 |
} |
|
65 |
|
|
66 |
public Object invoke(Object self, DynObject context) |
|
67 |
throws DynMethodException { |
|
68 |
try { |
|
69 |
return ((DGNStoreProvider) self).getLabeling(); |
|
70 |
} catch (OpenException e) { |
|
71 |
//FIXME |
|
72 |
throw new RuntimeException(e); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNGetLegend.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dgn.legend; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
31 |
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider; |
|
32 |
import org.gvsig.fmap.dal.store.dgn.LegendBuilder; |
|
33 |
import org.gvsig.tools.ToolsLocator; |
|
34 |
import org.gvsig.tools.dynobject.DynClass; |
|
35 |
import org.gvsig.tools.dynobject.DynMethod; |
|
36 |
import org.gvsig.tools.dynobject.DynObject; |
|
37 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
38 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
39 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
40 |
|
|
41 |
public class DGNGetLegend implements DynMethod { |
|
42 |
private static int code = DynObjectManager.NULLCODE; |
|
43 |
|
|
44 |
static void register(DynClass DGNDynClass) { |
|
45 |
if (code != DynObjectManager.NULLCODE) { |
|
46 |
return; |
|
47 |
} |
|
48 |
code = ToolsLocator.getDynObjectManager().registerDynMethod( |
|
49 |
DGNDynClass, |
|
50 |
new DGNGetLegend() |
|
51 |
); |
|
52 |
|
|
53 |
} |
|
54 |
public int getCode() throws DynMethodNotSupportedException { |
|
55 |
return code; |
|
56 |
} |
|
57 |
|
|
58 |
public String getDescription() { |
|
59 |
return "DGN Legend"; |
|
60 |
} |
|
61 |
|
|
62 |
public String getName() { |
|
63 |
return LegendBuilder.DYNMETHOD_GETLEGEND_NAME; |
|
64 |
} |
|
65 |
|
|
66 |
public Object invoke(Object self, DynObject context) |
|
67 |
throws DynMethodException { |
|
68 |
try { |
|
69 |
return ((DGNStoreProvider) self).getLegend(); |
|
70 |
} catch (OpenException e) { |
|
71 |
throw new RuntimeException(e); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNLegendLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.dal.store.dgn.legend; |
|
32 |
|
|
33 |
import org.gvsig.fmap.dal.DALLibrary; |
|
34 |
import org.gvsig.fmap.dal.store.dgn.DGNLibrary; |
|
35 |
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider; |
|
36 |
import org.gvsig.metadata.MetadataLibrary; |
|
37 |
import org.gvsig.metadata.MetadataLocator; |
|
38 |
import org.gvsig.tools.dynobject.DynClass; |
|
39 |
import org.gvsig.tools.library.AbstractLibrary; |
|
40 |
import org.gvsig.tools.library.LibraryException; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author jmvivo |
|
44 |
* |
|
45 |
*/ |
|
46 |
public class DGNLegendLibrary extends AbstractLibrary { |
|
47 |
|
|
48 |
@Override |
|
49 |
public void doRegistration() { |
|
50 |
registerAsServiceOf(DALLibrary.class); |
|
51 |
require(DGNLibrary.class); |
|
52 |
require(MetadataLibrary.class); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected void doInitialize() throws LibraryException { |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
protected void doPostInitialize() throws LibraryException { |
|
61 |
DynClass metadataDefinition = (DynClass) MetadataLocator.getMetadataManager() |
|
62 |
.getDefinition(DGNStoreProvider.METADATA_DEFINITION_NAME); |
|
63 |
DGNGetLegendBuilder.register(metadataDefinition); |
|
64 |
DGNGetLegend.register(metadataDefinition); |
|
65 |
DGNGetLabeling.register(metadataDefinition); |
|
66 |
} |
|
67 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNGetLegendBuilder.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dgn.legend; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.store.dgn.LegendBuilder; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.dynobject.DynClass; |
|
33 |
import org.gvsig.tools.dynobject.DynMethod; |
|
34 |
import org.gvsig.tools.dynobject.DynObject; |
|
35 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
36 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
37 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
38 |
|
|
39 |
public class DGNGetLegendBuilder implements DynMethod { |
|
40 |
private static int code = DynObjectManager.NULLCODE; |
|
41 |
|
|
42 |
static void register(DynClass DGNDynClass) { |
|
43 |
if (code != DynObjectManager.NULLCODE) { |
|
44 |
return; |
|
45 |
} |
|
46 |
code = ToolsLocator.getDynObjectManager().registerDynMethod( |
|
47 |
DGNDynClass, |
|
48 |
new DGNGetLegendBuilder() |
|
49 |
); |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
public int getCode() throws DynMethodNotSupportedException { |
|
54 |
return code; |
|
55 |
} |
|
56 |
|
|
57 |
public String getDescription() { |
|
58 |
return "DGN LegendBuilder creator"; |
|
59 |
} |
|
60 |
|
|
61 |
public String getName() { |
|
62 |
return LegendBuilder.DYNMETHOD_BUILDER_NAME; |
|
63 |
} |
|
64 |
|
|
65 |
public Object invoke(Object self, DynObject context) |
|
66 |
throws DynMethodException { |
|
67 |
return new DGNLegendBuilder(); |
|
68 |
} |
|
69 |
|
|
70 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNLegendBuilder.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dgn.legend; |
|
29 |
|
|
30 |
import java.awt.Color; |
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.DataTypes; |
|
33 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
34 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
|
35 |
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider; |
|
36 |
import org.gvsig.fmap.dal.store.dgn.LegendBuilder; |
|
37 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNReader; |
|
38 |
import org.gvsig.fmap.geom.Geometry; |
|
39 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
40 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
41 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend; |
|
42 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
43 |
import org.gvsig.symbology.SymbologyLocator; |
|
44 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.IAttrInTableLabelingStrategy; |
|
45 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
|
46 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
|
47 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
|
48 |
|
|
49 |
public class DGNLegendBuilder implements LegendBuilder { |
|
50 |
|
|
51 |
private MapContextManager mapContextManager = MapContextLocator |
|
52 |
.getMapContextManager(); |
|
53 |
|
|
54 |
private IVectorialUniqueValueLegend defaultLegend = null; |
|
55 |
private IAttrInTableLabelingStrategy labelingStragegy = null; |
|
56 |
|
|
57 |
public void begin() { |
|
58 |
// Nothing to do |
|
59 |
} |
|
60 |
|
|
61 |
public void end() { |
|
62 |
// Nothing to do |
|
63 |
} |
|
64 |
|
|
65 |
public Object getLegend() { |
|
66 |
return defaultLegend; |
|
67 |
} |
|
68 |
|
|
69 |
public LegendBuilder initialize(FeatureStoreProvider store) { |
|
70 |
defaultLegend = (IVectorialUniqueValueLegend) mapContextManager.createLegend( |
|
71 |
IVectorialUniqueValueLegend.LEGEND_NAME); |
|
72 |
defaultLegend.setShapeType(Geometry.TYPES.GEOMETRY); |
|
73 |
defaultLegend |
|
74 |
.setClassifyingFieldNames(new String[] { DGNStoreProvider.NAME_FIELD_COLOR }); |
|
75 |
defaultLegend.setClassifyingFieldTypes(new int[] { DataTypes.INT }); |
|
76 |
|
|
77 |
ISymbol myDefaultSymbol = |
|
78 |
mapContextManager.getSymbolManager() |
|
79 |
.createSymbol(Geometry.TYPES.GEOMETRY); |
|
80 |
|
|
81 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
|
82 |
defaultLegend.useDefaultSymbol(true); |
|
83 |
|
|
84 |
labelingStragegy = SymbologyLocator.getSymbologyManager().createAttrInTableLabelingStrategy(); |
|
85 |
labelingStragegy.setTextField(DGNStoreProvider.NAME_FIELD_TEXT); |
|
86 |
labelingStragegy |
|
87 |
.setRotationField(DGNStoreProvider.NAME_FIELD_ROTATIONTEXT); |
|
88 |
labelingStragegy.setHeightField(DGNStoreProvider.NAME_FIELD_HEIGHTTEXT); |
|
89 |
labelingStragegy.setUnit(1); // MapContext.NAMES[1] (meters) |
|
90 |
return this; |
|
91 |
} |
|
92 |
|
|
93 |
public void process(FeatureProvider feature, DGNReader dgnReader) { |
|
94 |
Integer clave = (Integer) feature.get("Color"); |
|
95 |
if (clave == null) { |
|
96 |
return; |
|
97 |
} |
|
98 |
|
|
99 |
defaultLegend.useDefaultSymbol(false); |
|
100 |
if (defaultLegend.getSymbolByValue(clave) == null) { |
|
101 |
ISymbol theSymbol; |
|
102 |
Color color = dgnReader.DGNLookupColor(clave.intValue()); |
|
103 |
theSymbol = |
|
104 |
mapContextManager.getSymbolManager().createSymbol( |
|
105 |
Geometry.TYPES.GEOMETRY, color); |
|
106 |
|
|
107 |
theSymbol.setDescription(clave.toString()); |
|
108 |
|
|
109 |
if (theSymbol instanceof IMarkerSymbol) { |
|
110 |
((IMarkerSymbol) theSymbol).setSize(1); |
|
111 |
} |
|
112 |
|
|
113 |
if (theSymbol instanceof ILineSymbol) { |
|
114 |
ILineSymbol lineSymbol = (ILineSymbol) theSymbol; |
|
115 |
lineSymbol.setLineWidth(1); |
|
116 |
lineSymbol.setLineColor(color); |
|
117 |
} |
|
118 |
|
|
119 |
if (theSymbol instanceof IFillSymbol) { |
|
120 |
IFillSymbol fillSymbol = (IFillSymbol) theSymbol; |
|
121 |
fillSymbol.getOutline().setLineColor(color); |
|
122 |
fillSymbol.getOutline().setLineWidth(1); |
|
123 |
fillSymbol.setFillColor(null); |
|
124 |
} |
|
125 |
if (theSymbol != null) { |
|
126 |
defaultLegend.addSymbol(clave, theSymbol); |
|
127 |
} |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 |
public Object getLabeling() { |
|
132 |
return labelingStragegy; |
|
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider.legend/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.dgn.provider.legend</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<description>DAL provider for DGN files</description> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.dgn</artifactId> |
|
11 |
<version>2.0.31</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
|
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.dgn.provider</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
|
|
22 |
<dependency> |
|
23 |
<groupId>commons-io</groupId> |
|
24 |
<artifactId>commons-io</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
|
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
56 |
<scope>compile</scope> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>org.gvsig</groupId> |
|
60 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
61 |
<scope>compile</scope> |
|
62 |
</dependency> |
|
63 |
|
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
67 |
<scope>compile</scope> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>org.gvsig</groupId> |
|
76 |
<artifactId>org.gvsig.utils</artifactId> |
|
77 |
<scope>compile</scope> |
|
78 |
</dependency> |
|
79 |
|
|
80 |
|
|
81 |
<!-- TESTS --> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
85 |
<type>test-jar</type> |
|
86 |
<scope>test</scope> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>org.gvsig</groupId> |
|
90 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
91 |
<scope>test</scope> |
|
92 |
</dependency> |
|
93 |
<dependency> |
|
94 |
<groupId>org.gvsig</groupId> |
|
95 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
96 |
<scope>test</scope> |
|
97 |
</dependency> |
|
98 |
<dependency> |
|
99 |
<groupId>org.gvsig</groupId> |
|
100 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
101 |
<scope>test</scope> |
|
102 |
</dependency> |
|
103 |
<dependency> |
|
104 |
<groupId>org.gvsig</groupId> |
|
105 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
106 |
<scope>test</scope> |
|
107 |
</dependency> |
|
108 |
<dependency> |
|
109 |
<groupId>org.gvsig</groupId> |
|
110 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
111 |
<scope>test</scope> |
|
112 |
</dependency> |
|
113 |
|
|
114 |
|
|
115 |
</dependencies> |
|
116 |
|
|
117 |
</project> |
|
0 | 118 |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider/src/test/java/org/gvsig/fmap/dal/store/dgn/TestDGN.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.store.dgn; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.net.URL; |
|
32 |
import org.gvsig.fmap.dal.DALLocator; |
|
33 |
import org.gvsig.fmap.dal.DataManager; |
|
34 |
|
|
35 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
38 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
39 |
|
|
40 |
import static junit.framework.Assert.assertNotNull; |
|
41 |
|
|
42 |
public class TestDGN extends AbstractLibraryAutoInitTestCase { |
|
43 |
|
|
44 |
private File file_prueba = null; |
|
45 |
private DataManager dataManager = null; |
|
46 |
|
|
47 |
@Override |
|
48 |
protected void doSetUp() throws Exception { |
|
49 |
URL res = TestDGN.class.getResource("data/prueba.dgn"); |
|
50 |
this.file_prueba = new File(res.getFile()); |
|
51 |
this.dataManager = DALLocator.getDataManager(); |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
/* |
|
56 |
* (non-Javadoc) |
|
57 |
* |
|
58 |
* @see |
|
59 |
* org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters |
|
60 |
* () |
|
61 |
*/ |
|
62 |
public DataStoreParameters getDefaultDataStoreParameters() |
|
63 |
throws DataException { |
|
64 |
|
|
65 |
DGNStoreParameters dgnParameters = null; |
|
66 |
|
|
67 |
dgnParameters = (DGNStoreParameters) dataManager |
|
68 |
.createStoreParameters(DGNStoreProvider.NAME); |
|
69 |
|
|
70 |
dgnParameters.setFile(file_prueba.getAbsolutePath()); |
|
71 |
dgnParameters.setCRS("EPSG:23030"); |
|
72 |
return dgnParameters; |
|
73 |
} |
|
74 |
|
|
75 |
/* |
|
76 |
* (non-Javadoc) |
|
77 |
* |
|
78 |
* @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer() |
|
79 |
*/ |
|
80 |
public boolean hasExplorer() { |
|
81 |
// TODO Auto-generated method stub |
|
82 |
return false; |
|
83 |
} |
|
84 |
|
|
85 |
public boolean usesResources() { |
|
86 |
return true; |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 |
public void testLegendAndLabeling() throws Exception { |
|
91 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
92 |
DGNStoreProvider.NAME, |
|
93 |
getDefaultDataStoreParameters() |
|
94 |
); |
|
95 |
|
|
96 |
assertNotNull(store.invokeDynMethod("getLegend", null)); |
|
97 |
assertNotNull(store.invokeDynMethod("getLabeling", null)); |
|
98 |
store.dispose(); |
|
99 |
} |
|
100 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/DGNFilesystemServerProvider.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.dgn; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.DALLocator; |
|
6 |
import org.gvsig.fmap.dal.DataManager; |
|
7 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
8 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
9 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
10 |
import org.gvsig.fmap.dal.exception.CreateException; |
|
11 |
import org.gvsig.fmap.dal.exception.DataException; |
|
12 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
13 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
14 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
15 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
16 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
|
17 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
18 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
19 |
|
|
20 |
public class DGNFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider |
|
21 |
implements FilesystemServerExplorerProvider, ResourceConsumer { |
|
22 |
|
|
23 |
// private FilesystemServerExplorerProviderServices serverExplorer; |
|
24 |
|
|
25 |
public String getDataStoreProviderName() { |
|
26 |
return DGNStoreProvider.NAME; |
|
27 |
} |
|
28 |
|
|
29 |
public int getMode() { |
|
30 |
return DataServerExplorer.MODE_FEATURE | DataServerExplorer.MODE_GEOMETRY; |
|
31 |
} |
|
32 |
|
|
33 |
public boolean accept(File pathname) { |
|
34 |
return (pathname.getName().toLowerCase().endsWith(".dgn")); |
|
35 |
} |
|
36 |
|
|
37 |
public String getDescription() { |
|
38 |
return DGNStoreProvider.DESCRIPTION; |
|
39 |
} |
|
40 |
|
|
41 |
public DataStoreParameters getParameters(File file) throws DataException { |
|
42 |
DataManager manager = DALLocator.getDataManager(); |
|
43 |
DGNStoreParameters params = (DGNStoreParameters) manager |
|
44 |
.createStoreParameters(this |
|
45 |
.getDataStoreProviderName()); |
|
46 |
params.setFile(file); |
|
47 |
return params; |
|
48 |
} |
|
49 |
|
|
50 |
public boolean canCreate() { |
|
51 |
return false; |
|
52 |
} |
|
53 |
|
|
54 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
55 |
return this.canCreate(); |
|
56 |
} |
|
57 |
|
|
58 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
|
59 |
throws CreateException { |
|
60 |
throw new UnsupportedOperationException(); |
|
61 |
} |
|
62 |
|
|
63 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
64 |
return null; |
|
65 |
} |
|
66 |
|
|
67 |
public void initialize( |
|
68 |
FilesystemServerExplorerProviderServices serverExplorer) { |
|
69 |
// this.serverExplorer = serverExplorer; |
|
70 |
} |
|
71 |
|
|
72 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
73 |
File file = new File(((DGNStoreParameters) parameters).getFileName()); |
|
74 |
if (!file.exists()) { |
|
75 |
throw new RemoveException(this.getDataStoreProviderName(), |
|
76 |
new FileNotFoundException(file)); |
|
77 |
} |
|
78 |
if (!file.delete()) { |
|
79 |
// FIXME throws ??? |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
83 |
|
|
84 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
85 |
// while it is using a resource anyone can't close it |
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* |
|
92 |
* @see |
|
93 |
* org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org. |
|
94 |
* gvsig.fmap.dal.resource.spi.ResourceProvider) |
|
95 |
*/ |
|
96 |
public void resourceChanged(ResourceProvider resource) { |
|
97 |
//Do nothing |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.31/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/DGNStoreProvider.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.dgn; |
|
2 |
|
|
3 |
import java.awt.geom.AffineTransform; |
|
4 |
import java.awt.geom.Arc2D; |
|
5 |
import java.io.BufferedWriter; |
|
6 |
import java.io.File; |
|
7 |
import java.io.FileWriter; |
|
8 |
import java.io.IOException; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.Date; |
|
11 |
import java.util.HashMap; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
import org.apache.commons.io.IOUtils; |
|
16 |
|
|
17 |
import org.cresques.cts.IProjection; |
|
18 |
import org.gvsig.fmap.dal.DALLocator; |
|
19 |
import org.gvsig.fmap.dal.DataManager; |
|
20 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
21 |
import org.gvsig.fmap.dal.DataStoreNotification; |
|
22 |
import org.gvsig.fmap.dal.DataTypes; |
|
23 |
import org.gvsig.fmap.dal.FileHelper; |
|
24 |
import org.gvsig.fmap.dal.exception.DataException; |
|
25 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
26 |
import org.gvsig.fmap.dal.exception.LoadException; |
|
27 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
28 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
29 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
30 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
31 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
33 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
|
34 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
35 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
|
36 |
import org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider; |
|
37 |
import org.gvsig.fmap.dal.resource.ResourceAction; |
|
38 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
39 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
|
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.FilesystemServerExplorer; |
|
43 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
44 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
45 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNElemArc; |
|
46 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNElemComplexHeader; |
|
47 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNElemCore; |
|
48 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNElemMultiPoint; |
|
49 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNElemText; |
|
50 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNFileHeader; |
|
51 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNLink; |
|
52 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNPoint; |
|
53 |
import org.gvsig.fmap.dal.store.dgn.lib.DGNReader; |
|
54 |
import org.gvsig.fmap.geom.Geometry; |
|
55 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
56 |
import org.gvsig.fmap.geom.GeometryManager; |
|
57 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
58 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
59 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
60 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
61 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
62 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
63 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
|
64 |
import org.gvsig.fmap.geom.primitive.Point; |
|
65 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
66 |
import org.slf4j.Logger; |
|
67 |
import org.slf4j.LoggerFactory; |
|
68 |
|
|
69 |
public class DGNStoreProvider extends AbstractMemoryStoreProvider implements |
|
70 |
ResourceConsumer { |
|
71 |
|
|
72 |
private static final Logger logger = LoggerFactory.getLogger(DGNStoreProvider.class); |
|
73 |
|
|
74 |
public static final String NAME = "DGN"; |
|
75 |
public static final String DESCRIPTION = "DGN file"; |
|
76 |
|
|
77 |
public static final String METADATA_DEFINITION_NAME = NAME; |
|
78 |
public static final String METADATA_DEFINITION_DESCRIPTION = "DGN File Store"; |
|
79 |
|
|
80 |
public static final int LOAD_MODE_PLAIN = 0; |
|
81 |
public static final int LOAD_MODE_GROUP1 = 1; |
|
82 |
|
|
83 |
public static final int CROP_OPERATION_NONE = 0; |
|
84 |
public static final int CROP_OPERATION_CONTAINS = 1; |
|
85 |
public static final int CROP_OPERATION_COVERS = 2; |
|
86 |
public static final int CROP_OPERATION_COVEREDBY = 3; |
|
87 |
public static final int CROP_OPERATION_CROSSES = 4; |
|
88 |
public static final int CROP_OPERATION_DISJOINT = 5; |
|
89 |
public static final int CROP_OPERATION_INTERSECT = 6; |
|
90 |
public static final int CROP_OPERATION_OVERLAPS = 7; |
|
91 |
public static final int CROP_OPERATION_TOUCHES = 8; |
|
92 |
public static final int CROP_OPERATION_WITHIN = 9; |
|
93 |
|
|
94 |
public static final int GROUP_GEOMETRIES_NONE = 0; |
|
95 |
public static final int GROUP_GEOMETRIES_CONVEXHULL = 1; |
|
96 |
public static final int GROUP_GEOMETRIES_UNION = 2; |
|
97 |
public static final int GROUP_GEOMETRIES_INTERSECTION = 3; |
|
98 |
public static final int GROUP_GEOMETRIES_TOPOINTS = 4; |
|
99 |
public static final int GROUP_GEOMETRIES_TOLINES = 5; |
|
100 |
public static final int GROUP_GEOMETRIES_TOPOLYGONS = 6; |
|
101 |
public static final int GROUP_GEOMETRIES_TOPOLYGONS_FIX = 7; |
|
102 |
|
|
103 |
public static final String NAME_FIELD_ID = "ID"; |
|
104 |
public static final String NAME_FIELD_GEOMETRY = "Geometry"; |
|
105 |
public static final String NAME_FIELD_TYPE = "Type"; |
|
106 |
public static final String NAME_FIELD_STYPE = "SType"; |
|
107 |
public static final String NAME_FIELD_ENTITY = "Entity"; |
|
108 |
public static final String NAME_FIELD_LEVEL = "Layer"; |
|
109 |
public static final String NAME_FIELD_COLOR = "Color"; |
|
110 |
public static final String NAME_FIELD_FILLCOLOR = "FillColor"; |
|
111 |
public static final String NAME_FIELD_ELEVATION = "Elevation"; |
|
112 |
public static final String NAME_FIELD_WEIGHT = "Weight"; |
|
113 |
public static final String NAME_FIELD_TEXT = "Text"; |
|
114 |
public static final String NAME_FIELD_HEIGHTTEXT = "HeightText"; |
|
115 |
public static final String NAME_FIELD_HEIGHTTEXTRAW = "HeightTextRaw"; |
|
116 |
public static final String NAME_FIELD_ROTATIONTEXT = "Rotation"; |
|
117 |
public static final String NAME_FIELD_STYLE = "Style"; |
|
118 |
public static final String NAME_FIELD_GROUP = "Group"; |
|
119 |
public static final String NAME_FIELD_ISSHAPE = "IsShape"; |
|
120 |
public static final String NAME_FIELD_ISCOMPLEXSHAPEHEADER = "IsComplexShapeHeader"; |
|
121 |
public static final String NAME_FIELD_ISHOLE = "IsHole"; |
|
122 |
public static final String NAME_FIELD_ISCOMPLEX = "IsComplex"; |
|
123 |
public static final String NAME_FIELD_PARENTID = "ParentId"; |
|
124 |
public static final String NAME_FIELD_SCALE = "Scale"; |
|
125 |
public static final String NAME_FIELD_LINKS_COUNT = "LinksCount"; |
|
126 |
public static final String NAME_FIELD_LINK_INDEX = "LinkIndex"; |
|
127 |
public static final String NAME_FIELD_LINK_TYPE = "LinkType"; |
|
128 |
public static final String NAME_FIELD_LINK_ENTITY = "LinkEntity"; |
|
129 |
public static final String NAME_FIELD_LINK_MS = "LinkMS"; |
|
130 |
public static final String NAME_FIELD_LINK_LENGTH = "LinkLength"; |
|
131 |
public static final String NAME_FIELD_LINK_DATA = "LinkData"; |
|
132 |
public static final String NAME_FIELD_DATA = "Data"; |
|
133 |
|
|
134 |
private int ID_FIELD_ID; |
|
135 |
private int ID_FIELD_TYPE; |
|
136 |
private int ID_FIELD_STYPE; |
|
137 |
private int ID_FIELD_ENTITY; |
|
138 |
private int ID_FIELD_LEVEL; |
|
139 |
private int ID_FIELD_COLOR; |
|
140 |
private int ID_FIELD_FILLCOLOR; |
|
141 |
private int ID_FIELD_ELEVATION; |
|
142 |
private int ID_FIELD_WEIGHT; |
|
143 |
private int ID_FIELD_TEXT; |
|
144 |
private int ID_FIELD_HEIGHTTEXT; |
|
145 |
private int ID_FIELD_HEIGHTTEXTRAW; |
|
146 |
private int ID_FIELD_ROTATIONTEXT; |
|
147 |
private int ID_FIELD_STYLE; |
|
148 |
private int ID_FIELD_GROUP; |
|
149 |
private int ID_FIELD_LAYER; |
|
150 |
private int ID_FIELD_ISCOMPLEXSHAPEHEADER; |
|
151 |
private int ID_FIELD_ISSHAPE; |
|
152 |
private int ID_FIELD_ISHOLE; |
|
153 |
private int ID_FIELD_ISCOMPLEX; |
|
154 |
private int ID_FIELD_PARENT; |
|
155 |
private int ID_FIELD_SCALE; |
|
156 |
private int ID_FIELD_LINKS_COUNT; |
|
157 |
private int ID_FIELD_LINK_INDEX; |
|
158 |
private int ID_FIELD_LINK_TYPE; |
|
159 |
private int ID_FIELD_LINK_ENTITY; |
|
160 |
private int ID_FIELD_LINK_MS; |
|
161 |
private int ID_FIELD_LINK_LENGTH; |
|
162 |
private int ID_FIELD_LINK_DATA; |
|
163 |
private int ID_FIELD_DATA; |
|
164 |
private int ID_FIELD_GEOMETRY; |
|
165 |
private int MAX_FIELD_ID; |
|
166 |
|
|
167 |
private IProjection projection; |
|
168 |
private ResourceProvider resource; |
|
169 |
private LegendBuilder legendBuilder; |
|
170 |
|
|
171 |
private long counterNewsOIDs = 0; |
|
172 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
173 |
|
|
174 |
private int groupByFieldIndex = -2; |
|
175 |
private Map<Object, FeatureProvider> groupedFeatures = null; |
|
176 |
|
|
177 |
DGNData dgndata = null; |
|
178 |
|
|
179 |
public DGNStoreProvider(DGNStoreParameters parameters, |
|
180 |
DataStoreProviderServices storeServices) throws InitializeException { |
|
181 |
super( |
|
182 |
parameters, |
|
183 |
storeServices, |
|
184 |
FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME) |
|
185 |
); |
|
186 |
|
|
187 |
counterNewsOIDs = 0; |
|
188 |
// projection = CRSFactory.getCRS(getParameters().getSRSID()); |
|
189 |
|
|
190 |
File file = getDGNParameters().getFile(); |
|
191 |
resource = this.createResource( |
|
192 |
FileResource.NAME, |
|
193 |
new Object[]{file.getAbsolutePath()} |
|
194 |
); |
|
195 |
|
|
196 |
resource.addConsumer(this); |
|
197 |
|
|
198 |
this.projection = this.getDGNParameters().getCRS(); |
|
199 |
|
|
200 |
try { |
|
201 |
legendBuilder = (LegendBuilder) this.invokeDynMethod( |
|
202 |
LegendBuilder.DYNMETHOD_BUILDER_NAME, null); |
|
203 |
} catch (DynMethodException e) { |
|
204 |
legendBuilder = null; |
|
205 |
} catch (Exception e) { |
|
206 |
throw new InitializeException(e); |
|
207 |
} |
|
208 |
|
|
209 |
this.initializeFeatureTypes(); |
|
210 |
|
|
211 |
} |
|
212 |
|
|
213 |
private DGNStoreParameters getDGNParameters() { |
|
214 |
return (DGNStoreParameters) this.getParameters(); |
|
215 |
} |
|
216 |
|
|
217 |
public String getProviderName() { |
|
218 |
return NAME; |
|
219 |
} |
|
220 |
|
|
221 |
public boolean allowWrite() { |
|
222 |
// not yet |
|
223 |
return false; |
|
224 |
} |
|
225 |
|
|
226 |
public Object getLegend() throws OpenException { |
|
227 |
this.open(); |
|
228 |
if (legendBuilder == null) { |
|
229 |
return null; |
|
230 |
} |
|
231 |
return legendBuilder.getLegend(); |
|
232 |
} |
|
233 |
|
|
234 |
public Object getLabeling() throws OpenException { |
|
235 |
this.open(); |
|
236 |
if (legendBuilder == null) { |
|
237 |
return null; |
|
238 |
} |
|
239 |
return legendBuilder.getLabeling(); |
|
240 |
} |
|
241 |
|
|
242 |
private class DGNData { |
|
243 |
|
|
244 |
public List data = null; |
|
245 |
public FeatureType defaultFType = null; |
|
246 |
public List fTypes = null; |
|
247 |
public Envelope envelope = null; |
|
248 |
public IProjection projection; |
|
249 |
public LegendBuilder legendBuilder; |
|
250 |
|
|
251 |
public Envelope getEnvelopeCopy() throws CreateEnvelopeException { |
|
252 |
if (envelope == null) { |
|
253 |
return null; |
|
254 |
} |
|
255 |
try { |
|
256 |
return (Envelope) envelope.clone(); |
|
257 |
} catch (CloneNotSupportedException ex) { |
|
258 |
logger.warn("Can't clone envelope.", ex); |
|
259 |
return null; |
|
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
public static class TimeCounter { |
|
265 |
private static final Logger logger = LoggerFactory.getLogger(TimeCounter.class); |
|
266 |
|
|
267 |
private long counter = 0; |
|
268 |
private Date t1; |
|
269 |
private Date t2; |
|
270 |
|
|
271 |
public void start() { |
|
272 |
this.t1 = new Date(); |
|
273 |
this.t2 = this.t1; |
|
274 |
} |
|
275 |
|
|
276 |
public void restart() { |
|
277 |
this.t1 = new Date(); |
|
278 |
this.t2 = this.t1; |
|
279 |
this.counter = 0; |
|
280 |
} |
|
281 |
|
|
282 |
public void stop() { |
|
283 |
this.t2 = new Date(); |
|
284 |
this.counter += this.t2.getTime()- this.t1.getTime(); |
|
285 |
} |
|
286 |
public long get() { |
|
287 |
return this.counter; |
|
288 |
} |
|
289 |
public void log(String msg) { |
|
290 |
logger.debug("Time "+get()+" ms. " + msg); |
|
291 |
} |
|
292 |
public void restart(String msg) { |
|
293 |
this.stop(); |
|
294 |
this.log(msg); |
|
295 |
this.restart(); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
public void open() throws OpenException { |
|
300 |
if (this.data != null) { |
|
301 |
return; |
|
302 |
} |
|
303 |
try { |
|
304 |
getResource().execute(new ResourceAction() { |
|
305 |
public Object run() throws Exception { |
|
306 |
|
|
307 |
TimeCounter tc = new TimeCounter(); |
|
308 |
tc.start(); |
|
309 |
|
|
310 |
FeatureStoreProviderServices store = getStoreServices(); |
|
311 |
if (dgndata == null |
|
312 |
&& !(getDGNParameters().useReload())) { |
|
313 |
if (resource.getData() != null) { |
|
314 |
dgndata = (DGNData) ((Map) resource.getData()).get(projection.getAbrev()); // OJO |
|
315 |
// no es del todo correcto (puede llevar reproyeccion) |
|
316 |
} else { |
|
317 |
resource.setData(new HashMap()); |
|
318 |
} |
|
319 |
} |
|
320 |
tc.restart("Retrive data from resource (data="+dgndata+")"); |
|
321 |
|
|
322 |
if (dgndata == null) { |
|
323 |
dgndata = new DGNData(); |
|
324 |
dgndata.data = new ArrayList(); |
|
325 |
data = dgndata.data; |
|
326 |
counterNewsOIDs = 0; |
|
327 |
Reader reader = new Reader().initialice( |
|
328 |
getMemoryProvider(), |
|
329 |
(File) resource.get(), |
|
330 |
projection, legendBuilder); |
|
331 |
reader.begin(store); |
|
332 |
dgndata.defaultFType = reader.getDefaultType().getNotEditableCopy(); |
|
333 |
List types = new ArrayList(); |
|
334 |
Iterator it = reader.getTypes().iterator(); |
|
335 |
EditableFeatureType fType; |
|
336 |
while (it.hasNext()) { |
|
337 |
fType = (EditableFeatureType) it.next(); |
|
338 |
if (fType.getId().equals( |
|
339 |
dgndata.defaultFType.getId())) { |
|
340 |
types.add(dgndata.defaultFType); |
|
341 |
} else { |
|
342 |
types.add(fType.getNotEditableCopy()); |
|
343 |
} |
|
344 |
} |
|
345 |
dgndata.fTypes = types; |
|
346 |
|
|
347 |
resource.notifyOpen(); |
|
348 |
store.setFeatureTypes(dgndata.fTypes, |
|
349 |
dgndata.defaultFType); |
|
350 |
reader.load(); |
|
351 |
dgndata.envelope = reader.getEnvelope(); |
|
352 |
dgndata.legendBuilder = legendBuilder; |
|
353 |
dgndata.projection = projection; |
|
354 |
reader.end(); |
|
355 |
if (resource.getData() == null) { |
|
356 |
resource.setData(new HashMap()); |
|
357 |
} |
|
358 |
((Map) resource.getData()).put( |
|
359 |
projection.getAbrev(), |
|
360 |
dgndata); // OJO la reproyeccion |
|
361 |
tc.restart("Loaded data from file (data="+dgndata+")"); |
|
362 |
resource.notifyClose(); |
|
363 |
} |
|
364 |
// El feature type no lo compartimos entre las instancias del |
|
365 |
// mismo resource ya que puede cambiar en funcion del filtro. |
|
366 |
// Por lo menos el geometry-type. |
|
367 |
List<FeatureType> featureTypes = getFeatureTypes(store); |
|
368 |
|
|
369 |
tc.restart("Created featuretype (featureTypes="+featureTypes+")"); |
|
370 |
|
|
371 |
PostProcessFeatures postProcess = new PostProcessFeatures( |
|
372 |
getDGNParameters(), |
|
373 |
featureTypes.get(0) |
|
374 |
); |
|
375 |
if (postProcess.hasOperations()) { |
|
376 |
data = postProcess.apply(dgndata.data); |
|
377 |
setDynValue("Envelope", postProcess.getEnvelope()); |
|
378 |
} else { |
|
379 |
data = dgndata.data; |
|
380 |
setDynValue("Envelope", dgndata.getEnvelopeCopy()); |
|
381 |
} |
|
382 |
tc.restart("PostProcessFeatures"); |
|
383 |
|
|
384 |
legendBuilder = dgndata.legendBuilder; |
|
385 |
store.setFeatureTypes(featureTypes, featureTypes.get(0)); |
|
386 |
setDynValue("CRS", projection); |
|
387 |
counterNewsOIDs = data.size(); |
|
388 |
tc.restart("load finished."); |
|
389 |
return null; |
|
390 |
} |
|
391 |
}); |
|
392 |
} catch (Exception e) { |
|
393 |
data = null; |
|
394 |
try { |
|
395 |
throw new OpenException(resource.getName(), e); |
|
396 |
} catch (AccessResourceException e1) { |
|
397 |
throw new OpenException(getProviderName(), e); |
|
398 |
} |
|
399 |
} |
|
400 |
} |
|
401 |
|
|
402 |
public DataServerExplorer getExplorer() throws ReadException { |
|
403 |
DataManager manager = DALLocator.getDataManager(); |
|
404 |
FilesystemServerExplorerParameters params; |
|
405 |
try { |
|
406 |
params = (FilesystemServerExplorerParameters) manager |
|
407 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
408 |
params.setRoot(this.getDGNParameters().getFile().getParent()); |
|
409 |
return manager.openServerExplorer(FilesystemServerExplorer.NAME, params); |
|
410 |
} catch (DataException e) { |
|
411 |
throw new ReadException(this.getProviderName(), e); |
|
412 |
} catch (ValidateDataParametersException e) { |
|
413 |
throw new ReadException(this.getProviderName(), e); |
|
414 |
} |
|
415 |
|
|
416 |
} |
|
417 |
|
|
418 |
public void performChanges(Iterator deleteds, Iterator inserteds, Iterator updateds, Iterator originalFeatureTypesUpdated) throws PerformEditingException { |
|
419 |
// FIXME Exception |
|
420 |
throw new UnsupportedOperationException(); |
|
421 |
} |
|
422 |
|
|
423 |
public List getFeatureTypes(FeatureStoreProviderServices store) { |
|
424 |
EditableFeatureType featureType = store.createFeatureType(getName()); |
|
425 |
|
|
426 |
featureType.setHasOID(true); |
|
427 |
|
|
428 |
ID_FIELD_ID = featureType.add(NAME_FIELD_ID, DataTypes.INT) |
|
429 |
.setDefaultValue(Integer.valueOf(0)) |
|
430 |
.getIndex(); |
|
431 |
|
|
432 |
ID_FIELD_PARENT = featureType.add(NAME_FIELD_PARENTID, DataTypes.INT) |
|
433 |
.setDefaultValue(Integer.valueOf(0)) |
|
434 |
.getIndex(); |
|
435 |
|
|
436 |
// FIXME: Cual es el size y el valor por defecto para Entity ? |
|
437 |
ID_FIELD_ENTITY = featureType.add(NAME_FIELD_ENTITY, DataTypes.STRING, 100) |
|
438 |
.setDefaultValue("") |
|
439 |
.getIndex(); |
|
440 |
|
|
441 |
// FIXME: Cual es el size de Layer ? |
|
442 |
ID_FIELD_LEVEL = featureType.add(NAME_FIELD_LEVEL, DataTypes.STRING, 100) |
|
443 |
.setDefaultValue("default") |
|
444 |
.getIndex(); |
|
445 |
ID_FIELD_LAYER = ID_FIELD_LEVEL; |
|
446 |
|
|
447 |
ID_FIELD_COLOR = featureType.add(NAME_FIELD_COLOR, DataTypes.INT) |
|
448 |
.setDefaultValue(Integer.valueOf(0)) |
|
449 |
.getIndex(); |
|
450 |
|
|
451 |
// FIXME: Cual es el size de Text ? |
|
452 |
ID_FIELD_TEXT = featureType.add(NAME_FIELD_TEXT, DataTypes.STRING, 100) |
|
453 |
.setDefaultValue("") |
|
454 |
.getIndex(); |
|
455 |
|
|
456 |
ID_FIELD_HEIGHTTEXT = featureType.add(NAME_FIELD_HEIGHTTEXT, DataTypes.DOUBLE) |
|
457 |
.setDefaultValue(Double.valueOf(10)) |
|
458 |
.getIndex(); |
|
459 |
|
|
460 |
ID_FIELD_HEIGHTTEXTRAW = featureType.add(NAME_FIELD_HEIGHTTEXTRAW, DataTypes.DOUBLE) |
|
461 |
.setDefaultValue(Double.valueOf(10)) |
|
462 |
.getIndex(); |
|
463 |
|
|
464 |
ID_FIELD_ROTATIONTEXT = featureType.add(NAME_FIELD_ROTATIONTEXT, DataTypes.DOUBLE) |
|
465 |
.setDefaultValue(Double.valueOf(0)) |
|
466 |
.getIndex(); |
|
467 |
|
|
468 |
ID_FIELD_TYPE = featureType.add(NAME_FIELD_TYPE, DataTypes.INT) |
|
469 |
.setDefaultValue(Integer.valueOf(0)) |
|
470 |
.getIndex(); |
|
471 |
|
|
472 |
ID_FIELD_STYPE = featureType.add(NAME_FIELD_STYPE, DataTypes.INT) |
|
473 |
.setDefaultValue(Integer.valueOf(0)) |
|
474 |
.getIndex(); |
|
475 |
|
|
476 |
ID_FIELD_FILLCOLOR = featureType.add(NAME_FIELD_FILLCOLOR, DataTypes.INT) |
|
477 |
.setDefaultValue(Integer.valueOf(0)) |
|
478 |
.getIndex(); |
|
479 |
|
|
480 |
ID_FIELD_STYLE = featureType.add(NAME_FIELD_STYLE, DataTypes.INT) |
|
481 |
.setDefaultValue(Integer.valueOf(0)) |
|
482 |
.getIndex(); |
|
483 |
|
|
484 |
ID_FIELD_ELEVATION = featureType.add(NAME_FIELD_ELEVATION, DataTypes.DOUBLE) |
|
485 |
.setDefaultValue(Double.valueOf(0)) |
|
486 |
.getIndex(); |
|
487 |
|
|
488 |
ID_FIELD_WEIGHT = featureType.add(NAME_FIELD_WEIGHT, DataTypes.DOUBLE) |
|
489 |
.setDefaultValue(Double.valueOf(0)) |
|
490 |
.getIndex(); |
|
491 |
|
|
492 |
ID_FIELD_GROUP = featureType.add(NAME_FIELD_GROUP, DataTypes.INT) |
|
493 |
.setDefaultValue(Integer.valueOf(0)) |
|
494 |
.getIndex(); |
|
495 |
|
|
496 |
ID_FIELD_ISSHAPE = featureType.add(NAME_FIELD_ISSHAPE, DataTypes.BOOLEAN) |
|
497 |
.setDefaultValue(Boolean.FALSE) |
|
498 |
.getIndex(); |
|
499 |
|
|
500 |
ID_FIELD_ISCOMPLEXSHAPEHEADER = featureType.add(NAME_FIELD_ISCOMPLEXSHAPEHEADER, DataTypes.BOOLEAN) |
|
501 |
.setDefaultValue(Boolean.FALSE) |
|
502 |
.getIndex(); |
|
503 |
|
|
504 |
ID_FIELD_ISHOLE = featureType.add(NAME_FIELD_ISHOLE, DataTypes.BOOLEAN) |
|
505 |
.setDefaultValue(Boolean.FALSE) |
|
506 |
.getIndex(); |
|
507 |
|
|
508 |
ID_FIELD_ISCOMPLEX = featureType.add(NAME_FIELD_ISCOMPLEX, DataTypes.BOOLEAN) |
|
509 |
.setDefaultValue(Boolean.FALSE) |
|
510 |
.getIndex(); |
|
511 |
|
|
512 |
ID_FIELD_SCALE = featureType.add(NAME_FIELD_SCALE, DataTypes.INT) |
|
513 |
.setDefaultValue(Integer.valueOf(0)) |
|
514 |
.getIndex(); |
|
515 |
|
|
516 |
ID_FIELD_LINKS_COUNT = featureType.add(NAME_FIELD_LINKS_COUNT, DataTypes.INT) |
|
517 |
.setDefaultValue(Integer.valueOf(0)) |
|
518 |
.getIndex(); |
|
519 |
|
|
520 |
ID_FIELD_LINK_INDEX = featureType.add(NAME_FIELD_LINK_INDEX, DataTypes.INT) |
|
521 |
.setDefaultValue(Integer.valueOf(0)) |
|
522 |
.getIndex(); |
|
523 |
|
|
524 |
ID_FIELD_LINK_ENTITY = featureType.add(NAME_FIELD_LINK_ENTITY, DataTypes.INT) |
|
525 |
.setDefaultValue(Integer.valueOf(0)) |
|
526 |
.getIndex(); |
|
527 |
|
|
528 |
ID_FIELD_LINK_TYPE = featureType.add(NAME_FIELD_LINK_TYPE, DataTypes.INT) |
|
529 |
.setDefaultValue(Integer.valueOf(0)) |
|
530 |
.getIndex(); |
|
531 |
|
|
532 |
ID_FIELD_LINK_MS = featureType.add(NAME_FIELD_LINK_MS, DataTypes.INT) |
|
533 |
.setDefaultValue(Integer.valueOf(0)) |
|
534 |
.getIndex(); |
|
535 |
|
|
536 |
ID_FIELD_LINK_LENGTH = featureType.add(NAME_FIELD_LINK_LENGTH, DataTypes.INT) |
|
537 |
.setDefaultValue(Integer.valueOf(0)) |
|
538 |
.getIndex(); |
|
539 |
|
|
540 |
ID_FIELD_LINK_DATA = featureType.add(NAME_FIELD_LINK_DATA, DataTypes.STRING, 512) |
|
541 |
.setDefaultValue("") |
|
542 |
.getIndex(); |
|
543 |
|
|
544 |
ID_FIELD_DATA = featureType.add(NAME_FIELD_DATA, DataTypes.STRING, 512) |
|
545 |
.setDefaultValue("") |
|
546 |
.getIndex(); |
|
547 |
|
|
548 |
EditableFeatureAttributeDescriptor attr = featureType.add(NAME_FIELD_GEOMETRY, DataTypes.GEOMETRY); |
|
549 |
attr.setSRS(this.projection); |
|
550 |
int geometryTypeToUse = getDGNParameters().getGeometryTypeFilter(); |
|
551 |
if (getDGNParameters().getGroupBy() != null) { |
|
552 |
switch (getDGNParameters().getGroupGeometriesOperation()) { |
|
553 |
case GROUP_GEOMETRIES_NONE: |
|
554 |
case GROUP_GEOMETRIES_UNION: |
|
555 |
case GROUP_GEOMETRIES_INTERSECTION: |
|
556 |
break; |
|
557 |
case GROUP_GEOMETRIES_TOPOINTS: |
|
558 |
geometryTypeToUse = Geometry.TYPES.MULTIPOINT; |
|
559 |
break; |
|
560 |
case GROUP_GEOMETRIES_TOLINES: |
|
561 |
geometryTypeToUse = Geometry.TYPES.MULTICURVE; |
|
562 |
break; |
|
563 |
case GROUP_GEOMETRIES_TOPOLYGONS: |
|
564 |
case GROUP_GEOMETRIES_TOPOLYGONS_FIX: |
|
565 |
case GROUP_GEOMETRIES_CONVEXHULL: |
|
566 |
geometryTypeToUse = Geometry.TYPES.MULTISURFACE; |
|
567 |
break; |
|
568 |
} |
|
569 |
} |
|
570 |
attr.setGeometryType(geometryTypeToUse); |
|
571 |
attr.setGeometrySubType(Geometry.SUBTYPES.GEOM3D); |
|
572 |
ID_FIELD_GEOMETRY = attr.getIndex(); |
|
573 |
|
|
574 |
featureType.setDefaultGeometryAttributeName(NAME_FIELD_GEOMETRY); |
|
575 |
|
|
576 |
MAX_FIELD_ID = featureType.size() - 1; |
|
577 |
|
|
578 |
List types = new ArrayList(); |
|
579 |
types.add(featureType); |
|
580 |
|
|
581 |
return types; |
|
582 |
} |
|
583 |
|
|
584 |
public class Reader { |
|
585 |
|
|
586 |
private File file; |
|
587 |
private IProjection projection; |
|
588 |
private List types; |
|
589 |
private LegendBuilder leyendBuilder; |
|
590 |
private AbstractMemoryStoreProvider store; |
|
591 |
private Envelope envelope; |
|
592 |
|
|
593 |
public Reader initialice(AbstractMemoryStoreProvider store, File file, |
|
594 |
IProjection projection, |
|
595 |
LegendBuilder leyendBuilder) { |
|
596 |
this.store = store; |
|
597 |
this.file = file; |
|
598 |
this.projection = projection; |
|
599 |
this.leyendBuilder = leyendBuilder; |
|
600 |
if (leyendBuilder != null) { |
|
601 |
leyendBuilder.initialize(store); |
|
602 |
} |
|
603 |
return this; |
|
604 |
} |
|
605 |
|
|
606 |
public Envelope getEnvelope() { |
|
607 |
return this.envelope; |
|
608 |
} |
|
609 |
|
|
610 |
public void begin(FeatureStoreProviderServices store) { |
|
611 |
|
|
612 |
types = getFeatureTypes(store); |
|
613 |
|
|
614 |
if (leyendBuilder != null) { |
|
615 |
leyendBuilder.begin(); |
|
616 |
} |
|
617 |
|
|
618 |
} |
|
619 |
|
|
620 |
public void end() { |
|
621 |
if (leyendBuilder != null) { |
|
622 |
leyendBuilder.end(); |
|
623 |
} |
|
624 |
} |
|
625 |
|
|
626 |
public List getTypes() { |
|
627 |
return types; |
|
628 |
} |
|
629 |
|
|
630 |
public EditableFeatureType getDefaultType() { |
|
631 |
return (EditableFeatureType) types.get(0); |
|
632 |
} |
|
633 |
|
|
634 |
// private Double toDouble(String value) { |
|
635 |
// if (value == null) { |
|
636 |
// return Double.valueOf(0); |
|
637 |
// } |
|
638 |
// return Double.valueOf(value); |
|
639 |
// } |
|
640 |
public void load() throws DataException, CreateEnvelopeException { |
|
641 |
switch (getDGNParameters().getLoadMode()) { |
|
642 |
case LOAD_MODE_PLAIN: |
|
643 |
default: |
|
644 |
load_plain(); |
|
645 |
break; |
|
646 |
case LOAD_MODE_GROUP1: |
|
647 |
load_group1(); |
|
648 |
break; |
|
649 |
} |
|
650 |
} |
|
651 |
|
|
652 |
public void load_plain() throws DataException { |
|
653 |
|
|
654 |
FileWriter xmlfw = null; |
|
655 |
BufferedWriter xmlbfw = null; |
|
656 |
|
|
657 |
this.envelope = null; |
|
658 |
|
|
659 |
boolean ignoreZs = getDGNParameters().ignoreZs(); |
|
660 |
boolean useZAsElevation = getDGNParameters().useZAsElevation(); |
|
661 |
boolean applyRoundToElevation = getDGNParameters().getApplyRoundToElevation(); |
|
662 |
double elevationFactor = getDGNParameters().geElevationFactor(); |
|
663 |
|
|
664 |
try { |
|
665 |
if (getDGNParameters().getXMLFile() != null) { |
|
666 |
File xmlfile = getDGNParameters().getXMLFile(); |
|
667 |
try { |
|
668 |
xmlfw = new FileWriter(xmlfile); |
|
669 |
xmlbfw = new BufferedWriter(xmlfw); |
|
670 |
|
|
671 |
} catch (Exception ex) { |
|
672 |
xmlfw = null; |
|
673 |
xmlbfw = null; |
|
674 |
logger.warn("Can't open xmfile for output (" + xmlfile.getAbsolutePath() + "'.", ex); |
|
675 |
} |
|
676 |
if (xmlbfw != null) { |
|
677 |
try { |
|
678 |
xmlbfw.write("<DGN>\n"); |
|
679 |
} catch (IOException ex) { |
|
680 |
logger.warn("Can't write to the xml file.", ex); |
|
681 |
} |
|
682 |
} |
|
683 |
|
|
684 |
} |
|
685 |
|
|
686 |
DGNReader dgnReader = new DGNReader(file.getAbsolutePath(), getDGNParameters().logErrors()); |
|
687 |
|
|
688 |
if (dgnReader.getInfo().dimension == 2 || getDGNParameters().ignoreZs()) { |
|
689 |
envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D); |
|
690 |
} else { |
|
691 |
envelope = geomManager.createEnvelope(SUBTYPES.GEOM3D); |
|
692 |
} |
Also available in: Unified diff