Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiLineString


    }

    public void testParse() throws Exception {
        GML2MockData.multiLineStringProperty(document, document);

        MultiLineString mp = (MultiLineString) parse();
        assertNotNull(mp);
    }
View Full Code Here


        StyleBuilder sb = new StyleBuilder();
        SimpleFeatureType pointType = DataUtilities.createType("emptyRings", "geom:MultiLineString,name:String");
        LineString emptyLine = gf.createLineString((Coordinate[]) null);
        LineString realLine = gf.createLineString(new Coordinate[] {new Coordinate(0,0),
                        new Coordinate(1, 1)});
        MultiLineString mls = gf.createMultiLineString(new LineString[] {emptyLine, realLine});
        SimpleFeature f = SimpleFeatureBuilder.build(pointType, new Object[] {mls, "name" }, null);
        Style style = sb.createStyle(sb.createPolygonSymbolizer());
       
        renderEmptyGeometry(f, style);
    }
View Full Code Here

    }

    public void testParse() throws Exception {
        GML2MockData.multiLineString(document, document);

        MultiLineString mp = (MultiLineString) parse();
        assertEquals(2, mp.getNumGeometries());
    }
View Full Code Here

        List<LineString> clippedLines = new ArrayList<LineString>();
        for (LineString ls : lines) {
            // If we want labels to be entirely in the display area, clip the linestring
            if (!partialsEnabled) {
                // more robust clipper -- see its dox
                MultiLineString ll = clipLineString(ls);
                if ((ll != null) && (!(ll.isEmpty()))) {
                    for (int t = 0; t < ll.getNumGeometries(); t++)
                        clippedLines.add((LineString) ll.getGeometryN(t));
                }
            }
            // If we want to draw partial labels on border, keep the whole linestring
            else {
                clippedLines.add(ls);
View Full Code Here

        return shapeType;
    }

    /** */
    public int getLength(Object geometry) {
        MultiLineString multi = (MultiLineString) geometry;

        int numlines;
        int numpoints;
        int length;

        numlines = multi.getNumGeometries();
        numpoints = multi.getNumPoints();

        if (shapeType == ShapeType.ARC) {
            length = 44 + (4 * numlines) + (numpoints * 16);
        } else if (shapeType == ShapeType.ARCM) {
            length = 44 + (4 * numlines) + (numpoints * 16) + 8 + 8
View Full Code Here

        return geometryFactory.createMultiLineString(lineStrings);
    }

    public void write(ByteBuffer buffer, Object geometry) {
        MultiLineString multi = (MultiLineString) geometry;

        Envelope box = multi.getEnvelopeInternal();
        buffer.putDouble(box.getMinX());
        buffer.putDouble(box.getMinY());
        buffer.putDouble(box.getMaxX());
        buffer.putDouble(box.getMaxY());

        final int numParts = multi.getNumGeometries();
        final CoordinateSequence[] lines = new CoordinateSequence[numParts];
        final double[] zExtreame = {Double.NaN, Double.NaN};
        final int npoints = multi.getNumPoints();

        buffer.putInt(numParts);
        buffer.putInt(npoints);

        {
            int idx = 0;
            for (int i = 0; i < numParts; i++) {
                lines[i] = ((LineString) multi.getGeometryN(i)).getCoordinateSequence();
                buffer.putInt(idx);
                idx = idx + lines[i].size();
            }
        }
       
View Full Code Here

    }
   
    @Test
    public void testInsideOut() throws Exception {
        LineString ls = (LineString) wkt.read("LINESTRING(-2 8, 12 8, 12 2, -2 2)");
        MultiLineString clipped = (MultiLineString) clipper.clip(ls, false);
        assertTrue(clipped.equalsExact(wkt.read("MULTILINESTRING((0 8, 10 8), (10 2, 0 2))")));
        showResult("Touch border", ls, clipped);
    }
View Full Code Here

   
    @Test
    public void testCrossingCircle() throws Exception {
        Point p = (Point) wkt.read("POINT(5 5)");
        LineString ls = ((Polygon) p.buffer(6)).getExteriorRing();
        MultiLineString clipped = (MultiLineString) clipper.clip(ls, false);
        assertEquals(4, clipped.getNumGeometries());
        showResult("Circle around", ls, clipped);
    }
View Full Code Here

    @Test
    public void testParseMulticurve() throws Exception {
        WKTReader reader = new WKTReader2();
        String WKT = "MULTICURVE EMPTY";
        MultiLineString ml = (MultiLineString) reader.read(WKT);
        assertTrue(ml.isEmpty());
       
        WKT = "MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))";
        ml = (MultiLineString) reader.read(WKT);
        assertEquals(2, ml.getNumGeometries());
        assertTrue(ml.getGeometryN(0).getClass() == LineString.class);
        assertTrue(ml.getGeometryN(1) instanceof CircularString);
       
        WKT = "MULTICURVE((100 100, 120 120), COMPOUNDCURVE(CIRCULARSTRING(0 0, 2 0, 2 1, 2 3, 4 3),(4 3, 4 5, 1 4, 0 0)))";
        ml = (MultiLineString) reader.read(WKT);
        assertEquals(2, ml.getNumGeometries());
        assertTrue(ml.getGeometryN(0).getClass() == LineString.class);
        assertTrue(ml.getGeometryN(1) instanceof CompoundRing);
    }
View Full Code Here

        SimpleFeatureCollection result = cp.execute(features, new WKTReader().read("POLYGON((-10 -10, -10 10010, 10010 10010, 10010 -10, -10 -10))"), true);
        assertEquals(1, result.size());
        SimpleFeatureIterator fi = result.features();
        // check the first polygon
        SimpleFeature f = fi.next();
        MultiLineString ml = (MultiLineString) f.getDefaultGeometry();
        assertEquals(1, ml.getNumGeometries());
        LineString ls = (LineString) ml.getGeometryN(0);
        CoordinateSequence cs = ls.getCoordinateSequence();
        assertEquals(3, cs.size());
        assertOrdinates(0, 0, 0, cs, 0);
        assertOrdinates(10000, 0, 1, cs, 1);
        assertOrdinates(10000, 10000, 2, cs, 2);
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.MultiLineString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.