Revision 23234 branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgLwPolyline.java
DwgLwPolyline.java | ||
---|---|---|
39 | 39 |
import java.util.List; |
40 | 40 |
import java.util.Map; |
41 | 41 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
42 |
import org.gvsig.fmap.geom.Geometry; |
|
43 |
import org.gvsig.fmap.geom.GeometryFactory; |
|
44 |
import org.gvsig.fmap.geom.GeometryManager; |
|
45 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
46 |
import org.gvsig.fmap.geom.primitive.NullGeometry; |
|
47 |
|
|
45 | 48 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 49 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 | 50 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
... | ... | |
305 | 308 |
public double getZ() { |
306 | 309 |
return getElevation(); |
307 | 310 |
} |
308 |
public IGeometry toFMapGeometry(boolean is3DFile) {
|
|
309 |
FPolyline2D lwpline = null;
|
|
310 |
List pts = getVertices();
|
|
311 |
public Geometry toFMapGeometry(boolean is3DFile) { |
|
312 |
GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
|
|
313 |
List vertices = getVertices();
|
|
311 | 314 |
double elev = getElevation(); |
312 |
if (pts != null && pts.size() > 0) { |
|
313 | 315 |
|
316 |
if (vertices != null && vertices.size()>0){ |
|
317 |
GeneralPathX gp = new GeneralPathX(); |
|
318 |
Object vertice = vertices.get(0); |
|
319 |
if(vertice instanceof double[]){ |
|
320 |
gp.moveTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue()); |
|
321 |
} else if (vertice instanceof Point2D){ |
|
322 |
gp.moveTo(new Double(((Point2D)vertice).getX()).floatValue(), |
|
323 |
new Double(((Point2D)vertice).getY()).floatValue()); |
|
324 |
} |
|
325 |
for (int i = 1; i < vertices.size(); i++) { |
|
326 |
vertice = vertices.get(i); |
|
327 |
if(vertice instanceof double[]){ |
|
328 |
gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue()); |
|
329 |
} else if (vertice instanceof Point2D){ |
|
330 |
gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(), |
|
331 |
new Double(((Point2D)vertice).getY()).floatValue()); |
|
332 |
} |
|
333 |
} |
|
314 | 334 |
if (is3DFile) { |
315 |
List pline3D = new ArrayList(); |
|
316 |
for (int j = 0; j < pts.size(); j++) { |
|
317 |
Object vertex = pts.get(j); |
|
318 |
double[] pt = new double[3]; |
|
319 |
if(vertex instanceof double[]){ |
|
320 |
double[] vertexArray = (double[])vertex; |
|
321 |
pt[0] = vertexArray[0]; |
|
322 |
pt[1] = vertexArray[1]; |
|
323 |
}else if(vertex instanceof Point2D){ |
|
324 |
Point2D vertexPt = (Point2D)vertex; |
|
325 |
pt[0] = vertexPt.getX(); |
|
326 |
pt[1] = vertexPt.getY(); |
|
327 |
} |
|
328 |
pt[2] = elev; |
|
329 |
pline3D.add(pt); |
|
330 |
} |
|
331 |
lwpline = FMapUtil.points3DToFPolyline3D(pline3D); |
|
335 |
return gFactory.createPolyline3D(gp,new double[] {elev}); |
|
332 | 336 |
} else { |
333 |
lwpline = FMapUtil.points2DToFPolyline2D(pts);
|
|
337 |
return gFactory.createPolyline2D(gp);
|
|
334 | 338 |
} |
335 |
|
|
339 |
} else { |
|
340 |
return new NullGeometry(); |
|
336 | 341 |
} |
337 |
return ShapeFactory.createGeometry(lwpline); |
|
338 | 342 |
} |
339 | 343 |
public String toFMapString(boolean is3DFile) { |
340 | 344 |
if(is3DFile) |
Also available in: Unified diff