Пример #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;
 }
Пример #2
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;
 }
Пример #3
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);
      }
    }
  }
Пример #4
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;
 }
Пример #5
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;
 }
Пример #6
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;
 }
Пример #7
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;
 }
Пример #8
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);
 }