Revision 35474
branches/v2_0_0_prep/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/towkb/WKBNativeTest.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2009 {Iver T.I.} {Task}
|
|
26 |
*/
|
|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.geom.operation.towkb; |
29 | 29 |
|
30 | 30 |
import org.gvsig.fmap.geom.Geometry; |
31 |
import org.gvsig.fmap.geom.Geometry.DIMENSIONS; |
|
31 | 32 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
32 | 33 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
33 | 34 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
45 | 46 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
46 | 47 |
*/ |
47 | 48 |
public class WKBNativeTest extends AbstractLibraryAutoInitTestCase { |
48 |
private GeometryManager manager;
|
|
49 |
private GeometryOperation toWkb2d;
|
|
50 |
private GeometryOperation fromWkb2d;
|
|
51 |
private FromWKBGeometryOperationContext fromWkbContext;
|
|
49 |
private GeometryManager manager;
|
|
50 |
private GeometryOperation toWkb2d;
|
|
51 |
private GeometryOperation fromWkb2d;
|
|
52 |
private FromWKBGeometryOperationContext fromWkbContext;
|
|
52 | 53 |
|
53 | 54 |
protected void doSetUp() throws Exception { |
54 |
manager = GeometryLocator.getGeometryManager();
|
|
55 |
toWkb2d = manager.getGeometryOperation(ToWKBNative.CODE,
|
|
56 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
|
|
57 |
fromWkb2d = manager.getGeometryOperation(FromWKB.CODE,
|
|
58 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
|
|
59 |
fromWkbContext = new FromWKBGeometryOperationContext();
|
|
60 |
}
|
|
55 |
manager = GeometryLocator.getGeometryManager();
|
|
56 |
toWkb2d = manager.getGeometryOperation(ToWKBNative.CODE,
|
|
57 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
|
|
58 |
fromWkb2d = manager.getGeometryOperation(FromWKB.CODE,
|
|
59 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
|
|
60 |
fromWkbContext = new FromWKBGeometryOperationContext();
|
|
61 |
}
|
|
61 | 62 |
|
62 |
public void testPoint() throws Exception{
|
|
63 |
Point point = (Point) manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
|
|
64 |
point.setX(1);
|
|
65 |
point.setY(2);
|
|
66 |
byte[] wkb = (byte[]) toWkb2d.invoke(point,
|
|
67 |
null);
|
|
68 |
fromWkbContext.setData(wkb);
|
|
69 |
Geometry geom = (Geometry) fromWkb2d.invoke(null,
|
|
70 |
fromWkbContext);
|
|
63 |
public void testPoint() throws Exception{
|
|
64 |
Point point = (Point) manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
|
|
65 |
point.setX(1);
|
|
66 |
point.setY(2);
|
|
67 |
byte[] wkb = (byte[]) toWkb2d.invoke(point,
|
|
68 |
null);
|
|
69 |
fromWkbContext.setData(wkb);
|
|
70 |
Geometry geom = (Geometry) fromWkb2d.invoke(null,
|
|
71 |
fromWkbContext);
|
|
71 | 72 |
|
72 |
assertEquals(point, geom);
|
|
73 |
}
|
|
73 |
assertEquals(point, geom);
|
|
74 |
}
|
|
74 | 75 |
|
75 |
public void testCurve() throws Exception {
|
|
76 |
public void testCurve() throws Exception {
|
|
76 | 77 |
|
77 |
GeneralPathX gp = new GeneralPathX();
|
|
78 |
GeneralPathX gp = new GeneralPathX();
|
|
78 | 79 |
|
79 |
gp.moveTo(0.0, 0.0);
|
|
80 |
gp.lineTo(1.0, 1.0);
|
|
81 |
gp.lineTo(2.0, 2.0);
|
|
82 |
gp.lineTo(3.0, 3.0);
|
|
83 |
Curve curve = (Curve) manager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
|
|
84 |
curve.setGeneralPath(gp);
|
|
85 |
byte[] wkb = (byte[]) toWkb2d.invoke(curve,
|
|
86 |
null);
|
|
87 |
fromWkbContext.setData(wkb);
|
|
88 |
Geometry geom = (Geometry) fromWkb2d.invoke(null,
|
|
89 |
fromWkbContext);
|
|
90 |
assertTrue(curve.equals(geom));
|
|
91 |
}
|
|
80 |
gp.moveTo(0.0, 0.0);
|
|
81 |
gp.lineTo(1.0, 1.0);
|
|
82 |
gp.lineTo(2.0, 2.0);
|
|
83 |
gp.lineTo(3.0, 3.0);
|
|
84 |
Curve curve = (Curve) manager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
|
|
85 |
curve.setGeneralPath(gp);
|
|
86 |
byte[] wkb = (byte[]) toWkb2d.invoke(curve,
|
|
87 |
null);
|
|
88 |
fromWkbContext.setData(wkb);
|
|
89 |
Geometry geom = (Geometry) fromWkb2d.invoke(null,
|
|
90 |
fromWkbContext);
|
|
91 |
assertTrue(curve.equals(geom));
|
|
92 |
}
|
|
92 | 93 |
|
93 |
public void testPolygon() throws Exception {
|
|
94 |
GeneralPathX gp = new GeneralPathX();
|
|
95 |
gp.moveTo(1.0, 1.0);
|
|
96 |
gp.lineTo(2.0, 2.0);
|
|
97 |
gp.lineTo(3.0, 3.0);
|
|
98 |
gp.lineTo(4.0, 4.0);
|
|
99 |
gp.lineTo(5.0, 5.0);
|
|
100 |
gp.closePath();
|
|
94 |
public void testPolygon() throws Exception {
|
|
95 |
GeneralPathX gp = new GeneralPathX();
|
|
96 |
gp.moveTo(1.0, 1.0);
|
|
97 |
gp.lineTo(2.0, 2.0);
|
|
98 |
gp.lineTo(3.0, 3.0);
|
|
99 |
gp.lineTo(4.0, 4.0);
|
|
100 |
gp.lineTo(5.0, 5.0);
|
|
101 |
gp.closePath();
|
|
101 | 102 |
|
102 |
Surface surface = manager.createSurface(gp, SUBTYPES.GEOM2D);
|
|
103 |
Surface surface = manager.createSurface(gp, SUBTYPES.GEOM2D);
|
|
103 | 104 |
|
104 |
byte[] wkb = (byte[]) toWkb2d.invoke(surface, null); |
|
105 |
fromWkbContext.setData(wkb); |
|
106 |
Geometry geom = (Geometry) fromWkb2d.invoke(null, fromWkbContext); |
|
107 |
assertTrue(surface.equals(geom)); |
|
105 |
byte[] wkb = (byte[]) toWkb2d.invoke(surface, null); |
|
106 |
fromWkbContext.setData(wkb); |
|
107 |
Geometry geom = (Geometry) fromWkb2d.invoke(null, fromWkbContext); |
|
108 |
assertTrue(surface.equals(geom)); |
|
109 |
} |
|
108 | 110 |
|
109 |
} |
|
110 |
|
|
111 |
// public void testPolygonWithZ() throws Exception { |
|
112 |
// Surface surface = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM3D); |
|
113 |
// |
|
114 |
// Point point = manager.createPoint(1, 1, SUBTYPES.GEOM3D); |
|
115 |
// point.setCoordinateAt(DIMENSIONS.Z, 1); |
|
116 |
// surface.addMoveToVertex(point); |
|
117 |
// |
|
118 |
// point = manager.createPoint(2, 2, SUBTYPES.GEOM3D); |
|
119 |
// point.setCoordinateAt(DIMENSIONS.Z, 2); |
|
120 |
// surface.addVertex(point); |
|
121 |
// |
|
122 |
// point = manager.createPoint(3, 3, SUBTYPES.GEOM3D); |
|
123 |
// point.setCoordinateAt(DIMENSIONS.Z, 3); |
|
124 |
// surface.addVertex(point); |
|
125 |
// |
|
126 |
// point = manager.createPoint(4, 4, SUBTYPES.GEOM3D); |
|
127 |
// point.setCoordinateAt(DIMENSIONS.Z, 4); |
|
128 |
// surface.addVertex(point); |
|
129 |
// |
|
130 |
// point = manager.createPoint(5, 5, SUBTYPES.GEOM3D); |
|
131 |
// point.setCoordinateAt(DIMENSIONS.Z, 5); |
|
132 |
// surface.addVertex(point); |
|
133 |
// |
|
134 |
// surface.closePrimitive(); |
|
135 |
// |
|
136 |
// byte[] wkb = (byte[]) toWkb2d.invoke(surface, null); |
|
137 |
// fromWkbContext.setData(wkb); |
|
138 |
// Geometry geom = (Geometry) fromWkb2d.invoke(null, fromWkbContext); |
|
139 |
// assertTrue(surface.equals(geom)); |
|
140 |
// } |
|
111 | 141 |
} |
112 | 142 |
|
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/fromwkb/WKBParser2.java | ||
---|---|---|
28 | 28 |
*/ |
29 | 29 |
package org.gvsig.fmap.geom.operation.fromwkb; |
30 | 30 |
|
31 |
import java.awt.geom.PathIterator; |
|
32 | 31 |
import java.nio.ByteBuffer; |
33 | 32 |
import java.nio.ByteOrder; |
34 | 33 |
|
... | ... | |
46 | 45 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
47 | 46 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
48 | 47 |
import org.gvsig.fmap.geom.primitive.Curve; |
49 |
import org.gvsig.fmap.geom.primitive.GeneralPathX;
|
|
48 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
|
|
50 | 49 |
import org.gvsig.fmap.geom.primitive.Point; |
51 | 50 |
import org.gvsig.fmap.geom.primitive.Primitive; |
52 | 51 |
import org.gvsig.fmap.geom.primitive.Surface; |
53 | 52 |
import org.gvsig.fmap.geom.primitive.impl.Point2D; |
54 |
import org.gvsig.fmap.geom.primitive.impl.Surface2D; |
|
55 | 53 |
import org.gvsig.fmap.geom.type.GeometryType; |
56 | 54 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
57 | 55 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
... | ... | |
324 | 322 |
|
325 | 323 |
private Curve parseLineString(ByteBuffer data, boolean haveZ, boolean haveM) throws CreateGeometryException { |
326 | 324 |
Point[] points = parsePointArray(data, haveZ, haveM); |
327 |
GeneralPathX gp = new GeneralPathX();
|
|
328 |
gp.moveTo(points[0].getX(), points[0].getY());
|
|
325 |
Curve curve = (Curve) geomManager.create(TYPES.CURVE, getSubType(haveZ, haveM));
|
|
326 |
curve.addMoveToVertex(points[0]);
|
|
329 | 327 |
for (int i = 1; i< points.length; i++) |
330 | 328 |
{ |
331 |
gp.lineTo(points[i].getX(), points[i].getY());
|
|
329 |
curve.addVertex(points[i]);
|
|
332 | 330 |
} |
333 |
return (Curve) geomManager.createCurve(gp, SUBTYPES.GEOM2D);
|
|
331 |
return curve;
|
|
334 | 332 |
} |
335 | 333 |
|
336 |
private Surface parseLinearRing(ByteBuffer data, boolean haveZ, boolean haveM) throws CreateGeometryException {
|
|
334 |
private void fillLinearRing(ByteBuffer data, OrientablePrimitive orientablePrimitive, boolean haveZ, boolean haveM) throws CreateGeometryException {
|
|
337 | 335 |
Point[] points = parsePointArray(data, haveZ, haveM); |
338 |
GeneralPathX gp = new GeneralPathX(); |
|
339 |
gp.moveTo(points[0].getX(), points[0].getY()); |
|
340 |
for (int i = 1; i< points.length; i++) |
|
336 |
|
|
337 |
orientablePrimitive.addMoveToVertex(points[0]); |
|
338 |
int lastPoint = points.length - 1; |
|
339 |
for (int i = 1; i< lastPoint; i++) |
|
341 | 340 |
{ |
342 |
gp.lineTo(points[i].getX(), points[i].getY()); |
|
343 |
} |
|
344 |
return (Surface) geomManager.createSurface(gp, SUBTYPES.GEOM2D); |
|
341 |
orientablePrimitive.addVertex(points[i]); |
|
342 |
} |
|
345 | 343 |
} |
346 | 344 |
|
347 | 345 |
private Surface parsePolygon(ByteBuffer data, boolean haveZ, boolean haveM) throws CreateGeometryException { |
348 | 346 |
int count = data.getInt(); |
349 |
Surface[] rings = new Surface2D[count]; |
|
347 |
int subType = getSubType(haveZ, haveM); |
|
348 |
|
|
349 |
Surface surface = (Surface) geomManager.create(TYPES.SURFACE, subType); |
|
350 |
|
|
350 | 351 |
for (int i = 0; i < count; i++) { |
351 |
rings[i] = parseLinearRing(data, haveZ, haveM); |
|
352 |
|
|
352 |
fillLinearRing(data, surface, haveZ, haveM); |
|
353 | 353 |
} |
354 |
GeneralPathX shape=getGeneralPathX(rings); |
|
355 |
if (!shape.isClosed()) { |
|
356 |
shape.closePath(); |
|
357 |
} |
|
358 |
return (Surface) geomManager.createSurface(shape, SUBTYPES.GEOM2D); |
|
354 |
|
|
355 |
surface.closePrimitive(); |
|
356 |
|
|
357 |
return surface; |
|
359 | 358 |
} |
359 |
|
|
360 | 360 |
private Curve parseMultiLineString(ByteBuffer data) throws CreateGeometryException { |
361 |
GeneralPathX gp = parseGeneralPath(data); |
|
362 |
// GeneralPathX shape=getGeneralPathX(strings); |
|
363 |
|
|
364 |
// parseGeometryArray(data, strings); |
|
365 |
return (Curve) geomManager.createCurve(gp, SUBTYPES.GEOM2D);//strings[0]; //new MultiLineString(strings); |
|
361 |
Curve curve = (Curve) geomManager.create(TYPES.CURVE, getSubType(gHaveZ, gHaveM)); |
|
362 |
fillOrientablePrimitive(data, curve); |
|
363 |
return curve; |
|
366 | 364 |
} |
367 | 365 |
|
368 | 366 |
/** |
... | ... | |
370 | 368 |
* @return |
371 | 369 |
* @throws CreateGeometryException |
372 | 370 |
*/ |
373 |
private GeneralPathX parseGeneralPath(ByteBuffer data)
|
|
371 |
private void fillOrientablePrimitive(ByteBuffer data, OrientablePrimitive orientablePrimitive)
|
|
374 | 372 |
throws CreateGeometryException { |
375 | 373 |
int count = data.getInt(); |
376 |
// FPolyline2D[] strings = new FPolyline2D[count]; |
|
377 |
GeneralPathX gp = new GeneralPathX(); |
|
374 |
|
|
378 | 375 |
for (int i=0; i < count; i++) |
379 | 376 |
{ |
380 | 377 |
parseTypeAndSRID(data); |
381 | 378 |
Point[] points = parsePointArray(data, gHaveZ, gHaveM); |
382 |
// int count2 = data.getInt(); |
|
383 |
/* |
|
384 |
* FPoint2D[] result = new FPoint2D[count2]; |
|
385 |
* for (int i = 0; i < count; i++) { |
|
386 |
* result[i] = parsePoint(data, haveZ, haveM); |
|
387 |
* } |
|
388 |
* return result; |
|
389 |
*/ |
|
390 |
/* |
|
391 |
* FPoint2D p = parsePoint(data, gHaveZ, gHaveM); |
|
392 |
* gp.moveTo(p.getX(), p.getY()); |
|
393 |
* for (int j = 1; j < count2; j++) { |
|
394 |
* p = parsePoint(data, gHaveZ, gHaveM); |
|
395 |
* gp.lineTo(p.getX(), p.getY()); |
|
396 |
* } |
|
397 |
*/ |
|
398 |
|
|
399 |
gp.moveTo(points[0].getX(), points[0].getY()); |
|
379 |
|
|
380 |
orientablePrimitive.addMoveToVertex(points[0]); |
|
400 | 381 |
for (int j = 1; j < points.length; j++) { |
401 |
gp.lineTo(points[j].getX(), points[j].getY()); |
|
402 |
} |
|
403 |
|
|
404 |
// strings[i] = parseLineString(data, gHaveZ, gHaveM); |
|
405 |
} |
|
406 |
return gp; |
|
382 |
orientablePrimitive.addVertex(points[j]); |
|
383 |
} |
|
384 |
} |
|
407 | 385 |
} |
408 | 386 |
|
409 | 387 |
private Surface parseMultiPolygon(ByteBuffer data) |
410 | 388 |
throws CreateGeometryException { |
411 | 389 |
int count = data.getInt(); |
412 |
// If we keep the GeneralPathX usage, we need to be able to create |
|
413 |
// different implementations based on geometry subtype. |
|
414 |
GeneralPathX gp = new GeneralPathX(); |
|
390 |
|
|
391 |
int subType = getSubType(gHaveZ, gHaveM); |
|
392 |
Surface surface = (Surface)geomManager.create(TYPES.SURFACE, subType); |
|
393 |
|
|
394 |
Point point; |
|
415 | 395 |
for (int i = 0; i < count; i++) { |
416 | 396 |
parseTypeAndSRID(data); |
417 |
int countRings = data.getInt(); |
|
397 |
int countRings = data.getInt();
|
|
418 | 398 |
for (int j = 0; j < countRings; j++) { |
419 | 399 |
double[][] points = |
420 | 400 |
parsePointsAsDoubleArray(data, gHaveZ, gHaveM); |
421 |
// TODO: this way the Z and M values are lost!! |
|
422 |
gp.addPoligon(points); |
|
401 |
|
|
402 |
//Add the initial point |
|
403 |
surface.addMoveToVertex(geomManager.createPoint(points[0][0], points[0][1], subType)); |
|
404 |
|
|
405 |
//Add the other points |
|
406 |
int lastPoint = points.length - 1; |
|
407 |
for (int k=1 ; k<lastPoint ; k++){ |
|
408 |
point = geomManager.createPoint(points[k][0], points[k][1], subType); |
|
409 |
for (int l=2 ; l<points[k].length ; i++){ |
|
410 |
point.setCoordinateAt(l, points[k][l]); |
|
411 |
} |
|
412 |
surface.addVertex(point); |
|
413 |
} |
|
414 |
surface.closePrimitive(); |
|
423 | 415 |
} |
424 | 416 |
} |
425 |
|
|
426 |
// TODO: this way the Z and M values are lost!! |
|
427 |
// TODO: implement OrientablePrimitive vertex manipulation methods |
|
428 |
return (Surface) geomManager.createSurface(gp, SUBTYPES.GEOM2D); |
|
417 |
return surface; |
|
429 | 418 |
} |
430 | 419 |
|
431 | 420 |
private MultiPrimitive parseCollection(ByteBuffer data) throws CreateGeometryException { |
... | ... | |
437 | 426 |
multiPrimitive.addPrimitive((Primitive) geoms[i]); |
438 | 427 |
} |
439 | 428 |
return multiPrimitive; |
440 |
} |
|
441 |
/** |
|
442 |
* Devuelve el GeneralPathX compuesto por todos los GeneralPath de todas |
|
443 |
* las geometr?as que componen el elemento. |
|
444 |
* |
|
445 |
* @param geometries Lista de geometr?as. |
|
446 |
* |
|
447 |
* @return GeneralPath completo. |
|
448 |
*/ |
|
449 |
private GeneralPathX getGeneralPathX(Geometry[] geometries) { |
|
450 |
GeneralPathX shape = new GeneralPathX(); |
|
451 |
|
|
452 |
for (int i = 0; i < geometries.length; i++) { |
|
453 |
Geometry shp = geometries[i]; |
|
454 |
PathIterator theIterator = shp.getPathIterator(null); //, flatness); |
|
455 |
double[] theData = new double[6]; |
|
456 |
int theType; |
|
457 |
// ArrayList arrayCoords; |
|
458 |
|
|
459 |
while (!theIterator.isDone()) { |
|
460 |
//while not done |
|
461 |
theType = theIterator.currentSegment(theData); |
|
462 |
|
|
463 |
//Populate a segment of the new |
|
464 |
// GeneralPathX object. |
|
465 |
//Process the current segment to populate a new |
|
466 |
// segment of the new GeneralPathX object. |
|
467 |
switch (theType) { |
|
468 |
case PathIterator.SEG_MOVETO: |
|
469 |
shape.moveTo(theData[0], theData[1]); |
|
470 |
|
|
471 |
break; |
|
472 |
|
|
473 |
case PathIterator.SEG_LINETO: |
|
474 |
shape.lineTo(theData[0], theData[1]); |
|
475 |
|
|
476 |
break; |
|
477 |
|
|
478 |
case PathIterator.SEG_QUADTO: |
|
479 |
shape.quadTo(theData[0], theData[1], theData[2], |
|
480 |
theData[3]); |
|
481 |
|
|
482 |
break; |
|
483 |
|
|
484 |
case PathIterator.SEG_CUBICTO: |
|
485 |
shape.curveTo(theData[0], theData[1], theData[2], |
|
486 |
theData[3], theData[4], theData[5]); |
|
487 |
|
|
488 |
break; |
|
489 |
|
|
490 |
case PathIterator.SEG_CLOSE: |
|
491 |
|
|
492 |
if (i == (geometries.length - 1)) { |
|
493 |
shape.closePath(); |
|
494 |
} |
|
495 |
|
|
496 |
break; |
|
497 |
} //end switch |
|
498 |
|
|
499 |
theIterator.next(); |
|
500 |
} //end while loop |
|
501 |
} |
|
502 |
|
|
503 |
return shape; |
|
504 |
} |
|
429 |
} |
|
505 | 430 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/AbstractPrimitive.java | ||
---|---|---|
292 | 292 |
// FIXME when 3D, 2DM and 3DM |
293 | 293 |
double[] myData = new double[6]; |
294 | 294 |
double[] otherData = new double[6]; |
295 |
double[] myFirst = new double[] { myPath.getPointCoords()[0],myPath.getPointCoords()[1]};
|
|
296 |
double[] otherFirst = new double[] { otherPath.getPointCoords()[0],otherPath.getPointCoords()[1]};
|
|
295 |
double[] myFirst = new double[] { myPath.getPointAt(0).getX(),myPath.getPointAt(0).getY()};
|
|
296 |
double[] otherFirst = new double[] { otherPath.getPointAt(0).getX(),otherPath.getPointAt(0).getY()};
|
|
297 | 297 |
|
298 | 298 |
while (!myIter.isDone()) { |
299 | 299 |
if (otherIter.isDone()) { |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/GeneralPathX.java | ||
---|---|---|
293 | 293 |
} |
294 | 294 |
|
295 | 295 |
/** |
296 |
* @param points |
|
297 |
*/ |
|
298 |
public void addPoligon(double[][] points) { |
|
299 |
// Go to the initial point |
|
300 |
moveTo(points[0][0], points[0][1]); |
|
301 |
|
|
302 |
// Add all the poligon points but the first and last ones |
|
303 |
needRoom(points.length, points.length * 2, true); |
|
304 |
int lastPoint = points.length - 1; |
|
305 |
for (int k = 1; k < lastPoint; k++) { |
|
306 |
pointTypes.add(SEG_LINETO); |
|
307 |
addPoint(points[k][0], points[k][1]); |
|
308 |
} |
|
309 |
// Close the poligon |
|
310 |
closePath(); |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 | 296 |
* Adds a curved segment, defined by two new points, to the path by |
315 | 297 |
* drawing a Quadratic curve that intersects both the current |
316 | 298 |
* coordinates and the coordinates (x2, y2), using the |
Also available in: Unified diff