Examples of Polygon


Examples of com.vividsolutions.jts.geom.Polygon

    // create a rectangle that overlaps 50 %
    GeometryFactory factory = new GeometryFactory();
    LinearRing half1 = factory.createLinearRing(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 0.5), new Coordinate(0, 0.5), new Coordinate(0, 0)});
    Polygon polygon = factory.createPolygon(half1, null);
    request.setLocation(converter.toDto(polygon));

    // execute
    SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
        SearchByLocationRequest.COMMAND, request, null, "en");
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

    // create a rectangle that overlaps 49 %
    GeometryFactory factory = new GeometryFactory();
    LinearRing half1 = factory.createLinearRing(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 0.49), new Coordinate(0, 0.49), new Coordinate(0, 0)});
    Polygon polygon = factory.createPolygon(half1, null);
    request.setLocation(converter.toDto(polygon));

    // execute
    SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
        SearchByLocationRequest.COMMAND, request, null, "en");
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

    } else if (geometry instanceof LineString) {
      dto = new Geometry(Geometry.LINE_STRING, srid, precision);
      dto.setCoordinates(convertCoordinates(geometry));
    } else if (geometry instanceof Polygon) {
      dto = new Geometry(Geometry.POLYGON, srid, precision);
      Polygon polygon = (Polygon) geometry;
      Geometry[] geometries = new Geometry[polygon.getNumInteriorRing() + 1];
      for (int i = 0; i < geometries.length; i++) {
        if (i == 0) {
          geometries[i] = toDto(polygon.getExteriorRing());
        } else {
          geometries[i] = toDto(polygon.getInteriorRingN(i - 1));
        }
      }
      dto.setGeometries(geometries);
    } else if (geometry instanceof MultiPoint) {
      dto = new Geometry(Geometry.MULTI_POINT, srid, precision);
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

          coords.add(new Coordinate(w, 0));
          coords.add(new Coordinate(w, h));
          coords.add(new Coordinate(0, h));
          coords.add(new Coordinate(0, 0));
          LinearRing ring = geometryFactory.createLinearRing(coords.toArray(new Coordinate[coords.size()]));
          Polygon p = geometryFactory.createPolygon(ring, null);
          polygon = new LiteShape2(p, null, null, false);
        }
        return polygon;
      } else if (symbolizer instanceof PointSymbolizer) {
        if (point == null) {
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

      MultiPoint mpoint = (MultiPoint) g;
      for (int i = 0; i < mpoint.getNumGeometries(); i++) {
        drawGeometry(mpoint.getGeometryN(i), symbol);
      }
    } else if (g instanceof Polygon) {
      Polygon poly = (Polygon) g;
      LineString shell = poly.getExteriorRing();
      int nHoles = poly.getNumInteriorRing();
      drawPathContent(shell.getCoordinates());
      for (int j = 0; j < nHoles; j++) {
        drawPathContent(poly.getInteriorRingN(j).getCoordinates());
      }
      template.closePathEoFillStroke();
    } else if (g instanceof LineString) {
      LineString line = (LineString) g;
      drawPathContent(line.getCoordinates());
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

  @Before
  public void setupBeans() throws LayerException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4329);
    LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 1), new Coordinate(0, 1), new Coordinate(0, 0), });
    Polygon p = factory.createPolygon(shell, null);
    MultiPolygon expected = factory.createMultiPolygon(new Polygon[] { p });
    CustomBean cb = new CustomBean();
    cb.setId(1);
    cb.setGeometry(expected);
    cb.setName("testbean");
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

  @Test
  public void readGeometry() throws LayerException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 1), new Coordinate(0, 1), new Coordinate(0, 0), });
    Polygon p = factory.createPolygon(shell, null);
    MultiPolygon expected = factory.createMultiPolygon(new Polygon[] { p });
    Assert.assertTrue(((CustomBean) layer.read("1")).getGeometry().equalsExact(expected));
  }
View Full Code Here

Examples of com.vividsolutions.jts.geom.Polygon

  public void readGeometry() throws LayerException {
    Object bean = layer.read("1");
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 1), new Coordinate(0, 1), new Coordinate(0, 0), });
    Polygon p = factory.createPolygon(shell, null);
    MultiPolygon expected =factory.createMultiPolygon(new Polygon[]{p});
    Geometry g = layer.getFeatureModel().getGeometry(bean);
    Assert.assertTrue(expected.equalsExact(g, 0.00001));
  }
View Full Code Here

Examples of de.lmu.ifi.dbs.elki.data.spatial.Polygon

        }
        catch(ObjectNotFoundException e) {
          // ignore
        }
      }
      Polygon chres = hull.getHull();
      if(chres != null && chres.size() >= 3) {
        SVGPath path = new SVGPath(chres);

        Element selHull = path.makeElement(svgp);
        SVGUtil.addCSSClass(selHull, SELECTEDHULL);
        // TODO: use relative selection size for opacity?
View Full Code Here

Examples of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.shapes.Polygon

    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, PhysicsAgent2D<?> bodyA, PhysicsAgent2D<?> bodyB) {
    Polygon polyA = (Polygon) bodyA.getBodyShape();
    Circle circle = (Circle) bodyB.getBodyShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only the circle
    Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
   
    Vector2f centroidA = new Vector2f(polyA.getCentroid());
    centroidA.add(bodyA.getPosition());

   
    int[][] collPairs = getCollisionCandidates(vertsA, centroidA, circle.getRadius(), bodyB.getPosition());

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.