[geotk] DefaultBoundingPolygon on Iso metadata
Guilhem
guilhem.legal at geomatys.fr
Fri Apr 19 03:23:52 PDT 2013
Hello robin,
You have to use another implementation localized in geotk-xml-gml (pending).
try this piece of code instead :
WKTReader wktReader = new WKTReader();
Geometry geom = wktReader.read(wktInfluence);
DefaultExtent defaultExtent = new DefaultExtent();
// JTS Polygon
org.opengis.geometry.Geometry geometry =
(org.opengis.geometry.Geometry) JTStoGeometry.toGML("3.1.1", geom,
CRS.decode("EPSG:4326"));
DefaultBoundingPolygon boundingPolygon = new
DefaultBoundingPolygon();
boundingPolygon.setPolygons(Collections.singleton(geometry));
defaultExtent.getGeographicElements().add(boundingPolygon);
I just try it, the XML marshalling works fine with this.
Guilhem Legal
Le 11/04/2013 15:30, robin berenger a écrit :
> 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
> _______________________________________________
> Geotoolkit mailing list
> Geotoolkit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geotoolkit
>
>
More information about the Geotoolkit
mailing list