Package org.openstreetmap.osmosis.core

Examples of org.openstreetmap.osmosis.core.OsmosisRuntimeException


            DataSourceUtils.releaseConnection(connection, dataSource);

            return result;

        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to check for the existence of column " + tableName + "."
                    + columnName + ".", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
View Full Code Here


            DataSourceUtils.releaseConnection(connection, dataSource);

            return result;

        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to check for the existence of table " + tableName + ".", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
View Full Code Here

     
        inStream.close();
      inStream = null;
     
      } catch (IOException e) {
        throw new OsmosisRuntimeException("Unable to process COPY file " + copyFile + ".", e);
      } catch (SQLException e) {
        throw new OsmosisRuntimeException("Unable to process COPY file " + copyFile + ".", e);
      } finally {
        if (inStream != null) {
        try {
          inStream.close();
        } catch (IOException e) {
View Full Code Here

  protected void populateCommonEntityParameters(Map<String, Object> args, Entity entity) {
    Map<String, String> tags;
   
    // We can't write an entity with a null timestamp.
    if (entity.getTimestamp() == null) {
      throw new OsmosisRuntimeException(
          "Entity(" + entity.getType() + ") " + entity.getId() + " does not have a timestamp set.");
    }
   
    tags = new HashMap<String, String>(entity.getTags().size());
    for (Tag tag : entity.getTags()) {
View Full Code Here

  private double getRequiredDoubleValue(Attributes attributes, String attributeName) {
    String valueString = attributes.getValue(attributeName);

    if (valueString == null) {
      throw new OsmosisRuntimeException(String.format(
          "Required attribute %s of the bounds element is missing", attributeName));
    }
    try {
      return Double.parseDouble(valueString);
    } catch (NumberFormatException e) {
      throw new OsmosisRuntimeException(
          String.format("Cannot parse the %s attribute of the bounds element", attributeName),
          e);
    }
  }
View Full Code Here

 
 
  private void initializeAddStage() {
    // We can't add if we've passed the add stage.
    if (stage.compareTo(StorageStage.Add) > 0) {
      throw new OsmosisRuntimeException("Cannot add to storage in stage " + stage + ".");
    }
   
    // If we're not up to the add stage, initialise for adding.
    if (stage.compareTo(StorageStage.Add) < 0) {
      try {
        nodeStorageFile = File.createTempFile("nodelatlon", null);
       
        fileOutStream = new FileOutputStream(nodeStorageFile);
        dataOutStream = new DataOutputStream(new BufferedOutputStream(fileOutStream, 65536));
        currentFileOffset = 0;
       
        stage = StorageStage.Add;
       
      } catch (IOException e) {
        throw new OsmosisRuntimeException(
            "Unable to create object stream writing to temporary file " + nodeStorageFile + ".", e);
      }
    }
  }
View Full Code Here

  private static Map<String, EntityType> memberToEntityMap;
 
 
  private static void addEntityTypeMapping(EntityType entityType, String memberType) {
    if (entityToMemberMap.containsKey(entityType)) {
      throw new OsmosisRuntimeException("Entity type (" + entityType + ") already has a mapping.");
    }
   
    entityToMemberMap.put(entityType, memberType);
    memberToEntityMap.put(memberType, entityType);
  }
View Full Code Here

      return;
    }
   
    // If we've been released, we can't iterate.
    if (stage.compareTo(StorageStage.Released) >= 0) {
      throw new OsmosisRuntimeException("Cannot read from node storage in stage " + stage + ".");
    }
   
    // If no data was written, writing should be initialized before reading.
    if (stage.compareTo(StorageStage.NotStarted) <= 0) {
      initializeAddStage();
    }
   
    // If we're in the add stage, close the output streams.
    if (stage.compareTo(StorageStage.Add) == 0) {
      try {
        dataOutStream.close();
        fileOutStream.close();
       
      } catch (IOException e) {
        throw new OsmosisRuntimeException("Unable to close output stream.", e);
      } finally {
        dataOutStream = null;
        fileOutStream = null;
      }
     
      try {
        fileInStream = new BufferedRandomAccessFileInputStream(nodeStorageFile);
        dataInStream = new DataInputStream(fileInStream);
       
      } catch (IOException e) {
        throw new OsmosisRuntimeException("Unable to open the node data file " + nodeStorageFile + ".", e);
      }
     
      stage = StorageStage.Reading;
    }
  }
View Full Code Here

   
    initializeAddStage();
   
    // We can only add nodes in sorted order.
    if (nodeId <= lastNodeId) {
      throw new OsmosisRuntimeException(
        "The node id of " + nodeId
        + " must be greater than the previous id of "
        + lastNodeId + "."
      );
    }
    lastNodeId = nodeId;
   
    try {
      // Write zeros to the file where no node data is available.
      requiredFileOffset = nodeId * NODE_DATA_SIZE;
      if (requiredFileOffset > currentFileOffset) {
        while (currentFileOffset < requiredFileOffset) {
          long offsetDifference;
         
          offsetDifference = requiredFileOffset - currentFileOffset;
          if (offsetDifference > ZERO_BUFFER_SIZE) {
            offsetDifference = ZERO_BUFFER_SIZE;
          }
         
          dataOutStream.write(zeroBuffer, 0, (int) offsetDifference);
         
          currentFileOffset += offsetDifference;
        }
      }
     
      // Write the node data. Prefix with a non-zero byte to identify that
      // data is available for this node.
      dataOutStream.writeByte(1);
      dataOutStream.writeInt(FixedPrecisionCoordinateConvertor.convertToFixed(nodeLocation.getLongitude()));
      dataOutStream.writeInt(FixedPrecisionCoordinateConvertor.convertToFixed(nodeLocation.getLatitude()));
      currentFileOffset += NODE_DATA_SIZE;
     
    } catch (IOException e) {
      throw new OsmosisRuntimeException(
        "Unable to write node location data to node storage file "
          + nodeStorageFile + ".",
        e
      );
    }
View Full Code Here

   */
  public String getMemberType(EntityType entityType) {
    if (entityToMemberMap.containsKey(entityType)) {
      return entityToMemberMap.get(entityType);
    } else {
      throw new OsmosisRuntimeException("The entity type " + entityType + " is not recognised.");
    }
  }
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.OsmosisRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.