private void parseOsmElement(final String name,final Attributes atts) throws OsmParseException {
  try {
    long osmId=Long.parseLong(atts.getValue("id"));
    String version=atts.getValue("version");
    long osmVersion=version == null ? 0 : Long.parseLong(atts.getValue("version"));
    String action=atts.getValue("action");
    byte status=OsmElement.STATE_UNCHANGED;
    if (action != null) {
      if (action.equalsIgnoreCase("modify")) {
        status=OsmElement.STATE_MODIFIED;
        if (osmId < 0) {
          status=OsmElement.STATE_CREATED;
        }
      }
 else       if (action.equalsIgnoreCase("delete")) {
        status=OsmElement.STATE_DELETED;
      }
    }
    if (isNode(name)) {
      int lat=(int)(Double.valueOf(atts.getValue("lat")) * 1E7);
      int lon=(int)(Double.valueOf(atts.getValue("lon")) * 1E7);
      currentNode=OsmElementFactory.createNode(osmId,osmVersion,status,lat,lon);
    }
 else     if (isWay(name)) {
      currentWay=OsmElementFactory.createWay(osmId,osmVersion,status);
      if (nodeIndex == null) {
        nodeIndex=storage.getNodeIndex();
      }
    }
 else     if (isRelation(name)) {
      currentRelation=OsmElementFactory.createRelation(osmId,osmVersion,status);
      if (nodeIndex == null) {
        nodeIndex=storage.getNodeIndex();
      }
      if (wayIndex == null) {
        wayIndex=storage.getWayIndex();
      }
    }
 else {
      throw new OsmParseException("Unknown element " + name);
    }
  }
 catch (  NumberFormatException e) {
    throw new OsmParseException("Element unparsable");
  }
}

private void parseOsmElement ( final String name , final Attributes atts ) throws OsmParseException { try { long osmId = Long . parseLong ( atts . getValue ( "id" ) ) ; String version = atts . getValue ( "version" ) ; long osmVersion = version == null ? 0 : Long . parseLong ( atts . getValue ( "version" ) ) ; String action = atts . getValue ( "action" ) ; byte status = OsmElement . STATE_UNCHANGED ; if ( action != null ) { if ( action . equalsIgnoreCase ( "modify" ) ) { status = OsmElement . STATE_MODIFIED ; if ( osmId < 0 ) { status = OsmElement . STATE_CREATED ; } } else if ( action . equalsIgnoreCase ( "delete" ) ) { status = OsmElement . STATE_DELETED ; } } if ( isNode ( name ) ) { int lat = ( int ) ( Double . valueOf ( atts . getValue ( "lat" ) ) * 1E7 ) ; int lon = ( int ) ( Double . valueOf ( atts . getValue ( "lon" ) ) * 1E7 ) ; currentNode = OsmElementFactory . createNode ( osmId , osmVersion , status , lat , lon ) ; } else if ( isWay ( name ) ) { currentWay = OsmElementFactory . createWay ( osmId , osmVersion , status ) ; if ( nodeIndex == null ) { nodeIndex = storage . getNodeIndex ( ) ; } } else if ( isRelation ( name ) ) { currentRelation = OsmElementFactory . createRelation ( osmId , osmVersion , status ) ; if ( nodeIndex == null ) { nodeIndex = storage . getNodeIndex ( ) ; } if ( wayIndex == null ) { wayIndex = storage . getWayIndex ( ) ; } } else { throw new OsmParseException ( "Unknown element " + name ) ; } } catch ( NumberFormatException e ) { throw new OsmParseException ( "Element unparsable" ) ; } }
parse api 0 . 6 output and josm osm files
