Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Geometry


    Iterator<?> it = getElements(queryFilter, 0, 0);
    // start with null envelope
    Envelope bounds = new Envelope();
    while (it.hasNext()) {
      Object o = it.next();
      Geometry g = featureModel.getGeometry(o);
      bounds.expandToInclude(g.getEnvelopeInternal());
    }
    return bounds;
  }
View Full Code Here


  public void draw(Graphics2D graphics, MapContent map, MapViewport viewport) {
    MathTransform worldtoScreen = createAffineTransform(viewport);
    for (Geometry geometry : geometries) {
      LiteShape2 shape;
      try {
        Geometry screenGeom = JTS.transform(geometry, worldtoScreen);
        shape = new LiteShape2(screenGeom, null, null, false);
        NumberRange<Double> range = NumberRange.create(0d, 100d);

        Style2D style2D = styleFactory.createStyle(null, style.featureTypeStyles().get(0).rules().get(0)
            .symbolizers().get(0), range);
View Full Code Here

    Assert.assertTrue(crsTransform2.equals(mathTransform));
  }

  @Test
  public void testCalcDefaultLabelPosition() throws Exception {
    Geometry geometry;
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    Coordinate coordinate;
    InternalFeature feature = new InternalFeatureImpl();
    feature.setId("x");
    feature.setLabel("Label x");
View Full Code Here

    Assert.assertEquals(4.0, coordinate.y, DELTA);
  }

  @Test
  public void testCreateCircle() throws Exception {
    Geometry geometry;
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    Point point = factory.createPoint(new Coordinate(0, 0));
    Point inside = factory.createPoint(new Coordinate(9.5, 0));
    Point insideFine = factory.createPoint(new Coordinate(6.8, 6.8));
    Point outsideAll = factory.createPoint(new Coordinate(9, 5));

    geometry = geoService.createCircle(point, 10, 4);
    Assert.assertEquals(5, geometry.getCoordinates().length);
    Assert.assertTrue(geometry.contains(inside));
    Assert.assertFalse(geometry.contains(insideFine));
    Assert.assertFalse(geometry.contains(outsideAll));

    geometry = geoService.createCircle(point, 10, 16);
    Assert.assertEquals(17, geometry.getCoordinates().length);
    Assert.assertTrue(geometry.contains(inside));
    Assert.assertTrue(geometry.contains(insideFine));
    Assert.assertFalse(geometry.contains(outsideAll));
  }
View Full Code Here

    Assert.assertFalse(geometry.contains(outsideAll));
  }

  @Test
  public void transformGeometryString() throws Exception {
    Geometry geometry = getLineString();

    Assert.assertEquals(geometry, geoService.transform(geometry, LONLAT, LONLAT));

    geometry = geoService.transform(geometry, LONLAT, LAMBERT72);
    assertTransformedLineString(geometry);
View Full Code Here

    assertTransformedLineString(geometry);
  }

  @Test
  public void transformGeometryCrs() throws Exception {
    Geometry geometry = getLineString();
    Crs source = geoService.getCrs2(LONLAT);
    Crs target = geoService.getCrs2(LAMBERT72);

    Assert.assertEquals(geometry, geoService.transform(geometry, source, source));
View Full Code Here

    assertTransformedLineString(geometry);
  }

  @Test
  public void transformGeometryCrsTransform() throws Exception {
    Geometry geometry = getLineString();
    CrsTransform transform = geoService.getCrsTransform(LONLAT, LAMBERT72);
    geometry = geoService.transform(geometry, transform);
    assertTransformedLineString(geometry);
  }
View Full Code Here

    assertTransformedLineString(geometry);
  }

  @Test
  public void transformGeometryJtsCrs() throws Exception {
    Geometry geometry = getLineString();
    CoordinateReferenceSystem source = CRS.decode(LONLAT);
    CoordinateReferenceSystem target = CRS.decode(LAMBERT72);

    Assert.assertEquals(geometry, geoService.transform(geometry, source, source));
View Full Code Here

  public void transformGeometryEmptyResultOnException() throws Exception {
    GeometryFactory geometryFactory = new GeometryFactory();
    WKTReader reader = new WKTReader( geometryFactory );
   
    Point point = (Point) reader.read("POINT (1 1)");
    Geometry geometry = geoService.transform(point, new ThrowingTransform());
    Assert.assertEquals(Point.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());
   
    LineString lineString = (LineString) reader.read("LINESTRING (0 1,1 1)");
    geometry = geoService.transform(lineString, new ThrowingTransform());
    Assert.assertEquals(LineString.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());
   
    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))");
    geometry = geoService.transform(multilineString, new ThrowingTransform());
    Assert.assertEquals(MultiLineString.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());
   
    MultiPolygon multipolygon = (MultiPolygon) reader.read("MULTIPOLYGON (((0 0,1 1,0 1,0 0)),((0 0,2 2,0 2,0 0)))");
    geometry = geoService.transform(multipolygon, new ThrowingTransform());
    Assert.assertEquals(MultiPolygon.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());
   
    Geometry collection = (GeometryCollection) reader.read("GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10)) ");
    geometry = geoService.transform(collection, new ThrowingTransform());
    Assert.assertEquals(GeometryCollection.class, geometry.getClass());
    Assert.assertTrue(geometry.isEmpty());
  }
View Full Code Here

    Assert.assertTrue(geometry.isEmpty());
  }

  @Test
  public void transformGeometryCrsNoTransform() throws Exception {
    Geometry geometry = getLineString();
    CrsTransform transform = geoService.getCrsTransform(LONLAT, LONLAT);
    geometry = geoService.transform(geometry, transform);
    Coordinate[] coordinates = geometry.getCoordinates();
    Assert.assertEquals(4, coordinates.length);
    Assert.assertEquals(5, coordinates[0].x, DELTA);
    Assert.assertEquals(4, coordinates[0].y, DELTA);
    Assert.assertEquals(30, coordinates[1].x, DELTA);
    Assert.assertEquals(10, coordinates[1].y, DELTA);
View Full Code Here

TOP

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

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.