gvsig-3d / 1.10 / trunk / libraries / lib3DMap / src / org / gvsig / gvsig3d / map3d / layers / FLyrOSG.java @ 113
History | View | Annotate | Download (3.69 KB)
1 |
package org.gvsig.gvsig3d.map3d.layers; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.awt.geom.Rectangle2D.Float; |
5 |
import java.util.Vector; |
6 |
|
7 |
import org.gvsig.gvsig3d.cacheservices.OSGCacheService; |
8 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
9 |
import org.gvsig.osgvp.core.osg.Vec3; |
10 |
import org.gvsig.osgvp.terrain.Terrain; |
11 |
|
12 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
13 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
14 |
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException; |
15 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
16 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
17 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
18 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingStrategy; |
19 |
import com.iver.utiles.XMLEntity; |
20 |
|
21 |
public class FLyrOSG extends FLyrVect { |
22 |
|
23 |
public FLyrOSG() {
|
24 |
super();
|
25 |
} |
26 |
|
27 |
public FLyrOSG(FLyrVect layerVect) {
|
28 |
super();
|
29 |
|
30 |
this.setSource(layerVect.getSource());
|
31 |
if (layerVect.isJoined()) {
|
32 |
this.setIsJoined(true); |
33 |
try {
|
34 |
this.setRecordset(layerVect.getRecordset());
|
35 |
} catch (ReadDriverException e) {
|
36 |
// TODO Auto-generated catch block
|
37 |
e.printStackTrace(); |
38 |
} |
39 |
} |
40 |
this.setVisible(layerVect.isVisible());
|
41 |
this.setISpatialIndex(layerVect.getISpatialIndex());
|
42 |
this.setName(layerVect.getName());
|
43 |
this.setCoordTrans(layerVect.getCoordTrans());
|
44 |
|
45 |
try {
|
46 |
this.setLegend((IVectorLegend)layerVect.getLegend().cloneLegend());
|
47 |
} catch (LegendLayerException e) {
|
48 |
// TODO Auto-generated catch block
|
49 |
e.printStackTrace(); |
50 |
} catch (XMLException e) {
|
51 |
// TODO Auto-generated catch block
|
52 |
e.printStackTrace(); |
53 |
} |
54 |
|
55 |
this.setIsLabeled(layerVect.isLabeled());
|
56 |
ILabelingStrategy labelingStrategy=layerVect.getLabelingStrategy(); |
57 |
if (labelingStrategy!=null) |
58 |
this.setLabelingStrategy(labelingStrategy);
|
59 |
|
60 |
this.setProjection(null); |
61 |
} |
62 |
|
63 |
@Override
|
64 |
public XMLEntity getXMLEntity() throws XMLException { |
65 |
XMLEntity xml = super.getXMLEntity();
|
66 |
|
67 |
xml.putProperty("className", FLyrVect.class.getName());
|
68 |
|
69 |
return xml;
|
70 |
} |
71 |
|
72 |
@Override
|
73 |
public Rectangle2D getFullExtent() { |
74 |
System.out.println("Fullextent OSG"); |
75 |
|
76 |
Layer3DProps props3D = Layer3DProps.getLayer3DProps(this);
|
77 |
if(props3D == null) return null; |
78 |
|
79 |
OSGCacheService osgCacheService = (OSGCacheService) props3D |
80 |
.getCacheService(); |
81 |
|
82 |
Vector<Vec3> bbox = osgCacheService.getLayerNode().getBoundingBox();
|
83 |
|
84 |
System.out.println("BBOX: "+bbox.get(0).x()+" "+bbox.get(0).y()+" "+bbox.get(0).z()+" " |
85 |
+bbox.get(1).x()+" "+bbox.get(1).y()+" "+bbox.get(1).z()); |
86 |
|
87 |
if(getMapContext() == null) return null; |
88 |
MapContext3D map3d = (MapContext3D) this.getMapContext();
|
89 |
|
90 |
Rectangle2D extent = new Rectangle2D.Float(); |
91 |
double x = 0, y = 0, w = 0, h = 0; |
92 |
|
93 |
if(map3d.getTerrain() == null) return null; |
94 |
switch(map3d.getTerrain().getCoordinateSystemType())
|
95 |
{ |
96 |
case Terrain.CoordinateSystemType.GEOCENTRIC:
|
97 |
Vec3 point1 = map3d.getTerrain().convertXYZToLatLongHeight(bbox.get(0));
|
98 |
Vec3 point2 = map3d.getTerrain().convertXYZToLatLongHeight(bbox.get(1));
|
99 |
x = point1.y(); |
100 |
y = point1.x(); |
101 |
w = point2.y() - point1.y(); |
102 |
h = point2.x() - point1.x(); |
103 |
break;
|
104 |
case Terrain.CoordinateSystemType.GEOGRAPHIC:
|
105 |
x = bbox.get(0).x();
|
106 |
y = bbox.get(0).y();
|
107 |
w = bbox.get(1).x() - x;
|
108 |
h = bbox.get(1).y() - y;
|
109 |
break;
|
110 |
case Terrain.CoordinateSystemType.PROJECTED:
|
111 |
x = bbox.get(0).x();
|
112 |
y = bbox.get(0).y();
|
113 |
w = bbox.get(1).x() - x;
|
114 |
h = bbox.get(1).y() - y;
|
115 |
break;
|
116 |
} |
117 |
|
118 |
extent.setRect(x, y, w, h); |
119 |
return extent;
|
120 |
} |
121 |
|
122 |
|
123 |
} |