Esempio n. 1
0
void OgrWriter::writePartial(const boost::shared_ptr<const hoot::Node>& newNode)
{
  // Add to the element cache
  ConstElementPtr myNode(newNode);
  _elementCache->addElement(myNode);
  ElementProviderPtr cacheProvider(_elementCache);

  // It's a base datatype, so can write immediately

  //LOG_DEBUG("Writing node " << newNode->getId() << " as it's in our range");

  _writePartial(cacheProvider, newNode);
}
Esempio n. 2
0
void OgrWriter::writePartial(const boost::shared_ptr<const hoot::Way>& newWay)
{
  /*
   * Make sure this way has any hope of working (i.e., are there enough spots in the cache
   * for all its nodes?
   */
  if ((long)newWay->getNodeCount() > _currElementCacheCapacity )
  {
    LOG_FATAL("Cannot do partial write of Way ID " << newWay->getId() <<
      " as it contains " << newWay->getNodeCount() << " nodes but our cache can only hold " <<
      _currElementCacheCapacity );
    throw HootException("Cannot stream write way with more nodes than our cache can hold");
  }

  // Make sure all the nodes in the way are in our cache
  const std::vector<long> wayNodeIds = newWay->getNodeIds();
  std::vector<long>::const_iterator nodeIdIterator;

  for ( nodeIdIterator = wayNodeIds.begin(); nodeIdIterator != wayNodeIds.end(); nodeIdIterator++ )
  {
    if ( _elementCache->containsNode(*nodeIdIterator) == true )
    {
      /*
      LOG_DEBUG("Way " << newWay->getId() << " contains node " << *nodeIdIterator <<
                   ": " << _elementCache->getNode(*nodeIdIterator)->getX() << ", " <<
                  _elementCache->getNode(*nodeIdIterator)->getY() );
      */
    }
    else
    {
      LOG_FATAL("Way " << newWay->getId() << " contains node " << *nodeIdIterator <<
        " which is NOT PRESENT in the cache");

      throw HootException("Way contains node which is NOT present in the cache!");
    }
  }

  //LOG_INFO("Writing way " << newWay->getId() );

  // Add to the element cache
  ConstElementPtr constWay(newWay);
  _elementCache->addElement(constWay);

  ElementProviderPtr cacheProvider(_elementCache);
  _writePartial(cacheProvider, newWay);
}
Esempio n. 3
0
void OgrWriter::writePartial(const boost::shared_ptr<const hoot::Node>& newNode)
{
  // Add to the element cache
  ConstElementPtr myNode(newNode);
  _elementCache->addElement(myNode);
  ElementProviderPtr cacheProvider(_elementCache);

  // It's a base datatype, so can write immediately

  //LOG_DEBUG("Writing node: \n" << newNode->toString());

  // DEBUG ONLY REMOVE -- if we're not Queen Anne's county, MD, bail
  /*
  if ( newNode->getId() > -642 || newNode->getId() < -733)
  {
    return;
  }
  */

  //LOG_INFO("Writing node " << newNode->getId() << " as it's in our range");

  _writePartial(cacheProvider, newNode);
}
Esempio n. 4
0
void OgrWriter::writePartial(const boost::shared_ptr<const hoot::Relation>& newRelation)
{
  // Make sure all the elements in the relation are in the cache
  const std::vector<RelationData::Entry>& relationEntries = newRelation->getMembers();

  std::vector<RelationData::Entry>::const_iterator relationElementIter;
  long nodeCount = 0;
  long wayCount = 0;
  long relationCount = 0;

  for ( relationElementIter = relationEntries.begin();
      relationElementIter != relationEntries.end();
      relationElementIter++ )
  {
    switch ( relationElementIter->getElementId().getType().getEnum() )
    {
      case ElementType::Node:
        nodeCount++;
        if ( nodeCount > _currElementCacheCapacity )
        {
          LOG_FATAL("Relation ID " << newRelation->getId() <<
            " contains more nodes than can fit in the cache (" << _currElementCacheCapacity<<
            ")");
          throw HootException("Relation with too many nodes");
        }
        break;
      case ElementType::Way:
        wayCount++;
        if ( wayCount > _currElementCacheCapacity)
        {
          LOG_FATAL("Relation ID " << newRelation->getId() <<
            " contains more ways than can fit in the cache (" << _currElementCacheCapacity <<
            ")");
          throw HootException("Relation with too many ways");
        }

        break;
      case ElementType::Relation:
        relationCount++;
        if ( relationCount > _currElementCacheCapacity)
        {
          LOG_FATAL("Relation ID " << newRelation->getId() <<
            " contains more relations than can fit in the cache (" << _currElementCacheCapacity <<
            ")");
          throw HootException("Relation with too many relations");
        }

        break;
      default:
        throw HootException("Relation containus unknown type");
        break;
    }

    if ( _elementCache->containsElement(relationElementIter->getElementId()) == false )
    {
      throw HootException("Relation element did not exist in cache");
    }
  }

  // Add to the cache
  ConstElementPtr constRelation(newRelation);
  _elementCache->addElement(constRelation);

  ElementProviderPtr cacheProvider(_elementCache);
    _writePartial(cacheProvider, newRelation);
}