Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Point


  }

  @Test
  public void create() throws Exception {
    WKTReader wktReader = new WKTReader();
    Point geometry = (Point) wktReader.read("POINT (0 0)");

    SimpleFeatureBuilder build = new SimpleFeatureBuilder(layer.getSchema());
    SimpleFeature feature = build.buildFeature("100000", new Object[] { geometry, "Tsjakamaka", 342 });

    Object created = layer.create(feature);
View Full Code Here


  }

  @Test
  public void testSetGeometry() throws Exception {
    WKTReader wktReader = new WKTReader();
    Point pt = (Point) wktReader.read("POINT (5 5)");
    featureModel.setGeometry(feature, pt);
    Assert.assertEquals(5, featureModel.getGeometry(feature).getCoordinate().x, 0);
  }
View Full Code Here

  @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));
View Full Code Here

  @Test
  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)");
View Full Code Here

  public void testPoint() throws MarshallException {
    GeometrySerializer ser = new GeometrySerializer();
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(100.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] {new Coordinate(
        12.3456, 34567.3456)});
    Point p = new Point(coords, factory);
    JSONObject jo = (JSONObject) ser.marshall(null, p);
    assertEquals("Point", jo.get("type").toString());
    assertEquals("31300", jo.get("srid").toString());
    assertEquals("2", jo.get("precision").toString());
    assertEquals("[12.35,34567.35]", jo.get("coordinates").toString());
View Full Code Here

    Assert.assertNull(geometry);
  }

  @Test
  public void setGeometry() throws LayerException {
    Point point = geometryFactory.createPoint(new Coordinate(1, 2));
    featureModel.setGeometry(feature1, point);

    Geometry geometry = featureModel.getGeometry(feature1);
    Assert.assertNotNull(geometry);
    Assert.assertTrue(geometry instanceof Point);
View Full Code Here

        }
        return polygon;
      } else if (symbolizer instanceof PointSymbolizer) {
        if (point == null) {
          Coordinate coord = new Coordinate(w / 2, h / 2);
          Point p = geometryFactory.createPoint(coord);
          point = new LiteShape2(p, null, null, false);
        }
        return point;
      } else {
        return null;
View Full Code Here

    } else if (g instanceof LineString) {
      LineString line = (LineString) g;
      drawPathContent(line.getCoordinates());
      template.stroke();
    } else if (g instanceof Point) {
      Point point = (Point) g;
      drawPoint(point.getCoordinate(), symbol);
      template.fillStroke();
    }
  }
View Full Code Here

      } else {
        labelPoint = geometry.getCentroid().getCoordinate();
      }
    }
    if (null == labelPoint && null != geometry) {
      Point centroid = geometry.getCentroid();
      if (null != centroid) {
        labelPoint = centroid.getCoordinate();
      }
    }
    if (null != labelPoint && (Double.isNaN(labelPoint.x) || Double.isNaN(labelPoint.y))) {
      labelPoint = new Coordinate(geometry.getCoordinate());
    }
View Full Code Here

  public void testPoint() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] { new Coordinate(12.3456,
        34567.3456) });
    Point p = new Point(coords, factory);
    JSONObject jtsJson = (JSONObject) jtsSerializer.marshall(null, p);
    Geometry dto = converter.toDto(p);
    JSONObject dtoJson = (JSONObject) dtoSerializer.marshall(null, dto);
    Assert.assertEquals(jtsJson.toString(), dtoJson.toString());
  }
View Full Code Here

TOP

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

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.