Package com.vividsolutions.jts.io

Examples of com.vividsolutions.jts.io.WKTReader


    super(ctx, factory);
  }

  @Override
  public Shape parseIfSupported(String wktString) throws ParseException {
    return parseIfSupported(wktString, new WKTReader(ctx.getGeometryFactory()));
  }


            if (regionIds.length > 1 && isWithinFilter) {
                geoms.add(0, unionedGeom);
            }
            return geoms;
        }else if (geomWKT != null) {
            WKTReader reader = new WKTReader();
            return Arrays.asList(reader.read(geomWKT));
        } else {
            return null;
        }
    }

                result.add(createLineStringUsingNodes(relationship));

            } else {
                String geometryWKT = (String) relationship.getProperty(OsmEntityAttributeKey.WAY_GEOMETRY.name());

                WKTReader reader = new WKTReader();

                try {
                    result.add((LineString) reader.read(geometryWKT));
                } catch (ParseException e) {
                    Object wayId = relationship.getProperty(OsmEntityAttributeKey.WAY_ID.name());
                    System.out.printf("Failed to parse geometry for way = %s and wkt = %s \n ", wayId, geometryWKT);
                    result.add(createLineStringUsingNodes(relationship));

public class PolygonUnionUsingBuffer {

  public static void main(String[] args)
      throws Exception
  {
    WKTReader rdr = new WKTReader();

    Geometry[] geom = new Geometry[3];
    geom[0] = rdr.read("POLYGON (( 100 180, 100 260, 180 260, 180 180, 100 180 ))");
    geom[1] = rdr.read("POLYGON (( 80 140, 80 200, 200 200, 200 140, 80 140 ))");
    geom[2] = rdr.read("POLYGON (( 160 160, 160 240, 240 240, 240 160, 160 160 ))");
    unionUsingBuffer(geom);

  }

        widgets.add(featureData("geom", geo("POINT(2 2)"), "name", "dynamite", "id", 2));
        return widgets;
    }

    protected Geometry geo(String wkt) throws ParseException {
        return new WKTReader().read(wkt);
    }

        Random rand = new Random();
        List<Coordinate> list = Lists.newArrayList();
        for (int i = 0; i < NUM_COORDS; i++) {
            list.add(new Coordinate(rand.nextInt(), rand.nextInt()));
        }
        Geometry oldGeom = new WKTReader()
                .read("MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 45 10, 30 5, 10 30, 20 35),(30 20, 20 25, 20 15, 30 20)))");
        Geometry newGeom = new WKTReader()
                .read("MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 45 20, 30 5, 10 10, 10 30, 20 35)))");
        LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.of(oldGeom),
                Optional.of(newGeom));
        LCSGeometryDiffImpl deserializedDiff = new LCSGeometryDiffImpl(diff.asText());
        assertEquals(diff, deserializedDiff);

        assertEquals(newGeom, resultingGeom.get());
    }

    @Test
    public void testModifiedMultiLineString() throws Exception {
        Geometry oldGeom = new WKTReader()
                .read("MULTILINESTRING ((40 40, 20 45, 45 30, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
        Geometry newGeom = new WKTReader()
                .read("MULTILINESTRING ((40 40, 20 35, 45 30, 40 40),(20 35, 45 20, 30 15, 10 10, 10 30, 20 35),(10 10, 20 20, 35 30))");
        LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.of(oldGeom),
                Optional.of(newGeom));
        LCSGeometryDiffImpl deserializedDiff = new LCSGeometryDiffImpl(diff.asText());
        assertEquals(diff, deserializedDiff);

        assertEquals(newGeom, resultingGeom.get());
    }

    @Test
    public void testNoOldGeometry() throws Exception {
        Geometry newGeom = new WKTReader()
                .read("MULTILINESTRING ((40 40, 20 35, 45 30, 40 40),(20 35, 45 20, 30 15, 10 10, 10 30, 20 35),(10 10, 20 20, 35 30))");
        LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.fromNullable((Geometry) null),
                Optional.of(newGeom));
        LCSGeometryDiffImpl deserializedDiff = new LCSGeometryDiffImpl(diff.asText());
        assertEquals(diff, deserializedDiff);

        assertEquals("0 point(s) deleted, 13 new point(s) added, 0 point(s) moved", diff.toString());
    }

    @Test
    public void testNoNewGeometry() throws Exception {
        Geometry oldGeom = new WKTReader()
                .read("MULTILINESTRING ((40 40, 20 45, 45 30, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
        LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.of(oldGeom),
                Optional.fromNullable((Geometry) null));
        LCSGeometryDiffImpl deserializedDiff = new LCSGeometryDiffImpl(diff.asText());
        assertEquals(diff, deserializedDiff);

        assertFalse(resultingGeom.isPresent());
    }

    @Test
    public void testDoubleReverseEquality() throws Exception {
        Geometry oldGeom = new WKTReader()
                .read("MULTILINESTRING ((40 40, 20 45, 45 30, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
        Geometry newGeom = new WKTReader()
                .read("MULTILINESTRING ((40 40, 20 35, 45 30, 40 40),(20 35, 45 20, 30 15, 10 10, 10 30, 20 35),(10 10, 20 20, 35 30))");
        LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.of(oldGeom),
                Optional.of(newGeom));
        LCSGeometryDiffImpl diff2 = diff.reversed().reversed();
        assertEquals(diff, diff2);

TOP

Related Classes of com.vividsolutions.jts.io.WKTReader

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.