Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Polygon


    Geometry result = null;

    if (geomToAddVertex instanceof Polygon || geomToAddVertex instanceof MultiPolygon) {

      Polygon polygon;
      // cast to polygon, we know that geomToAddVertex only has one
      // geometry.
      if (geomToAddVertex instanceof MultiPolygon) {
        MultiPolygon mpolygon = (MultiPolygon) geomToAddVertex;
        polygon = (Polygon) mpolygon.getGeometryN(0);
View Full Code Here


    List<Coordinate> shellCoordinates = null;
    List<LinearRing> holesList = null;
    GeometryFactory fc = polygonToAddVertex.getFactory();

    // cast to polygon and get the exterior boundary.
    Polygon polygonGeom = (Polygon) polygonToAddVertex;
    Geometry boundary = polygonGeom.getExteriorRing();

    Coordinate[] shellClosed = null;
    Coordinate[] boundaryCoordinates = boundary.getCoordinates();

    // for each neighbor
View Full Code Here

   */
  private static Geometry[] getInteriorHoles(Geometry geomToAddVertex) {

    Geometry[] holes = new Geometry[0];
    // get the interior rings.
    Polygon polygon = (Polygon) geomToAddVertex;

    holes = new Geometry[polygon.getNumInteriorRing()];
    for (int j = 0; j < polygon.getNumInteriorRing(); j++) {

      Geometry interiorRing = polygon.getInteriorRingN(j);
      holes[j] = interiorRing;
    }

    return holes;
  }
View Full Code Here

        // Polygon polygon = d.polygon(new int[]{40,30, 60,70, 30,130, 130,130, 130,30});

        int[] xy = new int[]{(int) (height * 0.15), (int) (width * 0.20), (int) (height * 0.4), (int) (width * 0.3),
                (int) (height * 0.85), (int) (width * 0.15), (int) (height * 0.85), (int) (width * 0.85), (int) (height * 0.15),
                (int) (width * 0.85)};
        Polygon polygon = d.polygon(xy);
        d.drawDirect(finalImage, d.feature(polygon), newRule);
        Graphics2D g2d = finalImage.createGraphics();
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.drawImage(finalImage, 0, 0, null);
        g2d.dispose();
View Full Code Here

        IAOIService aOIService = PlatformGIS.getAOIService();
        Geometry multiGeometry = aOIService.getGeometry();
        if (multiGeometry != null) {
       
            Geometry innerPolygons = null;
            Polygon polygon = null;
            // draw the rectangle around the active region green:143
            //float[] rgba = style.backgroundColor.getColorComponents(null);
            //g.setColor(new Color(rgba[0], rgba[1], rgba[2], style.bAlpha));
            graphic.setColor(new Color((float)0.5, (float)0.5, (float)0.5, (float)0.5));
   
            int screenWidth = screen.width;
            int screenHeight = screen.height;
   
            GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
            path.moveTo(0, 0);
            path.lineTo(screenWidth, 0);
            path.lineTo(screenWidth, screenHeight);
            path.lineTo(0, screenHeight);
            path.closePath();
           
            // if multi geometry - loop through each geometry
            for (int g=0; g<multiGeometry.getNumGeometries(); g++) {
                Geometry geometry = multiGeometry.getGeometryN(g);
                if (geometry.getGeometryType().equals("Polygon")){
                    polygon = (Polygon) geometry;
                   
                    // get the exterior rings
                    LineString exterior = polygon.getExteriorRing();
                   
                    // collects the internal holes if there are any
                    for (int i=0; i<polygon.getNumInteriorRing(); i++) {
                        if (innerPolygons == null) {
                            innerPolygons = polygon.getInteriorRingN(i);
                        }
                        else {
                            innerPolygons = innerPolygons.union(polygon.getInteriorRingN(i));
                        }
                       
                    }
                   
                    Coordinate[] coordinates = exterior.getCoordinates();
View Full Code Here

    }

  @Override
  protected Geometry toCollection(Geometry geometry) {
    if (geometry instanceof Polygon) {
      Polygon polygon = (Polygon) geometry;
      GeometryFactory factory = polygon.getFactory();
      return factory.createMultiPolygon(new Polygon[] { polygon });
    }
    return geometry;
  }
View Full Code Here

                new Coordinate(-128.6811, 59.0559), new Coordinate(-128.6817, 59.0538),
                new Coordinate(-128.683, 59.0526), new Coordinate(-128.6837, 59.052),
                new Coordinate(-128.685, 59.0512), new Coordinate(-128.6863, 59.0512),
                new Coordinate(-128.6889, 59.0493), new Coordinate(-128.6898, 59.0493)};
        GeometryFactory fac=new GeometryFactory();
        Polygon lake = fac.createPolygon(fac.createLinearRing(coords), new LinearRing[0]);
        Envelope env = lake.getEnvelopeInternal();
       
        ViewportModel model = ((ViewportModel) handler.getContext().getMap().getViewportModel());
        model.setBounds(env);
        model.setWidth(env.getWidth()*200);
       
View Full Code Here

        WKTReader reader = new WKTReader( geometryFactory );
       
       
        //create feature collection with 2 geometries:
        //1. donut minus hole
        Polygon donut = (Polygon) reader.read("POLYGON ((100 100, 120 100, 120 120, 100 120, 100 100),(112 112, 118 112, 118 118, 112 118, 112 112))");
       
        //2. hole
        Polygon hole = (Polygon) reader.read("POLYGON ((112 112, 118 112, 118 118, 112 118, 112 112))");
       
        //add the two geometries to a FeatureCollection
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName( "Test" );
        b.add( "location", Polygon.class );
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeature donutFeature = SimpleFeatureBuilder.build(type, new Object[]{donut}, "fid.1");
        SimpleFeature holeFeature = SimpleFeatureBuilder.build(type, new Object[]{hole}, "fid.2");
        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        fc.add(donutFeature);
        fc.add(holeFeature);
       
        //create iterator for collection
        FeatureIterator<SimpleFeature> iterator = fc.features();
       
        //create List<Geometry> for the simulated "drawn" shape
        Polygon userDrawnPoly = (Polygon) reader.read("POLYGON ((114 90, 130 90, 130 130, 114 130, 114 90))");
        List<Geometry> geoms = new ArrayList<Geometry>();
        geoms.add(userDrawnPoly);
       
        DifferenceFeatureCommand.runDifferenceOp(iterator, geoms);
        assertEquals(1, geoms.size());
View Full Code Here

        assertEquals(1, ((List) editBlackboardEvent.getNewValue()).size());
        assertEquals(map, editBlackboardEvent.getSource());
       
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        Polygon polygon = createPolygon(factory, 10);
        mapping=map.setGeometries(polygon, null);
        assertEquals(ShapeType.POLYGON, mapping.get(polygon).getShapeType());
        assertNotNull(mapping.get(polygon));
        assertPixMapState(map,1,5,1,5);
        assertEquals(Point.valueOf(20,10), map.getGeoms().get(0).getShell().getPoint(0) );
View Full Code Here

        assertEquals(2, candidates.size());
        assertTrue( candidates.get(0).getGeom()==mapping.get(ring3) || candidates.get(1).getGeom()==mapping.get(ring3));
        assertTrue( candidates.get(0).getGeom()==mapping.get(ring2) || candidates.get(1).getGeom()==mapping.get(ring2));
       
        // now testing geoms with holes
        Polygon polygon=createPolygon(factory, 10);
        mapping=map.setGeometries(ring1, null);
        mapping.putAll(map.addGeometry(polygon, null));

        candidates = map.getCandidates(26,12, true);
        assertEquals(1, candidates.size());
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.