[geotk] DefaultBoundingPolygon on Iso metadata

robin berenger berenger.robin at c-s.fr
Thu Apr 11 06:30:29 PDT 2013


Hello

I have a problem when i try to fill an opengis metadata with a 
defaultBoundingPolygon instead of a DefaultBoundingBox
(MetaData > DataIdentification > Extent > BoundingPolygon)  with a WKT 
String (POLYGON (50.1 .....)).

I have this attention log when i insert my metadata into the catalog, 
and the polygon isn't inserted.

ATTENTION: Unexpected geometry class in 
geometryAdpater:org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon

It seems that GmlGeometryAdapter needs a PolygonType, but i don't know 
how to create it from WKT .

public static DefaultExtent createGeographicInfluenceExtent(String 
wktInfluence) throws ParseException  {

         WKTReader wktReader = new WKTReader();
         Geometry geom = wktReader.read(wktInfluence);
         DefaultExtent defaultExtent = new DefaultExtent();
         Coordinate[] coordinates = geom.getCoordinates();
         DirectPosition2D[] exteriorRing = new 
DirectPosition2D[coordinates.length];

         for (int i = 0; i < coordinates.length; i++) {

             final double[] coords = new double[2];
             coords[0] = coordinates[i].x;
             coords[1] = coordinates[i].y;
             DirectPosition2D position = new DirectPosition2D();
             exteriorRing[i] = position;
         }
         // JTS Polygon
         org.opengis.geometry.Geometry geometry =  
(org.opengis.geometry.Geometry) GeometryUtils.createPolygon(exteriorRing);
         //PolygonAdapter polygonAdapter = new PolygonAdapter();
         //org.geotoolkit.internal.jaxb.PolygonType polT 
=polygonAdapter.marshal(p);
         //org.opengis.geometry.Geometry g = 
(org.opengis.geometry.Geometry)pklk;

         DefaultBoundingPolygon boundingPolygon = new 
DefaultBoundingPolygon();
         boundingPolygon.setPolygons(Collections.singleton(geometry));
         defaultExtent.getGeographicElements().add(boundingPolygon);

         return defaultExtent;
     }

Thanks for your help


More information about the Geotoolkit mailing list