use of org.geotoolkit.gml.xml.AbstractSurface in project geotoolkit by Geomatys.
the class JAXPStreamFeatureWriter method setId.
/**
* @param inc auto increment value, ids must be unique
*/
private void setId(AbstractGeometry gmlGeometry, String id) {
if (gmlGeometry.getId() == null || gmlGeometry.getId().isEmpty()) {
// do not override ids if they exist
gmlGeometry.setId(id + (gidInc));
gidInc++;
}
if (gmlGeometry instanceof MultiCurve) {
for (CurveProperty po : ((MultiCurve) gmlGeometry).getCurveMember()) {
final AbstractCurve child = po.getAbstractCurve();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiSurface) {
for (SurfaceProperty po : ((MultiSurface) gmlGeometry).getSurfaceMember()) {
final AbstractSurface child = po.getAbstractSurface();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiGeometryType) {
for (GeometryPropertyType po : ((MultiGeometryType) gmlGeometry).getGeometryMember()) {
final AbstractGeometryType child = po.getAbstractGeometry();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiSolidType) {
for (SolidPropertyType po : ((MultiSolidType) gmlGeometry).getSolidMember()) {
final AbstractSolidType child = po.getAbstractSolid().getValue();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
} else if (gmlGeometry instanceof MultiPointType) {
for (PointPropertyType po : ((MultiPointType) gmlGeometry).getPointMember()) {
final PointType child = po.getPoint();
if (child instanceof AbstractGeometry) {
setId((AbstractGeometry) child, id);
}
}
}
}
use of org.geotoolkit.gml.xml.AbstractSurface in project geotoolkit by Geomatys.
the class GeometryTransformer method get.
/**
* Procede to conversion from GML to JTS.
* @return Created JTS geometry. Never null, but can be an emptry geometry.
* @throws UnconvertibleObjectException If we don't know how to process
* source GML geometry.
*/
@Override
public Geometry get() throws UnconvertibleObjectException {
Geometry geometry;
/*
* SIMPLE CASES
*/
if (source instanceof org.geotoolkit.gml.xml.Point) {
geometry = accumulateAndBuild(coords -> (coords.length > 0 ? GF.createPoint(coords[0]) : GF.createPoint((Coordinate) null)));
} else if (source instanceof org.geotoolkit.gml.xml.LineString) {
geometry = accumulateAndBuild(GF::createLineString);
} else if (source instanceof org.geotoolkit.gml.xml.LinearRing) {
geometry = accumulateAndBuild(GF::createLinearRing);
} else if (source instanceof Curve) {
geometry = convertCurve((Curve) source);
} else if (source instanceof Envelope) {
geometry = convertEnvelope((Envelope) source);
/*
* COMPOSED GEOMETRIES
*/
} else if (source instanceof org.geotoolkit.gml.xml.Ring) {
geometry = convertRing((Ring) source);
} else if (source instanceof org.geotoolkit.gml.xml.Polygon) {
geometry = convertPolygon((org.geotoolkit.gml.xml.Polygon) source);
if (isForceMultiPolygon()) {
Polygon[] polys = { (Polygon) geometry };
final MultiPolygon result = GF.createMultiPolygon(polys);
applyCRS(result);
geometry = result;
}
} else if (source instanceof AbstractSurface) {
if (source instanceof SurfaceType) {
geometry = convertSurface((SurfaceType) source);
} else if (source instanceof org.geotoolkit.gml.xml.v311.SurfaceType) {
geometry = convertSurface((org.geotoolkit.gml.xml.v311.SurfaceType) source);
} else // TODO : complex case
{
throw new IllegalArgumentException("Unsupported geometry type : " + source.getClass());
}
/*
* GEOMETRY COLLECTIONS
*/
} else if (source instanceof org.geotoolkit.gml.xml.MultiPoint) {
geometry = convertMultiPoint((org.geotoolkit.gml.xml.MultiPoint) source);
} else if (source instanceof org.geotoolkit.gml.xml.MultiLineString) {
geometry = convertMultiLineString((org.geotoolkit.gml.xml.MultiLineString) source);
} else if (source instanceof MultiCurve) {
geometry = convertMultiCurve((MultiCurve) source);
} else if (source instanceof org.geotoolkit.gml.xml.MultiPolygon) {
geometry = convertMultiPolygon((org.geotoolkit.gml.xml.MultiPolygon) source);
} else if (source instanceof MultiSurface) {
geometry = convertMultiSurface((MultiSurface) source);
} else if (source instanceof MultiGeometry) {
geometry = convertMultiGeometry((MultiGeometry) source);
} else {
throw new IllegalArgumentException("Unsupported geometry type : " + source.getClass());
}
// store identifier in user map
final String id = source.getId();
if (id != null && !id.isEmpty()) {
Object userData = geometry.getUserData();
Map values;
if (userData instanceof Map) {
values = (Map) userData;
} else if (userData instanceof CoordinateReferenceSystem) {
values = new HashMap();
values.put(org.apache.sis.internal.feature.jts.JTS.CRS_KEY, userData);
} else if (userData == null) {
values = new HashMap();
} else {
throw new IllegalArgumentException("Unexpected user data object : " + userData);
}
values.put("@id", id);
geometry.setUserData(values);
}
return geometry;
}
Aggregations