package com.ximple.io.dgn7;
|
|
//~--- non-JDK imports --------------------------------------------------------
|
|
import org.apache.log4j.Logger;
|
|
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.GeometryFactory;
|
import com.vividsolutions.jts.geom.LinearRing;
|
|
/**
|
* ShapeElement
|
*
|
* @author Ulysses
|
* @version 0.1
|
* @since 2006/5/18 下午 03:08:43
|
*/
|
public class ShapeElement extends LineStringElement implements GeometryConverter
|
{
|
static final Logger logger = Logger.getLogger(ShapeElement.class);
|
|
public ShapeElement(short[] raw)
|
{
|
super(raw);
|
}
|
|
public Geometry toGeometry(GeometryFactory factory)
|
{
|
try
|
{
|
LinearRing ring = factory.createLinearRing(this.getVertices());
|
return factory.createPolygon(ring, null);
|
} catch (IllegalArgumentException e)
|
{
|
logger.warn(e.getMessage(), e);
|
return null;
|
}
|
}
|
|
public static class ElementHandler extends Element.ElementHandler
|
{
|
private static ElementHandler instance = null;
|
|
public ElementHandler()
|
{
|
super(ElementType.SHAPE);
|
}
|
|
public static IElementHandler getInstance()
|
{
|
if (instance == null)
|
{
|
instance = new ElementHandler();
|
}
|
|
return instance;
|
}
|
|
protected Element createElement(short[] raw)
|
{
|
return new ShapeElement(raw);
|
}
|
}
|
}
|