예제 #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);
    }
  }
예제 #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();
 }
예제 #3
0
 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;
 }
예제 #4
0
  @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);
    }
  }
예제 #5
0
 public void testSpatialObjectfailedCommit() throws Exception {
   SpatialDataSourceDecorator ds = new SpatialDataSourceDecorator(dsf.getDataSource("object"));
   ds.open();
   failedCommit(ds, new DefaultSpatialIndexQuery(ds.getFullExtent(), SPATIAL_FIELD_NAME));
 }
예제 #6
0
 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));
 }