private EXGeographicBoundingBox getGeographicBoundingBox(Envelope env, String epsgCode) {
   Envelope newEnvelope;
   if ("EPSG:4326".equals(epsgCode)) {
     newEnvelope = env;
   } else {
     try {
       GeometryFactory gf = new GeometryFactory();
       Polygon poly = (Polygon) gf.toGeometry(env);
       ST_Transform transformFunction = new ST_Transform();
       CoordinateReferenceSystem inputCRS = DataSourceFactory.getCRSFactory().getCRS(epsgCode);
       Value val =
           transformFunction.evaluate(
               null,
               ValueFactory.createValue(poly, inputCRS),
               ValueFactory.createValue("EPSG:4326"));
       newEnvelope = val.getAsGeometry().getEnvelopeInternal();
     } catch (FunctionException fe) {
       return getDummyGeographic();
     } catch (CRSException ex) {
       return getDummyGeographic();
     }
   }
   EXGeographicBoundingBox ret = new EXGeographicBoundingBox();
   ret.setEastBoundLongitude(newEnvelope.getMaxX());
   ret.setWestBoundLongitude(newEnvelope.getMinX());
   ret.setNorthBoundLatitude(newEnvelope.getMaxY());
   ret.setSouthBoundLatitude(newEnvelope.getMinY());
   return ret;
 }
Esempio n. 2
0
 private void setFieldValueInIndex(int rowIndex, int fieldId, Value oldValue, Value value)
     throws DriverException {
   if (indexEditionManager != null) {
     try {
       for (DataSourceIndex index : indexEditionManager.getDataSourceIndexes()) {
         String[] idxFields = index.getFieldNames();
         if (idxFields.length == 1) {
           if (idxFields[0].equals(getMetadata().getFieldName(fieldId))) {
             index.setFieldValue(oldValue, value, rowIndex);
           }
         } else {
           Value[] oldSet = new Value[idxFields.length];
           Value[] newSet = new Value[idxFields.length];
           String fieldName = getFieldName(fieldId);
           for (int i = 0; i < idxFields.length; i++) {
             if (idxFields[i].equals(fieldName)) {
               oldSet[i] = oldValue;
               newSet[i] = value;
             } else {
               oldSet[i] = getFieldValue(rowIndex, getFieldIndexByName(idxFields[i]));
               newSet[i] = oldSet[i];
             }
           }
           index.setFieldValue(
               ValueFactory.createValue(oldSet), ValueFactory.createValue(newSet), rowIndex);
         }
       }
     } catch (IndexException e) {
       throw new DriverException(e);
     }
   }
 }
 private void failedCommit(DataSource ds, IndexQuery query)
     throws DriverException, NonEditableDataSourceException {
   ds.deleteRow(2);
   ds.setFieldValue(0, 1, ValueFactory.createValue("nouveau"));
   Value[] row = ds.getRow(0);
   row[1] = ValueFactory.createValue("aaaaa");
   ds.insertFilledRow(row);
   Value[][] table = super.getDataSourceContents(ds);
   Iterator<Integer> it = ds.queryIndex(query);
   try {
     ReadDriver.failOnWrite = true;
     ds.commit();
     ds.close();
   } catch (DriverException e) {
     assertTrue(equals(table, super.getDataSourceContents(ds)));
     if (it != null) {
       assertTrue(ds.queryIndex(query) != null);
     } else {
       assertTrue(ds.queryIndex(query) == null);
     }
     ReadDriver.failOnWrite = false;
     ds.commit();
     ds.close();
   }
   ds.open();
   assertTrue(equals(table, super.getDataSourceContents(ds)));
   ds.close();
 }
Esempio n. 4
0
 @Override
 public Value evaluate(DataSourceFactory dsf, Value... args) throws FunctionException {
   if (args[0].isNull()) {
     return ValueFactory.createNullValue();
   } else {
     return ValueFactory.createValue(Math.atan(args[0].getAsDouble()));
   }
 }
Esempio n. 5
0
 @Override
 public Value evaluate(DataSourceFactory dsf, Value[] args) throws FunctionException {
   if (args[0].isNull()) {
     return ValueFactory.createNullValue();
   } else {
     final Geometry geom = args[0].getAsGeometry();
     return ValueFactory.createValue(GeometryConvert.toMultiPoint(geom));
   }
 }
Esempio n. 6
0
  @Override
  public Value evaluateResult(DataSourceFactory dsf, Value[] args) throws FunctionException {
    Geometry value = args[0].getAsGeometry();
    if (value instanceof Point) {
      final Point geometry = (Point) args[0].getAsGeometry();
      double y = geometry.getCoordinate().y;
      return ValueFactory.createValue(y);

    } else {
      return ValueFactory.createNullValue();
    }
  }
Esempio n. 7
0
  @Override
  public Value evaluate(DataSourceFactory dsf, Value[] args) throws FunctionException {

    Geometry g = args[0].getAsGeometry();

    if (g instanceof Polygon) {
      Polygon polygon = (Polygon) g;
      LineString ring = polygon.getInteriorRingN(args[1].getAsInt());
      if (ring != null) {
        return ValueFactory.createValue(ring);
      }
    }
    return ValueFactory.createNullValue();
  }
 /**
  * @param value String representation of the field
  * @return The corresponding value or null value if constraints are not respected.
  * @throws ParseException Unable to parse provided string
  * @throws DriverException The driver throw this exception
  */
 public Value getValue(Object value) throws ParseException, DriverException {
   Type fieldType = ds.getMetadata().getFieldType(fieldIndex);
   Value inputValue;
   if (value != null && (fieldType.getTypeCode() == Type.STRING || !value.toString().isEmpty())) {
     inputValue = ValueFactory.createValueByType(value.toString(), fieldType.getTypeCode());
   } else {
     inputValue = ValueFactory.createNullValue();
   }
   String error = ds.check(fieldIndex, inputValue);
   if (error == null || error.isEmpty()) {
     return inputValue;
   } else {
     throw new ParseException(error, 0);
   }
 }
Esempio n. 9
0
 private void insertInIndex(Value[] values, int rowIndex) throws DriverException {
   if (indexEditionManager != null) {
     try {
       for (DataSourceIndex index : indexEditionManager.getDataSourceIndexes()) {
         Metadata metadata = getMetadata();
         String[] idxFields = index.getFieldNames();
         if (idxFields.length == 1) {
           for (int i = 0; i < metadata.getFieldCount(); i++) {
             if (metadata.getFieldName(i).equals(idxFields[0])) {
               index.insertRow(values[i], rowIndex);
             }
           }
         } else {
           Value[] toInsert = new Value[idxFields.length];
           for (int i = 0; i < metadata.getFieldCount(); i++) {
             for (int j = 0; j < idxFields.length; j++) {
               if (metadata.getFieldName(i).equals(idxFields[j])) {
                 toInsert[j] = values[i];
               }
             }
             index.insertRow(ValueFactory.createValue(values), rowIndex);
           }
         }
       }
     } catch (IndexException e) {
       throw new DriverException("Cannot update index", e);
     }
   }
 }
Esempio n. 10
0
 private void deleteInIndex(int rowIndex) throws DriverException {
   if (indexEditionManager != null) {
     try {
       for (DataSourceIndex index : indexEditionManager.getDataSourceIndexes()) {
         Metadata metadata = getMetadata();
         String[] idxFields = index.getFieldNames();
         if (idxFields.length == 1) {
           for (int i = 0; i < metadata.getFieldCount(); i++) {
             if (metadata.getFieldName(i).equals(idxFields[0])) {
               Value v = getFieldValue(rowIndex, i);
               index.deleteRow(v, rowIndex);
             }
           }
         } else {
           Value[] toInsert = new Value[idxFields.length];
           for (int i = 0; i < metadata.getFieldCount(); i++) {
             for (int j = 0; j < idxFields.length; j++) {
               if (metadata.getFieldName(i).equals(idxFields[j])) {
                 toInsert[j] = getFieldValue(rowIndex, i);
               }
             }
             index.deleteRow(ValueFactory.createValue(toInsert), rowIndex);
           }
         }
       }
     } catch (IndexException e) {
       throw new DriverException(e);
     }
   }
 }
Esempio n. 11
0
  private Value[] getEmptyRow() throws DriverException {
    Value[] row = new Value[getFieldCount()];

    for (int i = 0; i < row.length; i++) {
      row[i] = ValueFactory.createNullValue();
    }

    return row;
  }
Esempio n. 12
0
  @Override
  public void insertFilledRow(Value[] values) throws DriverException {
    for (int i = 0; i < values.length; i++) {
      if (values[i] == null) {
        values[i] = ValueFactory.createNullValue();
      }
    }

    insertFilledRowAt(getRowCount(), values);
  }
Esempio n. 13
0
  /**
   * Gets the values of the original row
   *
   * @param dir address of the row to be retrieved
   * @return Row values
   * @throws DriverException if the operation fails
   */
  private Value[] getOriginalRow(PhysicalRowAddress dir) throws DriverException {
    ArrayList<Value> ret = new ArrayList<Value>();

    for (int i = 0; i < getFields().size(); i++) {
      int originalIndex = getFields().get(i).getOriginalIndex();
      if (originalIndex == -1) {
        ret.add(ValueFactory.createNullValue());
      } else {
        ret.add(dir.getFieldValue(originalIndex));
      }
    }

    return ret.toArray(new Value[ret.size()]);
  }
Esempio n. 14
0
  public void setUp() throws Exception {
    byte[] rasterData = new byte[4];
    RasterMetadata rasterMetadata = new RasterMetadata(0, 0, 1, 1, 2, 2);
    GeoRaster gr = GeoRasterFactory.createGeoRaster(rasterData, rasterMetadata);

    dsf = new DataSourceFactory();
    dsf.setTempDir("src/test/resources/backup");
    DefaultMetadata metadata =
        new DefaultMetadata(
            new Type[] {TypeFactory.createType(Type.RASTER)}, new String[] {"raster"});
    ObjectMemoryDriver omd = new ObjectMemoryDriver(metadata);
    omd.addValues(new Value[] {ValueFactory.createValue(gr)});
    dsf.getSourceManager().register("raster", omd);
  }
Esempio n. 15
0
  protected Value testSpatialFunction(
      ScalarFunction function, int[] valueType, int parameterCount, Value... normalValue)
      throws Exception {
    // Test null input
    ColumnValue[] vals = new ColumnValue[parameterCount];
    for (int i = 0; i < parameterCount; i++) {
      vals[i] = new ColumnValue(valueType[i], ValueFactory.createNullValue());
    }
    Value res = evaluate(function, vals);
    assertTrue(res.isNull());

    // Test too many parameters
    Value[] args = new Value[parameterCount + 1];
    for (int i = 0; i < args.length; i++) {
      args[i] = normalValue[0];
    }
    try {
      res = evaluate(function, args);
      fail();
    } catch (IncompatibleTypesException e) {
    }

    // Test wrong parameter type
    try {
      args = new Value[parameterCount];
      for (int i = 0; i < args.length; i++) {
        args[i] = ValueFactory.createValue(new Value[0]);
      }
      res = evaluate(function, args);
      fail();
    } catch (IncompatibleTypesException e) {
    }

    // Test normal input value and type
    res = evaluate(function, normalValue);
    return res;
  }
Esempio n. 16
0
  ModifyCommand.ModifyInfo doSetFieldValue(long row, int fieldId, Value value)
      throws DriverException {
    // convert value
    Value val = value;
    if (val == null) {
      val = ValueFactory.createNullValue();
    }

    // write check
    checkConstraints(val, fieldId);

    // Do modification
    ModifyCommand.ModifyInfo ret;
    PhysicalRowAddress dir = rowsAddresses.get((int) row);
    dirty = true;
    setFieldValueInIndex((int) row, fieldId, getFieldValue(row, fieldId), val);
    if (dir instanceof OriginalRowAddress) {
      Value[] original = getOriginalRow(dir);
      Value previousValue = original[fieldId];
      original[fieldId] = val;
      PhysicalRowAddress newAddress = internalBuffer.insertRow(dir.getPK(), original);
      rowsAddresses.set((int) row, newAddress);
      UpdateEditionInfo info = new UpdateEditionInfo(dir.getPK(), rowsAddresses.get((int) row));
      EditionInfo ei = editionActions.set((int) row, info);
      ret =
          new ModifyCommand.ModifyInfo(
              (OriginalRowAddress) dir,
              ei,
              (InternalBufferRowAddress) newAddress,
              previousValue,
              row,
              fieldId);
    } else {
      Value previousValue = dir.getFieldValue(fieldId);
      ((InternalBufferRowAddress) dir).setFieldValue(fieldId, val);
      /*
       * We don't modify the EditionInfo because is an insertion that
       * already points to the internal buffer
       */
      ret =
          new ModifyCommand.ModifyInfo(
              null, null, (InternalBufferRowAddress) dir, previousValue, row, fieldId);
    }
    cachedScope = null;

    editionListenerSupport.callSetFieldValue(row, fieldId, undoRedo);

    return ret;
  }
Esempio n. 17
0
 @Test
 public void testEditionWithFieldAdded() throws Exception {
   sm.register("toto", getTempCopyOf(super.getAnyNonSpatialResource()));
   DataSource d = dsf.getDataSource("toto", DataSourceFactory.EDITABLE);
   d.open();
   d.addField("extra", TypeFactory.createType(Type.STRING));
   int fi = d.getFieldIndexByName("extra");
   new UndoRedoTest().testAlphanumericEditionUndoRedo(d);
   Value newValue = ValueFactory.createValue("hi");
   d.setFieldValue(0, fi, newValue);
   d.undo();
   d.redo();
   d.commit();
   d.close();
   d.open();
   assertTrue(equals(d.getFieldValue(0, d.getFieldIndexByName("extra")), newValue));
   d.close();
 }
Esempio n. 18
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);
    }
  }
Esempio n. 19
0
 @Override
 public Value getFieldValue(long rowIndex, int fieldId) throws DriverException {
   if (isModified()) {
     PhysicalRowAddress physicalAddress = rowsAddresses.get((int) rowIndex);
     if (physicalAddress instanceof OriginalRowAddress) {
       int originalIndex = getFields().get(fieldId).getOriginalIndex();
       if (originalIndex == -1) {
         return ValueFactory.createNullValue();
       } else {
         return physicalAddress.getFieldValue(originalIndex);
       }
     } else {
       return physicalAddress.getFieldValue(fieldId);
     }
   } else {
     return getDataSource().getFieldValue(rowIndex, fieldId);
   }
 }
Esempio n. 20
0
 @Override
 public String getFromLower(Double d) {
   if (d == null) {
     throw new NullPointerException("The input threshold must not be null");
   }
   if (parameter instanceof StringLiteral) {
     return ((StringLiteral) parameter).getValue(null);
   } else {
     String col = get(d);
     if (col == null) {
       Categorize2String c2s = (Categorize2String) parameter;
       Map<String, Value> inp = new HashMap<String, Value>();
       inp.put(getField(), ValueFactory.createValue(d));
       return c2s.getValue(inp);
     } else {
       return col;
     }
   }
 }
Esempio n. 21
0
  @Test
  public void testFieldInsertionEditionWhileEdition() throws Exception {
    sm.register("toto", getTempCopyOf(super.getAnyNonSpatialResource()));
    DataSource d = dsf.getDataSource("toto");
    d.open();
    String nouveau = "nouveau";
    Value newValue = ValueFactory.createValue(nouveau);
    Value testValue = d.getFieldValue(2, 1);
    int lastField = d.getMetadata().getFieldCount();
    d.deleteRow(0);
    d.setFieldValue(0, 1, d.getFieldValue(1, 1));
    d.addField(nouveau, TypeFactory.createType(Type.STRING));
    d.setFieldValue(0, lastField, newValue);
    assertTrue(equals(d.getFieldValue(0, lastField), newValue));
    d.commit();
    d.close();

    d.open();
    assertEquals(d.getMetadata().getFieldName(lastField).toLowerCase(), nouveau);
    assertTrue(equals(d.getFieldValue(0, lastField), newValue));
    assertTrue(equals(d.getFieldValue(0, 1), testValue));
    d.close();
  }
Esempio n. 22
0
 @Override
 public Value evaluateResult(DataSourceFactory dsf, Value[] args) throws FunctionException {
   final Geometry gv = args[0].getAsGeometry();
   return ValueFactory.createValue(gv.getArea());
 }
Esempio n. 23
0
  @Before
  public void setUp() throws Exception {
    super.setUpTestsWithoutEdition();
    wktReader = new WKTReader();
    JTSMultiPolygon2D = wktReader.read("MULTIPOLYGON (((0 0, 1 1, 0 1, 0 0)))");
    JTSMultiLineString2D = wktReader.read("MULTILINESTRING ((0 0, 1 1, 0 1, 0 0))");
    JTSMultiPoint2D = wktReader.read("MULTIPOINT (0 0, 1 1, 0 1, 0 0)");
    JTSPolygon2D =
        wktReader.read(
            "POLYGON ((181 124, 87 162, 76 256, 166 315, 286 325, 373 255, 387 213, 377 159, 351 121, 298 101, 234 56, 181 124), (165 244, 227 219, 234 300, 168 288, 165 244), (244 130, 305 135, 324 186, 306 210, 272 206, 206 174, 244 130))");

    JTSLineString2D = wktReader.read("LINESTRING (1 1, 2 1, 2 2, 1 2, 1 1)");
    JTSLineString3D = wktReader.read("LINESTRING (1 1 1, 2 1 2, 2 2 3, 1 2 4, 1 1 5)");
    JTSPoint3D = wktReader.read("POINT(0 10 20)");
    JTSPoint2D = wktReader.read("POINT(0 10)");

    JTSPolygonWith2Holes =
        wktReader.read(
            "POLYGON ((85 55, 85 306, 366 306, 366 55, 85 55), (153 205, 212 173, 241 190, 251 253, 235 278, 147 254, 153 205), (262 88, 321 97, 324 153, 303 177, 240 138, 262 88))");

    GeometryFactory gf = new GeometryFactory();
    JTSGeometryCollection =
        gf.createGeometryCollection(
            new Geometry[] {JTSMultiPolygon2D, JTSMultiLineString2D, JTSPolygon2D});
    JTS3DCollection =
        gf.createGeometryCollection(new Geometry[] {JTSMultiPolygon2D, JTSLineString3D});

    // first datasource
    final MemoryDataSetDriver driver1 =
        new MemoryDataSetDriver(
            new String[] {"pk", "geom"},
            new Type[] {
              TypeFactory.createType(Type.INT, new PrimaryKeyConstraint()),
              TypeFactory.createType(Type.GEOMETRY)
            });

    // insert all filled rows...
    driver1.addValues(
        new Value[] {ValueFactory.createValue(1), ValueFactory.createValue(JTSMultiPolygon2D)});
    driver1.addValues(
        new Value[] {ValueFactory.createValue(2), ValueFactory.createValue(JTSMultiLineString2D)});
    driver1.addValues(
        new Value[] {ValueFactory.createValue(3), ValueFactory.createValue(JTSLineString2D)});
    driver1.addValues(
        new Value[] {ValueFactory.createValue(4), ValueFactory.createValue(JTSPolygon2D)});
    // and register this new driver...

    dsf.getSourceManager().register("ds1", driver1);

    // second datasource
    final MemoryDataSetDriver driver2 =
        new MemoryDataSetDriver(
            new String[] {"pk", "geom"},
            new Type[] {
              TypeFactory.createType(Type.INT, new PrimaryKeyConstraint()),
              TypeFactory.createType(Type.GEOMETRY)
            });

    driver1.addValues(
        new Value[] {ValueFactory.createValue(1), ValueFactory.createValue(JTSMultiPolygon2D)});
    // and register this new driver...
    dsf.getSourceManager().register("ds2", driver2);
  }
Esempio n. 24
0
 protected Value testSpatialFunction(
     ScalarFunction function, Geometry normalValue, int parameterCount) throws Exception {
   return testSpatialFunction(
       function, new int[] {Type.GEOMETRY}, parameterCount, ValueFactory.createValue(normalValue));
 }
Esempio n. 25
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if ("modify".equals(e.getActionCommand())) {
      try {
        File globals = new File(configPath);

        // Table creation
        GdmsWriter globalsGW = new GdmsWriter(globals);
        String[] fieldNames1 = {
          "bufferSize",
          "amenitiesWeighting",
          "constructibilityWeighting",
          "idealhousingWeighting",
          "gaussDeviation",
          "segregationThreshold",
          "segregationTolerance",
          "householdMemory",
          "movingThreshold",
          "immigrantNumber",
          "numberOfTurns",
          "year",
          "threshold_1",
          "threshold_2",
          "threshold_3",
          "threshold_4"
        };

        org.gdms.data.types.Type integ = TypeFactory.createType(64);
        org.gdms.data.types.Type doubl = TypeFactory.createType(16);
        org.gdms.data.types.Type[] fieldTypes1 = {
          doubl, doubl, doubl, doubl, doubl, doubl, doubl, integ, doubl, integ, integ, integ, doubl,
          doubl, doubl, doubl
        };
        Metadata m1 = new DefaultMetadata(fieldTypes1, fieldNames1);
        globalsGW.writeMetadata(0, m1);

        // Table filling
        Map<String, JSpinner> sp = spp.getSpinners();
        Double hM = (Double) sp.get("householdMemory").getValue();
        Integer hMi = hM.intValue();
        Double iN = (Double) sp.get("immigrantNumber").getValue();
        Integer iNi = iN.intValue();
        Double nOT = (Double) sp.get("numberOfTurns").getValue();
        Integer nOTi = nOT.intValue();
        Double y = (Double) sp.get("year").getValue();
        Integer yi = y.intValue();
        globalsGW.addValues(
            new Value[] {
              ValueFactory.createValue((Double) sp.get("bufferSize").getValue()),
              ValueFactory.createValue((Double) sp.get("amenitiesWeighting").getValue()),
              ValueFactory.createValue((Double) sp.get("constructibilityWeighting").getValue()),
              ValueFactory.createValue((Double) sp.get("idealhousingWeighting").getValue()),
              ValueFactory.createValue((Double) sp.get("gaussDeviation").getValue()),
              ValueFactory.createValue((Double) sp.get("segregationThreshold").getValue()),
              ValueFactory.createValue((Double) sp.get("segregationTolerance").getValue()),
              ValueFactory.createValue(hMi),
              ValueFactory.createValue((Double) sp.get("movingThreshold").getValue()),
              ValueFactory.createValue(iNi),
              ValueFactory.createValue(nOTi),
              ValueFactory.createValue(yi),
              ValueFactory.createValue((Double) sp.get("threshold_1").getValue()),
              ValueFactory.createValue((Double) sp.get("threshold_2").getValue()),
              ValueFactory.createValue((Double) sp.get("threshold_3").getValue()),
              ValueFactory.createValue((Double) sp.get("threshold_4").getValue()),
            });

        // Table closing
        globalsGW.writeRowIndexes();
        globalsGW.writeExtent();
        globalsGW.writeWritenRowCount();
        globalsGW.close();

        try {
          if (spp.getSelections().get("statistical").isSelected()) {
            new LaunchFrame(configPath, "statistical");
          } else if (spp.getSelections().get("schelling").isSelected()) {
            new LaunchFrame(configPath, "schelling");
          }
        } catch (DriverException ex) {
          Services.getErrorManager().error("Driver Exception", ex);
          JOptionPane.showMessageDialog(
              this, "Some driver error has occurred.", "Driver Error", JOptionPane.WARNING_MESSAGE);
          return;
        } catch (DataSourceCreationException ex) {
          Services.getErrorManager().error("DataSourceCreation Exception", ex);
          JOptionPane.showMessageDialog(
              this,
              "Some DataSource creation error has occurred.",
              "DataSource Creation Error",
              JOptionPane.WARNING_MESSAGE);
          return;
        }
        dispose();
      } catch (IOException ex) {
        Services.getErrorManager().error("I/O Exception", ex);
        JOptionPane.showMessageDialog(
            this, "Some I/O error has occurred.", "I/O Error", JOptionPane.WARNING_MESSAGE);
        return;
      } catch (DriverException ex) {
        Services.getErrorManager().error("Driver Exception", ex);
        JOptionPane.showMessageDialog(
            this, "Some driver error has occurred.", "Driver Error", JOptionPane.WARNING_MESSAGE);
        return;
      }

    } else {
      try {
        new LaunchFrame(configPath, oldChoice);
      } catch (DriverException ex) {
        Services.getErrorManager().error("Driver Exception", ex);
        JOptionPane.showMessageDialog(
            this, "Some driver error has occurred.", "Driver Error", JOptionPane.WARNING_MESSAGE);
        return;
      } catch (DataSourceCreationException ex) {
        Services.getErrorManager().error("DataSourceCreation Exception", ex);
        JOptionPane.showMessageDialog(
            this,
            "Some DataSource creation error has occurred.",
            "DataSource Creation Error",
            JOptionPane.WARNING_MESSAGE);
        return;
      }
      dispose();
    }
  }
Esempio n. 26
0
 @Override
 public Value evaluateResult(DataSourceFactory dsf, Value[] args) throws FunctionException {
   return ValueFactory.createValue(args[0].getAsGeometry().getLength());
 }
Esempio n. 27
0
 @Override
 public Value getAggregateResult() {
   return ValueFactory.createValue(UnaryUnionOp.union(toUnite), crs);
 }
Esempio n. 28
0
 public Value getFieldValue(long rowIndex, int fieldId) throws DriverException {
   return ValueFactory.createValue(sum);
 }
 @Test
 public void testAllGeters() throws Exception {
   AllTypesObjectDriver testD = new AllTypesObjectDriver();
   DataSet test = testD.getTable("main");
   DataSource d = dsf.getDataSource("alltypes");
   d.open();
   assertTrue(
       ValueFactory.createValue(d.getBinary(0, 0))
           .equals(test.getFieldValue(0, 0))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getBinary(0, "binary"))
           .equals(test.getFieldValue(0, 0))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getBoolean(0, 1))
           .equals(test.getFieldValue(0, 1))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getBoolean(0, "boolean"))
           .equals(test.getFieldValue(0, 1))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getByte(0, 2)).equals(test.getFieldValue(0, 2)).getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getByte(0, "byte"))
           .equals(test.getFieldValue(0, 2))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getDate(0, 3)).equals(test.getFieldValue(0, 3)).getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getDate(0, "date"))
           .equals(test.getFieldValue(0, 3))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getDouble(0, 4))
           .equals(test.getFieldValue(0, 4))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getDouble(0, "double"))
           .equals(test.getFieldValue(0, 4))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getFloat(0, 5)).equals(test.getFieldValue(0, 5)).getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getFloat(0, "float"))
           .equals(test.getFieldValue(0, 5))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getInt(0, 6)).equals(test.getFieldValue(0, 6)).getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getInt(0, "int"))
           .equals(test.getFieldValue(0, 6))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getLong(0, 7)).equals(test.getFieldValue(0, 7)).getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getLong(0, "long"))
           .equals(test.getFieldValue(0, 7))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getShort(0, 8)).equals(test.getFieldValue(0, 8)).getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getShort(0, "short"))
           .equals(test.getFieldValue(0, 8))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getString(0, 9))
           .equals(test.getFieldValue(0, 9))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getString(0, "string"))
           .equals(test.getFieldValue(0, 9))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getTimestamp(0, 10))
           .equals(test.getFieldValue(0, 10))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getTimestamp(0, "timestamp"))
           .equals(test.getFieldValue(0, 10))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getTime(0, 11))
           .equals(test.getFieldValue(0, 11))
           .getAsBoolean());
   assertTrue(
       ValueFactory.createValue(d.getTime(0, "time"))
           .equals(test.getFieldValue(0, 11))
           .getAsBoolean());
   d.close();
 }
Esempio n. 30
0
 @Override
 protected Value evaluateResult(DataSourceFactory dsf, Value[] args) throws FunctionException {
   final Geometry g = args[0].getAsGeometry();
   final int n = args[1].getAsInt();
   return ValueFactory.createValue(g.getGeometryN(n), args[0].getCRS());
 }