Revision 921
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.189/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.189/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.AbstractDynMethod; |
|
33 |
import org.gvsig.tools.dynobject.DynClass; |
|
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 extends AbstractDynMethod { |
|
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 DGNGetLegendBuilder() { |
|
54 |
super(LegendBuilder.DYNMETHOD_BUILDER_NAME,"DGN LegendBuilder creator"); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public int getCode() throws DynMethodNotSupportedException { |
|
59 |
return code; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public Object invoke(DynObject self, Object[] args) |
|
64 |
throws DynMethodException { |
|
65 |
return new DGNLegendBuilder(); |
|
66 |
} |
|
67 |
|
|
68 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.189/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 |
|
|
83 |
labelingStragegy = SymbologyLocator.getSymbologyManager().createAttrInTableLabelingStrategy(); |
|
84 |
labelingStragegy.setTextField(DGNStoreProvider.NAME_FIELD_TEXT); |
|
85 |
labelingStragegy |
|
86 |
.setRotationField(DGNStoreProvider.NAME_FIELD_ROTATIONTEXT); |
|
87 |
labelingStragegy.setHeightField(DGNStoreProvider.NAME_FIELD_HEIGHTTEXT); |
|
88 |
labelingStragegy.setUnit(1); // MapContext.NAMES[1] (meters) |
|
89 |
return this; |
|
90 |
} |
|
91 |
|
|
92 |
public void process(FeatureProvider feature, DGNReader dgnReader) { |
|
93 |
Integer clave = (Integer) feature.get("Color"); |
|
94 |
if (clave == null) { |
|
95 |
return; |
|
96 |
} |
|
97 |
|
|
98 |
defaultLegend.useDefaultSymbol(false); |
|
99 |
if (defaultLegend.getSymbolByValue(clave) == null) { |
|
100 |
ISymbol theSymbol; |
|
101 |
Color color = dgnReader.DGNLookupColor(clave.intValue()); |
|
102 |
theSymbol = |
|
103 |
mapContextManager.getSymbolManager().createSymbol( |
|
104 |
Geometry.TYPES.GEOMETRY, color); |
|
105 |
|
|
106 |
theSymbol.setDescription(clave.toString()); |
|
107 |
|
|
108 |
if (theSymbol instanceof IMarkerSymbol) { |
|
109 |
((IMarkerSymbol) theSymbol).setSize(1); |
|
110 |
} |
|
111 |
|
|
112 |
if (theSymbol instanceof ILineSymbol) { |
|
113 |
ILineSymbol lineSymbol = (ILineSymbol) theSymbol; |
|
114 |
lineSymbol.setLineWidth(1); |
|
115 |
lineSymbol.setLineColor(color); |
|
116 |
} |
|
117 |
|
|
118 |
if (theSymbol instanceof IFillSymbol) { |
|
119 |
IFillSymbol fillSymbol = (IFillSymbol) theSymbol; |
|
120 |
fillSymbol.getOutline().setLineColor(color); |
|
121 |
fillSymbol.getOutline().setLineWidth(1); |
|
122 |
fillSymbol.setFillColor(null); |
|
123 |
} |
|
124 |
if (theSymbol != null) { |
|
125 |
defaultLegend.addSymbol(clave, theSymbol); |
|
126 |
} |
|
127 |
} |
|
128 |
defaultLegend.useDefaultSymbol(true); |
|
129 |
} |
|
130 |
|
|
131 |
public Object getLabeling() { |
|
132 |
return labelingStragegy; |
|
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.189/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.AbstractDynMethod; |
|
35 |
import org.gvsig.tools.dynobject.DynClass; |
|
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 extends AbstractDynMethod { |
|
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 |
|
|
55 |
public DGNGetLabeling() { |
|
56 |
super(LegendBuilder.DYNMETHOD_GETLABELING_NAME,"DGN Labeling"); |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public int getCode() throws DynMethodNotSupportedException { |
|
61 |
return code; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public Object invoke(DynObject self, Object[] args) |
|
66 |
throws DynMethodException { |
|
67 |
try { |
|
68 |
return ((DGNStoreProvider) self).getLabeling(); |
|
69 |
} catch (OpenException e) { |
|
70 |
//FIXME |
|
71 |
throw new RuntimeException(e); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.189/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.AbstractDynMethod; |
|
35 |
import org.gvsig.tools.dynobject.DynClass; |
|
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 extends AbstractDynMethod { |
|
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 |
|
|
55 |
public DGNGetLegend() { |
|
56 |
super(LegendBuilder.DYNMETHOD_GETLEGEND_NAME,"DGN Legend"); |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public int getCode() throws DynMethodNotSupportedException { |
|
61 |
return code; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public Object invoke(DynObject self, Object[] args) |
|
66 |
throws DynMethodException { |
|
67 |
try { |
|
68 |
return ((DGNStoreProvider) self).getLegend(); |
|
69 |
} catch (OpenException e) { |
|
70 |
throw new RuntimeException(e); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
} |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.189/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.189</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 |
<!-- |
|
99 |
<dependency> |
|
100 |
<groupId>org.gvsig</groupId> |
|
101 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
102 |
<scope>test</scope> |
|
103 |
</dependency> |
|
104 |
--> |
|
105 |
<dependency> |
|
106 |
<groupId>org.gvsig</groupId> |
|
107 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
108 |
<scope>test</scope> |
|
109 |
</dependency> |
|
110 |
<dependency> |
|
111 |
<groupId>org.gvsig</groupId> |
|
112 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
113 |
<scope>test</scope> |
|
114 |
</dependency> |
|
115 |
|
|
116 |
|
|
117 |
</dependencies> |
|
118 |
|
|
119 |
</project> |
|
0 | 120 |
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.189/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/lib/DGNReader.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify it under |
|
7 |
* the terms of the GNU General Public License as published by the Free Software |
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later |
|
9 |
* version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
14 |
* details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us at info AT |
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.dal.store.dgn.lib; |
|
24 |
|
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.io.FileInputStream; |
|
28 |
import java.io.FileNotFoundException; |
|
29 |
import java.nio.ByteBuffer; |
|
30 |
import java.nio.ByteOrder; |
|
31 |
import java.nio.MappedByteBuffer; |
|
32 |
import java.nio.channels.FileChannel; |
|
33 |
import java.text.MessageFormat; |
|
34 |
import java.util.ArrayList; |
|
35 |
import java.util.Formatter; |
|
36 |
import java.util.Iterator; |
|
37 |
import java.util.LinkedHashMap; |
|
38 |
import java.util.List; |
|
39 |
import java.util.Map; |
|
40 |
import java.util.regex.Pattern; |
|
41 |
|
|
42 |
import org.gvsig.fmap.dal.exception.DataException; |
|
43 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
|
|
47 |
/** |
|
48 |
* Clase dedicada a leer del fichero DGN. |
|
49 |
* |
|
50 |
*/ |
|
51 |
public class DGNReader { |
|
52 |
|
|
53 |
private static Logger logger = LoggerFactory.getLogger(DGNReader.class); |
|
54 |
static int[][] abyDefaultPCT = {{255, 255, 255}, {0, 0, 255}, |
|
55 |
{0, 255, 0}, {255, 0, 0}, {255, 255, 0}, {255, 0, 255}, |
|
56 |
{255, 127, 0}, {0, 255, 255}, {64, 64, 64}, |
|
57 |
{192, 192, 192}, {254, 0, 96}, {160, 224, 0}, |
|
58 |
{0, 254, 160}, {128, 0, 160}, {176, 176, 176}, |
|
59 |
{0, 240, 240}, {240, 240, 240}, {0, 0, 240}, {0, 240, 0}, |
|
60 |
{240, 0, 0}, {240, 240, 0}, {240, 0, 240}, {240, 122, 0}, |
|
61 |
{0, 240, 240}, {240, 240, 240}, {0, 0, 240}, {0, 240, 0}, |
|
62 |
{240, 0, 0}, {240, 240, 0}, {240, 0, 240}, {240, 122, 0}, |
|
63 |
{0, 225, 225}, {225, 225, 225}, {0, 0, 225}, {0, 225, 0}, |
|
64 |
{225, 0, 0}, {225, 225, 0}, {225, 0, 225}, {225, 117, 0}, |
|
65 |
{0, 225, 225}, {225, 225, 225}, {0, 0, 225}, {0, 225, 0}, |
|
66 |
{225, 0, 0}, {225, 225, 0}, {225, 0, 225}, {225, 117, 0}, |
|
67 |
{0, 210, 210}, {210, 210, 210}, {0, 0, 210}, {0, 210, 0}, |
|
68 |
{210, 0, 0}, {210, 210, 0}, {210, 0, 210}, {210, 112, 0}, |
|
69 |
{0, 210, 210}, {210, 210, 210}, {0, 0, 210}, {0, 210, 0}, |
|
70 |
{210, 0, 0}, {210, 210, 0}, {210, 0, 210}, {210, 112, 0}, |
|
71 |
{0, 195, 195}, {195, 195, 195}, {0, 0, 195}, {0, 195, 0}, |
|
72 |
{195, 0, 0}, {195, 195, 0}, {195, 0, 195}, {195, 107, 0}, |
|
73 |
{0, 195, 195}, {195, 195, 195}, {0, 0, 195}, {0, 195, 0}, |
|
74 |
{195, 0, 0}, {195, 195, 0}, {195, 0, 195}, {195, 107, 0}, |
|
75 |
{0, 180, 180}, {180, 180, 180}, {0, 0, 180}, {0, 180, 0}, |
|
76 |
{180, 0, 0}, {180, 180, 0}, {180, 0, 180}, {180, 102, 0}, |
|
77 |
{0, 180, 180}, {180, 180, 180}, {0, 0, 180}, {0, 180, 0}, |
|
78 |
{180, 0, 0}, {180, 180, 0}, {180, 0, 180}, {180, 102, 0}, |
|
79 |
{0, 165, 165}, {165, 165, 165}, {0, 0, 165}, {0, 165, 0}, |
|
80 |
{165, 0, 0}, {165, 165, 0}, {165, 0, 165}, {165, 97, 0}, |
|
81 |
{0, 165, 165}, {165, 165, 165}, {0, 0, 165}, {0, 165, 0}, |
|
82 |
{165, 0, 0}, {165, 165, 0}, {165, 0, 165}, {165, 97, 0}, |
|
83 |
{0, 150, 150}, {150, 150, 150}, {0, 0, 150}, {0, 150, 0}, |
|
84 |
{150, 0, 0}, {150, 150, 0}, {150, 0, 150}, {150, 92, 0}, |
|
85 |
{0, 150, 150}, {150, 150, 150}, {0, 0, 150}, {0, 150, 0}, |
|
86 |
{150, 0, 0}, {150, 150, 0}, {150, 0, 150}, {150, 92, 0}, |
|
87 |
{0, 135, 135}, {135, 135, 135}, {0, 0, 135}, {0, 135, 0}, |
|
88 |
{135, 0, 0}, {135, 135, 0}, {135, 0, 135}, {135, 87, 0}, |
|
89 |
{0, 135, 135}, {135, 135, 135}, {0, 0, 135}, {0, 135, 0}, |
|
90 |
{135, 0, 0}, {135, 135, 0}, {135, 0, 135}, {135, 87, 0}, |
|
91 |
{0, 120, 120}, {120, 120, 120}, {0, 0, 120}, {0, 120, 0}, |
|
92 |
{120, 0, 0}, {120, 120, 0}, {120, 0, 120}, {120, 82, 0}, |
|
93 |
{0, 120, 120}, {120, 120, 120}, {0, 0, 120}, {0, 120, 0}, |
|
94 |
{120, 0, 0}, {120, 120, 0}, {120, 0, 120}, {120, 82, 0}, |
|
95 |
{0, 105, 105}, {105, 105, 105}, {0, 0, 105}, {0, 105, 0}, |
|
96 |
{105, 0, 0}, {105, 105, 0}, {105, 0, 105}, {105, 77, 0}, |
|
97 |
{0, 105, 105}, {105, 105, 105}, {0, 0, 105}, {0, 105, 0}, |
|
98 |
{105, 0, 0}, {105, 105, 0}, {105, 0, 105}, {105, 77, 0}, |
|
99 |
{0, 90, 90}, {90, 90, 90}, {0, 0, 90}, {0, 90, 0}, |
|
100 |
{90, 0, 0}, {90, 90, 0}, {90, 0, 90}, {90, 72, 0}, |
|
101 |
{0, 90, 90}, {90, 90, 90}, {0, 0, 90}, {0, 90, 0}, |
|
102 |
{90, 0, 0}, {90, 90, 0}, {90, 0, 90}, {90, 72, 0}, |
|
103 |
{0, 75, 75}, {75, 75, 75}, {0, 0, 75}, {0, 75, 0}, |
|
104 |
{75, 0, 0}, {75, 75, 0}, {75, 0, 75}, {75, 67, 0}, |
|
105 |
{0, 75, 75}, {75, 75, 75}, {0, 0, 75}, {0, 75, 0}, |
|
106 |
{75, 0, 0}, {75, 75, 0}, {75, 0, 75}, {75, 67, 0}, |
|
107 |
{0, 60, 60}, {60, 60, 60}, {0, 0, 60}, {0, 60, 0}, |
|
108 |
{60, 0, 0}, {60, 60, 0}, {60, 0, 60}, {60, 62, 0}, |
|
109 |
{0, 60, 60}, {60, 60, 60}, {0, 0, 60}, {0, 60, 0}, |
|
110 |
{60, 0, 0}, {60, 60, 0}, {60, 0, 60}, {60, 62, 0}, |
|
111 |
{0, 45, 45}, {45, 45, 45}, {0, 0, 45}, {0, 45, 0}, |
|
112 |
{45, 0, 0}, {45, 45, 0}, {45, 0, 45}, {45, 57, 0}, |
|
113 |
{0, 45, 45}, {45, 45, 45}, {0, 0, 45}, {0, 45, 0}, |
|
114 |
{45, 0, 0}, {45, 45, 0}, {45, 0, 45}, {45, 57, 0}, |
|
115 |
{0, 30, 30}, {30, 30, 30}, {0, 0, 30}, {0, 30, 0}, |
|
116 |
{30, 0, 0}, {30, 30, 0}, {30, 0, 30}, {30, 52, 0}, |
|
117 |
{0, 30, 30}, {30, 30, 30}, {0, 0, 30}, {0, 30, 0}, |
|
118 |
{30, 0, 0}, {30, 30, 0}, {30, 0, 30}, {192, 192, 192}, |
|
119 |
{28, 0, 100}}; |
|
120 |
private int LSB; |
|
121 |
private FileInputStream fin; |
|
122 |
|
|
123 |
// private LEDataInputStream input; |
|
124 |
private MappedByteBuffer bb; |
|
125 |
private int FALSE = 0; |
|
126 |
private int TRUE = 1; |
|
127 |
private DGNElemCore elemento; |
|
128 |
private DGNInfo info; // Contiene el path y otras cosas |
|
129 |
private Rectangle2D.Double m_BoundingBox; |
|
130 |
private DGNElemColorTable m_colorTable; |
|
131 |
|
|
132 |
private boolean logErrors = false; |
|
133 |
|
|
134 |
public DGNReader(String pathFich) throws DataException { |
|
135 |
this(pathFich, false); |
|
136 |
} |
|
137 |
|
|
138 |
public DGNReader(String pathFich, boolean logErrors) throws DataException { |
|
139 |
this.logErrors = logErrors; |
|
140 |
|
|
141 |
info = new DGNInfo(); |
|
142 |
|
|
143 |
DGNElemCore elemento = new DGNElemCore(this); |
|
144 |
int iArg; |
|
145 |
int bReportExtents = 0; |
|
146 |
byte[] achRaw = new byte[64]; |
|
147 |
achRaw[63] = 1; |
|
148 |
|
|
149 |
double dfSFXMin = 0.0; |
|
150 |
double dfSFXMax = 0.0; |
|
151 |
double dfSFYMin = 0.0; |
|
152 |
double dfSFYMax = 0.0; |
|
153 |
|
|
154 |
info.fp = pathFich; |
|
155 |
info = DGNOpen(info, 0); |
|
156 |
|
|
157 |
bb.rewind(); |
|
158 |
DGNSetSpatialFilter(info, dfSFXMin, dfSFYMin, dfSFXMax, dfSFYMax); |
|
159 |
|
|
160 |
int nLevel; |
|
161 |
int nType; |
|
162 |
int[] anLevelTypeCount = new int[128 * 64]; |
|
163 |
int[] anLevelCount = new int[64]; |
|
164 |
int[] anTypeCount = new int[128]; |
|
165 |
double[] adfExtents = new double[6]; |
|
166 |
int[] nCount = new int[1]; |
|
167 |
nCount[0] = 0; |
|
168 |
|
|
169 |
DGNGetExtents(info, adfExtents); // extender |
|
170 |
logdebug("X Range:" + adfExtents[0] + ", " + adfExtents[3]); |
|
171 |
logdebug("Y Range:" + adfExtents[1] + ", " + adfExtents[4]); |
|
172 |
logdebug("Z Range:" + adfExtents[2] + ", " + adfExtents[5]); |
|
173 |
|
|
174 |
m_BoundingBox = new Rectangle2D.Double(); |
|
175 |
m_BoundingBox.setRect(adfExtents[0], adfExtents[1], |
|
176 |
(adfExtents[3] - adfExtents[0]), |
|
177 |
(adfExtents[4] - adfExtents[1])); |
|
178 |
|
|
179 |
/* m_Renderer = new FRenderer(this); */ |
|
180 |
DGNElementInfo[] pasEI; // =new DGNElementInfo[nCount+1]; |
|
181 |
pasEI = DGNGetElementIndex(info, nCount); |
|
182 |
|
|
183 |
logdebug("Total Elements:" + nCount[0]); |
|
184 |
|
|
185 |
for (int i = 0; i < nCount[0]; i++) { |
|
186 |
anLevelTypeCount[(pasEI[i].level * 128) + pasEI[i].type]++; |
|
187 |
anLevelCount[pasEI[i].level]++; |
|
188 |
anTypeCount[pasEI[i].type]++; |
|
189 |
} |
|
190 |
|
|
191 |
logdebug("Per Type Report"); |
|
192 |
logdebug("==============="); |
|
193 |
|
|
194 |
for (nType = 0; nType < 128; nType++) { |
|
195 |
if (anTypeCount[nType] != 0) { |
|
196 |
logdebug("Type:" + DGNTypeToName(nType) + ":" |
|
197 |
+ anTypeCount[nType]); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
logdebug("Per Level Report\n"); |
|
202 |
logdebug("================\n"); |
|
203 |
for (nLevel = 0; nLevel < 64; nLevel++) { |
|
204 |
if (anLevelCount[nLevel] == 0) { |
|
205 |
continue; |
|
206 |
} |
|
207 |
logdebug("Level " + nLevel + "," + anLevelCount[nLevel] + "elements:"); |
|
208 |
for (nType = 0; nType < 128; nType++) { |
|
209 |
if (anLevelTypeCount[(nLevel * 128) + nType] != 0) { |
|
210 |
logdebug(" Type " + DGNTypeToName(nType) |
|
211 |
+ "," + anLevelTypeCount[(nLevel * 128) + nType]); |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
bb.rewind(); |
|
217 |
} |
|
218 |
|
|
219 |
public boolean is3D() { |
|
220 |
return this.info.dimension == 3; |
|
221 |
} |
|
222 |
|
|
223 |
/* |
|
224 |
* public Color getColor(int indexColor) { int r,g,b; // |
|
225 |
* System.err.println("indexcolor = " + indexColor); // Si no hay tabla de |
|
226 |
* colores, interpretamos que todas las cosas son negras if (m_colorTable == |
|
227 |
* null) return new Color(0,0,0); |
|
228 |
* |
|
229 |
* r = ByteUtils.getUnsigned(m_colorTable.color_info[indexColor][0]); g = |
|
230 |
* ByteUtils.getUnsigned(m_colorTable.color_info[indexColor][1]); b = |
|
231 |
* ByteUtils.getUnsigned(m_colorTable.color_info[indexColor][2]); |
|
232 |
* |
|
233 |
* if ((r==255) && (g==255) & (b==255)) { r=g=b=0; // El color blanco lo |
|
234 |
* devolvemos como negro. } |
|
235 |
* |
|
236 |
* return new Color(r,g,b); } |
|
237 |
*/ |
|
238 |
/** |
|
239 |
* Devuelve la informaci?n del DGN. |
|
240 |
* |
|
241 |
* @return DGNInfo Informaci?n. |
|
242 |
*/ |
|
243 |
public DGNInfo getInfo() { |
|
244 |
return info; |
|
245 |
} |
|
246 |
|
|
247 |
/** |
|
248 |
* Devuelve el n?mero de elementos. |
|
249 |
* |
|
250 |
* @return N?mero de elementos. |
|
251 |
*/ |
|
252 |
public int getNumEntities() { |
|
253 |
return info.element_count; |
|
254 |
} |
|
255 |
|
|
256 |
/** |
|
257 |
* Devuelve el rect?ngulo del extent. |
|
258 |
* |
|
259 |
* @return Rect?ngulo. |
|
260 |
*/ |
|
261 |
public Rectangle2D getBoundingBox() { |
|
262 |
return m_BoundingBox; |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* ********************************************************************* |
|
267 |
*/ |
|
268 |
/* DGNGotoElement() */ |
|
269 |
/** |
|
270 |
* ********************************************************************* |
|
271 |
*/ |
|
272 |
/** |
|
273 |
* Seek to indicated element. Changes what element will be read on the next |
|
274 |
* call to DGNReadElement(). Note that this function requires and index, and |
|
275 |
* one will be built if not already available. |
|
276 |
* |
|
277 |
* @param element_id the element to seek to. These values are sequentially |
|
278 |
* ordered starting at zero for the first element. |
|
279 |
* |
|
280 |
* @return returns TRUE on success or FALSE on failure. |
|
281 |
*/ |
|
282 |
public int DGNGotoElement(int element_id) { |
|
283 |
DGNBuildIndex(info); |
|
284 |
if ((element_id < 0) || (element_id >= info.element_count)) { |
|
285 |
return FALSE; |
|
286 |
} |
|
287 |
bb.position((int) info.element_index[element_id].offset); |
|
288 |
|
|
289 |
info.next_element_id = element_id; |
|
290 |
info.in_complex_group = FALSE; |
|
291 |
return TRUE; |
|
292 |
} |
|
293 |
|
|
294 |
private DGNInfo DGNOpen(DGNInfo info, int bUpdate) throws DataException { |
|
295 |
int pos = 0; |
|
296 |
byte[] abyHeader = new byte[512]; |
|
297 |
info.next_element_id = 0; |
|
298 |
info.got_tcb = FALSE; |
|
299 |
info.scale = 1.0; |
|
300 |
info.origin_x = 0.0; |
|
301 |
info.origin_y = 0.0; |
|
302 |
info.origin_z = 0.0; |
|
303 |
info.index_built = FALSE; |
|
304 |
info.element_count = 0; |
|
305 |
info.element_index = null; |
|
306 |
info.got_bounds = FALSE; |
|
307 |
|
|
308 |
try { |
|
309 |
fin = new FileInputStream(info.fp); |
|
310 |
|
|
311 |
FileChannel fc = fin.getChannel(); |
|
312 |
|
|
313 |
long sz = fc.size(); |
|
314 |
int numReg; |
|
315 |
|
|
316 |
// Get the file's size and then map it into memory |
|
317 |
bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz); |
|
318 |
bb.order(ByteOrder.nativeOrder()); |
|
319 |
bb.get(abyHeader, pos, abyHeader.length); |
|
320 |
|
|
321 |
info.ftall = (int) (sz / 16); |
|
322 |
|
|
323 |
if (bb.order() == ByteOrder.LITTLE_ENDIAN) { |
|
324 |
LSB = TRUE; |
|
325 |
} |
|
326 |
|
|
327 |
if (DGNTestOpen(abyHeader, abyHeader.length) != FALSE) { |
|
328 |
if (abyHeader[0] == (byte) 0xC8) { |
|
329 |
info.dimension = 3; // 0xC8 |
|
330 |
} else { |
|
331 |
info.dimension = 2; |
|
332 |
} |
|
333 |
|
|
334 |
info.has_spatial_filter = FALSE; |
|
335 |
info.sf_converted_to_uor = FALSE; |
|
336 |
info.select_complex_group = FALSE; |
|
337 |
info.in_complex_group = FALSE; |
|
338 |
} |
|
339 |
} catch (FileNotFoundException e) { |
|
340 |
throw new org.gvsig.fmap.dal.exception.FileNotFoundException( |
|
341 |
info.fp); |
|
342 |
} catch (Exception e) { |
|
343 |
throw new ReadException("DGNReader error", e); |
|
344 |
} |
|
345 |
|
|
346 |
return info; |
|
347 |
} |
|
348 |
|
|
349 |
/** |
|
350 |
* Comprobaci?n si se puede abrir el fichero. |
|
351 |
* |
|
352 |
* @param pabyHeader Vector byte con el header. |
|
353 |
* @param nByteCount n?mero de bytes. |
|
354 |
* |
|
355 |
* @return Devuelve un enteor que muestra si no hay errores. |
|
356 |
*/ |
|
357 |
private int DGNTestOpen(byte[] pabyHeader, int nByteCount) { |
|
358 |
if (nByteCount < 4) { |
|
359 |
return TRUE; |
|
360 |
} |
|
361 |
|
|
362 |
// Is it a cell library? |
|
363 |
if ((pabyHeader[0] == (byte) 0x08) && (pabyHeader[1] == (byte) 0x05) |
|
364 |
&& (pabyHeader[2] == (byte) 0x17) |
|
365 |
&& (pabyHeader[3] == (byte) 0x00)) { |
|
366 |
return TRUE; |
|
367 |
} |
|
368 |
|
|
369 |
// Is it not a regular 2D or 3D file? |
|
370 |
if (((pabyHeader[0] != (byte) 0x08) && (pabyHeader[0] != (byte) 0xC8)) |
|
371 |
|| (pabyHeader[1] != (byte) 0x09) |
|
372 |
|| (pabyHeader[2] != (byte) 0xFE) |
|
373 |
|| (pabyHeader[3] != (byte) 0x02)) { |
|
374 |
return FALSE; |
|
375 |
} |
|
376 |
|
|
377 |
return TRUE; |
|
378 |
} |
|
379 |
|
|
380 |
/** |
|
381 |
* Lee una fila del elemento. |
|
382 |
* |
|
383 |
* @param info Informaci?n del DGN. |
|
384 |
* @param core Elemento. |
|
385 |
* |
|
386 |
* @return Devuelve un entero que muestra si se ha calculado correctamente. |
|
387 |
*/ |
|
388 |
private int DGNLoadRawElement(DGNInfo info, DGNElemCore core) { |
|
389 |
/* -------------------------------------------------------------------- */ |
|
390 |
/* Read the first four bytes to get the level, type, and word */ |
|
391 |
/* count. */ |
|
392 |
/* -------------------------------------------------------------------- */ |
|
393 |
|
|
394 |
// int nType, nWords, nLevel; |
|
395 |
int nType = 0; |
|
396 |
int nWords = 0; |
|
397 |
int nLevel = 0; |
|
398 |
int bytesCount = 0; |
|
399 |
|
|
400 |
try { |
|
401 |
// input=new LEDataInputStream(fin); |
|
402 |
for (int i = 0; i < 4; i++) { |
|
403 |
info.abyElem[i] = bb.get(); |
|
404 |
if (i == 1) { |
|
405 |
if ((info.abyElem[0] == -1) && (info.abyElem[1] == -1)) { |
|
406 |
return FALSE; |
|
407 |
} |
|
408 |
} |
|
409 |
|
|
410 |
// info.temporal[i]=input.readByte(); |
|
411 |
} |
|
412 |
|
|
413 |
nWords = ByteUtils.byteToUnsignedInt(info.abyElem[2]) |
|
414 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[3]) * 256); |
|
415 |
nType = ByteUtils.byteToUnsignedInt(info.abyElem[1]) & 0x7f; |
|
416 |
nLevel = ByteUtils.byteToUnsignedInt(info.abyElem[0]) & 0x3f; |
|
417 |
|
|
418 |
/* |
|
419 |
* ------------------------------------------------------------------ |
|
420 |
*/ |
|
421 |
/* Read the rest of the element data into the working buffer. */ |
|
422 |
if (((nWords * 2) + 4) > info.abyElem.length) { |
|
423 |
return FALSE; |
|
424 |
} |
|
425 |
for (; bytesCount < (nWords * 2) && bb.hasRemaining(); bytesCount++) { |
|
426 |
info.abyElem[bytesCount + 4] = bb.get(); |
|
427 |
} |
|
428 |
info.ftall = bb.position(); |
|
429 |
} catch (Exception e) { |
|
430 |
logwarn(MessageFormat.format("The DGN file {0} may not be loaded correctly.\n" |
|
431 |
+ "Error loading:\n" |
|
432 |
+ "nWords = {1}\n" |
|
433 |
+ "info.next_element_id {2}\n" |
|
434 |
+ "info.abyElem.length = {3}\n" |
|
435 |
+ "bb.position() = {4}", |
|
436 |
info.fp, |
|
437 |
nWords, |
|
438 |
info.next_element_id, |
|
439 |
info.abyElem.length, |
|
440 |
bb.position()), e); |
|
441 |
|
|
442 |
return FALSE; |
|
443 |
} |
|
444 |
|
|
445 |
info.nElemBytes = bytesCount + 4; |
|
446 |
info.next_element_id++; |
|
447 |
|
|
448 |
/* -------------------------------------------------------------------- */ |
|
449 |
/* Return requested info. */ |
|
450 |
/* -------------------------------------------------------------------- */ |
|
451 |
core.type = nType; |
|
452 |
|
|
453 |
core.level = nLevel; |
|
454 |
|
|
455 |
return TRUE; |
|
456 |
} |
|
457 |
|
|
458 |
/** |
|
459 |
* Calcula el filtro espacial al rect?ngulo del elemento. |
|
460 |
* |
|
461 |
* @param info Informaci?n del DGN. |
|
462 |
*/ |
|
463 |
private void DGNSpatialFilterToUOR(DGNInfo info) { |
|
464 |
DGNPoint sMin = new DGNPoint(); |
|
465 |
DGNPoint sMax = new DGNPoint(); |
|
466 |
|
|
467 |
if ((info.sf_converted_to_uor == 1) |
|
468 |
|| (!(info.has_spatial_filter == 1)) || (!(info.got_tcb == 1))) { |
|
469 |
return; |
|
470 |
} |
|
471 |
|
|
472 |
sMin.x = info.sf_min_x_geo; |
|
473 |
sMin.y = info.sf_min_y_geo; |
|
474 |
sMin.z = 0; |
|
475 |
|
|
476 |
sMax.x = info.sf_max_x_geo; |
|
477 |
sMax.y = info.sf_max_y_geo; |
|
478 |
sMax.z = 0; |
|
479 |
|
|
480 |
DGNInverseTransformPoint(info, sMin); |
|
481 |
DGNInverseTransformPoint(info, sMax); |
|
482 |
|
|
483 |
info.sf_min_x = (long) (sMin.x + 2147483648.0); |
|
484 |
info.sf_min_y = (long) (sMin.y + 2147483648.0); |
|
485 |
info.sf_max_x = (long) (sMax.x + 2147483648.0); |
|
486 |
info.sf_max_y = (long) (sMax.y + 2147483648.0); |
|
487 |
|
|
488 |
info.sf_converted_to_uor = TRUE; |
|
489 |
} |
|
490 |
|
|
491 |
/** |
|
492 |
* Calcula un punto aplicandole la transformaci?n. |
|
493 |
* |
|
494 |
* @param info Informaci?n del DGN. |
|
495 |
* @param punto Punto. |
|
496 |
*/ |
|
497 |
private void DGNInverseTransformPoint(DGNInfo info, DGNPoint punto) { |
|
498 |
punto.x = (punto.x + info.origin_x) / info.scale; |
|
499 |
punto.y = (punto.y + info.origin_y) / info.scale; |
|
500 |
punto.z = (punto.z + info.origin_z) / info.scale; |
|
501 |
|
|
502 |
punto.x = Math.max(-2147483647, Math.min(2147483647, punto.x)); |
|
503 |
punto.y = Math.max(-2147483647, Math.min(2147483647, punto.y)); |
|
504 |
punto.z = Math.max(-2147483647, Math.min(2147483647, punto.z)); |
|
505 |
} |
|
506 |
|
|
507 |
public DGNElemCore DGNReadElement() { |
|
508 |
DGNElemCore elemento = new DGNElemCore(this); |
|
509 |
int nType; |
|
510 |
int nLevel; |
|
511 |
int bInsideFilter; |
|
512 |
|
|
513 |
/* -------------------------------------------------------------------- */ |
|
514 |
/* Load the element data into the current buffer. If a spatial */ |
|
515 |
/* filter is in effect, loop until we get something within our */ |
|
516 |
/* spatial constraints. */ |
|
517 |
/* -------------------------------------------------------------------- */ |
|
518 |
do { |
|
519 |
bInsideFilter = TRUE; |
|
520 |
|
|
521 |
int fin_fichero = DGNLoadRawElement(info, elemento); |
|
522 |
|
|
523 |
if (fin_fichero == FALSE) { |
|
524 |
return null; |
|
525 |
} |
|
526 |
|
|
527 |
if (info.has_spatial_filter != FALSE) { |
|
528 |
if (info.sf_converted_to_uor == FALSE) { |
|
529 |
DGNSpatialFilterToUOR(info); |
|
530 |
} |
|
531 |
|
|
532 |
if (DGNGetRawExtents(info, null, elemento) == null) { |
|
533 |
bInsideFilter = TRUE; |
|
534 |
} else if ((info.min_x > info.sf_max_x) |
|
535 |
|| (info.min_y > info.sf_max_y) |
|
536 |
|| (info.max_x < info.sf_min_x) |
|
537 |
|| (info.max_y < info.sf_min_y)) { |
|
538 |
bInsideFilter = FALSE; |
|
539 |
} |
|
540 |
|
|
541 |
if ((elemento.type == DGNFileHeader.DGNT_COMPLEX_CHAIN_HEADER) |
|
542 |
|| (elemento.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER)) { |
|
543 |
info.in_complex_group = TRUE; |
|
544 |
info.select_complex_group = bInsideFilter; |
|
545 |
} else if ((info.abyElem[0] & (byte) 0x80) != FALSE) { |
|
546 |
if (info.in_complex_group == TRUE) { |
|
547 |
bInsideFilter = info.select_complex_group; |
|
548 |
} |
|
549 |
} else { |
|
550 |
info.in_complex_group = FALSE; |
|
551 |
} |
|
552 |
} |
|
553 |
} while (bInsideFilter == FALSE); |
|
554 |
|
|
555 |
elemento = DGNProcessElement(info, elemento.type, elemento.level); |
|
556 |
|
|
557 |
return elemento; |
|
558 |
} |
|
559 |
|
|
560 |
/** |
|
561 |
* Devuelve los extent de una fila. |
|
562 |
* |
|
563 |
* @param info Informaci?n del DGN. |
|
564 |
* @param pabyRawData Vector de byte. |
|
565 |
* @param elemento Elemento. |
|
566 |
* |
|
567 |
* @return Vector de double. |
|
568 |
*/ |
|
569 |
public double[] DGNGetRawExtents(DGNInfo info, byte[] pabyRawData, |
|
570 |
DGNElemCore elemento) { |
|
571 |
if (pabyRawData == null) { |
|
572 |
pabyRawData = info.abyElem; |
|
573 |
} |
|
574 |
|
|
575 |
double[] tempo = new double[6]; |
|
576 |
|
|
577 |
switch (elemento.type) { |
|
578 |
case DGNFileHeader.DGNT_LINE: |
|
579 |
case DGNFileHeader.DGNT_LINE_STRING: |
|
580 |
case DGNFileHeader.DGNT_SHAPE: |
|
581 |
case DGNFileHeader.DGNT_CURVE: |
|
582 |
case DGNFileHeader.DGNT_BSPLINE: |
|
583 |
case DGNFileHeader.DGNT_ELLIPSE: |
|
584 |
case DGNFileHeader.DGNT_ARC: |
|
585 |
case DGNFileHeader.DGNT_TEXT: |
|
586 |
case DGNFileHeader.DGNT_COMPLEX_CHAIN_HEADER: |
|
587 |
case DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER: |
|
588 |
|
|
589 |
byte[] temp = new byte[4]; |
|
590 |
System.arraycopy(pabyRawData, 4, temp, 0, 4); |
|
591 |
tempo[0] = DGN_INT32(temp); // 4 |
|
592 |
|
|
593 |
System.arraycopy(pabyRawData, 8, temp, 0, 4); |
|
594 |
tempo[1] = DGN_INT32(temp); |
|
595 |
|
|
596 |
System.arraycopy(pabyRawData, 12, temp, 0, 4); |
|
597 |
tempo[2] = DGN_INT32(temp); |
|
598 |
|
|
599 |
System.arraycopy(pabyRawData, 16, temp, 0, 4); |
|
600 |
tempo[3] = DGN_INT32(temp); |
|
601 |
|
|
602 |
System.arraycopy(pabyRawData, 20, temp, 0, 4); |
|
603 |
tempo[4] = DGN_INT32(temp); |
|
604 |
|
|
605 |
System.arraycopy(pabyRawData, 24, temp, 0, 4); |
|
606 |
tempo[5] = DGN_INT32(temp); |
|
607 |
|
|
608 |
return tempo; |
|
609 |
|
|
610 |
default: |
|
611 |
return null; |
|
612 |
} |
|
613 |
} |
|
614 |
|
|
615 |
/** |
|
616 |
* A partir de un vector de byte devuelve un double. |
|
617 |
* |
|
618 |
* @param p Vector de byte. |
|
619 |
* |
|
620 |
* @return double. |
|
621 |
*/ |
|
622 |
private double DGN_INT32(byte[] p) { |
|
623 |
int x = 256; |
|
624 |
int x0; |
|
625 |
int x1; |
|
626 |
int x2; |
|
627 |
int x3; |
|
628 |
x0 = p[0]; |
|
629 |
x1 = p[1]; |
|
630 |
x2 = p[2]; |
|
631 |
x3 = p[3]; |
|
632 |
|
|
633 |
if (p[0] < 0) { |
|
634 |
x0 = x + p[0]; |
|
635 |
} |
|
636 |
|
|
637 |
if (p[1] < 0) { |
|
638 |
x1 = x + p[1]; |
|
639 |
} |
|
640 |
|
|
641 |
if (p[2] < 0) { |
|
642 |
x2 = x + p[2]; |
|
643 |
} |
|
644 |
|
|
645 |
if (p[3] < 0) { |
|
646 |
x3 = x + p[3]; |
|
647 |
} |
|
648 |
|
|
649 |
return (x2 + (x3 * 256) + (x1 * 65536 * 256) + (x0 * 65536)); |
|
650 |
} |
|
651 |
|
|
652 |
private DGNElemCore DGNProcessElement(DGNInfo info, int nType, int nLevel) { |
|
653 |
DGNElemCore elemento = new DGNElemCore(this); |
|
654 |
|
|
655 |
switch (nType) { |
|
656 |
case DGNFileHeader.DGNT_SHARED_CELL_DEFN: |
|
657 |
logdebug("DGNProcessElement (DGNT_SHARED_CELL_DEFN): Type " + DGNTypeToName(nType)); |
|
658 |
elemento.stype = DGNFileHeader.DGNST_SHARED_CELL_DEFN; |
|
659 |
DGNParseCore(info, elemento); |
|
660 |
|
|
661 |
break; |
|
662 |
|
|
663 |
case DGNFileHeader.DGNT_CELL_HEADER: { |
|
664 |
DGNElemCellHeader psCell = new DGNElemCellHeader(this); |
|
665 |
psCell.stype = DGNFileHeader.DGNST_CELL_HEADER; |
|
666 |
DGNParseCore(info, psCell); |
|
667 |
psCell.totlength = ByteUtils.getUnsigned(info.abyElem[36]) |
|
668 |
+ (ByteUtils.getUnsigned(info.abyElem[37]) * 256); |
|
669 |
|
|
670 |
byte[] temp = new byte[psCell.name.length]; |
|
671 |
System.arraycopy(psCell.name, 0, temp, 0, psCell.name.length); |
|
672 |
DGNRad50ToAscii(ByteUtils.byteToUnsignedInt(info.abyElem[38]) |
|
673 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[39]) * 256), |
|
674 |
temp); |
|
675 |
|
|
676 |
System.arraycopy(psCell.name, 3, temp, 0, psCell.name.length - 3); |
|
677 |
|
|
678 |
DGNRad50ToAscii(ByteUtils.byteToUnsignedInt(info.abyElem[40]) |
|
679 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[41]) * 256), |
|
680 |
temp); |
|
681 |
psCell.cclass = ByteUtils.byteToUnsignedInt(info.abyElem[42]) |
|
682 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[43]) * 256); |
|
683 |
psCell.levels[0] = ByteUtils.byteToUnsignedInt(info.abyElem[44]) |
|
684 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[45]) * 256); |
|
685 |
psCell.levels[1] = ByteUtils.byteToUnsignedInt(info.abyElem[46]) |
|
686 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[47]) * 256); |
|
687 |
psCell.levels[2] = ByteUtils.byteToUnsignedInt(info.abyElem[48]) |
|
688 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[49]) * 256); |
|
689 |
psCell.levels[3] = ByteUtils.byteToUnsignedInt(info.abyElem[50]) |
|
690 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[51]) * 256); |
|
691 |
psCell.color = info.abyElem[35]; |
|
692 |
|
|
693 |
if (info.dimension == 2) { |
|
694 |
byte[] temp1 = new byte[4]; |
|
695 |
System.arraycopy(info.abyElem, 52, temp1, 0, 4); |
|
696 |
psCell.rnglow.x = DGN_INT32(temp1); |
|
697 |
System.arraycopy(info.abyElem, 56, temp1, 0, 4); |
|
698 |
psCell.rnglow.y = DGN_INT32(temp); |
|
699 |
System.arraycopy(info.abyElem, 60, temp1, 0, 4); |
|
700 |
psCell.rnghigh.x = DGN_INT32(temp1); |
|
701 |
System.arraycopy(info.abyElem, 64, temp1, 0, 4); |
|
702 |
psCell.rnghigh.y = DGN_INT32(temp1); |
|
703 |
System.arraycopy(info.abyElem, 84, temp1, 0, 4); |
|
704 |
psCell.origin.x = DGN_INT32(temp1); |
|
705 |
System.arraycopy(info.abyElem, 88, temp1, 0, 4); |
|
706 |
psCell.origin.y = DGN_INT32(temp1); |
|
707 |
|
|
708 |
{ |
|
709 |
double a; |
|
710 |
double b; |
|
711 |
double c; |
|
712 |
double d; |
|
713 |
double a2; |
|
714 |
double c2; |
|
715 |
System.arraycopy(info.abyElem, 68, temp1, 0, 4); |
|
716 |
a = DGN_INT32(temp1); |
|
717 |
System.arraycopy(info.abyElem, 72, temp1, 0, 4); |
|
718 |
b = DGN_INT32(temp1); |
|
719 |
System.arraycopy(info.abyElem, 76, temp1, 0, 4); |
|
720 |
c = DGN_INT32(temp1); |
|
721 |
System.arraycopy(info.abyElem, 80, temp1, 0, 4); |
|
722 |
d = DGN_INT32(temp1); |
|
723 |
a2 = a * a; |
|
724 |
c2 = c * c; |
|
725 |
psCell.xscale = Math.sqrt(a2 + c2) / 214748; |
|
726 |
psCell.yscale = Math.sqrt((b * b) + (d * d)) / 214748; |
|
727 |
psCell.rotation = Math.acos(a / Math.sqrt(a2 + c2)); |
|
728 |
|
|
729 |
if (b <= 0) { |
|
730 |
psCell.rotation = (psCell.rotation * 180) / Math.PI; |
|
731 |
} else { |
|
732 |
psCell.rotation = 360 - ((psCell.rotation * 180) / Math.PI); |
|
733 |
} |
|
734 |
} |
|
735 |
} else { |
|
736 |
byte[] temp1 = new byte[4]; |
|
737 |
System.arraycopy(info.abyElem, 52, temp1, 0, 4); |
|
738 |
psCell.rnglow.x = DGN_INT32(temp1); |
|
739 |
System.arraycopy(info.abyElem, 56, temp1, 0, 4); |
|
740 |
psCell.rnglow.y = DGN_INT32(temp1); |
|
741 |
System.arraycopy(info.abyElem, 60, temp1, 0, 4); |
|
742 |
psCell.rnglow.z = DGN_INT32(temp1); |
|
743 |
System.arraycopy(info.abyElem, 64, temp1, 0, 4); |
|
744 |
psCell.rnghigh.x = DGN_INT32(temp1); |
|
745 |
System.arraycopy(info.abyElem, 68, temp1, 0, 4); |
|
746 |
psCell.rnghigh.y = DGN_INT32(temp1); |
|
747 |
System.arraycopy(info.abyElem, 72, temp1, 0, 4); |
|
748 |
psCell.rnghigh.z = DGN_INT32(temp1); |
|
749 |
|
|
750 |
System.arraycopy(info.abyElem, 112, temp1, 0, 4); |
|
751 |
psCell.origin.x = DGN_INT32(temp1); |
|
752 |
System.arraycopy(info.abyElem, 116, temp1, 0, 4); |
|
753 |
psCell.origin.y = DGN_INT32(temp1); |
|
754 |
System.arraycopy(info.abyElem, 120, temp1, 0, 4); |
|
755 |
psCell.origin.z = DGN_INT32(temp1); |
|
756 |
} |
|
757 |
|
|
758 |
DGNTransformPoint(info, psCell.rnglow); |
|
759 |
DGNTransformPoint(info, psCell.rnghigh); |
|
760 |
DGNTransformPoint(info, psCell.origin); |
|
761 |
elemento = psCell; |
|
762 |
} |
|
763 |
|
|
764 |
break; |
|
765 |
|
|
766 |
case DGNFileHeader.DGNT_CELL_LIBRARY: { |
|
767 |
logdebug("DGNProcessElement (DGNT_CELL_LIBRARY): Type " + DGNTypeToName(nType)); |
|
768 |
|
|
769 |
DGNElemCellLibrary psCell = new DGNElemCellLibrary(this); |
|
770 |
int iWord; |
|
771 |
psCell.stype = DGNFileHeader.DGNST_CELL_LIBRARY; |
|
772 |
DGNParseCore(info, psCell); |
|
773 |
|
|
774 |
byte[] temp = new byte[psCell.name.length]; |
|
775 |
System.arraycopy(psCell.name, 0, temp, 0, psCell.name.length); |
|
776 |
DGNRad50ToAscii(ByteUtils.byteToUnsignedInt(info.abyElem[32]) |
|
777 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[33]) * 256), |
|
778 |
temp); |
|
779 |
System.arraycopy(psCell.name, 3, temp, 0, psCell.name.length); |
|
780 |
DGNRad50ToAscii(ByteUtils.byteToUnsignedInt(info.abyElem[34]) |
|
781 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[35]) * 256), |
|
782 |
temp); |
|
783 |
psCell.properties = info.abyElem[38] + (info.abyElem[39] * 256); |
|
784 |
psCell.dispsymb = ByteUtils.byteToUnsignedInt(info.abyElem[40]) |
|
785 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[41]) * 256); |
|
786 |
psCell.cclass = ByteUtils.byteToUnsignedInt(info.abyElem[42]) |
|
787 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[43]) * 256); |
|
788 |
psCell.levels[0] = ByteUtils.byteToUnsignedInt(info.abyElem[44]) |
|
789 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[45]) * 256); |
|
790 |
psCell.levels[1] = ByteUtils.byteToUnsignedInt(info.abyElem[46]) |
|
791 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[47]) * 256); |
|
792 |
psCell.levels[2] = ByteUtils.byteToUnsignedInt(info.abyElem[48]) |
|
793 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[49]) * 256); |
|
794 |
psCell.levels[3] = ByteUtils.byteToUnsignedInt(info.abyElem[50]) |
|
795 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[51]) * 256); |
|
796 |
psCell.numwords = ByteUtils.byteToUnsignedInt(info.abyElem[36]) |
|
797 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[37]) * 256); |
|
798 |
|
|
799 |
for (iWord = 0; iWord < 9; iWord++) { |
|
800 |
int iOffset = 52 + (iWord * 2); |
|
801 |
System.arraycopy(psCell.name, iWord * 3, temp, 0, |
|
802 |
psCell.description.length); |
|
803 |
DGNRad50ToAscii( |
|
804 |
ByteUtils.byteToUnsignedInt(info.abyElem[iOffset]) |
|
805 |
+ (ByteUtils |
|
806 |
.byteToUnsignedInt(info.abyElem[iOffset + 1]) * 256), |
|
807 |
temp); |
|
808 |
} |
|
809 |
|
|
810 |
elemento = psCell; |
|
811 |
} |
|
812 |
|
|
813 |
break; |
|
814 |
|
|
815 |
case DGNFileHeader.DGNT_LINE: { |
|
816 |
DGNElemMultiPoint psLine = new DGNElemMultiPoint(this); |
|
817 |
psLine.stype = DGNFileHeader.DGNST_MULTIPOINT; |
|
818 |
DGNParseCore(info, psLine); |
|
819 |
psLine.num_vertices = 2; |
|
820 |
psLine.vertices = new DGNPoint[psLine.num_vertices]; |
|
821 |
|
|
822 |
if (info.dimension == 2) { |
|
823 |
byte[] temp1 = new byte[4]; |
|
824 |
System.arraycopy(info.abyElem, 36, temp1, 0, 4); |
|
825 |
psLine.vertices[0] = new DGNPoint(); |
|
826 |
psLine.vertices[0].x = DGN_INT32(temp1); |
|
827 |
System.arraycopy(info.abyElem, 40, temp1, 0, 4); |
|
828 |
psLine.vertices[0].y = DGN_INT32(temp1); |
|
829 |
System.arraycopy(info.abyElem, 44, temp1, 0, 4); |
|
830 |
psLine.vertices[1] = new DGNPoint(); |
|
831 |
psLine.vertices[1].x = DGN_INT32(temp1); |
|
832 |
System.arraycopy(info.abyElem, 48, temp1, 0, 4); |
|
833 |
psLine.vertices[1].y = DGN_INT32(temp1); |
|
834 |
} else { |
|
835 |
byte[] temp1 = new byte[4]; |
|
836 |
System.arraycopy(info.abyElem, 36, temp1, 0, 4); |
|
837 |
psLine.vertices[0] = new DGNPoint(); |
|
838 |
psLine.vertices[0].x = DGN_INT32(temp1); |
|
839 |
System.arraycopy(info.abyElem, 40, temp1, 0, 4); |
|
840 |
psLine.vertices[0].y = DGN_INT32(temp1); |
|
841 |
System.arraycopy(info.abyElem, 44, temp1, 0, 4); |
|
842 |
psLine.vertices[0].z = DGN_INT32(temp1); |
|
843 |
System.arraycopy(info.abyElem, 48, temp1, 0, 4); |
|
844 |
psLine.vertices[1] = new DGNPoint(); |
|
845 |
psLine.vertices[1].x = DGN_INT32(temp1); |
|
846 |
System.arraycopy(info.abyElem, 52, temp1, 0, 4); |
|
847 |
psLine.vertices[1].y = DGN_INT32(temp1); |
|
848 |
System.arraycopy(info.abyElem, 56, temp1, 0, 4); |
|
849 |
psLine.vertices[1].z = DGN_INT32(temp1); |
|
850 |
} |
|
851 |
|
|
852 |
DGNTransformPoint(info, psLine.vertices[0]); |
|
853 |
DGNTransformPoint(info, psLine.vertices[1]); |
|
854 |
elemento = psLine; |
|
855 |
} |
|
856 |
|
|
857 |
break; |
|
858 |
|
|
859 |
case DGNFileHeader.DGNT_LINE_STRING: |
|
860 |
case DGNFileHeader.DGNT_SHAPE: // regular |
|
861 |
case DGNFileHeader.DGNT_CURVE: // mal |
|
862 |
case DGNFileHeader.DGNT_BSPLINE: // aceptable |
|
863 |
{ |
|
864 |
DGNElemMultiPoint psLine = new DGNElemMultiPoint(this); |
|
865 |
int i; |
|
866 |
int count; |
|
867 |
int pntsize = info.dimension * 4; |
|
868 |
|
|
869 |
count = ByteUtils.byteToUnsignedInt(info.abyElem[36]) |
|
870 |
+ (ByteUtils.byteToUnsignedInt(info.abyElem[37]) * 256); |
|
871 |
psLine.stype = DGNFileHeader.DGNST_MULTIPOINT; |
|
872 |
DGNParseCore(info, psLine); |
|
873 |
|
|
874 |
if (info.nElemBytes < (38 + (count * pntsize))) { |
|
875 |
logdebug("Error en los vertices de multipunto"); |
|
876 |
count = (info.nElemBytes - 38) / pntsize; |
|
877 |
return null; |
|
878 |
} |
|
879 |
|
|
880 |
psLine.num_vertices = count; |
|
881 |
psLine.vertices = new DGNPoint[psLine.num_vertices]; |
|
882 |
|
|
883 |
for (i = 0; i < psLine.num_vertices; i++) { |
|
884 |
byte[] temp1 = new byte[4]; |
|
885 |
System.arraycopy(info.abyElem, 38 + (i * pntsize), temp1, 0, 4); |
|
886 |
psLine.vertices[i] = new DGNPoint(); |
|
887 |
psLine.vertices[i].x = DGN_INT32(temp1); |
|
888 |
System.arraycopy(info.abyElem, 42 + (i * pntsize), temp1, 0, 4); |
|
889 |
psLine.vertices[i].y = DGN_INT32(temp1); |
|
890 |
|
|
891 |
if (info.dimension == 3) { |
|
892 |
System.arraycopy(info.abyElem, 46 + (i * pntsize), temp1, |
|
893 |
0, 4); |
|
894 |
psLine.vertices[i].z = DGN_INT32(temp1); |
|
895 |
} |
|
896 |
|
|
897 |
DGNTransformPoint(info, psLine.vertices[i]); |
|
898 |
} |
|
899 |
|
|
900 |
elemento = psLine; |
|
901 |
} |
|
902 |
|
|
903 |
break; |
|
904 |
|
|
905 |
case DGNFileHeader.DGNT_GROUP_DATA: |
|
906 |
if (nLevel == DGNFileHeader.DGN_GDL_COLOR_TABLE) { |
|
907 |
elemento = DGNParseColorTable(info); |
|
908 |
} else { |
|
909 |
elemento.stype = DGNFileHeader.DGNST_CORE; |
|
910 |
DGNParseCore(info, elemento); |
|
911 |
} |
|
912 |
break; |
|
913 |
|
|
914 |
case DGNFileHeader.DGNT_ELLIPSE: { |
|
915 |
DGNElemArc psEllipse = new DGNElemArc(this); |
|
916 |
|
Also available in: Unified diff