Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryFactory


      if (null == layer) {
        return null;
      }
      String area = layer.getUpdateAuthorizedArea();
      try {
        WKTReader wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 0));
        return wktReader.read(area);
      } catch (ParseException pe) {
        throw new IllegalStateException("Could not parse geometry " + area, pe);
      }
    }
View Full Code Here


      if (null == layer) {
        return null;
      }
      String area = layer.getCreateAuthorizedArea();
      try {
        WKTReader wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 0));
        return wktReader.read(area);
      } catch (ParseException pe) {
        throw new IllegalStateException("Could not parse geometry " + area, pe);
      }
    }
View Full Code Here

      if (null == layer) {
        return null;
      }
      String area = layer.getDeleteAuthorizedArea();
      try {
        WKTReader wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 0));
        return wktReader.read(area);
      } catch (ParseException pe) {
        throw new IllegalStateException("Could not parse geometry " + area, pe);
      }
    }
View Full Code Here

    Filter filter;
    List<InternalFeature> oldFeatures;
    List<InternalFeature> newFeatures;
    InternalFeature feature;
    CoordinateReferenceSystem crs = beanLayer.getCrs();
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel());
    Geometry geometry;

    login("marino");
    oldFeatures = new ArrayList<InternalFeature>();
    newFeatures = new ArrayList<InternalFeature>();
    feature = converterService.toInternal(new Feature());
    feature.setId("4");
    feature.setLayer(beanLayer);
    // feature needs a geometry or exceptions all over
    geometry = geometryFactory.createPoint(new Coordinate(1.5, 1.5));
    feature.setGeometry(geometry);   
    newFeatures.add(feature);
    try {
      layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);
      Assert.fail("create should have failed");
    } catch (GeomajasSecurityException gse) {
      Assert.assertEquals(ExceptionCode.FEATURE_CREATE_PROHIBITED, gse.getExceptionCode());
    }
    filter = filterService.createFidFilter(new String[]{"4"});
    oldFeatures = layerService.getFeatures(LAYER_ID,
        crs, filter, null, VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES);
    Assert.assertEquals(0, oldFeatures.size());

    login("luc");
    oldFeatures = new ArrayList<InternalFeature>();
    newFeatures = new ArrayList<InternalFeature>();
    feature = converterService.toInternal(new Feature());
    feature.setId("4");
    feature.setLayer(beanLayer);
    // feature needs a geometry or exceptions all over
    geometry = geometryFactory.createPoint(new Coordinate(1.5, 1.5));
    feature.setGeometry(geometry);
    newFeatures.add(feature);
    layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);
    filter = filterService.createFidFilter(new String[]{"4"});
    oldFeatures = layerService.getFeatures(LAYER_ID,
View Full Code Here

    Filter filter;
    List<InternalFeature> oldFeatures;
    List<InternalFeature> newFeatures;
    InternalFeature feature;
    CoordinateReferenceSystem crs = beanLayer.getCrs();
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel());
    Geometry geometry;

    login("marino");
    // verify failing
    oldFeatures = new ArrayList<InternalFeature>();
    newFeatures = new ArrayList<InternalFeature>();
    feature = converterService.toInternal(new Feature());
    feature.setId("4");
    feature.setLayer(beanLayer);
    // feature needs a geometry or exceptions all over
    geometry = geometryFactory.createPoint(new Coordinate(5.5, 5.5));
    feature.setGeometry(geometry);
    newFeatures.add(feature);
    try {
      layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);
      Assert.fail("create area not checked");
    } catch (GeomajasSecurityException gse) {
      Assert.assertEquals(ExceptionCode.FEATURE_CREATE_PROHIBITED, gse.getExceptionCode());
    }
    filter = filterService.createFidFilter(new String[]{"4"});
    oldFeatures = layerService.getFeatures(LAYER_ID,
        crs, filter, null, VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES);
    Assert.assertEquals(0, oldFeatures.size());
    // verify success
    oldFeatures = new ArrayList<InternalFeature>();
    newFeatures = new ArrayList<InternalFeature>();
    feature = converterService.toInternal(new Feature());
    feature.setId("4");
    feature.setLayer(beanLayer);
    // feature needs a geometry or exceptions all over
    geometry = geometryFactory.createPoint(new Coordinate(1.5, 1.5));
    feature.setGeometry(geometry);
    newFeatures.add(feature);
    layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);
    filter = filterService.createFidFilter(new String[]{"4"});
    oldFeatures = layerService.getFeatures(LAYER_ID,
View Full Code Here

  private WKTReader wktReader;

  @Before
  public void setUpTestDataWithinTransaction() throws LayerException, ParseException {
    wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(), 4326));
    featureModel = layer.getFeatureModel();
    feature1 = NestedFeature.getDefaultInstance1();
    feature1.setGeometry(wktReader.read("POINT(10 20)"));
    layer.create(feature1);
  }
View Full Code Here

    if (precision == -1) {
      model = new PrecisionModel(PrecisionModel.FLOATING);
    } else {
      model = new PrecisionModel(Math.pow(10, precision));
    }
    GeometryFactory factory = new GeometryFactory(model, srid);
    com.vividsolutions.jts.geom.Geometry jts;

    String geometryType = geometry.getGeometryType();
    if (Geometry.POINT.equals(geometryType)) {
      jts = factory.createPoint(convertCoordinates(geometry)[0]);
    } else if (Geometry.LINEAR_RING.equals(geometryType)) {
      jts = factory.createLinearRing(convertCoordinates(geometry));
    } else if (Geometry.LINE_STRING.equals(geometryType)) {
      jts = factory.createLineString(convertCoordinates(geometry));
    } else if (Geometry.POLYGON.equals(geometryType)) {
      LinearRing exteriorRing = (LinearRing) toInternal(geometry.getGeometries()[0]);
      LinearRing[] interiorRings = new LinearRing[geometry.getGeometries().length - 1];
      for (int i = 0; i < interiorRings.length; i++) {
        interiorRings[i] = (LinearRing) toInternal(geometry.getGeometries()[i + 1]);
      }
      jts = factory.createPolygon(exteriorRing, interiorRings);
    } else if (Geometry.MULTI_POINT.equals(geometryType)) {
      Point[] points = new Point[geometry.getGeometries().length];
      jts = factory.createMultiPoint((Point[]) convertGeometries(geometry, points));
    } else if (Geometry.MULTI_LINE_STRING.equals(geometryType)) {
      LineString[] lineStrings = new LineString[geometry.getGeometries().length];
      jts = factory.createMultiLineString((LineString[]) convertGeometries(geometry, lineStrings));
    } else if (Geometry.MULTI_POLYGON.equals(geometryType)) {
      Polygon[] polygons = new Polygon[geometry.getGeometries().length];
      jts = factory.createMultiPolygon((Polygon[]) convertGeometries(geometry, polygons));
    } else {
      throw new GeomajasException(ExceptionCode.CANNOT_CONVERT_GEOMETRY, geometryType);
    }

    return jts;
View Full Code Here

    List<InternalFeature> newFeatures = new ArrayList<InternalFeature>();
    InternalFeature feature = converterService.toInternal(new Feature());
    feature.setId("4");
    feature.setLayer(beanLayer);
    // feature needs a geometry or exceptions all over
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel());
    Geometry geometry = geometryFactory.createPoint(new Coordinate(1.5, 1.5));
    feature.setGeometry(geometry);
    newFeatures.add(feature);
    layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);

    Iterator<FeatureBean> iterator =
View Full Code Here

    Assert.assertEquals(3, bounds.getMaxY(), ALLOWANCE);
  }
 
  @Test
  public void testGetBoundsIntersectsFiltered() throws Exception {
    GeometryFactory factory = new GeometryFactory();
    LineString equator = factory.createLineString(new Coordinate[] { new Coordinate(0, 0),
        new Coordinate(-180, 180) });
    Filter filter = filterService.createIntersectsFilter(equator,beanLayer.getLayerInfo().getFeatureInfo().getGeometryType().getName());
    Envelope bounds = layerService.getBounds(LAYER_ID,
        geoService.getCrs2(beanLayer.getLayerInfo().getCrs()), filter);
    Assert.assertEquals(0, bounds.getMinX(), ALLOWANCE);
View Full Code Here

    String key3 = "key3";
    String key4 = "key4";
    PipelineContext pipelineContext = new PipelineContextImpl();
    pipelineContext.put(key1, key1);
    pipelineContext.put(key3, key3);
    GeometryFactory geometryFactory = new GeometryFactory();
    pipelineContext.put(key4, new GeometryCollection(new Geometry[] {}, geometryFactory));

    // a context
    CacheContext cacheContext1 = cacheKeyService.getCacheContext(pipelineContext, new String[] {key1, key2, key4});
    Assert.assertEquals(key1, cacheContext1.get(key1));
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.