public static OXFFeature create(SamplingPointDocument xb_saPointDoc) { SamplingPointType xb_samplingPoint = xb_saPointDoc.getSamplingPoint(); String id = xb_samplingPoint.getId(); // FeatureType of the feature: OXFSamplingPointType oxf_saPointType = new OXFSamplingPointType(); OXFFeature feature = new OXFFeature(id, oxf_saPointType); // initialize the feature with the attributes from the XMLBean: oxf_saPointType.initializeFeature(feature, xb_samplingPoint); return feature; }
/** supports the Sampling specification of version 1.0: */ public void initializeFeature(OXFFeature feature, SamplingPointType xb_saPoint) { super.initializeFeature(feature, xb_saPoint); // // --- initialize the POSITION-attribute: if (xb_saPoint.getPosition() != null && xb_saPoint.getPosition().getPoint() != null && ((PointType) xb_saPoint.getPosition().getPoint()).getPos() != null) { PointType xb_point = xb_saPoint.getPosition().getPoint(); DirectPositionType xb_pos = xb_point.getPos(); List coordsList = xb_pos.getListValue(); double x = (Double) coordsList.get(0); double y = (Double) coordsList.get(1); double z = Double.NaN; try { z = (Double) coordsList.get(2); } catch (Exception e) { // no Exception -> 2D Point } if (coordsList.size() > 2) { z = (Double) coordsList.get(2); } Point point = new GeometryFactory().createPoint(new Coordinate(x, y, z)); feature.setAttribute(POSITION, point); initializeFeaturesGeometry(feature, point); } // check if the geometry-attribute is set: (could be set in this or the super class) if (feature.getGeometry() == null) { throw new IllegalArgumentException("The geometry attribute could not be initialized."); } }