Revision 77 trunk/org.gvsig.dwg/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/util/FMapUtil.java
FMapUtil.java | ||
---|---|---|
29 | 29 |
private static final GeometryManager gManager = GeometryLocator |
30 | 30 |
.getGeometryManager(); |
31 | 31 |
|
32 |
public static MultiCurve ptsToMultiLine(List<double[]> pts, int subType)
|
|
32 |
public static Line ptsToLine(List<double[]> pts, int subType)
|
|
33 | 33 |
throws CreateGeometryException { |
34 | 34 |
|
35 | 35 |
if (pts.size() < 2) { |
36 | 36 |
throw new IllegalArgumentException(); |
37 | 37 |
} |
38 |
|
|
39 |
Point point, prevPoint; |
|
40 |
Line line; |
|
41 |
|
|
42 |
MultiLine multi = gManager.createMultiLine(subType); |
|
43 |
prevPoint = FMapUtil.createPoint(subType, pts.get(0)); |
|
44 |
for (int i = 1; i < pts.size(); i++) { |
|
45 |
point = FMapUtil.createPoint(subType, pts.get(i)); |
|
46 |
line = gManager.createLine(subType); |
|
47 |
line.addVertex(prevPoint); |
|
48 |
line.addVertex(point); |
|
49 |
multi.addPrimitive(line); |
|
50 |
prevPoint = FMapUtil.createPoint(subType, pts.get(i)); |
|
38 |
boolean is3D = subType == Geometry.SUBTYPES.GEOM3D || subType == Geometry.SUBTYPES.GEOM3DM; |
|
39 |
Line line = gManager.createLine(subType); |
|
40 |
for (double[] p : pts) { |
|
41 |
if( is3D ) { |
|
42 |
line.addVertex(p[0],p[1],p[2]); |
|
43 |
} else { |
|
44 |
line.addVertex(p[0],p[1]); |
|
45 |
} |
|
51 | 46 |
} |
52 |
return multi; |
|
53 |
|
|
47 |
return line; |
|
54 | 48 |
} |
55 | 49 |
|
56 | 50 |
public static Surface ptsToPolygon(List<double[]> pts, int subType) |
... | ... | |
60 | 54 |
throw new IllegalArgumentException(); |
61 | 55 |
} |
62 | 56 |
|
57 |
boolean is3D = subType == Geometry.SUBTYPES.GEOM3D || subType == Geometry.SUBTYPES.GEOM3DM; |
|
63 | 58 |
Polygon polygon = gManager.createPolygon(subType); |
64 |
|
|
65 |
Iterator<double[]> iter = pts.iterator(); |
|
66 |
while (iter.hasNext()) { |
|
67 |
Point vertex = createPoint(subType, iter.next()); |
|
68 |
polygon.addVertex(vertex); |
|
59 |
for (double[] p : pts) { |
|
60 |
if( is3D ) { |
|
61 |
polygon.addVertex(p[0],p[1],p[2]); |
|
62 |
} else { |
|
63 |
polygon.addVertex(p[0],p[1]); |
|
64 |
} |
|
69 | 65 |
} |
70 | 66 |
return polygon; |
71 | 67 |
} |
Also available in: Unified diff