Revision 18268

View differences:

trunk/libraries/lib3DMap/src/com/iver/ai2/gvsig3d/map3d/ViewPort3D.java
8 8

  
9 9
import org.cresques.cts.IProjection;
10 10

  
11
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
12
import com.iver.andami.PluginServices;
13
import com.iver.andami.messages.NotificationManager;
14
import com.iver.andami.ui.mdiManager.IWindow;
11 15
import com.iver.cit.gvsig.fmap.ExtentHistory;
12 16
import com.iver.cit.gvsig.fmap.ViewPort;
13 17
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
18
import com.iver.cit.gvsig.fmap.layers.FLayer;
19
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
14 20
import com.iver.utiles.StringUtilities;
15 21
import com.iver.utiles.XMLEntity;
16 22

  
......
74 80
	 * 
75 81
	 * @throws RuntimeException
76 82
	 */
83
	@Override
77 84
	public Point2D toMapPoint(Point2D pScreen) {
78
		int x = (int) pScreen.getX();
79
		int y = this.getImageHeight() - (int) pScreen.getY() - 1;
85
		
86
		// getting layer information
87
		float heigth= 0;
88
		IWindow f = PluginServices.getMDIManager().getActiveWindow();
89
		if (f instanceof BaseView) {
90
			BaseView baseView = (BaseView) f;
91
			FLayer[] lyrs = baseView.getMapControl().getMapContext().getLayers().getActives();
92
			FLayer layer = lyrs[lyrs.length-1];
93
			Layer3DProps props = Layer3DProps.getLayer3DProps(layer);
94
			heigth = props.getHeigth();
95
			
96
		}
97
		
80 98

  
81
		Intersections hits = canvas3d.getOSGViewer().rayPick(x, y);
99
//		System.err.println("Coordenadas de pantalla " + pScreen.getX() + ","+ pScreen.getY());
100
		Intersections hits = canvas3d.getOSGViewer().rayPick(
101
				(int) pScreen.getX(), (int) pScreen.getY());
82 102
		Point2D pWorld = new Point2D.Double();
83 103
		if (hits.containsIntersections()) {
84 104
			// get XYZ coordinates on planet
85 105
			Vec3 hit = hits.getFirstIntersection().getIntersectionPoint();
86 106
			// convert to geo coordinates
87
			
107

  
108
			// System.err.println("Interseccion de osg " + hit.x() + ","+
109
			// hit.y());
88 110
			if (getProjection().getAbrev().compareToIgnoreCase("EPSG:4326") == 0) {
89
				Vec3 geoPt = planet.convertXYZToLatLongHeight(new Vec3(
90
						(double) hit.x(), (double) hit.y(), (double) hit.x()));
91
				pWorld.setLocation(geoPt.y(), geoPt.x());
92
			} else
93
				pWorld.setLocation((double) hit.x(), (double) hit.y());
111
				Vec3 geoPt = planet.convertXYZToLatLongHeight(hit);
112

  
113
				if (Math.abs(heigth - geoPt.z()) <= 1000) {
114
					pWorld.setLocation(geoPt.y(), geoPt.x());
115
				} else {
116
					pWorld.setLocation(360, 120);
117
				}
118
				NotificationManager.addInfo("Obteniendo punto de informacion "
119
						+ pWorld.getX() + "    ,   " + pWorld.getY());
120
			} else {
121
				if (Math.abs(heigth - hit.z()) <= 100) {
122
					pWorld.setLocation(hit.x(), hit.y());
123
				} else {
124
					pWorld.setLocation(360, 120);
125
				}
126
				NotificationManager.addInfo("Obteniendo punto de informacion "
127
						+ pWorld.getX() + "    ,   " + pWorld.getY());
128
			}
94 129
		} else {
95 130
			if (getProjection().getAbrev().compareToIgnoreCase("EPSG:4326") == 0) {
96 131
				pWorld.setLocation(360, 120);

Also available in: Unified diff