Revision 12043 trunk/libraries/libFMap/src-test/com/iver/cit/gvsig/fmap/core/symbols/TestCartographySupport.java
TestCartographySupport.java | ||
---|---|---|
58 | 58 |
import com.iver.cit.gvsig.fmap.MapContext; |
59 | 59 |
import com.iver.cit.gvsig.fmap.ViewPort; |
60 | 60 |
import com.iver.cit.gvsig.fmap.core.CartographicSupport; |
61 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
61 | 62 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
62 | 63 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
63 | 64 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
65 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
64 | 66 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
65 | 67 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
66 | 68 |
import com.iver.utiles.IPersistance; |
... | ... | |
72 | 74 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
73 | 75 |
*/ |
74 | 76 |
public class TestCartographySupport extends TestCase { |
77 |
/** |
|
78 |
* Geodesic vertex of the Micalet in Valencia (Spain) in <b>EPSG:23030</b> |
|
79 |
*/ |
|
80 |
public static final FPoint2D valenciaUTM30 = new FPoint2D(725846.080, 4373022.720); |
|
81 |
|
|
82 |
/** |
|
83 |
* Geodesic vertex of the Micalet in Valencia (Spain) in <b>EPSG:4326</b> |
|
84 |
*/ |
|
85 |
public static final FPoint2D valenciaGeo = new FPoint2D(- (0+ 22/60 + 27.919/3600), 39 + 28/60 + 35.4276/3600); |
|
86 |
/** |
|
87 |
* Extent that covers the whole Comunitat Valenciana in <b>EPSG:23030</b> |
|
88 |
*/ |
|
89 |
public static final Rectangle2D TEST_UTM30_EXTENT = new Rectangle2D.Double(); |
|
90 |
{ |
|
91 |
TEST_UTM30_EXTENT.setFrameFromDiagonal( |
|
92 |
4191037.369934333, |
|
93 |
626674.7454557443, |
|
94 |
|
|
95 |
4519266.460824658, |
|
96 |
797903.2656794232 |
|
97 |
); |
|
98 |
} |
|
99 |
/** |
|
100 |
* Extent that covers the whole Comunitat Valenciana in <b>EPSG:4326</b> |
|
101 |
*/ |
|
102 |
|
|
103 |
public static final Rectangle2D TEST_GEO_EXTENT = new Rectangle2D.Double(); |
|
104 |
{ |
|
105 |
TEST_GEO_EXTENT.setFrameFromDiagonal( |
|
106 |
|
|
107 |
- (1 + (31/60) + (28.09/3600)), // Western egde |
|
108 |
37 + (50/60) + (48.05/3600), // Southern edge |
|
109 |
|
|
110 |
0 + (31/60) + (1.85/3600), // Eastern edge |
|
111 |
40 + (47/60) + (21.36/3600) // Northern edge |
|
112 |
|
|
113 |
); |
|
114 |
} |
|
115 |
|
|
116 |
public static final Rectangle2D TEST_EXTENT = new Rectangle2D.Double( |
|
117 |
4191037.369934333, |
|
118 |
626674.7454557443, |
|
119 |
|
|
120 |
4519266.460824658 - 4191037.369934333, |
|
121 |
797903.2656794232 - 626674.7454557443 |
|
122 |
); |
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
75 | 127 |
private CartographicSupport[] symbols; |
76 | 128 |
private long[] scales = new long[] { |
77 | 129 |
|
... | ... | |
107 | 159 |
public void testCartographicSupportInSymbolUnitDefinition() { |
108 | 160 |
for (int i = 0; i < symbols.length; i++) { |
109 | 161 |
XMLEntity xml = ((IPersistance) symbols[i]).getXMLEntity(); |
162 |
String name = symbols[i].getClass().getName().substring( |
|
163 |
symbols[i].getClass().getName().lastIndexOf('.')+1, |
|
164 |
symbols[i].getClass().getName().length()); |
|
165 |
|
|
110 | 166 |
try { |
111 | 167 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not declare units correctly", |
112 | 168 |
symbols[i].getUnit() == xml.getIntProperty("unit")); |
... | ... | |
123 | 179 |
} |
124 | 180 |
|
125 | 181 |
xml.putProperty("unit", 3); |
126 |
assertTrue("The application of the UNIT value to the XMLEntity doesn't had any effect", symbols[i].getUnit() == 3); |
|
182 |
ISymbol ts = SymbologyFactory.createSymbolFromXML(xml, xml.getStringProperty("desc")); |
|
183 |
assertTrue("The application of the UNIT value to the XMLEntity doesn't had any effect ("+name+")", ((CartographicSupport) ts).getUnit() == 3); |
|
127 | 184 |
} |
128 | 185 |
} |
129 | 186 |
|
... | ... | |
131 | 188 |
public void testCartographicSupportInSymbolReferenceSystemDefinition() { |
132 | 189 |
for (int i = 0; i < symbols.length; i++) { |
133 | 190 |
XMLEntity xml = ((IPersistance) symbols[i]).getXMLEntity(); |
191 |
String name = symbols[i].getClass().getName().substring( |
|
192 |
symbols[i].getClass().getName().lastIndexOf('.')+1, |
|
193 |
symbols[i].getClass().getName().length()); |
|
134 | 194 |
try { |
135 | 195 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not declare units correctly", |
136 | 196 |
symbols[i].getReferenceSystem() == xml.getIntProperty("referenceSystem")); |
137 | 197 |
} catch (NotExistInXMLEntity neiXMLEx) { |
138 |
fail(((ISymbol) symbols[i]).getClassName()+ " does not declare field attribute in its XMLEntity"); |
|
198 |
fail(((ISymbol) symbols[i]).getClassName()+ " does not declare referenceSystem field attribute in its XMLEntity");
|
|
139 | 199 |
} |
140 | 200 |
symbols[i].setReferenceSystem(CartographicSupport.PAPER); |
141 | 201 |
try { |
142 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not apply changes to symbol",symbols[i].getUnit()== 5);
|
|
143 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not declare units correctly",
|
|
202 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not apply changes to symbol",symbols[i].getReferenceSystem()== CartographicSupport.PAPER);
|
|
203 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not declare referenceSystem correctly",
|
|
144 | 204 |
CartographicSupport.PAPER == ((IPersistance) symbols[i]).getXMLEntity().getIntProperty("referenceSystem")); |
145 | 205 |
} catch (NotExistInXMLEntity neiXMLEx) { |
146 |
fail(((ISymbol) symbols[i]).getClassName()+ " does not declare field attribute in its XMLEntity");
|
|
206 |
fail(((ISymbol) symbols[i]).getClassName()+ " does not declare referenceSystem field attribute in its XMLEntity ("+name+")");
|
|
147 | 207 |
} |
148 | 208 |
|
149 | 209 |
symbols[i].setReferenceSystem(CartographicSupport.WORLD); |
150 | 210 |
try { |
151 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not apply changes to symbol",symbols[i].getUnit()== 5);
|
|
152 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not declare units correctly",
|
|
211 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not apply changes to symbol",symbols[i].getReferenceSystem()== CartographicSupport.WORLD);
|
|
212 |
assertTrue( ((ISymbol) symbols[i]).getClassName()+" does not declare referenceSystem correctly",
|
|
153 | 213 |
CartographicSupport.WORLD == ((IPersistance) symbols[i]).getXMLEntity().getIntProperty("referenceSystem")); |
154 | 214 |
} catch (NotExistInXMLEntity neiXMLEx) { |
155 |
fail(((ISymbol) symbols[i]).getClassName()+ " does not declare field attribute in its XMLEntity"); |
|
215 |
fail(((ISymbol) symbols[i]).getClassName()+ " does not declare referenceSystem field attribute in its XMLEntity");
|
|
156 | 216 |
} |
157 | 217 |
|
158 | 218 |
xml.putProperty("referenceSystem", CartographicSupport.PAPER); |
159 |
assertTrue("The application of the REFERENCE SYSTEM value to the XMLEntity doesn't had any effect", symbols[i].getReferenceSystem() == CartographicSupport.PAPER); |
|
219 |
assertTrue("The application of the REFERENCE SYSTEM value to the XMLEntity doesn't had any effect ("+name+")", symbols[i].getReferenceSystem() == CartographicSupport.PAPER);
|
|
160 | 220 |
} |
161 | 221 |
} |
162 | 222 |
|
... | ... | |
195 | 255 |
sym.setLineColor(Color.RED); |
196 | 256 |
|
197 | 257 |
// setup MapContext and ViewPort |
198 |
MapContext mc = AllTests.newMapContext(AllTests.TEST_PROJECTION_DEFAULT);
|
|
258 |
MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_MERCATOR_PROJECTION);
|
|
199 | 259 |
ViewPort viewPort = mc.getViewPort(); |
200 | 260 |
|
201 | 261 |
// A thin extent from Valencia to Alacant (EPSG:23030) |
... | ... | |
204 | 264 |
4233679.785765858, |
205 | 265 |
47071.474971979726, |
206 | 266 |
155028.87952728104); |
207 |
|
|
267 |
|
|
208 | 268 |
viewPort.setExtent(extent); |
209 | 269 |
|
210 | 270 |
// A thin dimension more or less like the extent above |
211 | 271 |
viewPort.setImageSize(new Dimension(90, 300)); |
212 |
|
|
272 |
|
|
213 | 273 |
// con este extent y tama?o |
214 | 274 |
|
215 | 275 |
// will draw the symbol in the mapcontext's graphic layer |
Also available in: Unified diff