use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class OracleSdoGeometryJdbcFieldDefinition method addRingSimple.
private int addRingSimple(final List<LinearRing> rings, final int axisCount, final BigDecimal[] elemInfo, final int type, final BigDecimal[] coordinatesArray, final int elemInfoOffset, final int offset, final long interpretation) {
if (interpretation == 1) {
int length;
if (elemInfoOffset + 3 < elemInfo.length) {
final long nextOffset = elemInfo[elemInfoOffset + 3].longValue();
length = (int) (nextOffset - offset);
} else {
final int coordinateCount = coordinatesArray.length;
length = coordinateCount + 1 - offset;
}
final double[] coordinates = Numbers.toDoubleArray(coordinatesArray, offset - 1, length);
final LinearRing ring = this.geometryFactory.linearRing(axisCount, coordinates);
rings.add(ring);
} else {
throw new IllegalArgumentException("Unsupported geometry type " + type + " interpretation " + interpretation);
}
return elemInfoOffset + 3;
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PointInRingTest method runPtInRing.
@Override
protected void runPtInRing(final Location expectedLoc, final Point pt, final String wkt) throws Exception {
// isPointInRing is not defined for pts on boundary
if (expectedLoc == Location.BOUNDARY) {
return;
}
final Polygon geom = (Polygon) this.geometryFactory.geometry(wkt);
final boolean expected = expectedLoc == Location.INTERIOR;
final LinearRing shell = geom.getShell();
assertEquals(expected, shell.isPointInRing(pt));
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeometryImplTest method testEqualsExactForLinearRings.
// public void testEquals2() throws Exception {
// Geometry lineString =
// reader.read("LINESTRING(0 0, 0 50, 50 50, 50 0, 0 0)");
// Geometry geometryCollection =
// reader.read("GEOMETRYCOLLECTION ( LINESTRING(0 0 , 0 50), "
// + "LINESTRING(0 50 , 50 50), "
// + "LINESTRING(50 50, 50 0 ), "
// + "LINESTRING(50 0 , 0 0 ))");
// assertTrue(lineString.equals(geometryCollection));
// }
public void testEqualsExactForLinearRings() throws Exception {
final LinearRing x = this.geometryFactory.linearRing(2, 0.0, 0, 100.0, 0, 100.0, 100, 0.0, 0);
final LinearRing somethingExactlyEqual = this.geometryFactory.linearRing(2, 0.0, 0, 100.0, 0, 100.0, 100, 0.0, 0);
final LinearRing somethingNotEqualButSameClass = this.geometryFactory.linearRing(2, 0.0, 0, 100.0, 0, 100.0, 555, 0.0, 0);
final LinearRing sameClassButEmpty = this.geometryFactory.linearRing((LineString) null);
final LinearRing anotherSameClassButEmpty = this.geometryFactory.linearRing((LineString) null);
final CollectionFactory collectionFactory = new CollectionFactory() {
@Override
public Geometry newCollection(final Geometry... geometries) {
return GeometryImplTest.this.geometryFactory.lineal(geometries);
}
};
doTestEqualsExact(x, somethingExactlyEqual, somethingNotEqualButSameClass, sameClassButEmpty, anotherSameClassButEmpty, collectionFactory);
// LineString somethingEqualButNotExactly =
// geometryFactory.createLineString(new Point[] {
// new BaseLasPoint((double)0, 0), new PointDouble((double)100, 0), new
// Coordinate((double)100, 100),
// new BaseLasPoint((double)0, 0) });
//
// doTestEqualsExact(x, somethingExactlyEqual, somethingEqualButNotExactly,
// somethingNotEqualButSameClass);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class ArcGisRestServerFeatureReader method parseMultiPolygon.
public static Geometry parseMultiPolygon(final GeometryFactory geometryFactory, final MapEx properties) {
final List<Polygon> polygons = new ArrayList<>();
final List<LinearRing> rings = new ArrayList<>();
final List<List<List<Number>>> paths = properties.getValue("rings", Collections.emptyList());
for (final List<List<Number>> points : paths) {
final LinearRing ring = geometryFactory.linearRing(points);
if (ring.isClockwise()) {
if (!rings.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(rings);
polygons.add(polygon);
}
rings.clear();
}
rings.add(ring);
}
if (!rings.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(rings);
polygons.add(polygon);
}
return geometryFactory.geometry(polygons);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class AreaPrecisionPerfTest method main.
public static void main(final String[] args) throws Exception {
final double originX = 1000000;
final double originY = 5000000;
final long start = System.currentTimeMillis();
for (int nrVertices = 4; nrVertices <= 1000000; nrVertices *= 2) {
final Point[] coordinates = new Point[nrVertices + 1];
Point vertex;
for (int i = 0; i <= nrVertices; i++) {
vertex = new PointDoubleXY(originX + (1 + Math.sin((float) i / (float) nrVertices * 2 * Math.PI)), originY + (1 + Math.cos((float) i / (float) nrVertices * 2 * Math.PI)));
coordinates[i] = vertex;
}
// close ring
coordinates[nrVertices] = coordinates[0];
final LinearRing g1 = GeometryFactory.DEFAULT_3D.linearRing(coordinates);
final Polygon polygon = GeometryFactory.DEFAULT_3D.polygon(g1);
// System.out.println(polygon);
final double area = originalSignedArea(coordinates);
final double area2 = accurateSignedArea(coordinates);
final double exactArea = 0.5 * nrVertices * Math.sin(2 * Math.PI / nrVertices);
final double eps = exactArea - area;
final double eps2 = exactArea - area2;
// System.out.println(nrVertices + " orig err: " + eps + " acc err: "
// + eps2);
}
// System.out.println("Time: " + (System.currentTimeMillis() - start) /
// 1000.0);
}
Aggregations