use of org.apache.jena.geosparql.implementation.UnitsOfMeasure in project jena by apache.
the class GMLReader method buildCircleByCentrePoint.
private static LineString buildCircleByCentrePoint(List<Element> segments, CoordinateSequenceDimensions dims, SRSInfo srsInfo) {
Element circleElement = segments.get(0);
Point point = buildPoint(circleElement, dims);
Coordinate centre = point.getCoordinate();
// Get radius and convert units of measure if required.
Element radiusElement = circleElement.getChild("radius", GML_NAMESPACE);
double radius = Double.parseDouble(radiusElement.getTextNormalize());
// Extract units of measure uri. Use SRS units of measure if absent.
String uomURI = radiusElement.getAttributeValue("uom");
if (uomURI != null) {
UnitsOfMeasure uom = new UnitsOfMeasure(uomURI);
// Convert the radius if the specified units of measure don't match.
radius = UnitsOfMeasure.conversion(radius, uom, srsInfo.getUnitsOfMeasure());
}
GeometricShapeFactory geometricShapeFactory = new GeometricShapeFactory(GEOMETRY_FACTORY);
geometricShapeFactory.setCentre(centre);
// Set the width and height, i.e. the diameter.
geometricShapeFactory.setSize(radius * 2);
Polygon circlePolygon = geometricShapeFactory.createCircle();
return circlePolygon.getExteriorRing();
}
Aggregations