public SimpleFeature convertDwgCircle ( String typeName , String layerName , DwgCircle circle , int id ) { double [ ] center = circle . getCenter ( ) ; double radius = circle . getRadius ( ) ; Point2D [ ] ptos = GisModelCurveCalculator . calculateGisModelCircle ( new Point2D . Double ( center [ 0 ] , center [ 1 ] ) , radius ) ; CoordinateList coordList = new CoordinateList ( ) ; for ( int j = 0 ; j < ptos . length ; j ++ ) { Coordinate coord = new Coordinate ( ptos [ j ] . getX ( ) , ptos [ j ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } // close to create a polygon if ( ( ptos [ ptos . length - 1 ] . getX ( ) != ptos [ 0 ] . getX ( ) ) || ( ptos [ ptos . length - 1 ] . getY ( ) != ptos [ 0 ] . getY ( ) ) ) { Coordinate coord = new Coordinate ( ptos [ 0 ] . getX ( ) , ptos [ 0 ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , Polygon . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; LinearRing linearRing = gF . createLinearRing ( coordList . toCoordinateArray ( ) ) ; Geometry polygon = gF . createPolygon ( linearRing , null ) ; Object [ ] values = new Object [ ] { polygon , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; }
Builds a polygon feature from a dwg circle .