Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiPoint


  }

  @Test
  public void dtoMultiPointToJts() throws GeomajasException {
    // Test DTO MultiPoint to JTS:
    MultiPoint multiPoint = (MultiPoint) converter.toInternal(createDtoMultiPoint());
    Assert.assertEquals(dtoC2.getX(), multiPoint.getGeometryN(1).getCoordinate().x);
  }
View Full Code Here


* @author Jan De Moerloose
*/
public class MultiPointWriter implements GraphicsWriter {

  public void writeObject(Object o, GraphicsDocument document, boolean asChild) throws RenderException {
    MultiPoint mp = (MultiPoint) o;
    for (int i = 0; i < mp.getNumGeometries(); i++) {
      document.writeElement("use", i == 0 && asChild);
      Point p = (Point) mp.getGeometryN(i);
      document.writeAttribute("x", p.getX());
      document.writeAttribute("y", p.getY());
    }
  }
View Full Code Here

    Polygon polygon = (Polygon) reader.read("POLYGON ((0 0,1 1,0 1,0 0))");
    geometry = geoService.transform(polygon, new ThrowingTransform());
    Assert.assertEquals(Polygon.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());

    MultiPoint multipoint = (MultiPoint) reader.read("MULTIPOINT ((1 1),(2 1))");
    geometry = geoService.transform(multipoint, new ThrowingTransform());
    Assert.assertEquals(MultiPoint.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());
   
    MultiLineString multilineString = (MultiLineString) reader.read("MULTILINESTRING ((0 1,1 1),(0 2,2 2))");
View Full Code Here

      MultiLineString mline = (MultiLineString) g;
      for (int i = 0; i < mline.getNumGeometries(); i++) {
        drawGeometry(mline.getGeometryN(i), symbol);
      }
    } else if (g instanceof MultiPoint) {
      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();
View Full Code Here

    MultiGenerator pg = new MultiGenerator(pgc);
    pg.setBoundingBox(new Envelope(0,10,0,10));
    pg.setNumberGeometries(3);
    pg.setGeometryFactory(geometryFactory);
   
    MultiPoint pt = (MultiPoint) pg.create();

    GMLWriter out = new GMLWriter();
    out.setPrefix(null);
    out.write(pt,getWriter());
   
    GMLReader in = new GMLReader();
    MultiPoint pt2 = (MultiPoint) in.read(getReader(),geometryFactory);

//    System.out.println((pt==null?"NULL":pt.toString()));
//    System.out.println((pt2==null?"NULL":pt2.toString()));
    assertTrue("The input MultiPoint is not the same as the output MultiPoint",pt.equals(pt2));
  }
View Full Code Here

                                pm.beginTask("Converting geometries of places...", size);
                                int id = 0;
                                for( String name : keySet ) {
                                    Coordinate coordinate = placesMap.get(name);
                                    MultiPoint point = gF.createMultiPoint(new Coordinate[]{coordinate});
                                    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
                                    Object[] values = new Object[]{point, name};
                                    builder.addAll(values);
                                    SimpleFeature feature = builder.buildFeature(type.getTypeName() + "." + id);
                                    id++;
View Full Code Here

    System.out.println(p1);

    Point p2 = fact.createPoint(new Coordinate(1,1));
    System.out.println(p2);

    MultiPoint mpt = fact.createMultiPoint(new Coordinate[] { new Coordinate(0,0), new Coordinate(1,1) } );
    System.out.println(mpt);

  }
View Full Code Here

         * @param geom DOCUMENT ME!
         *
         * @throws IOException DOCUMENT ME!
         */
        protected void writeGeometry(Geometry geom) throws IOException {
            MultiPoint mp = (MultiPoint) geom;

            for (int i = 0; i < mp.getNumGeometries(); i++) {
                super.startElement(null);
                super.writeGeometry(mp.getGeometryN(i));
                super.endGeometry(mp.getGeometryN(i));
                super.endElement(null);
            }
        }
View Full Code Here

                fidFilter);
        SimpleFeature modified = store.getFeatures(fidFilter).features().next();
        assertEquals(newDescription, modified.getAttribute("description"));
       
        // test a mapped attribute
        MultiPoint mpo = (MultiPoint) original.getAttribute("pointProperty");
        MultiPoint mpm = mpo.getFactory().createMultiPoint(new Coordinate[] {new Coordinate(10, 12)});
        store.modifyFeatures(original.getFeatureType().getDescriptor("pointProperty"), mpm,
                fidFilter);
        modified = store.getFeatures(fidFilter).features().next();
        assertTrue(mpm.equalsExact((Geometry) modified.getAttribute("pointProperty")));
    }
View Full Code Here

        if (crossPoints != null) {
          ArrayList<Point> pts = new ArrayList<Point>();
          if (crossPoints instanceof Point) {
            pts.add((Point) crossPoints);
          } else if (crossPoints instanceof MultiPoint) {
            MultiPoint mp = (MultiPoint) crossPoints;
            for (int i = 0, count = mp.getNumGeometries(); i < count; i++) {
              Point pt = (Point) mp.getGeometryN(i);
              pts.add(pt);
            }
          }
          for (Iterator<Point> itr = pts.iterator(); itr.hasNext();) {
            Point pt = itr.next();
            double d = pt.distance(ptStart);
            if (d < nearestStart) {
              nearestStart = d;
              nearestCrossStart = pt;
            }
          }
        }
      }
      if (nearestCrossStart != null) {
        lineCoords.add(0, nearestCrossStart.getCoordinate());
      }

      // Extend end vertex
      Point ptEnd = source.getEndPoint();
      Point ptEnd2 = source.getPointN(source.getNumPoints() - 2);
      // Calculate an extend point
      double aEnd = Math.atan((ptEnd2.getY() - ptEnd.getY())
          / (ptEnd2.getX() - ptEnd.getX()));
      double xEnd = ptEnd.getX() + max
          * (ptEnd2.getX() > ptEnd.getX() ? -1 : 1)
          * Math.abs(Math.cos(aEnd));
      double yEnd = ptEnd.getY() + max
          * (ptEnd2.getY() > ptEnd.getY() ? -1 : 1)
          * Math.abs(Math.sin(aEnd));
      Point ptEnd3 = GeometryUtil.gf().createPoint(
          new Coordinate(xEnd, yEnd));
      LineString lEnd = GeometryUtil.gf().createLineString(
          new Coordinate[] { ptEnd.getCoordinate(),
              ptEnd3.getCoordinate() });

      Point nearestCrossEnd = null;
      double nearestEnd = Double.MAX_VALUE;
      for (Iterator<LineString> itrTrimExtend = trimExtendToList
          .iterator(); itrTrimExtend.hasNext();) {
        LineString l = itrTrimExtend.next();
        Geometry crossPoints = l.intersection(lEnd);
        if (crossPoints != null) {
          ArrayList<Point> pts = new ArrayList<Point>();
          if (crossPoints instanceof Point) {
            pts.add((Point) crossPoints);
          } else if (crossPoints instanceof MultiPoint) {
            MultiPoint mp = (MultiPoint) crossPoints;
            for (int i = 0, count = mp.getNumGeometries(); i < count; i++) {
              Point pt = (Point) mp.getGeometryN(i);
              pts.add(pt);
            }
          }
          for (Iterator<Point> itr = pts.iterator(); itr.hasNext();) {
            Point pt = itr.next();
View Full Code Here

TOP

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

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.