Java Code Examples for com.vividsolutions.jts.util.Assert#equals()

The following examples show how to use com.vividsolutions.jts.util.Assert#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConvexHull.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 *@param  vertices  the vertices of a linear ring, which may or may not be
 *      flattened (i.e. vertices collinear)
 *@return           the coordinates with unnecessary (collinear) vertices
 *      removed
 */
private Coordinate[] cleanRing(Coordinate[] original) {
  Assert.equals(original[0], original[original.length - 1]);
  ArrayList<Coordinate> cleanedRing = new ArrayList<Coordinate>();
  Coordinate previousDistinctCoordinate = null;
  for (int i = 0; i <= original.length - 2; i++) {
    Coordinate currentCoordinate = original[i];
    Coordinate nextCoordinate = original[i+1];
    if (currentCoordinate.equals(nextCoordinate)) {
      continue;
    }
    if (previousDistinctCoordinate != null
        && isBetween(previousDistinctCoordinate, currentCoordinate, nextCoordinate)) {
      continue;
    }
    cleanedRing.add(currentCoordinate);
    previousDistinctCoordinate = currentCoordinate;
  }
  cleanedRing.add(original[original.length - 1]);
  Coordinate[] cleanedRingCoordinates = new Coordinate[cleanedRing.size()];
  return cleanedRing.toArray(cleanedRingCoordinates);
}
 
Example 2
Source File: ClassificationPropagationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void deletePropagatedClassificationExpectFail(AtlasEntity entity, AtlasClassification classification) {
    try {
        deletePropagatedClassification(entity, classification);
        fail();
    } catch (AtlasBaseException ex) {
        Assert.equals(ex.getAtlasErrorCode(), PROPAGATED_CLASSIFICATION_REMOVAL_NOT_SUPPORTED);
    }
}
 
Example 3
Source File: TestMultithreadedTableProvider.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Test
public void addTableNotPartitioned() throws InterruptedException, StageException {
  String schema = "db";
  String table1Name = "table1";
  String table2Name = "table2";
  String offsetCol = null;
  final String partitionSize = null;
  int maxActivePartitions = 0;
  int threadNumber = 0;
  int numThreads = 1;

  TableContext table1 = createTableContext(schema, table1Name, offsetCol, partitionSize, maxActivePartitions, true);

  MultithreadedTableProvider provider = createTableProvider(numThreads, table1, BatchTableStrategy.PROCESS_ALL_AVAILABLE_ROWS_FROM_TABLE);

  TableRuntimeContext tableRuntimeContext = provider.nextTable(threadNumber);
  Assert.equals(table1Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);

  tableRuntimeContext = provider.nextTable(threadNumber);
  Assert.equals(table1Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);

  TableContext table2 = createTableContext(schema, table2Name, offsetCol, partitionSize, maxActivePartitions, true);
  Map<String, TableContext> tableContextMap = new HashMap<>();

  tableContextMap.put(table1.getQualifiedName(), table1);
  tableContextMap.put(table2.getQualifiedName(), table2);
  Queue<String> sortedTableOrder = new LinkedList<>();
  sortedTableOrder.add(table1.getQualifiedName());
  sortedTableOrder.add(table2.getQualifiedName());

  //Set added table lists
  provider.setTableContextMap(tableContextMap, sortedTableOrder);

  tableRuntimeContext = provider.nextTable(threadNumber);

  Assert.equals(table1Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);

  tableRuntimeContext = provider.nextTable(threadNumber);
  Assert.equals(table2Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);
}
 
Example 4
Source File: TestMultithreadedTableProvider.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Test
public void removeTableNotPartitioned() throws InterruptedException, StageException {
  String schema = "db";
  String table1Name = "table1";
  String table2Name = "table2";
  String offsetCol = null;
  final String partitionSize = null;
  int maxActivePartitions = 0;
  int threadNumber = 0;
  int numThreads = 1;

  TableContext table1 = createTableContext(schema, table1Name, offsetCol, partitionSize, maxActivePartitions, true);
  TableContext table2 = createTableContext(schema, table2Name, offsetCol, partitionSize, maxActivePartitions, true);
  Map<String, TableContext> tableContextMap = new HashMap<>();

  tableContextMap.put(table1.getQualifiedName(), table1);
  tableContextMap.put(table2.getQualifiedName(), table2);
  Queue<String> sortedTableOrder = new LinkedList<>();
  sortedTableOrder.add(table1.getQualifiedName());
  sortedTableOrder.add(table2.getQualifiedName());

  Map threadNumToMaxTableSlots = new HashMap<>();

  BatchTableStrategy batchTableStrategy = BatchTableStrategy.PROCESS_ALL_AVAILABLE_ROWS_FROM_TABLE;
  MultithreadedTableProvider provider = new MultithreadedTableProvider(
      tableContextMap,
      sortedTableOrder,
      threadNumToMaxTableSlots,
      numThreads,
      batchTableStrategy,
      (ctx) -> {} // do-nothing implementation
  );

  TableRuntimeContext tableRuntimeContext = provider.nextTable(threadNumber);
  Assert.equals(table1Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);

  tableRuntimeContext = provider.nextTable(threadNumber);
  Assert.equals(table2Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);

  tableContextMap.remove(table2.getQualifiedName());
  sortedTableOrder.remove(table2.getQualifiedName());
  //Set removed table lists
  provider.setTableContextMap(tableContextMap, sortedTableOrder);

  tableRuntimeContext = provider.nextTable(threadNumber);

  Assert.equals(table1Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);

  tableRuntimeContext = provider.nextTable(threadNumber);
  Assert.equals(table1Name, tableRuntimeContext.getSourceTableContext().getTableName());
  provider.releaseOwnedTable(tableRuntimeContext, threadNumber);
}
 
Example 5
Source File: HalfEdge.java    From jts with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Insert an edge with the same origin after this one.
 * Assumes that the inserted edge is in the correct
 * position around the ring.
 * 
 * @param e the edge to insert (with same origin)
 */
private void insertAfter(HalfEdge e) {
  Assert.equals(orig, e.orig());
  HalfEdge save = oNext();
  sym.setNext(e);
  e.sym().setNext(save);
}