use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class GeometryImplTest method testEqualsExactForPolygons.
public void testEqualsExactForPolygons() throws Exception {
final Polygon x = (Polygon) this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
final Polygon somethingExactlyEqual = (Polygon) this.geometryFactory.geometry("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
final Polygon somethingNotEqualButSameClass = (Polygon) this.geometryFactory.geometry("POLYGON ((50 50, 50 0, 0 0, 0 50, 50 50))");
final Polygon sameClassButEmpty = (Polygon) this.geometryFactory.geometry("POLYGON EMPTY");
final Polygon anotherSameClassButEmpty = (Polygon) this.geometryFactory.geometry("POLYGON EMPTY");
final CollectionFactory collectionFactory = new CollectionFactory() {
@Override
public Geometry newCollection(final Geometry... geometries) {
return GeometryImplTest.this.geometryFactory.polygonal((Object[]) geometries);
}
};
doTestEqualsExact(x, somethingExactlyEqual, somethingNotEqualButSameClass, sameClassButEmpty, anotherSameClassButEmpty, collectionFactory);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class TriangleTest method checkAcute.
public void checkAcute(final String wkt, final boolean expectedValue) throws Exception {
final Polygon g = (Polygon) this.geometryFactory.geometry(wkt);
final TriangleImpl t = newTriangle(g);
final boolean isAcute = t.isAcute();
// System.out.println("isAcute = " + isAcute);
assertEquals(expectedValue, isAcute);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class CascadedPolygonUnionTester method unionIterated.
public Geometry unionIterated(final Collection<? extends Polygon> polygons) {
Geometry unionAll = null;
int count = 0;
for (final Polygon polygon : polygons) {
if (unionAll == null) {
unionAll = polygon.clone();
} else {
unionAll = unionAll.union(polygon);
}
count++;
if (count % 100 == 0) {
System.out.print(".");
}
}
return unionAll;
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class RayCrossingCounterTest method runPtInRing.
@Override
protected void runPtInRing(final Location expectedLoc, final Point pt, final String wkt) throws Exception {
final Polygon geom = (Polygon) this.geometryFactory.geometry(wkt);
assertEquals(expectedLoc, RayCrossingCounter.locatePointInRing(pt, geom.getShell()));
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class ArcSdeStGeometryFieldDefinition method getParts.
public static List<List<Geometry>> getParts(final Geometry geometry) {
final List<List<Geometry>> partsList = new ArrayList<>();
if (geometry != null) {
final ClockDirection expectedRingOrientation = ClockDirection.COUNTER_CLOCKWISE;
for (final Geometry part : geometry.geometries()) {
if (!part.isEmpty()) {
if (part instanceof Point) {
final Point point = (Point) part;
partsList.add(Collections.<Geometry>singletonList(point));
} else if (part instanceof LineString) {
final LineString line = (LineString) part;
partsList.add(Collections.<Geometry>singletonList(line));
} else if (part instanceof Polygon) {
final Polygon polygon = (Polygon) part;
final List<Geometry> ringList = new ArrayList<>();
ClockDirection partExpectedRingOrientation = expectedRingOrientation;
for (LinearRing ring : polygon.rings()) {
final ClockDirection ringOrientation = ring.getClockDirection();
if (ringOrientation != partExpectedRingOrientation) {
ring = ring.reverse();
}
ringList.add(ring);
if (partExpectedRingOrientation == expectedRingOrientation) {
partExpectedRingOrientation = expectedRingOrientation.opposite();
}
}
partsList.add(ringList);
}
}
}
}
return partsList;
}
Aggregations