Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Import bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Camilleh9 committed Dec 6, 2014
1 parent 725a694 commit 66ee2cb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 54 deletions.
Binary file modified OSM2Hive.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions src/main/info/pavie/osm2hive/controller/HiveImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class HiveImporter extends GenericUDTF {
protected StringObjectInspector stringOI;

/** OSM XML Parser **/
protected OSMParser parser;
protected static OSMParser parser = new OSMParser();

/** Parsed OSM elements **/
protected Map<String,Element> elements;
Expand All @@ -48,7 +48,6 @@ protected void checkParameterOI(ObjectInspector[] argOIs) throws UDFArgumentExce
}

this.stringOI = (StringObjectInspector) arg1;
this.parser = new OSMParser();
}

/**
Expand Down
34 changes: 17 additions & 17 deletions src/main/info/pavie/osm2hive/controller/OSMParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import info.pavie.osm2hive.model.xml.InvalidMarkupException;
import info.pavie.osm2hive.model.xml.Markup;

import java.util.LinkedList;
import java.util.List;

/**
* This class parses OSM XML file, line by line.
* It uses the XML {@link Markup} parser, and create {@link Element}s objects.
Expand All @@ -20,12 +17,15 @@ public class OSMParser {
/** The element being parsed **/
private Element current;

/** The last parsed element **/
private Element lastParsed;

/** Is the current element ready (ie completely parsed) ? **/
private boolean isCurrentReady;

//TODO Remove, debug purposes only
/** Last read lines **/
private List<String> lastLines;
// /** Last read lines **/
// private List<String> lastLines = new LinkedList<String>();
//ENDTODO

//CONSTRUCTORS
Expand All @@ -34,10 +34,8 @@ public class OSMParser {
*/
public OSMParser() {
current = null;
lastParsed = null;
isCurrentReady = false;
//TODO Remove, debug purposes only
lastLines = new LinkedList<String>();
//ENDTODO
}

//ACCESSORS
Expand All @@ -52,7 +50,7 @@ public boolean isElementReady() {
* @return The current element, or null if not ready.
*/
public Element getCurrentElement() {
return (isCurrentReady) ? current : null;
return (isCurrentReady) ? lastParsed : null;
}

//OTHER METHODS
Expand Down Expand Up @@ -91,10 +89,10 @@ public void parse(String line) throws InvalidMarkupException {
Markup m = new Markup(line); //Parse the line

//TODO Remove, debug purposes only
lastLines.add(line);
if(lastLines.size() > 20) {
lastLines.remove(0);
}
// lastLines.add(line);
// if(lastLines.size() > 20) {
// lastLines.remove(0);
// }
//ENDTODO

switch(m.getType()) {
Expand Down Expand Up @@ -243,13 +241,15 @@ private void endMarkup(Markup m) {
|| (m.getName().equals("relation") && current instanceof Relation && ((Relation) current).getMembers().size() > 0)) {

isCurrentReady = true;
lastParsed = current;
current = null;
}
} else {
//TODO Remove, debug purposes only
System.err.println("End markup not matching: "+m.getName()+" with current object "+current);
for(String s : lastLines) {
System.err.println(s);
}
//TODO Remove, debug purposes only
// for(String s : lastLines) {
// System.err.println(s);
// }
//ENDTODO
}
} else {
Expand Down
35 changes: 0 additions & 35 deletions src/main/info/pavie/osm2hive/model/xml/TransitionListener.java

This file was deleted.

0 comments on commit 66ee2cb

Please sign in to comment.