Hi Michael,
   Thanks for helping me but i am still unable to solved out my problem in
PolygonfeatureHelper class, I make a createPolygonFeature() which return
SimpleFeature and this method call createFeatureType() 
Here is the code


public static SimpleFeature createPolyFeature(Geometry geom, String name ) {
    GeometryFactory gf = new GeometryFactory();
    
    if(geom instanceof Polygon ){
        geom = new MultiPolygon(new Polygon[] {(Polygon)geom  },new
GeometryFactory());
    }
    Object[] featureAttributes = { geom, name };
    SimpleFeatureBuilder sfb = new
SimpleFeatureBuilder(createFeatureType());
   sfb.add(featureAttributes);
    
    SimpleFeature f = sfb.buildFeature(null);
    return f;
  }
public static SimpleFeatureType createFeatureType() {
      
      AttributeDescriptor[] typesNew = new AttributeDescriptor[2];
      AttributeTypeBuilder build = new AttributeTypeBuilder();
      build.setBinding(String.class);
      build.setNillable(true);
      build.setLength(48);
      build.defaultValue(null);
      build.setName("NAME");
      AttributeDescriptor descriptor = build.buildDescriptor( "NAME" );
      
      AttributeTypeBuilder build1 = new AttributeTypeBuilder();
      build1.setBinding(MultiPolygon.class);
      build1.setName("the_geom");
      GeometryType geometryType = build1.buildGeometryType();
      GeometryDescriptor geomdescriptor =  build1.buildDescriptor(
"the_geom",   geometryType );
      
      typesNew[0] = descriptor;
      typesNew[1] = geomdescriptor;
      SimpleFeatureTypeBuilder sf = new SimpleFeatureTypeBuilder();
      sf.addAll(typesNew);
      sf.setName("Poly");
      
      SimpleFeatureType ft = sf.buildFeatureType();
       return ft;
}




--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/Problem-in-showing-Layer-on-JmapPane-tp5028912p5029151.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to