code: private static Geometry convertGeometry_(Geometry geometry, double tolerance) {
  		int gt = geometry.getType().value();
  
  		if (Geometry.isSegment(gt)) {
  			Polyline polyline = new Polyline(geometry.getDescription());
  			polyline.addSegment((Segment) geometry, true);
  			return polyline;
  		}
  
  		if (gt == Geometry.GeometryType.Envelope) {
  			Envelope envelope = (Envelope) (geometry);
  			Envelope2D env = new Envelope2D();
  			geometry.queryEnvelope2D(env);
  
  			if (env.getHeight() <= tolerance && env.getWidth() <= tolerance) {// treat
  																				// as
  																				// point
  				Point point = new Point(geometry.getDescription());
  				envelope.getCenter(point);
  				return point;
  			}
  
  			if (env.getHeight() <= tolerance || env.getWidth() <= tolerance) {// treat
  																				// as
  																				// line
  				Polyline polyline = new Polyline(geometry.getDescription());
  				Point p = new Point();
  				envelope.queryCornerByVal(0, p);
  				polyline.startPath(p);
  				envelope.queryCornerByVal(2, p);
  				polyline.lineTo(p);
  				return polyline;
  			}
  
  			// treat as polygon
  			Polygon polygon = new Polygon(geometry.getDescription());
  			polygon.addEnvelope(envelope, false);
  			return polygon;
  		}
  
  		return geometry;
  	}
docs: Upgrades the geometry to a feature geometry.