Revision 9447
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/util/UnitUtils.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.5 2006-12-21 18:25:30 azabala |
|
48 |
* Revision 1.6 2006-12-22 09:02:03 caballero |
|
49 |
* Tener en cuenta tanto las unidades reales como las de medida |
|
50 |
* |
|
51 |
* Revision 1.5 2006/12/21 18:25:30 azabala |
|
49 | 52 |
* bug fixed (change getMapUnits with getDistanceUnits) |
50 | 53 |
* |
51 | 54 |
* Revision 1.4 2006/09/15 10:42:54 caballero |
... | ... | |
74 | 77 |
/** |
75 | 78 |
* Utility methods to manage distances |
76 | 79 |
* (conversion from user entries to internal units, |
77 |
* verifying if projection is planar or we are
|
|
80 |
* verifying if projection is planar or we are |
|
78 | 81 |
* working with geographic coordinates, etc.) |
79 | 82 |
* @author azabala |
80 | 83 |
* |
81 | 84 |
*/ |
82 | 85 |
public class UnitUtils { |
83 |
|
|
86 |
|
|
84 | 87 |
public static final double EARTH_RADIUS = 6378137d; |
85 | 88 |
|
86 | 89 |
/** |
87 | 90 |
* For computing with geodetic coordinates: |
88 | 91 |
* returns the angular measure (in radians) |
89 |
* for a distance over the earth along a
|
|
92 |
* for a distance over the earth along a |
|
90 | 93 |
* meridiam. |
91 | 94 |
* Because this consideration is an approximation, |
92 | 95 |
* we consideer the eart like an sphere (not an |
... | ... | |
102 | 105 |
*/ |
103 | 106 |
return Math.toDegrees((2 * Math.PI * dist)/EARTH_RADIUS); |
104 | 107 |
} |
105 |
|
|
108 |
|
|
106 | 109 |
/** |
107 | 110 |
* Converts a distance entered by user in the GUI in the same distance |
108 | 111 |
* in internal units (measure units) |
109 |
*
|
|
112 |
* |
|
110 | 113 |
* */ |
111 | 114 |
public static double getInInternalUnits(double userEntryDistance){ |
115 |
// VCN he modificado esto a como creo que deber?a de estar, as? tiene en cuenta para calcular la distancia tanto las unidades |
|
116 |
//en las que se encuentra la cartograf?a como las unidades de medida seleccionadas por el usuario. |
|
117 |
int distanceUnits = ((View)PluginServices. |
|
118 |
getMDIManager(). |
|
119 |
getActiveWindow()).getMapControl().getViewPort().getDistanceUnits(); |
|
112 | 120 |
int mapUnits = ((View)PluginServices. |
113 | 121 |
getMDIManager(). |
114 |
getActiveWindow()).getMapControl().getViewPort().getDistanceUnits();
|
|
115 |
double distInInternalUnits = userEntryDistance * MapContext.CHANGEM[mapUnits];
|
|
122 |
getActiveWindow()).getMapControl().getViewPort().getMapUnits();
|
|
123 |
double distInInternalUnits = (userEntryDistance/MapContext.CHANGEM[distanceUnits]) * MapContext.CHANGEM[mapUnits];
|
|
116 | 124 |
/* |
117 | 125 |
* if layer's projections is in geographics |
118 | 126 |
coords, pass distance to a angular measure |
... | ... | |
125 | 133 |
getProjection(); |
126 | 134 |
if( (proj != null) && !(proj instanceof CSUTM)){ |
127 | 135 |
distInInternalUnits = |
128 |
UnitUtils.toSexaAngularMeasure(distInInternalUnits);
|
|
136 |
UnitUtils.toSexaAngularMeasure(distInInternalUnits); |
|
129 | 137 |
} |
130 | 138 |
return distInInternalUnits; |
131 | 139 |
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
138 | 146 |
} |
139 | 147 |
|
Also available in: Unified diff