本文整理了Java中com.vividsolutions.jts.geom.Geometry.setUserData()
方法的一些代码示例,展示了Geometry.setUserData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.setUserData()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Geometry
类名称:Geometry
方法名:setUserData
[英]A simple scheme for applications to add their own custom data to a Geometry. An example use might be to add an object representing a Coordinate Reference System.
Note that user data objects are not present in geometries created by construction methods.
[中]应用程序向几何图形添加自己的自定义数据的简单方案。例如,可以添加表示坐标参照系的对象。
请注意,由构造方法创建的几何图形中不存在用户数据对象。
代码示例来源:origin: osmandapp/Osmand
/**
* JTS 1.14 does not support intersection on a {@link GeometryCollection}. This function works around this
* by performing intersection on a flat list of geometry. The resulting list is pre-filtered for invalid
* or empty geometry (outside of bounds). Invalid geometry are logged as errors.
*
* @param envelope non-list geometry defines bounding area
* @param dataGeoms geometry pre-passed through {@link #flatFeatureList(Geometry)}
* @return list of geometry from {@code data} intersecting with {@code envelope}.
*/
private static List<Geometry> flatIntersection(Geometry envelope, List<Geometry> dataGeoms) {
final List<Geometry> intersectedGeoms = new ArrayList<>(dataGeoms.size());
Geometry nextIntersected;
for(Geometry nextGeom : dataGeoms) {
try {
// AABB intersection culling
if(envelope.getEnvelopeInternal().intersects(nextGeom.getEnvelopeInternal())) {
nextIntersected = envelope.intersection(nextGeom);
if(!nextIntersected.isEmpty()) {
nextIntersected.setUserData(nextGeom.getUserData());
intersectedGeoms.add(nextIntersected);
}
}
} catch (TopologyException e) {
//LoggerFactory.getLogger(JtsAdapter.class).error(e.getMessage(), e);
}
}
return intersectedGeoms;
}
代码示例来源:origin: osmandapp/Osmand
nextTransformGeom.setUserData(nextUserData);
代码示例来源:origin: osmandapp/Osmand
if (nextGeom != null) {
tileGeoms.add(nextGeom);
nextGeom.setUserData(tagConverter.toUserData(id, nextFeature.getTagsList(), keysList, valuesList));
代码示例来源:origin: com.vividsolutions/jts
/**
* Input is assumed to be a multiGeometry
* in which every component has its userData
* set to be a Coordinate which is the key to the output data.
* The Coordinate is used to determine
* the output data object to be written back into the component.
*
* @param targetGeom
*/
public void transferData(Geometry targetGeom)
{
for (int i = 0; i < targetGeom.getNumGeometries(); i++) {
Geometry geom = targetGeom.getGeometryN(i);
Coordinate vertexKey = (Coordinate) geom.getUserData();
if (vertexKey == null) continue;
geom.setUserData(coordDataMap.get(vertexKey));
}
}
}
代码示例来源:origin: org.geoserver.extension/querylayer
@Override
public void filter(Geometry g) {
g.setUserData(crs);
}
}
代码示例来源:origin: com.vividsolutions/jts
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv)
{
Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
List clipped = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry g = geom.getGeometryN(i);
Geometry result = null;
// don't clip unless necessary
if (clipEnv.contains(g.getEnvelopeInternal()))
result = g;
else if (clipEnv.intersects(g.getEnvelopeInternal())) {
result = clipPoly.intersection(g);
// keep vertex key info
result.setUserData(g.getUserData());
}
if (result != null && ! result.isEmpty()) {
clipped.add(result);
}
}
return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
}
}
代码示例来源:origin: org.geotools/gt-render
public void setUserData(Object userData) {
geometry.setUserData(userData);
}
代码示例来源:origin: DataSystemsLab/GeoSpark
private void handleNonSpatialDataToGeometry(Geometry geometry, List<String> splitedGeometryData)
{
LinkedList<String> splitedGeometryDataList = new LinkedList<String>(splitedGeometryData);
if (carryInputData) {
if (this.splitter != FileDataSplitter.GEOJSON){
//remove spatial data position
splitedGeometryDataList.remove(this.startOffset);
}
geometry.setUserData(String.join("\t", splitedGeometryDataList));
}
}
代码示例来源:origin: DataSystemsLab/GeoSpark
private Geometry readGeometry(Kryo kryo, Input input)
{
Geometry geometry = ShapeSerde.deserialize(input, geometryFactory);
geometry.setUserData(readUserData(kryo, input));
return geometry;
}
}
代码示例来源:origin: org.datasyslab/geospark
private Geometry readGeometry(Kryo kryo, Input input)
{
Geometry geometry = ShapeSerde.deserialize(input, geometryFactory);
geometry.setUserData(readUserData(kryo, input));
return geometry;
}
}
代码示例来源:origin: DataSystemsLab/GeoSpark
public Geometry getShape(GeometryFactory geometryFactory)
throws IOException, TypeUnknownException
{
ShapeParser parser = shapeType.getParser(geometryFactory);
ByteBuffer shapeBuffer = ByteBuffer.wrap(primitiveRecord);
Geometry shape = parser.parseShape(ShapeReaderFactory.fromByteBuffer(shapeBuffer));
if (attributes != null) {
shape.setUserData(attributes);
}
return shape;
}
}
代码示例来源:origin: DataSystemsLab/GeoSpark
public <T extends Geometry> void addMultiGeometry(GeometryCollection multiGeometry, List<T> result)
{
for (int i = 0; i < multiGeometry.getNumGeometries(); i++) {
T geometry = (T) multiGeometry.getGeometryN(i);
geometry.setUserData(multiGeometry.getUserData());
result.add(geometry);
}
}
代码示例来源:origin: org.datasyslab/geospark
public Geometry getShape(GeometryFactory geometryFactory)
throws IOException, TypeUnknownException
{
ShapeParser parser = shapeType.getParser(geometryFactory);
ByteBuffer shapeBuffer = ByteBuffer.wrap(primitiveRecord);
Geometry shape = parser.parseShape(ShapeReaderFactory.fromByteBuffer(shapeBuffer));
if (attributes != null) {
shape.setUserData(attributes);
}
return shape;
}
}
代码示例来源:origin: org.datasyslab/geospark
public <T extends Geometry> void addMultiGeometry(GeometryCollection multiGeometry, List<T> result)
{
for (int i = 0; i < multiGeometry.getNumGeometries(); i++) {
T geometry = (T) multiGeometry.getGeometryN(i);
geometry.setUserData(multiGeometry.getUserData());
result.add(geometry);
}
}
代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig
private Geometry removeHoles(Geometry inputPolygon) {
Class<?> geomBinding = inputPolygon.getClass();
Geometry finalGeom = inputPolygon;
if (Polygon.class.equals(geomBinding)) {
finalGeom = removeHoles((Polygon) inputPolygon);
} else if (MultiPolygon.class.equals(geomBinding)) {
List<Polygon> polygons = new ArrayList<Polygon>();
for (int index = 0; index < inputPolygon.getNumGeometries(); index++) {
Polygon polygon = (Polygon) inputPolygon.getGeometryN(index);
polygons.add((Polygon) removeHoles(polygon));
}
finalGeom = inputPolygon.getFactory().createMultiPolygon(
GeometryFactory.toPolygonArray(polygons));
}
finalGeom.setUserData(inputPolygon.getUserData());
return finalGeom;
}
代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig
private Geometry removeSmallHoles(Geometry inputPolygon, double areaTolerance) {
Class<?> geomBinding = inputPolygon.getClass();
Geometry finalGeom = inputPolygon;
if (Polygon.class.equals(geomBinding)) {
finalGeom = removeSmallHoles((Polygon) inputPolygon, areaTolerance);
} else if (MultiPolygon.class.equals(geomBinding)) {
List<Polygon> polygons = new ArrayList<Polygon>();
for (int index = 0; index < inputPolygon.getNumGeometries(); index++) {
Polygon polygon = (Polygon) inputPolygon.getGeometryN(index);
polygons.add((Polygon) removeSmallHoles(polygon, areaTolerance));
}
finalGeom = inputPolygon.getFactory().createMultiPolygon(
GeometryFactory.toPolygonArray(polygons));
}
finalGeom.setUserData(inputPolygon.getUserData());
return finalGeom;
}
代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig
private Geometry removeHoles(Polygon polygon) {
GeometryFactory factory = polygon.getFactory();
LineString exteriorRing = polygon.getExteriorRing();
Geometry finalGeom = factory.createPolygon((LinearRing) exteriorRing, null);
finalGeom.setUserData(polygon.getUserData());
return finalGeom;
}
代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig
private Geometry removeHoles(Polygon polygon) {
GeometryFactory factory = polygon.getFactory();
LineString exteriorRing = polygon.getExteriorRing();
Geometry finalGeom = factory.createPolygon((LinearRing) exteriorRing, null);
finalGeom.setUserData(polygon.getUserData());
return finalGeom;
}
}
代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig
@Override
public SimpleFeature next() throws NoSuchElementException {
SimpleFeature feature = delegate.next();
for (Object attribute : feature.getAttributes()) {
if (attribute instanceof Geometry) {
Geometry geometry = (Geometry) attribute;
geometry.setUserData(forcedCRS);
}
builder.add(attribute);
}
return builder.buildFeature(feature.getID());
}
}
代码示例来源:origin: org.geotools/gt-main
public Object visit(Literal expression, Object extraData) {
if (!(expression.getValue() instanceof Geometry))
return super.visit(expression, extraData);
// check if reprojection is needed
Geometry geom = (Geometry) expression.getValue();
if(geom.getUserData() != null && geom.getUserData() instanceof CoordinateReferenceSystem)
return super.visit(expression, extraData);
// clone the geometry and assign the new crs
Geometry clone = geom.getFactory().createGeometry(geom);
clone.setUserData(defaultCrs);
// clone
return ff.literal(clone);
}
}
内容来源于网络,如有侵权,请联系作者删除!