Example #1
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#containsWay(org.openstreetmap.osmosis.core.domain.v0_5.Way)
  */
 public boolean containsWay(final Way aW) {
   if (myCachingDataSet.containsWay(aW)) return true;
   Way n = myDataSource.getWaysByID(aW.getId());
   if (n == null) return false;
   myCachingDataSet.addWay(n);
   return true;
 }
Example #2
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#containsNode(org.openstreetmap.osmosis.core.domain.v0_5.Node)
  */
 public boolean containsNode(final Node aW) {
   if (myCachingDataSet.containsNode(aW)) return true;
   Node n = myDataSource.getNodeByID(aW.getId());
   if (n == null) return false;
   cacheNode(n);
   return true;
 }
Example #3
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#containsRelation(org.openstreetmap.osmosis.core.domain.v0_5.Relation)
  */
 public boolean containsRelation(final Relation aR) {
   if (myCachingDataSet.containsRelation(aR)) return true;
   Relation n = myDataSource.getRelationByID(aR.getId());
   if (n == null) return false;
   myCachingDataSet.addRelation(n);
   return true;
 }
Example #4
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getRelationByID(long)
  */
 public Relation getRelationByID(final long aRelationID) {
   Relation n = myCachingDataSet.getRelationByID(aRelationID);
   if (n == null) {
     n = myDataSource.getRelationByID(aRelationID);
     if (n != null) myCachingDataSet.addRelation(n);
   }
   return n;
 }
Example #5
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getNodeByID(long)
  */
 public Node getNodeByID(final long aNodeID) {
   Node n = myCachingDataSet.getNodeByID(aNodeID);
   if (n == null) {
     n = myDataSource.getNodeByID(aNodeID);
     if (n != null) cacheNode(n);
   }
   return n;
 }
Example #6
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#getNearestNode(org.openstreetmap.osm.data.coordinates.LatLon,
  *     org.openstreetmap.osm.data.Selector)
  */
 public Node getNearestNode(final LatLon aLastGPSPos, final Selector aSelector) {
   Node n = myCachingDataSet.getNearestNode(aLastGPSPos, aSelector);
   if (n == null) {
     n = myDataSource.getNearestNode(aLastGPSPos, aSelector);
     if (n != null) cacheNode(n);
   }
   return n;
 }
Example #7
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getWaysByID(long)
  */
 public Way getWaysByID(final long aWayID) {
   Way n = myCachingDataSet.getWaysByID(aWayID);
   if (n == null) {
     n = myDataSource.getWaysByID(aWayID);
     if (n != null) myCachingDataSet.addWay(n);
   }
   return n;
 }
Example #8
0
  /**
   * We have to get all ways for each node cached to get no inconsistencies when {@link
   * #getWaysForNode(long)} is called.
   *
   * @param n the node to add to {@link #myCachingDataSet}.
   */
  private void cacheNode(final Node n) {
    myCachingDataSet.addNode(n);

    Iterator<Way> ways = myDataSource.getWaysForNode(n.getId());
    if (ways != null && ways.hasNext()) {
      while (ways.hasNext()) {
        Way way = ways.next();
        myCachingDataSet.addWay(way);
      }
    }
  }
Example #9
0
  public void add(IDataSet ds, String option) {
    this.collection.addDataSet(ds, option);
    if (this.collection.getCount() == 1) {
      try {
        this.padAxisFrame.setTitle(ds.getAttributes().getProperties().getProperty("title"));
        this.padAxisFrame.setXTitle(ds.getAttributes().getProperties().getProperty("xtitle"));
        this.padAxisFrame.setYTitle(ds.getAttributes().getProperties().getProperty("ytitle"));
      } catch (Exception e) {

      }
    }
    this.updateStatBox();
  }
Example #10
0
 /**
  * @param aKey a key to look for
  * @param aValue (may be null) a value for the give key to look for
  * @return all nodes containing the given key (with the given value is specified)
  */
 public Iterator<Node> getNodesByTag(final String aKey, final String aValue) {
   Iterator<Node> n = myCachingDataSet.getNodesByTag(aKey, aValue);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getNodesByTag(aKey, aValue);
     if (n != null && n.hasNext()) {
       LinkedList<Node> nodes = new LinkedList<Node>();
       while (n.hasNext()) {
         Node node = n.next();
         nodes.add(node);
         myCachingDataSet.addNode(node);
         return nodes.iterator();
       }
     }
   }
   return n;
 }
Example #11
0
 /**
  * @param aKey a key to look for
  * @param aValue (may be null) a value for the give key to look for
  * @return all ways containing the given key (with the given value is specified)
  */
 public Iterator<Way> getWaysByTag(final String aKey, final String aValue) {
   Iterator<Way> n = myCachingDataSet.getWaysByTag(aKey, aValue);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getWaysByTag(aKey, aValue);
     if (n != null && n.hasNext()) {
       LinkedList<Way> nodes = new LinkedList<Way>();
       while (n.hasNext()) {
         Way way = n.next();
         nodes.add(way);
         myCachingDataSet.addWay(way);
         return nodes.iterator();
       }
     }
   }
   return n;
 }
Example #12
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getWaysByName(java.lang.String)
  */
 public Iterator<Way> getWaysByName(final String aLookFor, final Bounds boundingbox) {
   Iterator<Way> n = myCachingDataSet.getWaysByName(aLookFor, boundingbox);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getWaysByName(aLookFor, boundingbox);
     if (n != null && n.hasNext()) {
       LinkedList<Way> nodes = new LinkedList<Way>();
       while (n.hasNext()) {
         Way way = n.next();
         nodes.add(way);
         myCachingDataSet.addWay(way);
       }
       return nodes.iterator();
     }
   }
   return n;
 }
Example #13
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getWays(org.openstreetmap.osm.data.coordinates.Bounds)
  */
 public Iterator<Way> getWays(final Bounds aBoundingBox) {
   Iterator<Way> n = myCachingDataSet.getWays(aBoundingBox);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getWays(aBoundingBox);
     if (n != null && n.hasNext()) {
       LinkedList<Way> nodes = new LinkedList<Way>();
       while (n.hasNext()) {
         Way node = n.next();
         nodes.add(node);
         myCachingDataSet.addWay(node);
         return nodes.iterator();
       }
     }
   }
   return n;
 }
Example #14
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getNodesByName(java.lang.String)
  */
 public Iterator<Node> getNodesByName(final String aLookFor) {
   Iterator<Node> n = myCachingDataSet.getNodesByName(aLookFor);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getNodesByName(aLookFor);
     if (n != null && n.hasNext()) {
       LinkedList<Node> nodes = new LinkedList<Node>();
       while (n.hasNext()) {
         Node node = n.next();
         nodes.add(node);
         cacheNode(node);
         return nodes.iterator();
       }
     }
   }
   return n;
 }
Example #15
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#getNodes(org.openstreetmap.osm.data.coordinates.Bounds)
  */
 public Iterator<Node> getNodes(final Bounds aBoundingBox) {
   Iterator<Node> n = myCachingDataSet.getNodes(aBoundingBox);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getNodes(aBoundingBox);
     if (n != null && n.hasNext()) {
       LinkedList<Node> nodes = new LinkedList<Node>();
       while (n.hasNext()) {
         Node node = n.next();
         nodes.add(node);
         cacheNode(node);
         return nodes.iterator();
       }
     }
   }
   return n;
 }
Example #16
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getWaysForNode(long)
  */
 public Iterator<Way> getWaysForNode(final long aNodeID) {
   Iterator<Way> n = myCachingDataSet.getWaysForNode(aNodeID);
   if (n == null || !n.hasNext()) {
     n = myDataSource.getWaysForNode(aNodeID);
     if (n != null && n.hasNext()) {
       LinkedList<Way> nodes = new LinkedList<Way>();
       while (n.hasNext()) {
         Way node = n.next();
         nodes.add(node);
         myCachingDataSet.addWay(node);
       }
       return nodes.iterator();
     }
   }
   return n;
 }
  public void setup() {
    if (databasePool != null) {
      DatabaseConnection database = null;
      IDataSet dataSet = null;
      try {
        database = databasePool.borrowInstance(this);
        dataSet = database.getDataSet(dbQuery, true);

        int keyIdx = dataSet.getFieldIndex(keyColumn);
        int valueIdx = dataSet.getFieldIndex(valueColumn);

        while (dataSet.next()) {
          String name = dataSet.getFieldValue(keyIdx).asString();
          String value = dataSet.getFieldValue(valueIdx).asString();
          getLocalPropertyMap().put(name, value);
        }
      } catch (Exception e) {
        throw new RuntimeException(e);
      } finally {
        if (dataSet != null) {
          dataSet.close();
        }

        if (database != null) {
          databasePool.returnInstance(database, this);
        }
      }
    }
  }
Example #18
0
  /**
   * Adds the tables of the DbUnit dataset to the given schema.
   *
   * @param dbUnitDataSet The DbUnit dataset containing the tables, not null
   * @param schema The schema to add the tables to, not null
   */
  protected void addTables(IDataSet dbUnitDataSet, Schema schema) throws DataSetException {
    ITableIterator dbUnitTableIterator = dbUnitDataSet.iterator();
    while (dbUnitTableIterator.next()) {
      ITable dbUnitTable = dbUnitTableIterator.getTable();
      String tableName = dbUnitTable.getTableMetaData().getTableName();

      List<String> primaryKeyColumnNames = getPrimaryKeyColumnNames(dbUnitTable);

      Table table = schema.getTable(tableName);
      if (table == null) {
        table = new Table(tableName);
        schema.addTable(table);
      }
      addRows(dbUnitTable, table, primaryKeyColumnNames);
    }
  }
Example #19
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#addWay(org.openstreetmap.osmosis.core.domain.v0_5.Way)
  */
 public void addWay(final Way aW) {
   myCachingDataSet.addWay(aW);
   myDataSource.addWay(aW);
 }
Example #20
0
 /**
  * ${@inheritDoc}.
  *
  * @see org.openstreetmap.osm.data.IDataSet#getWayHelper()
  */
 public WayHelper getWayHelper() {
   return myCachingDataSet.getWayHelper();
 }
Example #21
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#addRelation(org.openstreetmap.osmosis.core.domain.v0_5.Relation)
  */
 public void addRelation(final Relation aR) {
   myCachingDataSet.addRelation(aR);
   myDataSource.addRelation(aR);
 }
Example #22
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#addNode(org.openstreetmap.osmosis.core.domain.v0_5.Node)
  */
 public void addNode(final Node aW) {
   myDataSource.addNode(aW);
   cacheNode(aW);
 }
Example #23
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#removeWay(org.openstreetmap.osmosis.core.domain.v0_5.Way)
  */
 public void removeWay(final Way aW) {
   myCachingDataSet.removeWay(aW);
   myDataSource.removeWay(aW);
 }
Example #24
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#removeRelation(org.openstreetmap.osmosis.core.domain.v0_5.Relation)
  */
 public void removeRelation(final Relation aR) {
   myCachingDataSet.removeRelation(aR);
   myDataSource.removeRelation(aR);
 }
Example #25
0
 /**
  * ${@inheritDoc}.
  *
  * @see
  *     org.openstreetmap.osm.data.IDataSet#removeNode(org.openstreetmap.osmosis.core.domain.v0_5.Node)
  */
 public void removeNode(final Node aW) {
   myCachingDataSet.removeNode(aW);
   myDataSource.removeNode(aW);
 }