use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class GeometryTestFactory method newSineStar.
public static Polygon newSineStar(final GeometryFactory fact, final double basex, final double basey, final double size, final double armLen, final int nArms, final int nPts) {
final Point[] pts = newSineStar(basex, basey, size, armLen, nArms, nPts);
final LinearRing ring = fact.linearRing(pts);
final Polygon poly = fact.polygon(ring);
return poly;
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class GeometryTestFactory method newBox.
public static Polygon newBox(final GeometryFactory fact, final double minx, final double miny, final int nSide, final double segLen) {
final double[] coordinates = newBox(minx, minx, nSide, segLen);
final LinearRing ring = fact.linearRing(2, coordinates);
final Polygon poly = fact.polygon(ring);
return poly;
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class NormalizeTest method testNormalizeEmptyPolygon.
public void testNormalizeEmptyPolygon() throws Exception {
Polygon actualValue = (Polygon) this.geometryFactory.geometry("POLYGON EMPTY");
actualValue = actualValue.normalize();
final Polygon expectedValue = (Polygon) this.geometryFactory.geometry("POLYGON EMPTY");
assertEqualsExact(expectedValue, actualValue);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class RectanglePredicateTest method testAngleOnBoundary.
@Test
public void testAngleOnBoundary() throws Exception {
final Polygon polygon = this.geometryFactory.polygon(2, 10.0, 10, 30, 10, 30, 30, 10, 30, 10, 10);
final LineString line = this.geometryFactory.lineString(2, 10.0, 30, 10, 10, 30, 10);
runRectanglePred(polygon, line);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class PolygonGenerator method newGeometry.
/**
* As the user increases the number of points, the probability of creating a random valid polygon decreases.
* Please take not of this when selecting the generation style, and the number of points.
*
* May return null if a geometry could not be created.
*
* @see #getNumberPoints()
* @see #setNumberPoints(int)
* @see #getGenerationAlgorithm()
* @see #setGenerationAlgorithm(int)
*
* @see #BOX
* @see #ARC
*
* @see com.revolsys.geometry.testold.generator.GeometryGenerator#newIterator()
*
* @throws IllegalStateException When the alg is not valid or the number of points is invalid
* @throws NullPointerException when either the Geometry Factory, or the Bounding Box are undefined.
*/
@Override
public Geometry newGeometry() {
if (this.geometryFactory == null) {
throw new NullPointerException("GeometryFactoryI is not declared");
}
if (this.boundingBox == null || this.boundingBox.isEmpty()) {
throw new NullPointerException("Bounding Box is not declared");
}
if (this.numberPoints < 4) {
throw new IllegalStateException("Too few points");
}
// base x
final double x = this.boundingBox.getMinX();
final double dx = this.boundingBox.getMaxX() - x;
// base y
final double y = this.boundingBox.getMinY();
final double dy = this.boundingBox.getMaxY() - y;
Polygon p = null;
for (int i = 0; i < RUNS; i++) {
switch(getGenerationAlgorithm()) {
case BOX:
p = newBox(x, dx, y, dy, this.numberHoles, this.numberPoints, this.geometryFactory);
break;
case ARC:
p = newArc(x, dx, y, dy, this.numberHoles, this.numberPoints, this.geometryFactory);
break;
default:
throw new IllegalStateException("Invalid Alg. Specified");
}
final IsValidOp valid = new IsValidOp(p);
if (valid.isValid()) {
return p;
}
}
return null;
}
Aggregations