Package com.vividsolutions.jts.io

Examples of com.vividsolutions.jts.io.WKTReader


      if (null == layer) {
        return null;
      }
      String area = layer.getCreateAuthorizedArea();
      try {
        WKTReader wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 0));
        return wktReader.read(area);
      } catch (ParseException pe) {
        throw new IllegalStateException("Could not parse geometry " + area, pe);
      }
    }


      if (null == layer) {
        return null;
      }
      String area = layer.getDeleteAuthorizedArea();
      try {
        WKTReader wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 0));
        return wktReader.read(area);
      } catch (ParseException pe) {
        throw new IllegalStateException("Could not parse geometry " + area, pe);
      }
    }

  private WKTReader wktReader;

  @Before
  public void setUpTestDataWithinTransaction() throws LayerException, ParseException {
    wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 4326));
    featureModel = layer.getFeatureModel();
    feature1 = NestedFeature.getDefaultInstance1();
    feature1.setGeometry(wktReader.read("POINT(10 20)"));
    layer.create(feature1);
  }

    }
    String data = (String) object;
    int srid = Integer.parseInt(data.substring(0, SRID_LENGTH - 1));
    Geometry geom;
    try {
      WKTReader reader = new WKTReader();
      geom = reader.read(data.substring(SRID_LENGTH + 1));
    } catch (Exception e) {
      throw new RuntimeException("Couldn't parse incoming wkt geometry.", e);
    }
    geom.setSRID(srid);
    return geom;

    Assert.assertTrue((jts.getLength() - gwt.getLength()) < ZERO);
  }

  @Test
  public void toWkt() throws ParseException {
    WKTReader reader = new WKTReader();
    com.vividsolutions.jts.geom.Geometry result = reader.read(gwt.toWkt());
    Assert.assertEquals(gwt.getX(), result.getCoordinate().x, DELTA);
    Assert.assertEquals(gwt.getY(), result.getCoordinate().y, DELTA);

    Assert.assertEquals("POINT(EMPTY)", empty.toWkt());
  }

    Assert.assertTrue((jts.getLength() - gwt.getLength()) < ZERO);
  }

  @Test
  public void toWkt() throws Exception {
    WKTReader reader = new WKTReader();
    com.vividsolutions.jts.geom.Geometry result = reader.read(gwt.toWkt());
    Assert.assertEquals(gwt.getCoordinate().getX(), result.getCoordinate().x, DELTA);
    Assert.assertEquals(gwt.getCoordinate().getY(), result.getCoordinate().y, DELTA);
    Assert.assertEquals("LINESTRING(EMPTY)", empty.toWkt());
  }

    Assert.assertTrue((jts.getLength() - gwt.getLength()) < DELTA);
  }

  @Test
  public void toWkt() throws ParseException {
    WKTReader reader = new WKTReader();
    com.vividsolutions.jts.geom.Geometry result = reader.read(gwt.toWkt());
    Assert.assertEquals(gwt.getX(), result.getCoordinate().x, DELTA);
    Assert.assertEquals(gwt.getY(), result.getCoordinate().y, DELTA);

    Assert.assertEquals("POINT(EMPTY)", empty.toWkt());
  }

    // Assert.assertEquals(Double.MAX_VALUE, gwt.getDistance(null), DELTA);
  }

  @Test
  public void toWkt() throws ParseException {
    WKTReader reader = new WKTReader();
    com.vividsolutions.jts.geom.Geometry result = reader.read(gwt.toWkt());
    Assert.assertEquals(gwt.getCoordinate().getX(), result.getCoordinate().x, DELTA);
    Assert.assertEquals(gwt.getCoordinate().getY(), result.getCoordinate().y, DELTA);

    Assert.assertEquals("LINESTRING(EMPTY)", empty.toWkt());
  }

  }

  void run()
      throws Exception
  {
    WKTReader rdr = new WKTReader();
    Collection lines = new ArrayList();

    lines.add(rdr.read("LINESTRING (0 0 , 10 10)"));   // isolated edge
    lines.add(rdr.read("LINESTRING (185 221, 100 100)"));   //dangling edge
    lines.add(rdr.read("LINESTRING (185 221, 88 275, 180 316)"));
    lines.add(rdr.read("LINESTRING (185 221, 292 281, 180 316)"));
    lines.add(rdr.read("LINESTRING (189 98, 83 187, 185 221)"));
    lines.add(rdr.read("LINESTRING (189 98, 325 168, 185 221)"));

    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);

    Collection polys = polygonizer.getPolygons();

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);

  }

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.