X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FSearchOsmPoisXmlHandler.java;fp=tim%2Fprune%2Ffunction%2FSearchOsmPoisXmlHandler.java;h=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hp=5683ece37da8f6aeec4dcf9ed250a2da2a3d2c42;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465;p=GpsPrune.git diff --git a/tim/prune/function/SearchOsmPoisXmlHandler.java b/tim/prune/function/SearchOsmPoisXmlHandler.java deleted file mode 100644 index 5683ece..0000000 --- a/tim/prune/function/SearchOsmPoisXmlHandler.java +++ /dev/null @@ -1,92 +0,0 @@ -package tim.prune.function; - -import java.util.ArrayList; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import tim.prune.function.search.SearchResult; - -/** - * XML handler for dealing with XML returned from the OSM Overpass api, - * specially for the OSM Poi service - */ -public class SearchOsmPoisXmlHandler extends DefaultHandler -{ - private ArrayList _pointList = null; - private SearchResult _currPoint = null; - private String _errorMessage = null; - - - /** - * React to the start of an XML tag - */ - public void startElement(String inUri, String inLocalName, String inTagName, - Attributes inAttributes) throws SAXException - { - if (inTagName.equals("osm")) { - _pointList = new ArrayList(); - } - else if (inTagName.equals("node")) - { - _currPoint = new SearchResult(); - _currPoint.setLatitude(inAttributes.getValue("lat")); - _currPoint.setLongitude(inAttributes.getValue("lon")); - } - else if (inTagName.equals("tag") && _currPoint != null) { - processTag(inAttributes); - } - super.startElement(inUri, inLocalName, inTagName, inAttributes); - } - - /** - * @param inAttributes attributes to process - */ - private void processTag(Attributes inAttributes) - { - String key = inAttributes.getValue("k"); - if (key != null) - { - String value = inAttributes.getValue("v"); - if (key.equals("name")) - { - _currPoint.setTrackName(value); - } - else if (key.equals("amenity") || key.equals("highway") || key.equals("railway")) - { - _currPoint.setPointType(value); - } - } - } - - /** - * React to the end of an XML tag - */ - public void endElement(String inUri, String inLocalName, String inTagName) - throws SAXException - { - if (inTagName.equals("node")) - { - // end of the entry - if (_currPoint.getTrackName() != null && !_currPoint.getTrackName().equals("")) - _pointList.add(_currPoint); - } - super.endElement(inUri, inLocalName, inTagName); - } - - /** - * @return the list of points - */ - public ArrayList getPointList() - { - return _pointList; - } - - /** - * @return error message, if any - */ - public String getErrorMessage() { - return _errorMessage; - } -}