Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Polygon


    document.writeElement("vml:shape", asChild);
    document.writeAttribute("fill-rule", "evenodd");
    document.writeAttributeStart("path");
    MultiPolygon mpoly = (MultiPolygon) o;
    for (int i = 0; i < mpoly.getNumGeometries(); i++) {
      Polygon poly = (Polygon) mpoly.getGeometryN(i);
      LineString shell = poly.getExteriorRing();
      int nHoles = poly.getNumInteriorRing();
      document.writeClosedPathContent(shell.getCoordinates());

      for (int j = 0; j < nHoles; j++) {
        document.writeClosedPathContent(poly.getInteriorRingN(j).getCoordinates());
      }
    }
    document.writeAttributeEnd();
  }
View Full Code Here


   */
  public void writeObject(Object o, GraphicsDocument document, boolean asChild) throws RenderException {
    document.writeElement("vml:shape", asChild);
    document.writeAttribute("fill-rule", "evenodd");
    document.writeAttributeStart("path");
    Polygon poly = (Polygon) o;
    LineString shell = poly.getExteriorRing();
    int nHoles = poly.getNumInteriorRing();
    document.writeClosedPathContent(shell.getCoordinates());
    for (int j = 0; j < nHoles; j++) {
      document.writeClosedPathContent(poly.getInteriorRingN(j).getCoordinates());
    }
    document.writeAttributeEnd();
  }
View Full Code Here

  }

  @Test
  public void dtoPolygonToJts() throws GeomajasException {
    // Test DTO Polygon to JTS:
    Polygon polygon = (Polygon) converter.toInternal(createDtoPolygon());
    Assert.assertEquals(dtoC6.getX(), polygon.getInteriorRingN(0).getCoordinateN(1).x);
  }
View Full Code Here

  @Test
  public void dtoMultiPolygonToJts() throws GeomajasException {
    // Test DTO MultiPolygon to JTS:
    MultiPolygon multiPolygon = (MultiPolygon) converter.toInternal(createDtoMultiPolygon());
    Polygon polygon = (Polygon) multiPolygon.getGeometryN(1);
    Assert.assertEquals(dtoC6.getX(), polygon.getInteriorRingN(0).getCoordinateN(1).x);
  }
View Full Code Here

  private MultiPolygon createJtsMultiPolygon() {
    LinearRing shell = factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC1, jtsC2, jtsC3,
        jtsC4, jtsC1 });
    LinearRing hole = factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC5, jtsC6, jtsC7,
        jtsC8, jtsC5 });
    Polygon polygon1 = factory.createPolygon(shell, new LinearRing[] {});
    Polygon polygon2 = factory.createPolygon(shell, new LinearRing[] { hole });
    return factory.createMultiPolygon(new Polygon[] { polygon1, polygon2 });
  }
View Full Code Here

    Assert.assertTrue(ne.evaluate(f));
  }

  @Test
  public void testContainsFilter() throws GeomajasException, ParseException {
    Polygon poly1 = (Polygon) wkt.read("POLYGON((0 0,1 0,1 1,0 1,0 0))");
    Polygon touching = (Polygon) wkt.read("POLYGON((1 1,2 1,2 2,1 2,1 1))");
    Polygon disjoint = (Polygon) wkt.read("POLYGON((2 2,3 2,3 3,2 3,2 2))");
    Polygon overlapping = (Polygon) wkt.read("POLYGON((0.5 0.5,1.5 0.5,1.5 1.5,0.5 1.5,0.5 0.5))");
    Polygon within = (Polygon) wkt.read("POLYGON((0.1 0.1,0.9 0.1,0.9 0.9,0.1 0.9,0.1 0.1))");
    Polygon contains = (Polygon) wkt.read("POLYGON((-0.1 -0.1,1.1 -0.1,1.1 1.1,-0.1 1.1,-0.1 -0.1))");
    Filter filter = filterService.createContainsFilter(poly1, "geometry");
    TestFeature f = new TestFeature();
    f.expectAndReturn("geometry", touching);
    Assert.assertFalse(filter.evaluate(f));
    f.clear();
View Full Code Here

    Assert.assertTrue(fid.evaluate(f));
  }

  @Test
  public void testGeometryTypeFilter() throws GeomajasException, ParseException {
    Polygon poly = (Polygon) wkt.read("POLYGON((0 0,1 0,1 1,0 1,0 0))");
    Filter fid = filterService.createGeometryTypeFilter("geometry", "Polygon");
    TestFeature f = new TestFeature();
    f.expectAndReturn("geometry", poly);
    Assert.assertTrue(fid.evaluate(f));
  }
View Full Code Here

    Assert.assertTrue(fid.evaluate(f));
  }

  @Test
  public void testIntersectsFilter() throws GeomajasException, ParseException {
    Polygon poly1 = (Polygon) wkt.read("POLYGON((0 0,1 0,1 1,0 1,0 0))");
    Polygon touching = (Polygon) wkt.read("POLYGON((1 1,2 1,2 2,1 2,1 1))");
    Polygon disjoint = (Polygon) wkt.read("POLYGON((2 2,3 2,3 3,2 3,2 2))");
    Polygon overlapping = (Polygon) wkt.read("POLYGON((0.5 0.5,1.5 0.5,1.5 1.5,0.5 1.5,0.5 0.5))");
    Polygon within = (Polygon) wkt.read("POLYGON((0.1 0.1,0.9 0.1,0.9 0.9,0.1 0.9,0.1 0.1))");
    Polygon contains = (Polygon) wkt.read("POLYGON((-0.1 -0.1,1.1 -0.1,1.1 1.1,-0.1 1.1,-0.1 -0.1))");
    Filter filter = filterService.createIntersectsFilter(poly1, "geometry");
    TestFeature f = new TestFeature();
    f.expectAndReturn("geometry", touching);
    Assert.assertTrue(filter.evaluate(f));
    f.clear();
View Full Code Here

    Assert.assertTrue(filter.evaluate(f));
  }

  @Test
  public void testOverlapsFilter() throws GeomajasException, ParseException {
    Polygon poly1 = (Polygon) wkt.read("POLYGON((0 0,1 0,1 1,0 1,0 0))");
    Polygon touching = (Polygon) wkt.read("POLYGON((1 1,2 1,2 2,1 2,1 1))");
    Polygon disjoint = (Polygon) wkt.read("POLYGON((2 2,3 2,3 3,2 3,2 2))");
    Polygon overlapping = (Polygon) wkt.read("POLYGON((0.5 0.5,1.5 0.5,1.5 1.5,0.5 1.5,0.5 0.5))");
    Polygon within = (Polygon) wkt.read("POLYGON((0.1 0.1,0.9 0.1,0.9 0.9,0.1 0.9,0.1 0.1))");
    Polygon contains = (Polygon) wkt.read("POLYGON((-0.1 -0.1,1.1 -0.1,1.1 1.1,-0.1 1.1,-0.1 -0.1))");
    Filter filter = filterService.createOverlapsFilter(poly1, "geometry");
    TestFeature f = new TestFeature();
    f.expectAndReturn("geometry", touching);
    Assert.assertFalse(filter.evaluate(f));
    f.clear();
View Full Code Here

    Assert.assertFalse(filter.evaluate(f));
  }

  @Test
  public void testTouchesFilter() throws GeomajasException, ParseException {
    Polygon poly1 = (Polygon) wkt.read("POLYGON((0 0,1 0,1 1,0 1,0 0))");
    Polygon touching = (Polygon) wkt.read("POLYGON((1 1,2 1,2 2,1 2,1 1))");
    Polygon disjoint = (Polygon) wkt.read("POLYGON((2 2,3 2,3 3,2 3,2 2))");
    Polygon overlapping = (Polygon) wkt.read("POLYGON((0.5 0.5,1.5 0.5,1.5 1.5,0.5 1.5,0.5 0.5))");
    Polygon within = (Polygon) wkt.read("POLYGON((0.1 0.1,0.9 0.1,0.9 0.9,0.1 0.9,0.1 0.1))");
    Polygon contains = (Polygon) wkt.read("POLYGON((-0.1 -0.1,1.1 -0.1,1.1 1.1,-0.1 1.1,-0.1 -0.1))");
    Filter filter = filterService.createTouchesFilter(poly1, "geometry");
    TestFeature f = new TestFeature();
    f.expectAndReturn("geometry", touching);
    Assert.assertTrue(filter.evaluate(f));
    f.clear();
View Full Code Here

TOP

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

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.