use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class CreateRandomShapeFunctions method randomLineString.
public static Geometry randomLineString(final Geometry g, final int nPts) {
final BoundingBox env = FunctionsUtil.getEnvelopeOrDefault(g);
final GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(g);
final double width = env.getWidth();
final double hgt = env.getHeight();
final Point[] pts = new Point[nPts];
for (int i = 0; i < nPts; i++) {
final double xLen = width * Math.random();
final double yLen = hgt * Math.random();
pts[i] = randomPtInRectangleAround(env.getCentre(), xLen, yLen);
}
return geomFact.lineString(pts);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class CreateRandomShapeFunctions method randomSegments.
public static Geometry randomSegments(final Geometry g, final int nPts) {
final BoundingBox env = FunctionsUtil.getEnvelopeOrDefault(g);
final GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(g);
final double xLen = env.getWidth();
final double yLen = env.getHeight();
final List lines = new ArrayList();
for (int i = 0; i < nPts; i++) {
final double x0 = env.getMinX() + xLen * Math.random();
final double y0 = env.getMinY() + yLen * Math.random();
final double x1 = env.getMinX() + xLen * Math.random();
final double y1 = env.getMinY() + yLen * Math.random();
lines.add(geomFact.lineString(new Point[] { new PointDoubleXY(x0, y0), new PointDoubleXY(x1, y1) }));
}
return geomFact.buildGeometry(lines);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class CreateRandomShapeFunctions method randomRectilinearWalk.
public static Geometry randomRectilinearWalk(final Geometry g, final int nPts) {
final BoundingBox env = FunctionsUtil.getEnvelopeOrDefault(g);
final GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(g);
final double xLen = env.getWidth();
final double yLen = env.getHeight();
final Point[] pts = new Point[nPts];
boolean xory = true;
for (int i = 0; i < nPts; i++) {
Point pt = null;
if (i == 0) {
pt = randomPtInRectangleAround(env.getCentre(), xLen, yLen);
} else {
final double dist = xLen * (Math.random() - 0.5);
double x = pts[i - 1].getX();
double y = pts[i - 1].getY();
if (xory) {
x += dist;
} else {
y += dist;
}
// switch orientation
xory = !xory;
pt = new PointDoubleXY(x, y);
}
pts[i] = pt;
}
return geomFact.lineString(pts);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class CreateRandomShapeFunctions method haltonPointsWithBases.
public static Geometry haltonPointsWithBases(final Geometry g, final int nPts, final int basei, final int basej) {
final BoundingBox env = FunctionsUtil.getEnvelopeOrDefault(g);
final Point[] pts = new Point[nPts];
final double baseX = env.getMinX();
final double baseY = env.getMinY();
int i = 0;
while (i < nPts) {
final double x = baseX + env.getWidth() * haltonOrdinate(i + 1, basei);
final double y = baseY + env.getHeight() * haltonOrdinate(i + 1, basej);
final Point p = new PointDoubleXY(x, y);
if (!env.covers(p)) {
continue;
}
pts[i++] = p;
}
return FunctionsUtil.getFactoryOrDefault(g).punctual(pts);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class AffineTransformationFunctions method transformByBaseline.
public static Geometry transformByBaseline(final Geometry g, final Geometry destBaseline) {
final BoundingBox env = g.getBoundingBox();
final Point src0 = new PointDoubleXY(env.getMinX(), env.getMinY());
final Point src1 = new PointDoubleXY(env.getMaxX(), env.getMinY());
final Point[] destPts = CoordinatesListUtil.getPointArray(destBaseline);
final Point dest0 = destPts[0];
final Point dest1 = destPts[1];
final AffineTransformation trans = AffineTransformationFactory.newFromBaseLines(src0, src1, dest0, dest1);
return trans.transform(g);
}
Aggregations