Search in sources :

Example 56 with LineString

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString)

Example 57 with LineString

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();
    }
}
Also used : ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) LineString(com.revolsys.geometry.model.LineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString)

Example 58 with LineString

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());
}
Also used : LineString(com.revolsys.geometry.model.LineString)

Example 59 with LineString

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());
}
Also used : LineString(com.revolsys.geometry.model.LineString)

Example 60 with LineString

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));
}
Also used : LineString(com.revolsys.geometry.model.LineString)

Aggregations

LineString (com.revolsys.geometry.model.LineString)380 Point (com.revolsys.geometry.model.Point)184 Geometry (com.revolsys.geometry.model.Geometry)65 ArrayList (java.util.ArrayList)62 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)51 Polygon (com.revolsys.geometry.model.Polygon)37 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)24 Edge (com.revolsys.geometry.graph.Edge)22 List (java.util.List)22 BoundingBox (com.revolsys.geometry.model.BoundingBox)20 Lineal (com.revolsys.geometry.model.Lineal)20 Test (org.junit.Test)20 LinearRing (com.revolsys.geometry.model.LinearRing)19 Record (com.revolsys.record.Record)17 Iterator (java.util.Iterator)14 LineStringEditor (com.revolsys.geometry.model.editor.LineStringEditor)13 Punctual (com.revolsys.geometry.model.Punctual)12 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)12 LineSegment (com.revolsys.geometry.model.segment.LineSegment)10 Polygonal (com.revolsys.geometry.model.Polygonal)9