use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class OsmWay method setGeometry.
protected void setGeometry(final List<Point> points) {
Geometry geometry;
if (points.isEmpty()) {
geometry = OsmConstants.WGS84_2D.point();
} else if (points.size() == 1) {
geometry = points.get(0);
} else {
final LineString line = OsmConstants.WGS84_2D.lineString(points);
if (isArea() && line.isClosed()) {
geometry = OsmConstants.WGS84_2D.polygon(line);
} else {
geometry = line;
}
}
setGeometryValue(geometry);
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class ArcConverter method write.
protected void write(final OsnSerializer serializer, final Object object, final boolean writeAttributes) throws IOException {
if (object instanceof LineString) {
final LineString line = (LineString) object;
serializer.startObject(this.geometryType);
serializer.fieldName("LineString");
serializer.startCollection("List");
final LineString points = line;
final int axisCount = points.getAxisCount();
for (int i = 0; i < points.getVertexCount(); i++) {
serializer.startObject(SaifConstants.POINT);
serializer.fieldName("coords");
final double x = points.getX(i);
final double y = points.getY(i);
final double z = points.getZ(i);
if (axisCount == 2) {
serializer.startObject("/Coord2D");
serializer.attribute("c1", x, true);
serializer.attribute("c2", y, false);
} else {
serializer.startObject("/Coord3D");
serializer.attribute("c1", x, true);
serializer.attribute("c2", y, true);
if (Double.isNaN(z)) {
serializer.attribute("c3", 0, false);
} else {
serializer.attribute("c3", z, false);
}
}
serializer.endObject();
serializer.endAttribute();
serializer.endObject();
}
serializer.endCollection();
serializer.endAttribute();
if (writeAttributes && line instanceof ArcLineString) {
writeAttributes(serializer, (ArcLineString) line);
}
serializer.endObject();
}
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineStringImplTest method testIsSimple.
public void testIsSimple() throws Exception {
final LineString l1 = (LineString) this.geometryFactory.geometry("LINESTRING (0 0, 10 10, 10 0, 0 10, 0 0)");
assertTrue(!l1.isSimple());
final LineString l2 = (LineString) this.geometryFactory.geometry("LINESTRING (0 0, 10 10, 10 0, 0 10)");
assertTrue(!l2.isSimple());
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineStringImplTest method testGetGeometryType.
public void testGetGeometryType() throws Exception {
final LineString l = (LineString) this.geometryFactory.geometry("LINESTRING EMPTY");
assertEquals("LineString", l.getGeometryType());
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineStringImplTest method testEquals3.
public void testEquals3() throws Exception {
final LineString l1 = (LineString) this.geometryFactory.geometry("LINESTRING(1.111 2.222, 3.333 4.444)");
final LineString l2 = (LineString) this.geometryFactory.geometry("LINESTRING(3.333 4.443, 1.111 2.222)");
assertTrue(!l1.equals(l2));
}
Aggregations