Exemple #1
0
  public ObjectDriver evaluate(
      DataSourceFactory dsf, DataSource[] tables, Value[] values, IProgressMonitor pm)
      throws ExecutionException {
    WorkbenchContext wbContext = Services.getService(WorkbenchContext.class);
    final GeomarkPanel geomarkPanel =
        (GeomarkPanel) wbContext.getWorkbench().getFrame().getView("Geomark");
    final String prefix = ((0 == values.length) ? tables[0].getName() : values[0]) + "-";

    try {
      final SpatialDataSourceDecorator sds = new SpatialDataSourceDecorator(tables[0]);
      sds.open();
      final int rowCount = (int) sds.getRowCount();
      for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {

        if (rowIndex / 100 == rowIndex / 100.0) {
          if (pm.isCancelled()) {
            break;
          } else {
            pm.progressTo((int) (100 * rowIndex / rowCount));
          }
        }

        final Envelope envelope = sds.getGeometry(rowIndex).getEnvelopeInternal();
        geomarkPanel.add(prefix + rowIndex, envelope);
      }
      sds.close();
      return null;
    } catch (DriverException e) {
      throw new ExecutionException(e);
    }
  }
Exemple #2
0
 public void testProducedRasterEnvelope() throws Exception {
   DataSource ds = dsf.getDataSource("raster");
   ds.open();
   SpatialDataSourceDecorator sds = new SpatialDataSourceDecorator(ds);
   Envelope env = sds.getFullExtent();
   assertTrue(env.getWidth() > 0);
   assertTrue(env.getHeight() > 0);
   ds.close();
 }
 public boolean accepts(MapContext mc, ILayer layer) {
   try {
     if (layer.isRaster()) {
       SpatialDataSourceDecorator ds = layer.getDataSource();
       if (ds.getRaster(0).getType() != ImagePlus.COLOR_RGB) {
         return true;
       }
     }
   } catch (IOException e) {
   } catch (DriverException e) {
   }
   return false;
 }
  @Override
  protected void polygonDone(com.vividsolutions.jts.geom.Polygon pol, MapContext mc, ToolManager tm)
      throws TransitionException {
    Geometry g = pol;
    if (ToolUtilities.geometryTypeIs(mc, GeometryConstraint.MULTI_POLYGON)) {
      g = ToolManager.toolsGeometryFactory.createMultiPolygon(new Polygon[] {pol});
    }

    SpatialDataSourceDecorator sds = mc.getActiveLayer().getDataSource();
    try {
      Value[] row = new Value[sds.getMetadata().getFieldCount()];
      row[sds.getSpatialFieldIndex()] = ValueFactory.createValue(g);
      row = ToolUtilities.populateNotNullFields(sds, row);
      sds.insertFilledRow(row);
    } catch (DriverException e) {
      throw new TransitionException("Cannot insert polygon", e);
    }
  }
 public void testSpatialObjectfailedCommit() throws Exception {
   SpatialDataSourceDecorator ds = new SpatialDataSourceDecorator(dsf.getDataSource("object"));
   ds.open();
   failedCommit(ds, new DefaultSpatialIndexQuery(ds.getFullExtent(), SPATIAL_FIELD_NAME));
 }
 public void testSpatialDBfailedOnWrite() throws Exception {
   SpatialDataSourceDecorator ds = new SpatialDataSourceDecorator(dsf.getDataSource("executeDB"));
   ds.open();
   ReadDriver.setCurrentDataSource(ds);
   failedCommit(ds, new DefaultSpatialIndexQuery(ds.getFullExtent(), SPATIAL_FIELD_NAME));
 }