use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineStringImplTest method testIsClosed.
public void testIsClosed() throws Exception {
final LineString l = (LineString) this.geometryFactory.geometry("LINESTRING EMPTY");
assertTrue(l.isEmpty());
assertTrue(!l.isClosed());
final LinearRing r = this.geometryFactory.linearRing();
assertTrue(r.isEmpty());
assertTrue(r.isClosed());
final Lineal m = this.geometryFactory.lineal(l, r);
assertTrue(!m.isClosed());
final Lineal m2 = this.geometryFactory.lineal(r);
assertTrue(m2.isClosed());
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class IsCounterClockWiseTest method testCounterClockWise.
public void testCounterClockWise() throws Exception {
final LineString pts = getLineString("POLYGON ((60 180, 140 240, 140 240, 140 240, 200 180, 120 120, 60 180))");
assertEquals(pts.isCounterClockwise(), false);
final LineString pts2 = getLineString("POLYGON ((60 180, 140 120, 100 180, 140 240, 60 180))");
assertEquals(pts2.isCounterClockwise(), true);
// same pts list with duplicate top point - check that isCounterClockise
// still works
final LineString pts2x = getLineString("POLYGON ((60 180, 140 120, 100 180, 140 240, 140 240, 60 180))");
assertEquals(pts2x.isCounterClockwise(), true);
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class PerturbedGridPolygonBuilder method buildGrid.
private Geometry buildGrid() {
final LineString[] lines = new LineString[this.numLines * 2];
int index = 0;
for (int i = 0; i < this.numLines; i++) {
final Point p0 = new PointDoubleXY(getRandOrdinate(), 0);
final Point p1 = new PointDoubleXY(getRandOrdinate(), this.gridWidth);
final LineString line = this.geomFactory.lineString(new Point[] { p0, p1 });
lines[index++] = line;
}
for (int i = 0; i < this.numLines; i++) {
final Point p0 = new PointDoubleXY(0, getRandOrdinate());
final Point p1 = new PointDoubleXY(this.gridWidth, getRandOrdinate());
final LineString line = this.geomFactory.lineString(new Point[] { p0, p1 });
lines[index++] = line;
}
final Lineal ml = this.geomFactory.lineal(lines);
final Geometry grid = ml.buffer(this.lineWidth);
// System.out.println(grid);
return grid;
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class RobustLineIntersectorTest method testA.
public void testA() {
final Point p1 = new PointDoubleXY(-123456789, -40);
final Point p2 = new PointDoubleXY(381039468754763d, 123456789);
final GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
final LineString l = geometryFactory.lineString(new Point[] { p1, p2 });
final Point p = geometryFactory.point(0.0, 0.0);
assertEquals(false, l.intersects(p));
assertEquals(false, geometryFactory.lineString(p1, p2).isOnLine(p));
assertEquals(-1, CGAlgorithmsDD.orientationIndex(p1, p2, p));
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class JTSFunctions method newS.
private static Geometry newS(final Geometry g) {
final GeometryFactory gf = FunctionsUtil.getFactoryOrDefault(g);
final double centreX = WIDTH - S_RADIUS;
final Point[] top = new Point[] { new PointDoubleXY(WIDTH, HEIGHT), new PointDoubleXY(centreX, HEIGHT) };
final Point[] bottom = new Point[] { new PointDoubleXY(centreX, 0), new PointDoubleXY(WIDTH - 2 * S_RADIUS, 0) };
final GeometricShapeFactory gsf = new GeometricShapeFactory(gf);
gsf.setCentre(new PointDoubleXY(centreX, HEIGHT - S_RADIUS));
gsf.setSize(2 * S_RADIUS);
gsf.setNumPoints(10);
final LineString arcTop = gsf.newArc(0.5 * Math.PI, Math.PI);
final GeometricShapeFactory gsf2 = new GeometricShapeFactory(gf);
gsf2.setCentre(new PointDoubleXY(centreX, S_RADIUS));
gsf2.setSize(2 * S_RADIUS);
gsf2.setNumPoints(10);
final LineString arcBottom = gsf2.newArc(1.5 * Math.PI, Math.PI).reverse();
final PointList coordList = new PointList();
coordList.add(top, false);
coordList.add(CoordinatesListUtil.getPointArray(arcTop), false, 1, arcTop.getVertexCount() - 1);
coordList.add(new PointDoubleXY(centreX, HEIGHT / 2));
coordList.add(CoordinatesListUtil.getPointArray(arcBottom), false, 1, arcBottom.getVertexCount() - 1);
coordList.add(bottom, false);
return gf.lineString(coordList.toPointArray());
}
Aggregations