Java Code Examples for com.vividsolutions.jts.geom.Geometry#setUserData()

The following examples show how to use com.vividsolutions.jts.geom.Geometry#setUserData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GamaShape.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private ShapeData getData(final boolean createIt) {
	final Geometry g = getInnerGeometry();
	if (g == null) { return null; }
	Object o = g.getUserData();
	if (o == null) {
		if (createIt) {
			o = new ShapeData();
			g.setUserData(o);
		} else {
			return null;
		}
	}
	return (ShapeData) o;
}
 
Example 2
Source File: SortingFunctions.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Geometry sortByLength(Geometry g)
{
  List geoms = components(g);
  Collections.sort(geoms, new GeometryLengthComparator());
  
  // annotate geometries with area
  for (Object o : geoms) {
    Geometry geom = (Geometry) o;
    geom.setUserData(geom.getLength());
  }
  
  return g.getFactory().buildGeometry(geoms);
}
 
Example 3
Source File: SortingFunctions.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Geometry sortByArea(Geometry g)
{
  List geoms = components(g);
  Collections.sort(geoms, new GeometryAreaComparator());
  
  // annotate geometries with area
  for (Object o : geoms) {
    Geometry geom = (Geometry) o;
    geom.setUserData(geom.getArea());
  }
  
  return g.getFactory().buildGeometry(geoms);
}
 
Example 4
Source File: GeometryDataUtil.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void setComponentDataToIndex(Geometry geom)
{
	for (int i = 0; i < geom.getNumGeometries(); i++) {
		Geometry comp = geom.getGeometryN(i);
		comp.setUserData("Component # " + i); 
	}
}