Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryFactory


  public void testOtherContextImpl() {
    CacheContext context = new MyCacheContext();
    String cacheKey1 = cacheKeyService.getCacheKey(context);
    context.put("bla", "bla");
    String cacheKey2 = cacheKeyService.getCacheKey(context);
    GeometryFactory geometryFactory = new GeometryFactory();
    context.put("geom", new GeometryCollection(new Geometry[] {}, geometryFactory));
    String cacheKey3 = cacheKeyService.getCacheKey(context);
    System.out.println("keys " + cacheKey1 + " " + cacheKey2 + " " + cacheKey3);
    Assert.assertFalse(cacheKey1.equals(cacheKey2));
    Assert.assertFalse(cacheKey2.equals(cacheKey3));
View Full Code Here


  @Qualifier("beans")
  private VectorLayer layer;

  @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");
    layer.saveOrUpdate(cb);
View Full Code Here

    layer.saveOrUpdate(cb);
  }

  @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

  }

  @Test
  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

    if (null == biggestGeometry) {
      // build Geometry which covers biggest possible area
      Envelope maxBounds = new Envelope(-Double.MAX_VALUE, Double.MAX_VALUE,
          -Double.MAX_VALUE, Double.MAX_VALUE);
      PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
      GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
      biggestGeometry = geometryFactory.toGeometry(maxBounds);
    }
    return biggestGeometry;
  }
View Full Code Here

      for (CrsTransformInfo crsTransformInfo : crsTransformDefinitions.values()) {
        String key = getTransformKey(crsTransformInfo);
        transformCache.put(key, getCrsTransform(key, crsTransformInfo));
      }
    }
    GeometryFactory factory = new GeometryFactory();
    EMPTY_GEOMETRIES.put(Point.class, factory.createPoint((Coordinate) null));
    EMPTY_GEOMETRIES.put(LineString.class, factory.createLineString((Coordinate[]) null));
    EMPTY_GEOMETRIES.put(Polygon.class, factory.createPolygon(null, null));
    EMPTY_GEOMETRIES.put(MultiPoint.class, factory.createMultiPoint((Coordinate[]) null));
    EMPTY_GEOMETRIES.put(MultiLineString.class, factory.createMultiLineString((LineString[]) null)); // cast needed!
    EMPTY_GEOMETRIES.put(MultiPolygon.class, factory.createMultiPolygon((Polygon[]) null)); // cast needed!
    EMPTY_GEOMETRIES.put(Geometry.class, factory.createGeometryCollection(null));
  }
View Full Code Here

    // base is the max bounds of the layer
    Envelope maxBounds = converterService.toInternal(layerInfo.getMaxExtent());
    PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
    int srid = geoService.getSridFromCrs(layer.getLayerInfo().getCrs());
    GeometryFactory geometryFactory = new GeometryFactory(precisionModel, srid);
    Geometry geometry = geometryFactory.toGeometry(maxBounds);

    // limit based on authorizations
    for (Authentication authentication : authentications) {
      for (BaseAuthorization authorization : authentication.getAuthorizations()) {
        if (authorization instanceof AreaAuthorization) {
View Full Code Here

    securityContext.setAuthentications("token", authentications);
    Assert.assertTrue(securityContext.isLayerVisible(LAYER_ID));
    Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
    Assert.assertNotNull(geometry);
    PrecisionModel precisionModel  = new PrecisionModel(PrecisionModel.FLOATING);
    GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
    Coordinate coordinate = new Coordinate();

    coordinate.x = coordinate.y = -86;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = -85.05;
    coordinate.y = -85.05;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = -85.05;
    coordinate.y = 85.05;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = 85.05;
    coordinate.y = -85.05;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = 85.05;
    coordinate.y = 85.05;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 86;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));

    Assert.assertFalse(securityContext.isPartlyVisibleSufficient(LAYER_ID));
  }
View Full Code Here

    securityContext.setAuthentications("token", authentications);

    Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
    Assert.assertNotNull(geometry);
    PrecisionModel precisionModel  = new PrecisionModel(PrecisionModel.FLOATING);
    GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
    Coordinate coordinate = new Coordinate();
    coordinate.x = coordinate.y = 0.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 1.5;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 2.5;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 3.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 4.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));

    Assert.assertFalse(securityContext.isPartlyVisibleSufficient(LAYER_ID));
  }
View Full Code Here

    securityContext.setAuthentications("token", authentications);

    Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
    Assert.assertNotNull(geometry);
    PrecisionModel precisionModel  = new PrecisionModel(PrecisionModel.FLOATING);
    GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
    Coordinate coordinate = new Coordinate();
    coordinate.x = coordinate.y = 0.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 1.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 2.5;
    Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 3.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
    coordinate.x = coordinate.y = 4.5;
    Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));

    Assert.assertFalse(securityContext.isPartlyVisibleSufficient(LAYER_ID));
  }
View Full Code Here

TOP

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

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.